Page Menu
Home
Musing Studio
Search
Configure Global Search
Log In
Files
F10387290
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
6 KB
Subscribers
None
View Options
diff --git a/Shared/Navigation/WFNavigation.swift b/Shared/Navigation/WFNavigation.swift
index 5042f3c..8a4300c 100644
--- a/Shared/Navigation/WFNavigation.swift
+++ b/Shared/Navigation/WFNavigation.swift
@@ -1,37 +1,57 @@
import SwiftUI
struct WFNavigation<CollectionList, PostList, PostDetail>: View
where CollectionList: View, PostList: View, PostDetail: View {
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 #available(iOS 16, macOS 13, *) {
+ #if os(macOS)
+ if #available(macOS 13, *) {
NavigationSplitView {
collectionList
} content: {
postList
} detail: {
postDetail
}
} else {
NavigationView {
collectionList
postList
postDetail
}
}
+ #else
+ // If we uncomment this, when we back out of the postDetail to the postList, the app further backs us out
+ // to the collectionList for some reason.
+// if #available(iOS 16, *) {
+// NavigationSplitView {
+// collectionList
+// } content: {
+// postList
+// } detail: {
+// postDetail
+// }
+// } else {
+ NavigationView {
+ collectionList
+ postList
+ postDetail
+ }
+// }
+ #endif
}
}
diff --git a/Shared/PostList/SearchablePostListFilteredView.swift b/Shared/PostList/SearchablePostListFilteredView.swift
index d4b2701..b045867 100644
--- a/Shared/PostList/SearchablePostListFilteredView.swift
+++ b/Shared/PostList/SearchablePostListFilteredView.swift
@@ -1,58 +1,88 @@
import SwiftUI
@available(iOS 15, macOS 12.0, *)
struct SearchablePostListFilteredView: View {
@EnvironmentObject var model: WriteFreelyModel
@Binding var postCount: Int
@State private var searchString = ""
var collections: FetchedResults<WFACollection>
var fetchRequest: FetchRequest<WFAPost>
var onDelete: (WFAPost) -> Void
var body: some View {
- List(selection: $model.selectedPost) {
- ForEach(fetchRequest.wrappedValue, id: \.self) { post in
+ if #available(iOS 16, *) {
+ List(fetchRequest.wrappedValue, id: \.self, selection: $model.selectedPost) { post in
if !searchString.isEmpty &&
!post.title.localizedCaseInsensitiveContains(searchString) &&
!post.body.localizedCaseInsensitiveContains(searchString) {
- EmptyView()
+ EmptyView()
} else {
NavigationLink(
destination: PostEditorView(post: post),
tag: post,
selection: $model.selectedPost,
label: {
if model.showAllPosts {
if let collection = collections.filter({ $0.alias == post.collectionAlias }).first {
PostCellView(post: post, collectionName: collection.title)
} else {
// swiftlint:disable:next line_length
let collectionName = model.account.server == "https://write.as" ? "Anonymous" : "Drafts"
PostCellView(post: post, collectionName: collectionName)
}
} else {
PostCellView(post: post)
}
})
.deleteDisabled(post.status != PostStatus.local.rawValue)
}
}
- .onDelete(perform: { indexSet in
- for index in indexSet {
- let post = fetchRequest.wrappedValue[index]
- delete(post)
+ .searchable(text: $searchString, prompt: "Search across posts")
+ } else {
+ List(selection: $model.selectedPost) {
+ ForEach(fetchRequest.wrappedValue, id: \.self) { post in
+ if !searchString.isEmpty &&
+ !post.title.localizedCaseInsensitiveContains(searchString) &&
+ !post.body.localizedCaseInsensitiveContains(searchString) {
+ EmptyView()
+ } else {
+ NavigationLink(
+ destination: PostEditorView(post: post),
+ tag: post,
+ selection: $model.selectedPost,
+ label: {
+ if model.showAllPosts {
+ if let collection = collections.filter({ $0.alias == post.collectionAlias }).first {
+ PostCellView(post: post, collectionName: collection.title)
+ } else {
+ // swiftlint:disable:next line_length
+ let collectionName = model.account.server == "https://write.as" ? "Anonymous" : "Drafts"
+ PostCellView(post: post, collectionName: collectionName)
+ }
+ } else {
+ PostCellView(post: post)
+ }
+ })
+ .deleteDisabled(post.status != PostStatus.local.rawValue)
+ }
}
- })
+ .onDelete(perform: { indexSet in
+ for index in indexSet {
+ let post = fetchRequest.wrappedValue[index]
+ delete(post)
+ }
+ })
+ }
+ #if os(iOS)
+ .searchable(text: $searchString, prompt: "Search across posts")
+ #else
+ .searchable(text: $searchString, placement: .toolbar, prompt: "Search across posts")
+ #endif
}
- #if os(iOS)
- .searchable(text: $searchString, prompt: "Search across posts")
- #else
- .searchable(text: $searchString, placement: .toolbar, prompt: "Search across posts")
- #endif
}
func delete(_ post: WFAPost) {
onDelete(post)
}
}
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Mon, Nov 25, 4:14 AM (1 d, 12 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3106556
Attached To
rWFSUI WriteFreely SwiftUI
Event Timeline
Log In to Comment