Skip to content

Commit 1928d37

Browse files
committed
- Restore BuildingTransactionDialog in SendView on desktop (revert showLoading)
- Replace AlertDialog with SDialog for collateral address picker - Revert custom CreateMasternodeView close button and cancel/pop behavior - Extract masternode collateral send notes to MasternodeCollateralNotes
1 parent cd8d3f3 commit 1928d37

6 files changed

Lines changed: 84 additions & 70 deletions

File tree

lib/pages/masternodes/create_masternode_view.dart

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,7 @@ class _CreateMasternodeDialogState extends ConsumerState<CreateMasternodeView> {
5454
style: STextStyles.desktopH3(context),
5555
),
5656
),
57-
DesktopDialogCloseButton(
58-
onPressedOverride: () {
59-
Navigator.of(context, rootNavigator: true).pop();
60-
},
61-
),
57+
const DesktopDialogCloseButton(),
6258
],
6359
),
6460
Flexible(
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
abstract final class MasternodeCollateralNotes {
2+
MasternodeCollateralNotes._();
3+
4+
static const unshield =
5+
"Masternode collateral unshield (1000 FIRO to transparent).";
6+
static const prep = "Masternode collateral prep (1000 FIRO self-send).";
7+
8+
static bool isUnshield(String? note) =>
9+
note != null && note.contains(unshield);
10+
11+
static bool isPrep(String? note) => note != null && note.contains(prep);
12+
}

lib/pages/masternodes/masternodes_home_view.dart

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import '../../widgets/loading_indicator.dart';
2727
import '../../widgets/stack_dialog.dart';
2828
import '../send_view/send_view.dart';
2929
import 'create_masternode_view.dart';
30+
import 'masternode_constants.dart';
3031
import 'sub_widgets/masternodes_list.dart';
3132
import 'sub_widgets/masternodes_table_desktop.dart';
3233

@@ -472,8 +473,8 @@ class _MasternodesHomeViewState extends ConsumerState<MasternodesHomeView> {
472473
? (unshieldAmount ?? kMasterNodeValue)
473474
: kMasterNodeValue,
474475
note: fromPrivate
475-
? "Masternode collateral unshield (1000 FIRO to transparent)."
476-
: "Masternode collateral prep (1000 FIRO self-send).",
476+
? MasternodeCollateralNotes.unshield
477+
: MasternodeCollateralNotes.prep,
477478
),
478479
),
479480
);

lib/pages/send_view/send_view.dart

Lines changed: 62 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ import '../../widgets/background.dart';
6868
import '../../widgets/custom_buttons/app_bar_icon_button.dart';
6969
import '../../widgets/custom_buttons/blue_text_button.dart';
7070
import '../../widgets/dialogs/firo_exchange_address_dialog.dart';
71+
import '../../widgets/dialogs/s_dialog.dart';
72+
import '../../widgets/desktop/secondary_button.dart';
7173
import '../../widgets/epic_txs_method_toggle.dart';
7274
import '../../widgets/eth_fee_form.dart';
7375
import '../../widgets/fee_slider.dart';
@@ -82,7 +84,7 @@ import '../../widgets/stack_text_field.dart';
8284
import '../../widgets/textfield_icon_button.dart';
8385
import '../address_book_views/address_book_view.dart';
8486
import '../coin_control/coin_control_view.dart';
85-
import '../masternodes/masternodes_home_view.dart';
87+
import '../masternodes/masternode_constants.dart';
8688
import 'confirm_transaction_view.dart';
8789
import 'sub_widgets/building_transaction_dialog.dart';
8890
import 'sub_widgets/dual_balance_selection_sheet.dart';
@@ -311,30 +313,52 @@ class _SendViewState extends ConsumerState<SendView> {
311313

312314
final selectedAddress = await showDialog<String>(
313315
context: context,
314-
builder: (ctx) => AlertDialog(
315-
title: const Text("Choose your address"),
316-
content: SizedBox(
317-
width: 520,
318-
child: ListView.builder(
319-
shrinkWrap: true,
320-
itemCount: addresses.length,
321-
itemBuilder: (_, index) => ListTile(
322-
contentPadding: EdgeInsets.zero,
323-
title: Text(
324-
addresses[index],
325-
maxLines: 1,
326-
overflow: TextOverflow.ellipsis,
316+
builder: (ctx) => SDialog(
317+
contentCanScroll: false,
318+
padding: EdgeInsets.all(Util.isDesktop ? 32 : 16),
319+
child: SizedBox(
320+
width: Util.isDesktop ? 520 : null,
321+
child: Column(
322+
mainAxisSize: MainAxisSize.min,
323+
crossAxisAlignment: CrossAxisAlignment.stretch,
324+
children: [
325+
Text(
326+
"Choose your address",
327+
style: Util.isDesktop
328+
? STextStyles.desktopH3(ctx)
329+
: STextStyles.pageTitleH2(ctx),
327330
),
328-
onTap: () => Navigator.of(ctx).pop(addresses[index]),
329-
),
331+
const SizedBox(height: 16),
332+
ConstrainedBox(
333+
constraints: BoxConstraints(
334+
maxHeight: MediaQuery.of(ctx).size.height * 0.5,
335+
),
336+
child: ListView.builder(
337+
shrinkWrap: true,
338+
itemCount: addresses.length,
339+
itemBuilder: (_, index) => ListTile(
340+
contentPadding: EdgeInsets.zero,
341+
title: Text(
342+
addresses[index],
343+
maxLines: 1,
344+
overflow: TextOverflow.ellipsis,
345+
style: Util.isDesktop
346+
? STextStyles.w500_16(ctx)
347+
: STextStyles.w500_14(ctx),
348+
),
349+
onTap: () => Navigator.of(ctx).pop(addresses[index]),
350+
),
351+
),
352+
),
353+
const SizedBox(height: 16),
354+
SecondaryButton(
355+
buttonHeight: ButtonHeight.l,
356+
label: "Cancel",
357+
onPressed: () => Navigator.of(ctx).pop(),
358+
),
359+
],
330360
),
331361
),
332-
actions: [
333-
TextButton(
334-
onPressed: () => Navigator.of(ctx).pop(),
335-
child: const Text("Cancel"),
336-
),
337-
],
338362
),
339363
);
340364

@@ -947,14 +971,13 @@ class _SendViewState extends ConsumerState<SendView> {
947971
}
948972
}
949973

950-
final shouldShowBuildingDialog = mounted && !Util.isDesktop;
951-
bool wasCancelled = false;
952974
try {
953-
if (shouldShowBuildingDialog) {
975+
bool wasCancelled = false;
976+
977+
if (mounted) {
954978
unawaited(
955979
showDialog<void>(
956980
context: context,
957-
useRootNavigator: false,
958981
useSafeArea: false,
959982
barrierDismissible: false,
960983
builder: (context) {
@@ -966,13 +989,17 @@ class _SendViewState extends ConsumerState<SendView> {
966989
BalanceType.private,
967990
onCancel: () {
968991
wasCancelled = true;
992+
993+
Navigator.of(context).pop();
969994
},
970995
);
971996
},
972997
),
973998
);
974999
}
9751000

1001+
final time = Future<dynamic>.delayed(const Duration(milliseconds: 2500));
1002+
9761003
Future<TxData> txDataFuture;
9771004

9781005
if (isPaynymSend) {
@@ -1122,27 +1149,9 @@ class _SendViewState extends ConsumerState<SendView> {
11221149
);
11231150
}
11241151

1125-
TxData txData;
1126-
if (Util.isDesktop && mounted) {
1127-
Exception? buildEx;
1128-
final desktopResult = await showLoading<TxData>(
1129-
whileFuture: txDataFuture,
1130-
context: context,
1131-
message: "Generating transaction...",
1132-
delay: const Duration(milliseconds: 2500),
1133-
rootNavigator: true,
1134-
onException: (e) => buildEx = e,
1135-
);
1136-
if (buildEx != null) throw buildEx!;
1137-
if (desktopResult == null || !mounted) return;
1138-
txData = desktopResult;
1139-
} else {
1140-
final time = Future<dynamic>.delayed(
1141-
const Duration(milliseconds: 2500),
1142-
);
1143-
final results = await Future.wait([txDataFuture, time]);
1144-
txData = results.first as TxData;
1145-
}
1152+
final results = await Future.wait([txDataFuture, time]);
1153+
1154+
TxData txData = results.first as TxData;
11461155

11471156
if (!wasCancelled && mounted) {
11481157
if (isPaynymSend) {
@@ -1157,10 +1166,8 @@ class _SendViewState extends ConsumerState<SendView> {
11571166
txData = txData.copyWith(noteOnChain: onChainNoteController.text);
11581167
}
11591168

1160-
if (shouldShowBuildingDialog) {
1161-
// pop building dialog
1162-
Navigator.of(context, rootNavigator: false).pop();
1163-
}
1169+
// pop building dialog
1170+
Navigator.of(context).pop();
11641171

11651172
unawaited(
11661173
Navigator.of(context).push(
@@ -1186,10 +1193,8 @@ class _SendViewState extends ConsumerState<SendView> {
11861193
} catch (e, s) {
11871194
Logging.instance.e("$e\n$s", error: e, stackTrace: s);
11881195
if (mounted) {
1189-
if (shouldShowBuildingDialog && !wasCancelled) {
1190-
// pop building dialog
1191-
Navigator.of(context, rootNavigator: false).pop();
1192-
}
1196+
// pop building dialog
1197+
Navigator.of(context).pop();
11931198

11941199
unawaited(
11951200
showDialog<dynamic>(
@@ -1370,10 +1375,9 @@ class _SendViewState extends ConsumerState<SendView> {
13701375
walletId = widget.walletId;
13711376
clipboard = widget.clipboard;
13721377
_isMasternodeCollateralUnshield =
1373-
(_data?.note.contains("Masternode collateral unshield") ?? false) &&
1374-
isFiro;
1378+
MasternodeCollateralNotes.isUnshield(_data?.note) && isFiro;
13751379
_isMasternodeCollateralSelfSend =
1376-
((_data?.note.contains("Masternode collateral prep") ?? false) ||
1380+
(MasternodeCollateralNotes.isPrep(_data?.note) ||
13771381
_isMasternodeCollateralUnshield) &&
13781382
isFiro;
13791383

lib/pages/send_view/sub_widgets/building_transaction_dialog.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ class _RestoringDialogState extends ConsumerState<BuildingTransactionDialog> {
7272
buttonHeight: ButtonHeight.l,
7373
label: "Cancel",
7474
onPressed: () {
75-
Navigator.of(context).pop();
7675
onCancel.call();
7776
},
7877
),

lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_send.dart

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -537,8 +537,9 @@ class _DesktopSendState extends ConsumerState<DesktopSend> {
537537
}
538538
}
539539

540-
bool wasCancelled = false;
541540
try {
541+
bool wasCancelled = false;
542+
542543
if (mounted) {
543544
unawaited(
544545
showDialog<dynamic>(
@@ -561,6 +562,8 @@ class _DesktopSendState extends ConsumerState<DesktopSend> {
561562
BalanceType.private,
562563
onCancel: () {
563564
wasCancelled = true;
565+
566+
Navigator.of(context).pop();
564567
},
565568
),
566569
),
@@ -772,9 +775,8 @@ class _DesktopSendState extends ConsumerState<DesktopSend> {
772775
} catch (e, s) {
773776
Logging.instance.e("Desktop send: ", error: e, stackTrace: s);
774777
if (mounted) {
775-
if (!wasCancelled) {
776-
Navigator.of(context, rootNavigator: true).pop();
777-
}
778+
// pop building dialog
779+
Navigator.of(context, rootNavigator: true).pop();
778780

779781
unawaited(
780782
showDialog<void>(

0 commit comments

Comments
 (0)