Outage detection.

pull/1/head
Matthew Chen 7 years ago
parent 793a868e6f
commit ae50dbe198

@ -9,11 +9,9 @@ class ReminderView: UIView {
let TAG = "[ReminderView]" let TAG = "[ReminderView]"
let label = UILabel() let label = UILabel()
static let defaultTapAction = { typealias Action = () -> Void
Logger.debug("[ReminderView] tapped.")
}
var tapAction: () -> Void var tapAction: (() -> Void)?
var text: String? { var text: String? {
get { get {
@ -44,7 +42,7 @@ class ReminderView: UIView {
} }
private init(mode: ReminderViewMode, private init(mode: ReminderViewMode,
text: String, tapAction: @escaping () -> Void) { text: String, tapAction: Action?) {
self.mode = mode self.mode = mode
self.tapAction = tapAction self.tapAction = tapAction
@ -55,12 +53,12 @@ class ReminderView: UIView {
setupSubviews() setupSubviews()
} }
@objc public class func nag(text: String, tapAction: @escaping () -> Void) -> ReminderView { @objc public class func nag(text: String, tapAction: Action?) -> ReminderView {
return ReminderView(mode: .nag, text: text, tapAction: tapAction) return ReminderView(mode: .nag, text: text, tapAction: tapAction)
} }
@objc public class func explanation(text: String) -> ReminderView { @objc public class func explanation(text: String) -> ReminderView {
return ReminderView(mode: .explanation, text: text, tapAction: ReminderView.defaultTapAction) return ReminderView(mode: .explanation, text: text, tapAction: nil)
} }
func setupSubviews() { func setupSubviews() {
@ -121,6 +119,9 @@ class ReminderView: UIView {
} }
@objc func handleTap(gestureRecognizer: UIGestureRecognizer) { @objc func handleTap(gestureRecognizer: UIGestureRecognizer) {
tapAction() guard gestureRecognizer.state == .recognized else {
return
}
tapAction?()
} }
} }

Loading…
Cancel
Save