summaryrefslogtreecommitdiff
path: root/Sora/Views
diff options
context:
space:
mode:
Diffstat (limited to 'Sora/Views')
-rw-r--r--Sora/Views/Generic/GenericItemView.swift2
-rw-r--r--Sora/Views/Generic/GenericListView.swift44
2 files changed, 45 insertions, 1 deletions
diff --git a/Sora/Views/Generic/GenericItemView.swift b/Sora/Views/Generic/GenericItemView.swift
index af79736..d0b86bd 100644
--- a/Sora/Views/Generic/GenericItemView.swift
+++ b/Sora/Views/Generic/GenericItemView.swift
@@ -29,7 +29,7 @@ struct GenericItemView<T: GenericItem>: View {
.foregroundStyle(Color.secondary)
if let folder = item.folder {
- Text("In \(folder)")
+ Text("In \(folder.name)")
.font(.caption)
.foregroundStyle(Color.secondary)
}
diff --git a/Sora/Views/Generic/GenericListView.swift b/Sora/Views/Generic/GenericListView.swift
index 0207048..9a1ec10 100644
--- a/Sora/Views/Generic/GenericListView.swift
+++ b/Sora/Views/Generic/GenericListView.swift
@@ -7,6 +7,8 @@ struct GenericListView<T: Identifiable & Hashable & GenericItem>: View {
@State private var searchText: String = ""
@State private var isShowingRemoveAllConfirmation = false
@Binding var isPresented: Bool
+ @State private var isNewCollectionAlertPresented = false
+ @State private var newCollectionName = ""
let allowBookmarking: Bool
let title: String
let emptyMessage: String
@@ -77,6 +79,22 @@ struct GenericListView<T: Identifiable & Hashable & GenericItem>: View {
removeAllAction()
}
}
+ .alert(
+ "New Collection",
+ isPresented: $isNewCollectionAlertPresented
+ ) {
+ TextField("Collection Name", text: $newCollectionName)
+
+ Button("Cancel") {
+ isNewCollectionAlertPresented = false
+ }
+
+ Button("Create") {
+ settings.folders.append(SettingsFolder(name: newCollectionName))
+
+ isNewCollectionAlertPresented = false
+ }
+ }
}
func itemButtonContent(item: T) -> some View {
@@ -109,6 +127,32 @@ struct GenericListView<T: Identifiable & Hashable & GenericItem>: View {
Label("Add to Search", systemImage: "plus")
}
+ Menu("\(item.folder != nil ? "Move" : "Add") to Collection") {
+ ForEach(settings.folders, id: \.id) { folder in
+ if item.folder?.id != folder.id {
+ Button(action: {
+ settings.updateBookmarkFolder(withID: item.id, folder: folder)
+ }) {
+ Label(folder.name, systemImage: "folder")
+ }
+ }
+ }
+
+ Button(action: {
+ isNewCollectionAlertPresented = true
+ }) {
+ Label("New Collection", systemImage: "plus")
+ }
+ }
+
+ if item.folder != nil {
+ Button(action: {
+ settings.updateBookmarkFolder(withID: item.id, folder: nil)
+ }) {
+ Label("Remove from Collection", systemImage: "folder.badge.minus")
+ }
+ }
+
if allowBookmarking {
let isBookmarked = settings.bookmarks.contains { $0.tags == item.tags }