From f758b55feaf5b08d2f1a4256a12a2ac6d73efe8d Mon Sep 17 00:00:00 2001 From: Angelo Stavrow Date: Sun, 1 Sep 2024 16:00:33 -0400 Subject: [PATCH] Fix iOS 16+ navigation --- Shared/Navigation/WFNavigation.swift | 48 ++++++++++++++++++---------- 1 file changed, 31 insertions(+), 17 deletions(-) diff --git a/Shared/Navigation/WFNavigation.swift b/Shared/Navigation/WFNavigation.swift index d3b6859..e87037b 100644 --- a/Shared/Navigation/WFNavigation.swift +++ b/Shared/Navigation/WFNavigation.swift @@ -45,25 +45,39 @@ struct WFNavigation: View } #else if #available(iOS 16, *) { - /// Consider converting this into a NavigationStack instead, and using `$model.selectedCollection` to set - /// the detail view that should be shown. Try moving navigation state out of **WriteFreelyModel** and into - /// **WFNavigation** instead, so that it eventually encapsulates _all_ things related to app navigation. -// NavigationSplitView { -// collectionList -// } detail: { -// postList -// } - NavigationStack { - List(collections, id: \.self, selection: $model.navState.selectedPost) { collection in - NavigationLink("\(collection.title)", destination: PostListView(selectedCollection: model.navState.selectedCollection, showAllPosts: model.navState.showAllPosts)) + if model.account.isLoggedIn { + List(selection: $model.navState.selectedCollection) { + NavigationLink( + "All Posts", + destination: PostListView(selectedCollection: nil, showAllPosts: true) + ) + NavigationLink( + model.account.server == "https://write.as" ? "Anonymous" : "Drafts", + destination: PostListView(selectedCollection: nil, showAllPosts: false) + ) + Section("Your Blogs") { + ForEach(collections, id: \.self) { collection in + NavigationLink( + "\(collection.title)", + destination: PostListView( + selectedCollection: model.navState.selectedCollection, + showAllPosts: model.navState.showAllPosts + ) + ) + } + } + } + .navigationTitle("\(URL(string: model.account.server)?.host ?? "WriteFreely")") + } else { + List { + NavigationLink( + "Drafts", + destination: PostListView(selectedCollection: nil, showAllPosts: false) + ) + } + .navigationTitle("WriteFreely") } -// List(fetchRequest.wrappedValue, id: \.self, selection: $model.navState.selectedPost) { post in -// NavigationLink( -// "\(post.title.isEmpty ? "UNTITLED" : post.title)", -// destination: PostEditorView(post: post) -// ) -// } } } else { NavigationView {