@@ -284,33 +284,40 @@ class TradeDetailScreen extends ConsumerWidget {
284284 cancelMessage = S .of (context)! .areYouSureCancel;
285285 }
286286
287+ final buttonController = MostroReactiveButtonController ();
287288 widgets.add (_buildNostrButton (
288289 S .of (context)! .cancel.toUpperCase (),
289290 action: action,
290291 backgroundColor: AppTheme .red1,
291- onPressed: () {
292- showDialog (
292+ controller: buttonController,
293+ onPressed: () async {
294+ final result = await showDialog <bool >(
293295 context: context,
294296 builder: (context) => AlertDialog (
295297 title: Text (S .of (context)! .cancelTradeDialogTitle),
296298 content: Text (cancelMessage),
297299 actions: [
298300 TextButton (
299- onPressed: () => context.pop (),
300- child: Text (S .of (context)! .cancel ),
301+ onPressed: () => context.pop (false ),
302+ child: Text (S .of (context)! .no ),
301303 ),
302304 ElevatedButton (
303305 onPressed: () {
304- context.pop ();
306+ context.pop (true );
305307 ref
306308 .read (orderNotifierProvider (orderId).notifier)
307309 .cancelOrder ();
308310 },
309- child: Text (S .of (context)! .confirm ),
311+ child: Text (S .of (context)! .yes ),
310312 ),
311313 ],
312314 ),
313315 );
316+
317+ // Reset loading state if dialog was cancelled
318+ if (result != true ) {
319+ buttonController.resetLoading ();
320+ }
314321 },
315322 ));
316323 break ;
@@ -490,8 +497,11 @@ class TradeDetailScreen extends ConsumerWidget {
490497 required actions.Action action,
491498 required VoidCallback ? onPressed,
492499 Color ? backgroundColor,
500+ Key ? key,
501+ MostroReactiveButtonController ? controller,
493502 }) {
494503 return MostroReactiveButton (
504+ key: key,
495505 label: label,
496506 buttonStyle: ButtonStyleType .raised,
497507 orderId: orderId,
@@ -500,6 +510,7 @@ class TradeDetailScreen extends ConsumerWidget {
500510 onPressed: onPressed ?? () {}, // Provide empty function when null
501511 showSuccessIndicator: true ,
502512 timeout: const Duration (seconds: 30 ),
513+ controller: controller,
503514 );
504515 }
505516
0 commit comments