Page MenuHomeMusing Studio

No OneTemporary

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
@@ -1,78 +1,92 @@
import SwiftUI
// MARK: - Navigation State
final class WFNavigationState: ObservableObject {
@Published var selectedCollection: WFACollection?
@Published var selectedPost: WFAPost?
@Published var showAllPosts: Bool = true
}
// MARK: - Navigation Implementation
struct WFNavigation<CollectionList, PostList, PostDetail>: View
where CollectionList: View, PostList: View, PostDetail: View {
@EnvironmentObject var model: WriteFreelyModel
@FetchRequest(sortDescriptors: []) var collections: FetchedResults<WFACollection>
private var collectionList: CollectionList
private var postList: PostList
private var postDetail: PostDetail
init(
@ViewBuilder collectionList: () -> CollectionList,
@ViewBuilder postList: () -> PostList,
@ViewBuilder postDetail: () -> PostDetail
) {
self.collectionList = collectionList()
self.postList = postList()
self.postDetail = postDetail()
}
var body: some View {
#if os(macOS)
NavigationSplitView {
collectionList
} content: {
postList
} detail: {
postDetail
}
#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 {
collectionList
postList
postDetail
}
}
#endif
}
}

File Metadata

Mime Type
text/x-diff
Expires
Mon, Nov 25, 9:37 AM (1 d, 12 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3106649

Event Timeline