Skip to content

Commit

Permalink
fix #29 doneHandler deprecated (#33)
Browse files Browse the repository at this point in the history
* fix #29 doneHandler deprecated

replace viewDidDisappear to viewWillDisappear for call self.dismissHandler

* fix #29 replace deprecated with unavailable for doneHandler
  • Loading branch information
UriyDevyataev authored Aug 30, 2023
1 parent 562fdcf commit 596a57f
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions Sources/Views/Controller.swift
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ open class FastisController<Value: FastisValue>: UIViewController, JTACMonthView
self.doneBarButtonItem.isEnabled = self.allowToChooseNilDate || self.value != nil
}
}

private var isDone = false

/**
Expand Down Expand Up @@ -214,6 +215,12 @@ open class FastisController<Value: FastisValue>: UIViewController, JTACMonthView
*/
public var dismissHandler: ((DismissAction) -> Void)?

/**
The block to execute after "Done" button will be tapped
*/
@available(*, unavailable, message: "use dismissHandler: ((DismissAction) -> Void)?")
public var doneHandler: ((Value?) -> Void)?

/**
And initial value which will be selected by default
*/
Expand Down Expand Up @@ -276,8 +283,8 @@ open class FastisController<Value: FastisValue>: UIViewController, JTACMonthView
self.configureInitialState()
}

open override func viewDidDisappear(_ animated: Bool) {
super.viewDidDisappear(animated)
override open func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)

if self.isDone {
self.dismissHandler?(.done(self.value))
Expand Down

0 comments on commit 596a57f

Please sign in to comment.