diff options
| author | Fuwn <[email protected]> | 2025-06-09 06:02:59 -0700 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2025-06-09 06:02:59 -0700 |
| commit | 3464cb6f80aeae2d0ac45e0e03f9f4eeef7d7f03 (patch) | |
| tree | 6eaba27dd2f26fa1050786e8d1b9b9e71fbab18f | |
| parent | feat: Development commit (diff) | |
| download | sora-testing-3464cb6f80aeae2d0ac45e0e03f9f4eeef7d7f03.tar.xz sora-testing-3464cb6f80aeae2d0ac45e0e03f9f4eeef7d7f03.zip | |
feat: Development commit
| -rw-r--r-- | Localizable.xcstrings | 6 | ||||
| -rw-r--r-- | Sora/Views/Generic/GenericListView.swift | 27 |
2 files changed, 31 insertions, 2 deletions
diff --git a/Localizable.xcstrings b/Localizable.xcstrings index 3235430..9adcf67 100644 --- a/Localizable.xcstrings +++ b/Localizable.xcstrings @@ -72,6 +72,9 @@ "Collection Name" : { }, + "Collection name cannot be empty." : { + + }, "Content Filtering" : { "localizations" : { "ja" : { @@ -127,6 +130,9 @@ "Enable \"Share Image\" Shortcut" : { }, + "Error" : { + + }, "Export Bookmarks" : { }, diff --git a/Sora/Views/Generic/GenericListView.swift b/Sora/Views/Generic/GenericListView.swift index 1d44e15..93b141b 100644 --- a/Sora/Views/Generic/GenericListView.swift +++ b/Sora/Views/Generic/GenericListView.swift @@ -9,6 +9,8 @@ struct GenericListView<T: Identifiable & Hashable & GenericItem>: View { @Binding var isPresented: Bool @State private var isNewCollectionAlertPresented = false @State private var newCollectionName = "" + @State private var itemPendingCollectionAssignment: UUID? + @State private var isCollectionErrorAlertPresented = false let allowBookmarking: Bool let title: String let emptyMessage: String @@ -91,11 +93,31 @@ struct GenericListView<T: Identifiable & Hashable & GenericItem>: View { } Button("Create") { - settings.folders.append(SettingsFolder(name: newCollectionName)) + if newCollectionName.isEmpty { + isCollectionErrorAlertPresented = true + } else { + let newFolder = SettingsFolder(name: newCollectionName) - isNewCollectionAlertPresented = false + settings.folders.append(newFolder) + + if let id = itemPendingCollectionAssignment { + settings.updateBookmarkFolder(withID: id, folder: newFolder) + } + + itemPendingCollectionAssignment = nil + newCollectionName = "" + isNewCollectionAlertPresented = false + } } } + .alert( + "Error", + isPresented: $isCollectionErrorAlertPresented, + ) { + Button("OK", role: .cancel) { () } + } message: { + Text("Collection name cannot be empty.") + } } func itemButtonContent(item: T) -> some View { @@ -140,6 +162,7 @@ struct GenericListView<T: Identifiable & Hashable & GenericItem>: View { } Button(action: { + itemPendingCollectionAssignment = item.id isNewCollectionAlertPresented = true }) { Label("New Collection", systemImage: "plus") |