add fusion progress provider to dialog + custom fusion

This commit is contained in:
ryleedavis 2023-09-20 16:15:07 -06:00
parent 0597e317ba
commit 77e638af16
2 changed files with 221 additions and 148 deletions

View file

@ -62,9 +62,12 @@ class _DesktopCashFusion extends ConsumerState<DesktopCashFusionView> {
late final FocusNode serverFocusNode; late final FocusNode serverFocusNode;
late final TextEditingController portController; late final TextEditingController portController;
late final FocusNode portFocusNode; late final FocusNode portFocusNode;
late final TextEditingController fusionRoundController;
late final FocusNode fusionRoundFocusNode;
String _serverTerm = ""; String _serverTerm = "";
String _portTerm = ""; String _portTerm = "";
String _fusionRoundTerm = "";
bool _useSSL = false; bool _useSSL = false;
bool _trusted = false; bool _trusted = false;
@ -139,9 +142,11 @@ class _DesktopCashFusion extends ConsumerState<DesktopCashFusionView> {
void initState() { void initState() {
serverController = TextEditingController(); serverController = TextEditingController();
portController = TextEditingController(); portController = TextEditingController();
fusionRoundController = TextEditingController();
serverFocusNode = FocusNode(); serverFocusNode = FocusNode();
portFocusNode = FocusNode(); portFocusNode = FocusNode();
fusionRoundFocusNode = FocusNode();
enableSSLCheckbox = true; enableSSLCheckbox = true;
@ -169,9 +174,11 @@ class _DesktopCashFusion extends ConsumerState<DesktopCashFusionView> {
void dispose() { void dispose() {
serverController.dispose(); serverController.dispose();
portController.dispose(); portController.dispose();
fusionRoundController.dispose();
serverFocusNode.dispose(); serverFocusNode.dispose();
portFocusNode.dispose(); portFocusNode.dispose();
fusionRoundFocusNode.dispose();
super.dispose(); super.dispose();
} }
@ -478,8 +485,12 @@ class _DesktopCashFusion extends ConsumerState<DesktopCashFusionView> {
value: e, value: e,
child: Text( child: Text(
e.name, e.name,
style: style: STextStyles.smallMed14(context)
STextStyles.desktopTextMedium(context), .copyWith(
color: Theme.of(context)
.extension<StackColors>()!
.textDark,
),
), ),
), ),
), ),
@ -522,6 +533,46 @@ class _DesktopCashFusion extends ConsumerState<DesktopCashFusionView> {
), ),
), ),
), ),
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( const SizedBox(
height: 20, height: 20,
), ),

View file

@ -1,6 +1,8 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:flutter_svg/svg.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/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/themes/stack_colors.dart';
import 'package:stackwallet/utilities/assets.dart'; import 'package:stackwallet/utilities/assets.dart';
import 'package:stackwallet/utilities/text_styles.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/desktop/secondary_button.dart';
import 'package:stackwallet/widgets/rounded_container.dart'; import 'package:stackwallet/widgets/rounded_container.dart';
enum CashFusionStatus { waiting, restoring, success, failed } enum CashFusionStatus { waiting, fusing, success, failed }
class FusionDialog extends StatelessWidget { class FusionDialog extends StatelessWidget {
const FusionDialog({ const FusionDialog({
@ -26,7 +28,7 @@ class FusionDialog extends StatelessWidget {
color: color:
Theme.of(context).extension<StackColors>()!.buttonBackSecondary, Theme.of(context).extension<StackColors>()!.buttonBackSecondary,
); );
case CashFusionStatus.restoring: case CashFusionStatus.fusing:
return SvgPicture.asset( return SvgPicture.asset(
Assets.svg.loader, Assets.svg.loader,
color: Theme.of(context).extension<StackColors>()!.accentColorGreen, color: Theme.of(context).extension<StackColors>()!.accentColorGreen,
@ -100,182 +102,202 @@ class FusionDialog extends StatelessWidget {
const SizedBox( const SizedBox(
height: 20, height: 20,
), ),
RoundedContainer( Consumer(builder: (_, ref, __) {
padding: EdgeInsets.zero, final state = ref.watch(fusionProgressUIStateProvider
color: .select((value) => value.connecting));
Theme.of(context).extension<StackColors>()!.popupBG, return RoundedContainer(
borderColor: Theme.of(context) padding: EdgeInsets.zero,
.extension<StackColors>()! color:
.background, Theme.of(context).extension<StackColors>()!.popupBG,
child: RestoringItemCard( borderColor: Theme.of(context)
left: SizedBox( .extension<StackColors>()!
width: 32, .background,
height: 32, child: RestoringItemCard(
child: RoundedContainer( left: SizedBox(
padding: const EdgeInsets.all(0), width: 32,
color: Theme.of(context) height: 32,
.extension<StackColors>()! child: RoundedContainer(
.buttonBackSecondary, padding: const EdgeInsets.all(0),
child: Center( color: Theme.of(context)
child: SvgPicture.asset( .extension<StackColors>()!
Assets.svg.node, .buttonBackSecondary,
width: 16, child: Center(
height: 16, 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( const SizedBox(
height: 12, height: 12,
), ),
RoundedContainer( Consumer(builder: (_, ref, __) {
padding: EdgeInsets.zero, final state = ref.watch(fusionProgressUIStateProvider
color: .select((value) => value.outputs));
Theme.of(context).extension<StackColors>()!.popupBG, return RoundedContainer(
borderColor: Theme.of(context) padding: EdgeInsets.zero,
.extension<StackColors>()! color:
.background, Theme.of(context).extension<StackColors>()!.popupBG,
child: RestoringItemCard( borderColor: Theme.of(context)
left: SizedBox( .extension<StackColors>()!
width: 32, .background,
height: 32, child: RestoringItemCard(
child: RoundedContainer( left: SizedBox(
padding: const EdgeInsets.all(0), width: 32,
color: Theme.of(context) height: 32,
.extension<StackColors>()! child: RoundedContainer(
.buttonBackSecondary, padding: const EdgeInsets.all(0),
child: Center( color: Theme.of(context)
child: SvgPicture.asset( .extension<StackColors>()!
Assets.svg.upFromLine, .buttonBackSecondary,
width: 30, child: Center(
height: 30, 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( const SizedBox(
height: 12, height: 12,
), ),
RoundedContainer( Consumer(builder: (_, ref, __) {
padding: EdgeInsets.zero, final state = ref.watch(fusionProgressUIStateProvider
color: .select((value) => value.peers));
Theme.of(context).extension<StackColors>()!.popupBG, return RoundedContainer(
borderColor: Theme.of(context) padding: EdgeInsets.zero,
.extension<StackColors>()! color:
.background, Theme.of(context).extension<StackColors>()!.popupBG,
child: RestoringItemCard( borderColor: Theme.of(context)
left: SizedBox( .extension<StackColors>()!
width: 32, .background,
height: 32, child: RestoringItemCard(
child: RoundedContainer( left: SizedBox(
padding: const EdgeInsets.all(0), width: 32,
color: Theme.of(context) height: 32,
.extension<StackColors>()! child: RoundedContainer(
.buttonBackSecondary, padding: const EdgeInsets.all(0),
child: Center( color: Theme.of(context)
child: SvgPicture.asset( .extension<StackColors>()!
Assets.svg.peers, .buttonBackSecondary,
width: 30, child: Center(
height: 30, 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( const SizedBox(
height: 12, height: 12,
), ),
RoundedContainer( Consumer(builder: (_, ref, __) {
padding: EdgeInsets.zero, final state = ref.watch(fusionProgressUIStateProvider
color: .select((value) => value.fusing));
Theme.of(context).extension<StackColors>()!.popupBG, return RoundedContainer(
borderColor: Theme.of(context) padding: EdgeInsets.zero,
.extension<StackColors>()! color:
.background, Theme.of(context).extension<StackColors>()!.popupBG,
child: RestoringItemCard( borderColor: Theme.of(context)
left: SizedBox( .extension<StackColors>()!
width: 32, .background,
height: 32, child: RestoringItemCard(
child: RoundedContainer( left: SizedBox(
padding: const EdgeInsets.all(0), width: 32,
color: Theme.of(context) height: 32,
.extension<StackColors>()! child: RoundedContainer(
.buttonBackSecondary, padding: const EdgeInsets.all(0),
child: Center( color: Theme.of(context)
child: SvgPicture.asset( .extension<StackColors>()!
Assets.svg.fusing, .buttonBackSecondary,
width: 30, child: Center(
height: 30, 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( const SizedBox(
height: 12, height: 12,
), ),
RoundedContainer( Consumer(builder: (_, ref, __) {
padding: EdgeInsets.zero, final state = ref.watch(fusionProgressUIStateProvider
color: .select((value) => value.complete));
Theme.of(context).extension<StackColors>()!.popupBG, return RoundedContainer(
borderColor: padding: EdgeInsets.zero,
Theme.of(context).extension<StackColors>()!.shadow, color:
child: RestoringItemCard( Theme.of(context).extension<StackColors>()!.popupBG,
left: SizedBox( borderColor:
width: 32, Theme.of(context).extension<StackColors>()!.shadow,
height: 32, child: RestoringItemCard(
child: RoundedContainer( left: SizedBox(
padding: const EdgeInsets.all(0), width: 32,
color: Theme.of(context) height: 32,
.extension<StackColors>()! child: RoundedContainer(
.buttonBackSecondary, padding: const EdgeInsets.all(0),
child: Center( color: Theme.of(context)
child: SvgPicture.asset( .extension<StackColors>()!
Assets.svg.checkCircle, .buttonBackSecondary,
width: 16, child: Center(
height: 16, 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( const SizedBox(
height: 12, height: 12,
), ),