Skip to content

Commit

Permalink
set dismiss trigger flag when popping by name or ID (#17)
Browse files Browse the repository at this point in the history
  • Loading branch information
renaudpg authored Jul 16, 2024
1 parent 1d95d53 commit 3f78c57
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions navigation/ios/NavigationState.swift
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class NavigationState<
return false
}

dedounceNavigation { [weak self] in
debounceNavigation { [weak self] in
guard let self else { return }
top().child = NavigationState(navigation: navigation, route: route)
}
Expand All @@ -66,20 +66,26 @@ class NavigationState<
override func popTo(route: PilotNavigationRoute, inclusive: Bool) {
guard let route = route as? Route else { fatalError("Invalid route type") }

dedounceNavigation { [weak self] in
debounceNavigation { [weak self] in
guard let self else { return }
if let routeNavigationState = findLast(route: route) {
if inclusive {
findParent(state: routeNavigationState)?.child = nil
let state = inclusive ? findParent(state: routeNavigationState) : routeNavigationState
guard let state else { return }

if let popDelayInSeconds = state.child?.navigation.popDelayInSeconds {
state.child?.navigationDismissTriggered = true
DispatchQueue.main.asyncAfter(deadline: .now() + popDelayInSeconds) {
state.child = nil
}
} else {
routeNavigationState.child = nil
state.child = nil
}
}
}
}

override func pop() {
dedounceNavigation { [weak self] in
debounceNavigation { [weak self] in
if let topPresenter = self?.topPresenter() {
if let popDelayInSeconds = topPresenter.child?.navigation.popDelayInSeconds {
topPresenter.child?.navigationDismissTriggered = true
Expand All @@ -95,7 +101,7 @@ class NavigationState<
}
}

private func dedounceNavigation(action: @escaping () -> Void) {
private func debounceNavigation(action: @escaping () -> Void) {
let navigationAnimationDuration = 0.55

if let lastNavigationDate {
Expand Down

0 comments on commit 3f78c57

Please sign in to comment.