-
Notifications
You must be signed in to change notification settings - Fork 93
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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Change window access modifier to open #46
Changes from all commits
311e0d1
934b02a
ce4d903
2c5451f
6e89f5c
aca10de
f12793f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,20 +11,10 @@ class FingerTipView: UIImageView { | |
} | ||
|
||
@objc (MBXFingerTipOverlayWindow) | ||
class FingerTipOverlayWindow: UIWindow { | ||
override var rootViewController: UIViewController? { | ||
set { | ||
super.rootViewController = newValue | ||
} | ||
|
||
get { | ||
return FingerTipWindow.fingerTipWindow?.rootViewController ?? super.rootViewController | ||
} | ||
} | ||
} | ||
class FingerTipOverlayWindow: UIWindow {} | ||
|
||
@objc (MBXFingerTipWindow) | ||
public class FingerTipWindow: UIWindow { | ||
open class FingerTipWindow: UIWindow { | ||
|
||
public static var fingerTipWindow: FingerTipWindow? { | ||
return UIApplication.shared.windows.compactMap({ $0 as? FingerTipWindow }).first | ||
|
@@ -97,7 +87,11 @@ public class FingerTipWindow: UIWindow { | |
var action: Bool? | ||
var fingerTipRemovalScheduled: Bool = false | ||
|
||
required init?(coder aDecoder: NSCoder) { | ||
deinit { | ||
NotificationCenter.default.removeObserver(self) | ||
} | ||
|
||
required public init?(coder aDecoder: NSCoder) { | ||
super.init(coder: aDecoder) | ||
|
||
commonInit() | ||
|
@@ -200,13 +194,6 @@ public class FingerTipWindow: UIWindow { | |
perform(#selector(removeInactiveFingerTips), with: nil, afterDelay: 0.1) | ||
} | ||
|
||
func cancelScheduledFingerTipRemoval() { | ||
fingerTipRemovalScheduled = true | ||
NSObject.cancelPreviousPerformRequests(withTarget: self, | ||
selector: #selector(removeInactiveFingerTips), | ||
object: nil) | ||
} | ||
|
||
Comment on lines
-203
to
-209
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is not used; I imagine that it was once used in conjunction with the |
||
@objc func removeInactiveFingerTips() { | ||
fingerTipRemovalScheduled = false | ||
|
||
|
@@ -233,16 +220,27 @@ public class FingerTipWindow: UIWindow { | |
return | ||
} | ||
|
||
UIView.animate(withDuration: fadeDuration) { | ||
let animation = { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
touchView.alpha = 0 | ||
touchView.frame = CGRect(x: touchView.center.x - touchView.frame.size.width / 1.5, | ||
y: touchView.center.y - touchView.frame.size.height / 1.5, | ||
width: touchView.frame.size.width * 1.5, | ||
height: touchView.frame.size.height * 1.5) | ||
} | ||
|
||
let completion: (Bool) -> () = { _ in | ||
touchView.fadingOut = false | ||
touchView.removeFromSuperview() | ||
} | ||
|
||
touchView.fadingOut = true | ||
touchView.perform(#selector(removeFromSuperview), with: nil, afterDelay: fadeDuration) | ||
|
||
if animated { | ||
UIView.animate(withDuration: fadeDuration, animations: animation, completion: completion) | ||
} else { | ||
animation() | ||
completion(true) | ||
} | ||
} | ||
|
||
func shouldAutomaticallyRemoveFingerTip(for touch: UITouch) -> Bool { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was causing a warning in logs; the getter also looks suspicious - sharing a view controller between UIWindows sounds dangerous. I don't see any issue with removing this code.