2022-09-01 21:17:46 +00:00
|
|
|
import 'dart:async';
|
|
|
|
|
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';
|
|
|
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
2022-11-01 17:42:33 +00:00
|
|
|
import 'package:flutter_svg/svg.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';
|
2022-11-14 15:05:45 +00:00
|
|
|
import 'package:stackwallet/pages_desktop_specific/home/my_stack_view/wallet_view/sub_widgets/desktop_auth_send.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';
|
2022-09-01 21:17:46 +00:00
|
|
|
import 'package:stackwallet/services/coins/epiccash/epiccash_wallet.dart';
|
2022-09-07 15:56:10 +00:00
|
|
|
import 'package:stackwallet/services/coins/firo/firo_wallet.dart';
|
2022-11-01 17:42:33 +00:00
|
|
|
import 'package:stackwallet/utilities/assets.dart';
|
|
|
|
import 'package:stackwallet/utilities/constants.dart';
|
2022-08-26 08:11:35 +00:00
|
|
|
import 'package:stackwallet/utilities/enums/coin_enum.dart';
|
2022-09-01 21:17:46 +00:00
|
|
|
import 'package:stackwallet/utilities/enums/flush_bar_type.dart';
|
2022-08-26 08:11:35 +00:00
|
|
|
import 'package:stackwallet/utilities/format.dart';
|
|
|
|
import 'package:stackwallet/utilities/text_styles.dart';
|
2022-09-22 23:48:50 +00:00
|
|
|
import 'package:stackwallet/utilities/theme/stack_colors.dart';
|
2022-11-01 17:42:33 +00:00
|
|
|
import 'package:stackwallet/utilities/util.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-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';
|
|
|
|
|
|
|
|
class ConfirmTransactionView extends ConsumerStatefulWidget {
|
|
|
|
const ConfirmTransactionView({
|
|
|
|
Key? key,
|
|
|
|
required this.transactionInfo,
|
|
|
|
required this.walletId,
|
|
|
|
this.routeOnSuccessName = WalletView.routeName,
|
2022-11-22 15:11:18 +00:00
|
|
|
this.isTradeTransaction = false,
|
2022-08-26 08:11:35 +00:00
|
|
|
}) : super(key: key);
|
|
|
|
|
|
|
|
static const String routeName = "/confirmTransactionView";
|
|
|
|
|
|
|
|
final Map<String, dynamic> transactionInfo;
|
|
|
|
final String walletId;
|
|
|
|
final String routeOnSuccessName;
|
2022-11-22 15:11:18 +00:00
|
|
|
final bool isTradeTransaction;
|
2022-08-26 08:11:35 +00:00
|
|
|
|
|
|
|
@override
|
|
|
|
ConsumerState<ConfirmTransactionView> createState() =>
|
|
|
|
_ConfirmTransactionViewState();
|
|
|
|
}
|
|
|
|
|
|
|
|
class _ConfirmTransactionViewState
|
|
|
|
extends ConsumerState<ConfirmTransactionView> {
|
|
|
|
late final Map<String, dynamic> transactionInfo;
|
|
|
|
late final String walletId;
|
|
|
|
late final String routeOnSuccessName;
|
2022-11-01 17:42:33 +00:00
|
|
|
late final bool isDesktop;
|
|
|
|
|
2022-08-26 08:11:35 +00:00
|
|
|
Future<void> _attemptSend(BuildContext context) async {
|
2022-11-14 15:05:45 +00:00
|
|
|
unawaited(
|
|
|
|
showDialog<dynamic>(
|
|
|
|
context: context,
|
|
|
|
useSafeArea: false,
|
|
|
|
barrierDismissible: false,
|
|
|
|
builder: (context) {
|
|
|
|
return const SendingTransactionDialog();
|
|
|
|
},
|
|
|
|
),
|
|
|
|
);
|
2022-08-26 08:11:35 +00:00
|
|
|
|
|
|
|
final note = transactionInfo["note"] as String? ?? "";
|
|
|
|
final manager =
|
2022-09-07 15:56:10 +00:00
|
|
|
ref.read(walletsChangeNotifierProvider).getManager(walletId);
|
2022-08-26 08:11:35 +00:00
|
|
|
|
|
|
|
try {
|
2022-09-07 15:56:10 +00:00
|
|
|
String txid;
|
|
|
|
final coin = manager.coin;
|
|
|
|
if ((coin == Coin.firo || coin == Coin.firoTestNet) &&
|
|
|
|
ref.read(publicPrivateBalanceStateProvider.state).state !=
|
|
|
|
"Private") {
|
|
|
|
txid = await (manager.wallet as FiroWallet)
|
|
|
|
.confirmSendPublic(txData: transactionInfo);
|
|
|
|
} else {
|
|
|
|
txid = await manager.confirmSend(txData: transactionInfo);
|
|
|
|
}
|
|
|
|
|
2022-08-26 08:11:35 +00:00
|
|
|
// save note
|
2022-09-01 21:17:46 +00:00
|
|
|
await ref
|
2022-08-26 08:11:35 +00:00
|
|
|
.read(notesServiceChangeNotifierProvider(walletId))
|
|
|
|
.editOrAddNote(txid: txid, note: note);
|
|
|
|
|
2022-11-07 16:24:08 +00:00
|
|
|
unawaited(manager.refresh());
|
|
|
|
|
2022-08-26 08:11:35 +00:00
|
|
|
// pop back to wallet
|
|
|
|
if (mounted) {
|
|
|
|
Navigator.of(context).popUntil(ModalRoute.withName(routeOnSuccessName));
|
|
|
|
}
|
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) {
|
|
|
|
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,
|
|
|
|
),
|
|
|
|
Text(
|
|
|
|
e.toString(),
|
|
|
|
style: STextStyles.smallMed14(context),
|
|
|
|
),
|
|
|
|
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>()!
|
|
|
|
.getSecondaryEnabledButtonColor(context),
|
|
|
|
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
|
|
|
transactionInfo = widget.transactionInfo;
|
|
|
|
walletId = widget.walletId;
|
|
|
|
routeOnSuccessName = widget.routeOnSuccessName;
|
|
|
|
super.initState();
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
final managerProvider = ref.watch(walletsChangeNotifierProvider
|
|
|
|
.select((value) => value.getManagerProvider(walletId)));
|
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(
|
|
|
|
"Confirm ${ref.watch(managerProvider.select((value) => value.coin.ticker.toUpperCase()))} transaction",
|
|
|
|
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(
|
|
|
|
"Send ${ref.watch(managerProvider.select((value) => value.coin)).ticker}",
|
|
|
|
style: STextStyles.pageTitleH1(context),
|
|
|
|
),
|
|
|
|
const SizedBox(
|
|
|
|
height: 12,
|
|
|
|
),
|
|
|
|
RoundedWhiteContainer(
|
2022-08-26 08:11:35 +00:00
|
|
|
child: Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
|
|
|
children: [
|
|
|
|
Text(
|
2022-11-01 17:42:33 +00:00
|
|
|
"Recipient",
|
|
|
|
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(
|
|
|
|
"${transactionInfo["address"] ?? "ERROR"}",
|
|
|
|
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
|
|
|
),
|
2022-11-01 17:42:33 +00:00
|
|
|
Text(
|
2022-11-23 18:31:31 +00:00
|
|
|
"${Format.satoshiAmountToPrettyString(transactionInfo["recipientAmt"] as int, ref.watch(
|
|
|
|
localeServiceChangeNotifierProvider
|
|
|
|
.select((value) => value.locale),
|
|
|
|
), ref.watch(
|
|
|
|
managerProvider.select((value) => value.coin),
|
|
|
|
))} ${ref.watch(
|
2022-11-01 17:42:33 +00:00
|
|
|
managerProvider.select((value) => value.coin),
|
|
|
|
).ticker}",
|
|
|
|
style: STextStyles.itemSubtitle12(context),
|
|
|
|
textAlign: TextAlign.right,
|
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(
|
|
|
|
"Transaction fee",
|
|
|
|
style: STextStyles.smallMed12(context),
|
2022-08-26 08:11:35 +00:00
|
|
|
),
|
2022-11-01 17:42:33 +00:00
|
|
|
Text(
|
2022-11-23 18:31:31 +00:00
|
|
|
"${Format.satoshiAmountToPrettyString(transactionInfo["fee"] as int, ref.watch(
|
|
|
|
localeServiceChangeNotifierProvider
|
|
|
|
.select((value) => value.locale),
|
|
|
|
), ref.watch(
|
|
|
|
managerProvider.select((value) => value.coin),
|
|
|
|
))} ${ref.watch(
|
2022-11-01 17:42:33 +00:00
|
|
|
managerProvider.select((value) => value.coin),
|
|
|
|
).ticker}",
|
|
|
|
style: STextStyles.itemSubtitle12(context),
|
|
|
|
textAlign: TextAlign.right,
|
2022-08-26 08:11:35 +00:00
|
|
|
),
|
2022-11-01 17:42:33 +00:00
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
const SizedBox(
|
|
|
|
height: 12,
|
|
|
|
),
|
|
|
|
RoundedWhiteContainer(
|
|
|
|
child: Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
|
|
|
children: [
|
|
|
|
Text(
|
|
|
|
"Note",
|
|
|
|
style: STextStyles.smallMed12(context),
|
2022-08-26 08:11:35 +00:00
|
|
|
),
|
|
|
|
const SizedBox(
|
2022-11-01 17:42:33 +00:00
|
|
|
height: 4,
|
|
|
|
),
|
|
|
|
Text(
|
|
|
|
transactionInfo["note"] as String,
|
|
|
|
style: STextStyles.itemSubtitle12(context),
|
2022-08-26 08:11:35 +00:00
|
|
|
),
|
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: [
|
2022-11-01 17:42:33 +00:00
|
|
|
SvgPicture.asset(
|
|
|
|
Assets.svg.send(context),
|
|
|
|
width: 32,
|
|
|
|
height: 32,
|
|
|
|
),
|
|
|
|
const SizedBox(
|
|
|
|
width: 16,
|
2022-08-26 08:11:35 +00:00
|
|
|
),
|
|
|
|
Text(
|
2022-11-01 17:42:33 +00:00
|
|
|
"Send ${ref.watch(
|
2022-09-07 15:56:10 +00:00
|
|
|
managerProvider
|
|
|
|
.select((value) => value.coin),
|
|
|
|
).ticker}",
|
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 amount =
|
|
|
|
transactionInfo["recipientAmt"] as int;
|
|
|
|
final coin = ref.watch(
|
|
|
|
managerProvider.select(
|
|
|
|
(value) => value.coin,
|
|
|
|
),
|
|
|
|
);
|
|
|
|
final externalCalls = ref.watch(
|
|
|
|
prefsChangeNotifierProvider.select(
|
|
|
|
(value) => value.externalCalls));
|
|
|
|
String fiatAmount = "N/A";
|
|
|
|
|
|
|
|
if (externalCalls) {
|
|
|
|
final price = ref
|
|
|
|
.read(priceAnd24hChangeNotifierProvider)
|
|
|
|
.getPrice(coin)
|
|
|
|
.item1;
|
|
|
|
if (price > Decimal.zero) {
|
|
|
|
fiatAmount = Format.localizedStringAsFixed(
|
|
|
|
value: Format.satoshisToAmount(amount,
|
|
|
|
coin: coin) *
|
|
|
|
price,
|
|
|
|
locale: ref
|
|
|
|
.read(
|
|
|
|
localeServiceChangeNotifierProvider)
|
|
|
|
.locale,
|
|
|
|
decimalPlaces: 2,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return Row(
|
|
|
|
children: [
|
|
|
|
Text(
|
|
|
|
"${Format.satoshiAmountToPrettyString(
|
|
|
|
amount,
|
|
|
|
ref.watch(
|
|
|
|
localeServiceChangeNotifierProvider
|
|
|
|
.select((value) => value.locale),
|
|
|
|
),
|
2022-11-23 18:31:31 +00:00
|
|
|
coin,
|
2022-11-01 17:42:33 +00:00
|
|
|
)} ${coin.ticker}",
|
|
|
|
style: STextStyles
|
|
|
|
.desktopTextExtraExtraSmall(
|
|
|
|
context)
|
|
|
|
.copyWith(
|
|
|
|
color: Theme.of(context)
|
|
|
|
.extension<StackColors>()!
|
|
|
|
.textDark,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
if (externalCalls)
|
|
|
|
Text(
|
|
|
|
" | ",
|
|
|
|
style: STextStyles
|
|
|
|
.desktopTextExtraExtraSmall(
|
|
|
|
context),
|
|
|
|
),
|
|
|
|
if (externalCalls)
|
|
|
|
Text(
|
|
|
|
"~$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(
|
|
|
|
"Send to",
|
|
|
|
style: STextStyles.desktopTextExtraExtraSmall(
|
|
|
|
context),
|
|
|
|
),
|
|
|
|
const SizedBox(
|
|
|
|
height: 2,
|
|
|
|
),
|
|
|
|
Text(
|
|
|
|
"${transactionInfo["address"] ?? "ERROR"}",
|
|
|
|
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
|
|
|
)
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
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,
|
|
|
|
),
|
|
|
|
child: Text(
|
|
|
|
"Transaction fee (estimated)",
|
|
|
|
style: STextStyles.desktopTextExtraExtraSmall(context),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
if (isDesktop)
|
|
|
|
Padding(
|
2022-11-14 13:56:07 +00:00
|
|
|
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,
|
|
|
|
child: Builder(builder: (context) {
|
|
|
|
final coin = ref
|
|
|
|
.watch(walletsChangeNotifierProvider
|
|
|
|
.select((value) => value.getManager(walletId)))
|
|
|
|
.coin;
|
|
|
|
|
|
|
|
final fee = Format.satoshisToAmount(
|
|
|
|
transactionInfo["fee"] as int,
|
|
|
|
coin: coin,
|
|
|
|
);
|
|
|
|
|
|
|
|
return Text(
|
|
|
|
"${Format.localizedStringAsFixed(
|
|
|
|
value: fee,
|
|
|
|
locale: ref.watch(localeServiceChangeNotifierProvider
|
|
|
|
.select((value) => value.locale)),
|
2022-11-23 18:31:31 +00:00
|
|
|
decimalPlaces: Constants.decimalPlacesForCoin(coin),
|
2022-11-14 13:56:07 +00:00
|
|
|
)} ${coin.ticker}",
|
|
|
|
style: STextStyles.itemSubtitle(context),
|
|
|
|
);
|
|
|
|
}),
|
|
|
|
)
|
|
|
|
// DropdownButtonHideUnderline(
|
|
|
|
// child: DropdownButton2(
|
|
|
|
// offset: const Offset(0, -10),
|
|
|
|
// isExpanded: true,
|
|
|
|
//
|
|
|
|
// dropdownElevation: 0,
|
|
|
|
// value: _fee,
|
|
|
|
// items: [
|
|
|
|
// ..._dropDownItems.map(
|
|
|
|
// (e) {
|
|
|
|
// String message = _fee.toString();
|
|
|
|
//
|
|
|
|
// return DropdownMenuItem(
|
|
|
|
// value: e,
|
|
|
|
// child: Text(message),
|
|
|
|
// );
|
|
|
|
// },
|
|
|
|
// ),
|
|
|
|
// ],
|
|
|
|
// onChanged: (value) {
|
|
|
|
// if (value is int) {
|
|
|
|
// setState(() {
|
|
|
|
// _fee = value;
|
|
|
|
// });
|
|
|
|
// }
|
|
|
|
// },
|
|
|
|
// icon: SvgPicture.asset(
|
|
|
|
// Assets.svg.chevronDown,
|
|
|
|
// width: 12,
|
|
|
|
// height: 6,
|
|
|
|
// color:
|
|
|
|
// Theme.of(context).extension<StackColors>()!.textDark3,
|
|
|
|
// ),
|
|
|
|
// buttonPadding: const EdgeInsets.symmetric(
|
|
|
|
// horizontal: 16,
|
|
|
|
// vertical: 8,
|
|
|
|
// ),
|
|
|
|
// buttonDecoration: BoxDecoration(
|
|
|
|
// color: Theme.of(context)
|
|
|
|
// .extension<StackColors>()!
|
|
|
|
// .textFieldDefaultBG,
|
|
|
|
// borderRadius: BorderRadius.circular(
|
|
|
|
// Constants.size.circularBorderRadius,
|
|
|
|
// ),
|
|
|
|
// ),
|
|
|
|
// dropdownDecoration: BoxDecoration(
|
|
|
|
// color: Theme.of(context)
|
|
|
|
// .extension<StackColors>()!
|
|
|
|
// .textFieldDefaultBG,
|
|
|
|
// borderRadius: BorderRadius.circular(
|
|
|
|
// Constants.size.circularBorderRadius,
|
|
|
|
// ),
|
|
|
|
// ),
|
|
|
|
// ),
|
|
|
|
// ),
|
|
|
|
),
|
2022-11-01 17:42:33 +00:00
|
|
|
if (!isDesktop) const Spacer(),
|
|
|
|
SizedBox(
|
|
|
|
height: isDesktop ? 23 : 12,
|
|
|
|
),
|
|
|
|
Padding(
|
|
|
|
padding: isDesktop
|
|
|
|
? const EdgeInsets.symmetric(
|
|
|
|
horizontal: 32,
|
|
|
|
)
|
|
|
|
: 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",
|
|
|
|
style: isDesktop
|
|
|
|
? STextStyles.desktopTextExtraExtraSmall(context)
|
|
|
|
.copyWith(
|
|
|
|
color: Theme.of(context)
|
|
|
|
.extension<StackColors>()!
|
|
|
|
.textConfirmTotalAmount,
|
|
|
|
)
|
|
|
|
: STextStyles.titleBold12(context).copyWith(
|
|
|
|
color: Theme.of(context)
|
|
|
|
.extension<StackColors>()!
|
|
|
|
.textConfirmTotalAmount,
|
|
|
|
),
|
2022-08-26 08:11:35 +00:00
|
|
|
),
|
2022-11-01 17:42:33 +00:00
|
|
|
Text(
|
|
|
|
"${Format.satoshiAmountToPrettyString(
|
|
|
|
(transactionInfo["fee"] as int) +
|
|
|
|
(transactionInfo["recipientAmt"] as int),
|
|
|
|
ref.watch(
|
|
|
|
localeServiceChangeNotifierProvider
|
|
|
|
.select((value) => value.locale),
|
|
|
|
),
|
2022-11-23 18:31:31 +00:00
|
|
|
ref.watch(
|
|
|
|
managerProvider.select((value) => value.coin),
|
|
|
|
),
|
2022-11-01 17:42:33 +00:00
|
|
|
)} ${ref.watch(
|
|
|
|
managerProvider.select((value) => value.coin),
|
|
|
|
).ticker}",
|
|
|
|
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,
|
|
|
|
),
|
|
|
|
],
|
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,
|
2022-11-01 17:42:33 +00:00
|
|
|
onPressed: () async {
|
2022-11-14 15:05:45 +00:00
|
|
|
final dynamic unlocked;
|
|
|
|
|
2022-11-25 00:16:26 +00:00
|
|
|
final coin = ref
|
|
|
|
.read(walletsChangeNotifierProvider)
|
|
|
|
.getManager(walletId)
|
|
|
|
.coin;
|
|
|
|
|
2022-11-14 15:05:45 +00:00
|
|
|
if (isDesktop) {
|
|
|
|
unlocked = await showDialog<bool?>(
|
|
|
|
context: context,
|
|
|
|
builder: (context) => DesktopDialog(
|
|
|
|
maxWidth: 580,
|
|
|
|
maxHeight: double.infinity,
|
|
|
|
child: Column(
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
children: [
|
|
|
|
Row(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.end,
|
|
|
|
children: const [
|
|
|
|
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
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|