add fusion rounds selection sheet

This commit is contained in:
julian 2023-10-16 12:00:35 -06:00
parent 006c0a19f3
commit e99c32ea00
4 changed files with 228 additions and 135 deletions

View file

@ -9,8 +9,10 @@
*/ */
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_native_splash/cli_commands.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:flutter_svg/svg.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/providers/global/wallets_provider.dart';
import 'package:stackwallet/services/mixins/fusion_wallet_interface.dart'; import 'package:stackwallet/services/mixins/fusion_wallet_interface.dart';
import 'package:stackwallet/themes/stack_colors.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/background.dart';
import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart';
import 'package:stackwallet/widgets/desktop/primary_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'; import 'package:stackwallet/widgets/rounded_white_container.dart';
class CashFusionView extends ConsumerStatefulWidget { class CashFusionView extends ConsumerStatefulWidget {
@ -36,15 +39,7 @@ class CashFusionView extends ConsumerStatefulWidget {
} }
class _CashFusionViewState extends ConsumerState<CashFusionView> { class _CashFusionViewState extends ConsumerState<CashFusionView> {
@override FusionOption _option = FusionOption.continuous;
void initState() {
super.initState();
}
@override
void dispose() {
super.dispose();
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
@ -145,135 +140,57 @@ class _CashFusionViewState extends ConsumerState<CashFusionView> {
const SizedBox( const SizedBox(
height: 12, height: 12,
), ),
TextField(), // TODO replace placholder textfield with button for bottom sheet RoundedContainer(
const SizedBox( onPressed: () async {
height: 16, final option =
), await showModalBottomSheet<FusionOption?>(
// Row( backgroundColor: Colors.transparent,
// mainAxisAlignment: MainAxisAlignment.spaceBetween, context: context,
// children: [ shape: const RoundedRectangleBorder(
// Text( borderRadius: BorderRadius.vertical(
// "Tor status", top: Radius.circular(20),
// textAlign: TextAlign.left, ),
// style: isDesktop ),
// ? STextStyles.desktopTextExtraExtraSmall(context) builder: (_) {
// : STextStyles.smallMed12(context), return FusionRoundCountSelectSheet(
// ), currentOption: _option,
// CustomTextButton( );
// text: ref.watch(prefsChangeNotifierProvider },
// .select((value) => value.useTor)) );
// ? "Disconnect" if (option != null) {
// : "Connect", setState(() {
// onTap: onTorTapped, _option = option;
// ), });
// ], }
// ), },
// const SizedBox( color: Theme.of(context)
// height: 12, .extension<StackColors>()!
// ),RoundedWhiteContainer( .textFieldActiveBG,
// borderColor: isDesktop child: Padding(
// ? Theme.of(context).extension<StackColors>()!.background padding: const EdgeInsets.symmetric(vertical: 8),
// : null, child: Row(
// padding: mainAxisAlignment:
// isDesktop ? const EdgeInsets.all(16) : const EdgeInsets.all(12), MainAxisAlignment.spaceBetween,
// child: Row( children: [
// children: [ Text(
// if (ref.watch(prefsChangeNotifierProvider _option.name.capitalize(),
// .select((value) => value.useTor))) style: STextStyles.w500_12(context),
// Container( ),
// width: _iconSize, SvgPicture.asset(
// height: _iconSize, Assets.svg.chevronDown,
// decoration: BoxDecoration( width: 12,
// color: Theme.of(context) color: Theme.of(context)
// .extension<StackColors>()! .extension<StackColors>()!
// .accentColorGreen .textSubtitle1,
// .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<StackColors>()!
// .accentColorGreen,
// ),
// ),
// ),
// if (!ref.watch(prefsChangeNotifierProvider
// .select((value) => value.useTor)))
// Container(
// width: _iconSize,
// height: _iconSize,
// decoration: BoxDecoration(
// color: Theme.of(context)
// .extension<StackColors>()!
// .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<StackColors>()!
// .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<StackColors>()!
// .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),
// ),
// ],
// ),
// ),
// ],
// ),
// ),
const SizedBox( const SizedBox(
height: 16, height: 16,
), ),
const Spacer(), const Spacer(),
PrimaryButton( PrimaryButton(
label: "Start", label: "Start",

View file

@ -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<StackColors>()!.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<StackColors>()!
.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<StackColors>()!
.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<StackColors>()!
.textDark3,
),
textAlign: TextAlign.left,
),
],
),
],
),
),
),
const SizedBox(
height: 16,
),
],
),
const SizedBox(
height: 16,
),
],
),
],
),
),
),
);
}
}

View file

@ -621,6 +621,14 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "2.0.0+1" 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: flutter_launcher_icons:
dependency: "direct dev" dependency: "direct dev"
description: description:

View file

@ -155,6 +155,7 @@ dependencies:
socks5_proxy: ^1.0.3+dev.3 socks5_proxy: ^1.0.3+dev.3
coinlib_flutter: ^1.0.0 coinlib_flutter: ^1.0.0
convert: ^3.1.1 convert: ^3.1.1
flutter_hooks: ^0.20.3
dev_dependencies: dev_dependencies:
flutter_test: flutter_test: