Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set navigationDismissTriggered flag when popping by specific route #17

Merged
merged 1 commit into from
Jul 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading