From e99c32ea00533a00e81d09313d2352563b35afe2 Mon Sep 17 00:00:00 2001 From: julian Date: Mon, 16 Oct 2023 12:00:35 -0600 Subject: [PATCH] add fusion rounds selection sheet --- lib/pages/cashfusion/cashfusion_view.dart | 187 +++++------------- .../fusion_rounds_selection_sheet.dart | 167 ++++++++++++++++ pubspec.lock | 8 + pubspec.yaml | 1 + 4 files changed, 228 insertions(+), 135 deletions(-) create mode 100644 lib/pages/cashfusion/fusion_rounds_selection_sheet.dart diff --git a/lib/pages/cashfusion/cashfusion_view.dart b/lib/pages/cashfusion/cashfusion_view.dart index 6db751bcd..240e9b087 100644 --- a/lib/pages/cashfusion/cashfusion_view.dart +++ b/lib/pages/cashfusion/cashfusion_view.dart @@ -9,8 +9,10 @@ */ import 'package:flutter/material.dart'; +import 'package:flutter_native_splash/cli_commands.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; +import 'package:stackwallet/pages/cashfusion/fusion_rounds_selection_sheet.dart'; import 'package:stackwallet/providers/global/wallets_provider.dart'; import 'package:stackwallet/services/mixins/fusion_wallet_interface.dart'; import 'package:stackwallet/themes/stack_colors.dart'; @@ -19,6 +21,7 @@ import 'package:stackwallet/utilities/text_styles.dart'; import 'package:stackwallet/widgets/background.dart'; import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; import 'package:stackwallet/widgets/desktop/primary_button.dart'; +import 'package:stackwallet/widgets/rounded_container.dart'; import 'package:stackwallet/widgets/rounded_white_container.dart'; class CashFusionView extends ConsumerStatefulWidget { @@ -36,15 +39,7 @@ class CashFusionView extends ConsumerStatefulWidget { } class _CashFusionViewState extends ConsumerState { - @override - void initState() { - super.initState(); - } - - @override - void dispose() { - super.dispose(); - } + FusionOption _option = FusionOption.continuous; @override Widget build(BuildContext context) { @@ -145,135 +140,57 @@ class _CashFusionViewState extends ConsumerState { const SizedBox( height: 12, ), - TextField(), // TODO replace placholder textfield with button for bottom sheet - const SizedBox( - height: 16, - ), - // Row( - // mainAxisAlignment: MainAxisAlignment.spaceBetween, - // children: [ - // Text( - // "Tor status", - // textAlign: TextAlign.left, - // style: isDesktop - // ? STextStyles.desktopTextExtraExtraSmall(context) - // : STextStyles.smallMed12(context), - // ), - // CustomTextButton( - // text: ref.watch(prefsChangeNotifierProvider - // .select((value) => value.useTor)) - // ? "Disconnect" - // : "Connect", - // onTap: onTorTapped, - // ), - // ], - // ), - // const SizedBox( - // height: 12, - // ),RoundedWhiteContainer( - // borderColor: isDesktop - // ? Theme.of(context).extension()!.background - // : null, - // padding: - // isDesktop ? const EdgeInsets.all(16) : const EdgeInsets.all(12), - // child: Row( - // children: [ - // if (ref.watch(prefsChangeNotifierProvider - // .select((value) => value.useTor))) - // Container( - // width: _iconSize, - // height: _iconSize, - // decoration: BoxDecoration( - // color: Theme.of(context) - // .extension()! - // .accentColorGreen - // .withOpacity(0.2), - // borderRadius: BorderRadius.circular(_iconSize), - // ), - // child: Center( - // child: SvgPicture.asset( - // Assets.svg.tor, - // height: isDesktop ? 19 : 14, - // width: isDesktop ? 19 : 14, - // color: Theme.of(context) - // .extension()! - // .accentColorGreen, - // ), - // ), - // ), - // if (!ref.watch(prefsChangeNotifierProvider - // .select((value) => value.useTor))) - // Container( - // width: _iconSize, - // height: _iconSize, - // decoration: BoxDecoration( - // color: Theme.of(context) - // .extension()! - // .textDark - // .withOpacity(0.08), - // borderRadius: BorderRadius.circular(_iconSize), - // ), - // child: Center( - // child: SvgPicture.asset( - // Assets.svg.tor, - // height: isDesktop ? 19 : 14, - // width: isDesktop ? 19 : 14, - // color: Theme.of(context) - // .extension()! - // .textDark, - // ), - // ), - // ), - // SizedBox( - // width: _boxPadding, - // ), - // TorSubscription( - // onTorStatusChanged: (status) { - // setState(() { - // _torConnectionStatus = status; - // }); - // }, - // child: Column( - // crossAxisAlignment: CrossAxisAlignment.start, - // children: [ - // Text( - // "Tor status", - // style: STextStyles.desktopTextExtraExtraSmall(context) - // .copyWith( - // color: Theme.of(context) - // .extension()! - // .textDark, - // ), - // ), - // if (_torConnectionStatus == TorConnectionStatus.connected) - // Text( - // "Connected", - // style: - // STextStyles.desktopTextExtraExtraSmall(context), - // ), - // if (_torConnectionStatus == - // TorConnectionStatus.connecting) - // Text( - // "Connecting...", - // style: - // STextStyles.desktopTextExtraExtraSmall(context), - // ), - // if (_torConnectionStatus == - // TorConnectionStatus.disconnected) - // Text( - // "Disconnected", - // style: - // STextStyles.desktopTextExtraExtraSmall(context), - // ), - // ], - // ), - // ), - // ], - // ), - // ), + RoundedContainer( + onPressed: () async { + final option = + await showModalBottomSheet( + backgroundColor: Colors.transparent, + context: context, + shape: const RoundedRectangleBorder( + borderRadius: BorderRadius.vertical( + top: Radius.circular(20), + ), + ), + builder: (_) { + return FusionRoundCountSelectSheet( + currentOption: _option, + ); + }, + ); + if (option != null) { + setState(() { + _option = option; + }); + } + }, + color: Theme.of(context) + .extension()! + .textFieldActiveBG, + child: Padding( + padding: const EdgeInsets.symmetric(vertical: 8), + child: Row( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + children: [ + Text( + _option.name.capitalize(), + style: STextStyles.w500_12(context), + ), + SvgPicture.asset( + Assets.svg.chevronDown, + width: 12, + color: Theme.of(context) + .extension()! + .textSubtitle1, + ), + ], + ), + ), + ), const SizedBox( height: 16, ), + const Spacer(), PrimaryButton( label: "Start", diff --git a/lib/pages/cashfusion/fusion_rounds_selection_sheet.dart b/lib/pages/cashfusion/fusion_rounds_selection_sheet.dart new file mode 100644 index 000000000..f3b00890f --- /dev/null +++ b/lib/pages/cashfusion/fusion_rounds_selection_sheet.dart @@ -0,0 +1,167 @@ +/* + * This file is part of Stack Wallet. + * + * Copyright (c) 2023 Cypher Stack + * All Rights Reserved. + * The code is distributed under GPLv3 license, see LICENSE file for details. + * Generated by julian on 2023-10-16 + * + */ + +import 'package:flutter/material.dart'; +import 'package:flutter_hooks/flutter_hooks.dart'; +import 'package:flutter_native_splash/cli_commands.dart'; +import 'package:stackwallet/themes/stack_colors.dart'; +import 'package:stackwallet/utilities/constants.dart'; +import 'package:stackwallet/utilities/text_styles.dart'; + +enum FusionOption { + continuous, + custom; +} + +class FusionRoundCountSelectSheet extends HookWidget { + const FusionRoundCountSelectSheet({ + Key? key, + required this.currentOption, + }) : super(key: key); + + final FusionOption currentOption; + + @override + Widget build(BuildContext context) { + final option = useState(currentOption); + + return WillPopScope( + onWillPop: () async { + Navigator.of(context).pop(option.value); + return false; + }, + child: Container( + decoration: BoxDecoration( + color: Theme.of(context).extension()!.popupBG, + borderRadius: const BorderRadius.vertical( + top: Radius.circular(20), + ), + ), + child: Padding( + padding: const EdgeInsets.only( + left: 24, + right: 24, + top: 10, + bottom: 0, + ), + child: Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Center( + child: Container( + decoration: BoxDecoration( + color: Theme.of(context) + .extension()! + .textFieldDefaultBG, + borderRadius: BorderRadius.circular( + Constants.size.circularBorderRadius, + ), + ), + width: 60, + height: 4, + ), + ), + const SizedBox( + height: 36, + ), + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + "Rounds of fusion", + style: STextStyles.pageTitleH2(context), + textAlign: TextAlign.left, + ), + const SizedBox( + height: 20, + ), + for (int i = 0; i < FusionOption.values.length; i++) + Column( + children: [ + GestureDetector( + onTap: () { + option.value = FusionOption.values[i]; + Navigator.of(context).pop(option.value); + }, + child: Container( + color: Colors.transparent, + child: Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + // Column( + // mainAxisAlignment: MainAxisAlignment.start, + // children: [ + SizedBox( + width: 20, + height: 20, + child: Radio( + activeColor: Theme.of(context) + .extension()! + .radioButtonIconEnabled, + value: FusionOption.values[i], + groupValue: option.value, + onChanged: (_) { + option.value = FusionOption.values[i]; + Navigator.of(context).pop(option.value); + }, + ), + ), + // ], + // ), + const SizedBox( + width: 12, + ), + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + FusionOption.values[i].name.capitalize(), + style: STextStyles.titleBold12(context), + textAlign: TextAlign.left, + ), + const SizedBox( + height: 2, + ), + Text( + option.value == FusionOption.continuous + ? "Keep fusing until manually stopped" + : "Stop after a set number of fusions", + style: STextStyles.itemSubtitle12(context) + .copyWith( + color: Theme.of(context) + .extension()! + .textDark3, + ), + textAlign: TextAlign.left, + ), + ], + ), + ], + ), + ), + ), + const SizedBox( + height: 16, + ), + ], + ), + const SizedBox( + height: 16, + ), + ], + ), + ], + ), + ), + ), + ); + } +} diff --git a/pubspec.lock b/pubspec.lock index ed5f1543a..49125d53d 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -621,6 +621,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.0.0+1" + flutter_hooks: + dependency: "direct main" + description: + name: flutter_hooks + sha256: "7c8db779c2d1010aa7f9ea3fbefe8f86524fcb87b69e8b0af31e1a4b55422dec" + url: "https://pub.dev" + source: hosted + version: "0.20.3" flutter_launcher_icons: dependency: "direct dev" description: diff --git a/pubspec.yaml b/pubspec.yaml index d8e1f877d..95480ff05 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -155,6 +155,7 @@ dependencies: socks5_proxy: ^1.0.3+dev.3 coinlib_flutter: ^1.0.0 convert: ^3.1.1 + flutter_hooks: ^0.20.3 dev_dependencies: flutter_test: