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_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<CashFusionView> {
@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<CashFusionView> {
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<StackColors>()!.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<StackColors>()!
// .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<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),
// ),
// ],
// ),
// ),
// ],
// ),
// ),
RoundedContainer(
onPressed: () async {
final option =
await showModalBottomSheet<FusionOption?>(
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<StackColors>()!
.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<StackColors>()!
.textSubtitle1,
),
],
),
),
),
const SizedBox(
height: 16,
),
const Spacer(),
PrimaryButton(
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"
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:

View file

@ -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: