From 77e638af1669ab9c1b3efe2dbd47573963d2866c Mon Sep 17 00:00:00 2001 From: ryleedavis Date: Wed, 20 Sep 2023 16:15:07 -0600 Subject: [PATCH] add fusion progress provider to dialog + custom fusion --- .../cashfusion/desktop_cashfusion_view.dart | 55 ++- .../cashfusion/sub_widgets/fusion_dialog.dart | 314 ++++++++++-------- 2 files changed, 221 insertions(+), 148 deletions(-) diff --git a/lib/pages_desktop_specific/cashfusion/desktop_cashfusion_view.dart b/lib/pages_desktop_specific/cashfusion/desktop_cashfusion_view.dart index 82870da5f..7b63b6f3f 100644 --- a/lib/pages_desktop_specific/cashfusion/desktop_cashfusion_view.dart +++ b/lib/pages_desktop_specific/cashfusion/desktop_cashfusion_view.dart @@ -62,9 +62,12 @@ class _DesktopCashFusion extends ConsumerState { late final FocusNode serverFocusNode; late final TextEditingController portController; late final FocusNode portFocusNode; + late final TextEditingController fusionRoundController; + late final FocusNode fusionRoundFocusNode; String _serverTerm = ""; String _portTerm = ""; + String _fusionRoundTerm = ""; bool _useSSL = false; bool _trusted = false; @@ -139,9 +142,11 @@ class _DesktopCashFusion extends ConsumerState { void initState() { serverController = TextEditingController(); portController = TextEditingController(); + fusionRoundController = TextEditingController(); serverFocusNode = FocusNode(); portFocusNode = FocusNode(); + fusionRoundFocusNode = FocusNode(); enableSSLCheckbox = true; @@ -169,9 +174,11 @@ class _DesktopCashFusion extends ConsumerState { void dispose() { serverController.dispose(); portController.dispose(); + fusionRoundController.dispose(); serverFocusNode.dispose(); portFocusNode.dispose(); + fusionRoundFocusNode.dispose(); super.dispose(); } @@ -478,8 +485,12 @@ class _DesktopCashFusion extends ConsumerState { value: e, child: Text( e.name, - style: - STextStyles.desktopTextMedium(context), + style: STextStyles.smallMed14(context) + .copyWith( + color: Theme.of(context) + .extension()! + .textDark, + ), ), ), ), @@ -522,6 +533,46 @@ class _DesktopCashFusion extends ConsumerState { ), ), ), + if (_roundType == FusionRounds.Custom) + const SizedBox( + height: 10, + ), + if (_roundType == FusionRounds.Custom) + SizedBox( + width: 460, + child: RoundedWhiteContainer( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + ClipRRect( + borderRadius: BorderRadius.circular( + Constants.size.circularBorderRadius, + ), + child: TextField( + autocorrect: false, + enableSuggestions: false, + controller: fusionRoundController, + focusNode: fusionRoundFocusNode, + onChanged: (value) { + setState(() { + _fusionRoundTerm = value; + }); + }, + style: STextStyles.field(context), + decoration: standardInputDecoration( + "", + fusionRoundFocusNode, + context, + desktopMed: true, + ).copyWith( + labelText: + "Enter number of fusions.."), + ), + ), + ], + ), + ), + ), const SizedBox( height: 20, ), diff --git a/lib/pages_desktop_specific/cashfusion/sub_widgets/fusion_dialog.dart b/lib/pages_desktop_specific/cashfusion/sub_widgets/fusion_dialog.dart index 20b20d494..5d2f50744 100644 --- a/lib/pages_desktop_specific/cashfusion/sub_widgets/fusion_dialog.dart +++ b/lib/pages_desktop_specific/cashfusion/sub_widgets/fusion_dialog.dart @@ -1,6 +1,8 @@ import 'package:flutter/material.dart'; +import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; import 'package:stackwallet/pages/settings_views/global_settings_view/stack_backup_views/sub_widgets/restoring_item_card.dart'; +import 'package:stackwallet/providers/cash_fusion/fusion_progress_ui_state_provider.dart'; import 'package:stackwallet/themes/stack_colors.dart'; import 'package:stackwallet/utilities/assets.dart'; import 'package:stackwallet/utilities/text_styles.dart'; @@ -9,7 +11,7 @@ import 'package:stackwallet/widgets/desktop/desktop_dialog_close_button.dart'; import 'package:stackwallet/widgets/desktop/secondary_button.dart'; import 'package:stackwallet/widgets/rounded_container.dart'; -enum CashFusionStatus { waiting, restoring, success, failed } +enum CashFusionStatus { waiting, fusing, success, failed } class FusionDialog extends StatelessWidget { const FusionDialog({ @@ -26,7 +28,7 @@ class FusionDialog extends StatelessWidget { color: Theme.of(context).extension()!.buttonBackSecondary, ); - case CashFusionStatus.restoring: + case CashFusionStatus.fusing: return SvgPicture.asset( Assets.svg.loader, color: Theme.of(context).extension()!.accentColorGreen, @@ -100,182 +102,202 @@ class FusionDialog extends StatelessWidget { const SizedBox( height: 20, ), - RoundedContainer( - padding: EdgeInsets.zero, - color: - Theme.of(context).extension()!.popupBG, - borderColor: Theme.of(context) - .extension()! - .background, - child: RestoringItemCard( - left: SizedBox( - width: 32, - height: 32, - child: RoundedContainer( - padding: const EdgeInsets.all(0), - color: Theme.of(context) - .extension()! - .buttonBackSecondary, - child: Center( - child: SvgPicture.asset( - Assets.svg.node, - width: 16, - height: 16, + Consumer(builder: (_, ref, __) { + final state = ref.watch(fusionProgressUIStateProvider + .select((value) => value.connecting)); + return RoundedContainer( + padding: EdgeInsets.zero, + color: + Theme.of(context).extension()!.popupBG, + borderColor: Theme.of(context) + .extension()! + .background, + child: RestoringItemCard( + left: SizedBox( + width: 32, + height: 32, + child: RoundedContainer( + padding: const EdgeInsets.all(0), + color: Theme.of(context) + .extension()! + .buttonBackSecondary, + child: Center( + child: SvgPicture.asset( + Assets.svg.node, + width: 16, + height: 16, + ), ), ), ), + right: SizedBox( + width: 20, + height: 20, + child: _getIconForState(state), + ), + title: "Connecting to server", ), - right: SizedBox( - width: 20, - height: 20, - child: SvgPicture.asset(Assets.svg.circleQuestion), - ), - title: "Connecting to server", - ), - ), + ); + }), const SizedBox( height: 12, ), - RoundedContainer( - padding: EdgeInsets.zero, - color: - Theme.of(context).extension()!.popupBG, - borderColor: Theme.of(context) - .extension()! - .background, - child: RestoringItemCard( - left: SizedBox( - width: 32, - height: 32, - child: RoundedContainer( - padding: const EdgeInsets.all(0), - color: Theme.of(context) - .extension()! - .buttonBackSecondary, - child: Center( - child: SvgPicture.asset( - Assets.svg.upFromLine, - width: 30, - height: 30, + Consumer(builder: (_, ref, __) { + final state = ref.watch(fusionProgressUIStateProvider + .select((value) => value.outputs)); + return RoundedContainer( + padding: EdgeInsets.zero, + color: + Theme.of(context).extension()!.popupBG, + borderColor: Theme.of(context) + .extension()! + .background, + child: RestoringItemCard( + left: SizedBox( + width: 32, + height: 32, + child: RoundedContainer( + padding: const EdgeInsets.all(0), + color: Theme.of(context) + .extension()! + .buttonBackSecondary, + child: Center( + child: SvgPicture.asset( + Assets.svg.upFromLine, + width: 30, + height: 30, + ), ), ), ), + right: SizedBox( + width: 20, + height: 20, + child: _getIconForState(state), + ), + title: "Allocating outputs", ), - right: SizedBox( - width: 20, - height: 20, - child: SvgPicture.asset(Assets.svg.circleQuestion), - ), - title: "Allocating outputs", - ), - ), + ); + }), const SizedBox( height: 12, ), - RoundedContainer( - padding: EdgeInsets.zero, - color: - Theme.of(context).extension()!.popupBG, - borderColor: Theme.of(context) - .extension()! - .background, - child: RestoringItemCard( - left: SizedBox( - width: 32, - height: 32, - child: RoundedContainer( - padding: const EdgeInsets.all(0), - color: Theme.of(context) - .extension()! - .buttonBackSecondary, - child: Center( - child: SvgPicture.asset( - Assets.svg.peers, - width: 30, - height: 30, + Consumer(builder: (_, ref, __) { + final state = ref.watch(fusionProgressUIStateProvider + .select((value) => value.peers)); + return RoundedContainer( + padding: EdgeInsets.zero, + color: + Theme.of(context).extension()!.popupBG, + borderColor: Theme.of(context) + .extension()! + .background, + child: RestoringItemCard( + left: SizedBox( + width: 32, + height: 32, + child: RoundedContainer( + padding: const EdgeInsets.all(0), + color: Theme.of(context) + .extension()! + .buttonBackSecondary, + child: Center( + child: SvgPicture.asset( + Assets.svg.peers, + width: 30, + height: 30, + ), ), ), ), + right: SizedBox( + width: 20, + height: 20, + child: _getIconForState(state), + ), + title: "Waiting for peers", ), - right: SizedBox( - width: 20, - height: 20, - child: SvgPicture.asset(Assets.svg.circleQuestion), - ), - title: "Waiting for peers", - ), - ), + ); + }), const SizedBox( height: 12, ), - RoundedContainer( - padding: EdgeInsets.zero, - color: - Theme.of(context).extension()!.popupBG, - borderColor: Theme.of(context) - .extension()! - .background, - child: RestoringItemCard( - left: SizedBox( - width: 32, - height: 32, - child: RoundedContainer( - padding: const EdgeInsets.all(0), - color: Theme.of(context) - .extension()! - .buttonBackSecondary, - child: Center( - child: SvgPicture.asset( - Assets.svg.fusing, - width: 30, - height: 30, + Consumer(builder: (_, ref, __) { + final state = ref.watch(fusionProgressUIStateProvider + .select((value) => value.fusing)); + return RoundedContainer( + padding: EdgeInsets.zero, + color: + Theme.of(context).extension()!.popupBG, + borderColor: Theme.of(context) + .extension()! + .background, + child: RestoringItemCard( + left: SizedBox( + width: 32, + height: 32, + child: RoundedContainer( + padding: const EdgeInsets.all(0), + color: Theme.of(context) + .extension()! + .buttonBackSecondary, + child: Center( + child: SvgPicture.asset( + Assets.svg.fusing, + width: 30, + height: 30, + ), ), ), ), + right: SizedBox( + width: 20, + height: 20, + child: _getIconForState(state), + ), + title: "Fusing", ), - right: SizedBox( - width: 20, - height: 20, - child: SvgPicture.asset(Assets.svg.circleQuestion), - ), - title: "Fusing", - ), - ), + ); + }), const SizedBox( height: 12, ), - RoundedContainer( - padding: EdgeInsets.zero, - color: - Theme.of(context).extension()!.popupBG, - borderColor: - Theme.of(context).extension()!.shadow, - child: RestoringItemCard( - left: SizedBox( - width: 32, - height: 32, - child: RoundedContainer( - padding: const EdgeInsets.all(0), - color: Theme.of(context) - .extension()! - .buttonBackSecondary, - child: Center( - child: SvgPicture.asset( - Assets.svg.checkCircle, - width: 16, - height: 16, + Consumer(builder: (_, ref, __) { + final state = ref.watch(fusionProgressUIStateProvider + .select((value) => value.complete)); + return RoundedContainer( + padding: EdgeInsets.zero, + color: + Theme.of(context).extension()!.popupBG, + borderColor: + Theme.of(context).extension()!.shadow, + child: RestoringItemCard( + left: SizedBox( + width: 32, + height: 32, + child: RoundedContainer( + padding: const EdgeInsets.all(0), + color: Theme.of(context) + .extension()! + .buttonBackSecondary, + child: Center( + child: SvgPicture.asset( + Assets.svg.checkCircle, + width: 16, + height: 16, + ), ), ), ), + right: SizedBox( + width: 20, + height: 20, + child: _getIconForState(state), + ), + title: "Complete", ), - right: SizedBox( - width: 20, - height: 20, - child: SvgPicture.asset(Assets.svg.circleQuestion), - ), - title: "Complete", - ), - ), + ); + }), const SizedBox( height: 12, ),