Skip to content

Commit

Permalink
Update to latest Swift version
Browse files Browse the repository at this point in the history
  • Loading branch information
Eric Hyche committed Feb 7, 2022
1 parent a8f98fe commit 96e5109
Show file tree
Hide file tree
Showing 13 changed files with 79 additions and 79 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@
developmentRegion = English;
hasScannedForEncodings = 0;
knownRegions = (
English,
en,
Base,
);
Expand Down Expand Up @@ -329,7 +330,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 10.3;
IPHONEOS_DEPLOYMENT_TARGET = 15.2;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
Expand Down Expand Up @@ -374,7 +375,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 10.3;
IPHONEOS_DEPLOYMENT_TARGET = 15.2;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
Expand All @@ -392,7 +393,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = org.erichyche.LearnAboutStackViews;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 5.0;
};
name = Debug;
};
Expand All @@ -405,7 +406,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = org.erichyche.LearnAboutStackViews;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 5.0;
};
name = Release;
};
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?


func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
return true
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import UIKit
struct EHPinningOptions: OptionSet {
let rawValue: Int

static let none = EHPinningOptions(rawValue: 0)
static let none = EHPinningOptions([])
static let leading = EHPinningOptions(rawValue: 1 << 0)
static let centerX = EHPinningOptions(rawValue: 1 << 1)
static let trailing = EHPinningOptions(rawValue: 1 << 2)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ class EHMultipleChoiceViewController: UIViewController {
rowStackView.distribution = .fill
rowStackView.alignment = .center
rowStackView.isLayoutMarginsRelativeArrangement = true
rowStackView.layoutMargins = UIEdgeInsetsMake(10.0, 10.0, 10.0, 10.0)
rowStackView.layoutMargins = UIEdgeInsets(top: 10.0, left: 10.0, bottom: 10.0, right: 10.0)
let rowLabel = UILabel(frame: .zero)
rowLabel.font = UIFont(name: "OpenSans-Semibold", size: 14.0)
rowLabel.textColor = textColorEnabled
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,10 @@ class EHStackViewContentViewController: UIViewController {
scrollView.translatesAutoresizingMaskIntoConstraints = false
view.addSubview(scrollView)

scrollView.topAnchor.constraint(equalTo: view.topAnchor).isActive = true
scrollView.leadingAnchor.constraint(equalTo: view.leadingAnchor).isActive = true
scrollView.trailingAnchor.constraint(equalTo: view.trailingAnchor).isActive = true
scrollView.bottomAnchor.constraint(equalTo: bottomLayoutGuide.topAnchor).isActive = true
scrollView.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor).isActive = true
scrollView.leadingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.leadingAnchor).isActive = true
scrollView.trailingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.trailingAnchor).isActive = true
scrollView.bottomAnchor.constraint(equalTo: view.safeAreaLayoutGuide.bottomAnchor).isActive = true

stackView.translatesAutoresizingMaskIntoConstraints = false
stackView.axis = .vertical
Expand Down Expand Up @@ -184,7 +184,7 @@ class EHStackViewContentViewController: UIViewController {
nameLabel.text = titleText(forArrangedSubview: view)
nameLabel.textColor = UIColor.black
nameLabel.font = UIFont(name: "OpenSans-Semibold", size: 14.0)
nameLabel.setContentHuggingPriority(UILayoutPriorityDefaultLow-1, for: .horizontal)
nameLabel.setContentHuggingPriority(UILayoutPriority.defaultLow-1, for: .horizontal)

let deleteImageView = UIImageView(image: UIImage(named: "trash-can"))
deleteImageView.isUserInteractionEnabled = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ typealias EHStackViewSettingsAnimationBlock = () -> Void
typealias EHStackViewSettingsCompletionBlock = (_ finished: Bool) -> Void

struct EHStackViewSettingsModel {
var axis: UILayoutConstraintAxis
var distribution: UIStackViewDistribution
var alignment: UIStackViewAlignment
var axis: NSLayoutConstraint.Axis
var distribution: UIStackView.Distribution
var alignment: UIStackView.Alignment
var spacing: CGFloat
var isBaselineRelativeArrangement: Bool
var isLayoutMarginsRelativeArrangement: Bool
Expand Down Expand Up @@ -108,8 +108,8 @@ extension EHStackViewSettingsModel {
if let firstView = constraint.firstItem as? UIView,
let secondView = constraint.secondItem as? UIView {
// Sort out which is the stack view and which is the container view
var stackViewAttribute: NSLayoutAttribute = .notAnAttribute
var containerViewAttribute: NSLayoutAttribute = .notAnAttribute
var stackViewAttribute: NSLayoutConstraint.Attribute = .notAnAttribute
var containerViewAttribute: NSLayoutConstraint.Attribute = .notAnAttribute
if firstView == stackView && secondView == containerView {
stackViewAttribute = constraint.firstAttribute
containerViewAttribute = constraint.secondAttribute
Expand All @@ -127,7 +127,7 @@ extension EHStackViewSettingsModel {
}


static func pinningOption(stackViewAttribute: NSLayoutAttribute, containerViewAttribute: NSLayoutAttribute) -> EHPinningOptions {
static func pinningOption(stackViewAttribute: NSLayoutConstraint.Attribute, containerViewAttribute: NSLayoutConstraint.Attribute) -> EHPinningOptions {
var option: EHPinningOptions = EHPinningOptions.none

switch (stackViewAttribute,containerViewAttribute) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,17 +70,17 @@ class EHStackViewSettingsViewController: UIViewController {
scrollView.translatesAutoresizingMaskIntoConstraints = false
view.addSubview(scrollView)

scrollView.topAnchor.constraint(equalTo: view.topAnchor).isActive = true
scrollView.leadingAnchor.constraint(equalTo: view.leadingAnchor).isActive = true
scrollView.trailingAnchor.constraint(equalTo: view.trailingAnchor).isActive = true
scrollView.bottomAnchor.constraint(equalTo: bottomLayoutGuide.topAnchor).isActive = true
scrollView.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor).isActive = true
scrollView.leadingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.leadingAnchor).isActive = true
scrollView.trailingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.trailingAnchor).isActive = true
scrollView.bottomAnchor.constraint(equalTo: view.safeAreaLayoutGuide.bottomAnchor).isActive = true

displayStackView.translatesAutoresizingMaskIntoConstraints = false
displayStackView.axis = .vertical
displayStackView.distribution = .fill
displayStackView.alignment = .fill
displayStackView.isLayoutMarginsRelativeArrangement = true
displayStackView.layoutMargins = UIEdgeInsetsMake(20.0, 10.0, 20.0, 10.0)
displayStackView.layoutMargins = UIEdgeInsets(top: 20.0, left: 10.0, bottom: 20.0, right: 10.0)
displayStackView.spacing = 8.0

scrollView.addSubview(displayStackView)
Expand Down Expand Up @@ -241,7 +241,7 @@ class EHStackViewSettingsViewController: UIViewController {
nameLabel.text = name
nameLabel.textColor = UIColor.black
nameLabel.font = UIFont(name: "OpenSans-Semibold", size: 14.0)
nameLabel.setContentHuggingPriority(UILayoutPriorityDefaultLow-1, for: .horizontal)
nameLabel.setContentHuggingPriority(UILayoutPriority.defaultLow-1, for: .horizontal)
nameLabel.isUserInteractionEnabled = true

let valueLabel = UILabel(frame: .zero)
Expand Down Expand Up @@ -275,7 +275,7 @@ class EHStackViewSettingsViewController: UIViewController {
nameLabel.text = name
nameLabel.textColor = UIColor.black
nameLabel.font = UIFont(name: "OpenSans-Semibold", size: 14.0)
nameLabel.setContentHuggingPriority(UILayoutPriorityDefaultLow-1, for: .horizontal)
nameLabel.setContentHuggingPriority(UILayoutPriority.defaultLow-1, for: .horizontal)

let valueSwitch = UISwitch(frame: .zero)
valueSwitch.isOn = value
Expand All @@ -297,7 +297,7 @@ class EHStackViewSettingsViewController: UIViewController {
case .axis:
let axisController = EHMultipleChoiceViewController(withDataSource: currentSettings.axis)
axisController.updateBlock = { [weak self] (dataSource) in
if let updatedEnum = dataSource as? UILayoutConstraintAxis {
if let updatedEnum = dataSource as? NSLayoutConstraint.Axis {
self?.currentSettings.axis = updatedEnum
}
self?.updateRow(content: rowEnum)
Expand All @@ -307,7 +307,7 @@ class EHStackViewSettingsViewController: UIViewController {
case .distribution:
let distController = EHMultipleChoiceViewController(withDataSource: currentSettings.distribution)
distController.updateBlock = { [weak self] (dataSource) in
if let updatedEnum = dataSource as? UIStackViewDistribution {
if let updatedEnum = dataSource as? UIStackView.Distribution {
self?.currentSettings.distribution = updatedEnum
}
self?.updateRow(content: rowEnum)
Expand All @@ -317,7 +317,7 @@ class EHStackViewSettingsViewController: UIViewController {
case .alignment:
let alignController = EHMultipleChoiceViewController(withDataSource: currentSettings.alignment)
alignController.updateBlock = { [weak self] (dataSource) in
if let updatedEnum = dataSource as? UIStackViewAlignment {
if let updatedEnum = dataSource as? UIStackView.Alignment {
self?.currentSettings.alignment = updatedEnum
}
self?.updateRow(content: rowEnum)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,19 @@

import UIKit

extension UILayoutConstraintAxis {
extension NSLayoutConstraint.Axis {

var textDescription: String {
get {
var desc = ""
switch self {
case .horizontal: desc = "horizontal"
case .vertical: desc = "vertical"
}
return desc
switch self {
case .horizontal: return "horizontal"
case .vertical: return "vertical"
@unknown default: return "unknown"
}
}

}

extension UILayoutConstraintAxis : EHMultipleChoiceDataSource {
extension NSLayoutConstraint.Axis : EHMultipleChoiceDataSource {

func title() -> String {
return "UILayoutConstraintAxis"
Expand All @@ -36,7 +33,7 @@ extension UILayoutConstraintAxis : EHMultipleChoiceDataSource {
func choiceText(atIndex: Int) -> String {
var text = "Unknown"

if let indexChoice = UILayoutConstraintAxis(rawValue: atIndex) {
if let indexChoice = NSLayoutConstraint.Axis(rawValue: atIndex) {
text = indexChoice.textDescription
}

Expand All @@ -46,7 +43,7 @@ extension UILayoutConstraintAxis : EHMultipleChoiceDataSource {
func isChoiceSelected(atIndex: Int) -> Bool {
var selected = false

if let indexChoice = UILayoutConstraintAxis(rawValue: atIndex) {
if let indexChoice = NSLayoutConstraint.Axis(rawValue: atIndex) {
selected = (indexChoice == self)
}

Expand All @@ -66,7 +63,7 @@ extension UILayoutConstraintAxis : EHMultipleChoiceDataSource {
let oppositeOfInputIndex = (atIndex == 0 ? 1 : 0)
let updatedSelectedIndex = (selected ? atIndex : oppositeOfInputIndex)
if updatedSelectedIndex != self.rawValue,
let updatedEnum = UILayoutConstraintAxis(rawValue: updatedSelectedIndex) {
let updatedEnum = NSLayoutConstraint.Axis(rawValue: updatedSelectedIndex) {
self = updatedEnum
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,22 @@

import UIKit

extension UIStackViewAlignment {
extension UIStackView.Alignment {

var textDescription: String {
get {
var desc = ""
switch self {
case .fill: desc = "fill"
case .leading: desc = "leading"
case .firstBaseline: desc = "firstBaseline"
case .center: desc = "center"
case .trailing: desc = "trailing"
case .lastBaseline: desc = "lastBaseline"
}
return desc
switch self {
case .fill: return "fill"
case .leading: return "leading"
case .firstBaseline: return "firstBaseline"
case .center: return "center"
case .trailing: return "trailing"
case .lastBaseline: return "lastBaseline"
@unknown default: return "unknown"
}
}
}

extension UIStackViewAlignment: EHMultipleChoiceDataSource {
extension UIStackView.Alignment: EHMultipleChoiceDataSource {

func title() -> String {
return "UIStackViewAlignment"
Expand All @@ -39,7 +36,7 @@ extension UIStackViewAlignment: EHMultipleChoiceDataSource {
func choiceText(atIndex: Int) -> String {
var text = "Unknown"

if let indexChoice = UIStackViewAlignment(rawValue: atIndex) {
if let indexChoice = UIStackView.Alignment(rawValue: atIndex) {
text = indexChoice.textDescription
}

Expand All @@ -49,7 +46,7 @@ extension UIStackViewAlignment: EHMultipleChoiceDataSource {
func isChoiceSelected(atIndex: Int) -> Bool {
var selected = false

if let indexChoice = UIStackViewAlignment(rawValue: atIndex) {
if let indexChoice = UIStackView.Alignment(rawValue: atIndex) {
selected = (indexChoice == self)
}

Expand All @@ -66,7 +63,7 @@ extension UIStackViewAlignment: EHMultipleChoiceDataSource {

mutating func setChoice(selected: Bool, atIndex: Int) {
if atIndex < choiceCount() && selected {
if let updatedEnum = UIStackViewAlignment(rawValue: atIndex) {
if let updatedEnum = UIStackView.Alignment(rawValue: atIndex) {
self = updatedEnum
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,21 @@

import UIKit

extension UIStackViewDistribution {
extension UIStackView.Distribution {

var textDescription: String {
get {
var desc = ""
switch self {
case .fill: desc = "fill"
case .fillEqually: desc = "fillEqually"
case .fillProportionally: desc = "fillProportionally"
case .equalSpacing: desc = "equalSpacing"
case .equalCentering: desc = "equalCentering"
}
return desc
switch self {
case .fill: return "fill"
case .fillEqually: return "fillEqually"
case .fillProportionally: return "fillProportionally"
case .equalSpacing: return "equalSpacing"
case .equalCentering: return "equalCentering"
@unknown default: return "unknown"
}
}
}

extension UIStackViewDistribution : EHMultipleChoiceDataSource {
extension UIStackView.Distribution : EHMultipleChoiceDataSource {

func title() -> String {
return "UIStackViewDistribution"
Expand All @@ -38,7 +35,7 @@ extension UIStackViewDistribution : EHMultipleChoiceDataSource {
func choiceText(atIndex: Int) -> String {
var text = "Unknown"

if let indexChoice = UIStackViewDistribution(rawValue: atIndex) {
if let indexChoice = UIStackView.Distribution(rawValue: atIndex) {
text = indexChoice.textDescription
}

Expand All @@ -48,7 +45,7 @@ extension UIStackViewDistribution : EHMultipleChoiceDataSource {
func isChoiceSelected(atIndex: Int) -> Bool {
var selected = false

if let indexChoice = UIStackViewDistribution(rawValue: atIndex) {
if let indexChoice = UIStackView.Distribution(rawValue: atIndex) {
selected = (indexChoice == self)
}

Expand All @@ -65,7 +62,7 @@ extension UIStackViewDistribution : EHMultipleChoiceDataSource {

mutating func setChoice(selected: Bool, atIndex: Int) {
if atIndex < choiceCount() && selected {
if let updatedEnum = UIStackViewDistribution(rawValue: atIndex) {
if let updatedEnum = UIStackView.Distribution(rawValue: atIndex) {
self = updatedEnum
}
}
Expand Down
Loading

0 comments on commit 96e5109

Please sign in to comment.