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-01 21:17:46 +00:00
|
|
|
import 'dart:async';
|
2023-05-09 23:59:26 +00:00
|
|
|
import 'dart:io';
|
2022-09-01 21:17:46 +00:00
|
|
|
|
2022-11-01 17:42:33 +00:00
|
|
|
import 'package:decimal/decimal.dart';
|
2022-08-26 08:11:35 +00:00
|
|
|
import 'package:flutter/material.dart';
|
2023-10-10 21:26:12 +00:00
|
|
|
import 'package:flutter_libepiccash/lib.dart';
|
2022-08-26 08:11:35 +00:00
|
|
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
2022-11-01 17:42:33 +00:00
|
|
|
import 'package:flutter_svg/svg.dart';
|
2023-11-09 17:39:12 +00:00
|
|
|
import 'package:stackwallet/models/isar/models/transaction_note.dart';
|
2022-09-01 21:17:46 +00:00
|
|
|
import 'package:stackwallet/notifications/show_flush_bar.dart';
|
2022-08-26 08:11:35 +00:00
|
|
|
import 'package:stackwallet/pages/pinpad_views/lock_screen_view.dart';
|
|
|
|
import 'package:stackwallet/pages/send_view/sub_widgets/sending_transaction_dialog.dart';
|
|
|
|
import 'package:stackwallet/pages/wallet_view/wallet_view.dart';
|
2023-03-16 18:10:59 +00:00
|
|
|
import 'package:stackwallet/pages_desktop_specific/coin_control/desktop_coin_control_use_dialog.dart';
|
2022-12-01 14:48:23 +00:00
|
|
|
import 'package:stackwallet/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_auth_send.dart';
|
2023-11-09 17:39:12 +00:00
|
|
|
import 'package:stackwallet/providers/db/main_db_provider.dart';
|
2022-08-26 08:11:35 +00:00
|
|
|
import 'package:stackwallet/providers/providers.dart';
|
2022-09-21 00:46:07 +00:00
|
|
|
import 'package:stackwallet/providers/wallet/public_private_balance_state_provider.dart';
|
2022-08-26 08:11:35 +00:00
|
|
|
import 'package:stackwallet/route_generator.dart';
|
2023-05-09 21:57:40 +00:00
|
|
|
import 'package:stackwallet/themes/stack_colors.dart';
|
2023-05-09 16:30:06 +00:00
|
|
|
import 'package:stackwallet/themes/theme_providers.dart';
|
2023-04-06 21:24:56 +00:00
|
|
|
import 'package:stackwallet/utilities/amount/amount.dart';
|
2023-05-29 21:10:55 +00:00
|
|
|
import 'package:stackwallet/utilities/amount/amount_formatter.dart';
|
2022-11-01 17:42:33 +00:00
|
|
|
import 'package:stackwallet/utilities/constants.dart';
|
2022-08-26 08:11:35 +00:00
|
|
|
import 'package:stackwallet/utilities/enums/coin_enum.dart';
|
|
|
|
import 'package:stackwallet/utilities/text_styles.dart';
|
2022-11-01 17:42:33 +00:00
|
|
|
import 'package:stackwallet/utilities/util.dart';
|
2024-01-10 22:53:12 +00:00
|
|
|
import 'package:stackwallet/wallets/isar/providers/eth/current_token_wallet_provider.dart';
|
2023-11-03 19:46:55 +00:00
|
|
|
import 'package:stackwallet/wallets/isar/providers/wallet_info_provider.dart';
|
|
|
|
import 'package:stackwallet/wallets/models/tx_data.dart';
|
2023-11-24 17:56:38 +00:00
|
|
|
import 'package:stackwallet/wallets/wallet/impl/firo_wallet.dart';
|
2023-10-10 21:26:12 +00:00
|
|
|
// import 'package:stackwallet/wallets/example/libepiccash.dart';
|
2022-11-25 19:24:01 +00:00
|
|
|
import 'package:stackwallet/widgets/background.dart';
|
2022-11-01 17:42:33 +00:00
|
|
|
import 'package:stackwallet/widgets/conditional_parent.dart';
|
2022-08-26 08:11:35 +00:00
|
|
|
import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart';
|
2022-11-14 15:05:45 +00:00
|
|
|
import 'package:stackwallet/widgets/desktop/desktop_dialog.dart';
|
|
|
|
import 'package:stackwallet/widgets/desktop/desktop_dialog_close_button.dart';
|
2022-11-01 17:42:33 +00:00
|
|
|
import 'package:stackwallet/widgets/desktop/primary_button.dart';
|
2022-11-30 17:36:58 +00:00
|
|
|
import 'package:stackwallet/widgets/icon_widgets/x_icon.dart';
|
2022-08-26 08:11:35 +00:00
|
|
|
import 'package:stackwallet/widgets/rounded_container.dart';
|
|
|
|
import 'package:stackwallet/widgets/rounded_white_container.dart';
|
|
|
|
import 'package:stackwallet/widgets/stack_dialog.dart';
|
2022-11-30 17:36:58 +00:00
|
|
|
import 'package:stackwallet/widgets/stack_text_field.dart';
|
|
|
|
import 'package:stackwallet/widgets/textfield_icon_button.dart';
|
2022-08-26 08:11:35 +00:00
|
|
|
|
|
|
|
class ConfirmTransactionView extends ConsumerStatefulWidget {
|
|
|
|
const ConfirmTransactionView({
|
|
|
|
Key? key,
|
2023-11-03 19:46:55 +00:00
|
|
|
required this.txData,
|
2022-08-26 08:11:35 +00:00
|
|
|
required this.walletId,
|
2024-01-04 18:52:00 +00:00
|
|
|
required this.onSuccess,
|
2022-08-26 08:11:35 +00:00
|
|
|
this.routeOnSuccessName = WalletView.routeName,
|
2022-11-22 15:11:18 +00:00
|
|
|
this.isTradeTransaction = false,
|
2023-01-09 21:43:16 +00:00
|
|
|
this.isPaynymTransaction = false,
|
|
|
|
this.isPaynymNotificationTransaction = false,
|
2023-03-31 15:25:51 +00:00
|
|
|
this.isTokenTx = false,
|
2023-01-09 21:43:16 +00:00
|
|
|
this.onSuccessInsteadOfRouteOnSuccess,
|
2022-08-26 08:11:35 +00:00
|
|
|
}) : super(key: key);
|
|
|
|
|
|
|
|
static const String routeName = "/confirmTransactionView";
|
|
|
|
|
2023-11-03 19:46:55 +00:00
|
|
|
final TxData txData;
|
2022-08-26 08:11:35 +00:00
|
|
|
final String walletId;
|
|
|
|
final String routeOnSuccessName;
|
2022-11-22 15:11:18 +00:00
|
|
|
final bool isTradeTransaction;
|
2023-01-09 21:43:16 +00:00
|
|
|
final bool isPaynymTransaction;
|
|
|
|
final bool isPaynymNotificationTransaction;
|
2023-03-31 15:25:51 +00:00
|
|
|
final bool isTokenTx;
|
2023-01-09 21:43:16 +00:00
|
|
|
final VoidCallback? onSuccessInsteadOfRouteOnSuccess;
|
2024-01-04 18:52:00 +00:00
|
|
|
final VoidCallback onSuccess;
|
2022-08-26 08:11:35 +00:00
|
|
|
|
|
|
|
@override
|
|
|
|
ConsumerState<ConfirmTransactionView> createState() =>
|
|
|
|
_ConfirmTransactionViewState();
|
|
|
|
}
|
|
|
|
|
|
|
|
class _ConfirmTransactionViewState
|
|
|
|
extends ConsumerState<ConfirmTransactionView> {
|
|
|
|
late final String walletId;
|
|
|
|
late final String routeOnSuccessName;
|
2022-11-01 17:42:33 +00:00
|
|
|
late final bool isDesktop;
|
|
|
|
|
2022-11-30 17:36:58 +00:00
|
|
|
late final FocusNode _noteFocusNode;
|
|
|
|
late final TextEditingController noteController;
|
|
|
|
|
2023-07-31 10:16:08 +00:00
|
|
|
late final FocusNode _onChainNoteFocusNode;
|
|
|
|
late final TextEditingController onChainNoteController;
|
|
|
|
|
2022-08-26 08:11:35 +00:00
|
|
|
Future<void> _attemptSend(BuildContext context) async {
|
2023-11-03 19:46:55 +00:00
|
|
|
final wallet = ref.read(pWallets).getWallet(walletId);
|
|
|
|
final coin = wallet.info.coin;
|
2023-04-20 23:39:16 +00:00
|
|
|
|
|
|
|
final sendProgressController = ProgressAndSuccessController();
|
|
|
|
|
2022-11-14 15:05:45 +00:00
|
|
|
unawaited(
|
|
|
|
showDialog<dynamic>(
|
|
|
|
context: context,
|
|
|
|
useSafeArea: false,
|
|
|
|
barrierDismissible: false,
|
|
|
|
builder: (context) {
|
2023-03-13 17:49:39 +00:00
|
|
|
return SendingTransactionDialog(
|
2023-11-03 19:46:55 +00:00
|
|
|
coin: coin,
|
2023-04-20 23:39:16 +00:00
|
|
|
controller: sendProgressController,
|
2023-03-13 17:49:39 +00:00
|
|
|
);
|
2022-11-14 15:05:45 +00:00
|
|
|
},
|
|
|
|
),
|
|
|
|
);
|
2022-08-26 08:11:35 +00:00
|
|
|
|
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-12-27 16:01:13 +00:00
|
|
|
final List<String> txids = [];
|
2023-11-09 21:31:23 +00:00
|
|
|
Future<TxData> txDataFuture;
|
2023-03-13 17:49:39 +00:00
|
|
|
|
2022-11-30 17:36:58 +00:00
|
|
|
final note = noteController.text;
|
2022-08-26 08:11:35 +00:00
|
|
|
|
|
|
|
try {
|
2023-03-31 15:25:51 +00:00
|
|
|
if (widget.isTokenTx) {
|
2023-11-03 19:46:55 +00:00
|
|
|
// TODO: [prio=high] fixme
|
|
|
|
throw UnimplementedError("fixme");
|
|
|
|
// txidFuture = ref
|
|
|
|
// .read(tokenServiceProvider)!
|
|
|
|
// .confirmSend(txData: transactionInfo);
|
2023-03-31 15:25:51 +00:00
|
|
|
} else if (widget.isPaynymNotificationTransaction) {
|
2023-11-03 19:46:55 +00:00
|
|
|
// TODO: [prio=high] fixme
|
|
|
|
throw UnimplementedError("fixme");
|
|
|
|
// txidFuture = (wallet as PaynymWalletInterface)
|
|
|
|
// .broadcastNotificationTx(preparedTx: transactionInfo);
|
2023-01-09 21:43:16 +00:00
|
|
|
} else if (widget.isPaynymTransaction) {
|
2023-11-09 21:31:23 +00:00
|
|
|
txDataFuture = wallet.confirmSend(txData: widget.txData);
|
2022-09-07 15:56:10 +00:00
|
|
|
} else {
|
2023-12-21 16:23:55 +00:00
|
|
|
if (wallet is FiroWallet) {
|
|
|
|
switch (ref.read(publicPrivateBalanceStateProvider.state).state) {
|
|
|
|
case FiroType.public:
|
2023-12-27 16:01:13 +00:00
|
|
|
if (widget.txData.sparkMints == null) {
|
|
|
|
txDataFuture = wallet.confirmSend(txData: widget.txData);
|
|
|
|
} else {
|
|
|
|
txDataFuture =
|
|
|
|
wallet.confirmSparkMintTransactions(txData: widget.txData);
|
|
|
|
}
|
2023-12-21 16:23:55 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case FiroType.lelantus:
|
|
|
|
txDataFuture = wallet.confirmSendLelantus(txData: widget.txData);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case FiroType.spark:
|
|
|
|
txDataFuture = wallet.confirmSendSpark(txData: widget.txData);
|
|
|
|
break;
|
|
|
|
}
|
2023-01-09 21:43:16 +00:00
|
|
|
} else {
|
2023-07-31 10:16:08 +00:00
|
|
|
if (coin == Coin.epicCash) {
|
2023-11-09 21:31:23 +00:00
|
|
|
txDataFuture = wallet.confirmSend(
|
2023-11-03 19:46:55 +00:00
|
|
|
txData: widget.txData.copyWith(
|
|
|
|
noteOnChain: onChainNoteController.text,
|
|
|
|
),
|
|
|
|
);
|
|
|
|
} else {
|
2023-11-09 21:31:23 +00:00
|
|
|
txDataFuture = wallet.confirmSend(txData: widget.txData);
|
2023-07-31 10:16:08 +00:00
|
|
|
}
|
2023-01-09 21:43:16 +00:00
|
|
|
}
|
2022-09-07 15:56:10 +00:00
|
|
|
}
|
|
|
|
|
2023-03-13 17:49:39 +00:00
|
|
|
final results = await Future.wait([
|
2023-11-09 21:31:23 +00:00
|
|
|
txDataFuture,
|
2023-03-13 17:49:39 +00:00
|
|
|
time,
|
|
|
|
]);
|
|
|
|
|
2023-04-24 18:12:47 +00:00
|
|
|
sendProgressController.triggerSuccess?.call();
|
2023-04-20 23:39:16 +00:00
|
|
|
await Future<void>.delayed(const Duration(seconds: 5));
|
|
|
|
|
2023-12-27 16:01:13 +00:00
|
|
|
if (wallet is FiroWallet &&
|
|
|
|
(results.first as TxData).sparkMints != null) {
|
|
|
|
txids.addAll((results.first as TxData).sparkMints!.map((e) => e.txid!));
|
|
|
|
} else {
|
|
|
|
txids.add((results.first as TxData).txid!);
|
|
|
|
}
|
2023-03-16 18:10:59 +00:00
|
|
|
ref.refresh(desktopUseUTXOs);
|
2023-03-13 17:49:39 +00:00
|
|
|
|
2022-08-26 08:11:35 +00:00
|
|
|
// save note
|
2023-12-27 16:01:13 +00:00
|
|
|
for (final txid in txids) {
|
|
|
|
await ref.read(mainDBProvider).putTransactionNote(
|
|
|
|
TransactionNote(
|
|
|
|
walletId: walletId,
|
|
|
|
txid: txid,
|
|
|
|
value: note,
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
2022-08-26 08:11:35 +00:00
|
|
|
|
2023-03-31 15:25:51 +00:00
|
|
|
if (widget.isTokenTx) {
|
2024-01-10 22:53:12 +00:00
|
|
|
unawaited(ref.read(pCurrentTokenWallet)!.refresh());
|
2023-03-31 15:25:51 +00:00
|
|
|
} else {
|
2023-11-03 19:46:55 +00:00
|
|
|
unawaited(wallet.refresh());
|
2023-03-31 15:25:51 +00:00
|
|
|
}
|
2022-11-07 16:24:08 +00:00
|
|
|
|
2024-01-04 18:52:00 +00:00
|
|
|
widget.onSuccess.call();
|
|
|
|
|
2022-08-26 08:11:35 +00:00
|
|
|
// pop back to wallet
|
|
|
|
if (mounted) {
|
2023-01-09 21:43:16 +00:00
|
|
|
if (widget.onSuccessInsteadOfRouteOnSuccess == null) {
|
|
|
|
Navigator.of(context)
|
|
|
|
.popUntil(ModalRoute.withName(routeOnSuccessName));
|
|
|
|
} else {
|
|
|
|
widget.onSuccessInsteadOfRouteOnSuccess!.call();
|
|
|
|
}
|
2022-08-26 08:11:35 +00:00
|
|
|
}
|
2022-09-01 21:17:46 +00:00
|
|
|
} on BadEpicHttpAddressException catch (_) {
|
|
|
|
if (mounted) {
|
|
|
|
// pop building dialog
|
|
|
|
Navigator.of(context).pop();
|
|
|
|
unawaited(
|
|
|
|
showFloatingFlushBar(
|
|
|
|
type: FlushBarType.warning,
|
|
|
|
message:
|
2022-09-07 15:56:10 +00:00
|
|
|
"Connection failed. Please check the address and try again.",
|
2022-09-01 21:17:46 +00:00
|
|
|
context: context,
|
|
|
|
),
|
|
|
|
);
|
|
|
|
return;
|
|
|
|
}
|
2022-08-26 08:11:35 +00:00
|
|
|
} catch (e, s) {
|
2022-12-13 00:17:02 +00:00
|
|
|
//todo: comeback to this
|
2022-08-26 08:11:35 +00:00
|
|
|
debugPrint("$e\n$s");
|
|
|
|
// pop sending dialog
|
|
|
|
Navigator.of(context).pop();
|
|
|
|
|
2022-09-01 21:17:46 +00:00
|
|
|
await showDialog<void>(
|
2022-08-26 08:11:35 +00:00
|
|
|
context: context,
|
|
|
|
useSafeArea: false,
|
|
|
|
barrierDismissible: true,
|
|
|
|
builder: (context) {
|
2022-11-14 15:05:45 +00:00
|
|
|
if (isDesktop) {
|
|
|
|
return DesktopDialog(
|
|
|
|
maxWidth: 450,
|
|
|
|
child: Padding(
|
|
|
|
padding: const EdgeInsets.all(32),
|
|
|
|
child: Column(
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: [
|
|
|
|
Text(
|
|
|
|
"Broadcast transaction failed",
|
|
|
|
style: STextStyles.desktopH3(context),
|
|
|
|
),
|
|
|
|
const SizedBox(
|
|
|
|
height: 24,
|
|
|
|
),
|
2023-12-21 16:24:22 +00:00
|
|
|
Flexible(
|
|
|
|
child: SingleChildScrollView(
|
|
|
|
child: SelectableText(
|
|
|
|
e.toString(),
|
|
|
|
style: STextStyles.smallMed14(context),
|
|
|
|
),
|
|
|
|
),
|
2022-11-14 15:05:45 +00:00
|
|
|
),
|
|
|
|
const SizedBox(
|
|
|
|
height: 56,
|
|
|
|
),
|
|
|
|
Row(
|
|
|
|
children: [
|
|
|
|
const Spacer(),
|
|
|
|
Expanded(
|
|
|
|
child: PrimaryButton(
|
2022-11-17 17:46:44 +00:00
|
|
|
buttonHeight: ButtonHeight.l,
|
2022-11-14 15:05:45 +00:00
|
|
|
label: "Ok",
|
|
|
|
onPressed: Navigator.of(context).pop,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
)
|
|
|
|
],
|
|
|
|
),
|
2022-08-26 08:11:35 +00:00
|
|
|
),
|
2022-11-14 15:05:45 +00:00
|
|
|
);
|
|
|
|
} else {
|
|
|
|
return StackDialog(
|
|
|
|
title: "Broadcast transaction failed",
|
|
|
|
message: e.toString(),
|
|
|
|
rightButton: TextButton(
|
|
|
|
style: Theme.of(context)
|
|
|
|
.extension<StackColors>()!
|
2023-01-24 19:29:12 +00:00
|
|
|
.getSecondaryEnabledButtonStyle(context),
|
2022-11-14 15:05:45 +00:00
|
|
|
child: Text(
|
|
|
|
"Ok",
|
|
|
|
style: STextStyles.button(context).copyWith(
|
|
|
|
color: Theme.of(context)
|
|
|
|
.extension<StackColors>()!
|
|
|
|
.accentColorDark),
|
|
|
|
),
|
|
|
|
onPressed: () {
|
|
|
|
Navigator.of(context).pop();
|
|
|
|
},
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
2022-08-26 08:11:35 +00:00
|
|
|
},
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
void initState() {
|
2022-11-01 17:42:33 +00:00
|
|
|
isDesktop = Util.isDesktop;
|
2022-08-26 08:11:35 +00:00
|
|
|
walletId = widget.walletId;
|
|
|
|
routeOnSuccessName = widget.routeOnSuccessName;
|
2022-11-30 17:36:58 +00:00
|
|
|
_noteFocusNode = FocusNode();
|
|
|
|
noteController = TextEditingController();
|
2023-11-03 19:46:55 +00:00
|
|
|
noteController.text = widget.txData.note ?? "";
|
2023-07-31 10:16:08 +00:00
|
|
|
|
|
|
|
_onChainNoteFocusNode = FocusNode();
|
|
|
|
onChainNoteController = TextEditingController();
|
2023-11-03 19:46:55 +00:00
|
|
|
onChainNoteController.text = widget.txData.noteOnChain ?? "";
|
2023-07-31 10:16:08 +00:00
|
|
|
|
2022-08-26 08:11:35 +00:00
|
|
|
super.initState();
|
|
|
|
}
|
|
|
|
|
2022-11-30 17:36:58 +00:00
|
|
|
@override
|
|
|
|
void dispose() {
|
|
|
|
noteController.dispose();
|
2023-07-31 10:16:08 +00:00
|
|
|
onChainNoteController.dispose();
|
2022-11-30 17:36:58 +00:00
|
|
|
|
|
|
|
_noteFocusNode.dispose();
|
2023-07-31 10:16:08 +00:00
|
|
|
_onChainNoteFocusNode.dispose();
|
2022-11-30 17:36:58 +00:00
|
|
|
super.dispose();
|
|
|
|
}
|
|
|
|
|
2022-08-26 08:11:35 +00:00
|
|
|
@override
|
2023-11-03 19:46:55 +00:00
|
|
|
Widget build(BuildContext context) {
|
|
|
|
final coin = ref.watch(pWalletCoin(walletId));
|
2023-05-29 21:10:55 +00:00
|
|
|
|
2023-03-31 15:25:51 +00:00
|
|
|
final String unit;
|
|
|
|
if (widget.isTokenTx) {
|
|
|
|
unit = ref.watch(
|
2024-01-10 22:53:12 +00:00
|
|
|
pCurrentTokenWallet.select((value) => value!.tokenContract.symbol));
|
2023-03-31 15:25:51 +00:00
|
|
|
} else {
|
2023-05-29 21:10:55 +00:00
|
|
|
unit = coin.ticker;
|
2023-03-31 15:25:51 +00:00
|
|
|
}
|
2023-12-27 16:01:13 +00:00
|
|
|
|
|
|
|
final Amount? fee;
|
2024-01-05 19:45:42 +00:00
|
|
|
final Amount amountWithoutChange;
|
2023-12-27 16:01:13 +00:00
|
|
|
|
|
|
|
final wallet = ref.watch(pWallets).getWallet(walletId);
|
|
|
|
|
|
|
|
if (wallet is FiroWallet) {
|
|
|
|
switch (ref.read(publicPrivateBalanceStateProvider.state).state) {
|
|
|
|
case FiroType.public:
|
|
|
|
if (widget.txData.sparkMints != null) {
|
|
|
|
fee = widget.txData.sparkMints!
|
|
|
|
.map((e) => e.fee!)
|
|
|
|
.reduce((value, element) => value += element);
|
2024-01-05 19:45:42 +00:00
|
|
|
amountWithoutChange = widget.txData.sparkMints!
|
2023-12-27 16:01:13 +00:00
|
|
|
.map((e) => e.amountSpark!)
|
|
|
|
.reduce((value, element) => value += element);
|
|
|
|
} else {
|
|
|
|
fee = widget.txData.fee;
|
2024-01-05 19:45:42 +00:00
|
|
|
amountWithoutChange = widget.txData.amountWithoutChange!;
|
2023-12-27 16:01:13 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case FiroType.lelantus:
|
|
|
|
fee = widget.txData.fee;
|
2024-01-05 19:45:42 +00:00
|
|
|
amountWithoutChange = widget.txData.amountWithoutChange!;
|
2023-12-27 16:01:13 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case FiroType.spark:
|
|
|
|
fee = widget.txData.fee;
|
2024-01-05 19:45:42 +00:00
|
|
|
amountWithoutChange = (widget.txData.amountWithoutChange ??
|
2023-12-27 16:01:13 +00:00
|
|
|
Amount.zeroWith(
|
|
|
|
fractionDigits: wallet.cryptoCurrency.fractionDigits)) +
|
2024-01-05 19:45:42 +00:00
|
|
|
(widget.txData.amountSparkWithoutChange ??
|
2023-12-27 16:01:13 +00:00
|
|
|
Amount.zeroWith(
|
|
|
|
fractionDigits: wallet.cryptoCurrency.fractionDigits));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
fee = widget.txData.fee;
|
2024-01-05 19:45:42 +00:00
|
|
|
amountWithoutChange = widget.txData.amountWithoutChange!;
|
2023-12-27 16:01:13 +00:00
|
|
|
}
|
|
|
|
|
2022-11-01 17:42:33 +00:00
|
|
|
return ConditionalParent(
|
|
|
|
condition: !isDesktop,
|
2022-11-25 19:24:01 +00:00
|
|
|
builder: (child) => Background(
|
|
|
|
child: Scaffold(
|
2022-11-01 17:42:33 +00:00
|
|
|
backgroundColor:
|
|
|
|
Theme.of(context).extension<StackColors>()!.background,
|
2022-11-25 19:24:01 +00:00
|
|
|
appBar: AppBar(
|
|
|
|
backgroundColor:
|
|
|
|
Theme.of(context).extension<StackColors>()!.background,
|
|
|
|
leading: AppBarBackButton(
|
|
|
|
onPressed: () async {
|
|
|
|
// if (FocusScope.of(context).hasFocus) {
|
|
|
|
// FocusScope.of(context).unfocus();
|
|
|
|
// await Future<void>.delayed(Duration(milliseconds: 50));
|
|
|
|
// }
|
|
|
|
Navigator.of(context).pop();
|
|
|
|
},
|
|
|
|
),
|
|
|
|
title: Text(
|
|
|
|
"Confirm transaction",
|
|
|
|
style: STextStyles.navBarTitle(context),
|
|
|
|
),
|
2022-11-01 17:42:33 +00:00
|
|
|
),
|
2022-11-25 19:24:01 +00:00
|
|
|
body: LayoutBuilder(
|
|
|
|
builder: (builderContext, constraints) {
|
|
|
|
return Padding(
|
|
|
|
padding: const EdgeInsets.only(
|
|
|
|
left: 12,
|
|
|
|
top: 12,
|
|
|
|
right: 12,
|
|
|
|
),
|
|
|
|
child: SingleChildScrollView(
|
|
|
|
child: ConstrainedBox(
|
|
|
|
constraints: BoxConstraints(
|
|
|
|
minHeight: constraints.maxHeight - 24,
|
|
|
|
),
|
|
|
|
child: IntrinsicHeight(
|
|
|
|
child: Padding(
|
|
|
|
padding: const EdgeInsets.all(4),
|
|
|
|
child: child,
|
|
|
|
),
|
2022-11-01 17:42:33 +00:00
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
2022-11-25 19:24:01 +00:00
|
|
|
);
|
|
|
|
},
|
|
|
|
),
|
2022-08-26 08:11:35 +00:00
|
|
|
),
|
|
|
|
),
|
2022-11-01 17:42:33 +00:00
|
|
|
child: ConditionalParent(
|
|
|
|
condition: isDesktop,
|
|
|
|
builder: (child) => Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
children: [
|
|
|
|
Row(
|
|
|
|
children: [
|
|
|
|
AppBarBackButton(
|
|
|
|
size: 40,
|
|
|
|
iconSize: 24,
|
|
|
|
onPressed: () => Navigator.of(
|
|
|
|
context,
|
|
|
|
rootNavigator: true,
|
|
|
|
).pop(),
|
2022-08-26 08:11:35 +00:00
|
|
|
),
|
2022-11-01 17:42:33 +00:00
|
|
|
Text(
|
2023-03-31 15:25:51 +00:00
|
|
|
"Confirm $unit transaction",
|
2022-11-01 17:42:33 +00:00
|
|
|
style: STextStyles.desktopH3(context),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
child,
|
|
|
|
],
|
|
|
|
),
|
|
|
|
child: Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
|
|
|
mainAxisSize: isDesktop ? MainAxisSize.min : MainAxisSize.max,
|
|
|
|
children: [
|
|
|
|
if (!isDesktop)
|
|
|
|
Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
|
|
|
children: [
|
|
|
|
Text(
|
2023-03-31 15:25:51 +00:00
|
|
|
"Send $unit",
|
2022-11-01 17:42:33 +00:00
|
|
|
style: STextStyles.pageTitleH1(context),
|
|
|
|
),
|
|
|
|
const SizedBox(
|
|
|
|
height: 12,
|
|
|
|
),
|
|
|
|
RoundedWhiteContainer(
|
2022-08-26 08:11:35 +00:00
|
|
|
child: Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
|
|
|
children: [
|
|
|
|
Text(
|
2023-01-26 18:16:38 +00:00
|
|
|
widget.isPaynymTransaction
|
|
|
|
? "PayNym recipient"
|
|
|
|
: "Recipient",
|
2022-11-01 17:42:33 +00:00
|
|
|
style: STextStyles.smallMed12(context),
|
2022-08-26 08:11:35 +00:00
|
|
|
),
|
|
|
|
const SizedBox(
|
2022-11-01 17:42:33 +00:00
|
|
|
height: 4,
|
2022-08-26 08:11:35 +00:00
|
|
|
),
|
2022-11-01 17:42:33 +00:00
|
|
|
Text(
|
2023-01-26 18:16:38 +00:00
|
|
|
widget.isPaynymTransaction
|
2023-11-03 19:46:55 +00:00
|
|
|
? widget.txData.paynymAccountLite!.nymName
|
2023-12-27 16:01:13 +00:00
|
|
|
: widget.txData.recipients?.first.address ??
|
|
|
|
widget.txData.sparkRecipients!.first.address,
|
2022-11-01 17:42:33 +00:00
|
|
|
style: STextStyles.itemSubtitle12(context),
|
2022-08-26 08:11:35 +00:00
|
|
|
),
|
2022-11-01 17:42:33 +00:00
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
const SizedBox(
|
|
|
|
height: 12,
|
|
|
|
),
|
|
|
|
RoundedWhiteContainer(
|
|
|
|
child: Row(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
children: [
|
|
|
|
Text(
|
|
|
|
"Amount",
|
|
|
|
style: STextStyles.smallMed12(context),
|
2022-08-26 08:11:35 +00:00
|
|
|
),
|
2023-11-22 18:30:09 +00:00
|
|
|
SelectableText(
|
2023-05-29 21:10:55 +00:00
|
|
|
ref.watch(pAmountFormatter(coin)).format(
|
2024-01-05 19:45:42 +00:00
|
|
|
amountWithoutChange,
|
2023-05-29 21:10:55 +00:00
|
|
|
ethContract: ref
|
2024-01-10 22:53:12 +00:00
|
|
|
.watch(pCurrentTokenWallet)
|
2023-05-29 21:10:55 +00:00
|
|
|
?.tokenContract,
|
|
|
|
),
|
2022-11-01 17:42:33 +00:00
|
|
|
style: STextStyles.itemSubtitle12(context),
|
|
|
|
textAlign: TextAlign.right,
|
2022-08-26 08:11:35 +00:00
|
|
|
),
|
2022-11-01 17:42:33 +00:00
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
2023-06-08 20:00:31 +00:00
|
|
|
if (coin != Coin.banano && coin != Coin.nano)
|
|
|
|
const SizedBox(
|
|
|
|
height: 12,
|
|
|
|
),
|
|
|
|
if (coin != Coin.banano && coin != Coin.nano)
|
|
|
|
RoundedWhiteContainer(
|
|
|
|
child: Row(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
children: [
|
|
|
|
Text(
|
|
|
|
"Transaction fee",
|
|
|
|
style: STextStyles.smallMed12(context),
|
|
|
|
),
|
2023-11-22 18:30:09 +00:00
|
|
|
SelectableText(
|
2023-12-27 16:01:13 +00:00
|
|
|
ref.watch(pAmountFormatter(coin)).format(fee!),
|
2023-06-08 20:00:31 +00:00
|
|
|
style: STextStyles.itemSubtitle12(context),
|
|
|
|
textAlign: TextAlign.right,
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
2022-11-01 17:42:33 +00:00
|
|
|
),
|
2023-11-03 19:46:55 +00:00
|
|
|
if (widget.txData.fee != null && widget.txData.vSize != null)
|
2023-06-17 16:42:23 +00:00
|
|
|
const SizedBox(
|
|
|
|
height: 12,
|
|
|
|
),
|
2023-11-03 19:46:55 +00:00
|
|
|
if (widget.txData.fee != null && widget.txData.vSize != null)
|
2023-06-17 16:42:23 +00:00
|
|
|
RoundedWhiteContainer(
|
|
|
|
child: Row(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
children: [
|
|
|
|
Text(
|
|
|
|
"sats/vByte",
|
|
|
|
style: STextStyles.smallMed12(context),
|
|
|
|
),
|
|
|
|
const SizedBox(
|
|
|
|
height: 4,
|
|
|
|
),
|
2023-11-22 18:30:09 +00:00
|
|
|
SelectableText(
|
2023-12-27 16:01:13 +00:00
|
|
|
"~${fee!.raw.toInt() ~/ widget.txData.vSize!}",
|
2023-06-17 16:42:23 +00:00
|
|
|
style: STextStyles.itemSubtitle12(context),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
2023-07-20 22:04:01 +00:00
|
|
|
if (coin == Coin.epicCash &&
|
2023-11-03 19:46:55 +00:00
|
|
|
widget.txData.noteOnChain!.isNotEmpty)
|
2023-07-05 12:57:17 +00:00
|
|
|
const SizedBox(
|
|
|
|
height: 12,
|
|
|
|
),
|
2023-07-20 22:04:01 +00:00
|
|
|
if (coin == Coin.epicCash &&
|
2023-11-03 19:46:55 +00:00
|
|
|
widget.txData.noteOnChain!.isNotEmpty)
|
2023-07-05 12:57:17 +00:00
|
|
|
RoundedWhiteContainer(
|
2023-07-20 22:04:01 +00:00
|
|
|
child: Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
|
|
|
children: [
|
|
|
|
Text(
|
|
|
|
"On chain note",
|
|
|
|
style: STextStyles.smallMed12(context),
|
|
|
|
),
|
|
|
|
const SizedBox(
|
|
|
|
height: 4,
|
|
|
|
),
|
2023-11-22 18:30:09 +00:00
|
|
|
SelectableText(
|
2023-11-03 19:46:55 +00:00
|
|
|
widget.txData.noteOnChain!,
|
2023-07-20 22:04:01 +00:00
|
|
|
style: STextStyles.itemSubtitle12(context),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
2023-07-05 12:57:17 +00:00
|
|
|
),
|
2023-11-03 19:46:55 +00:00
|
|
|
if (widget.txData.note!.isNotEmpty)
|
2023-07-20 22:04:01 +00:00
|
|
|
const SizedBox(
|
|
|
|
height: 12,
|
|
|
|
),
|
2023-11-03 19:46:55 +00:00
|
|
|
if (widget.txData.note!.isNotEmpty)
|
2023-07-20 22:04:01 +00:00
|
|
|
RoundedWhiteContainer(
|
|
|
|
child: Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
|
|
|
children: [
|
|
|
|
Text(
|
|
|
|
(coin == Coin.epicCash) ? "Local Note" : "Note",
|
|
|
|
style: STextStyles.smallMed12(context),
|
|
|
|
),
|
|
|
|
const SizedBox(
|
|
|
|
height: 4,
|
|
|
|
),
|
2023-11-22 18:30:09 +00:00
|
|
|
SelectableText(
|
2023-11-03 19:46:55 +00:00
|
|
|
widget.txData.note!,
|
2023-07-20 22:04:01 +00:00
|
|
|
style: STextStyles.itemSubtitle12(context),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
2022-11-01 17:42:33 +00:00
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
if (isDesktop)
|
|
|
|
Padding(
|
|
|
|
padding: const EdgeInsets.only(
|
|
|
|
top: 16,
|
|
|
|
left: 32,
|
|
|
|
right: 32,
|
|
|
|
bottom: 50,
|
|
|
|
),
|
|
|
|
child: RoundedWhiteContainer(
|
|
|
|
padding: const EdgeInsets.all(0),
|
|
|
|
borderColor:
|
|
|
|
Theme.of(context).extension<StackColors>()!.background,
|
|
|
|
child: Column(
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
|
|
|
children: [
|
|
|
|
Container(
|
|
|
|
decoration: BoxDecoration(
|
2022-09-22 23:48:50 +00:00
|
|
|
color: Theme.of(context)
|
|
|
|
.extension<StackColors>()!
|
2022-11-01 17:42:33 +00:00
|
|
|
.background,
|
|
|
|
borderRadius: BorderRadius.only(
|
|
|
|
topLeft: Radius.circular(
|
|
|
|
Constants.size.circularBorderRadius,
|
|
|
|
),
|
|
|
|
topRight: Radius.circular(
|
|
|
|
Constants.size.circularBorderRadius,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
child: Padding(
|
|
|
|
padding: const EdgeInsets.symmetric(
|
|
|
|
horizontal: 12,
|
|
|
|
vertical: 22,
|
|
|
|
),
|
2022-08-26 08:11:35 +00:00
|
|
|
child: Row(
|
|
|
|
children: [
|
2023-05-09 23:59:26 +00:00
|
|
|
SvgPicture.file(
|
|
|
|
File(
|
|
|
|
ref.watch(
|
|
|
|
themeProvider.select(
|
|
|
|
(value) => value.assets.send,
|
|
|
|
),
|
2023-05-09 16:30:06 +00:00
|
|
|
),
|
|
|
|
),
|
2022-11-01 17:42:33 +00:00
|
|
|
width: 32,
|
|
|
|
height: 32,
|
|
|
|
),
|
|
|
|
const SizedBox(
|
|
|
|
width: 16,
|
2022-08-26 08:11:35 +00:00
|
|
|
),
|
|
|
|
Text(
|
2023-03-31 15:25:51 +00:00
|
|
|
"Send $unit",
|
2022-11-01 17:42:33 +00:00
|
|
|
style: STextStyles.desktopTextMedium(context),
|
2022-08-26 08:11:35 +00:00
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
2022-11-01 17:42:33 +00:00
|
|
|
),
|
|
|
|
Padding(
|
|
|
|
padding: const EdgeInsets.all(12),
|
|
|
|
child: Column(
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: [
|
|
|
|
Text(
|
|
|
|
"Amount",
|
|
|
|
style: STextStyles.desktopTextExtraExtraSmall(
|
|
|
|
context),
|
|
|
|
),
|
|
|
|
const SizedBox(
|
|
|
|
height: 2,
|
|
|
|
),
|
|
|
|
Builder(
|
|
|
|
builder: (context) {
|
|
|
|
final externalCalls = ref.watch(
|
|
|
|
prefsChangeNotifierProvider.select(
|
|
|
|
(value) => value.externalCalls));
|
|
|
|
String fiatAmount = "N/A";
|
|
|
|
|
|
|
|
if (externalCalls) {
|
2023-04-11 20:25:13 +00:00
|
|
|
final price = widget.isTokenTx
|
|
|
|
? ref
|
|
|
|
.read(
|
|
|
|
priceAnd24hChangeNotifierProvider)
|
|
|
|
.getTokenPrice(
|
|
|
|
ref
|
2024-01-10 22:53:12 +00:00
|
|
|
.read(pCurrentTokenWallet)!
|
2023-04-11 20:25:13 +00:00
|
|
|
.tokenContract
|
|
|
|
.address,
|
|
|
|
)
|
|
|
|
.item1
|
|
|
|
: ref
|
|
|
|
.read(
|
|
|
|
priceAnd24hChangeNotifierProvider)
|
|
|
|
.getPrice(coin)
|
|
|
|
.item1;
|
2022-11-01 17:42:33 +00:00
|
|
|
if (price > Decimal.zero) {
|
2024-01-05 19:45:42 +00:00
|
|
|
fiatAmount =
|
|
|
|
(amountWithoutChange.decimal * price)
|
|
|
|
.toAmount(fractionDigits: 2)
|
|
|
|
.fiatString(
|
|
|
|
locale: ref
|
|
|
|
.read(
|
|
|
|
localeServiceChangeNotifierProvider)
|
|
|
|
.locale,
|
|
|
|
);
|
2022-11-01 17:42:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return Row(
|
|
|
|
children: [
|
2023-11-22 18:30:09 +00:00
|
|
|
SelectableText(
|
2023-05-29 21:10:55 +00:00
|
|
|
ref.watch(pAmountFormatter(coin)).format(
|
2024-01-05 19:45:42 +00:00
|
|
|
amountWithoutChange,
|
2023-05-29 21:10:55 +00:00
|
|
|
ethContract: ref
|
2024-01-10 22:53:12 +00:00
|
|
|
.read(pCurrentTokenWallet)
|
2023-05-29 21:10:55 +00:00
|
|
|
?.tokenContract),
|
2022-11-01 17:42:33 +00:00
|
|
|
style: STextStyles
|
|
|
|
.desktopTextExtraExtraSmall(
|
|
|
|
context)
|
|
|
|
.copyWith(
|
|
|
|
color: Theme.of(context)
|
|
|
|
.extension<StackColors>()!
|
|
|
|
.textDark,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
if (externalCalls)
|
|
|
|
Text(
|
|
|
|
" | ",
|
|
|
|
style: STextStyles
|
|
|
|
.desktopTextExtraExtraSmall(
|
|
|
|
context),
|
|
|
|
),
|
|
|
|
if (externalCalls)
|
2023-11-22 18:30:09 +00:00
|
|
|
SelectableText(
|
2022-11-01 17:42:33 +00:00
|
|
|
"~$fiatAmount ${ref.watch(prefsChangeNotifierProvider.select(
|
|
|
|
(value) => value.currency,
|
|
|
|
))}",
|
|
|
|
style: STextStyles
|
|
|
|
.desktopTextExtraExtraSmall(
|
|
|
|
context),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
);
|
|
|
|
},
|
|
|
|
),
|
|
|
|
],
|
2022-08-26 08:11:35 +00:00
|
|
|
),
|
2022-11-01 17:42:33 +00:00
|
|
|
),
|
|
|
|
Container(
|
|
|
|
height: 1,
|
|
|
|
color: Theme.of(context)
|
|
|
|
.extension<StackColors>()!
|
|
|
|
.background,
|
|
|
|
),
|
|
|
|
Padding(
|
|
|
|
padding: const EdgeInsets.all(12),
|
|
|
|
child: Column(
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: [
|
|
|
|
Text(
|
2023-02-10 18:07:57 +00:00
|
|
|
widget.isPaynymTransaction
|
|
|
|
? "PayNym recipient"
|
|
|
|
: "Send to",
|
2022-11-01 17:42:33 +00:00
|
|
|
style: STextStyles.desktopTextExtraExtraSmall(
|
|
|
|
context),
|
|
|
|
),
|
|
|
|
const SizedBox(
|
|
|
|
height: 2,
|
|
|
|
),
|
2023-11-22 18:30:09 +00:00
|
|
|
SelectableText(
|
2023-12-21 00:00:02 +00:00
|
|
|
// TODO: [prio=high] spark transaction specifics - better handling
|
2023-02-10 18:07:57 +00:00
|
|
|
widget.isPaynymTransaction
|
2023-11-03 19:46:55 +00:00
|
|
|
? widget.txData.paynymAccountLite!.nymName
|
2023-12-21 00:00:02 +00:00
|
|
|
: widget.txData.recipients?.first.address ??
|
|
|
|
widget.txData.sparkRecipients!.first
|
|
|
|
.address,
|
2022-11-01 17:42:33 +00:00
|
|
|
style: STextStyles.desktopTextExtraExtraSmall(
|
|
|
|
context)
|
|
|
|
.copyWith(
|
|
|
|
color: Theme.of(context)
|
|
|
|
.extension<StackColors>()!
|
|
|
|
.textDark,
|
2022-08-26 08:11:35 +00:00
|
|
|
),
|
2022-11-01 17:42:33 +00:00
|
|
|
)
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
2023-02-10 18:07:57 +00:00
|
|
|
if (widget.isPaynymTransaction)
|
|
|
|
Container(
|
|
|
|
height: 1,
|
|
|
|
color: Theme.of(context)
|
|
|
|
.extension<StackColors>()!
|
|
|
|
.background,
|
|
|
|
),
|
|
|
|
if (widget.isPaynymTransaction)
|
|
|
|
Padding(
|
|
|
|
padding: const EdgeInsets.all(12),
|
|
|
|
child: Column(
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: [
|
|
|
|
Text(
|
|
|
|
"Transaction fee",
|
|
|
|
style: STextStyles.desktopTextExtraExtraSmall(
|
|
|
|
context),
|
|
|
|
),
|
|
|
|
const SizedBox(
|
|
|
|
height: 2,
|
|
|
|
),
|
2023-12-27 16:01:13 +00:00
|
|
|
SelectableText(
|
|
|
|
ref.watch(pAmountFormatter(coin)).format(fee!),
|
|
|
|
style: STextStyles.desktopTextExtraExtraSmall(
|
|
|
|
context)
|
|
|
|
.copyWith(
|
|
|
|
color: Theme.of(context)
|
|
|
|
.extension<StackColors>()!
|
|
|
|
.textDark,
|
|
|
|
),
|
2023-02-10 18:07:57 +00:00
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
2022-11-30 17:36:58 +00:00
|
|
|
// Container(
|
|
|
|
// height: 1,
|
|
|
|
// color: Theme.of(context)
|
|
|
|
// .extension<StackColors>()!
|
|
|
|
// .background,
|
|
|
|
// ),
|
|
|
|
// Padding(
|
|
|
|
// padding: const EdgeInsets.all(12),
|
|
|
|
// child: Column(
|
|
|
|
// mainAxisSize: MainAxisSize.min,
|
|
|
|
// crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
// children: [
|
|
|
|
// Text(
|
|
|
|
// "Note",
|
|
|
|
// style: STextStyles.desktopTextExtraExtraSmall(
|
|
|
|
// context),
|
|
|
|
// ),
|
|
|
|
// const SizedBox(
|
|
|
|
// height: 2,
|
|
|
|
// ),
|
|
|
|
// Text(
|
|
|
|
// transactionInfo["note"] as String,
|
|
|
|
// style: STextStyles.desktopTextExtraExtraSmall(
|
|
|
|
// context)
|
|
|
|
// .copyWith(
|
|
|
|
// color: Theme.of(context)
|
|
|
|
// .extension<StackColors>()!
|
|
|
|
// .textDark,
|
|
|
|
// ),
|
|
|
|
// )
|
|
|
|
// ],
|
|
|
|
// ),
|
|
|
|
// ),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
if (isDesktop)
|
|
|
|
Padding(
|
|
|
|
padding: const EdgeInsets.only(
|
|
|
|
left: 32,
|
|
|
|
right: 32,
|
|
|
|
),
|
|
|
|
child: Column(
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: [
|
2023-07-31 10:16:08 +00:00
|
|
|
if (coin == Coin.epicCash)
|
|
|
|
Text(
|
|
|
|
"On chain Note (optional)",
|
|
|
|
style: STextStyles.smallMed12(context),
|
|
|
|
textAlign: TextAlign.left,
|
|
|
|
),
|
|
|
|
if (coin == Coin.epicCash)
|
|
|
|
const SizedBox(
|
|
|
|
height: 8,
|
|
|
|
),
|
|
|
|
if (coin == Coin.epicCash)
|
|
|
|
ClipRRect(
|
|
|
|
borderRadius: BorderRadius.circular(
|
|
|
|
Constants.size.circularBorderRadius,
|
|
|
|
),
|
|
|
|
child: TextField(
|
|
|
|
autocorrect: Util.isDesktop ? false : true,
|
|
|
|
enableSuggestions: Util.isDesktop ? false : true,
|
|
|
|
maxLength: 256,
|
|
|
|
controller: onChainNoteController,
|
|
|
|
focusNode: _onChainNoteFocusNode,
|
|
|
|
style: STextStyles.field(context),
|
|
|
|
onChanged: (_) => setState(() {}),
|
|
|
|
decoration: standardInputDecoration(
|
|
|
|
"Type something...",
|
|
|
|
_onChainNoteFocusNode,
|
|
|
|
context,
|
|
|
|
).copyWith(
|
|
|
|
suffixIcon: onChainNoteController.text.isNotEmpty
|
|
|
|
? Padding(
|
2023-10-06 22:36:21 +00:00
|
|
|
padding: const EdgeInsets.only(right: 0),
|
|
|
|
child: UnconstrainedBox(
|
|
|
|
child: Row(
|
|
|
|
children: [
|
|
|
|
TextFieldIconButton(
|
|
|
|
child: const XIcon(),
|
|
|
|
onTap: () async {
|
|
|
|
setState(() {
|
|
|
|
onChainNoteController.text = "";
|
|
|
|
});
|
|
|
|
},
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
2023-07-31 10:16:08 +00:00
|
|
|
),
|
2023-10-06 22:36:21 +00:00
|
|
|
)
|
2023-07-31 10:16:08 +00:00
|
|
|
: null,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
if (coin == Coin.epicCash)
|
|
|
|
const SizedBox(
|
|
|
|
height: 12,
|
|
|
|
),
|
2023-11-22 18:30:09 +00:00
|
|
|
SelectableText(
|
2023-10-06 22:36:21 +00:00
|
|
|
(coin == Coin.epicCash)
|
|
|
|
? "Local Note (optional)"
|
2023-07-31 10:16:08 +00:00
|
|
|
: "Note (optional)",
|
2022-11-30 17:36:58 +00:00
|
|
|
style:
|
|
|
|
STextStyles.desktopTextExtraSmall(context).copyWith(
|
2022-11-01 17:42:33 +00:00
|
|
|
color: Theme.of(context)
|
|
|
|
.extension<StackColors>()!
|
2022-11-30 17:36:58 +00:00
|
|
|
.textFieldActiveSearchIconRight,
|
2022-11-01 17:42:33 +00:00
|
|
|
),
|
2022-11-30 17:36:58 +00:00
|
|
|
textAlign: TextAlign.left,
|
|
|
|
),
|
|
|
|
const SizedBox(
|
|
|
|
height: 10,
|
|
|
|
),
|
|
|
|
ClipRRect(
|
|
|
|
borderRadius: BorderRadius.circular(
|
|
|
|
Constants.size.circularBorderRadius,
|
|
|
|
),
|
|
|
|
child: TextField(
|
|
|
|
minLines: 1,
|
|
|
|
maxLines: 5,
|
|
|
|
autocorrect: isDesktop ? false : true,
|
|
|
|
enableSuggestions: isDesktop ? false : true,
|
|
|
|
controller: noteController,
|
|
|
|
focusNode: _noteFocusNode,
|
|
|
|
style:
|
|
|
|
STextStyles.desktopTextExtraSmall(context).copyWith(
|
|
|
|
color: Theme.of(context)
|
|
|
|
.extension<StackColors>()!
|
|
|
|
.textFieldActiveText,
|
|
|
|
height: 1.8,
|
|
|
|
),
|
|
|
|
onChanged: (_) => setState(() {}),
|
|
|
|
decoration: standardInputDecoration(
|
|
|
|
"Type something...",
|
|
|
|
_noteFocusNode,
|
|
|
|
context,
|
|
|
|
desktopMed: true,
|
|
|
|
).copyWith(
|
|
|
|
contentPadding: const EdgeInsets.only(
|
|
|
|
left: 16,
|
|
|
|
top: 11,
|
|
|
|
bottom: 12,
|
|
|
|
right: 5,
|
|
|
|
),
|
|
|
|
suffixIcon: noteController.text.isNotEmpty
|
|
|
|
? Padding(
|
|
|
|
padding: const EdgeInsets.only(right: 0),
|
|
|
|
child: UnconstrainedBox(
|
|
|
|
child: Row(
|
|
|
|
children: [
|
|
|
|
TextFieldIconButton(
|
|
|
|
child: const XIcon(),
|
|
|
|
onTap: () async {
|
|
|
|
setState(
|
|
|
|
() => noteController.text = "",
|
|
|
|
);
|
|
|
|
},
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
)
|
|
|
|
: null,
|
2022-11-01 17:42:33 +00:00
|
|
|
),
|
|
|
|
),
|
2022-11-30 17:36:58 +00:00
|
|
|
),
|
|
|
|
const SizedBox(
|
|
|
|
height: 20,
|
|
|
|
)
|
|
|
|
],
|
2022-11-01 17:42:33 +00:00
|
|
|
),
|
|
|
|
),
|
2023-02-10 18:07:57 +00:00
|
|
|
if (isDesktop && !widget.isPaynymTransaction)
|
2022-11-01 17:42:33 +00:00
|
|
|
Padding(
|
|
|
|
padding: const EdgeInsets.only(
|
|
|
|
left: 32,
|
|
|
|
),
|
|
|
|
child: Text(
|
2022-11-30 17:36:58 +00:00
|
|
|
"Transaction fee",
|
2022-11-01 17:42:33 +00:00
|
|
|
style: STextStyles.desktopTextExtraExtraSmall(context),
|
|
|
|
),
|
|
|
|
),
|
2023-02-10 18:07:57 +00:00
|
|
|
if (isDesktop && !widget.isPaynymTransaction)
|
2022-11-01 17:42:33 +00:00
|
|
|
Padding(
|
2023-02-10 18:07:57 +00:00
|
|
|
padding: const EdgeInsets.only(
|
|
|
|
top: 10,
|
|
|
|
left: 32,
|
|
|
|
right: 32,
|
|
|
|
),
|
|
|
|
child: RoundedContainer(
|
|
|
|
padding: const EdgeInsets.symmetric(
|
|
|
|
horizontal: 16,
|
|
|
|
vertical: 18,
|
2022-11-14 13:56:07 +00:00
|
|
|
),
|
2023-02-10 18:07:57 +00:00
|
|
|
color: Theme.of(context)
|
|
|
|
.extension<StackColors>()!
|
|
|
|
.textFieldDefaultBG,
|
2023-12-27 16:01:13 +00:00
|
|
|
child: SelectableText(
|
|
|
|
ref.watch(pAmountFormatter(coin)).format(fee!),
|
|
|
|
style: STextStyles.itemSubtitle(context),
|
2022-11-14 13:56:07 +00:00
|
|
|
),
|
2023-02-10 18:07:57 +00:00
|
|
|
),
|
|
|
|
),
|
2023-06-19 16:04:25 +00:00
|
|
|
if (isDesktop &&
|
|
|
|
!widget.isPaynymTransaction &&
|
2023-11-03 19:46:55 +00:00
|
|
|
widget.txData.fee != null &&
|
|
|
|
widget.txData.vSize != null)
|
2023-06-19 16:04:25 +00:00
|
|
|
Padding(
|
|
|
|
padding: const EdgeInsets.only(
|
|
|
|
left: 32,
|
|
|
|
),
|
|
|
|
child: Text(
|
|
|
|
"sats/vByte",
|
|
|
|
style: STextStyles.desktopTextExtraExtraSmall(context),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
if (isDesktop &&
|
|
|
|
!widget.isPaynymTransaction &&
|
2023-11-03 19:46:55 +00:00
|
|
|
widget.txData.fee != null &&
|
|
|
|
widget.txData.vSize != null)
|
2023-06-19 16:04:25 +00:00
|
|
|
Padding(
|
|
|
|
padding: const EdgeInsets.only(
|
|
|
|
top: 10,
|
|
|
|
left: 32,
|
|
|
|
right: 32,
|
|
|
|
),
|
|
|
|
child: RoundedContainer(
|
|
|
|
padding: const EdgeInsets.symmetric(
|
|
|
|
horizontal: 16,
|
|
|
|
vertical: 18,
|
|
|
|
),
|
|
|
|
color: Theme.of(context)
|
|
|
|
.extension<StackColors>()!
|
|
|
|
.textFieldDefaultBG,
|
2023-11-22 18:30:09 +00:00
|
|
|
child: SelectableText(
|
2023-12-27 16:01:13 +00:00
|
|
|
"~${fee!.raw.toInt() ~/ widget.txData.vSize!}",
|
2023-06-19 16:04:25 +00:00
|
|
|
style: STextStyles.itemSubtitle(context),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
2022-11-01 17:42:33 +00:00
|
|
|
if (!isDesktop) const Spacer(),
|
|
|
|
SizedBox(
|
|
|
|
height: isDesktop ? 23 : 12,
|
|
|
|
),
|
2023-04-11 20:25:13 +00:00
|
|
|
if (!widget.isTokenTx)
|
|
|
|
Padding(
|
2022-11-01 17:42:33 +00:00
|
|
|
padding: isDesktop
|
|
|
|
? const EdgeInsets.symmetric(
|
2023-04-11 20:25:13 +00:00
|
|
|
horizontal: 32,
|
2022-11-01 17:42:33 +00:00
|
|
|
)
|
2023-04-11 20:25:13 +00:00
|
|
|
: const EdgeInsets.all(0),
|
|
|
|
child: RoundedContainer(
|
|
|
|
padding: isDesktop
|
|
|
|
? const EdgeInsets.symmetric(
|
|
|
|
horizontal: 16,
|
|
|
|
vertical: 18,
|
|
|
|
)
|
|
|
|
: const EdgeInsets.all(12),
|
|
|
|
color: Theme.of(context)
|
|
|
|
.extension<StackColors>()!
|
|
|
|
.snackBarBackSuccess,
|
|
|
|
child: Row(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
children: [
|
|
|
|
Text(
|
|
|
|
isDesktop ? "Total amount to send" : "Total amount",
|
2023-04-05 22:06:31 +00:00
|
|
|
style: isDesktop
|
|
|
|
? STextStyles.desktopTextExtraExtraSmall(context)
|
|
|
|
.copyWith(
|
|
|
|
color: Theme.of(context)
|
|
|
|
.extension<StackColors>()!
|
|
|
|
.textConfirmTotalAmount,
|
|
|
|
)
|
2023-04-11 20:25:13 +00:00
|
|
|
: STextStyles.titleBold12(context).copyWith(
|
2023-04-05 22:06:31 +00:00
|
|
|
color: Theme.of(context)
|
|
|
|
.extension<StackColors>()!
|
|
|
|
.textConfirmTotalAmount,
|
|
|
|
),
|
2023-11-03 19:46:55 +00:00
|
|
|
),
|
2023-12-27 16:01:13 +00:00
|
|
|
SelectableText(
|
2024-01-05 19:45:42 +00:00
|
|
|
ref
|
|
|
|
.watch(pAmountFormatter(coin))
|
|
|
|
.format(amountWithoutChange + fee!),
|
2023-12-27 16:01:13 +00:00
|
|
|
style: isDesktop
|
|
|
|
? STextStyles.desktopTextExtraExtraSmall(context)
|
|
|
|
.copyWith(
|
|
|
|
color: Theme.of(context)
|
|
|
|
.extension<StackColors>()!
|
|
|
|
.textConfirmTotalAmount,
|
|
|
|
)
|
|
|
|
: STextStyles.itemSubtitle12(context).copyWith(
|
|
|
|
color: Theme.of(context)
|
|
|
|
.extension<StackColors>()!
|
|
|
|
.textConfirmTotalAmount,
|
|
|
|
),
|
|
|
|
textAlign: TextAlign.right,
|
|
|
|
),
|
2023-04-11 20:25:13 +00:00
|
|
|
],
|
|
|
|
),
|
2022-08-26 08:11:35 +00:00
|
|
|
),
|
|
|
|
),
|
2022-11-01 17:42:33 +00:00
|
|
|
SizedBox(
|
|
|
|
height: isDesktop ? 28 : 16,
|
|
|
|
),
|
|
|
|
Padding(
|
|
|
|
padding: isDesktop
|
|
|
|
? const EdgeInsets.symmetric(
|
|
|
|
horizontal: 32,
|
|
|
|
)
|
|
|
|
: const EdgeInsets.all(0),
|
|
|
|
child: PrimaryButton(
|
|
|
|
label: "Send",
|
2022-11-23 20:55:04 +00:00
|
|
|
buttonHeight: isDesktop ? ButtonHeight.l : null,
|
2023-11-03 19:46:55 +00:00
|
|
|
onPressed: () async {
|
2022-11-14 15:05:45 +00:00
|
|
|
final dynamic unlocked;
|
|
|
|
|
|
|
|
if (isDesktop) {
|
|
|
|
unlocked = await showDialog<bool?>(
|
|
|
|
context: context,
|
|
|
|
builder: (context) => DesktopDialog(
|
|
|
|
maxWidth: 580,
|
|
|
|
maxHeight: double.infinity,
|
|
|
|
child: Column(
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
children: [
|
2023-11-03 19:46:55 +00:00
|
|
|
const Row(
|
2022-11-14 15:05:45 +00:00
|
|
|
mainAxisAlignment: MainAxisAlignment.end,
|
2023-11-03 19:46:55 +00:00
|
|
|
children: [
|
2022-11-14 15:05:45 +00:00
|
|
|
DesktopDialogCloseButton(),
|
|
|
|
],
|
|
|
|
),
|
2022-11-25 00:16:26 +00:00
|
|
|
Padding(
|
|
|
|
padding: const EdgeInsets.only(
|
2022-11-14 15:05:45 +00:00
|
|
|
left: 32,
|
|
|
|
right: 32,
|
|
|
|
bottom: 32,
|
|
|
|
),
|
2022-11-25 00:16:26 +00:00
|
|
|
child: DesktopAuthSend(
|
|
|
|
coin: coin,
|
|
|
|
),
|
2022-11-14 15:05:45 +00:00
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
2022-11-01 17:42:33 +00:00
|
|
|
),
|
2022-11-14 15:05:45 +00:00
|
|
|
);
|
|
|
|
} else {
|
|
|
|
unlocked = await Navigator.push(
|
|
|
|
context,
|
|
|
|
RouteGenerator.getRoute(
|
|
|
|
shouldUseMaterialRoute:
|
|
|
|
RouteGenerator.useMaterialPageRoute,
|
|
|
|
builder: (_) => const LockscreenView(
|
|
|
|
showBackButton: true,
|
|
|
|
popOnSuccess: true,
|
|
|
|
routeOnSuccessArguments: true,
|
|
|
|
routeOnSuccess: "",
|
|
|
|
biometricsCancelButtonString: "CANCEL",
|
|
|
|
biometricsLocalizedReason:
|
|
|
|
"Authenticate to send transaction",
|
|
|
|
biometricsAuthenticationTitle: "Confirm Transaction",
|
|
|
|
),
|
|
|
|
settings:
|
|
|
|
const RouteSettings(name: "/confirmsendlockscreen"),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
2022-11-01 17:42:33 +00:00
|
|
|
|
2022-11-22 15:11:18 +00:00
|
|
|
if (mounted) {
|
|
|
|
if (unlocked == true) {
|
|
|
|
unawaited(_attemptSend(context));
|
|
|
|
} else {
|
|
|
|
unawaited(
|
|
|
|
showFloatingFlushBar(
|
|
|
|
type: FlushBarType.warning,
|
|
|
|
message: Util.isDesktop
|
|
|
|
? "Invalid passphrase"
|
|
|
|
: "Invalid PIN",
|
|
|
|
context: context),
|
|
|
|
);
|
|
|
|
}
|
2022-11-01 17:42:33 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
),
|
|
|
|
),
|
|
|
|
if (isDesktop)
|
|
|
|
const SizedBox(
|
|
|
|
height: 32,
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
2022-08-26 08:11:35 +00:00
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|