From 2afec92279c8faab60ba1baec3eb3bd29caeaff6 Mon Sep 17 00:00:00 2001 From: julian Date: Wed, 2 Nov 2022 14:24:41 -0600 Subject: [PATCH] desktop wallet network settings expanding advanced rescan --- assets/svg/network-wired-2.svg | 10 ++ .../sub_widgets/confirm_full_rescan.dart | 139 +++++++++++---- .../wallet_network_settings_view.dart | 163 ++++++++++++++++-- lib/utilities/assets.dart | 1 + lib/widgets/conditional_parent.dart | 4 +- pubspec.yaml | 1 + 6 files changed, 266 insertions(+), 52 deletions(-) create mode 100644 assets/svg/network-wired-2.svg diff --git a/assets/svg/network-wired-2.svg b/assets/svg/network-wired-2.svg new file mode 100644 index 000000000..bbbfa056f --- /dev/null +++ b/assets/svg/network-wired-2.svg @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/lib/pages/settings_views/wallet_settings_view/wallet_network_settings_view/sub_widgets/confirm_full_rescan.dart b/lib/pages/settings_views/wallet_settings_view/wallet_network_settings_view/sub_widgets/confirm_full_rescan.dart index 141eb4c99..950d8d79e 100644 --- a/lib/pages/settings_views/wallet_settings_view/wallet_network_settings_view/sub_widgets/confirm_full_rescan.dart +++ b/lib/pages/settings_views/wallet_settings_view/wallet_network_settings_view/sub_widgets/confirm_full_rescan.dart @@ -1,6 +1,11 @@ import 'package:flutter/material.dart'; import 'package:stackwallet/utilities/text_styles.dart'; import 'package:stackwallet/utilities/theme/stack_colors.dart'; +import 'package:stackwallet/utilities/util.dart'; +import 'package:stackwallet/widgets/desktop/desktop_dialog.dart'; +import 'package:stackwallet/widgets/desktop/desktop_dialog_close_button.dart'; +import 'package:stackwallet/widgets/desktop/primary_button.dart'; +import 'package:stackwallet/widgets/desktop/secondary_button.dart'; import 'package:stackwallet/widgets/stack_dialog.dart'; class ConfirmFullRescanDialog extends StatelessWidget { @@ -11,40 +16,110 @@ class ConfirmFullRescanDialog extends StatelessWidget { @override Widget build(BuildContext context) { - return WillPopScope( - onWillPop: () async { - return true; - }, - child: StackDialog( - title: "Rescan blockchain", - message: - "Warning! It may take a while. If you exit before completion, you will have to redo the process.", - leftButton: TextButton( - style: Theme.of(context) - .extension()! - .getSecondaryEnabledButtonColor(context), - child: Text( - "Cancel", - style: STextStyles.itemSubtitle12(context), - ), - onPressed: () { - Navigator.of(context).pop(); - }, + if (Util.isDesktop) { + return DesktopDialog( + maxWidth: 576, + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Padding( + padding: const EdgeInsets.only( + left: 32, + ), + child: Text( + "Rescan blockchain", + style: STextStyles.desktopH3(context), + ), + ), + const DesktopDialogCloseButton(), + ], + ), + Padding( + padding: const EdgeInsets.only( + top: 8, + left: 32, + right: 32, + bottom: 32, + ), + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + Text( + "Warning! It may take a while. If you exit before completion, you will have to redo the process.", + style: STextStyles.desktopTextSmall(context), + ), + const SizedBox( + height: 43, + ), + Row( + children: [ + Expanded( + child: SecondaryButton( + desktopMed: true, + onPressed: Navigator.of(context).pop, + label: "Cancel", + ), + ), + const SizedBox( + width: 16, + ), + Expanded( + child: PrimaryButton( + desktopMed: true, + onPressed: () { + Navigator.of(context).pop(); + onConfirm.call(); + }, + label: "Rescan", + ), + ), + ], + ) + ], + ), + ) + ], ), - rightButton: TextButton( - style: Theme.of(context) - .extension()! - .getPrimaryEnabledButtonColor(context), - child: Text( - "Rescan", - style: STextStyles.button(context), + ); + } else { + return WillPopScope( + onWillPop: () async { + return true; + }, + child: StackDialog( + title: "Rescan blockchain", + message: + "Warning! It may take a while. If you exit before completion, you will have to redo the process.", + leftButton: TextButton( + style: Theme.of(context) + .extension()! + .getSecondaryEnabledButtonColor(context), + child: Text( + "Cancel", + style: STextStyles.itemSubtitle12(context), + ), + onPressed: () { + Navigator.of(context).pop(); + }, + ), + rightButton: TextButton( + style: Theme.of(context) + .extension()! + .getPrimaryEnabledButtonColor(context), + child: Text( + "Rescan", + style: STextStyles.button(context), + ), + onPressed: () { + Navigator.of(context).pop(); + onConfirm.call(); + }, ), - onPressed: () { - Navigator.of(context).pop(); - onConfirm.call(); - }, ), - ), - ); + ); + } } } diff --git a/lib/pages/settings_views/wallet_settings_view/wallet_network_settings_view/wallet_network_settings_view.dart b/lib/pages/settings_views/wallet_settings_view/wallet_network_settings_view/wallet_network_settings_view.dart index 8195491d8..fdb73fc88 100644 --- a/lib/pages/settings_views/wallet_settings_view/wallet_network_settings_view/wallet_network_settings_view.dart +++ b/lib/pages/settings_views/wallet_settings_view/wallet_network_settings_view/wallet_network_settings_view.dart @@ -28,6 +28,7 @@ import 'package:stackwallet/widgets/animated_text.dart'; import 'package:stackwallet/widgets/conditional_parent.dart'; import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; import 'package:stackwallet/widgets/custom_buttons/blue_text_button.dart'; +import 'package:stackwallet/widgets/expandable.dart'; import 'package:stackwallet/widgets/progress_bar.dart'; import 'package:stackwallet/widgets/rounded_container.dart'; import 'package:stackwallet/widgets/rounded_white_container.dart'; @@ -61,7 +62,7 @@ class _WalletNetworkSettingsViewState extends ConsumerState { final double _padding = 16; final double _boxPadding = 12; - final double _iconSize = 28; + final double _iconSize = Util.isDesktop ? 40 : 28; late final EventBus eventBus; @@ -75,6 +76,7 @@ class _WalletNetworkSettingsViewState late double _percent; late int _blocksRemaining; + bool _advancedIsExpanded = true; Future _attemptRescan() async { if (!Platform.isLinux) await Wakelock.enable(); @@ -269,7 +271,7 @@ class _WalletNetworkSettingsViewState final bool isDesktop = Util.isDesktop; final progressLength = isDesktop - ? 450.0 + ? 430.0 : screenWidth - (_padding * 2) - (_boxPadding * 3) - _iconSize; final coin = ref @@ -373,7 +375,7 @@ class _WalletNetworkSettingsViewState GestureDetector( onTap: () { Navigator.of(context).pop(); - showDialog( + showDialog( context: context, useSafeArea: false, barrierDismissible: true, @@ -453,11 +455,17 @@ class _WalletNetworkSettingsViewState ), ], ), - const SizedBox( - height: 9, + SizedBox( + height: isDesktop ? 12 : 9, ), if (_currentSyncStatus == WalletSyncStatus.synced) RoundedWhiteContainer( + borderColor: isDesktop + ? Theme.of(context).extension()!.background + : null, + padding: isDesktop + ? const EdgeInsets.all(16) + : const EdgeInsets.all(12), child: Row( children: [ Container( @@ -527,6 +535,12 @@ class _WalletNetworkSettingsViewState ), if (_currentSyncStatus == WalletSyncStatus.syncing) RoundedWhiteContainer( + borderColor: isDesktop + ? Theme.of(context).extension()!.background + : null, + padding: isDesktop + ? const EdgeInsets.all(16) + : const EdgeInsets.all(12), child: Row( children: [ Container( @@ -618,6 +632,12 @@ class _WalletNetworkSettingsViewState ), if (_currentSyncStatus == WalletSyncStatus.unableToSync) RoundedWhiteContainer( + borderColor: isDesktop + ? Theme.of(context).extension()!.background + : null, + padding: isDesktop + ? const EdgeInsets.all(16) + : const EdgeInsets.all(12), child: Row( children: [ Container( @@ -708,8 +728,8 @@ class _WalletNetworkSettingsViewState ), ), ), - const SizedBox( - height: 20, + SizedBox( + height: isDesktop ? 32 : 20, ), Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, @@ -740,8 +760,8 @@ class _WalletNetworkSettingsViewState ), ], ), - const SizedBox( - height: 8, + SizedBox( + height: isDesktop ? 12 : 8, ), NodesList( coin: ref.watch(walletsChangeNotifierProvider @@ -750,18 +770,125 @@ class _WalletNetworkSettingsViewState ), if (isDesktop) const SizedBox( - height: 20, + height: 32, ), if (isDesktop) - Row( - mainAxisAlignment: MainAxisAlignment.start, - children: [ - Text( - "Advanced", - textAlign: TextAlign.left, - style: STextStyles.desktopTextExtraExtraSmall(context), + Padding( + padding: const EdgeInsets.only( + bottom: 12, + ), + child: Row( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Text( + "Advanced", + textAlign: TextAlign.left, + style: STextStyles.desktopTextExtraExtraSmall(context), + ), + ], + ), + ), + if (isDesktop) + RoundedWhiteContainer( + borderColor: isDesktop + ? Theme.of(context).extension()!.background + : null, + padding: isDesktop + ? const EdgeInsets.all(16) + : const EdgeInsets.all(12), + child: Expandable( + onExpandChanged: (state) { + setState(() { + _advancedIsExpanded = state == ExpandableState.expanded; + }); + }, + header: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Row( + children: [ + Container( + width: _iconSize, + height: _iconSize, + decoration: BoxDecoration( + color: Theme.of(context) + .extension()! + .textFieldDefaultBG, + borderRadius: BorderRadius.circular(_iconSize), + ), + child: Center( + child: SvgPicture.asset( + Assets.svg.networkWired, + width: 24, + color: Theme.of(context) + .extension()! + .textDark, + ), + ), + ), + const SizedBox( + width: 10, + ), + Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + "Advanced", + style: STextStyles.desktopTextExtraExtraSmall( + context) + .copyWith( + color: Theme.of(context) + .extension()! + .textDark, + ), + ), + Text( + "Rescan blockchain", + style: STextStyles.desktopTextExtraExtraSmall( + context), + ), + ], + ) + ], + ), + SvgPicture.asset( + _advancedIsExpanded + ? Assets.svg.chevronDown + : Assets.svg.chevronUp, + width: 12, + height: 6, + color: Theme.of(context) + .extension()! + .textSubtitle1, + ), + ], ), - ], + body: Row( + children: [ + Padding( + padding: const EdgeInsets.only( + left: 50, + top: 16, + bottom: 6, + ), + child: BlueTextButton( + text: "Rescan", + onTap: () async { + await showDialog( + context: context, + builder: (context) { + return ConfirmFullRescanDialog( + onConfirm: _attemptRescan, + ); + }, + ); + }, + ), + ), + ], + ), + ), ), ], ), diff --git a/lib/utilities/assets.dart b/lib/utilities/assets.dart index 78535c19b..386ea1cd8 100644 --- a/lib/utilities/assets.dart +++ b/lib/utilities/assets.dart @@ -101,6 +101,7 @@ class _SVG { String get downloadFolder => "assets/svg/folder-down.svg"; String get lock => "assets/svg/lock-keyhole.svg"; String get network => "assets/svg/network-wired.svg"; + String get networkWired => "assets/svg/network-wired-2.svg"; String get addressBook => "assets/svg/address-book.svg"; String get addressBook2 => "assets/svg/address-book2.svg"; String get arrowRotate3 => "assets/svg/rotate-exclamation.svg"; diff --git a/lib/widgets/conditional_parent.dart b/lib/widgets/conditional_parent.dart index 6db50c6e8..757c8f992 100644 --- a/lib/widgets/conditional_parent.dart +++ b/lib/widgets/conditional_parent.dart @@ -4,13 +4,13 @@ class ConditionalParent extends StatelessWidget { const ConditionalParent({ Key? key, required this.condition, - required this.child, required this.builder, + required this.child, }) : super(key: key); final bool condition; - final Widget child; final Widget Function(Widget) builder; + final Widget child; @override Widget build(BuildContext context) { diff --git a/pubspec.yaml b/pubspec.yaml index 29d25cb84..b84135f4a 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -237,6 +237,7 @@ flutter: - assets/svg/rotate-exclamation.svg - assets/svg/folder-down.svg - assets/svg/network-wired.svg + - assets/svg/network-wired-2.svg - assets/svg/address-book.svg - assets/svg/address-book2.svg - assets/svg/arrow-right.svg