Added method to NavigationHandler which handles removing specific viewController object.
Added previousActionCompletion block to Model. Called previousAction completion callback in ActionPreviousSubmitModel.
This commit is contained in:
parent
42fdeb75b1
commit
2830e044c0
@ -43,5 +43,8 @@ open class ActionPreviousSubmitHandler: MVMCoreJSONActionHandlerProtocol {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if let _model = model as? ActionPreviousSubmitModel, let callBack = _model.completionHandler {
|
||||||
|
await callBack()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -11,11 +11,19 @@ public struct ActionPreviousSubmitModel: ActionModelProtocol {
|
|||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Properties
|
// MARK: - Properties
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
public typealias previousActionCompletion = (() async -> Void)
|
||||||
public static var identifier: String = "previousSubmit"
|
public static var identifier: String = "previousSubmit"
|
||||||
public var actionType: String = ActionPreviousSubmitModel.identifier
|
public var actionType: String = ActionPreviousSubmitModel.identifier
|
||||||
public var extraParameters: JSONValueDictionary?
|
public var extraParameters: JSONValueDictionary?
|
||||||
public var analyticsData: JSONValueDictionary?
|
public var analyticsData: JSONValueDictionary?
|
||||||
|
public var completionHandler : previousActionCompletion?
|
||||||
|
|
||||||
|
private enum CodingKeys: String, CodingKey {
|
||||||
|
case actionType
|
||||||
|
case completionHandler
|
||||||
|
case extraParameters
|
||||||
|
case analyticsData
|
||||||
|
}
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Initialzier
|
// MARK: - Initialzier
|
||||||
@ -26,6 +34,24 @@ public struct ActionPreviousSubmitModel: ActionModelProtocol {
|
|||||||
self.analyticsData = analyticsData
|
self.analyticsData = analyticsData
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public init(_ extraParameters: JSONValueDictionary? = nil, _ analyticsData: JSONValueDictionary? = nil, completionHandler handler: @escaping previousActionCompletion) {
|
||||||
|
self.init(extraParameters, analyticsData)
|
||||||
|
self.completionHandler = handler
|
||||||
|
}
|
||||||
|
|
||||||
|
public init(from decoder: any Decoder) throws {
|
||||||
|
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
||||||
|
extraParameters = try typeContainer.decodeIfPresent(JSONValueDictionary.self, forKey: .extraParameters)
|
||||||
|
analyticsData = try typeContainer.decodeIfPresent(JSONValueDictionary.self, forKey: .analyticsData)
|
||||||
|
}
|
||||||
|
|
||||||
|
public func encode(to encoder: any Encoder) throws {
|
||||||
|
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||||
|
try container.encode(actionType, forKey: .actionType)
|
||||||
|
try container.encodeIfPresent(extraParameters, forKey: .extraParameters)
|
||||||
|
try container.encodeIfPresent(analyticsData, forKey: .analyticsData)
|
||||||
|
}
|
||||||
|
|
||||||
// Default
|
// Default
|
||||||
public func isEqual(to model: any ModelComparisonProtocol) -> Bool {
|
public func isEqual(to model: any ModelComparisonProtocol) -> Bool {
|
||||||
guard let model = model as? Self else { return false }
|
guard let model = model as? Self else { return false }
|
||||||
|
|||||||
@ -177,6 +177,10 @@ public class NavigationHandler {
|
|||||||
await navigate(with: .dismiss(viewController: presentedViewController), delegateObject: delegateObject)
|
await navigate(with: .dismiss(viewController: presentedViewController), delegateObject: delegateObject)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public func remove(viewController: UIViewController) async {
|
||||||
|
await self.navigationController?.removeViewController(viewController: viewController)
|
||||||
|
}
|
||||||
|
|
||||||
public func removeCurrentViewController(delegateObject: DelegateObject? = nil, animated: Bool = true) async {
|
public func removeCurrentViewController(delegateObject: DelegateObject? = nil, animated: Bool = true) async {
|
||||||
if let presentedViewController = await getTopMostPresentedViewController() {
|
if let presentedViewController = await getTopMostPresentedViewController() {
|
||||||
if let navigationController = (presentedViewController as? UINavigationController),
|
if let navigationController = (presentedViewController as? UINavigationController),
|
||||||
@ -217,6 +221,11 @@ public extension UINavigationController {
|
|||||||
func getViewControllers() -> [UIViewController] {
|
func getViewControllers() -> [UIViewController] {
|
||||||
NavigationHandler.shared().getViewControllers(for: self)
|
NavigationHandler.shared().getViewControllers(for: self)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@objc @MainActor
|
||||||
|
func removeViewController(viewController: UIViewController) {
|
||||||
|
self.viewControllers.removeAll { $0 === viewController }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extension UIViewController {
|
extension UIViewController {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user