mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2024-11-17 09:47:37 +00:00
WIP desktop 'more features' and coin control
This commit is contained in:
parent
87c15c2c39
commit
d0be86f4ba
8 changed files with 554 additions and 295 deletions
|
@ -6,6 +6,7 @@ import 'package:cw_core/node.dart';
|
||||||
import 'package:cw_core/unspent_coins_info.dart';
|
import 'package:cw_core/unspent_coins_info.dart';
|
||||||
import 'package:cw_core/wallet_info.dart';
|
import 'package:cw_core/wallet_info.dart';
|
||||||
import 'package:cw_core/wallet_type.dart';
|
import 'package:cw_core/wallet_type.dart';
|
||||||
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:flutter_libmonero/monero/monero.dart';
|
import 'package:flutter_libmonero/monero/monero.dart';
|
||||||
|
@ -91,7 +92,7 @@ void main() async {
|
||||||
setWindowMaxSize(Size.infinite);
|
setWindowMaxSize(Size.infinite);
|
||||||
|
|
||||||
final screenHeight = screen?.frame.height;
|
final screenHeight = screen?.frame.height;
|
||||||
if (screenHeight != null) {
|
if (screenHeight != null && !kDebugMode) {
|
||||||
// starting to height be 3/4 screen height or 900, whichever is smaller
|
// starting to height be 3/4 screen height or 900, whichever is smaller
|
||||||
final height = min<double>(screenHeight * 0.75, 900);
|
final height = min<double>(screenHeight * 0.75, 900);
|
||||||
setWindowFrame(
|
setWindowFrame(
|
||||||
|
|
|
@ -1,47 +1,32 @@
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
|
||||||
import 'package:decimal/decimal.dart';
|
|
||||||
import 'package:event_bus/event_bus.dart';
|
import 'package:event_bus/event_bus.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.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/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/my_stack_view/wallet_view/sub_widgets/delete_wallet_button.dart';
|
import 'package:stackwallet/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/delete_wallet_button.dart';
|
||||||
|
import 'package:stackwallet/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_wallet_features.dart';
|
||||||
import 'package:stackwallet/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_wallet_summary.dart';
|
import 'package:stackwallet/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_wallet_summary.dart';
|
||||||
import 'package:stackwallet/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/my_wallet.dart';
|
import 'package:stackwallet/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/my_wallet.dart';
|
||||||
import 'package:stackwallet/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/network_info_button.dart';
|
import 'package:stackwallet/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/network_info_button.dart';
|
||||||
import 'package:stackwallet/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/recent_desktop_transactions.dart';
|
import 'package:stackwallet/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/recent_desktop_transactions.dart';
|
||||||
import 'package:stackwallet/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/wallet_keys_button.dart';
|
import 'package:stackwallet/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/wallet_keys_button.dart';
|
||||||
import 'package:stackwallet/providers/global/auto_swb_service_provider.dart';
|
import 'package:stackwallet/providers/global/auto_swb_service_provider.dart';
|
||||||
import 'package:stackwallet/providers/global/paynym_api_provider.dart';
|
|
||||||
import 'package:stackwallet/providers/providers.dart';
|
import 'package:stackwallet/providers/providers.dart';
|
||||||
import 'package:stackwallet/providers/ui/transaction_filter_provider.dart';
|
import 'package:stackwallet/providers/ui/transaction_filter_provider.dart';
|
||||||
import 'package:stackwallet/providers/wallet/my_paynym_account_state_provider.dart';
|
|
||||||
import 'package:stackwallet/services/coins/firo/firo_wallet.dart';
|
|
||||||
import 'package:stackwallet/services/event_bus/events/global/wallet_sync_status_changed_event.dart';
|
import 'package:stackwallet/services/event_bus/events/global/wallet_sync_status_changed_event.dart';
|
||||||
import 'package:stackwallet/services/event_bus/global_event_bus.dart';
|
import 'package:stackwallet/services/event_bus/global_event_bus.dart';
|
||||||
import 'package:stackwallet/services/mixins/paynym_wallet_interface.dart';
|
|
||||||
import 'package:stackwallet/utilities/assets.dart';
|
import 'package:stackwallet/utilities/assets.dart';
|
||||||
import 'package:stackwallet/utilities/constants.dart';
|
import 'package:stackwallet/utilities/constants.dart';
|
||||||
import 'package:stackwallet/utilities/enums/backup_frequency_type.dart';
|
import 'package:stackwallet/utilities/enums/backup_frequency_type.dart';
|
||||||
import 'package:stackwallet/utilities/enums/coin_enum.dart';
|
|
||||||
import 'package:stackwallet/utilities/enums/derive_path_type_enum.dart';
|
|
||||||
import 'package:stackwallet/utilities/logger.dart';
|
|
||||||
import 'package:stackwallet/utilities/text_styles.dart';
|
|
||||||
import 'package:stackwallet/utilities/theme/stack_colors.dart';
|
import 'package:stackwallet/utilities/theme/stack_colors.dart';
|
||||||
import 'package:stackwallet/widgets/background.dart';
|
import 'package:stackwallet/widgets/background.dart';
|
||||||
import 'package:stackwallet/widgets/conditional_parent.dart';
|
import 'package:stackwallet/widgets/conditional_parent.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/custom_loading_overlay.dart';
|
import 'package:stackwallet/widgets/custom_loading_overlay.dart';
|
||||||
import 'package:stackwallet/widgets/desktop/desktop_app_bar.dart';
|
import 'package:stackwallet/widgets/desktop/desktop_app_bar.dart';
|
||||||
import 'package:stackwallet/widgets/desktop/desktop_dialog.dart';
|
|
||||||
import 'package:stackwallet/widgets/desktop/desktop_scaffold.dart';
|
import 'package:stackwallet/widgets/desktop/desktop_scaffold.dart';
|
||||||
import 'package:stackwallet/widgets/desktop/primary_button.dart';
|
|
||||||
import 'package:stackwallet/widgets/desktop/secondary_button.dart';
|
|
||||||
import 'package:stackwallet/widgets/hover_text_field.dart';
|
import 'package:stackwallet/widgets/hover_text_field.dart';
|
||||||
import 'package:stackwallet/widgets/loading_indicator.dart';
|
|
||||||
import 'package:stackwallet/widgets/rounded_white_container.dart';
|
import 'package:stackwallet/widgets/rounded_white_container.dart';
|
||||||
|
|
||||||
/// [eventBus] should only be set during testing
|
/// [eventBus] should only be set during testing
|
||||||
|
@ -92,162 +77,6 @@ class _DesktopWalletViewState extends ConsumerState<DesktopWalletView> {
|
||||||
ref.read(managerProvider.notifier).isActiveWallet = false;
|
ref.read(managerProvider.notifier).isActiveWallet = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> attemptAnonymize() async {
|
|
||||||
final managerProvider = ref
|
|
||||||
.read(walletsChangeNotifierProvider)
|
|
||||||
.getManagerProvider(widget.walletId);
|
|
||||||
|
|
||||||
bool shouldPop = false;
|
|
||||||
unawaited(
|
|
||||||
showDialog(
|
|
||||||
context: context,
|
|
||||||
builder: (context) => WillPopScope(
|
|
||||||
child: const CustomLoadingOverlay(
|
|
||||||
message: "Anonymizing balance",
|
|
||||||
eventBus: null,
|
|
||||||
),
|
|
||||||
onWillPop: () async => shouldPop,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
final firoWallet = ref.read(managerProvider).wallet as FiroWallet;
|
|
||||||
|
|
||||||
final publicBalance = await firoWallet.availablePublicBalance();
|
|
||||||
if (publicBalance <= Decimal.zero) {
|
|
||||||
shouldPop = true;
|
|
||||||
if (mounted) {
|
|
||||||
Navigator.of(context, rootNavigator: true).pop();
|
|
||||||
Navigator.of(context).popUntil(
|
|
||||||
ModalRoute.withName(DesktopWalletView.routeName),
|
|
||||||
);
|
|
||||||
unawaited(
|
|
||||||
showFloatingFlushBar(
|
|
||||||
type: FlushBarType.info,
|
|
||||||
message: "No funds available to anonymize!",
|
|
||||||
context: context,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
await firoWallet.anonymizeAllPublicFunds();
|
|
||||||
shouldPop = true;
|
|
||||||
if (mounted) {
|
|
||||||
Navigator.of(context, rootNavigator: true).pop();
|
|
||||||
Navigator.of(context).popUntil(
|
|
||||||
ModalRoute.withName(DesktopWalletView.routeName),
|
|
||||||
);
|
|
||||||
unawaited(
|
|
||||||
showFloatingFlushBar(
|
|
||||||
type: FlushBarType.success,
|
|
||||||
message: "Anonymize transaction submitted",
|
|
||||||
context: context,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
} catch (e) {
|
|
||||||
shouldPop = true;
|
|
||||||
if (mounted) {
|
|
||||||
Navigator.of(context, rootNavigator: true).pop();
|
|
||||||
Navigator.of(context).popUntil(
|
|
||||||
ModalRoute.withName(DesktopWalletView.routeName),
|
|
||||||
);
|
|
||||||
await showDialog<dynamic>(
|
|
||||||
context: context,
|
|
||||||
builder: (_) => DesktopDialog(
|
|
||||||
maxWidth: 400,
|
|
||||||
maxHeight: 300,
|
|
||||||
child: Padding(
|
|
||||||
padding: const EdgeInsets.all(24),
|
|
||||||
child: Column(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
children: [
|
|
||||||
Text(
|
|
||||||
"Anonymize all failed",
|
|
||||||
style: STextStyles.desktopH3(context),
|
|
||||||
),
|
|
||||||
const Spacer(
|
|
||||||
flex: 1,
|
|
||||||
),
|
|
||||||
Text(
|
|
||||||
"Reason: $e",
|
|
||||||
style: STextStyles.desktopTextSmall(context),
|
|
||||||
),
|
|
||||||
const Spacer(
|
|
||||||
flex: 2,
|
|
||||||
),
|
|
||||||
Row(
|
|
||||||
children: [
|
|
||||||
const Spacer(),
|
|
||||||
const SizedBox(
|
|
||||||
width: 16,
|
|
||||||
),
|
|
||||||
Expanded(
|
|
||||||
child: PrimaryButton(
|
|
||||||
label: "Ok",
|
|
||||||
buttonHeight: ButtonHeight.l,
|
|
||||||
onPressed:
|
|
||||||
Navigator.of(context, rootNavigator: true).pop,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
)
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> onPaynymButtonPressed() async {
|
|
||||||
unawaited(
|
|
||||||
showDialog(
|
|
||||||
context: context,
|
|
||||||
builder: (context) => const LoadingIndicator(
|
|
||||||
width: 100,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
final manager =
|
|
||||||
ref.read(walletsChangeNotifierProvider).getManager(widget.walletId);
|
|
||||||
|
|
||||||
final wallet = manager.wallet as PaynymWalletInterface;
|
|
||||||
|
|
||||||
final code =
|
|
||||||
await wallet.getPaymentCode(DerivePathTypeExt.primaryFor(manager.coin));
|
|
||||||
|
|
||||||
final account = await ref.read(paynymAPIProvider).nym(code.toString());
|
|
||||||
|
|
||||||
Logging.instance.log(
|
|
||||||
"my nym account: $account",
|
|
||||||
level: LogLevel.Info,
|
|
||||||
);
|
|
||||||
|
|
||||||
if (mounted) {
|
|
||||||
Navigator.of(context, rootNavigator: true).pop();
|
|
||||||
|
|
||||||
// check if account exists and for matching code to see if claimed
|
|
||||||
if (account.value != null && account.value!.codes.first.claimed) {
|
|
||||||
ref.read(myPaynymAccountStateProvider.state).state = account.value!;
|
|
||||||
|
|
||||||
await Navigator.of(context).pushNamed(
|
|
||||||
PaynymHomeView.routeName,
|
|
||||||
arguments: widget.walletId,
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
await Navigator.of(context).pushNamed(
|
|
||||||
PaynymClaimView.routeName,
|
|
||||||
arguments: widget.walletId,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
controller = TextEditingController();
|
controller = TextEditingController();
|
||||||
|
@ -418,115 +247,9 @@ class _DesktopWalletViewState extends ConsumerState<DesktopWalletView> {
|
||||||
: WalletSyncStatus.synced,
|
: WalletSyncStatus.synced,
|
||||||
),
|
),
|
||||||
const Spacer(),
|
const Spacer(),
|
||||||
if (coin == Coin.firo) const SizedBox(width: 10),
|
DesktopWalletFeatures(
|
||||||
if (coin == Coin.firo)
|
walletId: widget.walletId,
|
||||||
SecondaryButton(
|
|
||||||
width: 180,
|
|
||||||
buttonHeight: ButtonHeight.l,
|
|
||||||
label: "Anonymize funds",
|
|
||||||
onPressed: () async {
|
|
||||||
await showDialog<void>(
|
|
||||||
context: context,
|
|
||||||
barrierDismissible: false,
|
|
||||||
builder: (context) => DesktopDialog(
|
|
||||||
maxWidth: 500,
|
|
||||||
maxHeight: 210,
|
|
||||||
child: Padding(
|
|
||||||
padding: const EdgeInsets.symmetric(
|
|
||||||
horizontal: 32, vertical: 20),
|
|
||||||
child: Column(
|
|
||||||
children: [
|
|
||||||
Text(
|
|
||||||
"Attention!",
|
|
||||||
style: STextStyles.desktopH2(context),
|
|
||||||
),
|
),
|
||||||
const SizedBox(height: 16),
|
|
||||||
Text(
|
|
||||||
"You're about to anonymize all of your public funds.",
|
|
||||||
style:
|
|
||||||
STextStyles.desktopTextSmall(context),
|
|
||||||
),
|
|
||||||
const SizedBox(height: 32),
|
|
||||||
Row(
|
|
||||||
mainAxisAlignment:
|
|
||||||
MainAxisAlignment.center,
|
|
||||||
children: [
|
|
||||||
SecondaryButton(
|
|
||||||
width: 200,
|
|
||||||
buttonHeight: ButtonHeight.l,
|
|
||||||
label: "Cancel",
|
|
||||||
onPressed: () {
|
|
||||||
Navigator.of(context).pop();
|
|
||||||
},
|
|
||||||
),
|
|
||||||
const SizedBox(width: 20),
|
|
||||||
PrimaryButton(
|
|
||||||
width: 200,
|
|
||||||
buttonHeight: ButtonHeight.l,
|
|
||||||
label: "Continue",
|
|
||||||
onPressed: () {
|
|
||||||
Navigator.of(context).pop();
|
|
||||||
|
|
||||||
unawaited(attemptAnonymize());
|
|
||||||
},
|
|
||||||
)
|
|
||||||
],
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
if (ref.watch(walletsChangeNotifierProvider.select(
|
|
||||||
(value) => value
|
|
||||||
.getManager(widget.walletId)
|
|
||||||
.hasPaynymSupport)))
|
|
||||||
SecondaryButton(
|
|
||||||
label: "PayNym",
|
|
||||||
width: 160,
|
|
||||||
buttonHeight: ButtonHeight.l,
|
|
||||||
icon: SvgPicture.asset(
|
|
||||||
Assets.svg.user,
|
|
||||||
height: 20,
|
|
||||||
width: 20,
|
|
||||||
color: Theme.of(context)
|
|
||||||
.extension<StackColors>()!
|
|
||||||
.buttonTextSecondary,
|
|
||||||
),
|
|
||||||
onPressed: onPaynymButtonPressed,
|
|
||||||
),
|
|
||||||
// if (coin == Coin.firo) const SizedBox(width: 16),
|
|
||||||
// SecondaryButton(
|
|
||||||
// width: 180,
|
|
||||||
// buttonHeight: ButtonHeight.l,
|
|
||||||
// onPressed: () {
|
|
||||||
// _onExchangePressed(context);
|
|
||||||
// },
|
|
||||||
// label: "Swap",
|
|
||||||
// icon: Container(
|
|
||||||
// width: 24,
|
|
||||||
// height: 24,
|
|
||||||
// decoration: BoxDecoration(
|
|
||||||
// borderRadius: BorderRadius.circular(24),
|
|
||||||
// color: Theme.of(context)
|
|
||||||
// .extension<StackColors>()!
|
|
||||||
// .buttonBackPrimary
|
|
||||||
// .withOpacity(0.2),
|
|
||||||
// ),
|
|
||||||
// child: Center(
|
|
||||||
// child: SvgPicture.asset(
|
|
||||||
// Assets.svg.arrowRotate2,
|
|
||||||
// width: 14,
|
|
||||||
// height: 14,
|
|
||||||
// color: Theme.of(context)
|
|
||||||
// .extension<StackColors>()!
|
|
||||||
// .buttonTextSecondary,
|
|
||||||
// ),
|
|
||||||
// ),
|
|
||||||
// ),
|
|
||||||
// ),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
|
@ -0,0 +1,158 @@
|
||||||
|
import 'dart:async';
|
||||||
|
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
|
import 'package:flutter_svg/svg.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/my_stack_view/wallet_view/sub_widgets/more_features/more_features_dialog.dart';
|
||||||
|
import 'package:stackwallet/providers/global/paynym_api_provider.dart';
|
||||||
|
import 'package:stackwallet/providers/global/wallets_provider.dart';
|
||||||
|
import 'package:stackwallet/providers/wallet/my_paynym_account_state_provider.dart';
|
||||||
|
import 'package:stackwallet/services/mixins/paynym_wallet_interface.dart';
|
||||||
|
import 'package:stackwallet/utilities/assets.dart';
|
||||||
|
import 'package:stackwallet/utilities/constants.dart';
|
||||||
|
import 'package:stackwallet/utilities/enums/coin_enum.dart';
|
||||||
|
import 'package:stackwallet/utilities/enums/derive_path_type_enum.dart';
|
||||||
|
import 'package:stackwallet/utilities/logger.dart';
|
||||||
|
import 'package:stackwallet/utilities/theme/stack_colors.dart';
|
||||||
|
import 'package:stackwallet/widgets/desktop/secondary_button.dart';
|
||||||
|
import 'package:stackwallet/widgets/loading_indicator.dart';
|
||||||
|
|
||||||
|
class DesktopWalletFeatures extends ConsumerWidget {
|
||||||
|
const DesktopWalletFeatures({
|
||||||
|
Key? key,
|
||||||
|
required this.walletId,
|
||||||
|
}) : super(key: key);
|
||||||
|
|
||||||
|
final String walletId;
|
||||||
|
|
||||||
|
Future<void> onPaynymButtonPressed(
|
||||||
|
BuildContext context, WidgetRef ref) async {
|
||||||
|
unawaited(
|
||||||
|
showDialog(
|
||||||
|
context: context,
|
||||||
|
builder: (context) => const LoadingIndicator(
|
||||||
|
width: 100,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
final manager =
|
||||||
|
ref.read(walletsChangeNotifierProvider).getManager(walletId);
|
||||||
|
|
||||||
|
final wallet = manager.wallet as PaynymWalletInterface;
|
||||||
|
|
||||||
|
final code =
|
||||||
|
await wallet.getPaymentCode(DerivePathTypeExt.primaryFor(manager.coin));
|
||||||
|
|
||||||
|
final account = await ref.read(paynymAPIProvider).nym(code.toString());
|
||||||
|
|
||||||
|
Logging.instance.log(
|
||||||
|
"my nym account: $account",
|
||||||
|
level: LogLevel.Info,
|
||||||
|
);
|
||||||
|
|
||||||
|
if (context.mounted) {
|
||||||
|
Navigator.of(context, rootNavigator: true).pop();
|
||||||
|
|
||||||
|
// check if account exists and for matching code to see if claimed
|
||||||
|
if (account.value != null && account.value!.codes.first.claimed) {
|
||||||
|
ref.read(myPaynymAccountStateProvider.state).state = account.value!;
|
||||||
|
|
||||||
|
await Navigator.of(context).pushNamed(
|
||||||
|
PaynymHomeView.routeName,
|
||||||
|
arguments: walletId,
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
await Navigator.of(context).pushNamed(
|
||||||
|
PaynymClaimView.routeName,
|
||||||
|
arguments: walletId,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _onMorePressed(BuildContext context) async {
|
||||||
|
await showDialog<void>(
|
||||||
|
context: context,
|
||||||
|
builder: (context) => MoreFeaturesDialog(walletId: walletId));
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context, WidgetRef ref) {
|
||||||
|
final manager = ref.watch(
|
||||||
|
walletsChangeNotifierProvider.select(
|
||||||
|
(value) => value.getManager(walletId),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
final showMore = manager.hasPaynymSupport ||
|
||||||
|
manager.hasCoinControlSupport ||
|
||||||
|
manager.coin == Coin.firo ||
|
||||||
|
manager.coin == Coin.firoTestNet ||
|
||||||
|
manager.hasWhirlpoolSupport;
|
||||||
|
|
||||||
|
return Row(
|
||||||
|
children: [
|
||||||
|
if (Constants.enableExchange)
|
||||||
|
SecondaryButton(
|
||||||
|
label: "Swap",
|
||||||
|
width: 160,
|
||||||
|
buttonHeight: ButtonHeight.l,
|
||||||
|
icon: SvgPicture.asset(
|
||||||
|
Assets.svg.arrowRotate,
|
||||||
|
height: 20,
|
||||||
|
width: 20,
|
||||||
|
color: Theme.of(context)
|
||||||
|
.extension<StackColors>()!
|
||||||
|
.buttonTextSecondary,
|
||||||
|
),
|
||||||
|
onPressed: () => onPaynymButtonPressed(context, ref),
|
||||||
|
),
|
||||||
|
if (Constants.enableExchange)
|
||||||
|
const SizedBox(
|
||||||
|
width: 16,
|
||||||
|
),
|
||||||
|
if (Constants.enableExchange)
|
||||||
|
SecondaryButton(
|
||||||
|
label: "Buy",
|
||||||
|
width: 160,
|
||||||
|
buttonHeight: ButtonHeight.l,
|
||||||
|
icon: SvgPicture.asset(
|
||||||
|
Assets.svg.buy(context),
|
||||||
|
height: 20,
|
||||||
|
width: 20,
|
||||||
|
color: Theme.of(context)
|
||||||
|
.extension<StackColors>()!
|
||||||
|
.buttonTextSecondary,
|
||||||
|
),
|
||||||
|
onPressed: () => onPaynymButtonPressed(context, ref),
|
||||||
|
),
|
||||||
|
if (showMore)
|
||||||
|
const SizedBox(
|
||||||
|
width: 16,
|
||||||
|
),
|
||||||
|
SecondaryButton(
|
||||||
|
label: "More",
|
||||||
|
width: 160,
|
||||||
|
buttonHeight: ButtonHeight.l,
|
||||||
|
icon: SvgPicture.asset(
|
||||||
|
Assets.svg.iconFor(
|
||||||
|
coin: ref.watch(
|
||||||
|
walletsChangeNotifierProvider.select(
|
||||||
|
(value) => value.getManager(walletId).coin,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
height: 20,
|
||||||
|
width: 20,
|
||||||
|
color:
|
||||||
|
Theme.of(context).extension<StackColors>()!.buttonTextSecondary,
|
||||||
|
),
|
||||||
|
onPressed: () => _onMorePressed(context),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,340 @@
|
||||||
|
import 'dart:async';
|
||||||
|
|
||||||
|
import 'package:decimal/decimal.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
|
import 'package:flutter_svg/flutter_svg.dart';
|
||||||
|
import 'package:stackwallet/notifications/show_flush_bar.dart';
|
||||||
|
import 'package:stackwallet/pages_desktop_specific/my_stack_view/wallet_view/desktop_wallet_view.dart';
|
||||||
|
import 'package:stackwallet/providers/global/wallets_provider.dart';
|
||||||
|
import 'package:stackwallet/services/coins/firo/firo_wallet.dart';
|
||||||
|
import 'package:stackwallet/utilities/assets.dart';
|
||||||
|
import 'package:stackwallet/utilities/enums/coin_enum.dart';
|
||||||
|
import 'package:stackwallet/utilities/text_styles.dart';
|
||||||
|
import 'package:stackwallet/utilities/theme/stack_colors.dart';
|
||||||
|
import 'package:stackwallet/widgets/custom_loading_overlay.dart';
|
||||||
|
import 'package:stackwallet/widgets/desktop/desktop_dialog.dart';
|
||||||
|
import 'package:stackwallet/widgets/desktop/desktop_dialog_close_button.dart';
|
||||||
|
import 'package:stackwallet/widgets/desktop/primary_button.dart';
|
||||||
|
import 'package:stackwallet/widgets/desktop/secondary_button.dart';
|
||||||
|
import 'package:stackwallet/widgets/rounded_container.dart';
|
||||||
|
|
||||||
|
class MoreFeaturesDialog extends ConsumerWidget {
|
||||||
|
const MoreFeaturesDialog({
|
||||||
|
Key? key,
|
||||||
|
required this.walletId,
|
||||||
|
}) : super(key: key);
|
||||||
|
|
||||||
|
final String walletId;
|
||||||
|
|
||||||
|
Future<void> _onAnonymizeAllPressed(
|
||||||
|
BuildContext context, WidgetRef ref,) async {
|
||||||
|
Navigator.of(context, rootNavigator: true).pop();
|
||||||
|
await showDialog<void>(
|
||||||
|
context: context,
|
||||||
|
barrierDismissible: false,
|
||||||
|
builder: (context) => DesktopDialog(
|
||||||
|
maxWidth: 500,
|
||||||
|
maxHeight: 210,
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 32, vertical: 20),
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
"Attention!",
|
||||||
|
style: STextStyles.desktopH2(context),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 16),
|
||||||
|
Text(
|
||||||
|
"You're about to anonymize all of your public funds.",
|
||||||
|
style: STextStyles.desktopTextSmall(context),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 32),
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
SecondaryButton(
|
||||||
|
width: 200,
|
||||||
|
buttonHeight: ButtonHeight.l,
|
||||||
|
label: "Cancel",
|
||||||
|
onPressed: () {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
},
|
||||||
|
),
|
||||||
|
const SizedBox(width: 20),
|
||||||
|
PrimaryButton(
|
||||||
|
width: 200,
|
||||||
|
buttonHeight: ButtonHeight.l,
|
||||||
|
label: "Continue",
|
||||||
|
onPressed: () {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
|
||||||
|
unawaited(
|
||||||
|
_attemptAnonymize(context, ref),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _attemptAnonymize(BuildContext context, WidgetRef ref) async {
|
||||||
|
final managerProvider =
|
||||||
|
ref.read(walletsChangeNotifierProvider).getManagerProvider(walletId);
|
||||||
|
|
||||||
|
bool shouldPop = false;
|
||||||
|
unawaited(
|
||||||
|
showDialog(
|
||||||
|
context: context,
|
||||||
|
builder: (context) => WillPopScope(
|
||||||
|
child: const CustomLoadingOverlay(
|
||||||
|
message: "Anonymizing balance",
|
||||||
|
eventBus: null,
|
||||||
|
),
|
||||||
|
onWillPop: () async => shouldPop,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
final firoWallet = ref.read(managerProvider).wallet as FiroWallet;
|
||||||
|
|
||||||
|
final publicBalance = firoWallet.availablePublicBalance();
|
||||||
|
if (publicBalance <= Decimal.zero) {
|
||||||
|
shouldPop = true;
|
||||||
|
if (context.mounted) {
|
||||||
|
Navigator.of(context, rootNavigator: true).pop();
|
||||||
|
Navigator.of(context).popUntil(
|
||||||
|
ModalRoute.withName(DesktopWalletView.routeName),
|
||||||
|
);
|
||||||
|
unawaited(
|
||||||
|
showFloatingFlushBar(
|
||||||
|
type: FlushBarType.info,
|
||||||
|
message: "No funds available to anonymize!",
|
||||||
|
context: context,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
await firoWallet.anonymizeAllPublicFunds();
|
||||||
|
shouldPop = true;
|
||||||
|
if (context.mounted) {
|
||||||
|
Navigator.of(context, rootNavigator: true).pop();
|
||||||
|
Navigator.of(context).popUntil(
|
||||||
|
ModalRoute.withName(DesktopWalletView.routeName),
|
||||||
|
);
|
||||||
|
unawaited(
|
||||||
|
showFloatingFlushBar(
|
||||||
|
type: FlushBarType.success,
|
||||||
|
message: "Anonymize transaction submitted",
|
||||||
|
context: context,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
shouldPop = true;
|
||||||
|
if (context.mounted) {
|
||||||
|
Navigator.of(context, rootNavigator: true).pop();
|
||||||
|
Navigator.of(context).popUntil(
|
||||||
|
ModalRoute.withName(DesktopWalletView.routeName),
|
||||||
|
);
|
||||||
|
await showDialog<dynamic>(
|
||||||
|
context: context,
|
||||||
|
builder: (_) => DesktopDialog(
|
||||||
|
maxWidth: 400,
|
||||||
|
maxHeight: 300,
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.all(24),
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
"Anonymize all failed",
|
||||||
|
style: STextStyles.desktopH3(context),
|
||||||
|
),
|
||||||
|
const Spacer(
|
||||||
|
flex: 1,
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
"Reason: $e",
|
||||||
|
style: STextStyles.desktopTextSmall(context),
|
||||||
|
),
|
||||||
|
const Spacer(
|
||||||
|
flex: 2,
|
||||||
|
),
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
const Spacer(),
|
||||||
|
const SizedBox(
|
||||||
|
width: 16,
|
||||||
|
),
|
||||||
|
Expanded(
|
||||||
|
child: PrimaryButton(
|
||||||
|
label: "Ok",
|
||||||
|
buttonHeight: ButtonHeight.l,
|
||||||
|
onPressed:
|
||||||
|
Navigator.of(context, rootNavigator: true).pop,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void _onWhirlpoolPressed(
|
||||||
|
BuildContext context, WidgetRef ref,) {
|
||||||
|
Navigator.of(context, rootNavigator: true).pop();}
|
||||||
|
void _onCoinControlPressed(
|
||||||
|
BuildContext context, WidgetRef ref,) {
|
||||||
|
Navigator.of(context, rootNavigator: true).pop();}
|
||||||
|
void _onPaynymPressed(
|
||||||
|
BuildContext context, WidgetRef ref,) {
|
||||||
|
Navigator.of(context, rootNavigator: true).pop();}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context, WidgetRef ref) {
|
||||||
|
final manager = ref.watch(
|
||||||
|
walletsChangeNotifierProvider.select(
|
||||||
|
(value) => value.getManager(walletId),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
return DesktopDialog(
|
||||||
|
child: Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.only(
|
||||||
|
left: 32,
|
||||||
|
),
|
||||||
|
child: Text(
|
||||||
|
"More features",
|
||||||
|
style: STextStyles.desktopH3(context),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const DesktopDialogCloseButton(),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
if (manager.coin == Coin.firo || manager.coin == Coin.firoTestNet)
|
||||||
|
_MoreFeaturesItem(
|
||||||
|
label: "Anonymize funds",
|
||||||
|
detail: "Anonymize funds",
|
||||||
|
iconAsset: Assets.svg.anonymize,
|
||||||
|
onPressed: () => _onAnonymizeAllPressed(context, ref),
|
||||||
|
),
|
||||||
|
if (manager.hasWhirlpoolSupport)
|
||||||
|
_MoreFeaturesItem(
|
||||||
|
label: "Whirlpool",
|
||||||
|
detail: "Powerful Bitcoin privacy enhancer",
|
||||||
|
iconAsset: Assets.svg.whirlPool,
|
||||||
|
onPressed: () =>_onWhirlpoolPressed(context, ref),
|
||||||
|
),
|
||||||
|
if (manager.hasCoinControlSupport)
|
||||||
|
_MoreFeaturesItem(
|
||||||
|
label: "Coin control",
|
||||||
|
detail: "Control, freeze, and utilize outputs at your discretion",
|
||||||
|
iconAsset: Assets.svg.coinControl.gamePad,
|
||||||
|
onPressed: () =>_onCoinControlPressed(context, ref),
|
||||||
|
),
|
||||||
|
if (manager.hasPaynymSupport)
|
||||||
|
_MoreFeaturesItem(
|
||||||
|
label: "PayNym",
|
||||||
|
detail: "Increased address privacy using BIP47",
|
||||||
|
iconAsset: Assets.svg.robotHead,
|
||||||
|
onPressed: () => _onPaynymPressed(context, ref),
|
||||||
|
),
|
||||||
|
const SizedBox(
|
||||||
|
height: 28,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class _MoreFeaturesItem extends StatelessWidget {
|
||||||
|
const _MoreFeaturesItem({
|
||||||
|
Key? key,
|
||||||
|
required this.label,
|
||||||
|
required this.detail,
|
||||||
|
required this.iconAsset,
|
||||||
|
this.onPressed,
|
||||||
|
}) : super(key: key);
|
||||||
|
|
||||||
|
static const double iconSizeBG = 46;
|
||||||
|
static const double iconSize = 26;
|
||||||
|
|
||||||
|
final String label;
|
||||||
|
final String detail;
|
||||||
|
final String iconAsset;
|
||||||
|
final VoidCallback? onPressed;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(
|
||||||
|
vertical: 6,
|
||||||
|
horizontal: 32,
|
||||||
|
),
|
||||||
|
child: RoundedContainer(
|
||||||
|
color: Colors.transparent,
|
||||||
|
borderColor:
|
||||||
|
Theme.of(context).extension<StackColors>()!.textFieldDefaultBG,
|
||||||
|
onPressed: onPressed,
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
RoundedContainer(
|
||||||
|
padding: const EdgeInsets.all(0),
|
||||||
|
color:
|
||||||
|
Theme.of(context).extension<StackColors>()!.settingsIconBack,
|
||||||
|
width: iconSizeBG,
|
||||||
|
height: iconSizeBG,
|
||||||
|
radiusMultiplier: iconSizeBG,
|
||||||
|
child: Center(
|
||||||
|
child: SvgPicture.asset(
|
||||||
|
iconAsset,
|
||||||
|
width: iconSize,
|
||||||
|
height: iconSize,
|
||||||
|
color: Theme.of(context)
|
||||||
|
.extension<StackColors>()!
|
||||||
|
.settingsIconIcon,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(
|
||||||
|
width: 16,
|
||||||
|
),
|
||||||
|
Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
label,
|
||||||
|
style: STextStyles.w600_20(context),
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
detail,
|
||||||
|
style: STextStyles.desktopTextExtraExtraSmall(context),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
|
@ -232,6 +232,8 @@ class Manager with ChangeNotifier {
|
||||||
|
|
||||||
bool get hasCoinControlSupport => _currentWallet is CoinControlInterface;
|
bool get hasCoinControlSupport => _currentWallet is CoinControlInterface;
|
||||||
|
|
||||||
|
bool get hasWhirlpoolSupport => false;
|
||||||
|
|
||||||
int get rescanOnOpenVersion =>
|
int get rescanOnOpenVersion =>
|
||||||
DB.instance.get<dynamic>(
|
DB.instance.get<dynamic>(
|
||||||
boxName: DB.boxNameDBInfo,
|
boxName: DB.boxNameDBInfo,
|
||||||
|
|
|
@ -1255,6 +1255,23 @@ class STextStyles {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static TextStyle w600_20(BuildContext context) {
|
||||||
|
switch (_theme(context).themeType) {
|
||||||
|
case ThemeType.light:
|
||||||
|
case ThemeType.oceanBreeze:
|
||||||
|
case ThemeType.dark:
|
||||||
|
case ThemeType.oledBlack:
|
||||||
|
case ThemeType.fruitSorbet:
|
||||||
|
case ThemeType.forest:
|
||||||
|
return GoogleFonts.inter(
|
||||||
|
color: _theme(context).textDark,
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
fontSize: 20,
|
||||||
|
height: 30 / 20,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static TextStyle syncPercent(BuildContext context) {
|
static TextStyle syncPercent(BuildContext context) {
|
||||||
switch (_theme(context).themeType) {
|
switch (_theme(context).themeType) {
|
||||||
case ThemeType.light:
|
case ThemeType.light:
|
||||||
|
|
|
@ -155,6 +155,7 @@ class SecondaryButton extends StatelessWidget {
|
||||||
.getSecondaryDisabledButtonStyle(context),
|
.getSecondaryDisabledButtonStyle(context),
|
||||||
child: Row(
|
child: Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
if (icon != null) icon!,
|
if (icon != null) icon!,
|
||||||
if (icon != null && label != null)
|
if (icon != null && label != null)
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:stackwallet/utilities/constants.dart';
|
import 'package:stackwallet/utilities/constants.dart';
|
||||||
|
import 'package:stackwallet/widgets/conditional_parent.dart';
|
||||||
|
|
||||||
class RoundedContainer extends StatelessWidget {
|
class RoundedContainer extends StatelessWidget {
|
||||||
const RoundedContainer({
|
const RoundedContainer({
|
||||||
|
@ -12,6 +13,7 @@ class RoundedContainer extends StatelessWidget {
|
||||||
this.height,
|
this.height,
|
||||||
this.borderColor,
|
this.borderColor,
|
||||||
this.boxShadow,
|
this.boxShadow,
|
||||||
|
this.onPressed,
|
||||||
}) : super(key: key);
|
}) : super(key: key);
|
||||||
|
|
||||||
final Widget? child;
|
final Widget? child;
|
||||||
|
@ -22,10 +24,24 @@ class RoundedContainer extends StatelessWidget {
|
||||||
final double? height;
|
final double? height;
|
||||||
final Color? borderColor;
|
final Color? borderColor;
|
||||||
final List<BoxShadow>? boxShadow;
|
final List<BoxShadow>? boxShadow;
|
||||||
|
final VoidCallback? onPressed;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Container(
|
return ConditionalParent(
|
||||||
|
condition: onPressed != null,
|
||||||
|
builder: (child) => RawMaterialButton(
|
||||||
|
padding: const EdgeInsets.all(0),
|
||||||
|
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
||||||
|
shape: RoundedRectangleBorder(
|
||||||
|
borderRadius: BorderRadius.circular(
|
||||||
|
Constants.size.circularBorderRadius * radiusMultiplier,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
onPressed: onPressed,
|
||||||
|
child: child,
|
||||||
|
),
|
||||||
|
child: Container(
|
||||||
width: width,
|
width: width,
|
||||||
height: height,
|
height: height,
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
|
@ -40,6 +56,7 @@ class RoundedContainer extends StatelessWidget {
|
||||||
padding: padding,
|
padding: padding,
|
||||||
child: child,
|
child: child,
|
||||||
),
|
),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue