Skip to content

Commit

Permalink
Use NavigationStack instead of NavigationView
Browse files Browse the repository at this point in the history
NavigationView is deprecated now. For these use-cases, Apple recommends
switching to NavigationStack instead.
  • Loading branch information
matthewrfennell authored and tmolitor-stud-tu committed Aug 20, 2024
1 parent 3f20882 commit ba385ff
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Monal/Classes/AddContactMenu.swift
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ struct AddContactMenu: View {
}
})
.sheet(isPresented: $showQRCodeScanner) {
NavigationView {
NavigationStack {
MLQRCodeScanner(handleClose: {
self.showQRCodeScanner = false
})
Expand Down
2 changes: 1 addition & 1 deletion Monal/Classes/DebugView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ struct DebugView: View {
}

#Preview {
NavigationView {
NavigationStack {
DebugView()
}
}
2 changes: 1 addition & 1 deletion Monal/Classes/EditGroupSubject.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ struct EditGroupSubject: View {
}

var body: some View {
NavigationView {
NavigationStack {
VStack {
Form {
Section(header: Text("Group Description (optional)")) {
Expand Down
2 changes: 1 addition & 1 deletion Monal/Classes/RegisterAccount.swift
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ struct RegisterAccount: View {
}
.frame(maxWidth: .infinity)
.sheet(isPresented: $showWebView) {
NavigationView {
NavigationStack {
WebView(url: termsSiteForCurrentLanguage())
.navigationBarTitle(Text("Terms of \(RegisterAccount.XMPPServer[$selectedServerIndex.wrappedValue]["XMPPServer"]!)"), displayMode: .inline)
.toolbar(content: {
Expand Down
8 changes: 3 additions & 5 deletions Monal/Classes/SwiftuiHelpers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,7 @@ struct LazyClosureView<Content: View>: View {
}
}

// use this to wrap a view into NavigationView, if it should be the outermost swiftui view of a new view stack
// use this to wrap a view into NavigationStack, if it should be the outermost swiftui view of a new view stack
struct AddTopLevelNavigation<Content: View>: View {
let build: () -> Content
let delegate: SheetDismisserProtocol
Expand All @@ -517,7 +517,7 @@ struct AddTopLevelNavigation<Content: View>: View {
self.delegate = delegate
}
var body: some View {
NavigationView {
NavigationStack {
build()
.navigationBarTitleDisplayMode(.automatic)
.navigationBarBackButtonHidden(true) // will not be shown because swiftui does not know we navigated here from UIKit
Expand All @@ -527,7 +527,6 @@ struct AddTopLevelNavigation<Content: View>: View {
Image(systemName: "arrow.backward")
}.keyboardShortcut(.escape, modifiers: []))
}
.navigationViewStyle(.stack)
}
}

Expand All @@ -547,11 +546,10 @@ struct UIKitWorkaround<Content: View>: View {
#if targetEnvironment(macCatalyst)
build().navigationBarTitleDisplayMode(.inline)
#else
NavigationView {
NavigationStack {
build()
.navigationBarTitleDisplayMode(.automatic)
}
.navigationViewStyle(.stack)

#endif
}
Expand Down

0 comments on commit ba385ff

Please sign in to comment.