Commit 62a7d0e0 by Orkhan Alikhanov

Renamed DialogController event handlers

parent 85c13ac2
...@@ -26,7 +26,7 @@ open class DialogBuilder<T: DialogView> { ...@@ -26,7 +26,7 @@ open class DialogBuilder<T: DialogView> {
open func isCancelable(_ value: Bool, handler: (() -> Void)? = nil) -> DialogBuilder { open func isCancelable(_ value: Bool, handler: (() -> Void)? = nil) -> DialogBuilder {
controller.isCancelable = value controller.isCancelable = value
controller.canceledHandler = handler controller.didCancelHandler = handler
return self return self
} }
...@@ -37,19 +37,19 @@ open class DialogBuilder<T: DialogView> { ...@@ -37,19 +37,19 @@ open class DialogBuilder<T: DialogView> {
open func positive(_ title: String?, handler: (() -> Void)?) -> DialogBuilder { open func positive(_ title: String?, handler: (() -> Void)?) -> DialogBuilder {
dialogView.positiveButton.title = title dialogView.positiveButton.title = title
controller.positiveHandler = handler controller.didTapPositiveButtonHandler = handler
return self return self
} }
open func negative(_ title: String?, handler: (() -> Void)?) -> DialogBuilder { open func negative(_ title: String?, handler: (() -> Void)?) -> DialogBuilder {
dialogView.negativeButton.title = title dialogView.negativeButton.title = title
controller.negativeHandler = handler controller.didTapNegativeButtonHandler = handler
return self return self
} }
open func neutral(_ title: String?, handler: (() -> Void)?) -> DialogBuilder { open func neutral(_ title: String?, handler: (() -> Void)?) -> DialogBuilder {
dialogView.neutralButton.title = title dialogView.neutralButton.title = title
controller.neutralHandler = handler controller.didTapNeutralButtonHandler = handler
return self return self
} }
......
...@@ -36,29 +36,29 @@ open class DialogController<T: DialogView>: UIViewController { ...@@ -36,29 +36,29 @@ open class DialogController<T: DialogView>: UIViewController {
dialogView.maxSize = CGSize(width: Screen.width * 0.8, height: Screen.height * 0.9) dialogView.maxSize = CGSize(width: Screen.width * 0.8, height: Screen.height * 0.9)
} }
open var canceledHandler: (() -> Void)? open var didCancelHandler: (() -> Void)?
open var shouldDismissHandler: ((Button?) -> Bool)? open var shouldDismissHandler: ((Button?) -> Bool)?
open var positiveHandler: (() -> Void)? open var didTapPositiveButtonHandler: (() -> Void)?
open var negativeHandler: (() -> Void)? open var didTapNegativeButtonHandler: (() -> Void)?
open var neutralHandler: (() -> Void)? open var didTapNeutralButtonHandler: (() -> Void)?
@objc @objc
private func didTapView() { private func didTapView() {
guard isCancelable else { return } guard isCancelable else { return }
dismiss(nil) dismiss(nil)
canceledHandler?() didCancelHandler?()
} }
@objc @objc
private func didTapButton(_ sender: Button) { private func didTapButton(_ sender: Button) {
switch sender { switch sender {
case dialogView.positiveButton: case dialogView.positiveButton:
positiveHandler?() didTapPositiveButtonHandler?()
case dialogView.negativeButton: case dialogView.negativeButton:
negativeHandler?() didTapNegativeButtonHandler?()
case dialogView.neutralButton: case dialogView.neutralButton:
neutralHandler?() didTapNeutralButtonHandler?()
default: default:
break break
} }
......
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