@@ -18,28 +18,6 @@ struct Inbox: View {
1818
1919 var body : some View {
2020 VStack ( alignment: . leading, spacing: 0 ) {
21- // Anchor the action sheet at the top to be able to show the popover on iPad in the most appropriate position
22- // When the app supports iOS 15+, we can remove this workaround by moving the `actionSheet` and `alert` calls to the `ToolbarItem`'s button.
23- Divider ( )
24- . hidden ( )
25- . actionSheet ( isPresented: $showingActionSheet) {
26- ActionSheet (
27- title: Text ( Localization . title) ,
28- buttons: [
29- . default( Text ( Localization . dismissAllNotes) , action: {
30- showingDismissAlert = true
31- } ) ,
32- . cancel( )
33- ]
34- )
35- }
36- . alert ( isPresented: $showingDismissAlert) {
37- return Alert ( title: Text ( Localization . dismissAllNotesAlertTitle) ,
38- message: Text ( Localization . dismissAllNotesAlertMessage) ,
39- primaryButton: . default( Text ( Localization . dismissAllNotes) , action: viewModel. dismissAllInboxNotes) ,
40- secondaryButton: . cancel( ) )
41- }
42-
4321 Group {
4422 switch viewModel. syncState {
4523 case . results:
@@ -83,16 +61,33 @@ struct Inbox: View {
8361 }
8462 . toolbar {
8563 ToolbarItem ( placement: . navigationBarTrailing) {
86- Button ( action: {
87- showingActionSheet = true
88- } , label: {
89- Image ( uiImage: . moreImage)
90- . renderingMode ( . template)
91- } )
92- . renderedIf ( viewModel. syncState == . results)
64+ if viewModel. syncState == . results {
65+ Button ( action: {
66+ showingActionSheet = true
67+ } , label: {
68+ Image ( uiImage: . moreImage)
69+ . renderingMode ( . template)
70+ } )
71+ . confirmationDialog ( Localization . title, isPresented: $showingActionSheet) {
72+ Button ( Localization . dismissAllNotes) {
73+ showingDismissAlert = true
74+ }
75+ }
76+ }
9377 }
9478 }
95- . wooNavigationBarStyle ( )
79+ . alert ( Localization . dismissAllNotesAlertTitle, isPresented: $showingDismissAlert, actions: {
80+ Button ( Localization . dismissAllNotes) {
81+ showingDismissAlert = false
82+ viewModel. dismissAllInboxNotes ( )
83+ }
84+
85+ Button ( Localization . cancel) {
86+ showingDismissAlert = false
87+ }
88+ } , message: {
89+ Text ( Localization . dismissAllNotesAlertMessage)
90+ } )
9691 }
9792 }
9893}
@@ -116,6 +111,11 @@ private extension Inbox {
116111 comment: " Title of the alert for dismissing all the inbox notes. " )
117112 static let dismissAllNotesAlertMessage = NSLocalizedString ( " Are you sure? Inbox messages will be dismissed forever. " ,
118113 comment: " Message displayed in the alert for dismissing all the inbox notes. " )
114+ static let cancel = NSLocalizedString (
115+ " inbox.alert.cancel " ,
116+ value: " Cancel " ,
117+ comment: " Button to dismiss the confirmation alert on the Inbox screen. "
118+ )
119119 }
120120}
121121
0 commit comments