@@ -53,7 +53,9 @@ class TradeDetailScreen extends ConsumerWidget {
5353 // Detailed info: includes the last Mostro message action text
5454 MostroMessageDetail (orderId: orderId),
5555 const SizedBox (height: 24 ),
56- _buildCountDownTime (orderPayload.expiresAt),
56+ _buildCountDownTime (orderPayload.expiresAt != null
57+ ? orderPayload.expiresAt! * 1000
58+ : null ),
5759 const SizedBox (height: 36 ),
5860 Wrap (
5961 alignment: WrapAlignment .center,
@@ -104,10 +106,9 @@ class TradeDetailScreen extends ConsumerWidget {
104106 final method = tradeState.order! .paymentMethod;
105107 final timestamp = formatDateTime (
106108 tradeState.order! .createdAt != null && tradeState.order! .createdAt! > 0
107- ? DateTime .fromMillisecondsSinceEpoch (tradeState.order! .createdAt! )
108- : DateTime .fromMillisecondsSinceEpoch (
109- tradeState.order! .createdAt ?? 0 ,
110- ),
109+ ? DateTime .fromMillisecondsSinceEpoch (
110+ tradeState.order! .createdAt! * 1000 )
111+ : session.startTime,
111112 );
112113 return CustomCard (
113114 padding: const EdgeInsets .all (16 ),
@@ -223,24 +224,49 @@ class TradeDetailScreen extends ConsumerWidget {
223224 // FSM-driven action mapping: ensure all actions are handled
224225 switch (action) {
225226 case actions.Action .cancel:
226- String buttonText;
227- Color buttonColor;
227+ String cancelMessage;
228228
229229 if (tradeState.status == Status .active ||
230230 tradeState.status == Status .fiatSent) {
231- buttonText = 'COOPERATIVE CANCEL' ;
232- buttonColor = AppTheme .red1;
231+ if (tradeState.action == actions.Action .cooperativeCancelInitiatedByPeer) {
232+ cancelMessage =
233+ 'If you confirm, you will accept the cooperative cancellation initiated by your counterparty.' ;
234+ } else {
235+ cancelMessage =
236+ 'If you confirm, you will start a cooperative cancellation with your counterparty.' ;
237+ }
233238 } else {
234- buttonText = 'CANCEL' ;
235- buttonColor = AppTheme .red1;
239+ cancelMessage = 'Are you sure you want to cancel this trade?' ;
236240 }
237241
238242 widgets.add (_buildNostrButton (
239- buttonText ,
243+ 'CANCEL' ,
240244 action: action,
241- backgroundColor: buttonColor,
242- onPressed: () =>
243- ref.read (orderNotifierProvider (orderId).notifier).cancelOrder (),
245+ backgroundColor: AppTheme .red1,
246+ onPressed: () {
247+ showDialog (
248+ context: context,
249+ builder: (context) => AlertDialog (
250+ title: const Text ('Cancel Trade' ),
251+ content: Text (cancelMessage),
252+ actions: [
253+ TextButton (
254+ onPressed: () => context.pop (),
255+ child: const Text ('Cancel' ),
256+ ),
257+ ElevatedButton (
258+ onPressed: () {
259+ context.pop ();
260+ ref
261+ .read (orderNotifierProvider (orderId).notifier)
262+ .cancelOrder ();
263+ },
264+ child: const Text ('Confirm' ),
265+ ),
266+ ],
267+ ),
268+ );
269+ },
244270 ));
245271 break ;
246272
@@ -386,15 +412,11 @@ class TradeDetailScreen extends ConsumerWidget {
386412 ));
387413 break ;
388414
389- case actions.Action .holdInvoicePaymentSettled:
390- case actions.Action .holdInvoicePaymentAccepted:
415+ case actions.Action .sendDm:
391416 widgets.add (_buildContactButton (context));
392417 break ;
393418
394419 case actions.Action .holdInvoicePaymentCanceled:
395- // These are system actions, not user actions, so no button needed
396- break ;
397-
398420 case actions.Action .buyerInvoiceAccepted:
399421 case actions.Action .waitingSellerToPay:
400422 case actions.Action .waitingBuyerInvoice:
@@ -407,15 +429,11 @@ class TradeDetailScreen extends ConsumerWidget {
407429 case actions.Action .adminTookDispute:
408430 case actions.Action .paymentFailed:
409431 case actions.Action .invoiceUpdated:
410- case actions.Action .sendDm:
411432 case actions.Action .tradePubkey:
412433 case actions.Action .cantDo:
413434 case actions.Action .released:
414- // Not user-facing or not relevant as a button
415435 break ;
416-
417436 default :
418- // Optionally handle unknown or unimplemented actions
419437 break ;
420438 }
421439 }
@@ -457,7 +475,7 @@ class TradeDetailScreen extends ConsumerWidget {
457475 /// CLOSE
458476 Widget _buildCloseButton (BuildContext context) {
459477 return OutlinedButton (
460- onPressed: () => context.pop ( ),
478+ onPressed: () => context.go ( '/order_book' ),
461479 style: AppTheme .theme.outlinedButtonTheme.style,
462480 child: const Text ('CLOSE' ),
463481 );
0 commit comments