show CashFusion option in wallet More dialog

This commit is contained in:
sneurlax 2023-07-26 17:07:56 -05:00
parent 6e9d8b26d0
commit 4e134664e7
3 changed files with 41 additions and 1 deletions

View file

@ -19,6 +19,7 @@ import 'package:isar/isar.dart';
import 'package:stackwallet/models/isar/exchange_cache/currency.dart';
import 'package:stackwallet/notifications/show_flush_bar.dart';
import 'package:stackwallet/pages/buy_view/buy_in_wallet_view.dart';
import 'package:stackwallet/pages/cashfusion/cashfusion_view.dart';
import 'package:stackwallet/pages/coin_control/coin_control_view.dart';
import 'package:stackwallet/pages/exchange_view/wallet_initiated_exchange_view.dart';
import 'package:stackwallet/pages/home_view/home_view.dart';
@ -79,6 +80,8 @@ import 'package:stackwallet/widgets/wallet_navigation_bar/components/wallet_navi
import 'package:stackwallet/widgets/wallet_navigation_bar/wallet_navigation_bar.dart';
import 'package:tuple/tuple.dart';
import '../../widgets/wallet_navigation_bar/components/icons/fusion_nav_icon.dart';
/// [eventBus] should only be set during testing
class WalletView extends ConsumerStatefulWidget {
const WalletView({
@ -1007,6 +1010,22 @@ class _WalletViewState extends ConsumerState<WalletView> {
}
},
),
if (ref.watch(
walletsChangeNotifierProvider.select(
(value) =>
value.getManager(widget.walletId).hasFusionSupport,
),
))
WalletNavigationBarItemData(
label: "Fusion",
icon: const FusionNavIcon(),
onTap: () {
Navigator.of(context).pushNamed(
CashFusionView.routeName,
arguments: walletId,
);
},
),
],
),
],

View file

@ -18,6 +18,7 @@ import 'package:flutter_svg/svg.dart';
import 'package:stackwallet/notifications/show_flush_bar.dart';
import 'package:stackwallet/pages/paynym/paynym_claim_view.dart';
import 'package:stackwallet/pages/paynym/paynym_home_view.dart';
import 'package:stackwallet/pages_desktop_specific/cashfusion/desktop_cashfusion_view.dart';
import 'package:stackwallet/pages_desktop_specific/coin_control/desktop_coin_control_view.dart';
import 'package:stackwallet/pages_desktop_specific/desktop_menu.dart';
import 'package:stackwallet/pages_desktop_specific/my_stack_view/wallet_view/desktop_wallet_view.dart';
@ -80,6 +81,7 @@ class _DesktopWalletFeaturesState extends ConsumerState<DesktopWalletFeatures> {
onCoinControlPressed: _onCoinControlPressed,
onAnonymizeAllPressed: _onAnonymizeAllPressed,
onWhirlpoolPressed: _onWhirlpoolPressed,
onFusionPressed: _onFusionPressed,
),
);
}
@ -313,6 +315,15 @@ class _DesktopWalletFeaturesState extends ConsumerState<DesktopWalletFeatures> {
}
}
void _onFusionPressed() {
Navigator.of(context, rootNavigator: true).pop();
Navigator.of(context).pushNamed(
DesktopCashFusionView.routeName,
arguments: widget.walletId,
);
}
@override
Widget build(BuildContext context) {
final manager = ref.watch(
@ -330,7 +341,8 @@ class _DesktopWalletFeaturesState extends ConsumerState<DesktopWalletFeatures> {
)) ||
manager.coin == Coin.firo ||
manager.coin == Coin.firoTestNet ||
manager.hasWhirlpoolSupport;
manager.hasWhirlpoolSupport ||
manager.hasFusionSupport;
return Row(
children: [

View file

@ -29,6 +29,7 @@ class MoreFeaturesDialog extends ConsumerStatefulWidget {
required this.onCoinControlPressed,
required this.onAnonymizeAllPressed,
required this.onWhirlpoolPressed,
required this.onFusionPressed,
}) : super(key: key);
final String walletId;
@ -36,6 +37,7 @@ class MoreFeaturesDialog extends ConsumerStatefulWidget {
final VoidCallback? onCoinControlPressed;
final VoidCallback? onAnonymizeAllPressed;
final VoidCallback? onWhirlpoolPressed;
final VoidCallback? onFusionPressed;
@override
ConsumerState<MoreFeaturesDialog> createState() => _MoreFeaturesDialogState();
@ -103,6 +105,13 @@ class _MoreFeaturesDialogState extends ConsumerState<MoreFeaturesDialog> {
iconAsset: Assets.svg.robotHead,
onPressed: () => widget.onPaynymPressed?.call(),
),
if (manager.hasFusionSupport)
_MoreFeaturesItem(
label: "CashFusion",
detail: "Decentralized Bitcoin mixing protocol",
iconAsset: Assets.svg.robotHead,
onPressed: () => widget.onFusionPressed?.call(),
),
const SizedBox(
height: 28,
),