2022-09-21 21:59:52 +00:00
|
|
|
import 'dart:async';
|
|
|
|
|
2022-08-26 08:11:35 +00:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
2022-10-03 00:54:35 +00:00
|
|
|
import 'package:stackwallet/models/exchange/response_objects/trade.dart';
|
2022-08-26 08:11:35 +00:00
|
|
|
import 'package:stackwallet/models/trade_wallet_lookup.dart';
|
|
|
|
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-12-01 14:48:23 +00:00
|
|
|
import 'package:stackwallet/pages_desktop_specific/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';
|
|
|
|
import 'package:stackwallet/route_generator.dart';
|
2022-11-07 17:46:17 +00:00
|
|
|
import 'package:stackwallet/services/coins/firo/firo_wallet.dart';
|
2023-04-06 21:24:56 +00:00
|
|
|
import 'package:stackwallet/utilities/amount/amount.dart';
|
2022-11-22 17:21:43 +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-09-22 23:48:50 +00:00
|
|
|
import 'package:stackwallet/utilities/theme/stack_colors.dart';
|
2022-11-22 17:21:43 +00:00
|
|
|
import 'package:stackwallet/utilities/util.dart';
|
2022-11-25 19:24:01 +00:00
|
|
|
import 'package:stackwallet/widgets/background.dart';
|
2022-11-22 17:21:43 +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-22 17:21:43 +00:00
|
|
|
import 'package:stackwallet/widgets/desktop/desktop_dialog.dart';
|
|
|
|
import 'package:stackwallet/widgets/desktop/desktop_dialog_close_button.dart';
|
|
|
|
import 'package:stackwallet/widgets/desktop/primary_button.dart';
|
|
|
|
import 'package:stackwallet/widgets/desktop/secondary_button.dart';
|
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';
|
|
|
|
import 'package:uuid/uuid.dart';
|
|
|
|
|
|
|
|
class ConfirmChangeNowSendView extends ConsumerStatefulWidget {
|
|
|
|
const ConfirmChangeNowSendView({
|
|
|
|
Key? key,
|
|
|
|
required this.transactionInfo,
|
|
|
|
required this.walletId,
|
|
|
|
this.routeOnSuccessName = WalletView.routeName,
|
|
|
|
required this.trade,
|
2022-11-07 17:46:17 +00:00
|
|
|
this.shouldSendPublicFiroFunds,
|
2022-11-22 21:32:06 +00:00
|
|
|
this.fromDesktopStep4 = false,
|
2022-08-26 08:11:35 +00:00
|
|
|
}) : super(key: key);
|
|
|
|
|
|
|
|
static const String routeName = "/confirmChangeNowSend";
|
|
|
|
|
|
|
|
final Map<String, dynamic> transactionInfo;
|
|
|
|
final String walletId;
|
|
|
|
final String routeOnSuccessName;
|
2022-10-03 00:54:35 +00:00
|
|
|
final Trade trade;
|
2022-11-07 17:46:17 +00:00
|
|
|
final bool? shouldSendPublicFiroFunds;
|
2022-11-22 21:32:06 +00:00
|
|
|
final bool fromDesktopStep4;
|
2022-08-26 08:11:35 +00:00
|
|
|
|
|
|
|
@override
|
|
|
|
ConsumerState<ConfirmChangeNowSendView> createState() =>
|
|
|
|
_ConfirmChangeNowSendViewState();
|
|
|
|
}
|
|
|
|
|
|
|
|
class _ConfirmChangeNowSendViewState
|
|
|
|
extends ConsumerState<ConfirmChangeNowSendView> {
|
|
|
|
late final Map<String, dynamic> transactionInfo;
|
|
|
|
late final String walletId;
|
|
|
|
late final String routeOnSuccessName;
|
2022-10-03 00:54:35 +00:00
|
|
|
late final Trade trade;
|
2022-08-26 08:11:35 +00:00
|
|
|
|
2023-01-16 00:09:11 +00:00
|
|
|
final isDesktop = Util.isDesktop;
|
|
|
|
|
2022-08-26 08:11:35 +00:00
|
|
|
Future<void> _attemptSend(BuildContext context) async {
|
2023-03-13 17:49:39 +00:00
|
|
|
final manager =
|
|
|
|
ref.read(walletsChangeNotifierProvider).getManager(walletId);
|
2022-11-22 17:21:43 +00:00
|
|
|
unawaited(
|
|
|
|
showDialog<void>(
|
|
|
|
context: context,
|
|
|
|
useSafeArea: false,
|
|
|
|
barrierDismissible: false,
|
|
|
|
builder: (context) {
|
2023-03-13 17:49:39 +00:00
|
|
|
return SendingTransactionDialog(
|
|
|
|
coin: manager.coin,
|
|
|
|
);
|
2022-11-22 17:21:43 +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
|
|
|
),
|
|
|
|
);
|
|
|
|
|
|
|
|
late String txid;
|
|
|
|
Future<String> txidFuture;
|
|
|
|
|
2022-08-26 08:11:35 +00:00
|
|
|
final String note = transactionInfo["note"] as String? ?? "";
|
|
|
|
|
|
|
|
try {
|
2022-11-07 17:46:17 +00:00
|
|
|
if (widget.shouldSendPublicFiroFunds == true) {
|
2023-03-13 17:49:39 +00:00
|
|
|
txidFuture = (manager.wallet as FiroWallet)
|
2022-11-07 17:46:17 +00:00
|
|
|
.confirmSendPublic(txData: transactionInfo);
|
|
|
|
} else {
|
2023-03-13 17:49:39 +00:00
|
|
|
txidFuture = manager.confirmSend(txData: transactionInfo);
|
2022-11-07 17:46:17 +00:00
|
|
|
}
|
|
|
|
|
2022-09-21 21:59:52 +00:00
|
|
|
unawaited(manager.refresh());
|
2022-08-26 08:11:35 +00:00
|
|
|
|
2023-03-13 17:49:39 +00:00
|
|
|
final results = await Future.wait([
|
|
|
|
txidFuture,
|
|
|
|
time,
|
|
|
|
]);
|
|
|
|
|
|
|
|
txid = results.first as String;
|
|
|
|
|
2022-08-26 08:11:35 +00:00
|
|
|
// save note
|
2022-09-21 21:59:52 +00:00
|
|
|
await ref
|
2022-08-26 08:11:35 +00:00
|
|
|
.read(notesServiceChangeNotifierProvider(walletId))
|
|
|
|
.editOrAddNote(txid: txid, note: note);
|
|
|
|
|
|
|
|
await ref.read(tradeSentFromStackLookupProvider).save(
|
|
|
|
tradeWalletLookup: TradeWalletLookup(
|
|
|
|
uuid: const Uuid().v1(),
|
|
|
|
txid: txid,
|
2022-10-03 00:54:35 +00:00
|
|
|
tradeId: trade.tradeId,
|
2022-08-26 08:11:35 +00:00
|
|
|
walletIds: [walletId],
|
|
|
|
),
|
|
|
|
);
|
|
|
|
|
|
|
|
// pop back to wallet
|
|
|
|
if (mounted) {
|
2022-11-22 17:21:43 +00:00
|
|
|
if (Util.isDesktop) {
|
|
|
|
Navigator.of(context, rootNavigator: true).pop();
|
2022-11-22 21:32:06 +00:00
|
|
|
|
|
|
|
// stupid hack
|
|
|
|
if (widget.fromDesktopStep4) {
|
|
|
|
Navigator.of(context, rootNavigator: true).pop();
|
|
|
|
Navigator.of(context, rootNavigator: true).pop();
|
|
|
|
Navigator.of(context, rootNavigator: true).pop();
|
|
|
|
Navigator.of(context, rootNavigator: true).pop();
|
|
|
|
Navigator.of(context, rootNavigator: true).pop();
|
|
|
|
}
|
2022-11-22 17:21:43 +00:00
|
|
|
}
|
2022-11-22 21:32:06 +00:00
|
|
|
|
2022-08-26 08:11:35 +00:00
|
|
|
Navigator.of(context).popUntil(ModalRoute.withName(routeOnSuccessName));
|
|
|
|
}
|
|
|
|
} catch (e) {
|
|
|
|
// pop sending dialog
|
|
|
|
Navigator.of(context).pop();
|
|
|
|
|
2022-09-21 00:46:07 +00:00
|
|
|
await showDialog<dynamic>(
|
2022-08-26 08:11:35 +00:00
|
|
|
context: context,
|
|
|
|
useSafeArea: false,
|
|
|
|
barrierDismissible: true,
|
|
|
|
builder: (context) {
|
|
|
|
return StackDialog(
|
|
|
|
title: "Broadcast transaction failed",
|
|
|
|
message: e.toString(),
|
|
|
|
rightButton: TextButton(
|
2022-09-22 23:48:50 +00:00
|
|
|
style: Theme.of(context)
|
|
|
|
.extension<StackColors>()!
|
2023-01-24 19:29:12 +00:00
|
|
|
.getSecondaryEnabledButtonStyle(context),
|
2022-08-26 08:11:35 +00:00
|
|
|
child: Text(
|
|
|
|
"Ok",
|
2022-09-22 22:17:21 +00:00
|
|
|
style: STextStyles.button(context).copyWith(
|
2022-09-22 23:48:50 +00:00
|
|
|
color: Theme.of(context)
|
|
|
|
.extension<StackColors>()!
|
|
|
|
.buttonTextSecondary,
|
2022-08-26 08:11:35 +00:00
|
|
|
),
|
|
|
|
),
|
|
|
|
onPressed: () {
|
|
|
|
Navigator.of(context).pop();
|
|
|
|
},
|
|
|
|
),
|
|
|
|
);
|
|
|
|
},
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-11-22 17:21:43 +00:00
|
|
|
Future<void> _confirmSend() async {
|
|
|
|
final dynamic unlocked;
|
|
|
|
|
2022-11-25 00:16:26 +00:00
|
|
|
final coin =
|
|
|
|
ref.read(walletsChangeNotifierProvider).getManager(walletId).coin;
|
|
|
|
|
2022-11-22 17:21:43 +00:00
|
|
|
if (Util.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-22 17:21:43 +00:00
|
|
|
left: 32,
|
|
|
|
right: 32,
|
|
|
|
bottom: 32,
|
|
|
|
),
|
2022-11-25 00:16:26 +00:00
|
|
|
child: DesktopAuthSend(
|
|
|
|
coin: coin,
|
|
|
|
),
|
2022-11-22 17:21:43 +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"),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (unlocked is bool && unlocked && mounted) {
|
|
|
|
await _attemptSend(context);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-08-26 08:11:35 +00:00
|
|
|
@override
|
|
|
|
void initState() {
|
|
|
|
transactionInfo = widget.transactionInfo;
|
|
|
|
walletId = widget.walletId;
|
|
|
|
routeOnSuccessName = widget.routeOnSuccessName;
|
|
|
|
trade = widget.trade;
|
|
|
|
super.initState();
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
final managerProvider = ref.watch(walletsChangeNotifierProvider
|
|
|
|
.select((value) => value.getManagerProvider(walletId)));
|
2022-11-22 17:21:43 +00:00
|
|
|
|
|
|
|
return ConditionalParent(
|
|
|
|
condition: !isDesktop,
|
|
|
|
builder: (child) {
|
2022-11-25 19:24:01 +00:00
|
|
|
return Background(
|
|
|
|
child: Scaffold(
|
2022-11-22 17:21:43 +00:00
|
|
|
backgroundColor:
|
|
|
|
Theme.of(context).extension<StackColors>()!.background,
|
2022-11-25 19:24:01 +00:00
|
|
|
appBar: AppBar(
|
|
|
|
backgroundColor:
|
2023-01-16 00:09:11 +00:00
|
|
|
Theme.of(context).extension<StackColors>()!.backgroundAppBar,
|
2022-11-25 19:24:01 +00:00
|
|
|
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-08-26 08:11:35 +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-22 17:21:43 +00:00
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
2022-11-25 19:24:01 +00:00
|
|
|
);
|
|
|
|
},
|
|
|
|
),
|
2022-11-22 17:21:43 +00:00
|
|
|
),
|
|
|
|
);
|
|
|
|
},
|
|
|
|
child: ConditionalParent(
|
|
|
|
condition: isDesktop,
|
|
|
|
builder: (child) => DesktopDialog(
|
|
|
|
maxHeight: double.infinity,
|
|
|
|
maxWidth: 580,
|
|
|
|
child: Column(
|
|
|
|
children: [
|
|
|
|
Row(
|
|
|
|
children: [
|
|
|
|
const SizedBox(
|
|
|
|
width: 6,
|
|
|
|
),
|
|
|
|
const AppBarBackButton(
|
|
|
|
isCompact: true,
|
|
|
|
iconSize: 23,
|
|
|
|
),
|
|
|
|
const SizedBox(
|
|
|
|
width: 12,
|
|
|
|
),
|
|
|
|
Text(
|
|
|
|
"Confirm ${ref.watch(managerProvider.select((value) => value.coin)).ticker} transaction",
|
|
|
|
style: STextStyles.desktopH3(context),
|
|
|
|
)
|
|
|
|
],
|
|
|
|
),
|
|
|
|
Padding(
|
|
|
|
padding: const EdgeInsets.only(
|
|
|
|
left: 32,
|
|
|
|
right: 32,
|
|
|
|
bottom: 32,
|
2022-08-26 08:11:35 +00:00
|
|
|
),
|
2022-11-22 17:21:43 +00:00
|
|
|
child: Column(
|
|
|
|
children: [
|
|
|
|
RoundedWhiteContainer(
|
|
|
|
padding: const EdgeInsets.all(0),
|
|
|
|
borderColor: Theme.of(context)
|
|
|
|
.extension<StackColors>()!
|
|
|
|
.background,
|
|
|
|
child: child,
|
|
|
|
),
|
|
|
|
const SizedBox(
|
|
|
|
height: 16,
|
|
|
|
),
|
|
|
|
Row(
|
2022-08-26 08:11:35 +00:00
|
|
|
children: [
|
|
|
|
Text(
|
2022-11-22 17:21:43 +00:00
|
|
|
"Transaction fee",
|
|
|
|
style:
|
|
|
|
STextStyles.desktopTextExtraExtraSmall(context),
|
2022-08-26 08:11:35 +00:00
|
|
|
),
|
2022-11-22 17:21:43 +00:00
|
|
|
],
|
|
|
|
),
|
|
|
|
const SizedBox(
|
|
|
|
height: 10,
|
|
|
|
),
|
|
|
|
RoundedContainer(
|
|
|
|
color: Theme.of(context)
|
|
|
|
.extension<StackColors>()!
|
|
|
|
.textFieldDefaultBG,
|
|
|
|
child: Row(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.end,
|
|
|
|
children: [
|
|
|
|
Text(
|
2023-04-11 19:14:34 +00:00
|
|
|
"${(transactionInfo["fee"] is Amount ? transactionInfo["fee"] as Amount : (transactionInfo["fee"] as int).toAmountAsRaw(
|
|
|
|
fractionDigits: ref.watch(
|
|
|
|
managerProvider
|
|
|
|
.select((value) => value.coin.decimals),
|
|
|
|
),
|
|
|
|
)).localizedStringAsFixed(
|
|
|
|
locale: ref.watch(
|
|
|
|
localeServiceChangeNotifierProvider.select(
|
|
|
|
(value) => value.locale,
|
|
|
|
),
|
2022-11-23 18:31:31 +00:00
|
|
|
),
|
2022-11-22 17:21:43 +00:00
|
|
|
)} ${ref.watch(
|
|
|
|
managerProvider.select((value) => value.coin),
|
|
|
|
).ticker}",
|
|
|
|
style:
|
|
|
|
STextStyles.desktopTextExtraExtraSmall(context)
|
|
|
|
.copyWith(
|
|
|
|
color: Theme.of(context)
|
|
|
|
.extension<StackColors>()!
|
|
|
|
.textDark,
|
|
|
|
),
|
2022-08-26 08:11:35 +00:00
|
|
|
),
|
2022-11-22 17:21:43 +00:00
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
const SizedBox(
|
|
|
|
height: 16,
|
|
|
|
),
|
|
|
|
RoundedContainer(
|
|
|
|
color: Theme.of(context)
|
|
|
|
.extension<StackColors>()!
|
|
|
|
.snackBarBackSuccess,
|
|
|
|
child: Row(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
children: [
|
|
|
|
Text(
|
|
|
|
"Total amount",
|
|
|
|
style: STextStyles.titleBold12(context).copyWith(
|
|
|
|
color: Theme.of(context)
|
|
|
|
.extension<StackColors>()!
|
|
|
|
.textConfirmTotalAmount,
|
|
|
|
),
|
2022-08-26 08:11:35 +00:00
|
|
|
),
|
2023-04-05 22:06:31 +00:00
|
|
|
Builder(
|
|
|
|
builder: (context) {
|
|
|
|
final coin = ref.watch(
|
2022-11-23 18:31:31 +00:00
|
|
|
managerProvider.select((value) => value.coin),
|
2023-04-05 22:06:31 +00:00
|
|
|
);
|
2023-04-11 19:14:34 +00:00
|
|
|
final fee = transactionInfo["fee"] is Amount
|
|
|
|
? transactionInfo["fee"] as Amount
|
|
|
|
: (transactionInfo["fee"] as int)
|
|
|
|
.toAmountAsRaw(
|
|
|
|
fractionDigits: coin.decimals,
|
|
|
|
);
|
2023-04-05 22:06:31 +00:00
|
|
|
final amount =
|
|
|
|
transactionInfo["recipientAmt"] as Amount;
|
|
|
|
final total = amount + fee;
|
|
|
|
final locale = ref.watch(
|
|
|
|
localeServiceChangeNotifierProvider.select(
|
|
|
|
(value) => value.locale,
|
|
|
|
),
|
|
|
|
);
|
|
|
|
return Text(
|
|
|
|
"${total.localizedStringAsFixed(
|
|
|
|
locale: locale,
|
|
|
|
)}"
|
|
|
|
" ${coin.ticker}",
|
|
|
|
style: STextStyles.itemSubtitle12(context)
|
|
|
|
.copyWith(
|
|
|
|
color: Theme.of(context)
|
|
|
|
.extension<StackColors>()!
|
|
|
|
.textConfirmTotalAmount,
|
|
|
|
),
|
|
|
|
textAlign: TextAlign.right,
|
|
|
|
);
|
|
|
|
},
|
2022-08-26 08:11:35 +00:00
|
|
|
),
|
2022-11-22 17:21:43 +00:00
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
const SizedBox(
|
|
|
|
height: 16,
|
|
|
|
),
|
|
|
|
Row(
|
|
|
|
children: [
|
|
|
|
Expanded(
|
|
|
|
child: SecondaryButton(
|
|
|
|
label: "Cancel",
|
|
|
|
buttonHeight: ButtonHeight.l,
|
|
|
|
onPressed: Navigator.of(context).pop,
|
2022-08-26 08:11:35 +00:00
|
|
|
),
|
|
|
|
),
|
|
|
|
const SizedBox(
|
2022-11-22 17:21:43 +00:00
|
|
|
width: 16,
|
2022-08-26 08:11:35 +00:00
|
|
|
),
|
2022-11-22 17:21:43 +00:00
|
|
|
Expanded(
|
|
|
|
child: PrimaryButton(
|
|
|
|
label: "Send",
|
|
|
|
buttonHeight: isDesktop ? ButtonHeight.l : null,
|
|
|
|
onPressed: _confirmSend,
|
2022-08-26 08:11:35 +00:00
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
2022-11-22 17:21:43 +00:00
|
|
|
)
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
child: Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
|
|
|
children: [
|
|
|
|
ConditionalParent(
|
|
|
|
condition: isDesktop,
|
|
|
|
builder: (child) => Container(
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
color: Theme.of(context).extension<StackColors>()!.background,
|
|
|
|
borderRadius: BorderRadius.vertical(
|
|
|
|
top: Radius.circular(
|
|
|
|
Constants.size.circularBorderRadius,
|
2022-08-26 08:11:35 +00:00
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
2022-11-22 17:21:43 +00:00
|
|
|
child: Padding(
|
|
|
|
padding: const EdgeInsets.all(12),
|
|
|
|
child: Row(
|
|
|
|
children: [
|
|
|
|
child,
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
child: Text(
|
|
|
|
"Send ${ref.watch(managerProvider.select((value) => value.coin)).ticker}",
|
|
|
|
style: isDesktop
|
|
|
|
? STextStyles.desktopTextMedium(context)
|
|
|
|
: STextStyles.pageTitleH1(context),
|
2022-08-26 08:11:35 +00:00
|
|
|
),
|
|
|
|
),
|
2022-11-22 17:21:43 +00:00
|
|
|
isDesktop
|
|
|
|
? Container(
|
|
|
|
color:
|
|
|
|
Theme.of(context).extension<StackColors>()!.background,
|
|
|
|
height: 1,
|
|
|
|
)
|
|
|
|
: const SizedBox(
|
|
|
|
height: 12,
|
|
|
|
),
|
|
|
|
RoundedWhiteContainer(
|
|
|
|
child: Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
|
|
|
children: [
|
|
|
|
Text(
|
|
|
|
"Send from",
|
|
|
|
style: STextStyles.smallMed12(context),
|
|
|
|
),
|
|
|
|
const SizedBox(
|
|
|
|
height: 4,
|
|
|
|
),
|
|
|
|
Text(
|
|
|
|
ref
|
|
|
|
.watch(walletsChangeNotifierProvider)
|
|
|
|
.getManager(walletId)
|
|
|
|
.walletName,
|
|
|
|
style: STextStyles.itemSubtitle12(context),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
isDesktop
|
|
|
|
? Container(
|
|
|
|
color:
|
|
|
|
Theme.of(context).extension<StackColors>()!.background,
|
|
|
|
height: 1,
|
|
|
|
)
|
|
|
|
: const SizedBox(
|
|
|
|
height: 12,
|
|
|
|
),
|
|
|
|
RoundedWhiteContainer(
|
|
|
|
child: Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
|
|
|
children: [
|
|
|
|
Text(
|
|
|
|
"${trade.exchangeName} address",
|
|
|
|
style: STextStyles.smallMed12(context),
|
|
|
|
),
|
|
|
|
const SizedBox(
|
|
|
|
height: 4,
|
|
|
|
),
|
|
|
|
Text(
|
|
|
|
"${transactionInfo["address"] ?? "ERROR"}",
|
|
|
|
style: STextStyles.itemSubtitle12(context),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
isDesktop
|
|
|
|
? Container(
|
|
|
|
color:
|
|
|
|
Theme.of(context).extension<StackColors>()!.background,
|
|
|
|
height: 1,
|
|
|
|
)
|
|
|
|
: const SizedBox(
|
|
|
|
height: 12,
|
|
|
|
),
|
|
|
|
RoundedWhiteContainer(
|
|
|
|
child: Row(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
children: [
|
|
|
|
Text(
|
|
|
|
"Amount",
|
|
|
|
style: STextStyles.smallMed12(context),
|
|
|
|
),
|
|
|
|
ConditionalParent(
|
|
|
|
condition: isDesktop,
|
|
|
|
builder: (child) => Row(
|
|
|
|
children: [
|
|
|
|
child,
|
|
|
|
Builder(builder: (context) {
|
|
|
|
final coin = ref.watch(
|
|
|
|
walletsChangeNotifierProvider.select(
|
|
|
|
(value) => value.getManager(walletId).coin));
|
|
|
|
final price = ref.watch(
|
|
|
|
priceAnd24hChangeNotifierProvider
|
|
|
|
.select((value) => value.getPrice(coin)));
|
2023-04-05 22:06:31 +00:00
|
|
|
final amount =
|
|
|
|
transactionInfo["recipientAmt"] as Amount;
|
|
|
|
final value = (price.item1 * amount.decimal)
|
|
|
|
.toAmount(fractionDigits: 2);
|
2022-11-22 17:21:43 +00:00
|
|
|
final currency = ref.watch(prefsChangeNotifierProvider
|
|
|
|
.select((value) => value.currency));
|
2023-04-05 22:06:31 +00:00
|
|
|
final locale = ref.watch(
|
|
|
|
localeServiceChangeNotifierProvider.select(
|
|
|
|
(value) => value.locale,
|
|
|
|
),
|
|
|
|
);
|
2022-11-22 17:21:43 +00:00
|
|
|
|
|
|
|
return Text(
|
2023-04-05 22:06:31 +00:00
|
|
|
" | ${value.localizedStringAsFixed(locale: locale)} $currency",
|
2022-11-22 17:21:43 +00:00
|
|
|
style:
|
|
|
|
STextStyles.desktopTextExtraExtraSmall(context)
|
|
|
|
.copyWith(
|
|
|
|
color: Theme.of(context)
|
|
|
|
.extension<StackColors>()!
|
|
|
|
.textSubtitle2,
|
|
|
|
),
|
|
|
|
);
|
|
|
|
})
|
|
|
|
],
|
|
|
|
),
|
|
|
|
child: Text(
|
2023-04-05 22:06:31 +00:00
|
|
|
"${(transactionInfo["recipientAmt"] as Amount).localizedStringAsFixed(
|
|
|
|
locale: ref.watch(
|
|
|
|
localeServiceChangeNotifierProvider.select(
|
|
|
|
(value) => value.locale,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
)} ${ref.watch(
|
2022-11-22 17:21:43 +00:00
|
|
|
managerProvider.select((value) => value.coin),
|
|
|
|
).ticker}",
|
|
|
|
style: STextStyles.itemSubtitle12(context),
|
|
|
|
textAlign: TextAlign.right,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
isDesktop
|
|
|
|
? Container(
|
|
|
|
color:
|
|
|
|
Theme.of(context).extension<StackColors>()!.background,
|
|
|
|
height: 1,
|
|
|
|
)
|
|
|
|
: const SizedBox(
|
|
|
|
height: 12,
|
|
|
|
),
|
|
|
|
RoundedWhiteContainer(
|
|
|
|
child: Row(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
children: [
|
|
|
|
Text(
|
|
|
|
"Transaction fee",
|
|
|
|
style: STextStyles.smallMed12(context),
|
|
|
|
),
|
|
|
|
Text(
|
2023-04-11 19:14:34 +00:00
|
|
|
"${(transactionInfo["fee"] is Amount ? transactionInfo["fee"] as Amount : (transactionInfo["fee"] as int).toAmountAsRaw(fractionDigits: ref.watch(
|
|
|
|
managerProvider.select(
|
|
|
|
(value) => value.coin.decimals,
|
|
|
|
),
|
|
|
|
))).localizedStringAsFixed(
|
|
|
|
locale: ref.watch(
|
|
|
|
localeServiceChangeNotifierProvider.select(
|
|
|
|
(value) => value.locale,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
)} ${ref.watch(
|
2022-11-22 17:21:43 +00:00
|
|
|
managerProvider.select((value) => value.coin),
|
|
|
|
).ticker}",
|
|
|
|
style: STextStyles.itemSubtitle12(context),
|
|
|
|
textAlign: TextAlign.right,
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
isDesktop
|
|
|
|
? Container(
|
|
|
|
color:
|
|
|
|
Theme.of(context).extension<StackColors>()!.background,
|
|
|
|
height: 1,
|
|
|
|
)
|
|
|
|
: const SizedBox(
|
|
|
|
height: 12,
|
|
|
|
),
|
|
|
|
RoundedWhiteContainer(
|
|
|
|
child: Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
|
|
|
children: [
|
|
|
|
Text(
|
|
|
|
"Note",
|
|
|
|
style: STextStyles.smallMed12(context),
|
|
|
|
),
|
|
|
|
const SizedBox(
|
|
|
|
height: 4,
|
|
|
|
),
|
|
|
|
Text(
|
|
|
|
transactionInfo["note"] as String? ?? "",
|
|
|
|
style: STextStyles.itemSubtitle12(context),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
isDesktop
|
|
|
|
? Container(
|
|
|
|
color:
|
|
|
|
Theme.of(context).extension<StackColors>()!.background,
|
|
|
|
height: 1,
|
|
|
|
)
|
|
|
|
: const SizedBox(
|
|
|
|
height: 12,
|
|
|
|
),
|
|
|
|
RoundedWhiteContainer(
|
|
|
|
child: Row(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
children: [
|
|
|
|
Text(
|
|
|
|
"Trade ID",
|
|
|
|
style: STextStyles.smallMed12(context),
|
|
|
|
),
|
|
|
|
Text(
|
|
|
|
trade.tradeId,
|
|
|
|
style: STextStyles.itemSubtitle12(context),
|
|
|
|
textAlign: TextAlign.right,
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
if (!isDesktop)
|
|
|
|
const SizedBox(
|
|
|
|
height: 12,
|
|
|
|
),
|
|
|
|
if (!isDesktop)
|
|
|
|
RoundedContainer(
|
|
|
|
color: Theme.of(context)
|
|
|
|
.extension<StackColors>()!
|
|
|
|
.snackBarBackSuccess,
|
|
|
|
child: Row(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
children: [
|
|
|
|
Text(
|
|
|
|
"Total amount",
|
|
|
|
style: STextStyles.titleBold12(context).copyWith(
|
|
|
|
color: Theme.of(context)
|
|
|
|
.extension<StackColors>()!
|
|
|
|
.textConfirmTotalAmount,
|
|
|
|
),
|
|
|
|
),
|
2023-04-05 22:06:31 +00:00
|
|
|
Builder(
|
|
|
|
builder: (context) {
|
|
|
|
final coin = ref.watch(
|
|
|
|
managerProvider.select((value) => value.coin),
|
|
|
|
);
|
2023-04-11 19:14:34 +00:00
|
|
|
final fee = transactionInfo["fee"] is Amount
|
|
|
|
? transactionInfo["fee"] as Amount
|
|
|
|
: (transactionInfo["fee"] as int).toAmountAsRaw(
|
|
|
|
fractionDigits: coin.decimals,
|
|
|
|
);
|
2023-04-05 22:06:31 +00:00
|
|
|
final amount =
|
|
|
|
transactionInfo["recipientAmt"] as Amount;
|
|
|
|
final total = amount + fee;
|
|
|
|
final locale = ref.watch(
|
|
|
|
localeServiceChangeNotifierProvider.select(
|
|
|
|
(value) => value.locale,
|
|
|
|
),
|
|
|
|
);
|
|
|
|
return Text(
|
|
|
|
"${total.localizedStringAsFixed(
|
|
|
|
locale: locale,
|
|
|
|
)}"
|
|
|
|
" ${coin.ticker}",
|
|
|
|
style: STextStyles.itemSubtitle12(context).copyWith(
|
|
|
|
color: Theme.of(context)
|
|
|
|
.extension<StackColors>()!
|
|
|
|
.textConfirmTotalAmount,
|
|
|
|
),
|
|
|
|
textAlign: TextAlign.right,
|
|
|
|
);
|
|
|
|
},
|
2022-11-22 17:21:43 +00:00
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
if (!isDesktop)
|
|
|
|
const SizedBox(
|
|
|
|
height: 16,
|
|
|
|
),
|
|
|
|
if (!isDesktop) const Spacer(),
|
|
|
|
if (!isDesktop)
|
|
|
|
PrimaryButton(
|
|
|
|
label: "Send",
|
|
|
|
buttonHeight: isDesktop ? ButtonHeight.l : null,
|
|
|
|
onPressed: _confirmSend,
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
2022-08-26 08:11:35 +00:00
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|