From 3464cb6f80aeae2d0ac45e0e03f9f4eeef7d7f03 Mon Sep 17 00:00:00 2001 From: Fuwn Date: Mon, 9 Jun 2025 06:02:59 -0700 Subject: feat: Development commit --- Localizable.xcstrings | 6 ++++++ 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 @@ -71,6 +71,9 @@ }, "Collection Name" : { + }, + "Collection name cannot be empty." : { + }, "Content Filtering" : { "localizations" : { @@ -126,6 +129,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: 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: 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: View { } Button(action: { + itemPendingCollectionAssignment = item.id isNewCollectionAlertPresented = true }) { Label("New Collection", systemImage: "plus") -- cgit v1.2.3