@@ -86,10 +86,7 @@ struct ShareFolderWithDeviceDetailsView: View {
8686 }
8787 }
8888 }
89- . alert (
90- isPresented: Binding (
91- get: { self . error != nil } , set: { nv in self . error = nv ? self . error : nil } )
92- ) {
89+ . alert ( isPresented: Binding . isNotNil ( $error) ) {
9390 Alert ( title: Text ( " Could not set encryption key " ) , message: Text ( self . error!) )
9491 }
9592 }
@@ -439,12 +436,9 @@ private struct ExternalFolderSectionView: View {
439436 }
440437 }
441438 )
442- . alert (
443- isPresented: . constant( self . errorText != nil ) ,
444- content: {
445- Alert ( title: Text ( " Could not relink folder " ) , message: Text ( errorText ?? " " ) , dismissButton: . default( Text ( " OK " ) ) )
446- }
447- )
439+ . alert ( isPresented: Binding . isNotNil ( $errorText) ) {
440+ Alert ( title: Text ( " Could not relink folder " ) , message: Text ( errorText ?? " " ) , dismissButton: . default( Text ( " OK " ) ) )
441+ }
448442 } footer: {
449443 if isAccessible {
450444 Text ( " This folder is not in the default location, and may belong to another app. " )
@@ -549,12 +543,9 @@ struct ExternalFolderInaccessibleView: View {
549543 }
550544 }
551545 )
552- . alert (
553- isPresented: . constant( self . errorText != nil ) ,
554- content: {
555- Alert ( title: Text ( " Could not relink folder " ) , message: Text ( errorText ?? " " ) , dismissButton: . default( Text ( " OK " ) ) )
556- }
557- )
546+ . alert ( isPresented: Binding . isNotNil ( $errorText) ) {
547+ Alert ( title: Text ( " Could not relink folder " ) , message: Text ( errorText ?? " " ) , dismissButton: . default( Text ( " OK " ) ) )
548+ }
558549 }
559550 }
560551
@@ -587,13 +578,11 @@ struct ExternalFolderInaccessibleView: View {
587578
588579struct FolderView : View {
589580 private enum ConfirmableAction {
590- case none
591581 case unlinkFolder
592582 case removeFolder
593583
594584 var message : String {
595585 switch self {
596- case . none: return " "
597586 case . removeFolder:
598587 return String (
599588 localized:
@@ -609,7 +598,6 @@ struct FolderView: View {
609598
610599 var buttonTitle : String {
611600 switch self {
612- case . none: return " "
613601 case . removeFolder: return String ( localized: " Remove the folder and all files " )
614602 case . unlinkFolder: return String ( localized: " Unlink the folder " )
615603 }
@@ -621,7 +609,7 @@ struct FolderView: View {
621609 @Environment ( \. dismiss) private var dismiss
622610 @State private var isWorking = false
623611 @State private var showAlert : ShowAlert ? = nil
624- @State private var showConfirmable : ConfirmableAction = . none
612+ @State private var showConfirmable : ConfirmableAction ? = nil
625613 @State private var advancedExpanded = false
626614 @State private var possiblePeers : [ SushitrainPeer ] = [ ]
627615 @State private var unsupportedDataProtection = false
@@ -758,14 +746,11 @@ struct FolderView: View {
758746 #endif
759747 }
760748 . confirmationDialog (
761- showConfirmable. message,
762- isPresented: Binding (
763- get: { self . showConfirmable != . none } ,
764- set: { self . showConfirmable = $0 ? self . showConfirmable : . none }
765- ) ,
766- titleVisibility: . visible
749+ showConfirmable? . message ?? " " , isPresented: Binding . isNotNil ( $showConfirmable) , titleVisibility: . visible
767750 ) {
768- Button ( showConfirmable. buttonTitle, role: . destructive, action: self . confirmedAction)
751+ if let sc = showConfirmable {
752+ Button ( sc. buttonTitle, role: . destructive, action: self . confirmedAction)
753+ }
769754 }
770755 }
771756
@@ -1296,7 +1281,7 @@ private struct FolderGenerateThumbnailsView: View {
12961281 }
12971282 }
12981283 . padding ( 30 )
1299- . alert ( isPresented: Binding . constant ( error != nil ) ) {
1284+ . alert ( isPresented: Binding . isNotNil ( $ error) ) {
13001285 Alert (
13011286 title: Text ( " An error occurred " ) , message: Text ( error!) ,
13021287 dismissButton: . default( Text ( " OK " ) ) {
0 commit comments