Commit 3130d7be by Daniel Dahan

minor cleanup to self references

parent 4433996f
Subproject commit 8840fda209630cfaa986312702610ea877a15ae1 Subproject commit d74082864a5df29e98eda1ddcdcec167aab5d805
...@@ -107,11 +107,11 @@ extension FABMenuItem { ...@@ -107,11 +107,11 @@ extension FABMenuItem {
titleLabel.isHidden = false titleLabel.isHidden = false
UIView.animate(withDuration: 0.25, animations: { [weak self] in UIView.animate(withDuration: 0.25, animations: { [weak self] in
guard let s = self else { guard let `self` = self else {
return return
} }
s.titleLabel.alpha = 1 `self`.titleLabel.alpha = 1
}) })
} }
...@@ -365,18 +365,18 @@ extension FABMenu { ...@@ -365,18 +365,18 @@ extension FABMenu {
} }
spring.expand(duration: duration, delay: delay, usingSpringWithDamping: usingSpringWithDamping, initialSpringVelocity: initialSpringVelocity, options: options, animations: animations) { [weak self, isTriggeredByUserInteraction = isTriggeredByUserInteraction, completion = completion] (view) in spring.expand(duration: duration, delay: delay, usingSpringWithDamping: usingSpringWithDamping, initialSpringVelocity: initialSpringVelocity, options: options, animations: animations) { [weak self, isTriggeredByUserInteraction = isTriggeredByUserInteraction, completion = completion] (view) in
guard let s = self else { guard let `self` = self else {
return return
} }
(view as? FABMenuItem)?.showTitleLabel() (view as? FABMenuItem)?.showTitleLabel()
if isTriggeredByUserInteraction && view == s.fabMenuItems.last { if isTriggeredByUserInteraction && view == self.fabMenuItems.last {
s.delegate?.fabMenuDidOpen?(fabMenu: s) self.delegate?.fabMenuDidOpen?(fabMenu: self)
} }
completion?(view) completion?(view)
s.handleCompletionCallback?(view) self.handleCompletionCallback?(view)
} }
} }
...@@ -414,18 +414,18 @@ extension FABMenu { ...@@ -414,18 +414,18 @@ extension FABMenu {
} }
spring.contract(duration: duration, delay: delay, usingSpringWithDamping: usingSpringWithDamping, initialSpringVelocity: initialSpringVelocity, options: options, animations: animations) { [weak self, isTriggeredByUserInteraction = isTriggeredByUserInteraction, completion = completion] (view) in spring.contract(duration: duration, delay: delay, usingSpringWithDamping: usingSpringWithDamping, initialSpringVelocity: initialSpringVelocity, options: options, animations: animations) { [weak self, isTriggeredByUserInteraction = isTriggeredByUserInteraction, completion = completion] (view) in
guard let s = self else { guard let `self` = self else {
return return
} }
(view as? FABMenuItem)?.hideTitleLabel() (view as? FABMenuItem)?.hideTitleLabel()
if isTriggeredByUserInteraction && view == s.fabMenuItems.last { if isTriggeredByUserInteraction && view == self.fabMenuItems.last {
s.delegate?.fabMenuDidClose?(fabMenu: s) self.delegate?.fabMenuDidClose?(fabMenu: self)
} }
completion?(view) completion?(view)
s.handleCompletionCallback?(view) self.handleCompletionCallback?(view)
} }
} }
} }
......
...@@ -415,11 +415,11 @@ open class NavigationDrawerController: TransitionController { ...@@ -415,11 +415,11 @@ open class NavigationDrawerController: TransitionController {
open override func transition(to viewController: UIViewController, completion: ((Bool) -> Void)? = nil) { open override func transition(to viewController: UIViewController, completion: ((Bool) -> Void)? = nil) {
super.transition(to: viewController) { [weak self, completion = completion] (result) in super.transition(to: viewController) { [weak self, completion = completion] (result) in
guard let s = self else { guard let `self` = self else {
return return
} }
s.view.sendSubview(toBack: s.contentViewController.view) self.view.sendSubview(toBack: self.contentViewController.view)
completion?(result) completion?(result)
} }
} }
...@@ -524,43 +524,43 @@ open class NavigationDrawerController: TransitionController { ...@@ -524,43 +524,43 @@ open class NavigationDrawerController: TransitionController {
if hide { if hide {
UIView.animate(withDuration: duration, UIView.animate(withDuration: duration,
animations: { [weak self, v = v] in animations: { [weak self, v = v] in
guard let s = self else { guard let `self` = self else {
return return
} }
v.bounds.size.width = width v.bounds.size.width = width
v.layer.position.x = -width / 2 v.layer.position.x = -width / 2
s.rootViewController.view.alpha = 1 self.rootViewController.view.alpha = 1
}) { [weak self, v = v] _ in }) { [weak self, v = v] _ in
guard let s = self else { guard let `self` = self else {
return return
} }
v.isShadowPathAutoSizing = true v.isShadowPathAutoSizing = true
s.layoutSubviews() self.layoutSubviews()
s.hideView(container: v) self.hideView(container: v)
} }
} else { } else {
UIView.animate(withDuration: duration, UIView.animate(withDuration: duration,
animations: { [weak self, v = v] in animations: { [weak self, v = v] in
guard let s = self else { guard let `self` = self else {
return return
} }
v.bounds.size.width = width v.bounds.size.width = width
v.layer.position.x = width / 2 v.layer.position.x = width / 2
s.rootViewController.view.alpha = 0.5 self.rootViewController.view.alpha = 0.5
}) { [weak self, v = v] _ in }) { [weak self, v = v] _ in
guard let s = self else { guard let `self` = self else {
return return
} }
v.isShadowPathAutoSizing = true v.isShadowPathAutoSizing = true
s.layoutSubviews() self.layoutSubviews()
s.showView(container: v) self.showView(container: v)
} }
} }
} else { } else {
...@@ -610,43 +610,43 @@ open class NavigationDrawerController: TransitionController { ...@@ -610,43 +610,43 @@ open class NavigationDrawerController: TransitionController {
if hide { if hide {
UIView.animate(withDuration: duration, UIView.animate(withDuration: duration,
animations: { [weak self, v = v] in animations: { [weak self, v = v] in
guard let s = self else { guard let `self` = self else {
return return
} }
v.bounds.size.width = width v.bounds.size.width = width
v.layer.position.x = s.view.bounds.width + width / 2 v.layer.position.x = self.view.bounds.width + width / 2
s.rootViewController.view.alpha = 1 self.rootViewController.view.alpha = 1
}) { [weak self, v = v] _ in }) { [weak self, v = v] _ in
guard let s = self else { guard let `self` = self else {
return return
} }
v.isShadowPathAutoSizing = true v.isShadowPathAutoSizing = true
s.layoutSubviews() self.layoutSubviews()
s.hideView(container: v) self.hideView(container: v)
} }
} else { } else {
UIView.animate(withDuration: duration, UIView.animate(withDuration: duration,
animations: { [weak self, v = v] in animations: { [weak self, v = v] in
guard let s = self else { guard let `self` = self else {
return return
} }
v.bounds.size.width = width v.bounds.size.width = width
v.layer.position.x = s.view.bounds.width - width / 2 v.layer.position.x = self.view.bounds.width - width / 2
s.rootViewController.view.alpha = 0.5 self.rootViewController.view.alpha = 0.5
}) { [weak self, v = v] _ in }) { [weak self, v = v] _ in
guard let s = self else { guard let `self` = self else {
return return
} }
v.isShadowPathAutoSizing = true v.isShadowPathAutoSizing = true
s.layoutSubviews() self.layoutSubviews()
s.showView(container: v) self.showView(container: v)
} }
} }
} else { } else {
...@@ -719,20 +719,20 @@ open class NavigationDrawerController: TransitionController { ...@@ -719,20 +719,20 @@ open class NavigationDrawerController: TransitionController {
UIView.animate(withDuration: TimeInterval(0 == velocity ? animationDuration : fmax(0.1, fmin(1, Double(v.frame.origin.x / velocity)))), UIView.animate(withDuration: TimeInterval(0 == velocity ? animationDuration : fmax(0.1, fmin(1, Double(v.frame.origin.x / velocity)))),
animations: { [weak self, v = v] in animations: { [weak self, v = v] in
guard let s = self else { guard let `self` = self else {
return return
} }
v.layer.position.x = v.bounds.width / 2 v.layer.position.x = v.bounds.width / 2
s.rootViewController.view.alpha = 0.5 self.rootViewController.view.alpha = 0.5
}) { [weak self] _ in }) { [weak self] _ in
guard let s = self else { guard let `self` = self else {
return return
} }
s.isAnimating = false self.isAnimating = false
s.delegate?.navigationDrawerController?(navigationDrawerController: s, didOpen: .left) self.delegate?.navigationDrawerController?(navigationDrawerController: self, didOpen: .left)
} }
} }
...@@ -766,21 +766,21 @@ open class NavigationDrawerController: TransitionController { ...@@ -766,21 +766,21 @@ open class NavigationDrawerController: TransitionController {
UIView.animate(withDuration: TimeInterval(0 == velocity ? animationDuration : fmax(0.1, fmin(1, Double(v.frame.origin.x / velocity)))), UIView.animate(withDuration: TimeInterval(0 == velocity ? animationDuration : fmax(0.1, fmin(1, Double(v.frame.origin.x / velocity)))),
animations: { [weak self, v = v] in animations: { [weak self, v = v] in
guard let s = self else { guard let `self` = self else {
return return
} }
v.layer.position.x = s.view.bounds.width - v.bounds.width / 2 v.layer.position.x = self.view.bounds.width - v.bounds.width / 2
s.rootViewController.view.alpha = 0.5 self.rootViewController.view.alpha = 0.5
}) { [weak self] _ in }) { [weak self] _ in
guard let s = self else { guard let `self` = self else {
return return
} }
s.isAnimating = false self.isAnimating = false
s.delegate?.navigationDrawerController?(navigationDrawerController: s, didOpen: .right) self.delegate?.navigationDrawerController?(navigationDrawerController: self, didOpen: .right)
} }
} }
...@@ -809,25 +809,25 @@ open class NavigationDrawerController: TransitionController { ...@@ -809,25 +809,25 @@ open class NavigationDrawerController: TransitionController {
UIView.animate(withDuration: TimeInterval(0 == velocity ? animationDuration : fmax(0.1, fmin(1, Double(v.frame.origin.x / velocity)))), UIView.animate(withDuration: TimeInterval(0 == velocity ? animationDuration : fmax(0.1, fmin(1, Double(v.frame.origin.x / velocity)))),
animations: { [weak self, v = v] in animations: { [weak self, v = v] in
guard let s = self else { guard let `self` = self else {
return return
} }
v.layer.position.x = -v.bounds.width / 2 v.layer.position.x = -v.bounds.width / 2
s.rootViewController.view.alpha = 1 self.rootViewController.view.alpha = 1
}) { [weak self, v = v] _ in }) { [weak self, v = v] _ in
guard let s = self else { guard let `self` = self else {
return return
} }
s.hideView(container: v) self.hideView(container: v)
s.toggleStatusBar() self.toggleStatusBar()
s.isAnimating = false self.isAnimating = false
s.isUserInteractionEnabled = true self.isUserInteractionEnabled = true
s.delegate?.navigationDrawerController?(navigationDrawerController: s, didClose: .left) self.delegate?.navigationDrawerController?(navigationDrawerController: self, didClose: .left)
} }
} }
...@@ -856,25 +856,25 @@ open class NavigationDrawerController: TransitionController { ...@@ -856,25 +856,25 @@ open class NavigationDrawerController: TransitionController {
UIView.animate(withDuration: TimeInterval(0 == velocity ? animationDuration : fmax(0.1, fmin(1, Double(v.frame.origin.x / velocity)))), UIView.animate(withDuration: TimeInterval(0 == velocity ? animationDuration : fmax(0.1, fmin(1, Double(v.frame.origin.x / velocity)))),
animations: { [weak self, v = v] in animations: { [weak self, v = v] in
guard let s = self else { guard let `self` = self else {
return return
} }
v.layer.position.x = s.view.bounds.width + v.bounds.width / 2 v.layer.position.x = self.view.bounds.width + v.bounds.width / 2
s.rootViewController.view.alpha = 1 self.rootViewController.view.alpha = 1
}) { [weak self, v = v] _ in }) { [weak self, v = v] _ in
guard let s = self else { guard let `self` = self else {
return return
} }
s.hideView(container: v) self.hideView(container: v)
s.toggleStatusBar() self.toggleStatusBar()
s.isAnimating = false self.isAnimating = false
s.isUserInteractionEnabled = true self.isUserInteractionEnabled = true
s.delegate?.navigationDrawerController?(navigationDrawerController: s, didClose: .right) self.delegate?.navigationDrawerController?(navigationDrawerController: self, didClose: .right)
} }
} }
...@@ -934,17 +934,17 @@ open class NavigationDrawerController: TransitionController { ...@@ -934,17 +934,17 @@ open class NavigationDrawerController: TransitionController {
/// Shows the statusBar. /// Shows the statusBar.
fileprivate func showStatusBar() { fileprivate func showStatusBar() {
Motion.async { [weak self] in Motion.async { [weak self] in
guard let s = self else {
return
}
guard let v = Application.keyWindow else { guard let v = Application.keyWindow else {
return return
} }
v.windowLevel = UIWindowLevelNormal v.windowLevel = UIWindowLevelNormal
s.delegate?.navigationDrawerController?(navigationDrawerController: s, statusBar: false) guard let `self` = self else {
return
}
self.delegate?.navigationDrawerController?(navigationDrawerController: self, statusBar: false)
} }
} }
...@@ -955,17 +955,17 @@ open class NavigationDrawerController: TransitionController { ...@@ -955,17 +955,17 @@ open class NavigationDrawerController: TransitionController {
} }
Motion.async { [weak self] in Motion.async { [weak self] in
guard let s = self else {
return
}
guard let v = Application.keyWindow else { guard let v = Application.keyWindow else {
return return
} }
v.windowLevel = UIWindowLevelStatusBar + 1 v.windowLevel = UIWindowLevelStatusBar + 1
s.delegate?.navigationDrawerController?(navigationDrawerController: s, statusBar: true) guard let `self` = self else {
return
}
self.delegate?.navigationDrawerController?(navigationDrawerController: self, statusBar: true)
} }
} }
......
...@@ -744,13 +744,13 @@ extension TextField { ...@@ -744,13 +744,13 @@ extension TextField {
} }
UIView.animate(withDuration: 0.15, animations: { [weak self] in UIView.animate(withDuration: 0.15, animations: { [weak self] in
guard let s = self else { guard let `self` = self else {
return return
} }
s.placeholderLabel.transform = CGAffineTransform.identity self.placeholderLabel.transform = CGAffineTransform.identity
s.placeholderLabel.frame.origin.x = s.leftViewWidth + s.textInset self.placeholderLabel.frame.origin.x = s.leftViewWidth + s.textInset
s.placeholderLabel.frame.origin.y = 0 self.placeholderLabel.frame.origin.y = 0
}) })
} }
} }
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