Page Menu
Home
Musing Studio
Search
Configure Global Search
Log In
Files
F10455809
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
4 KB
Subscribers
None
View Options
diff --git a/Shared/PostCollection/CollectionListView.swift b/Shared/PostCollection/CollectionListView.swift
index a084f82..9dbcb22 100644
--- a/Shared/PostCollection/CollectionListView.swift
+++ b/Shared/PostCollection/CollectionListView.swift
@@ -1,78 +1,90 @@
import SwiftUI
struct CollectionListView: View {
@EnvironmentObject var model: WriteFreelyModel
@FetchRequest(
entity: WFACollection.entity(),
sortDescriptors: [NSSortDescriptor(keyPath: \WFACollection.title, ascending: true)]
) var collections: FetchedResults<WFACollection>
var body: some View {
List(selection: $model.selectedCollection) {
if model.account.isLoggedIn {
NavigationLink(
destination: PostListView(),
isActive: Binding<Bool>(
get: { () -> Bool in
model.selectedCollection == nil && model.showAllPosts
}, set: { newValue in
if newValue {
- self.model.selectedCollection = nil
self.model.showAllPosts = true
+ self.model.selectedCollection = nil
} else {
// No-op
}
}
- )) {
+ ),
+ label: {
Text("All Posts")
- }
+ })
NavigationLink(
destination: PostListView(),
isActive: Binding<Bool>(
get: { () -> Bool in
model.selectedCollection == nil && !model.showAllPosts
}, set: { newValue in
if newValue {
- self.model.selectedCollection = nil
self.model.showAllPosts = false
+ self.model.selectedCollection = nil
} else {
// No-op
}
}
- )) {
+ ),
+ label: {
Text(model.account.server == "https://write.as" ? "Anonymous" : "Drafts")
- }
+ })
Section(header: Text("Your Blogs")) {
ForEach(collections, id: \.alias) { collection in
NavigationLink(
- collection.title,
destination: PostListView(),
- tag: collection,
- selection: $model.selectedCollection
+ isActive: Binding<Bool>(
+ get: { () -> Bool in
+ model.selectedCollection == collection && !model.showAllPosts
+ }, set: { newValue in
+ if newValue {
+ self.model.showAllPosts = false
+ self.model.selectedCollection = collection
+ } else {
+ // No-op
+ }
+ }
+ ),
+ label: { Text(collection.title) }
)
}
}
} else {
- NavigationLink(destination: PostListView(selectedCollection: nil, showAllPosts: false)) {
+ NavigationLink(destination: PostListView()) {
Text("Drafts")
}
}
}
.navigationTitle(
model.account.isLoggedIn ? "\(URL(string: model.account.server)?.host ?? "WriteFreely")" : "WriteFreely"
)
.listStyle(SidebarListStyle())
}
}
struct CollectionListView_LoggedOutPreviews: PreviewProvider {
static var previews: some View {
let context = LocalStorageManager.persistentContainer.viewContext
let model = WriteFreelyModel()
return CollectionListView()
.environment(\.managedObjectContext, context)
.environmentObject(model)
}
}
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Fri, Jan 31, 9:42 PM (17 h, 3 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3145996
Attached To
rWFSUI WriteFreely SwiftUI
Event Timeline
Log In to Comment