mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2025-01-24 11:15:58 +00:00
trade details view bug fixes
This commit is contained in:
parent
57814fab4b
commit
7dc44eb7da
1 changed files with 36 additions and 12 deletions
|
@ -1,3 +1,5 @@
|
||||||
|
import 'dart:async';
|
||||||
|
|
||||||
import 'package:decimal/decimal.dart';
|
import 'package:decimal/decimal.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
|
@ -10,6 +12,7 @@ import 'package:stackwallet/notifications/show_flush_bar.dart';
|
||||||
import 'package:stackwallet/pages/exchange_view/edit_trade_note_view.dart';
|
import 'package:stackwallet/pages/exchange_view/edit_trade_note_view.dart';
|
||||||
import 'package:stackwallet/pages/wallet_view/transaction_views/edit_note_view.dart';
|
import 'package:stackwallet/pages/wallet_view/transaction_views/edit_note_view.dart';
|
||||||
import 'package:stackwallet/pages/wallet_view/transaction_views/transaction_details_view.dart';
|
import 'package:stackwallet/pages/wallet_view/transaction_views/transaction_details_view.dart';
|
||||||
|
import 'package:stackwallet/providers/exchange/change_now_provider.dart';
|
||||||
import 'package:stackwallet/providers/exchange/trade_note_service_provider.dart';
|
import 'package:stackwallet/providers/exchange/trade_note_service_provider.dart';
|
||||||
import 'package:stackwallet/providers/global/trades_service_provider.dart';
|
import 'package:stackwallet/providers/global/trades_service_provider.dart';
|
||||||
import 'package:stackwallet/providers/providers.dart';
|
import 'package:stackwallet/providers/providers.dart';
|
||||||
|
@ -63,6 +66,26 @@ class _TradeDetailsViewState extends ConsumerState<TradeDetailsView> {
|
||||||
clipboard = widget.clipboard;
|
clipboard = widget.clipboard;
|
||||||
transactionIfSentFromStack = widget.transactionIfSentFromStack;
|
transactionIfSentFromStack = widget.transactionIfSentFromStack;
|
||||||
walletId = widget.walletId;
|
walletId = widget.walletId;
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
super.initState();
|
super.initState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,8 +100,6 @@ class _TradeDetailsViewState extends ConsumerState<TradeDetailsView> {
|
||||||
status = ChangeNowTransactionStatus.Failed;
|
status = ChangeNowTransactionStatus.Failed;
|
||||||
}
|
}
|
||||||
|
|
||||||
debugPrint("statusstatusstatusstatus: $status");
|
|
||||||
debugPrint("statusstatusstatusstatusSTRING: $statusString");
|
|
||||||
switch (status) {
|
switch (status) {
|
||||||
case ChangeNowTransactionStatus.New:
|
case ChangeNowTransactionStatus.New:
|
||||||
case ChangeNowTransactionStatus.Waiting:
|
case ChangeNowTransactionStatus.Waiting:
|
||||||
|
@ -113,6 +134,11 @@ class _TradeDetailsViewState extends ConsumerState<TradeDetailsView> {
|
||||||
debugPrint("hasTx: $hasTx");
|
debugPrint("hasTx: $hasTx");
|
||||||
debugPrint("trade: ${trade.toString()}");
|
debugPrint("trade: ${trade.toString()}");
|
||||||
|
|
||||||
|
final sendAmount = Decimal.tryParse(
|
||||||
|
trade.statusObject?.amountSendDecimal ?? "") ??
|
||||||
|
Decimal.tryParse(trade.statusObject?.expectedSendAmountDecimal ?? "") ??
|
||||||
|
Decimal.parse("-1");
|
||||||
|
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
backgroundColor: CFColors.almostWhite,
|
backgroundColor: CFColors.almostWhite,
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
|
@ -150,7 +176,7 @@ class _TradeDetailsViewState extends ConsumerState<TradeDetailsView> {
|
||||||
height: 4,
|
height: 4,
|
||||||
),
|
),
|
||||||
SelectableText(
|
SelectableText(
|
||||||
"${Format.localizedStringAsFixed(value: Decimal.parse(trade.statusObject?.amountSendDecimal ?? trade.amount), locale: ref.watch(
|
"${Format.localizedStringAsFixed(value: sendAmount, locale: ref.watch(
|
||||||
localeServiceChangeNotifierProvider
|
localeServiceChangeNotifierProvider
|
||||||
.select((value) => value.locale),
|
.select((value) => value.locale),
|
||||||
), decimalPlaces: trade.fromCurrency.toLowerCase() == "xmr" ? 12 : 8)} ${trade.fromCurrency.toUpperCase()}",
|
), decimalPlaces: trade.fromCurrency.toLowerCase() == "xmr" ? 12 : 8)} ${trade.fromCurrency.toUpperCase()}",
|
||||||
|
@ -205,7 +231,7 @@ class _TradeDetailsViewState extends ConsumerState<TradeDetailsView> {
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
if (!sentFromStack && hasTx)
|
if (!sentFromStack && !hasTx)
|
||||||
const SizedBox(
|
const SizedBox(
|
||||||
height: 12,
|
height: 12,
|
||||||
),
|
),
|
||||||
|
@ -214,9 +240,8 @@ class _TradeDetailsViewState extends ConsumerState<TradeDetailsView> {
|
||||||
color: CFColors.warningBackground,
|
color: CFColors.warningBackground,
|
||||||
child: RichText(
|
child: RichText(
|
||||||
text: TextSpan(
|
text: TextSpan(
|
||||||
text: "You must send at least ${Decimal.parse(
|
text:
|
||||||
trade.statusObject!.amountSendDecimal,
|
"You must send at least ${sendAmount.toStringAsFixed(
|
||||||
).toStringAsFixed(
|
|
||||||
trade.fromCurrency.toLowerCase() == "xmr" ? 12 : 8,
|
trade.fromCurrency.toLowerCase() == "xmr" ? 12 : 8,
|
||||||
)} ${trade.fromCurrency.toUpperCase()}. ",
|
)} ${trade.fromCurrency.toUpperCase()}. ",
|
||||||
style: STextStyles.label.copyWith(
|
style: STextStyles.label.copyWith(
|
||||||
|
@ -225,9 +250,8 @@ class _TradeDetailsViewState extends ConsumerState<TradeDetailsView> {
|
||||||
),
|
),
|
||||||
children: [
|
children: [
|
||||||
TextSpan(
|
TextSpan(
|
||||||
text: "If you send less than ${Decimal.parse(
|
text:
|
||||||
trade.statusObject!.amountSendDecimal,
|
"If you send less than ${sendAmount.toStringAsFixed(
|
||||||
).toStringAsFixed(
|
|
||||||
trade.fromCurrency.toLowerCase() == "xmr"
|
trade.fromCurrency.toLowerCase() == "xmr"
|
||||||
? 12
|
? 12
|
||||||
: 8,
|
: 8,
|
||||||
|
@ -623,11 +647,11 @@ class _TradeDetailsViewState extends ConsumerState<TradeDetailsView> {
|
||||||
onTap: () async {
|
onTap: () async {
|
||||||
final data = ClipboardData(text: trade.id);
|
final data = ClipboardData(text: trade.id);
|
||||||
await clipboard.setData(data);
|
await clipboard.setData(data);
|
||||||
showFloatingFlushBar(
|
unawaited(showFloatingFlushBar(
|
||||||
type: FlushBarType.info,
|
type: FlushBarType.info,
|
||||||
message: "Copied to clipboard",
|
message: "Copied to clipboard",
|
||||||
context: context,
|
context: context,
|
||||||
);
|
));
|
||||||
},
|
},
|
||||||
child: SvgPicture.asset(
|
child: SvgPicture.asset(
|
||||||
Assets.svg.copy,
|
Assets.svg.copy,
|
||||||
|
|
Loading…
Reference in a new issue