Skip to content

Commit

Permalink
Merge pull request #1 from octopus-energy/mattjung/onDismiss
Browse files Browse the repository at this point in the history
Add `onDismiss` to route API
  • Loading branch information
mattjung authored Jun 14, 2022
2 parents a52c8ef + 06dc3fa commit 2e6bc0a
Showing 1 changed file with 38 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,16 @@ public extension NavigationCoordinatable {
self.popTo(-1, action)
return self
}


@discardableResult func route<Input, Output: Coordinatable>(
to route: KeyPath<Self, Transition<Self, Presentation, Input, Output>>,
_ input: Input,
onDismiss: @escaping () -> ()
) -> Output {
stack.dismissalAction[-1] = onDismiss
return self.route(to: route, input)
}

@discardableResult func route<Input, Output: Coordinatable>(
to route: KeyPath<Self, Transition<Self, Presentation, Input, Output>>,
_ input: Input
Expand All @@ -379,7 +388,15 @@ public extension NavigationCoordinatable {
output.parent = self
return output
}


@discardableResult func route<Output: Coordinatable>(
to route: KeyPath<Self, Transition<Self, Presentation, Void, Output>>,
onDismiss: @escaping () -> ()
) -> Output {
stack.dismissalAction[-1] = onDismiss
return self.route(to: route)
}

@discardableResult func route<Output: Coordinatable>(
to route: KeyPath<Self, Transition<Self, Presentation, Void, Output>>
) -> Output {
Expand All @@ -396,7 +413,16 @@ public extension NavigationCoordinatable {
output.parent = self
return output
}


@discardableResult func route<Input, Output: View>(
to route: KeyPath<Self, Transition<Self, Presentation, Input, Output>>,
_ input: Input,
onDismiss: @escaping () -> ()
) -> Self {
stack.dismissalAction[-1] = onDismiss
return self.route(to: route, input)
}

@discardableResult func route<Input, Output: View>(
to route: KeyPath<Self, Transition<Self, Presentation, Input, Output>>,
_ input: Input
Expand All @@ -413,7 +439,15 @@ public extension NavigationCoordinatable {
)
return self
}


@discardableResult func route<Output: View>(
to route: KeyPath<Self, Transition<Self, Presentation, Void, Output>>,
onDismiss: @escaping () -> ()
) -> Self {
stack.dismissalAction[-1] = onDismiss
return self.route(to: route)
}

@discardableResult func route<Output: View>(
to route: KeyPath<Self, Transition<Self, Presentation, Void, Output>>
) -> Self {
Expand Down

0 comments on commit 2e6bc0a

Please sign in to comment.