2023-05-26 21:21:16 +00:00
|
|
|
/*
|
|
|
|
* 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 Cypher Stack on 2023-05-26
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2022-09-21 21:59:52 +00:00
|
|
|
import 'dart:async';
|
2023-05-09 23:59:26 +00:00
|
|
|
import 'dart:io';
|
2022-09-21 21:59:52 +00:00
|
|
|
|
2022-08-26 08:11:35 +00:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|
|
|
import 'package:flutter_svg/svg.dart';
|
2024-07-09 14:54:29 +00:00
|
|
|
|
|
|
|
import '../../app_config.dart';
|
2024-05-23 00:37:06 +00:00
|
|
|
import '../../models/exchange/response_objects/trade.dart';
|
|
|
|
import '../../pages_desktop_specific/desktop_exchange/desktop_exchange_view.dart';
|
|
|
|
import '../../providers/providers.dart';
|
|
|
|
import '../../route_generator.dart';
|
|
|
|
import '../../themes/coin_icon_provider.dart';
|
|
|
|
import '../../themes/stack_colors.dart';
|
|
|
|
import '../../themes/theme_providers.dart';
|
|
|
|
import '../../utilities/amount/amount.dart';
|
|
|
|
import '../../utilities/amount/amount_formatter.dart';
|
|
|
|
import '../../utilities/assets.dart';
|
|
|
|
import '../../utilities/constants.dart';
|
|
|
|
import '../../utilities/enums/fee_rate_type_enum.dart';
|
2024-07-22 18:35:06 +00:00
|
|
|
import '../../utilities/logger.dart';
|
2024-05-23 00:37:06 +00:00
|
|
|
import '../../utilities/text_styles.dart';
|
|
|
|
import '../../utilities/util.dart';
|
|
|
|
import '../../wallets/crypto_currency/crypto_currency.dart';
|
|
|
|
import '../../wallets/isar/providers/wallet_info_provider.dart';
|
|
|
|
import '../../wallets/models/tx_data.dart';
|
|
|
|
import '../../wallets/wallet/impl/firo_wallet.dart';
|
2024-10-18 22:55:12 +00:00
|
|
|
import '../../wallets/wallet/intermediate/lib_monero_wallet.dart';
|
2024-05-23 00:37:06 +00:00
|
|
|
import '../../widgets/background.dart';
|
|
|
|
import '../../widgets/conditional_parent.dart';
|
|
|
|
import '../../widgets/custom_buttons/app_bar_icon_button.dart';
|
|
|
|
import '../../widgets/desktop/desktop_dialog.dart';
|
|
|
|
import '../../widgets/desktop/desktop_dialog_close_button.dart';
|
|
|
|
import '../../widgets/expandable.dart';
|
|
|
|
import '../../widgets/rounded_white_container.dart';
|
|
|
|
import '../../widgets/stack_dialog.dart';
|
2024-07-09 14:54:29 +00:00
|
|
|
import '../home_view/home_view.dart';
|
|
|
|
import '../send_view/sub_widgets/building_transaction_dialog.dart';
|
|
|
|
import 'confirm_change_now_send.dart';
|
2022-08-26 08:11:35 +00:00
|
|
|
|
|
|
|
class SendFromView extends ConsumerStatefulWidget {
|
|
|
|
const SendFromView({
|
2024-05-27 23:56:22 +00:00
|
|
|
super.key,
|
2022-08-26 08:11:35 +00:00
|
|
|
required this.coin,
|
|
|
|
required this.trade,
|
|
|
|
required this.amount,
|
|
|
|
required this.address,
|
2022-11-22 17:21:43 +00:00
|
|
|
this.shouldPopRoot = false,
|
2022-11-22 21:32:06 +00:00
|
|
|
this.fromDesktopStep4 = false,
|
2024-05-27 23:56:22 +00:00
|
|
|
});
|
2022-08-26 08:11:35 +00:00
|
|
|
|
|
|
|
static const String routeName = "/sendFrom";
|
|
|
|
|
2024-05-15 21:20:45 +00:00
|
|
|
final CryptoCurrency coin;
|
2023-04-05 22:06:31 +00:00
|
|
|
final Amount amount;
|
2022-08-26 08:11:35 +00:00
|
|
|
final String address;
|
2022-10-03 00:54:35 +00:00
|
|
|
final Trade trade;
|
2022-11-22 17:21:43 +00:00
|
|
|
final bool shouldPopRoot;
|
2022-11-22 21:32:06 +00:00
|
|
|
final bool fromDesktopStep4;
|
2022-08-26 08:11:35 +00:00
|
|
|
|
|
|
|
@override
|
|
|
|
ConsumerState<SendFromView> createState() => _SendFromViewState();
|
|
|
|
}
|
|
|
|
|
|
|
|
class _SendFromViewState extends ConsumerState<SendFromView> {
|
2024-05-15 21:20:45 +00:00
|
|
|
late final CryptoCurrency coin;
|
2023-04-05 22:06:31 +00:00
|
|
|
late final Amount amount;
|
2022-08-26 08:11:35 +00:00
|
|
|
late final String address;
|
2022-10-03 00:54:35 +00:00
|
|
|
late final Trade trade;
|
2022-08-26 08:11:35 +00:00
|
|
|
|
|
|
|
@override
|
|
|
|
void initState() {
|
|
|
|
coin = widget.coin;
|
|
|
|
address = widget.address;
|
|
|
|
amount = widget.amount;
|
|
|
|
trade = widget.trade;
|
|
|
|
super.initState();
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2022-09-30 21:21:10 +00:00
|
|
|
debugPrint("BUILD: $runtimeType");
|
|
|
|
|
2023-10-31 17:15:59 +00:00
|
|
|
final walletIds = ref
|
2023-11-03 19:46:55 +00:00
|
|
|
.watch(pWallets)
|
|
|
|
.wallets
|
|
|
|
.where((e) => e.info.coin == coin)
|
|
|
|
.map((e) => e.walletId)
|
|
|
|
.toList();
|
2022-09-30 21:21:10 +00:00
|
|
|
|
2022-11-22 15:11:18 +00:00
|
|
|
final isDesktop = Util.isDesktop;
|
|
|
|
|
|
|
|
return ConditionalParent(
|
|
|
|
condition: !isDesktop,
|
|
|
|
builder: (child) {
|
2022-11-25 19:24:01 +00:00
|
|
|
return Background(
|
|
|
|
child: Scaffold(
|
|
|
|
backgroundColor:
|
|
|
|
Theme.of(context).extension<StackColors>()!.background,
|
|
|
|
appBar: AppBar(
|
|
|
|
leading: AppBarBackButton(
|
|
|
|
onPressed: () {
|
|
|
|
Navigator.of(context).pop();
|
|
|
|
},
|
|
|
|
),
|
|
|
|
title: Text(
|
|
|
|
"Send from",
|
|
|
|
style: STextStyles.navBarTitle(context),
|
|
|
|
),
|
2022-11-22 15:11:18 +00:00
|
|
|
),
|
2022-11-25 19:24:01 +00:00
|
|
|
body: Padding(
|
|
|
|
padding: const EdgeInsets.all(16),
|
|
|
|
child: child,
|
2022-11-22 15:11:18 +00:00
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
},
|
|
|
|
child: ConditionalParent(
|
|
|
|
condition: isDesktop,
|
|
|
|
builder: (child) => DesktopDialog(
|
|
|
|
maxHeight: double.infinity,
|
|
|
|
child: Column(
|
|
|
|
children: [
|
|
|
|
Row(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
children: [
|
|
|
|
Padding(
|
|
|
|
padding: const EdgeInsets.only(
|
|
|
|
left: 32,
|
|
|
|
),
|
|
|
|
child: Text(
|
2024-07-09 14:54:29 +00:00
|
|
|
"Send from ${AppConfig.prefix}",
|
2022-11-22 15:11:18 +00:00
|
|
|
style: STextStyles.desktopH3(context),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
DesktopDialogCloseButton(
|
|
|
|
onPressedOverride: Navigator.of(
|
|
|
|
context,
|
2022-11-22 17:21:43 +00:00
|
|
|
rootNavigator: widget.shouldPopRoot,
|
2022-11-22 15:11:18 +00:00
|
|
|
).pop,
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
Padding(
|
|
|
|
padding: const EdgeInsets.only(
|
|
|
|
left: 32,
|
|
|
|
right: 32,
|
|
|
|
bottom: 32,
|
|
|
|
),
|
|
|
|
child: child,
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
2022-08-26 08:11:35 +00:00
|
|
|
),
|
2022-09-30 21:21:10 +00:00
|
|
|
child: Column(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
2022-08-26 08:11:35 +00:00
|
|
|
children: [
|
2022-09-30 21:21:10 +00:00
|
|
|
Row(
|
|
|
|
children: [
|
|
|
|
Text(
|
2023-05-29 21:10:55 +00:00
|
|
|
"You need to send ${ref.watch(pAmountFormatter(coin)).format(amount)}",
|
2022-11-22 15:11:18 +00:00
|
|
|
style: isDesktop
|
|
|
|
? STextStyles.desktopTextExtraExtraSmall(context)
|
|
|
|
: STextStyles.itemSubtitle(context),
|
2022-09-30 21:21:10 +00:00
|
|
|
),
|
|
|
|
],
|
2022-08-26 08:11:35 +00:00
|
|
|
),
|
|
|
|
const SizedBox(
|
|
|
|
height: 16,
|
|
|
|
),
|
2022-11-22 15:11:18 +00:00
|
|
|
ConditionalParent(
|
|
|
|
condition: !isDesktop,
|
|
|
|
builder: (child) => Expanded(
|
|
|
|
child: child,
|
|
|
|
),
|
2022-09-30 21:21:10 +00:00
|
|
|
child: ListView.builder(
|
2022-11-22 15:11:18 +00:00
|
|
|
primary: isDesktop ? false : null,
|
|
|
|
shrinkWrap: isDesktop,
|
2022-09-30 21:21:10 +00:00
|
|
|
itemCount: walletIds.length,
|
|
|
|
itemBuilder: (context, index) {
|
|
|
|
return Padding(
|
|
|
|
padding: const EdgeInsets.symmetric(vertical: 4),
|
|
|
|
child: SendFromCard(
|
|
|
|
walletId: walletIds[index],
|
|
|
|
amount: amount,
|
|
|
|
address: address,
|
|
|
|
trade: trade,
|
2022-11-22 21:32:06 +00:00
|
|
|
fromDesktopStep4: widget.fromDesktopStep4,
|
2022-09-30 21:21:10 +00:00
|
|
|
),
|
|
|
|
);
|
|
|
|
},
|
|
|
|
),
|
2022-08-26 08:11:35 +00:00
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class SendFromCard extends ConsumerStatefulWidget {
|
|
|
|
const SendFromCard({
|
2024-05-09 22:12:22 +00:00
|
|
|
super.key,
|
2022-08-26 08:11:35 +00:00
|
|
|
required this.walletId,
|
|
|
|
required this.amount,
|
|
|
|
required this.address,
|
|
|
|
required this.trade,
|
2022-11-22 21:32:06 +00:00
|
|
|
this.fromDesktopStep4 = false,
|
2024-05-09 22:12:22 +00:00
|
|
|
});
|
2022-08-26 08:11:35 +00:00
|
|
|
|
|
|
|
final String walletId;
|
2023-04-05 22:06:31 +00:00
|
|
|
final Amount amount;
|
2022-08-26 08:11:35 +00:00
|
|
|
final String address;
|
2022-10-03 00:54:35 +00:00
|
|
|
final Trade trade;
|
2022-11-22 21:32:06 +00:00
|
|
|
final bool fromDesktopStep4;
|
2022-08-26 08:11:35 +00:00
|
|
|
|
|
|
|
@override
|
|
|
|
ConsumerState<SendFromCard> createState() => _SendFromCardState();
|
|
|
|
}
|
|
|
|
|
|
|
|
class _SendFromCardState extends ConsumerState<SendFromCard> {
|
|
|
|
late final String walletId;
|
2023-04-05 22:06:31 +00:00
|
|
|
late final Amount amount;
|
2022-08-26 08:11:35 +00:00
|
|
|
late final String address;
|
2022-10-03 00:54:35 +00:00
|
|
|
late final Trade trade;
|
2022-08-26 08:11:35 +00:00
|
|
|
|
2023-11-03 19:46:55 +00:00
|
|
|
Future<void> _send({bool? shouldSendPublicFiroFunds}) async {
|
|
|
|
final coin = ref.read(pWalletCoin(walletId));
|
|
|
|
|
2022-11-07 17:46:17 +00:00
|
|
|
try {
|
|
|
|
bool wasCancelled = false;
|
|
|
|
|
2024-05-09 22:12:22 +00:00
|
|
|
final wallet = ref.read(pWallets).getWallet(walletId);
|
|
|
|
|
2022-11-07 17:46:17 +00:00
|
|
|
unawaited(
|
|
|
|
showDialog<dynamic>(
|
|
|
|
context: context,
|
|
|
|
useSafeArea: false,
|
|
|
|
barrierDismissible: false,
|
|
|
|
builder: (context) {
|
2022-11-22 17:21:43 +00:00
|
|
|
return ConditionalParent(
|
|
|
|
condition: Util.isDesktop,
|
|
|
|
builder: (child) => DesktopDialog(
|
|
|
|
maxWidth: 400,
|
|
|
|
maxHeight: double.infinity,
|
|
|
|
child: Padding(
|
|
|
|
padding: const EdgeInsets.all(32),
|
|
|
|
child: child,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
child: BuildingTransactionDialog(
|
2023-11-03 19:46:55 +00:00
|
|
|
coin: coin,
|
2024-05-09 22:12:22 +00:00
|
|
|
isSpark:
|
|
|
|
wallet is FiroWallet && shouldSendPublicFiroFunds != true,
|
2022-11-22 17:21:43 +00:00
|
|
|
onCancel: () {
|
|
|
|
wasCancelled = true;
|
2022-11-07 17:46:17 +00:00
|
|
|
|
2022-11-22 17:21:43 +00:00
|
|
|
Navigator.of(context).pop();
|
|
|
|
},
|
|
|
|
),
|
2022-11-07 17:46:17 +00:00
|
|
|
);
|
|
|
|
},
|
|
|
|
),
|
|
|
|
);
|
|
|
|
|
2024-07-22 18:35:06 +00:00
|
|
|
// Currently CwBasedInterface wallets (xmr/wow) shouldn't even have
|
|
|
|
// access to this screen but this is needed to get past an error that
|
|
|
|
// would occur only to lead to another error which is why xmr/wow wallets
|
|
|
|
// don't have access to this screen currently
|
2024-10-18 22:55:12 +00:00
|
|
|
if (wallet is LibMoneroWallet) {
|
2024-07-22 18:35:06 +00:00
|
|
|
await wallet.init();
|
|
|
|
await wallet.open();
|
|
|
|
}
|
|
|
|
|
2023-03-13 17:49:39 +00:00
|
|
|
final time = Future<dynamic>.delayed(
|
|
|
|
const Duration(
|
2023-03-14 15:43:54 +00:00
|
|
|
milliseconds: 2500,
|
2023-03-13 17:49:39 +00:00
|
|
|
),
|
|
|
|
);
|
|
|
|
|
2023-11-03 19:46:55 +00:00
|
|
|
TxData txData;
|
|
|
|
Future<TxData> txDataFuture;
|
|
|
|
|
2022-11-07 17:46:17 +00:00
|
|
|
// if not firo then do normal send
|
|
|
|
if (shouldSendPublicFiroFunds == null) {
|
2024-05-15 21:20:45 +00:00
|
|
|
final memo = coin is Stellar
|
2023-11-03 19:46:55 +00:00
|
|
|
? trade.payInExtraId.isNotEmpty
|
|
|
|
? trade.payInExtraId
|
|
|
|
: null
|
|
|
|
: null;
|
|
|
|
txDataFuture = wallet.prepareSend(
|
|
|
|
txData: TxData(
|
|
|
|
recipients: [
|
|
|
|
(
|
|
|
|
address: address,
|
2024-01-16 22:34:12 +00:00
|
|
|
amount: amount,
|
|
|
|
isChange: false,
|
2023-11-03 19:46:55 +00:00
|
|
|
),
|
|
|
|
],
|
|
|
|
memo: memo,
|
|
|
|
feeRateType: FeeRateType.average,
|
|
|
|
),
|
2022-11-07 17:46:17 +00:00
|
|
|
);
|
|
|
|
} else {
|
2023-11-03 19:46:55 +00:00
|
|
|
final firoWallet = wallet as FiroWallet;
|
2022-11-07 17:46:17 +00:00
|
|
|
// otherwise do firo send based on balance selected
|
|
|
|
if (shouldSendPublicFiroFunds) {
|
2023-11-03 19:46:55 +00:00
|
|
|
txDataFuture = wallet.prepareSend(
|
|
|
|
txData: TxData(
|
|
|
|
recipients: [
|
|
|
|
(
|
|
|
|
address: address,
|
2024-01-16 22:34:12 +00:00
|
|
|
amount: amount,
|
|
|
|
isChange: false,
|
2023-11-03 19:46:55 +00:00
|
|
|
),
|
|
|
|
],
|
|
|
|
feeRateType: FeeRateType.average,
|
|
|
|
),
|
2022-11-07 17:46:17 +00:00
|
|
|
);
|
2023-11-20 15:15:36 +00:00
|
|
|
} else {
|
2024-01-16 22:34:12 +00:00
|
|
|
txDataFuture = firoWallet.prepareSendSpark(
|
2023-11-20 15:15:36 +00:00
|
|
|
txData: TxData(
|
|
|
|
recipients: [
|
|
|
|
(
|
|
|
|
address: address,
|
2024-01-16 22:34:12 +00:00
|
|
|
amount: amount,
|
|
|
|
isChange: false,
|
2023-11-20 15:15:36 +00:00
|
|
|
),
|
|
|
|
],
|
|
|
|
// feeRateType: FeeRateType.average,
|
|
|
|
),
|
|
|
|
);
|
2022-11-07 17:46:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-03-13 17:49:39 +00:00
|
|
|
final results = await Future.wait([
|
|
|
|
txDataFuture,
|
|
|
|
time,
|
|
|
|
]);
|
|
|
|
|
2023-11-03 19:46:55 +00:00
|
|
|
txData = results.first as TxData;
|
2023-03-13 17:49:39 +00:00
|
|
|
|
2022-11-07 17:46:17 +00:00
|
|
|
if (!wasCancelled) {
|
|
|
|
// pop building dialog
|
|
|
|
|
|
|
|
if (mounted) {
|
2022-11-22 17:21:43 +00:00
|
|
|
Navigator.of(
|
|
|
|
context,
|
|
|
|
rootNavigator: Util.isDesktop,
|
|
|
|
).pop();
|
2022-11-07 17:46:17 +00:00
|
|
|
}
|
|
|
|
|
2023-11-03 19:46:55 +00:00
|
|
|
txData = txData.copyWith(
|
|
|
|
note: "${trade.payInCurrency.toUpperCase()}/"
|
|
|
|
"${trade.payOutCurrency.toUpperCase()} exchange",
|
|
|
|
);
|
2022-11-07 17:46:17 +00:00
|
|
|
|
|
|
|
if (mounted) {
|
|
|
|
await Navigator.of(context).push(
|
|
|
|
RouteGenerator.getRoute(
|
|
|
|
shouldUseMaterialRoute: RouteGenerator.useMaterialPageRoute,
|
|
|
|
builder: (_) => ConfirmChangeNowSendView(
|
2023-11-03 19:46:55 +00:00
|
|
|
txData: txData,
|
2022-11-07 17:46:17 +00:00
|
|
|
walletId: walletId,
|
2022-11-22 17:21:43 +00:00
|
|
|
routeOnSuccessName: Util.isDesktop
|
|
|
|
? DesktopExchangeView.routeName
|
|
|
|
: HomeView.routeName,
|
2022-11-07 17:46:17 +00:00
|
|
|
trade: trade,
|
|
|
|
shouldSendPublicFiroFunds: shouldSendPublicFiroFunds,
|
2022-11-22 21:32:06 +00:00
|
|
|
fromDesktopStep4: widget.fromDesktopStep4,
|
2022-11-07 17:46:17 +00:00
|
|
|
),
|
|
|
|
settings: const RouteSettings(
|
|
|
|
name: ConfirmChangeNowSendView.routeName,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
2024-07-22 18:35:06 +00:00
|
|
|
} catch (e, s) {
|
|
|
|
Logging.instance.log("$e\n$s", level: LogLevel.Error);
|
2024-05-09 22:12:22 +00:00
|
|
|
if (mounted) {
|
|
|
|
// pop building dialog
|
|
|
|
Navigator.of(context).pop();
|
|
|
|
|
|
|
|
await showDialog<dynamic>(
|
|
|
|
context: context,
|
|
|
|
useSafeArea: false,
|
|
|
|
barrierDismissible: true,
|
|
|
|
builder: (context) {
|
|
|
|
return StackDialog(
|
|
|
|
title: "Transaction failed",
|
|
|
|
message: e.toString(),
|
|
|
|
rightButton: TextButton(
|
|
|
|
style: Theme.of(context)
|
|
|
|
.extension<StackColors>()!
|
|
|
|
.getSecondaryEnabledButtonStyle(context),
|
|
|
|
child: Text(
|
|
|
|
"Ok",
|
|
|
|
style: STextStyles.button(context).copyWith(
|
|
|
|
color: Theme.of(context)
|
|
|
|
.extension<StackColors>()!
|
|
|
|
.buttonTextSecondary,
|
|
|
|
),
|
2022-11-07 17:46:17 +00:00
|
|
|
),
|
2024-05-09 22:12:22 +00:00
|
|
|
onPressed: () {
|
|
|
|
Navigator.of(context).pop();
|
|
|
|
},
|
2022-11-07 17:46:17 +00:00
|
|
|
),
|
2024-05-09 22:12:22 +00:00
|
|
|
);
|
|
|
|
},
|
|
|
|
);
|
|
|
|
}
|
2022-11-07 17:46:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-08-26 08:11:35 +00:00
|
|
|
@override
|
|
|
|
void initState() {
|
|
|
|
walletId = widget.walletId;
|
|
|
|
amount = widget.amount;
|
|
|
|
address = widget.address;
|
|
|
|
trade = widget.trade;
|
|
|
|
super.initState();
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2023-11-03 19:46:55 +00:00
|
|
|
final wallet = ref.watch(pWallets).getWallet(walletId);
|
2022-08-26 08:11:35 +00:00
|
|
|
|
|
|
|
final locale = ref.watch(
|
2024-05-09 22:12:22 +00:00
|
|
|
localeServiceChangeNotifierProvider.select((value) => value.locale),
|
|
|
|
);
|
2022-08-26 08:11:35 +00:00
|
|
|
|
2023-11-03 19:46:55 +00:00
|
|
|
final coin = ref.watch(pWalletCoin(walletId));
|
2022-08-26 08:11:35 +00:00
|
|
|
|
2024-05-15 21:20:45 +00:00
|
|
|
final isFiro = coin is Firo;
|
2022-11-07 17:46:17 +00:00
|
|
|
|
2022-08-26 08:11:35 +00:00
|
|
|
return RoundedWhiteContainer(
|
|
|
|
padding: const EdgeInsets.all(0),
|
2022-11-07 17:46:17 +00:00
|
|
|
child: ConditionalParent(
|
|
|
|
condition: isFiro,
|
|
|
|
builder: (child) => Expandable(
|
|
|
|
header: Container(
|
|
|
|
color: Colors.transparent,
|
|
|
|
child: Padding(
|
|
|
|
padding: const EdgeInsets.all(12),
|
|
|
|
child: child,
|
|
|
|
),
|
2022-08-26 08:11:35 +00:00
|
|
|
),
|
2022-11-07 17:46:17 +00:00
|
|
|
body: Column(
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: [
|
|
|
|
MaterialButton(
|
|
|
|
splashColor:
|
|
|
|
Theme.of(context).extension<StackColors>()!.highlight,
|
|
|
|
key: Key("walletsSheetItemButtonFiroPrivateKey_$walletId"),
|
|
|
|
padding: const EdgeInsets.all(0),
|
|
|
|
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
|
|
|
shape: RoundedRectangleBorder(
|
|
|
|
borderRadius: BorderRadius.circular(
|
|
|
|
Constants.size.circularBorderRadius,
|
|
|
|
),
|
|
|
|
),
|
2022-11-22 15:11:18 +00:00
|
|
|
onPressed: () async {
|
2022-11-22 17:21:43 +00:00
|
|
|
if (mounted) {
|
2022-11-22 15:11:18 +00:00
|
|
|
unawaited(
|
|
|
|
_send(
|
|
|
|
shouldSendPublicFiroFunds: false,
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
},
|
2022-11-07 17:46:17 +00:00
|
|
|
child: Container(
|
|
|
|
color: Colors.transparent,
|
|
|
|
child: Padding(
|
|
|
|
padding: const EdgeInsets.only(
|
|
|
|
top: 6,
|
|
|
|
left: 16,
|
|
|
|
right: 16,
|
|
|
|
bottom: 6,
|
2022-08-26 08:11:35 +00:00
|
|
|
),
|
2022-11-07 17:46:17 +00:00
|
|
|
child: Row(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
children: [
|
|
|
|
Column(
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: [
|
|
|
|
Text(
|
|
|
|
"Use private balance",
|
|
|
|
style: STextStyles.itemSubtitle(context),
|
|
|
|
),
|
2023-04-05 22:06:31 +00:00
|
|
|
Text(
|
2024-05-09 22:12:22 +00:00
|
|
|
ref.watch(pAmountFormatter(coin)).format(
|
|
|
|
ref
|
|
|
|
.watch(pWalletBalanceTertiary(walletId))
|
|
|
|
.spendable,
|
|
|
|
),
|
2023-04-05 22:06:31 +00:00
|
|
|
style: STextStyles.itemSubtitle(context),
|
2022-11-07 17:46:17 +00:00
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
SvgPicture.asset(
|
|
|
|
Assets.svg.chevronRight,
|
|
|
|
height: 14,
|
|
|
|
width: 7,
|
|
|
|
color: Theme.of(context)
|
|
|
|
.extension<StackColors>()!
|
|
|
|
.infoItemLabel,
|
|
|
|
),
|
|
|
|
],
|
2022-08-26 08:11:35 +00:00
|
|
|
),
|
|
|
|
),
|
2022-11-07 17:46:17 +00:00
|
|
|
),
|
|
|
|
),
|
|
|
|
MaterialButton(
|
|
|
|
splashColor:
|
|
|
|
Theme.of(context).extension<StackColors>()!.highlight,
|
|
|
|
key: Key("walletsSheetItemButtonFiroPublicKey_$walletId"),
|
|
|
|
padding: const EdgeInsets.all(0),
|
|
|
|
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
|
|
|
shape: RoundedRectangleBorder(
|
|
|
|
borderRadius: BorderRadius.circular(
|
|
|
|
Constants.size.circularBorderRadius,
|
|
|
|
),
|
|
|
|
),
|
2022-11-22 15:11:18 +00:00
|
|
|
onPressed: () async {
|
2022-11-22 17:21:43 +00:00
|
|
|
if (mounted) {
|
2022-11-22 15:11:18 +00:00
|
|
|
unawaited(
|
|
|
|
_send(
|
|
|
|
shouldSendPublicFiroFunds: true,
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
},
|
2022-11-07 17:46:17 +00:00
|
|
|
child: Container(
|
|
|
|
color: Colors.transparent,
|
|
|
|
child: Padding(
|
|
|
|
padding: const EdgeInsets.only(
|
|
|
|
top: 6,
|
|
|
|
left: 16,
|
|
|
|
right: 16,
|
|
|
|
bottom: 6,
|
|
|
|
),
|
|
|
|
child: Row(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
children: [
|
|
|
|
Column(
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: [
|
|
|
|
Text(
|
|
|
|
"Use public balance",
|
|
|
|
style: STextStyles.itemSubtitle(context),
|
|
|
|
),
|
2023-04-05 22:06:31 +00:00
|
|
|
Text(
|
2023-05-29 21:10:55 +00:00
|
|
|
ref.watch(pAmountFormatter(coin)).format(
|
2023-11-03 19:46:55 +00:00
|
|
|
ref
|
2024-01-16 22:34:12 +00:00
|
|
|
.watch(pWalletBalance(walletId))
|
2023-11-03 19:46:55 +00:00
|
|
|
.spendable,
|
|
|
|
),
|
2023-04-05 22:06:31 +00:00
|
|
|
style: STextStyles.itemSubtitle(context),
|
2022-11-07 17:46:17 +00:00
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
SvgPicture.asset(
|
|
|
|
Assets.svg.chevronRight,
|
|
|
|
height: 14,
|
|
|
|
width: 7,
|
|
|
|
color: Theme.of(context)
|
|
|
|
.extension<StackColors>()!
|
|
|
|
.infoItemLabel,
|
|
|
|
),
|
|
|
|
],
|
2022-08-26 08:11:35 +00:00
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
2022-11-07 17:46:17 +00:00
|
|
|
const SizedBox(
|
|
|
|
height: 6,
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
child: ConditionalParent(
|
|
|
|
condition: !isFiro,
|
|
|
|
builder: (child) => MaterialButton(
|
|
|
|
splashColor: Theme.of(context).extension<StackColors>()!.highlight,
|
|
|
|
key: Key("walletsSheetItemButtonKey_$walletId"),
|
|
|
|
padding: const EdgeInsets.all(8),
|
|
|
|
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
|
|
|
shape: RoundedRectangleBorder(
|
|
|
|
borderRadius: BorderRadius.circular(
|
|
|
|
Constants.size.circularBorderRadius,
|
2022-08-26 08:11:35 +00:00
|
|
|
),
|
|
|
|
),
|
2022-11-22 15:11:18 +00:00
|
|
|
onPressed: () async {
|
2022-11-22 17:21:43 +00:00
|
|
|
if (mounted) {
|
2022-11-22 15:11:18 +00:00
|
|
|
unawaited(
|
2023-11-03 19:46:55 +00:00
|
|
|
_send(),
|
2022-11-22 15:11:18 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
},
|
2022-11-07 17:46:17 +00:00
|
|
|
child: child,
|
|
|
|
),
|
|
|
|
child: Row(
|
|
|
|
children: [
|
|
|
|
Container(
|
|
|
|
decoration: BoxDecoration(
|
2024-05-15 21:20:45 +00:00
|
|
|
color: ref.watch(pCoinColor(coin)).withOpacity(0.5),
|
2022-11-07 17:46:17 +00:00
|
|
|
borderRadius: BorderRadius.circular(
|
|
|
|
Constants.size.circularBorderRadius,
|
2022-09-30 21:21:10 +00:00
|
|
|
),
|
2022-11-07 17:46:17 +00:00
|
|
|
),
|
|
|
|
child: Padding(
|
|
|
|
padding: const EdgeInsets.all(6),
|
2023-05-09 23:59:26 +00:00
|
|
|
child: SvgPicture.file(
|
|
|
|
File(
|
|
|
|
ref.watch(
|
|
|
|
coinIconProvider(coin),
|
|
|
|
),
|
2023-05-09 15:21:04 +00:00
|
|
|
),
|
2022-11-07 17:46:17 +00:00
|
|
|
width: 24,
|
|
|
|
height: 24,
|
2022-09-30 21:21:10 +00:00
|
|
|
),
|
2022-11-07 17:46:17 +00:00
|
|
|
),
|
2022-09-30 21:21:10 +00:00
|
|
|
),
|
2022-11-07 17:46:17 +00:00
|
|
|
const SizedBox(
|
|
|
|
width: 12,
|
|
|
|
),
|
|
|
|
Expanded(
|
|
|
|
child: Column(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: [
|
|
|
|
Text(
|
2023-11-03 19:46:55 +00:00
|
|
|
ref.watch(pWalletName(walletId)),
|
2022-11-07 17:46:17 +00:00
|
|
|
style: STextStyles.titleBold12(context),
|
|
|
|
),
|
|
|
|
if (!isFiro)
|
|
|
|
const SizedBox(
|
|
|
|
height: 2,
|
|
|
|
),
|
|
|
|
if (!isFiro)
|
2023-04-05 22:06:31 +00:00
|
|
|
Text(
|
2023-11-03 19:46:55 +00:00
|
|
|
ref.watch(pAmountFormatter(coin)).format(
|
2024-05-09 22:12:22 +00:00
|
|
|
ref.watch(pWalletBalance(walletId)).spendable,
|
|
|
|
),
|
2023-04-05 22:06:31 +00:00
|
|
|
style: STextStyles.itemSubtitle(context),
|
2022-11-07 17:46:17 +00:00
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
2022-08-26 08:11:35 +00:00
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|