diff options
| author | Fuwn <[email protected]> | 2025-07-08 06:59:04 -0700 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2025-07-08 06:59:52 -0700 |
| commit | 39bfd73c01b02847c15fc856ea56d28fadee05c4 (patch) | |
| tree | 2fd30ffe4bdf995be41c515fbe1bd3650bc9ee29 /Sora/Views/Generic | |
| parent | feat: Development commit (diff) | |
| download | sora-testing-39bfd73c01b02847c15fc856ea56d28fadee05c4.tar.xz sora-testing-39bfd73c01b02847c15fc856ea56d28fadee05c4.zip | |
feat: Development commit
Diffstat (limited to 'Sora/Views/Generic')
| -rw-r--r-- | Sora/Views/Generic/CollectionAlertsModifier.swift | 59 |
1 files changed, 0 insertions, 59 deletions
diff --git a/Sora/Views/Generic/CollectionAlertsModifier.swift b/Sora/Views/Generic/CollectionAlertsModifier.swift deleted file mode 100644 index 6c39da8..0000000 --- a/Sora/Views/Generic/CollectionAlertsModifier.swift +++ /dev/null @@ -1,59 +0,0 @@ -import SwiftUI - -struct CollectionAlertsModifier: ViewModifier { - @Binding var isNewCollectionAlertPresented: Bool - @Binding var newCollectionName: String - @Binding var isCollectionErrorAlertPresented: Bool - let onCreate: (String) -> Void - - func body(content: Content) -> some View { - content - .alert( - "New Collection", - isPresented: $isNewCollectionAlertPresented - ) { - TextField("Collection Name", text: $newCollectionName) - - Button("Cancel") { - newCollectionName = "" - isNewCollectionAlertPresented = false - } - - Button("Create") { - if newCollectionName.isEmpty { - isCollectionErrorAlertPresented = true - } else { - onCreate(newCollectionName) - newCollectionName = "" - isNewCollectionAlertPresented = false - } - } - } - .alert( - "Error", - isPresented: $isCollectionErrorAlertPresented - ) { - Button("OK", role: .cancel) { () } - } message: { - Text("Collection name cannot be empty.") - } - } -} - -extension View { - func collectionAlerts( - isNewCollectionAlertPresented: Binding<Bool>, - newCollectionName: Binding<String>, - isCollectionErrorAlertPresented: Binding<Bool>, - onCreate: @escaping (String) -> Void - ) -> some View { - modifier( - CollectionAlertsModifier( - isNewCollectionAlertPresented: isNewCollectionAlertPresented, - newCollectionName: newCollectionName, - isCollectionErrorAlertPresented: isCollectionErrorAlertPresented, - onCreate: onCreate - ) - ) - } -} |