Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to Swift 4.1 #14

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 39 additions & 7 deletions FMBlurable.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
05C052371BAC9FC700D0108A /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 05C052351BAC9FC700D0108A /* LaunchScreen.storyboard */; };
05C052421BAC9FC700D0108A /* FMBlurableTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 05C052411BAC9FC700D0108A /* FMBlurableTests.swift */; };
05C0524D1BAC9FC700D0108A /* FMBlurableUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 05C0524C1BAC9FC700D0108A /* FMBlurableUITests.swift */; };
05C0525E1BACA49200D0108A /* FMBlurable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 05C0525D1BACA49200D0108A /* FMBlurable.swift */; settings = {ASSET_TAGS = (); }; };
05EF481A1BB58FE8004EB3D2 /* SliderWidget.swift in Sources */ = {isa = PBXBuildFile; fileRef = 05EF48191BB58FE8004EB3D2 /* SliderWidget.swift */; settings = {ASSET_TAGS = (); }; };
05EF481C1BB59201004EB3D2 /* assets in Resources */ = {isa = PBXBuildFile; fileRef = 05EF481B1BB59201004EB3D2 /* assets */; settings = {ASSET_TAGS = (); }; };
05C0525E1BACA49200D0108A /* FMBlurable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 05C0525D1BACA49200D0108A /* FMBlurable.swift */; };
05EF481A1BB58FE8004EB3D2 /* SliderWidget.swift in Sources */ = {isa = PBXBuildFile; fileRef = 05EF48191BB58FE8004EB3D2 /* SliderWidget.swift */; };
05EF481C1BB59201004EB3D2 /* assets in Resources */ = {isa = PBXBuildFile; fileRef = 05EF481B1BB59201004EB3D2 /* assets */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand Down Expand Up @@ -212,11 +212,12 @@
05C052211BAC9FC700D0108A /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0700;
LastUpgradeCheck = 0940;
ORGANIZATIONNAME = "Simon Gladman";
TargetAttributes = {
05C052281BAC9FC700D0108A = {
CreatedOnToolsVersion = 7.0;
DevelopmentTeam = PB3CY9VB3G;
};
05C0523C1BAC9FC700D0108A = {
CreatedOnToolsVersion = 7.0;
Expand Down Expand Up @@ -347,13 +348,23 @@
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
Expand All @@ -379,7 +390,8 @@
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_OPTIMIZATION_LEVEL = "-O";
SWIFT_VERSION = 4.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
Expand All @@ -392,13 +404,23 @@
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
Expand All @@ -417,6 +439,8 @@
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SWIFT_COMPILATION_MODE = wholemodule;
SWIFT_VERSION = 4.0;
TARGETED_DEVICE_FAMILY = "1,2";
VALIDATE_PRODUCT = YES;
};
Expand All @@ -426,21 +450,25 @@
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
DEVELOPMENT_TEAM = PB3CY9VB3G;
INFOPLIST_FILE = FMBlurable/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = uk.co.flexmonkey.FMBlurable;
PRODUCT_BUNDLE_IDENTIFIER = uk.co.flexmonkey.Blurable;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.0;
};
name = Debug;
};
05C052531BAC9FC700D0108A /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
DEVELOPMENT_TEAM = PB3CY9VB3G;
INFOPLIST_FILE = FMBlurable/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = uk.co.flexmonkey.FMBlurable;
PRODUCT_BUNDLE_IDENTIFIER = uk.co.flexmonkey.Blurable;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.0;
};
name = Release;
};
Expand All @@ -452,6 +480,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = uk.co.flexmonkey.FMBlurableTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.0;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/FMBlurable.app/FMBlurable";
};
name = Debug;
Expand All @@ -464,6 +493,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = uk.co.flexmonkey.FMBlurableTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.0;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/FMBlurable.app/FMBlurable";
};
name = Release;
Expand All @@ -475,6 +505,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = uk.co.flexmonkey.FMBlurableUITests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.0;
TEST_TARGET_NAME = FMBlurable;
USES_XCTRUNNER = YES;
};
Expand All @@ -487,6 +518,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = uk.co.flexmonkey.FMBlurableUITests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.0;
TEST_TARGET_NAME = FMBlurable;
USES_XCTRUNNER = YES;
};
Expand Down
28 changes: 1 addition & 27 deletions FMBlurable/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,34 +13,8 @@ class AppDelegate: UIResponder, UIApplicationDelegate {

var window: UIWindow?


func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
// Override point for customization after application launch.
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey : Any]? = nil) -> Bool {
return true
}

func applicationWillResignActive(application: UIApplication) {
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}

func applicationDidEnterBackground(application: UIApplication) {
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}

func applicationWillEnterForeground(application: UIApplication) {
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}

func applicationDidBecomeActive(application: UIApplication) {
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}

func applicationWillTerminate(application: UIApplication) {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}


}

16 changes: 10 additions & 6 deletions FMBlurable/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="8191" systemVersion="15B17c" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="BYZ-38-t0r">
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14113" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
<device id="retina5_9" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="8154"/>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14088"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--View Controller-->
Expand All @@ -13,10 +18,9 @@
<viewControllerLayoutGuide type="bottom" id="wfy-db-euE"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
<rect key="frame" x="0.0" y="0.0" width="375" height="812"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<animations/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
Expand Down
94 changes: 43 additions & 51 deletions FMBlurable/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class ViewController: UIViewController
let slider = UISlider()
let stepper = UIStepper()
let unarrangedLabel = UILabel()
let unarrangedButton = UIButton(type: UIButtonType.InfoDark)
let unarrangedButton = UIButton(type: UIButtonType.infoDark)
let compositeComponent = SliderWidget(title: "Composite Component")

let toolbar = UIToolbar()
Expand All @@ -30,14 +30,14 @@ class ViewController: UIViewController
view.addSubview(stackView)
view.addSubview(toolbar)

stackView.frame = view.frame.insetBy(dx: 50, dy: 200)
stackView.frame = view.frame.insetBy(dx: 50, dy: 180)

stackView.axis = UILayoutConstraintAxis.Vertical
stackView.axis = UILayoutConstraintAxis.vertical

stackView.alignment = UIStackViewAlignment.Fill
stackView.distribution = UIStackViewDistribution.EqualSpacing
stackView.alignment = UIStackViewAlignment.fill
stackView.distribution = UIStackViewDistribution.equalSpacing

horizontalStackView.distribution = UIStackViewDistribution.FillEqually
horizontalStackView.distribution = UIStackViewDistribution.fillEqually

stackView.addArrangedSubview(segmentedControl)
stackView.addArrangedSubview(slider)
Expand All @@ -47,29 +47,29 @@ class ViewController: UIViewController
horizontalStackView.addArrangedSubview(stepper)
horizontalStackView.addArrangedSubview(toggleSwitch)

unarrangedLabel.text = "Unarranged Label"
unarrangedLabel.text = "label"

view.addSubview(unarrangedLabel)

unarrangedButton.setTitle("Unarranged Button", forState: UIControlState.Normal)
unarrangedButton.setTitle("button", for: UIControlState.normal)

view.addSubview(unarrangedButton)

let spacer = UIBarButtonItem(barButtonSystemItem: UIBarButtonSystemItem.FlexibleSpace, target: nil, action: nil)
let spacer = UIBarButtonItem(barButtonSystemItem: UIBarButtonSystemItem.flexibleSpace, target: nil, action: nil)

let toggleSegmentedControl = UIBarButtonItem(title: BarButtonLabel.SegmentedControl.rawValue, style: UIBarButtonItemStyle.Plain, target: self, action: #selector(ViewController.toolbarClickHandler(_:)))
let toggleSegmentedControl = UIBarButtonItem(title: BarButtonLabel.segmented.rawValue, style: UIBarButtonItemStyle.plain, target: self, action: #selector(ViewController.toolbarClickHandler(_:)))

let toggleToggleSwitch = UIBarButtonItem(title: BarButtonLabel.Switch.rawValue, style: UIBarButtonItemStyle.Plain, target: self, action: #selector(ViewController.toolbarClickHandler(_:)))
let toggleToggleSwitch = UIBarButtonItem(title: BarButtonLabel.switch.rawValue, style: UIBarButtonItemStyle.plain, target: self, action: #selector(ViewController.toolbarClickHandler(_:)))

let toggleSlider = UIBarButtonItem(title: BarButtonLabel.Slider.rawValue, style: UIBarButtonItemStyle.Plain, target: self, action: #selector(ViewController.toolbarClickHandler(_:)))
let toggleSlider = UIBarButtonItem(title: BarButtonLabel.slider.rawValue, style: UIBarButtonItemStyle.plain, target: self, action: #selector(ViewController.toolbarClickHandler(_:)))

let toggleStepper = UIBarButtonItem(title: BarButtonLabel.Stepper.rawValue, style: UIBarButtonItemStyle.Plain, target: self, action: #selector(ViewController.toolbarClickHandler(_:)))
let toggleStepper = UIBarButtonItem(title: BarButtonLabel.stepper.rawValue, style: UIBarButtonItemStyle.plain, target: self, action: #selector(ViewController.toolbarClickHandler(_:)))

let toggleUnarrangedLabel = UIBarButtonItem(title: BarButtonLabel.LabelOne.rawValue, style: UIBarButtonItemStyle.Plain, target: self, action: #selector(ViewController.toolbarClickHandler(_:)))
let toggleUnarrangedLabel = UIBarButtonItem(title: BarButtonLabel.label.rawValue, style: UIBarButtonItemStyle.plain, target: self, action: #selector(ViewController.toolbarClickHandler(_:)))

let toggleUnarrangedButton = UIBarButtonItem(title: BarButtonLabel.Button.rawValue, style: UIBarButtonItemStyle.Plain, target: self, action: #selector(ViewController.toolbarClickHandler(_:)))
let toggleUnarrangedButton = UIBarButtonItem(title: BarButtonLabel.button.rawValue, style: UIBarButtonItemStyle.plain, target: self, action: #selector(ViewController.toolbarClickHandler(_:)))

let toggleCompositeComponent = UIBarButtonItem(title: BarButtonLabel.CompositeComponent.rawValue, style: UIBarButtonItemStyle.Plain, target: self, action: #selector(ViewController.toolbarClickHandler(_:)))
let toggleCompositeComponent = UIBarButtonItem(title: BarButtonLabel.composite.rawValue, style: UIBarButtonItemStyle.plain, target: self, action: #selector(ViewController.toolbarClickHandler(_:)))

toolbar.setItems([toggleSegmentedControl, spacer,
toggleToggleSwitch, spacer,
Expand All @@ -80,10 +80,10 @@ class ViewController: UIViewController
toggleCompositeComponent], animated: false)
}

func toolbarClickHandler(barButtonItem: UIBarButtonItem)
@objc func toolbarClickHandler(_ barButtonItem: UIBarButtonItem)
{
guard let title = barButtonItem.title,
barButtonLabel = BarButtonLabel(rawValue: title) else
let barButtonLabel = BarButtonLabel(rawValue: title) else
{
return
}
Expand All @@ -92,19 +92,19 @@ class ViewController: UIViewController

switch barButtonLabel
{
case .SegmentedControl:
case .segmented:
widget = segmentedControl
case .Switch:
case .switch:
widget = toggleSwitch
case .Slider:
case .slider:
widget = slider
case .Stepper:
case .stepper:
widget = stepper
case .LabelOne:
case .label:
widget = unarrangedLabel
case .Button:
case .button:
widget = unarrangedButton
case .CompositeComponent:
case .composite:
widget = compositeComponent
}

Expand All @@ -114,7 +114,7 @@ class ViewController: UIViewController
}
else
{
widget.blur(blurRadius: 2)
widget.blur(radius: 2)
}
}

Expand All @@ -123,41 +123,33 @@ class ViewController: UIViewController
stackView.frame = CGRect(x: 0,
y: topLayoutGuide.length,
width: view.frame.width,
height: view.frame.height - topLayoutGuide.length).insetBy(dx: 50, dy: 50)
height: view.frame.height - topLayoutGuide.length).insetBy(dx: 40, dy: 40)

toolbar.frame = CGRect(x: 0,
y: view.frame.height - toolbar.intrinsicContentSize().height,
y: view.frame.height - toolbar.intrinsicContentSize.height - 20,
width: view.frame.width,
height: toolbar.intrinsicContentSize().height)
height: toolbar.intrinsicContentSize.height)

unarrangedButton.frame = CGRect(x: view.frame.width - unarrangedButton.intrinsicContentSize().width - 20,
y: 20,
width: unarrangedButton.intrinsicContentSize().width,
height: unarrangedButton.intrinsicContentSize().height)
unarrangedButton.frame = CGRect(x: view.frame.width - unarrangedButton.intrinsicContentSize.width - 40,
y: 40,
width: unarrangedButton.intrinsicContentSize.width,
height: unarrangedButton.intrinsicContentSize.height)

unarrangedLabel.frame = CGRect(x: 20,
y: 20,
width: unarrangedLabel.intrinsicContentSize().width,
height: unarrangedLabel.intrinsicContentSize().height)
y: 40,
width: unarrangedLabel.intrinsicContentSize.width,
height: unarrangedLabel.intrinsicContentSize.height)
}

}

enum BarButtonLabel: String
{
case SegmentedControl,
Switch,
Slider,
Stepper,
LabelOne,
Button,
CompositeComponent
case segmented,
`switch`,
slider,
stepper,
label,
button,
composite
}








Loading