mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2025-03-22 15:19:11 +00:00
send from button in trade details
This commit is contained in:
parent
626b0ee9ef
commit
5451698b92
4 changed files with 161 additions and 74 deletions
|
@ -48,6 +48,26 @@ class _SendFromViewState extends ConsumerState<SendFromView> {
|
||||||
late final String address;
|
late final String address;
|
||||||
late final ExchangeTransaction trade;
|
late final ExchangeTransaction trade;
|
||||||
|
|
||||||
|
String formatAmount(Decimal amount, Coin coin) {
|
||||||
|
switch (coin) {
|
||||||
|
case Coin.bitcoin:
|
||||||
|
case Coin.bitcoincash:
|
||||||
|
case Coin.dogecoin:
|
||||||
|
case Coin.epicCash:
|
||||||
|
case Coin.firo:
|
||||||
|
case Coin.namecoin:
|
||||||
|
case Coin.bitcoinTestNet:
|
||||||
|
case Coin.bitcoincashTestnet:
|
||||||
|
case Coin.dogecoinTestNet:
|
||||||
|
case Coin.firoTestNet:
|
||||||
|
return amount.toStringAsFixed(Constants.decimalPlaces);
|
||||||
|
case Coin.monero:
|
||||||
|
return amount.toStringAsFixed(Constants.decimalPlacesMonero);
|
||||||
|
case Coin.wownero:
|
||||||
|
return amount.toStringAsFixed(Constants.decimalPlacesWownero);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
coin = widget.coin;
|
coin = widget.coin;
|
||||||
|
@ -59,6 +79,11 @@ class _SendFromViewState extends ConsumerState<SendFromView> {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
debugPrint("BUILD: $runtimeType");
|
||||||
|
|
||||||
|
final walletIds = ref.watch(walletsChangeNotifierProvider
|
||||||
|
.select((value) => value.getWalletIdsFor(coin: coin)));
|
||||||
|
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
backgroundColor: Theme.of(context).extension<StackColors>()!.background,
|
backgroundColor: Theme.of(context).extension<StackColors>()!.background,
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
|
@ -68,44 +93,41 @@ class _SendFromViewState extends ConsumerState<SendFromView> {
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
title: Text(
|
title: Text(
|
||||||
"Send ",
|
"Send from",
|
||||||
style: STextStyles.navBarTitle(context),
|
style: STextStyles.navBarTitle(context),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
body: Padding(
|
body: Padding(
|
||||||
padding: const EdgeInsets.all(16),
|
padding: const EdgeInsets.all(16),
|
||||||
child: Wrap(
|
child: Column(
|
||||||
// crossAxisAlignment: CrossAxisAlignment.stretch,
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Row(
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
"Choose your ${coin.ticker} wallet",
|
"You need to send ${formatAmount(amount, coin)} ${coin.ticker}",
|
||||||
style: STextStyles.pageTitleH1(context),
|
|
||||||
),
|
|
||||||
const SizedBox(
|
|
||||||
height: 8,
|
|
||||||
),
|
|
||||||
Text(
|
|
||||||
"You need to send ${amount.toStringAsFixed(coin == Coin.monero ? Constants.satsPerCoinMonero : coin == Coin.wownero ? Constants.satsPerCoinWownero : Constants.satsPerCoin)} ${coin.ticker}",
|
|
||||||
style: STextStyles.itemSubtitle(context),
|
style: STextStyles.itemSubtitle(context),
|
||||||
),
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
const SizedBox(
|
const SizedBox(
|
||||||
height: 16,
|
height: 16,
|
||||||
),
|
),
|
||||||
ListView(
|
Expanded(
|
||||||
shrinkWrap: true,
|
child: ListView.builder(
|
||||||
children: [
|
itemCount: walletIds.length,
|
||||||
...ref
|
itemBuilder: (context, index) {
|
||||||
.watch(walletsChangeNotifierProvider
|
return Padding(
|
||||||
.select((value) => value.managers))
|
padding: const EdgeInsets.symmetric(vertical: 4),
|
||||||
.where((element) => element.coin == coin)
|
child: SendFromCard(
|
||||||
.map((e) => SendFromCard(
|
walletId: walletIds[index],
|
||||||
walletId: e.walletId,
|
|
||||||
amount: amount,
|
amount: amount,
|
||||||
address: address,
|
address: address,
|
||||||
trade: trade,
|
trade: trade,
|
||||||
))
|
),
|
||||||
.toList(growable: false)
|
);
|
||||||
],
|
},
|
||||||
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
@ -163,7 +185,7 @@ class _SendFromCardState extends ConsumerState<SendFromCard> {
|
||||||
child: MaterialButton(
|
child: MaterialButton(
|
||||||
splashColor: Theme.of(context).extension<StackColors>()!.highlight,
|
splashColor: Theme.of(context).extension<StackColors>()!.highlight,
|
||||||
key: Key("walletsSheetItemButtonKey_$walletId"),
|
key: Key("walletsSheetItemButtonKey_$walletId"),
|
||||||
padding: const EdgeInsets.all(5),
|
padding: const EdgeInsets.all(8),
|
||||||
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
||||||
shape: RoundedRectangleBorder(
|
shape: RoundedRectangleBorder(
|
||||||
borderRadius: BorderRadius.circular(
|
borderRadius: BorderRadius.circular(
|
||||||
|
@ -276,18 +298,19 @@ class _SendFromCardState extends ConsumerState<SendFromCard> {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.all(4),
|
padding: const EdgeInsets.all(6),
|
||||||
child: SvgPicture.asset(
|
child: SvgPicture.asset(
|
||||||
Assets.svg.iconFor(coin: coin),
|
Assets.svg.iconFor(coin: coin),
|
||||||
width: 20,
|
width: 24,
|
||||||
height: 20,
|
height: 24,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(
|
const SizedBox(
|
||||||
width: 12,
|
width: 12,
|
||||||
),
|
),
|
||||||
Column(
|
Expanded(
|
||||||
|
child: Column(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
|
@ -308,10 +331,10 @@ class _SendFromCardState extends ConsumerState<SendFromCard> {
|
||||||
value: snapshot.data!,
|
value: snapshot.data!,
|
||||||
locale: locale,
|
locale: locale,
|
||||||
decimalPlaces: coin == Coin.monero
|
decimalPlaces: coin == Coin.monero
|
||||||
? Constants.satsPerCoinMonero
|
? Constants.decimalPlacesMonero
|
||||||
: coin == Coin.wownero
|
: coin == Coin.wownero
|
||||||
? Constants.satsPerCoinWownero
|
? Constants.decimalPlacesWownero
|
||||||
: Constants.satsPerCoin,
|
: Constants.decimalPlaces,
|
||||||
)} ${coin.ticker}",
|
)} ${coin.ticker}",
|
||||||
style: STextStyles.itemSubtitle(context),
|
style: STextStyles.itemSubtitle(context),
|
||||||
);
|
);
|
||||||
|
@ -330,6 +353,7 @@ class _SendFromCardState extends ConsumerState<SendFromCard> {
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
|
@ -10,6 +10,7 @@ import 'package:stackwallet/models/exchange/change_now/exchange_transaction_stat
|
||||||
import 'package:stackwallet/models/paymint/transactions_model.dart';
|
import 'package:stackwallet/models/paymint/transactions_model.dart';
|
||||||
import 'package:stackwallet/notifications/show_flush_bar.dart';
|
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/exchange_view/send_from_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/change_now_provider.dart';
|
||||||
|
@ -24,6 +25,7 @@ import 'package:stackwallet/utilities/format.dart';
|
||||||
import 'package:stackwallet/utilities/text_styles.dart';
|
import 'package:stackwallet/utilities/text_styles.dart';
|
||||||
import 'package:stackwallet/utilities/theme/stack_colors.dart';
|
import 'package:stackwallet/utilities/theme/stack_colors.dart';
|
||||||
import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart';
|
import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart';
|
||||||
|
import 'package:stackwallet/widgets/desktop/secondary_button.dart';
|
||||||
import 'package:stackwallet/widgets/rounded_container.dart';
|
import 'package:stackwallet/widgets/rounded_container.dart';
|
||||||
import 'package:stackwallet/widgets/rounded_white_container.dart';
|
import 'package:stackwallet/widgets/rounded_white_container.dart';
|
||||||
import 'package:stackwallet/widgets/stack_dialog.dart';
|
import 'package:stackwallet/widgets/stack_dialog.dart';
|
||||||
|
@ -60,6 +62,15 @@ class _TradeDetailsViewState extends ConsumerState<TradeDetailsView> {
|
||||||
|
|
||||||
String _note = "";
|
String _note = "";
|
||||||
|
|
||||||
|
bool isStackCoin(String ticker) {
|
||||||
|
try {
|
||||||
|
coinFromTickerCaseInsensitive(ticker);
|
||||||
|
return true;
|
||||||
|
} on ArgumentError catch (_) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
initState() {
|
initState() {
|
||||||
tradeId = widget.tradeId;
|
tradeId = widget.tradeId;
|
||||||
|
@ -756,6 +767,36 @@ class _TradeDetailsViewState extends ConsumerState<TradeDetailsView> {
|
||||||
const SizedBox(
|
const SizedBox(
|
||||||
height: 12,
|
height: 12,
|
||||||
),
|
),
|
||||||
|
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);
|
||||||
|
|
||||||
|
print("amount: $amount");
|
||||||
|
print("address: $address");
|
||||||
|
print("coin: $coin");
|
||||||
|
|
||||||
|
Navigator.of(context).pushNamed(
|
||||||
|
SendFromView.routeName,
|
||||||
|
arguments: Tuple4(
|
||||||
|
coin,
|
||||||
|
amount,
|
||||||
|
address,
|
||||||
|
trade,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
|
import 'package:decimal/decimal.dart';
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
import 'package:stackwallet/models/contact_address_entry.dart';
|
import 'package:stackwallet/models/contact_address_entry.dart';
|
||||||
|
import 'package:stackwallet/models/exchange/change_now/exchange_transaction.dart';
|
||||||
import 'package:stackwallet/models/exchange/incomplete_exchange.dart';
|
import 'package:stackwallet/models/exchange/incomplete_exchange.dart';
|
||||||
import 'package:stackwallet/models/paymint/transactions_model.dart';
|
import 'package:stackwallet/models/paymint/transactions_model.dart';
|
||||||
import 'package:stackwallet/models/send_view_auto_fill_data.dart';
|
import 'package:stackwallet/models/send_view_auto_fill_data.dart';
|
||||||
|
@ -27,6 +29,7 @@ import 'package:stackwallet/pages/exchange_view/exchange_step_views/step_1_view.
|
||||||
import 'package:stackwallet/pages/exchange_view/exchange_step_views/step_2_view.dart';
|
import 'package:stackwallet/pages/exchange_view/exchange_step_views/step_2_view.dart';
|
||||||
import 'package:stackwallet/pages/exchange_view/exchange_step_views/step_3_view.dart';
|
import 'package:stackwallet/pages/exchange_view/exchange_step_views/step_3_view.dart';
|
||||||
import 'package:stackwallet/pages/exchange_view/exchange_step_views/step_4_view.dart';
|
import 'package:stackwallet/pages/exchange_view/exchange_step_views/step_4_view.dart';
|
||||||
|
import 'package:stackwallet/pages/exchange_view/send_from_view.dart';
|
||||||
import 'package:stackwallet/pages/exchange_view/trade_details_view.dart';
|
import 'package:stackwallet/pages/exchange_view/trade_details_view.dart';
|
||||||
import 'package:stackwallet/pages/exchange_view/wallet_initiated_exchange_view.dart';
|
import 'package:stackwallet/pages/exchange_view/wallet_initiated_exchange_view.dart';
|
||||||
import 'package:stackwallet/pages/home_view/home_view.dart';
|
import 'package:stackwallet/pages/home_view/home_view.dart';
|
||||||
|
@ -894,6 +897,23 @@ class RouteGenerator {
|
||||||
}
|
}
|
||||||
return _routeError("${settings.name} invalid args: ${args.toString()}");
|
return _routeError("${settings.name} invalid args: ${args.toString()}");
|
||||||
|
|
||||||
|
case SendFromView.routeName:
|
||||||
|
if (args is Tuple4<Coin, Decimal, String, ExchangeTransaction>) {
|
||||||
|
return getRoute(
|
||||||
|
shouldUseMaterialRoute: useMaterialPageRoute,
|
||||||
|
builder: (_) => SendFromView(
|
||||||
|
coin: args.item1,
|
||||||
|
amount: args.item2,
|
||||||
|
trade: args.item4,
|
||||||
|
address: args.item3,
|
||||||
|
),
|
||||||
|
settings: RouteSettings(
|
||||||
|
name: settings.name,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return _routeError("${settings.name} invalid args: ${args.toString()}");
|
||||||
|
|
||||||
// == Desktop specific routes ============================================
|
// == Desktop specific routes ============================================
|
||||||
case CreatePasswordView.routeName:
|
case CreatePasswordView.routeName:
|
||||||
return getRoute(
|
return getRoute(
|
||||||
|
|
|
@ -21,6 +21,8 @@ abstract class Constants {
|
||||||
static const int satsPerCoinWownero = 100000000000;
|
static const int satsPerCoinWownero = 100000000000;
|
||||||
static const int satsPerCoin = 100000000;
|
static const int satsPerCoin = 100000000;
|
||||||
static const int decimalPlaces = 8;
|
static const int decimalPlaces = 8;
|
||||||
|
static const int decimalPlacesWownero = 11;
|
||||||
|
static const int decimalPlacesMonero = 12;
|
||||||
|
|
||||||
static const int notificationsMax = 0xFFFFFFFF;
|
static const int notificationsMax = 0xFFFFFFFF;
|
||||||
static const Duration networkAliveTimerDuration = Duration(seconds: 10);
|
static const Duration networkAliveTimerDuration = Duration(seconds: 10);
|
||||||
|
|
Loading…
Reference in a new issue