@@ -54,6 +54,7 @@ def __init__(
54
54
self .on_reset_app_callback = on_reset_app_callback
55
55
self .preferences : Optional [Preferences ] = None
56
56
self .currencies = []
57
+ self .pop_up_handler = None
57
58
58
59
def set_available_currencies (self ):
59
60
self .currencies = [
@@ -107,7 +108,25 @@ def on_language_selected(self, e):
107
108
return
108
109
self .preferences .language = e .control .value
109
110
110
- def on_reset_app (self , e ):
111
+ def on_reset_app_clicked (self , e ):
112
+ """Ask user to confirm this action"""
113
+ if self .pop_up_handler :
114
+ # Close any existing dialog
115
+ self .pop_up_handler .close_dialog ()
116
+ # Add a confirmation dialog
117
+ self .pop_up_handler = views .ConfirmDisplayPopUp (
118
+ dialog_controller = self .dialog_controller ,
119
+ title = "Are You Sure?" ,
120
+ description = f"Are you sure you wish to reset the app?\n This will clear all your data." ,
121
+ on_proceed = self .on_reset_app_confirmed ,
122
+ proceed_button_label = "Yes! Reset" ,
123
+ )
124
+ self .pop_up_handler .open_dialog ()
125
+
126
+ def on_reset_app_confirmed (
127
+ self ,
128
+ ):
129
+ """Reset the app to default state"""
111
130
logger .warning ("Resetting the app to default state" )
112
131
logger .warning ("Clearning preferences" )
113
132
result : IntentResult [None ] = self .intent .clear_preferences ()
@@ -189,7 +208,7 @@ def build(self):
189
208
self .reset_button = views .TDangerButton (
190
209
label = "Reset App and Quit" ,
191
210
icon = icons .RESTART_ALT_OUTLINED ,
192
- on_click = self .on_reset_app ,
211
+ on_click = self .on_reset_app_clicked ,
193
212
tooltip = "Warning: This will reset the app to default state and delete all data. You will have to restart the app." ,
194
213
)
195
214
0 commit comments