-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#### Added - Deep links support for nested NavigationStorages. - Updated docs, tests and code comments. #### Fixed - Issue with async call in MainActor from deeplink methods `checkSubAction` and `replace`. This was reproduced only from iOS 16 (iOS 15, 17 don't).
- Loading branch information
Showing
10 changed files
with
181 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// | ||
// NavigationViewStorage.swift | ||
// | ||
// | ||
// Created by Sergey Balalaev on 20.11.2023. | ||
// | ||
|
||
import SwiftUI | ||
|
||
public struct NavigationViewStorage<Content: View>: View { | ||
let content: Content | ||
|
||
@OptionalEnvironmentObject | ||
private var parentNavigationStorage: NavigationStorage? | ||
|
||
@StateObject | ||
var navigationStorage = NavigationStorage() | ||
|
||
public init(@ViewBuilder content: () -> Content) { | ||
self.content = content() | ||
} | ||
|
||
public var body: some View { | ||
navigation | ||
.onAppear{ | ||
if let parentNavigationStorage = parentNavigationStorage { | ||
parentNavigationStorage.childStorge = navigationStorage | ||
navigationStorage.parentStorge = parentNavigationStorage | ||
} | ||
} | ||
.onDisappear(){ | ||
parentNavigationStorage?.childStorge = nil | ||
} | ||
.optionalEnvironmentObject(navigationStorage) | ||
} | ||
|
||
@ViewBuilder | ||
private var navigation: some View { | ||
if #available(iOS 16.0, *) { | ||
NavigationStack { | ||
content | ||
} | ||
} else { | ||
NavigationView { | ||
content | ||
} | ||
// bug from Apple: when change screen | ||
// - dismiss to First View | ||
// https://developer.apple.com/forums/thread/691242 | ||
.navigationViewStyle(.stack) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters