@@ -41,33 +41,48 @@ struct NavStackEntryView<R: CustomRegistry>: View {
41
41
42
42
@ViewBuilder
43
43
private var elementTree : some View {
44
- switch coordinator. state {
45
- case . connected:
46
- if let doc = coordinator. document {
47
- coordinator. builder. fromNodes ( doc [ doc. root ( ) ] . children ( ) , coordinator: coordinator, url: coordinator. url)
48
- . environment ( \. coordinatorEnvironment, CoordinatorEnvironment ( coordinator, document: doc) )
49
- } else {
50
- fatalError ( " State is `.connected`, but no `Document` was found. " )
51
- }
52
- default :
53
- if R . LoadingView. self == Never . self {
54
- switch coordinator. state {
55
- case . connected:
56
- fatalError ( )
57
- case . notConnected:
58
- SwiftUI . Text ( " Not Connected " )
59
- case . connecting:
60
- SwiftUI . Text ( " Connecting " )
61
- case . connectionFailed( let error) :
62
- SwiftUI . VStack {
63
- SwiftUI . Text ( " Connection Failed " )
64
- . font ( . subheadline)
65
- SwiftUI . Text ( error. localizedDescription)
44
+ if coordinator. url == entry. url {
45
+ switch coordinator. state {
46
+ case . connected:
47
+ if let doc = coordinator. document {
48
+ coordinator. builder. fromNodes ( doc [ doc. root ( ) ] . children ( ) , coordinator: coordinator, url: coordinator. url)
49
+ . environment ( \. coordinatorEnvironment, CoordinatorEnvironment ( coordinator, document: doc) )
50
+ . onPreferenceChange ( NavigationTitleModifierKey . self) { navigationTitle in
51
+ self . liveViewModel. cachedNavigationTitle = navigationTitle
52
+ print ( " Nav title changed " )
53
+ }
54
+ } else {
55
+ fatalError ( " State is `.connected`, but no `Document` was found. " )
56
+ }
57
+ default :
58
+ let content = Group {
59
+ if R . LoadingView. self == Never . self {
60
+ switch coordinator. state {
61
+ case . connected:
62
+ fatalError ( )
63
+ case . notConnected:
64
+ SwiftUI . Text ( " Not Connected " )
65
+ case . connecting:
66
+ SwiftUI . Text ( " Connecting " )
67
+ case . connectionFailed( let error) :
68
+ SwiftUI . VStack {
69
+ SwiftUI . Text ( " Connection Failed " )
70
+ . font ( . subheadline)
71
+ SwiftUI . Text ( error. localizedDescription)
72
+ }
73
+ }
74
+ } else {
75
+ R . loadingView ( for: coordinator. url, state: coordinator. state)
66
76
}
67
77
}
68
- } else {
69
- R . loadingView ( for: coordinator. url, state: coordinator. state)
78
+ if let cachedNavigationTitle = liveViewModel. cachedNavigationTitle {
79
+ content. modifier ( cachedNavigationTitle)
80
+ } else {
81
+ content
82
+ }
70
83
}
84
+ } else if let cachedNavigationTitle = liveViewModel. cachedNavigationTitle {
85
+ SwiftUI . Text ( " " ) . modifier ( cachedNavigationTitle)
71
86
}
72
87
}
73
88
}
0 commit comments