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,7 +102,10 @@ class FusionDialog extends StatelessWidget {
const SizedBox( const SizedBox(
height: 20, height: 20,
), ),
RoundedContainer( Consumer(builder: (_, ref, __) {
final state = ref.watch(fusionProgressUIStateProvider
.select((value) => value.connecting));
return RoundedContainer(
padding: EdgeInsets.zero, padding: EdgeInsets.zero,
color: color:
Theme.of(context).extension<StackColors>()!.popupBG, Theme.of(context).extension<StackColors>()!.popupBG,
@ -128,15 +133,19 @@ class FusionDialog extends StatelessWidget {
right: SizedBox( right: SizedBox(
width: 20, width: 20,
height: 20, height: 20,
child: SvgPicture.asset(Assets.svg.circleQuestion), child: _getIconForState(state),
), ),
title: "Connecting to server", title: "Connecting to server",
), ),
), );
}),
const SizedBox( const SizedBox(
height: 12, height: 12,
), ),
RoundedContainer( Consumer(builder: (_, ref, __) {
final state = ref.watch(fusionProgressUIStateProvider
.select((value) => value.outputs));
return RoundedContainer(
padding: EdgeInsets.zero, padding: EdgeInsets.zero,
color: color:
Theme.of(context).extension<StackColors>()!.popupBG, Theme.of(context).extension<StackColors>()!.popupBG,
@ -164,15 +173,19 @@ class FusionDialog extends StatelessWidget {
right: SizedBox( right: SizedBox(
width: 20, width: 20,
height: 20, height: 20,
child: SvgPicture.asset(Assets.svg.circleQuestion), child: _getIconForState(state),
), ),
title: "Allocating outputs", title: "Allocating outputs",
), ),
), );
}),
const SizedBox( const SizedBox(
height: 12, height: 12,
), ),
RoundedContainer( Consumer(builder: (_, ref, __) {
final state = ref.watch(fusionProgressUIStateProvider
.select((value) => value.peers));
return RoundedContainer(
padding: EdgeInsets.zero, padding: EdgeInsets.zero,
color: color:
Theme.of(context).extension<StackColors>()!.popupBG, Theme.of(context).extension<StackColors>()!.popupBG,
@ -200,15 +213,19 @@ class FusionDialog extends StatelessWidget {
right: SizedBox( right: SizedBox(
width: 20, width: 20,
height: 20, height: 20,
child: SvgPicture.asset(Assets.svg.circleQuestion), child: _getIconForState(state),
), ),
title: "Waiting for peers", title: "Waiting for peers",
), ),
), );
}),
const SizedBox( const SizedBox(
height: 12, height: 12,
), ),
RoundedContainer( Consumer(builder: (_, ref, __) {
final state = ref.watch(fusionProgressUIStateProvider
.select((value) => value.fusing));
return RoundedContainer(
padding: EdgeInsets.zero, padding: EdgeInsets.zero,
color: color:
Theme.of(context).extension<StackColors>()!.popupBG, Theme.of(context).extension<StackColors>()!.popupBG,
@ -236,15 +253,19 @@ class FusionDialog extends StatelessWidget {
right: SizedBox( right: SizedBox(
width: 20, width: 20,
height: 20, height: 20,
child: SvgPicture.asset(Assets.svg.circleQuestion), child: _getIconForState(state),
), ),
title: "Fusing", title: "Fusing",
), ),
), );
}),
const SizedBox( const SizedBox(
height: 12, height: 12,
), ),
RoundedContainer( Consumer(builder: (_, ref, __) {
final state = ref.watch(fusionProgressUIStateProvider
.select((value) => value.complete));
return RoundedContainer(
padding: EdgeInsets.zero, padding: EdgeInsets.zero,
color: color:
Theme.of(context).extension<StackColors>()!.popupBG, Theme.of(context).extension<StackColors>()!.popupBG,
@ -271,11 +292,12 @@ class FusionDialog extends StatelessWidget {
right: SizedBox( right: SizedBox(
width: 20, width: 20,
height: 20, height: 20,
child: SvgPicture.asset(Assets.svg.circleQuestion), child: _getIconForState(state),
), ),
title: "Complete", title: "Complete",
), ),
), );
}),
const SizedBox( const SizedBox(
height: 12, height: 12,
), ),