Commit 4f2d6628 by Daniel Dahan

issue-44: updated to iOS 9

parent a45f4e2e
...@@ -324,6 +324,8 @@ ...@@ -324,6 +324,8 @@
9638322D1B88DFD80015F710 /* Project object */ = { 9638322D1B88DFD80015F710 /* Project object */ = {
isa = PBXProject; isa = PBXProject;
attributes = { attributes = {
LastSwiftMigration = 0710;
LastSwiftUpdateCheck = 0710;
LastUpgradeCheck = 0640; LastUpgradeCheck = 0640;
ORGANIZATIONNAME = "GraphKit, Inc."; ORGANIZATIONNAME = "GraphKit, Inc.";
TargetAttributes = { TargetAttributes = {
......
...@@ -230,14 +230,14 @@ public class BasicCardView : MaterialCardView, Comparable, Equatable { ...@@ -230,14 +230,14 @@ public class BasicCardView : MaterialCardView, Comparable, Equatable {
// container // container
if nil == titleLabelContainer { if nil == titleLabelContainer {
titleLabelContainer = UIView() titleLabelContainer = UIView()
titleLabelContainer!.setTranslatesAutoresizingMaskIntoConstraints(false) titleLabelContainer!.translatesAutoresizingMaskIntoConstraints = false
titleLabelContainer!.backgroundColor = MaterialTheme.clear.color titleLabelContainer!.backgroundColor = MaterialTheme.clear.color
addSubview(titleLabelContainer!) addSubview(titleLabelContainer!)
} }
// text // text
titleLabelContainer!.addSubview(t) titleLabelContainer!.addSubview(t)
t.setTranslatesAutoresizingMaskIntoConstraints(false) t.translatesAutoresizingMaskIntoConstraints = false
t.backgroundColor = MaterialTheme.clear.color t.backgroundColor = MaterialTheme.clear.color
t.font = Roboto.regular t.font = Roboto.regular
t.numberOfLines = 0 t.numberOfLines = 0
...@@ -273,14 +273,14 @@ public class BasicCardView : MaterialCardView, Comparable, Equatable { ...@@ -273,14 +273,14 @@ public class BasicCardView : MaterialCardView, Comparable, Equatable {
// container // container
if nil == detailLabelContainer { if nil == detailLabelContainer {
detailLabelContainer = UIView() detailLabelContainer = UIView()
detailLabelContainer!.setTranslatesAutoresizingMaskIntoConstraints(false) detailLabelContainer!.translatesAutoresizingMaskIntoConstraints = false
detailLabelContainer!.backgroundColor = MaterialTheme.clear.color detailLabelContainer!.backgroundColor = MaterialTheme.clear.color
addSubview(detailLabelContainer!) addSubview(detailLabelContainer!)
} }
// text // text
detailLabelContainer!.addSubview(l) detailLabelContainer!.addSubview(l)
l.setTranslatesAutoresizingMaskIntoConstraints(false) l.translatesAutoresizingMaskIntoConstraints = false
l.textColor = MaterialTheme.white.color l.textColor = MaterialTheme.white.color
l.backgroundColor = MaterialTheme.clear.color l.backgroundColor = MaterialTheme.clear.color
l.font = Roboto.light l.font = Roboto.light
...@@ -299,7 +299,7 @@ public class BasicCardView : MaterialCardView, Comparable, Equatable { ...@@ -299,7 +299,7 @@ public class BasicCardView : MaterialCardView, Comparable, Equatable {
public var divider: UIView? { public var divider: UIView? {
didSet { didSet {
if let d = divider { if let d = divider {
d.setTranslatesAutoresizingMaskIntoConstraints(false) d.translatesAutoresizingMaskIntoConstraints = false
d.backgroundColor = MaterialTheme.blueGrey.darken1 d.backgroundColor = MaterialTheme.blueGrey.darken1
addSubview(d) addSubview(d)
} else { } else {
...@@ -322,7 +322,7 @@ public class BasicCardView : MaterialCardView, Comparable, Equatable { ...@@ -322,7 +322,7 @@ public class BasicCardView : MaterialCardView, Comparable, Equatable {
if let b = leftButtons { if let b = leftButtons {
if nil == buttonsContainer { if nil == buttonsContainer {
buttonsContainer = UIView() buttonsContainer = UIView()
buttonsContainer!.setTranslatesAutoresizingMaskIntoConstraints(false) buttonsContainer!.translatesAutoresizingMaskIntoConstraints = false
buttonsContainer!.backgroundColor = MaterialTheme.clear.color buttonsContainer!.backgroundColor = MaterialTheme.clear.color
addSubview(buttonsContainer!) addSubview(buttonsContainer!)
} }
...@@ -341,7 +341,7 @@ public class BasicCardView : MaterialCardView, Comparable, Equatable { ...@@ -341,7 +341,7 @@ public class BasicCardView : MaterialCardView, Comparable, Equatable {
if let b = rightButtons { if let b = rightButtons {
if nil == buttonsContainer { if nil == buttonsContainer {
buttonsContainer = UIView() buttonsContainer = UIView()
buttonsContainer!.setTranslatesAutoresizingMaskIntoConstraints(false) buttonsContainer!.translatesAutoresizingMaskIntoConstraints = false
buttonsContainer!.backgroundColor = MaterialTheme.clear.color buttonsContainer!.backgroundColor = MaterialTheme.clear.color
addSubview(buttonsContainer!) addSubview(buttonsContainer!)
} }
...@@ -355,7 +355,7 @@ public class BasicCardView : MaterialCardView, Comparable, Equatable { ...@@ -355,7 +355,7 @@ public class BasicCardView : MaterialCardView, Comparable, Equatable {
/** /**
:name: init :name: init
*/ */
public required init(coder aDecoder: NSCoder) { public required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder) super.init(coder: aDecoder)
} }
...@@ -409,10 +409,10 @@ public class BasicCardView : MaterialCardView, Comparable, Equatable { ...@@ -409,10 +409,10 @@ public class BasicCardView : MaterialCardView, Comparable, Equatable {
// title // title
if nil != titleLabelContainer && nil != titleLabel { if nil != titleLabelContainer && nil != titleLabel {
// clear for updated constraints // clear for updated constraints
titleLabelContainer!.removeConstraints(titleLabelContainer!.constraints()) titleLabelContainer!.removeConstraints(titleLabelContainer!.constraints)
// container // container
layoutConstraints += Layout.constraint("H:|[titleLabelContainer]|", options: nil, metrics: nil, views: ["titleLabelContainer": titleLabelContainer!]) layoutConstraints += Layout.constraint("H:|[titleLabelContainer]|", options: [], metrics: nil, views: ["titleLabelContainer": titleLabelContainer!])
verticalFormat += "[titleLabelContainer]" verticalFormat += "[titleLabelContainer]"
views["titleLabelContainer"] = titleLabelContainer! views["titleLabelContainer"] = titleLabelContainer!
...@@ -421,17 +421,17 @@ public class BasicCardView : MaterialCardView, Comparable, Equatable { ...@@ -421,17 +421,17 @@ public class BasicCardView : MaterialCardView, Comparable, Equatable {
Layout.expandToParentWithPad(titleLabelContainer!, child: titleLabel!, top: titleLabelTopInset, left: titleLabelLeftInset, bottom: titleLabelBottomInset, right: titleLabelRightInset) Layout.expandToParentWithPad(titleLabelContainer!, child: titleLabel!, top: titleLabelTopInset, left: titleLabelLeftInset, bottom: titleLabelBottomInset, right: titleLabelRightInset)
} else { } else {
Layout.expandToParentHorizontallyWithPad(titleLabelContainer!, child: titleLabel!, left: titleLabelLeftInset, right: titleLabelRightInset) Layout.expandToParentHorizontallyWithPad(titleLabelContainer!, child: titleLabel!, left: titleLabelLeftInset, right: titleLabelRightInset)
titleLabelContainer!.addConstraints(Layout.constraint("V:|-(titleLabelTopInset)-[titleLabel(<=maximumTitleLabelHeight)]-(titleLabelBottomInset)-|", options: nil, metrics: ["titleLabelTopInset": titleLabelTopInset, "titleLabelBottomInset": titleLabelBottomInset, "maximumTitleLabelHeight": maximumTitleLabelHeight], views: ["titleLabel": titleLabel!])) titleLabelContainer!.addConstraints(Layout.constraint("V:|-(titleLabelTopInset)-[titleLabel(<=maximumTitleLabelHeight)]-(titleLabelBottomInset)-|", options: [], metrics: ["titleLabelTopInset": titleLabelTopInset, "titleLabelBottomInset": titleLabelBottomInset, "maximumTitleLabelHeight": maximumTitleLabelHeight], views: ["titleLabel": titleLabel!]))
} }
} }
// detail // detail
if nil != detailLabelContainer && nil != detailLabel { if nil != detailLabelContainer && nil != detailLabel {
// clear for updated constraints // clear for updated constraints
detailLabelContainer!.removeConstraints(detailLabelContainer!.constraints()) detailLabelContainer!.removeConstraints(detailLabelContainer!.constraints)
// container // container
layoutConstraints += Layout.constraint("H:|[detailLabelContainer]|", options: nil, metrics: nil, views: ["detailLabelContainer": detailLabelContainer!]) layoutConstraints += Layout.constraint("H:|[detailLabelContainer]|", options: [], metrics: nil, views: ["detailLabelContainer": detailLabelContainer!])
verticalFormat += "[detailLabelContainer]" verticalFormat += "[detailLabelContainer]"
views["detailLabelContainer"] = detailLabelContainer! views["detailLabelContainer"] = detailLabelContainer!
...@@ -439,24 +439,24 @@ public class BasicCardView : MaterialCardView, Comparable, Equatable { ...@@ -439,24 +439,24 @@ public class BasicCardView : MaterialCardView, Comparable, Equatable {
Layout.expandToParentWithPad(detailLabelContainer!, child: detailLabel!, top: detailLabelTopInset, left: detailLabelLeftInset, bottom: detailLabelBottomInset, right: detailLabelRightInset) Layout.expandToParentWithPad(detailLabelContainer!, child: detailLabel!, top: detailLabelTopInset, left: detailLabelLeftInset, bottom: detailLabelBottomInset, right: detailLabelRightInset)
} else { } else {
Layout.expandToParentHorizontallyWithPad(detailLabelContainer!, child: detailLabel!, left: detailLabelLeftInset, right: detailLabelRightInset) Layout.expandToParentHorizontallyWithPad(detailLabelContainer!, child: detailLabel!, left: detailLabelLeftInset, right: detailLabelRightInset)
detailLabelContainer!.addConstraints(Layout.constraint("V:|-(detailLabelTopInset)-[detailLabel(<=maximumDetailLabelHeight)]-(detailLabelBottomInset)-|", options: nil, metrics: ["detailLabelTopInset": detailLabelTopInset, "detailLabelBottomInset": detailLabelBottomInset, "maximumDetailLabelHeight": maximumDetailLabelHeight], views: ["detailLabel": detailLabel!])) detailLabelContainer!.addConstraints(Layout.constraint("V:|-(detailLabelTopInset)-[detailLabel(<=maximumDetailLabelHeight)]-(detailLabelBottomInset)-|", options: [], metrics: ["detailLabelTopInset": detailLabelTopInset, "detailLabelBottomInset": detailLabelBottomInset, "maximumDetailLabelHeight": maximumDetailLabelHeight], views: ["detailLabel": detailLabel!]))
} }
} }
// buttons // buttons
if nil != buttonsContainer && (nil != leftButtons || nil != rightButtons) { if nil != buttonsContainer && (nil != leftButtons || nil != rightButtons) {
// clear for updated constraints // clear for updated constraints
buttonsContainer!.removeConstraints(buttonsContainer!.constraints()) buttonsContainer!.removeConstraints(buttonsContainer!.constraints)
// divider // divider
if nil != divider { if nil != divider {
layoutConstraints += Layout.constraint("H:|[divider]|", options: nil, metrics: nil, views: ["divider": divider!]) layoutConstraints += Layout.constraint("H:|[divider]|", options: [], metrics: nil, views: ["divider": divider!])
views["divider"] = divider! views["divider"] = divider!
verticalFormat += "[divider(1)]" verticalFormat += "[divider(1)]"
} }
//container //container
layoutConstraints += Layout.constraint("H:|[buttonsContainer]|", options: nil, metrics: nil, views: ["buttonsContainer": buttonsContainer!]) layoutConstraints += Layout.constraint("H:|[buttonsContainer]|", options: [], metrics: nil, views: ["buttonsContainer": buttonsContainer!])
verticalFormat += "[buttonsContainer]" verticalFormat += "[buttonsContainer]"
views["buttonsContainer"] = buttonsContainer! views["buttonsContainer"] = buttonsContainer!
...@@ -471,7 +471,7 @@ public class BasicCardView : MaterialCardView, Comparable, Equatable { ...@@ -471,7 +471,7 @@ public class BasicCardView : MaterialCardView, Comparable, Equatable {
horizontalFormat += "-(buttonLeftInset)-[button\(i)]" horizontalFormat += "-(buttonLeftInset)-[button\(i)]"
Layout.expandToParentVerticallyWithPad(buttonsContainer!, child: button, top: buttonTopInset, bottom: buttonBottomInset) Layout.expandToParentVerticallyWithPad(buttonsContainer!, child: button, top: buttonTopInset, bottom: buttonBottomInset)
} }
buttonsContainer!.addConstraints(Layout.constraint(horizontalFormat, options: nil, metrics: ["buttonLeftInset": buttonLeftInset], views: buttonViews)) buttonsContainer!.addConstraints(Layout.constraint(horizontalFormat, options: [], metrics: ["buttonLeftInset": buttonLeftInset], views: buttonViews))
} }
// rightButtons // rightButtons
...@@ -485,7 +485,7 @@ public class BasicCardView : MaterialCardView, Comparable, Equatable { ...@@ -485,7 +485,7 @@ public class BasicCardView : MaterialCardView, Comparable, Equatable {
horizontalFormat += "[button\(i)]-(buttonRightInset)-" horizontalFormat += "[button\(i)]-(buttonRightInset)-"
Layout.expandToParentVerticallyWithPad(buttonsContainer!, child: button, top: buttonTopInset, bottom: buttonBottomInset) Layout.expandToParentVerticallyWithPad(buttonsContainer!, child: button, top: buttonTopInset, bottom: buttonBottomInset)
} }
buttonsContainer!.addConstraints(Layout.constraint(horizontalFormat + "|", options: nil, metrics: ["buttonRightInset": buttonRightInset], views: buttonViews)) buttonsContainer!.addConstraints(Layout.constraint(horizontalFormat + "|", options: [], metrics: ["buttonRightInset": buttonRightInset], views: buttonViews))
} }
} }
...@@ -493,7 +493,7 @@ public class BasicCardView : MaterialCardView, Comparable, Equatable { ...@@ -493,7 +493,7 @@ public class BasicCardView : MaterialCardView, Comparable, Equatable {
// combine constraints // combine constraints
if 0 < layoutConstraints.count { if 0 < layoutConstraints.count {
layoutConstraints += Layout.constraint(verticalFormat, options: nil, metrics: nil, views: views) layoutConstraints += Layout.constraint(verticalFormat, options: [], metrics: nil, views: views)
NSLayoutConstraint.activateConstraints(layoutConstraints) NSLayoutConstraint.activateConstraints(layoutConstraints)
} }
} }
......
...@@ -101,7 +101,7 @@ public class Capture: NSObject, AVCaptureFileOutputRecordingDelegate { ...@@ -101,7 +101,7 @@ public class Capture: NSObject, AVCaptureFileOutputRecordingDelegate {
// setup default camera device // setup default camera device
let videoDevice: AVCaptureDevice = AVCaptureDevice.defaultDeviceWithMediaType(AVMediaTypeVideo) let videoDevice: AVCaptureDevice = AVCaptureDevice.defaultDeviceWithMediaType(AVMediaTypeVideo)
var videoInput: AVCaptureDeviceInput? = AVCaptureDeviceInput.deviceInputWithDevice(videoDevice, error: &error) as? AVCaptureDeviceInput let videoInput: AVCaptureDeviceInput? = AVCaptureDeviceInput.deviceInputWithDevice(videoDevice) as? AVCaptureDeviceInput
if nil == videoInput { if nil == videoInput {
return false return false
...@@ -113,7 +113,7 @@ public class Capture: NSObject, AVCaptureFileOutputRecordingDelegate { ...@@ -113,7 +113,7 @@ public class Capture: NSObject, AVCaptureFileOutputRecordingDelegate {
} }
let audioDevice: AVCaptureDevice = AVCaptureDevice.defaultDeviceWithMediaType(AVMediaTypeAudio) let audioDevice: AVCaptureDevice = AVCaptureDevice.defaultDeviceWithMediaType(AVMediaTypeAudio)
var audioInput: AVCaptureDeviceInput? = AVCaptureDeviceInput.deviceInputWithDevice(audioDevice, error: &error) as? AVCaptureDeviceInput let audioInput: AVCaptureDeviceInput? = AVCaptureDeviceInput.deviceInputWithDevice(audioDevice) as? AVCaptureDeviceInput
if nil == audioInput { if nil == audioInput {
return false return false
...@@ -218,9 +218,9 @@ public class Capture: NSObject, AVCaptureFileOutputRecordingDelegate { ...@@ -218,9 +218,9 @@ public class Capture: NSObject, AVCaptureFileOutputRecordingDelegate {
return false return false
} }
var error: NSError? let error: NSError?
var videoDevice: AVCaptureDevice? = inactiveCamera let videoDevice: AVCaptureDevice? = inactiveCamera
var videoInput: AVCaptureDeviceInput? = AVCaptureDeviceInput.deviceInputWithDevice(videoDevice, error: &error) as? AVCaptureDeviceInput let videoInput: AVCaptureDeviceInput? = AVCaptureDeviceInput.deviceInputWithDevice(videoDevice) as? AVCaptureDeviceInput
if nil == videoInput { if nil == videoInput {
session.beginConfiguration() session.beginConfiguration()
...@@ -263,10 +263,12 @@ public class Capture: NSObject, AVCaptureFileOutputRecordingDelegate { ...@@ -263,10 +263,12 @@ public class Capture: NSObject, AVCaptureFileOutputRecordingDelegate {
let device: AVCaptureDevice = activeCamera let device: AVCaptureDevice = activeCamera
if flashMode != device.flashMode && device.isFlashModeSupported(flashMode) { if flashMode != device.flashMode && device.isFlashModeSupported(flashMode) {
var error: NSError? var error: NSError?
if device.lockForConfiguration(&error) { do {
try device.lockForConfiguration()
device.flashMode = flashMode device.flashMode = flashMode
device.unlockForConfiguration() device.unlockForConfiguration()
} else { } catch let error1 as NSError {
error = error1
delegate?.captureDeviceConfigurationFailed?(self, error: error) delegate?.captureDeviceConfigurationFailed?(self, error: error)
} }
} }
...@@ -297,10 +299,12 @@ public class Capture: NSObject, AVCaptureFileOutputRecordingDelegate { ...@@ -297,10 +299,12 @@ public class Capture: NSObject, AVCaptureFileOutputRecordingDelegate {
let device: AVCaptureDevice = activeCamera let device: AVCaptureDevice = activeCamera
if torchMode != device.torchMode && device.isTorchModeSupported(torchMode) { if torchMode != device.torchMode && device.isTorchModeSupported(torchMode) {
var error: NSError? var error: NSError?
if device.lockForConfiguration(&error) { do {
try device.lockForConfiguration()
device.torchMode = torchMode device.torchMode = torchMode
device.unlockForConfiguration() device.unlockForConfiguration()
} else { } catch let error1 as NSError {
error = error1
delegate?.captureDeviceConfigurationFailed?(self, error: error) delegate?.captureDeviceConfigurationFailed?(self, error: error)
} }
} }
...@@ -328,11 +332,13 @@ public class Capture: NSObject, AVCaptureFileOutputRecordingDelegate { ...@@ -328,11 +332,13 @@ public class Capture: NSObject, AVCaptureFileOutputRecordingDelegate {
let device: AVCaptureDevice = activeCamera let device: AVCaptureDevice = activeCamera
if device.focusPointOfInterestSupported && device.isFocusModeSupported(.AutoFocus) { if device.focusPointOfInterestSupported && device.isFocusModeSupported(.AutoFocus) {
var error: NSError? var error: NSError?
if device.lockForConfiguration(&error) { do {
try device.lockForConfiguration()
device.focusPointOfInterest = point device.focusPointOfInterest = point
device.focusMode = .AutoFocus device.focusMode = .AutoFocus
device.unlockForConfiguration() device.unlockForConfiguration()
} else { } catch let error1 as NSError {
error = error1
delegate?.captureDeviceConfigurationFailed?(self, error: error) delegate?.captureDeviceConfigurationFailed?(self, error: error)
} }
} }
...@@ -356,11 +362,12 @@ public class Capture: NSObject, AVCaptureFileOutputRecordingDelegate { ...@@ -356,11 +362,12 @@ public class Capture: NSObject, AVCaptureFileOutputRecordingDelegate {
*/ */
public func exposeAtPoint(point: CGPoint) { public func exposeAtPoint(point: CGPoint) {
let device: AVCaptureDevice = activeCamera let device: AVCaptureDevice = activeCamera
var exposureMode: AVCaptureExposureMode = .ContinuousAutoExposure let exposureMode: AVCaptureExposureMode = .ContinuousAutoExposure
if device.exposurePointOfInterestSupported && device.isExposureModeSupported(exposureMode) { if device.exposurePointOfInterestSupported && device.isExposureModeSupported(exposureMode) {
var error: NSError? var error: NSError?
if device.lockForConfiguration(&error) { do {
try device.lockForConfiguration()
device.exposurePointOfInterest = point device.exposurePointOfInterest = point
device.exposureMode = exposureMode device.exposureMode = exposureMode
...@@ -368,7 +375,8 @@ public class Capture: NSObject, AVCaptureFileOutputRecordingDelegate { ...@@ -368,7 +375,8 @@ public class Capture: NSObject, AVCaptureFileOutputRecordingDelegate {
device.addObserver(self, forKeyPath: "adjustingExposure", options: .New, context: &CaptureAdjustingExposureContext) device.addObserver(self, forKeyPath: "adjustingExposure", options: .New, context: &CaptureAdjustingExposureContext)
} }
device.unlockForConfiguration() device.unlockForConfiguration()
} else { } catch let error1 as NSError {
error = error1
delegate?.captureDeviceConfigurationFailed?(self, error: error) delegate?.captureDeviceConfigurationFailed?(self, error: error)
} }
} }
...@@ -378,7 +386,7 @@ public class Capture: NSObject, AVCaptureFileOutputRecordingDelegate { ...@@ -378,7 +386,7 @@ public class Capture: NSObject, AVCaptureFileOutputRecordingDelegate {
* override to set observeValueForKeyPath and handle exposure observance. * override to set observeValueForKeyPath and handle exposure observance.
* @delegate If the configuration fails, the capture(capture: Capture!, deviceConfigurationFailed error: NSError!) is called. * @delegate If the configuration fails, the capture(capture: Capture!, deviceConfigurationFailed error: NSError!) is called.
*/ */
override public func observeValueForKeyPath(keyPath: String, ofObject object: AnyObject, change: [NSObject : AnyObject], context: UnsafeMutablePointer<Void>) { override public func observeValueForKeyPath(keyPath: String?, ofObject object: AnyObject?, change: [String : AnyObject]?, context: UnsafeMutablePointer<Void>) {
if context == &CaptureAdjustingExposureContext { if context == &CaptureAdjustingExposureContext {
let device: AVCaptureDevice = object as! AVCaptureDevice let device: AVCaptureDevice = object as! AVCaptureDevice
...@@ -386,10 +394,14 @@ public class Capture: NSObject, AVCaptureFileOutputRecordingDelegate { ...@@ -386,10 +394,14 @@ public class Capture: NSObject, AVCaptureFileOutputRecordingDelegate {
object.removeObserver(self, forKeyPath: "adjustingExposure", context: &CaptureAdjustingExposureContext) object.removeObserver(self, forKeyPath: "adjustingExposure", context: &CaptureAdjustingExposureContext)
dispatch_async(queue) { dispatch_async(queue) {
var error: NSError? var error: NSError?
if device.lockForConfiguration(&error) { do {
try device.lockForConfiguration()
device.unlockForConfiguration() device.unlockForConfiguration()
} else { } catch var error1 as NSError {
error = error1
self.delegate?.captureDeviceConfigurationFailed?(self, error: error) self.delegate?.captureDeviceConfigurationFailed?(self, error: error)
} catch {
fatalError()
} }
} }
} else { } else {
...@@ -406,16 +418,17 @@ public class Capture: NSObject, AVCaptureFileOutputRecordingDelegate { ...@@ -406,16 +418,17 @@ public class Capture: NSObject, AVCaptureFileOutputRecordingDelegate {
public func resetFocusAndExposureModes() { public func resetFocusAndExposureModes() {
let device: AVCaptureDevice = activeCamera let device: AVCaptureDevice = activeCamera
var exposureMode: AVCaptureExposureMode = .ContinuousAutoExposure let exposureMode: AVCaptureExposureMode = .ContinuousAutoExposure
let canResetExposure: Bool = device.focusPointOfInterestSupported && device.isExposureModeSupported(exposureMode) let canResetExposure: Bool = device.focusPointOfInterestSupported && device.isExposureModeSupported(exposureMode)
var focusMode: AVCaptureFocusMode = .ContinuousAutoFocus let focusMode: AVCaptureFocusMode = .ContinuousAutoFocus
let canResetFocus: Bool = device.focusPointOfInterestSupported && device.isFocusModeSupported(focusMode) let canResetFocus: Bool = device.focusPointOfInterestSupported && device.isFocusModeSupported(focusMode)
let centerPoint: CGPoint = CGPointMake(0.5, 0.5) let centerPoint: CGPoint = CGPointMake(0.5, 0.5)
var error: NSError? var error: NSError?
if device.lockForConfiguration(&error) { do {
try device.lockForConfiguration()
if canResetFocus { if canResetFocus {
device.focusMode = focusMode device.focusMode = focusMode
device.focusPointOfInterest = centerPoint device.focusPointOfInterest = centerPoint
...@@ -425,7 +438,8 @@ public class Capture: NSObject, AVCaptureFileOutputRecordingDelegate { ...@@ -425,7 +438,8 @@ public class Capture: NSObject, AVCaptureFileOutputRecordingDelegate {
device.exposurePointOfInterest = centerPoint device.exposurePointOfInterest = centerPoint
} }
device.unlockForConfiguration() device.unlockForConfiguration()
} else { } catch let error1 as NSError {
error = error1
delegate?.captureDeviceConfigurationFailed?(self, error: error) delegate?.captureDeviceConfigurationFailed?(self, error: error)
} }
} }
...@@ -437,7 +451,7 @@ public class Capture: NSObject, AVCaptureFileOutputRecordingDelegate { ...@@ -437,7 +451,7 @@ public class Capture: NSObject, AVCaptureFileOutputRecordingDelegate {
* @delegate If failure, capture(capture: Capture!, assetLibraryWriteFailed error: NSError!) is called. * @delegate If failure, capture(capture: Capture!, assetLibraryWriteFailed error: NSError!) is called.
*/ */
public func captureStillImage() { public func captureStillImage() {
var connection: AVCaptureConnection = imageOutput.connectionWithMediaType(AVMediaTypeVideo) let connection: AVCaptureConnection = imageOutput.connectionWithMediaType(AVMediaTypeVideo)
if connection.supportsVideoOrientation { if connection.supportsVideoOrientation {
connection.videoOrientation = currentVideoOrientation connection.videoOrientation = currentVideoOrientation
} }
...@@ -482,10 +496,12 @@ public class Capture: NSObject, AVCaptureFileOutputRecordingDelegate { ...@@ -482,10 +496,12 @@ public class Capture: NSObject, AVCaptureFileOutputRecordingDelegate {
if device.smoothAutoFocusSupported { if device.smoothAutoFocusSupported {
var error: NSError? var error: NSError?
if device.lockForConfiguration(&error) { do {
try device.lockForConfiguration()
device.smoothAutoFocusEnabled = false device.smoothAutoFocusEnabled = false
device.unlockForConfiguration() device.unlockForConfiguration()
} else { } catch let error1 as NSError {
error = error1
delegate?.captureDeviceConfigurationFailed?(self, error: error) delegate?.captureDeviceConfigurationFailed?(self, error: error)
} }
} }
...@@ -546,9 +562,12 @@ public class Capture: NSObject, AVCaptureFileOutputRecordingDelegate { ...@@ -546,9 +562,12 @@ public class Capture: NSObject, AVCaptureFileOutputRecordingDelegate {
private var uniqueURL: NSURL? { private var uniqueURL: NSURL? {
var error: NSError? var error: NSError?
let fileManager: NSFileManager = NSFileManager.defaultManager() let fileManager: NSFileManager = NSFileManager.defaultManager()
let tempDirectoryTemplate: String = NSTemporaryDirectory().stringByAppendingPathComponent("FocusLibrary") let tempDirectoryTemplate: String = (NSTemporaryDirectory() as NSString).stringByAppendingPathComponent("FocusLibrary")
if fileManager.createDirectoryAtPath(tempDirectoryTemplate, withIntermediateDirectories: true, attributes: nil, error: &error) { do {
try fileManager.createDirectoryAtPath(tempDirectoryTemplate, withIntermediateDirectories: true, attributes: nil)
return NSURL.fileURLWithPath(tempDirectoryTemplate + "/test.mov") return NSURL.fileURLWithPath(tempDirectoryTemplate + "/test.mov")
} catch let error1 as NSError {
error = error1
} }
return nil return nil
} }
...@@ -611,13 +630,13 @@ public class Capture: NSObject, AVCaptureFileOutputRecordingDelegate { ...@@ -611,13 +630,13 @@ public class Capture: NSObject, AVCaptureFileOutputRecordingDelegate {
*/ */
private func generateThumbnailForVideoAtURL(videoURL: NSURL!) { private func generateThumbnailForVideoAtURL(videoURL: NSURL!) {
dispatch_async(queue) { dispatch_async(queue) {
let asset: AVAsset = AVAsset.assetWithURL(videoURL) as! AVAsset let asset: AVAsset = AVAsset.assetWithURL(videoURL)
let imageGenerator: AVAssetImageGenerator = AVAssetImageGenerator(asset: asset) let imageGenerator: AVAssetImageGenerator = AVAssetImageGenerator(asset: asset)
imageGenerator.maximumSize = CGSizeMake(100, 0) imageGenerator.maximumSize = CGSizeMake(100, 0)
imageGenerator.appliesPreferredTrackTransform = true imageGenerator.appliesPreferredTrackTransform = true
let imageRef: CGImageRef = imageGenerator.copyCGImageAtTime(kCMTimeZero, actualTime: nil, error: nil) let imageRef: CGImageRef = try? imageGenerator.copyCGImageAtTime(kCMTimeZero, actualTime: nil)
let image: UIImage = UIImage(CGImage: imageRef)! let image: UIImage = UIImage(CGImage: imageRef)
dispatch_async(dispatch_get_main_queue()) { dispatch_async(dispatch_get_main_queue()) {
self.postAssetLibraryNotification(image) self.postAssetLibraryNotification(image)
......
...@@ -118,7 +118,7 @@ public class Preview: UIView { ...@@ -118,7 +118,7 @@ public class Preview: UIView {
// //
private var doubleDoubleTapRecognizer: UITapGestureRecognizer? private var doubleDoubleTapRecognizer: UITapGestureRecognizer?
required public init(coder aDecoder: NSCoder) { required public init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder) super.init(coder: aDecoder)
prepareView() prepareView()
} }
...@@ -130,7 +130,7 @@ public class Preview: UIView { ...@@ -130,7 +130,7 @@ public class Preview: UIView {
public init() { public init() {
super.init(frame: CGRectZero) super.init(frame: CGRectZero)
setTranslatesAutoresizingMaskIntoConstraints(false) translatesAutoresizingMaskIntoConstraints = false
prepareView() prepareView()
} }
......
...@@ -25,7 +25,7 @@ public struct Layout { ...@@ -25,7 +25,7 @@ public struct Layout {
public static func width(parent: UIView, child: UIView, width: CGFloat = 0) { public static func width(parent: UIView, child: UIView, width: CGFloat = 0) {
let metrics: Dictionary<String, AnyObject> = ["width" : width] let metrics: Dictionary<String, AnyObject> = ["width" : width]
let views: Dictionary<String, AnyObject> = ["child" : child] let views: Dictionary<String, AnyObject> = ["child" : child]
parent.addConstraints(constraint("H:[child(width)]", options: nil, metrics: metrics, views: views)) parent.addConstraints(constraint("H:[child(width)]", options: [], metrics: metrics, views: views))
} }
/** /**
...@@ -34,7 +34,7 @@ public struct Layout { ...@@ -34,7 +34,7 @@ public struct Layout {
public static func height(parent: UIView, child: UIView, height: CGFloat = 0) { public static func height(parent: UIView, child: UIView, height: CGFloat = 0) {
let metrics: Dictionary<String, AnyObject> = ["height" : height] let metrics: Dictionary<String, AnyObject> = ["height" : height]
let views: Dictionary<String, AnyObject> = ["child" : child] let views: Dictionary<String, AnyObject> = ["child" : child]
parent.addConstraints(constraint("V:[child(height)]", options: nil, metrics: metrics, views: views)) parent.addConstraints(constraint("V:[child(height)]", options: [], metrics: metrics, views: views))
} }
/** /**
...@@ -50,8 +50,8 @@ public struct Layout { ...@@ -50,8 +50,8 @@ public struct Layout {
*/ */
public static func expandToParent(parent: UIView, child: UIView) { public static func expandToParent(parent: UIView, child: UIView) {
let views: Dictionary<String, AnyObject> = ["child" : child] let views: Dictionary<String, AnyObject> = ["child" : child]
parent.addConstraints(constraint("H:|[child]|", options: nil, metrics: nil, views: views)) parent.addConstraints(constraint("H:|[child]|", options: [], metrics: nil, views: views))
parent.addConstraints(constraint("V:|[child]|", options: nil, metrics: nil, views: views)) parent.addConstraints(constraint("V:|[child]|", options: [], metrics: nil, views: views))
} }
/** /**
...@@ -65,7 +65,7 @@ public struct Layout { ...@@ -65,7 +65,7 @@ public struct Layout {
:name: expandToParentHorizontallyWithPad :name: expandToParentHorizontallyWithPad
*/ */
public static func expandToParentHorizontallyWithPad(parent: UIView, child: UIView, left: CGFloat = 0, right: CGFloat = 0) { public static func expandToParentHorizontallyWithPad(parent: UIView, child: UIView, left: CGFloat = 0, right: CGFloat = 0) {
parent.addConstraints(constraint("H:|-(left)-[child]-(right)-|", options: nil, metrics: ["left": left, "right": right], views: ["child" : child])) parent.addConstraints(constraint("H:|-(left)-[child]-(right)-|", options: [], metrics: ["left": left, "right": right], views: ["child" : child]))
} }
/** /**
...@@ -79,7 +79,7 @@ public struct Layout { ...@@ -79,7 +79,7 @@ public struct Layout {
:name: expandToParentVerticallyWithPad :name: expandToParentVerticallyWithPad
*/ */
public static func expandToParentVerticallyWithPad(parent: UIView, child: UIView, top: CGFloat = 0, bottom: CGFloat = 0) { public static func expandToParentVerticallyWithPad(parent: UIView, child: UIView, top: CGFloat = 0, bottom: CGFloat = 0) {
parent.addConstraints(constraint("V:|-(top)-[child]-(bottom)-|", options: nil, metrics: ["bottom": bottom, "top": top], views: ["child" : child])) parent.addConstraints(constraint("V:|-(top)-[child]-(bottom)-|", options: [], metrics: ["bottom": bottom, "top": top], views: ["child" : child]))
} }
/** /**
...@@ -87,8 +87,8 @@ public struct Layout { ...@@ -87,8 +87,8 @@ public struct Layout {
*/ */
public static func expandToParentWithPad(parent: UIView, child: UIView, top: CGFloat = 0, left: CGFloat = 0, bottom: CGFloat = 0, right: CGFloat = 0) { public static func expandToParentWithPad(parent: UIView, child: UIView, top: CGFloat = 0, left: CGFloat = 0, bottom: CGFloat = 0, right: CGFloat = 0) {
let views: Dictionary<String, AnyObject> = ["child" : child] let views: Dictionary<String, AnyObject> = ["child" : child]
parent.addConstraints(constraint("H:|-(left)-[child]-(right)-|", options: nil, metrics: ["left": left, "right": right], views: views)) parent.addConstraints(constraint("H:|-(left)-[child]-(right)-|", options: [], metrics: ["left": left, "right": right], views: views))
parent.addConstraints(constraint("V:|-(top)-[child]-(bottom)-|", options: nil, metrics: ["bottom": bottom, "top": top], views: views)) parent.addConstraints(constraint("V:|-(top)-[child]-(bottom)-|", options: [], metrics: ["bottom": bottom, "top": top], views: views))
} }
/** /**
...@@ -97,8 +97,8 @@ public struct Layout { ...@@ -97,8 +97,8 @@ public struct Layout {
public static func alignFromTopLeft(parent: UIView, child: UIView, top: CGFloat = 0, left: CGFloat = 0) { public static func alignFromTopLeft(parent: UIView, child: UIView, top: CGFloat = 0, left: CGFloat = 0) {
let metrics: Dictionary<String, AnyObject> = ["top" : top, "left" : left] let metrics: Dictionary<String, AnyObject> = ["top" : top, "left" : left]
let views: Dictionary<String, AnyObject> = ["child" : child] let views: Dictionary<String, AnyObject> = ["child" : child]
parent.addConstraints(constraint("H:|-(left)-[child]", options: nil, metrics: metrics, views: views)) parent.addConstraints(constraint("H:|-(left)-[child]", options: [], metrics: metrics, views: views))
parent.addConstraints(constraint("V:|-(top)-[child]", options: nil, metrics: metrics, views: views)) parent.addConstraints(constraint("V:|-(top)-[child]", options: [], metrics: metrics, views: views))
} }
/** /**
...@@ -107,8 +107,8 @@ public struct Layout { ...@@ -107,8 +107,8 @@ public struct Layout {
public static func alignFromTopRight(parent: UIView, child: UIView, top: CGFloat = 0, right: CGFloat = 0) { public static func alignFromTopRight(parent: UIView, child: UIView, top: CGFloat = 0, right: CGFloat = 0) {
let metrics: Dictionary<String, AnyObject> = ["top" : top, "right" : right] let metrics: Dictionary<String, AnyObject> = ["top" : top, "right" : right]
let views: Dictionary<String, AnyObject> = ["child" : child] let views: Dictionary<String, AnyObject> = ["child" : child]
parent.addConstraints(constraint("H:[child]-(right)-|", options: nil, metrics: metrics, views: views)) parent.addConstraints(constraint("H:[child]-(right)-|", options: [], metrics: metrics, views: views))
parent.addConstraints(constraint("V:|-(top)-[child]", options: nil, metrics: metrics, views: views)) parent.addConstraints(constraint("V:|-(top)-[child]", options: [], metrics: metrics, views: views))
} }
/** /**
...@@ -117,8 +117,8 @@ public struct Layout { ...@@ -117,8 +117,8 @@ public struct Layout {
public static func alignFromBottomLeft(parent: UIView, child: UIView, bottom: CGFloat = 0, left: CGFloat = 0) { public static func alignFromBottomLeft(parent: UIView, child: UIView, bottom: CGFloat = 0, left: CGFloat = 0) {
let metrics: Dictionary<String, AnyObject> = ["bottom" : bottom, "left" : left] let metrics: Dictionary<String, AnyObject> = ["bottom" : bottom, "left" : left]
let views: Dictionary<String, AnyObject> = ["child" : child] let views: Dictionary<String, AnyObject> = ["child" : child]
parent.addConstraints(constraint("H:|-(left)-[child]", options: nil, metrics: metrics, views: views)) parent.addConstraints(constraint("H:|-(left)-[child]", options: [], metrics: metrics, views: views))
parent.addConstraints(constraint("V:[child]-(bottom)-|", options: nil, metrics: metrics, views: views)) parent.addConstraints(constraint("V:[child]-(bottom)-|", options: [], metrics: metrics, views: views))
} }
/** /**
...@@ -127,8 +127,8 @@ public struct Layout { ...@@ -127,8 +127,8 @@ public struct Layout {
public static func alignFromBottomRight(parent: UIView, child: UIView, bottom: CGFloat = 0, right: CGFloat = 0) { public static func alignFromBottomRight(parent: UIView, child: UIView, bottom: CGFloat = 0, right: CGFloat = 0) {
let metrics: Dictionary<String, AnyObject> = ["bottom" : bottom, "right" : right] let metrics: Dictionary<String, AnyObject> = ["bottom" : bottom, "right" : right]
let views: Dictionary<String, AnyObject> = ["child" : child] let views: Dictionary<String, AnyObject> = ["child" : child]
parent.addConstraints(constraint("H:[child]-(right)-|", options: nil, metrics: metrics, views: views)) parent.addConstraints(constraint("H:[child]-(right)-|", options: [], metrics: metrics, views: views))
parent.addConstraints(constraint("V:[child]-(bottom)-|", options: nil, metrics: metrics, views: views)) parent.addConstraints(constraint("V:[child]-(bottom)-|", options: [], metrics: metrics, views: views))
} }
/** /**
...@@ -150,6 +150,6 @@ public struct Layout { ...@@ -150,6 +150,6 @@ public struct Layout {
options: options, options: options,
metrics: metrics, metrics: metrics,
views: views views: views
) as! Array<NSLayoutConstraint> )
} }
} }
...@@ -49,7 +49,7 @@ public class MaterialButton : UIButton { ...@@ -49,7 +49,7 @@ public class MaterialButton : UIButton {
/** /**
:name: init :name: init
*/ */
public required init(coder aDecoder: NSCoder) { public required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder) super.init(coder: aDecoder)
prepareView() prepareView()
} }
...@@ -72,7 +72,7 @@ public class MaterialButton : UIButton { ...@@ -72,7 +72,7 @@ public class MaterialButton : UIButton {
/** /**
:name: touchesBegan :name: touchesBegan
*/ */
public override func touchesBegan(touches: Set<NSObject>, withEvent event: UIEvent) { public override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) {
super.touchesBegan(touches, withEvent: event) super.touchesBegan(touches, withEvent: event)
pulseBegan(touches, withEvent: event) pulseBegan(touches, withEvent: event)
} }
...@@ -80,7 +80,7 @@ public class MaterialButton : UIButton { ...@@ -80,7 +80,7 @@ public class MaterialButton : UIButton {
/** /**
:name: touchesEnded :name: touchesEnded
*/ */
public override func touchesEnded(touches: Set<NSObject>, withEvent event: UIEvent) { public override func touchesEnded(touches: Set<UITouch>, withEvent event: UIEvent?) {
super.touchesEnded(touches, withEvent: event) super.touchesEnded(touches, withEvent: event)
shrink() shrink()
pulseEnded(touches, withEvent: event) pulseEnded(touches, withEvent: event)
...@@ -89,7 +89,7 @@ public class MaterialButton : UIButton { ...@@ -89,7 +89,7 @@ public class MaterialButton : UIButton {
/** /**
:name: touchesCancelled :name: touchesCancelled
*/ */
public override func touchesCancelled(touches: Set<NSObject>!, withEvent event: UIEvent!) { public override func touchesCancelled(touches: Set<UITouch>?, withEvent event: UIEvent?) {
super.touchesCancelled(touches, withEvent: event) super.touchesCancelled(touches, withEvent: event)
shrink() shrink()
pulseEnded(touches, withEvent: event) pulseEnded(touches, withEvent: event)
...@@ -108,7 +108,7 @@ public class MaterialButton : UIButton { ...@@ -108,7 +108,7 @@ public class MaterialButton : UIButton {
// :name: prepareView // :name: prepareView
// //
internal func prepareView() { internal func prepareView() {
setTranslatesAutoresizingMaskIntoConstraints(false) translatesAutoresizingMaskIntoConstraints = false
} }
// //
...@@ -167,7 +167,7 @@ public class MaterialButton : UIButton { ...@@ -167,7 +167,7 @@ public class MaterialButton : UIButton {
// :name: prepareBackgroundColorView // :name: prepareBackgroundColorView
// //
private func prepareBackgroundColorView() { private func prepareBackgroundColorView() {
backgroundColorView.setTranslatesAutoresizingMaskIntoConstraints(false) backgroundColorView.translatesAutoresizingMaskIntoConstraints = false
backgroundColorView.layer.masksToBounds = true backgroundColorView.layer.masksToBounds = true
backgroundColorView.clipsToBounds = true backgroundColorView.clipsToBounds = true
backgroundColorView.userInteractionEnabled = false backgroundColorView.userInteractionEnabled = false
...@@ -183,7 +183,7 @@ public class MaterialButton : UIButton { ...@@ -183,7 +183,7 @@ public class MaterialButton : UIButton {
delay: 0, delay: 0,
usingSpringWithDamping: 0.2, usingSpringWithDamping: 0.2,
initialSpringVelocity: 10, initialSpringVelocity: 10,
options: nil, options: [],
animations: { animations: {
self.transform = CGAffineTransformIdentity self.transform = CGAffineTransformIdentity
}, },
......
...@@ -54,7 +54,7 @@ public class MaterialCardView : UIView { ...@@ -54,7 +54,7 @@ public class MaterialCardView : UIView {
/** /**
:name: init :name: init
*/ */
public required init(coder aDecoder: NSCoder) { public required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder) super.init(coder: aDecoder)
prepareView() prepareView()
} }
...@@ -77,7 +77,7 @@ public class MaterialCardView : UIView { ...@@ -77,7 +77,7 @@ public class MaterialCardView : UIView {
/** /**
:name: touchesBegan :name: touchesBegan
*/ */
public override func touchesBegan(touches: Set<NSObject>, withEvent event: UIEvent) { public override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) {
super.touchesBegan(touches, withEvent: event) super.touchesBegan(touches, withEvent: event)
pulseBegan(touches, withEvent: event) pulseBegan(touches, withEvent: event)
} }
...@@ -85,7 +85,7 @@ public class MaterialCardView : UIView { ...@@ -85,7 +85,7 @@ public class MaterialCardView : UIView {
/** /**
:name: touchesEnded :name: touchesEnded
*/ */
public override func touchesEnded(touches: Set<NSObject>, withEvent event: UIEvent) { public override func touchesEnded(touches: Set<UITouch>, withEvent event: UIEvent?) {
super.touchesEnded(touches, withEvent: event) super.touchesEnded(touches, withEvent: event)
shrink() shrink()
pulseEnded(touches, withEvent: event) pulseEnded(touches, withEvent: event)
...@@ -94,7 +94,7 @@ public class MaterialCardView : UIView { ...@@ -94,7 +94,7 @@ public class MaterialCardView : UIView {
/** /**
:name: touchesCancelled :name: touchesCancelled
*/ */
public override func touchesCancelled(touches: Set<NSObject>!, withEvent event: UIEvent!) { public override func touchesCancelled(touches: Set<UITouch>?, withEvent event: UIEvent?) {
super.touchesCancelled(touches, withEvent: event) super.touchesCancelled(touches, withEvent: event)
shrink() shrink()
pulseEnded(touches, withEvent: event) pulseEnded(touches, withEvent: event)
...@@ -104,7 +104,7 @@ public class MaterialCardView : UIView { ...@@ -104,7 +104,7 @@ public class MaterialCardView : UIView {
// :name: prepareView // :name: prepareView
// //
internal func prepareView() { internal func prepareView() {
setTranslatesAutoresizingMaskIntoConstraints(false) translatesAutoresizingMaskIntoConstraints = false
prepareBackgroundColorView() prepareBackgroundColorView()
preparePulseViewContainer() preparePulseViewContainer()
prepareCard() prepareCard()
...@@ -146,7 +146,7 @@ public class MaterialCardView : UIView { ...@@ -146,7 +146,7 @@ public class MaterialCardView : UIView {
// //
// :name: pulseBegan // :name: pulseBegan
// //
internal func pulseBegan(touches: Set<NSObject>, withEvent event: UIEvent) { internal func pulseBegan(touches: Set<NSObject>, withEvent event: UIEvent?) {
let width: CGFloat = bounds.size.width / 3 let width: CGFloat = bounds.size.width / 3
pulseView = UIView(frame: CGRectMake(0, 0, width, width)) pulseView = UIView(frame: CGRectMake(0, 0, width, width))
pulseView!.layer.cornerRadius = width / 2 pulseView!.layer.cornerRadius = width / 2
...@@ -164,7 +164,7 @@ public class MaterialCardView : UIView { ...@@ -164,7 +164,7 @@ public class MaterialCardView : UIView {
// //
// :name: pulseEnded // :name: pulseEnded
// //
internal func pulseEnded(touches: Set<NSObject>, withEvent event: UIEvent) { internal func pulseEnded(touches: Set<NSObject>?, withEvent event: UIEvent?) {
UIView.animateWithDuration(0.3, UIView.animateWithDuration(0.3,
animations: { _ in animations: { _ in
self.pulseView?.alpha = 0 self.pulseView?.alpha = 0
...@@ -182,7 +182,7 @@ public class MaterialCardView : UIView { ...@@ -182,7 +182,7 @@ public class MaterialCardView : UIView {
// We need this view so we can use the masksToBounds // We need this view so we can use the masksToBounds
// so the pulse doesn't animate off the button // so the pulse doesn't animate off the button
private func prepareBackgroundColorView() { private func prepareBackgroundColorView() {
backgroundColorView.setTranslatesAutoresizingMaskIntoConstraints(false) backgroundColorView.translatesAutoresizingMaskIntoConstraints = false
backgroundColorView.layer.cornerRadius = 2 backgroundColorView.layer.cornerRadius = 2
backgroundColorView.layer.masksToBounds = true backgroundColorView.layer.masksToBounds = true
backgroundColorView.clipsToBounds = true backgroundColorView.clipsToBounds = true
...@@ -197,7 +197,7 @@ public class MaterialCardView : UIView { ...@@ -197,7 +197,7 @@ public class MaterialCardView : UIView {
// We need this view so we can use the masksToBounds // We need this view so we can use the masksToBounds
// so the pulse doesn't animate off the button // so the pulse doesn't animate off the button
private func preparePulseViewContainer() { private func preparePulseViewContainer() {
pulseViewContainer.setTranslatesAutoresizingMaskIntoConstraints(false) pulseViewContainer.translatesAutoresizingMaskIntoConstraints = false
pulseViewContainer.layer.cornerRadius = 2 pulseViewContainer.layer.cornerRadius = 2
pulseViewContainer.layer.masksToBounds = true pulseViewContainer.layer.masksToBounds = true
pulseViewContainer.clipsToBounds = true pulseViewContainer.clipsToBounds = true
...@@ -212,7 +212,7 @@ public class MaterialCardView : UIView { ...@@ -212,7 +212,7 @@ public class MaterialCardView : UIView {
delay: 0, delay: 0,
usingSpringWithDamping: 0.2, usingSpringWithDamping: 0.2,
initialSpringVelocity: 10, initialSpringVelocity: 10,
options: nil, options: [],
animations: { animations: {
self.transform = CGAffineTransformIdentity self.transform = CGAffineTransformIdentity
}, },
......
...@@ -34,7 +34,7 @@ public class MaterialText: NSObject { ...@@ -34,7 +34,7 @@ public class MaterialText: NSObject {
*/ */
public var searchPattern: String = "(^|\\s)#[\\d\\w_\u{203C}\u{2049}\u{20E3}\u{2122}\u{2139}\u{2194}-\u{2199}\u{21A9}-\u{21AA}\u{231A}-\u{231B}\u{23E9}-\u{23EC}\u{23F0}\u{23F3}\u{24C2}\u{25AA}-\u{25AB}\u{25B6}\u{25C0}\u{25FB}-\u{25FE}\u{2600}-\u{2601}\u{260E}\u{2611}\u{2614}-\u{2615}\u{261D}\u{263A}\u{2648}-\u{2653}\u{2660}\u{2663}\u{2665}-\u{2666}\u{2668}\u{267B}\u{267F}\u{2693}\u{26A0}-\u{26A1}\u{26AA}-\u{26AB}\u{26BD}-\u{26BE}\u{26C4}-\u{26C5}\u{26CE}\u{26D4}\u{26EA}\u{26F2}-\u{26F3}\u{26F5}\u{26FA}\u{26FD}\u{2702}\u{2705}\u{2708}-\u{270C}\u{270F}\u{2712}\u{2714}\u{2716}\u{2728}\u{2733}-\u{2734}\u{2744}\u{2747}\u{274C}\u{274E}\u{2753}-\u{2755}\u{2757}\u{2764}\u{2795}-\u{2797}\u{27A1}\u{27B0}\u{2934}-\u{2935}\u{2B05}-\u{2B07}\u{2B1B}-\u{2B1C}\u{2B50}\u{2B55}\u{3030}\u{303D}\u{3297}\u{3299}\u{1F004}\u{1F0CF}\u{1F170}-\u{1F171}\u{1F17E}-\u{1F17F}\u{1F18E}\u{1F191}-\u{1F19A}\u{1F1E7}-\u{1F1EC}\u{1F1EE}-\u{1F1F0}\u{1F1F3}\u{1F1F5}\u{1F1F7}-\u{1F1FA}\u{1F201}-\u{1F202}\u{1F21A}\u{1F22F}\u{1F232}-\u{1F23A}\u{1F250}-\u{1F251}\u{1F300}-\u{1F320}\u{1F330}-\u{1F335}\u{1F337}-\u{1F37C}\u{1F380}-\u{1F393}\u{1F3A0}-\u{1F3C4}\u{1F3C6}-\u{1F3CA}\u{1F3E0}-\u{1F3F0}\u{1F400}-\u{1F43E}\u{1F440}\u{1F442}-\u{1F4F7}\u{1F4F9}-\u{1F4FC}\u{1F500}-\u{1F507}\u{1F509}-\u{1F53D}\u{1F550}-\u{1F567}\u{1F5FB}-\u{1F640}\u{1F645}-\u{1F64F}\u{1F680}-\u{1F68A}]+" { public var searchPattern: String = "(^|\\s)#[\\d\\w_\u{203C}\u{2049}\u{20E3}\u{2122}\u{2139}\u{2194}-\u{2199}\u{21A9}-\u{21AA}\u{231A}-\u{231B}\u{23E9}-\u{23EC}\u{23F0}\u{23F3}\u{24C2}\u{25AA}-\u{25AB}\u{25B6}\u{25C0}\u{25FB}-\u{25FE}\u{2600}-\u{2601}\u{260E}\u{2611}\u{2614}-\u{2615}\u{261D}\u{263A}\u{2648}-\u{2653}\u{2660}\u{2663}\u{2665}-\u{2666}\u{2668}\u{267B}\u{267F}\u{2693}\u{26A0}-\u{26A1}\u{26AA}-\u{26AB}\u{26BD}-\u{26BE}\u{26C4}-\u{26C5}\u{26CE}\u{26D4}\u{26EA}\u{26F2}-\u{26F3}\u{26F5}\u{26FA}\u{26FD}\u{2702}\u{2705}\u{2708}-\u{270C}\u{270F}\u{2712}\u{2714}\u{2716}\u{2728}\u{2733}-\u{2734}\u{2744}\u{2747}\u{274C}\u{274E}\u{2753}-\u{2755}\u{2757}\u{2764}\u{2795}-\u{2797}\u{27A1}\u{27B0}\u{2934}-\u{2935}\u{2B05}-\u{2B07}\u{2B1B}-\u{2B1C}\u{2B50}\u{2B55}\u{3030}\u{303D}\u{3297}\u{3299}\u{1F004}\u{1F0CF}\u{1F170}-\u{1F171}\u{1F17E}-\u{1F17F}\u{1F18E}\u{1F191}-\u{1F19A}\u{1F1E7}-\u{1F1EC}\u{1F1EE}-\u{1F1F0}\u{1F1F3}\u{1F1F5}\u{1F1F7}-\u{1F1FA}\u{1F201}-\u{1F202}\u{1F21A}\u{1F22F}\u{1F232}-\u{1F23A}\u{1F250}-\u{1F251}\u{1F300}-\u{1F320}\u{1F330}-\u{1F335}\u{1F337}-\u{1F37C}\u{1F380}-\u{1F393}\u{1F3A0}-\u{1F3C4}\u{1F3C6}-\u{1F3CA}\u{1F3E0}-\u{1F3F0}\u{1F400}-\u{1F43E}\u{1F440}\u{1F442}-\u{1F4F7}\u{1F4F9}-\u{1F4FC}\u{1F500}-\u{1F507}\u{1F509}-\u{1F53D}\u{1F550}-\u{1F567}\u{1F5FB}-\u{1F640}\u{1F645}-\u{1F64F}\u{1F680}-\u{1F68A}]+" {
didSet { didSet {
textStorage.searchExpression = NSRegularExpression(pattern: searchPattern, options: nil, error: nil) textStorage.searchExpression = try? NSRegularExpression(pattern: searchPattern, options: [])
} }
} }
...@@ -56,7 +56,7 @@ public class MaterialText: NSObject { ...@@ -56,7 +56,7 @@ public class MaterialText: NSObject {
public override init() { public override init() {
textStorage = MaterialTextStorage() textStorage = MaterialTextStorage()
super.init() super.init()
textStorage.searchExpression = NSRegularExpression(pattern: searchPattern, options: nil, error: nil) textStorage.searchExpression = try? NSRegularExpression(pattern: searchPattern, options: [])
textStorage.textStorageWillProcessEdit = { (textStorage: MaterialTextStorage, string: String, range: NSRange) -> Void in textStorage.textStorageWillProcessEdit = { (textStorage: MaterialTextStorage, string: String, range: NSRange) -> Void in
self.delegate?.textStorageWillProcessEdit?(self, textStorage: textStorage, string: string, range: range) self.delegate?.textStorageWillProcessEdit?(self, textStorage: textStorage, string: string, range: range)
} }
...@@ -82,8 +82,8 @@ public class MaterialText: NSObject { ...@@ -82,8 +82,8 @@ public class MaterialText: NSObject {
*/ */
public var matches: Array<String> { public var matches: Array<String> {
get { get {
let results: Array<NSTextCheckingResult> = textStorage.searchExpression!.matchesInString(string, options: nil, range: NSMakeRange(0, count(string.utf16))) as! Array<NSTextCheckingResult> let results: Array<NSTextCheckingResult> = textStorage.searchExpression!.matchesInString(string, options: [], range: NSMakeRange(0, string.utf16.count))
return unique(map(results) {(self.string as NSString).substringWithRange($0.range)}) return unique(results.map {(self.string as NSString).substringWithRange($0.range)})
} }
} }
...@@ -93,6 +93,6 @@ public class MaterialText: NSObject { ...@@ -93,6 +93,6 @@ public class MaterialText: NSObject {
*/ */
private func unique<S: SequenceType, E: Hashable where E == S.Generator.Element>(source: S) -> [E] { private func unique<S: SequenceType, E: Hashable where E == S.Generator.Element>(source: S) -> [E] {
var seen: [E:Bool] = [:] var seen: [E:Bool] = [:]
return filter(source) {nil == seen.updateValue(true, forKey: $0)} return source.filter {nil == seen.updateValue(true, forKey: $0)}
} }
} }
\ No newline at end of file
...@@ -48,7 +48,7 @@ public class MaterialTextStorage: NSTextStorage { ...@@ -48,7 +48,7 @@ public class MaterialTextStorage: NSTextStorage {
*/ */
internal var textStorageDidProcessEdit: MaterialTextStorageDidProcessEdit? internal var textStorageDidProcessEdit: MaterialTextStorageDidProcessEdit?
required public init(coder aDecoder: NSCoder) { required public init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder) super.init(coder: aDecoder)
} }
...@@ -69,22 +69,22 @@ public class MaterialTextStorage: NSTextStorage { ...@@ -69,22 +69,22 @@ public class MaterialTextStorage: NSTextStorage {
override public func processEditing() { override public func processEditing() {
let range: NSRange = (string as NSString).paragraphRangeForRange(editedRange) let range: NSRange = (string as NSString).paragraphRangeForRange(editedRange)
textStorageWillProcessEdit?(self, string, range) textStorageWillProcessEdit?(self, string, range)
searchExpression!.enumerateMatchesInString(string, options: nil, range: range) { (result: NSTextCheckingResult!, flags: NSMatchingFlags, stop: UnsafeMutablePointer<ObjCBool>) in searchExpression!.enumerateMatchesInString(string, options: [], range: range) { (result: NSTextCheckingResult!, flags: NSMatchingFlags, stop: UnsafeMutablePointer<ObjCBool>) in
self.textStorageDidProcessEdit?(self, result, flags, stop) self.textStorageDidProcessEdit?(self, result, flags, stop)
} }
super.processEditing() super.processEditing()
} }
override public func attributesAtIndex(location: Int, effectiveRange range: NSRangePointer) -> [NSObject : AnyObject] { override public func attributesAtIndex(location: Int, effectiveRange range: NSRangePointer) -> [String : AnyObject] {
return store.attributesAtIndex(location, effectiveRange: range) return store.attributesAtIndex(location, effectiveRange: range)
} }
override public func replaceCharactersInRange(range: NSRange, withString str: String) { override public func replaceCharactersInRange(range: NSRange, withString str: String) {
store.replaceCharactersInRange(range, withString: str) store.replaceCharactersInRange(range, withString: str)
edited(NSTextStorageEditActions.EditedCharacters, range: range, changeInLength: count(str.utf16) - range.length) edited(NSTextStorageEditActions.EditedCharacters, range: range, changeInLength: str.utf16.count - range.length)
} }
override public func setAttributes(attrs: [NSObject : AnyObject]?, range: NSRange) { override public func setAttributes(attrs: [String : AnyObject]?, range: NSRange) {
store.setAttributes(attrs, range: range) store.setAttributes(attrs, range: range)
edited(NSTextStorageEditActions.EditedAttributes, range: range, changeInLength: 0) edited(NSTextStorageEditActions.EditedAttributes, range: range, changeInLength: 0)
} }
......
...@@ -40,7 +40,7 @@ public enum SideNavigationViewState { ...@@ -40,7 +40,7 @@ public enum SideNavigationViewState {
} }
@objc(SideNavigationViewContainer) @objc(SideNavigationViewContainer)
public class SideNavigationViewContainer : Printable { public class SideNavigationViewContainer : NSObject {
/** /**
:name: state :name: state
*/ */
...@@ -59,7 +59,7 @@ public class SideNavigationViewContainer : Printable { ...@@ -59,7 +59,7 @@ public class SideNavigationViewContainer : Printable {
/** /**
:name: description :name: description
*/ */
public var description: String { public override var description: String {
let s: String = .Opened == state ? "Opened" : "Closed" let s: String = .Opened == state ? "Opened" : "Closed"
return "(state: \(s), point: \(point), frame: \(frame))" return "(state: \(s), point: \(point), frame: \(frame))"
} }
...@@ -362,7 +362,7 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer ...@@ -362,7 +362,7 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer
/** /**
:name: init :name: init
*/ */
public required init(coder aDecoder: NSCoder) { public required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder) super.init(coder: aDecoder)
} }
...@@ -548,28 +548,28 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer ...@@ -548,28 +548,28 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer
:name: toggleLeftViewContainer :name: toggleLeftViewContainer
*/ */
public func toggleLeftViewContainer(velocity: CGFloat = 0) { public func toggleLeftViewContainer(velocity: CGFloat = 0) {
isLeftContainerOpened ? closeLeftViewContainer(velocity: velocity) : openLeftViewContainer(velocity: velocity) isLeftContainerOpened ? closeLeftViewContainer(velocity) : openLeftViewContainer(velocity)
} }
/** /**
:name: toggleRightViewContainer :name: toggleRightViewContainer
*/ */
public func toggleRightViewContainer(velocity: CGFloat = 0) { public func toggleRightViewContainer(velocity: CGFloat = 0) {
isRightContainerOpened ? closeRightViewContainer(velocity: velocity) : openRightViewContainer(velocity: velocity) isRightContainerOpened ? closeRightViewContainer(velocity) : openRightViewContainer(velocity)
} }
/** /**
:name: toggleBottomViewContainer :name: toggleBottomViewContainer
*/ */
public func toggleBottomViewContainer(velocity: CGFloat = 0) { public func toggleBottomViewContainer(velocity: CGFloat = 0) {
isBottomContainerOpened ? closeBottomViewContainer(velocity: velocity) : openBottomViewContainer(velocity: velocity) isBottomContainerOpened ? closeBottomViewContainer(velocity) : openBottomViewContainer(velocity)
} }
/** /**
:name: toggleTopViewContainer :name: toggleTopViewContainer
*/ */
public func toggleTopViewContainer(velocity: CGFloat = 0) { public func toggleTopViewContainer(velocity: CGFloat = 0) {
isTopContainerOpened ? closeTopViewContainer(velocity: velocity) : openTopViewContainer(velocity: velocity) isTopContainerOpened ? closeTopViewContainer(velocity) : openTopViewContainer(velocity)
} }
/** /**
...@@ -940,7 +940,7 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer ...@@ -940,7 +940,7 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer
if let c = leftContainer { if let c = leftContainer {
if .Began == gesture.state { if .Began == gesture.state {
addShadow(&leftViewContainer) addShadow(&leftViewContainer)
toggleStatusBar(hide: true) toggleStatusBar(true)
c.state = isLeftContainerOpened ? .Opened : .Closed c.state = isLeftContainerOpened ? .Opened : .Closed
c.point = gesture.locationInView(view) c.point = gesture.locationInView(view)
c.frame = vc.frame c.frame = vc.frame
...@@ -959,9 +959,9 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer ...@@ -959,9 +959,9 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer
let x: CGFloat = c.point.x >= 1000 || c.point.x <= -1000 ? c.point.x : 0 let x: CGFloat = c.point.x >= 1000 || c.point.x <= -1000 ? c.point.x : 0
c.state = vc.frame.origin.x <= CGFloat(floor(leftOriginX)) + options.horizontalThreshold || c.point.x <= -1000 ? .Closed : .Opened c.state = vc.frame.origin.x <= CGFloat(floor(leftOriginX)) + options.horizontalThreshold || c.point.x <= -1000 ? .Closed : .Opened
if .Closed == c.state { if .Closed == c.state {
closeLeftViewContainer(velocity: x) closeLeftViewContainer(x)
} else { } else {
openLeftViewContainer(velocity: x) openLeftViewContainer(x)
} }
delegate?.sideNavDidEndLeftPan?(self, container: c) delegate?.sideNavDidEndLeftPan?(self, container: c)
} }
...@@ -991,7 +991,7 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer ...@@ -991,7 +991,7 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer
c.state = isRightContainerOpened ? .Opened : .Closed c.state = isRightContainerOpened ? .Opened : .Closed
c.frame = vc.frame c.frame = vc.frame
addShadow(&rightViewContainer) addShadow(&rightViewContainer)
toggleStatusBar(hide: true) toggleStatusBar(true)
delegate?.sideNavDidBeginRightPan?(self, container: c) delegate?.sideNavDidBeginRightPan?(self, container: c)
} else if .Changed == gesture.state { } else if .Changed == gesture.state {
c.point = gesture.translationInView(gesture.view!) c.point = gesture.translationInView(gesture.view!)
...@@ -1006,9 +1006,9 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer ...@@ -1006,9 +1006,9 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer
let x: CGFloat = c.point.x <= -1000 || c.point.x >= 1000 ? c.point.x : 0 let x: CGFloat = c.point.x <= -1000 || c.point.x >= 1000 ? c.point.x : 0
c.state = vc.frame.origin.x >= CGFloat(floor(rightOriginX) - options.horizontalThreshold) || c.point.x >= 1000 ? .Closed : .Opened c.state = vc.frame.origin.x >= CGFloat(floor(rightOriginX) - options.horizontalThreshold) || c.point.x >= 1000 ? .Closed : .Opened
if .Closed == c.state { if .Closed == c.state {
closeRightViewContainer(velocity: x) closeRightViewContainer(x)
} else { } else {
openRightViewContainer(velocity: x) openRightViewContainer(x)
} }
delegate?.sideNavDidEndRightPan?(self, container: c) delegate?.sideNavDidEndRightPan?(self, container: c)
} }
...@@ -1035,7 +1035,7 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer ...@@ -1035,7 +1035,7 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer
if let c = bottomContainer { if let c = bottomContainer {
if .Began == gesture.state { if .Began == gesture.state {
addShadow(&bottomViewContainer) addShadow(&bottomViewContainer)
toggleStatusBar(hide: true) toggleStatusBar(true)
c.state = isBottomContainerOpened ? .Opened : .Closed c.state = isBottomContainerOpened ? .Opened : .Closed
c.point = gesture.locationInView(view) c.point = gesture.locationInView(view)
c.frame = vc.frame c.frame = vc.frame
...@@ -1053,9 +1053,9 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer ...@@ -1053,9 +1053,9 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer
let y: CGFloat = c.point.y <= -1000 || c.point.y >= 1000 ? c.point.y : 0 let y: CGFloat = c.point.y <= -1000 || c.point.y >= 1000 ? c.point.y : 0
c.state = vc.frame.origin.y >= CGFloat(floor(bottomOriginY) - options.verticalThreshold) || c.point.y >= 1000 ? .Closed : .Opened c.state = vc.frame.origin.y >= CGFloat(floor(bottomOriginY) - options.verticalThreshold) || c.point.y >= 1000 ? .Closed : .Opened
if .Closed == c.state { if .Closed == c.state {
closeBottomViewContainer(velocity: y) closeBottomViewContainer(y)
} else { } else {
openBottomViewContainer(velocity: y) openBottomViewContainer(y)
} }
delegate?.sideNavDidEndBottomPan?(self, container: c) delegate?.sideNavDidEndBottomPan?(self, container: c)
} }
...@@ -1082,7 +1082,7 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer ...@@ -1082,7 +1082,7 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer
if let c = topContainer { if let c = topContainer {
if .Began == gesture.state { if .Began == gesture.state {
addShadow(&topViewContainer) addShadow(&topViewContainer)
toggleStatusBar(hide: true) toggleStatusBar(true)
c.state = isTopContainerOpened ? .Opened : .Closed c.state = isTopContainerOpened ? .Opened : .Closed
c.point = gesture.locationInView(view) c.point = gesture.locationInView(view)
c.frame = vc.frame c.frame = vc.frame
...@@ -1100,9 +1100,9 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer ...@@ -1100,9 +1100,9 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer
let y: CGFloat = c.point.y <= -1000 || c.point.y >= 1000 ? c.point.y : 0 let y: CGFloat = c.point.y <= -1000 || c.point.y >= 1000 ? c.point.y : 0
c.state = vc.frame.origin.y >= CGFloat(floor(topOriginY) + options.verticalThreshold) || c.point.y >= 1000 ? .Opened : .Closed c.state = vc.frame.origin.y >= CGFloat(floor(topOriginY) + options.verticalThreshold) || c.point.y >= 1000 ? .Opened : .Closed
if .Closed == c.state { if .Closed == c.state {
closeTopViewContainer(velocity: y) closeTopViewContainer(y)
} else { } else {
openTopViewContainer(velocity: y) openTopViewContainer(y)
} }
delegate?.sideNavDidEndTopPan?(self, container: c) delegate?.sideNavDidEndTopPan?(self, container: c)
} }
...@@ -1243,7 +1243,7 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer ...@@ -1243,7 +1243,7 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer
private func prepareMainContainer() { private func prepareMainContainer() {
mainViewContainer = UIView(frame: view.bounds) mainViewContainer = UIView(frame: view.bounds)
mainViewContainer!.backgroundColor = MaterialTheme.clear.color mainViewContainer!.backgroundColor = MaterialTheme.clear.color
mainViewContainer!.autoresizingMask = .FlexibleHeight | .FlexibleWidth mainViewContainer!.autoresizingMask = [.FlexibleHeight, .FlexibleWidth]
view.addSubview(mainViewContainer!) view.addSubview(mainViewContainer!)
} }
...@@ -1253,7 +1253,7 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer ...@@ -1253,7 +1253,7 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer
private func prepareBackdropContainer() { private func prepareBackdropContainer() {
backdropViewContainer = UIView(frame: view.bounds) backdropViewContainer = UIView(frame: view.bounds)
backdropViewContainer!.backgroundColor = options.backdropBackgroundColor backdropViewContainer!.backgroundColor = options.backdropBackgroundColor
backdropViewContainer!.autoresizingMask = .FlexibleHeight | .FlexibleWidth backdropViewContainer!.autoresizingMask = [.FlexibleHeight, .FlexibleWidth]
backdropViewContainer!.layer.opacity = 0 backdropViewContainer!.layer.opacity = 0
view.addSubview(backdropViewContainer!) view.addSubview(backdropViewContainer!)
} }
...@@ -1311,7 +1311,7 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer ...@@ -1311,7 +1311,7 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer
// //
private func prepareContainerToOpen(inout viewController: UIViewController?, inout viewContainer: UIView?, state: SideNavigationViewState) { private func prepareContainerToOpen(inout viewController: UIViewController?, inout viewContainer: UIView?, state: SideNavigationViewState) {
addShadow(&viewContainer) addShadow(&viewContainer)
toggleStatusBar(hide: true) toggleStatusBar(true)
} }
// //
...@@ -1327,7 +1327,7 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer ...@@ -1327,7 +1327,7 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer
private func prepareContainedViewController(inout viewContainer: UIView?, inout viewController: UIViewController?) { private func prepareContainedViewController(inout viewContainer: UIView?, inout viewController: UIViewController?) {
if let vc = viewController { if let vc = viewController {
if let c = viewContainer { if let c = viewContainer {
vc.view.setTranslatesAutoresizingMaskIntoConstraints(false) vc.view.translatesAutoresizingMaskIntoConstraints = false
addChildViewController(vc) addChildViewController(vc)
c.addSubview(vc.view) c.addSubview(vc.view)
Layout.expandToParent(c, child: vc.view) Layout.expandToParent(c, child: vc.view)
......
...@@ -27,7 +27,7 @@ public class TextView: UITextView { ...@@ -27,7 +27,7 @@ public class TextView: UITextView {
/** /**
:name: init :name: init
*/ */
public required init(coder aDecoder: NSCoder) { public required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder) super.init(coder: aDecoder)
prepareView() prepareView()
} }
...@@ -38,7 +38,7 @@ public class TextView: UITextView { ...@@ -38,7 +38,7 @@ public class TextView: UITextView {
public override init(frame: CGRect, textContainer: NSTextContainer?) { public override init(frame: CGRect, textContainer: NSTextContainer?) {
super.init(frame: frame, textContainer: textContainer) super.init(frame: frame, textContainer: textContainer)
if CGRectZero == frame { if CGRectZero == frame {
setTranslatesAutoresizingMaskIntoConstraints(false) translatesAutoresizingMaskIntoConstraints = false
} }
prepareView() prepareView()
} }
...@@ -58,7 +58,7 @@ public class TextView: UITextView { ...@@ -58,7 +58,7 @@ public class TextView: UITextView {
public var placeholderLabel: UILabel? { public var placeholderLabel: UILabel? {
didSet { didSet {
if let p = placeholderLabel { if let p = placeholderLabel {
p.setTranslatesAutoresizingMaskIntoConstraints(false) p.translatesAutoresizingMaskIntoConstraints = false
p.font = font p.font = font
p.textAlignment = textAlignment p.textAlignment = textAlignment
p.numberOfLines = 0 p.numberOfLines = 0
...@@ -137,7 +137,7 @@ public class TextView: UITextView { ...@@ -137,7 +137,7 @@ public class TextView: UITextView {
if let p = placeholderLabel { if let p = placeholderLabel {
NSLayoutConstraint.deactivateConstraints(layoutConstraints) NSLayoutConstraint.deactivateConstraints(layoutConstraints)
layoutConstraints = Layout.constraint("H:|-(left)-[placeholderLabel]-(right)-|", layoutConstraints = Layout.constraint("H:|-(left)-[placeholderLabel]-(right)-|",
options: nil, options: [],
metrics: [ metrics: [
"left": textContainerInset.left + textContainer.lineFragmentPadding, "left": textContainerInset.left + textContainer.lineFragmentPadding,
"right": textContainerInset.right + textContainer.lineFragmentPadding "right": textContainerInset.right + textContainer.lineFragmentPadding
...@@ -146,7 +146,7 @@ public class TextView: UITextView { ...@@ -146,7 +146,7 @@ public class TextView: UITextView {
]) ])
layoutConstraints += Layout.constraint("V:|-(top)-[placeholderLabel]-(>=bottom)-|", layoutConstraints += Layout.constraint("V:|-(top)-[placeholderLabel]-(>=bottom)-|",
options: nil, options: [],
metrics: [ metrics: [
"top": textContainerInset.top, "top": textContainerInset.top,
"bottom": textContainerInset.bottom "bottom": textContainerInset.bottom
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment