@@ -68,66 +68,25 @@ class _EmergencyKitScreenState extends State<EmergencyKitScreen> {
68
68
],
69
69
)),
70
70
const SizedBox (height: 30 ),
71
- OutlinedButton (
72
- onPressed: () {
73
- showDialog (
74
- context: context,
75
- builder: (context) {
76
- return AlertDialog (
77
- title: const Text ("Are you sure?" ),
78
- content: const Text (
79
- "Performing that action may break your app state and should only get executed after consulting with the 10101 Team." ),
80
- actions: [
81
- TextButton (
82
- onPressed: () => GoRouter .of (context).pop (),
83
- child: const Text ('No' ),
84
- ),
85
- TextButton (
86
- onPressed: () async {
87
- final messenger = ScaffoldMessenger .of (context);
88
- final orderChangeNotifier =
89
- context.read <OrderChangeNotifier >();
90
- final goRouter = GoRouter .of (context);
91
-
92
- try {
93
- await rust.api.setFillingOrdersToFailed ();
94
- await orderChangeNotifier.initialize ();
95
- showSnackBar (messenger,
96
- "Successfully set filling orders to failed" );
97
- } catch (e) {
98
- showSnackBar (messenger,
99
- "Failed to set filling orders to failed. Error: $e " );
100
- }
101
-
102
- goRouter.pop ();
103
- },
104
- child: const Text ('Yes' ),
105
- ),
106
- ]);
107
- });
108
- },
109
- style: ButtonStyle (
110
- fixedSize: MaterialStateProperty .all (const Size (double .infinity, 50 )),
111
- iconSize: MaterialStateProperty .all <double >(20.0 ),
112
- elevation: MaterialStateProperty .all <double >(0 ),
113
- // this reduces the shade
114
- side: MaterialStateProperty .all (
115
- const BorderSide (width: 1.0 , color: tenTenOnePurple)),
116
- padding: MaterialStateProperty .all <EdgeInsetsGeometry >(
117
- const EdgeInsets .fromLTRB (20 , 12 , 20 , 12 ),
118
- ),
119
- shape: MaterialStateProperty .all <RoundedRectangleBorder >(
120
- RoundedRectangleBorder (
121
- borderRadius: BorderRadius .circular (8.0 ),
122
- ),
123
- ),
124
- backgroundColor: MaterialStateProperty .all <Color >(Colors .transparent),
125
- ),
126
- child: const Row (mainAxisAlignment: MainAxisAlignment .center, children: [
127
- Icon (FontAwesomeIcons .broom),
128
- SizedBox (width: 10 ),
129
- Text ("Cleanup filling orders" , style: TextStyle (fontSize: 16 ))
130
- ])),
71
+ EmergencyKitButton (
72
+ icon: const Icon (FontAwesomeIcons .broom),
73
+ title: "Cleanup filling orders" ,
74
+ onPressed: () async {
75
+ final messenger = ScaffoldMessenger .of (context);
76
+ final orderChangeNotifier = context.read <OrderChangeNotifier >();
77
+ final goRouter = GoRouter .of (context);
78
+
79
+ try {
80
+ await rust.api.setFillingOrdersToFailed ();
81
+ await orderChangeNotifier.initialize ();
82
+ showSnackBar (messenger, "Successfully set filling orders to failed" );
83
+ } catch (e) {
84
+ showSnackBar (
85
+ messenger, "Failed to set filling orders to failed. Error: $e " );
86
+ }
87
+
88
+ goRouter.pop ();
89
+ }),
131
90
const SizedBox (height: 30 ),
132
91
Row (
133
92
children: [
@@ -186,45 +145,57 @@ class _EmergencyKitScreenState extends State<EmergencyKitScreen> {
186
145
))
187
146
],
188
147
),
189
- const SizedBox (
190
- height: 30 ,
191
- ),
148
+ const SizedBox (height: 30 ),
149
+ EmergencyKitButton (
150
+ icon: const Icon (FontAwesomeIcons .broom),
151
+ title: "Delete position" ,
152
+ onPressed: () async {
153
+ final messenger = ScaffoldMessenger .of (context);
154
+ final goRouter = GoRouter .of (context);
155
+
156
+ try {
157
+ await rust.api.deletePosition ();
158
+ showSnackBar (messenger, "Successfully deleted position" );
159
+ } catch (e) {
160
+ showSnackBar (messenger, "Failed to delete position. Error: $e " );
161
+ }
162
+
163
+ goRouter.pop ();
164
+ }),
165
+ const SizedBox (height: 30 ),
166
+ EmergencyKitButton (
167
+ icon: const Icon (FontAwesomeIcons .broom),
168
+ title: "Resend SettleFinalize Message" ,
169
+ onPressed: () async {
170
+ final messenger = ScaffoldMessenger .of (context);
171
+ final goRouter = GoRouter .of (context);
172
+
173
+ try {
174
+ await rust.api.resendSettleFinalizeMessage ();
175
+ showSnackBar (messenger, "Successfully resend SettleFinalize message" );
176
+ } catch (e) {
177
+ showSnackBar (
178
+ messenger, "Failed to resend SettleFinalize message. Error: $e " );
179
+ }
180
+
181
+ goRouter.pop ();
182
+ }),
183
+ const SizedBox (height: 30 ),
192
184
Visibility (
193
- visible: config.network == "regtest" ,
194
- child: OutlinedButton (
195
- onPressed: () {
196
- final messenger = ScaffoldMessenger .of (context);
197
- try {
198
- rust.api.resetAllAnsweredPolls ();
199
- showSnackBar (messenger,
200
- "Successfully reset answered polls - You can now answer them again" );
201
- } catch (e) {
202
- showSnackBar (messenger, "Failed to reset answered polls: $e " );
203
- }
204
- },
205
- style: ButtonStyle (
206
- fixedSize: MaterialStateProperty .all (const Size (double .infinity, 50 )),
207
- iconSize: MaterialStateProperty .all <double >(20.0 ),
208
- elevation: MaterialStateProperty .all <double >(0 ),
209
- // this reduces the shade
210
- side: MaterialStateProperty .all (
211
- const BorderSide (width: 1.0 , color: tenTenOnePurple)),
212
- padding: MaterialStateProperty .all <EdgeInsetsGeometry >(
213
- const EdgeInsets .fromLTRB (20 , 12 , 20 , 12 ),
214
- ),
215
- shape: MaterialStateProperty .all <RoundedRectangleBorder >(
216
- RoundedRectangleBorder (
217
- borderRadius: BorderRadius .circular (8.0 ),
218
- ),
219
- ),
220
- backgroundColor: MaterialStateProperty .all <Color >(Colors .transparent),
221
- ),
222
- child: const Row (mainAxisAlignment: MainAxisAlignment .center, children: [
223
- Icon (FontAwesomeIcons .broom),
224
- SizedBox (width: 10 ),
225
- Text ("Reset answered poll cache" , style: TextStyle (fontSize: 16 ))
226
- ])),
227
- )
185
+ visible: config.network == "regtest" ,
186
+ child: EmergencyKitButton (
187
+ icon: const Icon (FontAwesomeIcons .broom),
188
+ title: "Reset answered poll cache" ,
189
+ onPressed: () {
190
+ final messenger = ScaffoldMessenger .of (context);
191
+ try {
192
+ rust.api.resetAllAnsweredPolls ();
193
+ showSnackBar (messenger,
194
+ "Successfully reset answered polls - You can now answer them again" );
195
+ } catch (e) {
196
+ showSnackBar (messenger, "Failed to reset answered polls: $e " );
197
+ }
198
+ })),
228
199
])),
229
200
],
230
201
),
@@ -233,3 +204,57 @@ class _EmergencyKitScreenState extends State<EmergencyKitScreen> {
233
204
);
234
205
}
235
206
}
207
+
208
+ class EmergencyKitButton extends StatelessWidget {
209
+ final Icon icon;
210
+ final String title;
211
+ final VoidCallback onPressed;
212
+
213
+ const EmergencyKitButton (
214
+ {super .key, required this .icon, required this .title, required this .onPressed});
215
+
216
+ @override
217
+ Widget build (BuildContext context) {
218
+ return OutlinedButton (
219
+ onPressed: () {
220
+ showDialog (
221
+ context: context,
222
+ builder: (context) {
223
+ return AlertDialog (
224
+ title: const Text ("Are you sure?" ),
225
+ content: const Text (
226
+ "Performing that action may break your app state and should only get executed after consulting with the 10101 Team." ),
227
+ actions: [
228
+ TextButton (
229
+ onPressed: () => GoRouter .of (context).pop (),
230
+ child: const Text ('No' ),
231
+ ),
232
+ TextButton (
233
+ onPressed: onPressed,
234
+ child: const Text ('Yes' ),
235
+ ),
236
+ ]);
237
+ });
238
+ },
239
+ style: ButtonStyle (
240
+ fixedSize: MaterialStateProperty .all (const Size (double .infinity, 50 )),
241
+ iconSize: MaterialStateProperty .all <double >(20.0 ),
242
+ elevation: MaterialStateProperty .all <double >(0 ),
243
+ side: MaterialStateProperty .all (const BorderSide (width: 1.0 , color: tenTenOnePurple)),
244
+ padding: MaterialStateProperty .all <EdgeInsetsGeometry >(
245
+ const EdgeInsets .fromLTRB (20 , 12 , 20 , 12 ),
246
+ ),
247
+ shape: MaterialStateProperty .all <RoundedRectangleBorder >(
248
+ RoundedRectangleBorder (
249
+ borderRadius: BorderRadius .circular (8.0 ),
250
+ ),
251
+ ),
252
+ backgroundColor: MaterialStateProperty .all <Color >(Colors .transparent),
253
+ ),
254
+ child: Row (mainAxisAlignment: MainAxisAlignment .center, children: [
255
+ icon,
256
+ const SizedBox (width: 10 ),
257
+ Text (title, style: const TextStyle (fontSize: 16 ))
258
+ ]));
259
+ }
260
+ }
0 commit comments