2022-09-03 18:37:54 +00:00
|
|
|
import 'dart:async';
|
|
|
|
|
2022-08-26 08:11:35 +00:00
|
|
|
import 'package:decimal/decimal.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter/services.dart';
|
|
|
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|
|
|
import 'package:flutter_svg/svg.dart';
|
|
|
|
import 'package:qr_flutter/qr_flutter.dart';
|
|
|
|
import 'package:stackwallet/models/exchange/change_now/exchange_transaction_status.dart';
|
|
|
|
import 'package:stackwallet/models/paymint/transactions_model.dart';
|
|
|
|
import 'package:stackwallet/notifications/show_flush_bar.dart';
|
|
|
|
import 'package:stackwallet/pages/exchange_view/edit_trade_note_view.dart';
|
2022-09-30 21:21:10 +00:00
|
|
|
import 'package:stackwallet/pages/exchange_view/send_from_view.dart';
|
2022-08-26 08:11:35 +00:00
|
|
|
import 'package:stackwallet/pages/wallet_view/transaction_views/edit_note_view.dart';
|
|
|
|
import 'package:stackwallet/pages/wallet_view/transaction_views/transaction_details_view.dart';
|
2022-09-03 18:37:54 +00:00
|
|
|
import 'package:stackwallet/providers/exchange/change_now_provider.dart';
|
2022-08-26 08:11:35 +00:00
|
|
|
import 'package:stackwallet/providers/exchange/trade_note_service_provider.dart';
|
|
|
|
import 'package:stackwallet/providers/global/trades_service_provider.dart';
|
|
|
|
import 'package:stackwallet/providers/providers.dart';
|
|
|
|
import 'package:stackwallet/utilities/assets.dart';
|
|
|
|
import 'package:stackwallet/utilities/clipboard_interface.dart';
|
|
|
|
import 'package:stackwallet/utilities/enums/coin_enum.dart';
|
|
|
|
import 'package:stackwallet/utilities/enums/flush_bar_type.dart';
|
|
|
|
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-08-26 08:11:35 +00:00
|
|
|
import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart';
|
2022-09-30 21:21:10 +00:00
|
|
|
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:tuple/tuple.dart';
|
|
|
|
import 'package:url_launcher/url_launcher.dart';
|
|
|
|
|
|
|
|
class TradeDetailsView extends ConsumerStatefulWidget {
|
|
|
|
const TradeDetailsView({
|
|
|
|
Key? key,
|
|
|
|
required this.tradeId,
|
|
|
|
required this.transactionIfSentFromStack,
|
|
|
|
required this.walletId,
|
|
|
|
required this.walletName,
|
|
|
|
this.clipboard = const ClipboardWrapper(),
|
|
|
|
}) : super(key: key);
|
|
|
|
|
|
|
|
static const String routeName = "/tradeDetails";
|
|
|
|
|
|
|
|
final String tradeId;
|
|
|
|
final ClipboardInterface clipboard;
|
|
|
|
final Transaction? transactionIfSentFromStack;
|
|
|
|
final String? walletId;
|
|
|
|
final String? walletName;
|
|
|
|
|
|
|
|
@override
|
|
|
|
ConsumerState<TradeDetailsView> createState() => _TradeDetailsViewState();
|
|
|
|
}
|
|
|
|
|
|
|
|
class _TradeDetailsViewState extends ConsumerState<TradeDetailsView> {
|
|
|
|
late final String tradeId;
|
|
|
|
late final ClipboardInterface clipboard;
|
|
|
|
late final Transaction? transactionIfSentFromStack;
|
|
|
|
late final String? walletId;
|
|
|
|
|
|
|
|
String _note = "";
|
|
|
|
|
2022-09-30 21:21:10 +00:00
|
|
|
bool isStackCoin(String ticker) {
|
|
|
|
try {
|
|
|
|
coinFromTickerCaseInsensitive(ticker);
|
|
|
|
return true;
|
|
|
|
} on ArgumentError catch (_) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-08-26 08:11:35 +00:00
|
|
|
@override
|
|
|
|
initState() {
|
|
|
|
tradeId = widget.tradeId;
|
|
|
|
clipboard = widget.clipboard;
|
|
|
|
transactionIfSentFromStack = widget.transactionIfSentFromStack;
|
|
|
|
walletId = widget.walletId;
|
2022-09-03 18:37:54 +00:00
|
|
|
|
|
|
|
WidgetsBinding.instance.addPostFrameCallback((timeStamp) async {
|
|
|
|
final trade = ref
|
|
|
|
.read(tradesServiceProvider)
|
|
|
|
.trades
|
|
|
|
.firstWhere((e) => e.id == tradeId);
|
|
|
|
|
|
|
|
if (mounted && trade.statusObject == null ||
|
|
|
|
trade.statusObject!.amountSendDecimal.isEmpty) {
|
|
|
|
final status = await ref
|
|
|
|
.read(changeNowProvider)
|
|
|
|
.getTransactionStatus(id: trade.id);
|
|
|
|
|
|
|
|
if (mounted && status.value != null) {
|
|
|
|
await ref.read(tradesServiceProvider).edit(
|
|
|
|
trade: trade.copyWith(statusObject: status.value),
|
|
|
|
shouldNotifyListeners: true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
2022-08-26 08:11:35 +00:00
|
|
|
super.initState();
|
|
|
|
}
|
|
|
|
|
|
|
|
String _fetchIconAssetForStatus(String statusString) {
|
|
|
|
ChangeNowTransactionStatus? status;
|
|
|
|
try {
|
|
|
|
if (statusString.toLowerCase().startsWith("waiting")) {
|
|
|
|
statusString = "Waiting";
|
|
|
|
}
|
|
|
|
status = changeNowTransactionStatusFromStringIgnoreCase(statusString);
|
|
|
|
} on ArgumentError catch (_) {
|
|
|
|
status = ChangeNowTransactionStatus.Failed;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (status) {
|
|
|
|
case ChangeNowTransactionStatus.New:
|
|
|
|
case ChangeNowTransactionStatus.Waiting:
|
|
|
|
case ChangeNowTransactionStatus.Confirming:
|
|
|
|
case ChangeNowTransactionStatus.Exchanging:
|
|
|
|
case ChangeNowTransactionStatus.Sending:
|
|
|
|
case ChangeNowTransactionStatus.Refunded:
|
|
|
|
case ChangeNowTransactionStatus.Verifying:
|
2022-09-23 14:33:44 +00:00
|
|
|
return Assets.svg.txExchangePending(context);
|
2022-08-26 08:11:35 +00:00
|
|
|
case ChangeNowTransactionStatus.Finished:
|
2022-09-23 14:33:44 +00:00
|
|
|
return Assets.svg.txExchange(context);
|
2022-08-26 08:11:35 +00:00
|
|
|
case ChangeNowTransactionStatus.Failed:
|
2022-09-23 14:33:44 +00:00
|
|
|
return Assets.svg.txExchangeFailed(context);
|
2022-08-26 08:11:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
final bool sentFromStack =
|
|
|
|
transactionIfSentFromStack != null && walletId != null;
|
|
|
|
|
|
|
|
final trade = ref.watch(tradesServiceProvider
|
|
|
|
.select((value) => value.trades.firstWhere((e) => e.id == tradeId)));
|
|
|
|
|
|
|
|
final bool hasTx = sentFromStack ||
|
|
|
|
!(trade.statusObject?.status == ChangeNowTransactionStatus.New ||
|
|
|
|
trade.statusObject?.status == ChangeNowTransactionStatus.Waiting ||
|
|
|
|
trade.statusObject?.status == ChangeNowTransactionStatus.Refunded ||
|
|
|
|
trade.statusObject?.status == ChangeNowTransactionStatus.Failed);
|
|
|
|
|
|
|
|
debugPrint("sentFromStack: $sentFromStack");
|
|
|
|
debugPrint("hasTx: $hasTx");
|
|
|
|
debugPrint("trade: ${trade.toString()}");
|
|
|
|
|
2022-09-03 18:37:54 +00:00
|
|
|
final sendAmount = Decimal.tryParse(
|
|
|
|
trade.statusObject?.amountSendDecimal ?? "") ??
|
|
|
|
Decimal.tryParse(trade.statusObject?.expectedSendAmountDecimal ?? "") ??
|
|
|
|
Decimal.parse("-1");
|
|
|
|
|
2022-08-26 08:11:35 +00:00
|
|
|
return Scaffold(
|
2022-09-22 23:48:50 +00:00
|
|
|
backgroundColor: Theme.of(context).extension<StackColors>()!.background,
|
2022-08-26 08:11:35 +00:00
|
|
|
appBar: AppBar(
|
2022-09-22 23:48:50 +00:00
|
|
|
backgroundColor: Theme.of(context).extension<StackColors>()!.background,
|
2022-08-26 08:11:35 +00:00
|
|
|
leading: AppBarBackButton(
|
|
|
|
onPressed: () async {
|
|
|
|
Navigator.of(context).pop();
|
|
|
|
},
|
|
|
|
),
|
|
|
|
title: Text(
|
|
|
|
"Trade details",
|
2022-09-22 22:17:21 +00:00
|
|
|
style: STextStyles.navBarTitle(context),
|
2022-08-26 08:11:35 +00:00
|
|
|
),
|
|
|
|
),
|
|
|
|
body: Padding(
|
|
|
|
padding: const EdgeInsets.all(12),
|
|
|
|
child: SingleChildScrollView(
|
|
|
|
child: Padding(
|
|
|
|
padding: const EdgeInsets.all(4),
|
|
|
|
child: Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
|
|
|
children: [
|
|
|
|
RoundedWhiteContainer(
|
|
|
|
child: Row(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
children: [
|
|
|
|
Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: [
|
|
|
|
SelectableText(
|
|
|
|
"${trade.fromCurrency.toUpperCase()} → ${trade.toCurrency.toUpperCase()}",
|
2022-09-22 22:17:21 +00:00
|
|
|
style: STextStyles.titleBold12(context),
|
2022-08-26 08:11:35 +00:00
|
|
|
),
|
|
|
|
const SizedBox(
|
|
|
|
height: 4,
|
|
|
|
),
|
|
|
|
SelectableText(
|
2022-09-03 18:37:54 +00:00
|
|
|
"${Format.localizedStringAsFixed(value: sendAmount, locale: ref.watch(
|
2022-08-26 08:11:35 +00:00
|
|
|
localeServiceChangeNotifierProvider
|
|
|
|
.select((value) => value.locale),
|
|
|
|
), decimalPlaces: trade.fromCurrency.toLowerCase() == "xmr" ? 12 : 8)} ${trade.fromCurrency.toUpperCase()}",
|
2022-09-22 22:17:21 +00:00
|
|
|
style: STextStyles.itemSubtitle(context),
|
2022-08-26 08:11:35 +00:00
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
Container(
|
|
|
|
width: 32,
|
|
|
|
height: 32,
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
borderRadius: BorderRadius.circular(32),
|
|
|
|
),
|
|
|
|
child: Center(
|
|
|
|
child: SvgPicture.asset(
|
|
|
|
_fetchIconAssetForStatus(
|
|
|
|
trade.statusObject?.status.name ??
|
|
|
|
trade.statusString),
|
|
|
|
width: 32,
|
|
|
|
height: 32,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
const SizedBox(
|
|
|
|
height: 12,
|
|
|
|
),
|
|
|
|
RoundedWhiteContainer(
|
|
|
|
child: Row(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
children: [
|
|
|
|
Text(
|
|
|
|
"Status",
|
2022-09-22 22:17:21 +00:00
|
|
|
style: STextStyles.itemSubtitle(context),
|
2022-08-26 08:11:35 +00:00
|
|
|
),
|
|
|
|
const SizedBox(
|
|
|
|
height: 4,
|
|
|
|
),
|
|
|
|
SelectableText(
|
|
|
|
trade.statusObject?.status.name ?? trade.statusString,
|
2022-09-22 22:17:21 +00:00
|
|
|
style: STextStyles.itemSubtitle(context).copyWith(
|
2022-08-26 08:11:35 +00:00
|
|
|
color: trade.statusObject != null
|
2022-09-22 23:48:50 +00:00
|
|
|
? Theme.of(context)
|
|
|
|
.extension<StackColors>()!
|
2022-09-21 21:59:52 +00:00
|
|
|
.colorForStatus(trade.statusObject!.status)
|
2022-09-22 23:48:50 +00:00
|
|
|
: Theme.of(context)
|
|
|
|
.extension<StackColors>()!
|
|
|
|
.accentColorDark,
|
2022-08-26 08:11:35 +00:00
|
|
|
),
|
|
|
|
),
|
|
|
|
// ),
|
|
|
|
// ),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
2022-09-03 18:37:54 +00:00
|
|
|
if (!sentFromStack && !hasTx)
|
2022-08-26 08:11:35 +00:00
|
|
|
const SizedBox(
|
|
|
|
height: 12,
|
|
|
|
),
|
|
|
|
if (!sentFromStack && !hasTx)
|
|
|
|
RoundedContainer(
|
2022-09-22 23:48:50 +00:00
|
|
|
color: Theme.of(context)
|
|
|
|
.extension<StackColors>()!
|
|
|
|
.warningBackground,
|
2022-08-26 08:11:35 +00:00
|
|
|
child: RichText(
|
|
|
|
text: TextSpan(
|
2022-09-03 18:37:54 +00:00
|
|
|
text:
|
|
|
|
"You must send at least ${sendAmount.toStringAsFixed(
|
2022-08-26 08:11:35 +00:00
|
|
|
trade.fromCurrency.toLowerCase() == "xmr" ? 12 : 8,
|
|
|
|
)} ${trade.fromCurrency.toUpperCase()}. ",
|
2022-09-24 21:52:03 +00:00
|
|
|
style: STextStyles.label700(context).copyWith(
|
2022-09-22 23:48:50 +00:00
|
|
|
color: Theme.of(context)
|
|
|
|
.extension<StackColors>()!
|
|
|
|
.warningForeground,
|
2022-08-26 08:11:35 +00:00
|
|
|
),
|
|
|
|
children: [
|
|
|
|
TextSpan(
|
2022-09-03 18:37:54 +00:00
|
|
|
text:
|
|
|
|
"If you send less than ${sendAmount.toStringAsFixed(
|
2022-08-26 08:11:35 +00:00
|
|
|
trade.fromCurrency.toLowerCase() == "xmr"
|
|
|
|
? 12
|
|
|
|
: 8,
|
|
|
|
)} ${trade.fromCurrency.toUpperCase()}, your transaction may not be converted and it may not be refunded.",
|
2022-09-22 22:17:21 +00:00
|
|
|
style: STextStyles.label(context).copyWith(
|
2022-09-22 23:48:50 +00:00
|
|
|
color: Theme.of(context)
|
|
|
|
.extension<StackColors>()!
|
|
|
|
.warningForeground,
|
2022-08-26 08:11:35 +00:00
|
|
|
),
|
|
|
|
),
|
|
|
|
]),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
if (sentFromStack)
|
|
|
|
const SizedBox(
|
|
|
|
height: 12,
|
|
|
|
),
|
|
|
|
if (sentFromStack)
|
|
|
|
RoundedWhiteContainer(
|
|
|
|
child: Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: [
|
|
|
|
Text(
|
|
|
|
"Sent from",
|
2022-09-22 22:17:21 +00:00
|
|
|
style: STextStyles.itemSubtitle(context),
|
2022-08-26 08:11:35 +00:00
|
|
|
),
|
|
|
|
const SizedBox(
|
|
|
|
height: 4,
|
|
|
|
),
|
|
|
|
SelectableText(
|
|
|
|
widget.walletName!,
|
2022-09-22 22:17:21 +00:00
|
|
|
style: STextStyles.itemSubtitle12(context),
|
2022-08-26 08:11:35 +00:00
|
|
|
),
|
|
|
|
const SizedBox(
|
|
|
|
height: 10,
|
|
|
|
),
|
|
|
|
GestureDetector(
|
|
|
|
onTap: () {
|
|
|
|
final Coin coin = coinFromTickerCaseInsensitive(
|
|
|
|
trade.fromCurrency);
|
|
|
|
|
|
|
|
Navigator.of(context).pushNamed(
|
|
|
|
TransactionDetailsView.routeName,
|
|
|
|
arguments: Tuple3(
|
|
|
|
transactionIfSentFromStack!, coin, walletId!),
|
|
|
|
);
|
|
|
|
},
|
|
|
|
child: Text(
|
|
|
|
"View transaction",
|
2022-09-22 22:17:21 +00:00
|
|
|
style: STextStyles.link2(context),
|
2022-08-26 08:11:35 +00:00
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
if (sentFromStack)
|
|
|
|
const SizedBox(
|
|
|
|
height: 12,
|
|
|
|
),
|
|
|
|
if (sentFromStack)
|
|
|
|
RoundedWhiteContainer(
|
|
|
|
child: Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: [
|
|
|
|
Text(
|
|
|
|
"ChangeNOW address",
|
2022-09-22 22:17:21 +00:00
|
|
|
style: STextStyles.itemSubtitle(context),
|
2022-08-26 08:11:35 +00:00
|
|
|
),
|
|
|
|
const SizedBox(
|
|
|
|
height: 4,
|
|
|
|
),
|
|
|
|
SelectableText(
|
|
|
|
trade.payinAddress,
|
2022-09-22 22:17:21 +00:00
|
|
|
style: STextStyles.itemSubtitle12(context),
|
2022-08-26 08:11:35 +00:00
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
if (!sentFromStack && !hasTx)
|
|
|
|
const SizedBox(
|
|
|
|
height: 12,
|
|
|
|
),
|
|
|
|
if (!sentFromStack && !hasTx)
|
|
|
|
RoundedWhiteContainer(
|
|
|
|
child: Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: [
|
2022-09-30 19:41:40 +00:00
|
|
|
Row(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
children: [
|
|
|
|
Text(
|
|
|
|
"Send ${trade.fromCurrency.toUpperCase()} to this address",
|
|
|
|
style: STextStyles.itemSubtitle(context),
|
|
|
|
),
|
|
|
|
GestureDetector(
|
|
|
|
onTap: () async {
|
|
|
|
final address = trade.payinAddress;
|
|
|
|
await Clipboard.setData(
|
|
|
|
ClipboardData(
|
|
|
|
text: address,
|
|
|
|
),
|
|
|
|
);
|
|
|
|
unawaited(showFloatingFlushBar(
|
|
|
|
type: FlushBarType.info,
|
|
|
|
message: "Copied to clipboard",
|
|
|
|
context: context,
|
|
|
|
));
|
|
|
|
},
|
|
|
|
child: Row(
|
|
|
|
children: [
|
|
|
|
SvgPicture.asset(
|
|
|
|
Assets.svg.copy,
|
|
|
|
width: 12,
|
|
|
|
height: 12,
|
|
|
|
color: Theme.of(context)
|
|
|
|
.extension<StackColors>()!
|
|
|
|
.infoItemIcons,
|
|
|
|
),
|
|
|
|
const SizedBox(
|
|
|
|
width: 4,
|
|
|
|
),
|
|
|
|
Text(
|
|
|
|
"Copy",
|
|
|
|
style: STextStyles.link2(context),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
2022-08-26 08:11:35 +00:00
|
|
|
),
|
|
|
|
const SizedBox(
|
|
|
|
height: 4,
|
|
|
|
),
|
|
|
|
SelectableText(
|
|
|
|
trade.payinAddress,
|
2022-09-22 22:17:21 +00:00
|
|
|
style: STextStyles.itemSubtitle12(context),
|
2022-08-26 08:11:35 +00:00
|
|
|
),
|
|
|
|
const SizedBox(
|
|
|
|
height: 10,
|
|
|
|
),
|
|
|
|
GestureDetector(
|
|
|
|
onTap: () {
|
|
|
|
showDialog<dynamic>(
|
|
|
|
context: context,
|
|
|
|
useSafeArea: false,
|
|
|
|
barrierDismissible: true,
|
|
|
|
builder: (_) {
|
|
|
|
final width =
|
|
|
|
MediaQuery.of(context).size.width / 2;
|
|
|
|
return StackDialogBase(
|
|
|
|
child: Column(
|
|
|
|
crossAxisAlignment:
|
|
|
|
CrossAxisAlignment.stretch,
|
|
|
|
children: [
|
|
|
|
Center(
|
|
|
|
child: Text(
|
2022-09-22 14:10:25 +00:00
|
|
|
"Send ${trade.fromCurrency.toUpperCase()} to this address",
|
2022-09-22 22:17:21 +00:00
|
|
|
style:
|
|
|
|
STextStyles.pageTitleH2(context),
|
2022-08-26 08:11:35 +00:00
|
|
|
),
|
|
|
|
),
|
|
|
|
const SizedBox(
|
|
|
|
height: 12,
|
|
|
|
),
|
|
|
|
Center(
|
|
|
|
child: RepaintBoundary(
|
|
|
|
// key: _qrKey,
|
|
|
|
child: SizedBox(
|
|
|
|
width: width + 20,
|
|
|
|
height: width + 20,
|
|
|
|
child: QrImage(
|
2022-09-21 21:59:52 +00:00
|
|
|
data: trade.payinAddress,
|
|
|
|
size: width,
|
2022-09-22 23:48:50 +00:00
|
|
|
backgroundColor: Theme.of(
|
|
|
|
context)
|
|
|
|
.extension<StackColors>()!
|
|
|
|
.popupBG,
|
|
|
|
foregroundColor: Theme.of(
|
|
|
|
context)
|
|
|
|
.extension<StackColors>()!
|
2022-09-21 21:59:52 +00:00
|
|
|
.accentColorDark),
|
2022-08-26 08:11:35 +00:00
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
const SizedBox(
|
|
|
|
height: 12,
|
|
|
|
),
|
|
|
|
Center(
|
|
|
|
child: SizedBox(
|
|
|
|
width: width,
|
|
|
|
child: TextButton(
|
|
|
|
onPressed: () async {
|
|
|
|
// await _capturePng(true);
|
|
|
|
Navigator.of(context).pop();
|
|
|
|
},
|
2022-09-22 23:48:50 +00:00
|
|
|
style: Theme.of(context)
|
|
|
|
.extension<StackColors>()!
|
2022-09-21 00:46:07 +00:00
|
|
|
.getSecondaryEnabledButtonColor(
|
|
|
|
context),
|
2022-08-26 08:11:35 +00:00
|
|
|
child: Text(
|
|
|
|
"Cancel",
|
2022-09-22 22:17:21 +00:00
|
|
|
style: STextStyles.button(context)
|
2022-09-21 21:59:52 +00:00
|
|
|
.copyWith(
|
2022-09-22 23:48:50 +00:00
|
|
|
color: Theme.of(context)
|
|
|
|
.extension<
|
|
|
|
StackColors>()!
|
2022-09-21 21:59:52 +00:00
|
|
|
.accentColorDark),
|
2022-08-26 08:11:35 +00:00
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
);
|
|
|
|
},
|
|
|
|
);
|
|
|
|
},
|
|
|
|
child: Row(
|
|
|
|
children: [
|
|
|
|
SvgPicture.asset(
|
2022-09-22 14:10:25 +00:00
|
|
|
Assets.svg.qrcode,
|
|
|
|
width: 12,
|
|
|
|
height: 12,
|
2022-09-22 23:48:50 +00:00
|
|
|
color: Theme.of(context)
|
|
|
|
.extension<StackColors>()!
|
|
|
|
.infoItemIcons,
|
2022-08-26 08:11:35 +00:00
|
|
|
),
|
|
|
|
const SizedBox(
|
|
|
|
width: 4,
|
|
|
|
),
|
|
|
|
Text(
|
2022-09-22 14:10:25 +00:00
|
|
|
"Show QR code",
|
2022-09-22 22:17:21 +00:00
|
|
|
style: STextStyles.link2(context),
|
2022-08-26 08:11:35 +00:00
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
const SizedBox(
|
|
|
|
height: 12,
|
|
|
|
),
|
|
|
|
RoundedWhiteContainer(
|
|
|
|
child: Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: [
|
|
|
|
Row(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
children: [
|
|
|
|
Text(
|
|
|
|
"Trade note",
|
2022-09-22 22:17:21 +00:00
|
|
|
style: STextStyles.itemSubtitle(context),
|
2022-08-26 08:11:35 +00:00
|
|
|
),
|
|
|
|
GestureDetector(
|
|
|
|
onTap: () {
|
|
|
|
Navigator.of(context).pushNamed(
|
|
|
|
EditTradeNoteView.routeName,
|
|
|
|
arguments: Tuple2(
|
|
|
|
tradeId,
|
|
|
|
ref
|
|
|
|
.read(tradeNoteServiceProvider)
|
|
|
|
.getNote(tradeId: tradeId),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
},
|
|
|
|
child: Row(
|
|
|
|
children: [
|
|
|
|
SvgPicture.asset(
|
|
|
|
Assets.svg.pencil,
|
|
|
|
width: 10,
|
|
|
|
height: 10,
|
2022-09-22 23:48:50 +00:00
|
|
|
color: Theme.of(context)
|
|
|
|
.extension<StackColors>()!
|
|
|
|
.infoItemIcons,
|
2022-08-26 08:11:35 +00:00
|
|
|
),
|
|
|
|
const SizedBox(
|
|
|
|
width: 4,
|
|
|
|
),
|
|
|
|
Text(
|
|
|
|
"Edit",
|
2022-09-22 22:17:21 +00:00
|
|
|
style: STextStyles.link2(context),
|
2022-08-26 08:11:35 +00:00
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
const SizedBox(
|
|
|
|
height: 4,
|
|
|
|
),
|
|
|
|
SelectableText(
|
|
|
|
ref.watch(tradeNoteServiceProvider.select(
|
|
|
|
(value) => value.getNote(tradeId: tradeId))),
|
2022-09-22 22:17:21 +00:00
|
|
|
style: STextStyles.itemSubtitle12(context),
|
2022-08-26 08:11:35 +00:00
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
if (sentFromStack)
|
|
|
|
const SizedBox(
|
|
|
|
height: 12,
|
|
|
|
),
|
|
|
|
if (sentFromStack)
|
|
|
|
RoundedWhiteContainer(
|
|
|
|
child: Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: [
|
|
|
|
Row(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
children: [
|
|
|
|
Text(
|
|
|
|
"Transaction note",
|
2022-09-22 22:17:21 +00:00
|
|
|
style: STextStyles.itemSubtitle(context),
|
2022-08-26 08:11:35 +00:00
|
|
|
),
|
|
|
|
GestureDetector(
|
|
|
|
onTap: () {
|
|
|
|
Navigator.of(context).pushNamed(
|
|
|
|
EditNoteView.routeName,
|
|
|
|
arguments: Tuple3(
|
|
|
|
transactionIfSentFromStack!.txid,
|
|
|
|
walletId!,
|
|
|
|
_note,
|
|
|
|
),
|
|
|
|
);
|
|
|
|
},
|
|
|
|
child: Row(
|
|
|
|
children: [
|
|
|
|
SvgPicture.asset(
|
|
|
|
Assets.svg.pencil,
|
|
|
|
width: 10,
|
|
|
|
height: 10,
|
2022-09-22 23:48:50 +00:00
|
|
|
color: Theme.of(context)
|
|
|
|
.extension<StackColors>()!
|
|
|
|
.infoItemIcons,
|
2022-08-26 08:11:35 +00:00
|
|
|
),
|
|
|
|
const SizedBox(
|
|
|
|
width: 4,
|
|
|
|
),
|
|
|
|
Text(
|
|
|
|
"Edit",
|
2022-09-22 22:17:21 +00:00
|
|
|
style: STextStyles.link2(context),
|
2022-08-26 08:11:35 +00:00
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
const SizedBox(
|
|
|
|
height: 4,
|
|
|
|
),
|
|
|
|
FutureBuilder(
|
|
|
|
future: ref.watch(
|
|
|
|
notesServiceChangeNotifierProvider(walletId!)
|
|
|
|
.select((value) => value.getNoteFor(
|
|
|
|
txid: transactionIfSentFromStack!.txid))),
|
|
|
|
builder:
|
|
|
|
(builderContext, AsyncSnapshot<String> snapshot) {
|
|
|
|
if (snapshot.connectionState ==
|
|
|
|
ConnectionState.done &&
|
|
|
|
snapshot.hasData) {
|
|
|
|
_note = snapshot.data ?? "";
|
|
|
|
}
|
|
|
|
return SelectableText(
|
|
|
|
_note,
|
2022-09-22 22:17:21 +00:00
|
|
|
style: STextStyles.itemSubtitle12(context),
|
2022-08-26 08:11:35 +00:00
|
|
|
);
|
|
|
|
},
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
const SizedBox(
|
|
|
|
height: 12,
|
|
|
|
),
|
|
|
|
RoundedWhiteContainer(
|
|
|
|
child: Row(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
children: [
|
|
|
|
Text(
|
|
|
|
"Date",
|
2022-09-22 22:17:21 +00:00
|
|
|
style: STextStyles.itemSubtitle(context),
|
2022-08-26 08:11:35 +00:00
|
|
|
),
|
|
|
|
// Flexible(
|
|
|
|
// child: FittedBox(
|
|
|
|
// fit: BoxFit.scaleDown,
|
|
|
|
// child:
|
|
|
|
SelectableText(
|
|
|
|
Format.extractDateFrom(
|
|
|
|
trade.date.millisecondsSinceEpoch ~/ 1000),
|
2022-09-22 22:17:21 +00:00
|
|
|
style: STextStyles.itemSubtitle12(context),
|
2022-08-26 08:11:35 +00:00
|
|
|
),
|
|
|
|
// ),
|
|
|
|
// ),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
const SizedBox(
|
|
|
|
height: 12,
|
|
|
|
),
|
|
|
|
RoundedWhiteContainer(
|
|
|
|
child: Row(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
children: [
|
|
|
|
Text(
|
|
|
|
"Exchange",
|
2022-09-22 22:17:21 +00:00
|
|
|
style: STextStyles.itemSubtitle(context),
|
2022-08-26 08:11:35 +00:00
|
|
|
),
|
|
|
|
// Flexible(
|
|
|
|
// child: FittedBox(
|
|
|
|
// fit: BoxFit.scaleDown,
|
|
|
|
// child:
|
|
|
|
SelectableText(
|
|
|
|
"ChangeNOW",
|
2022-09-22 22:17:21 +00:00
|
|
|
style: STextStyles.itemSubtitle12(context),
|
2022-08-26 08:11:35 +00:00
|
|
|
),
|
|
|
|
// ),
|
|
|
|
// ),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
const SizedBox(
|
|
|
|
height: 12,
|
|
|
|
),
|
|
|
|
RoundedWhiteContainer(
|
|
|
|
child: Row(
|
|
|
|
children: [
|
|
|
|
Text(
|
|
|
|
"Trade ID",
|
2022-09-22 22:17:21 +00:00
|
|
|
style: STextStyles.itemSubtitle(context),
|
2022-08-26 08:11:35 +00:00
|
|
|
),
|
|
|
|
const Spacer(),
|
|
|
|
Row(
|
|
|
|
children: [
|
|
|
|
Text(
|
|
|
|
trade.id,
|
2022-09-22 22:17:21 +00:00
|
|
|
style: STextStyles.itemSubtitle12(context),
|
2022-08-26 08:11:35 +00:00
|
|
|
),
|
|
|
|
const SizedBox(
|
|
|
|
width: 10,
|
|
|
|
),
|
|
|
|
GestureDetector(
|
|
|
|
onTap: () async {
|
|
|
|
final data = ClipboardData(text: trade.id);
|
|
|
|
await clipboard.setData(data);
|
2022-09-03 18:37:54 +00:00
|
|
|
unawaited(showFloatingFlushBar(
|
2022-08-26 08:11:35 +00:00
|
|
|
type: FlushBarType.info,
|
|
|
|
message: "Copied to clipboard",
|
|
|
|
context: context,
|
2022-09-03 18:37:54 +00:00
|
|
|
));
|
2022-08-26 08:11:35 +00:00
|
|
|
},
|
|
|
|
child: SvgPicture.asset(
|
|
|
|
Assets.svg.copy,
|
2022-09-22 23:48:50 +00:00
|
|
|
color: Theme.of(context)
|
|
|
|
.extension<StackColors>()!
|
|
|
|
.infoItemIcons,
|
2022-08-26 08:11:35 +00:00
|
|
|
width: 12,
|
|
|
|
),
|
|
|
|
)
|
|
|
|
],
|
|
|
|
)
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
const SizedBox(
|
|
|
|
height: 12,
|
|
|
|
),
|
|
|
|
RoundedWhiteContainer(
|
|
|
|
child: Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: [
|
|
|
|
Text(
|
|
|
|
"Tracking",
|
2022-09-22 22:17:21 +00:00
|
|
|
style: STextStyles.itemSubtitle(context),
|
2022-08-26 08:11:35 +00:00
|
|
|
),
|
|
|
|
const SizedBox(
|
|
|
|
height: 4,
|
|
|
|
),
|
|
|
|
GestureDetector(
|
|
|
|
onTap: () {
|
|
|
|
final url =
|
|
|
|
"https://changenow.io/exchange/txs/${trade.id}";
|
|
|
|
launchUrl(
|
|
|
|
Uri.parse(url),
|
|
|
|
mode: LaunchMode.externalApplication,
|
|
|
|
);
|
|
|
|
},
|
|
|
|
child: Text(
|
|
|
|
"https://changenow.io/exchange/txs/${trade.id}",
|
2022-09-22 22:17:21 +00:00
|
|
|
style: STextStyles.link2(context),
|
2022-08-26 08:11:35 +00:00
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
const SizedBox(
|
|
|
|
height: 12,
|
|
|
|
),
|
2022-09-30 21:21:10 +00:00
|
|
|
if (isStackCoin(trade.fromCurrency) &&
|
|
|
|
trade.statusObject != null &&
|
|
|
|
(trade.statusObject!.status ==
|
|
|
|
ChangeNowTransactionStatus.New ||
|
|
|
|
trade.statusObject!.status ==
|
|
|
|
ChangeNowTransactionStatus.Waiting))
|
|
|
|
SecondaryButton(
|
|
|
|
label: "Send from Stack",
|
|
|
|
onPressed: () {
|
|
|
|
final amount = sendAmount;
|
|
|
|
final address = trade.payinAddress;
|
|
|
|
|
|
|
|
final coin =
|
|
|
|
coinFromTickerCaseInsensitive(trade.fromCurrency);
|
|
|
|
|
|
|
|
Navigator.of(context).pushNamed(
|
|
|
|
SendFromView.routeName,
|
|
|
|
arguments: Tuple4(
|
|
|
|
coin,
|
|
|
|
amount,
|
|
|
|
address,
|
|
|
|
trade,
|
|
|
|
),
|
|
|
|
);
|
|
|
|
},
|
|
|
|
),
|
2022-08-26 08:11:35 +00:00
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|