mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2025-01-22 10:34:32 +00:00
commit
df15461a81
13 changed files with 443 additions and 286 deletions
|
@ -49,7 +49,7 @@ class CoinControlView extends ConsumerStatefulWidget {
|
||||||
|
|
||||||
final String walletId;
|
final String walletId;
|
||||||
final CoinControlViewType type;
|
final CoinControlViewType type;
|
||||||
final int? requestedTotal;
|
final Amount? requestedTotal;
|
||||||
final Set<UTXO>? selectedUTXOs;
|
final Set<UTXO>? selectedUTXOs;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -673,7 +673,7 @@ class _CoinControlViewState extends ConsumerState<CoinControlView> {
|
||||||
),
|
),
|
||||||
Builder(
|
Builder(
|
||||||
builder: (context) {
|
builder: (context) {
|
||||||
int selectedSum =
|
final int selectedSumInt =
|
||||||
_selectedAvailable.isEmpty
|
_selectedAvailable.isEmpty
|
||||||
? 0
|
? 0
|
||||||
: _selectedAvailable
|
: _selectedAvailable
|
||||||
|
@ -682,15 +682,19 @@ class _CoinControlViewState extends ConsumerState<CoinControlView> {
|
||||||
(value, element) =>
|
(value, element) =>
|
||||||
value += element,
|
value += element,
|
||||||
);
|
);
|
||||||
|
final selectedSum =
|
||||||
|
selectedSumInt.toAmountAsRaw(
|
||||||
|
fractionDigits: coin.decimals,
|
||||||
|
);
|
||||||
return Text(
|
return Text(
|
||||||
"${selectedSum.toAmountAsRaw(fractionDigits: coin.decimals).localizedStringAsFixed(
|
"${selectedSum.localizedStringAsFixed(
|
||||||
locale: ref.watch(
|
locale: ref.watch(
|
||||||
localeServiceChangeNotifierProvider
|
localeServiceChangeNotifierProvider
|
||||||
.select(
|
.select(
|
||||||
(value) => value.locale,
|
(value) => value.locale,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
)} ${coin.ticker}",
|
)} ${coin.ticker}",
|
||||||
style: widget.requestedTotal == null
|
style: widget.requestedTotal == null
|
||||||
? STextStyles.w600_14(context)
|
? STextStyles.w600_14(context)
|
||||||
: STextStyles.w600_14(context).copyWith(
|
: STextStyles.w600_14(context).copyWith(
|
||||||
|
@ -731,14 +735,14 @@ class _CoinControlViewState extends ConsumerState<CoinControlView> {
|
||||||
style: STextStyles.w600_14(context),
|
style: STextStyles.w600_14(context),
|
||||||
),
|
),
|
||||||
Text(
|
Text(
|
||||||
"${widget.requestedTotal!.toAmountAsRaw(fractionDigits: coin.decimals).localizedStringAsFixed(
|
"${widget.requestedTotal!.localizedStringAsFixed(
|
||||||
locale: ref.watch(
|
locale: ref.watch(
|
||||||
localeServiceChangeNotifierProvider
|
localeServiceChangeNotifierProvider
|
||||||
.select(
|
.select(
|
||||||
(value) => value.locale,
|
(value) => value.locale,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
)} ${coin.ticker}",
|
)} ${coin.ticker}",
|
||||||
style: STextStyles.w600_14(context),
|
style: STextStyles.w600_14(context),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|
|
@ -124,13 +124,15 @@ class _UtxoCardState extends ConsumerState<UtxoCard> {
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
"${utxo.value.toAmountAsRaw(fractionDigits: coin.decimals).localizedStringAsFixed(
|
"${utxo.value.toAmountAsRaw(
|
||||||
|
fractionDigits: coin.decimals,
|
||||||
|
).localizedStringAsFixed(
|
||||||
locale: ref.watch(
|
locale: ref.watch(
|
||||||
localeServiceChangeNotifierProvider.select(
|
localeServiceChangeNotifierProvider.select(
|
||||||
(value) => value.locale,
|
(value) => value.locale,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
)}} ${coin.ticker}",
|
)} ${coin.ticker}",
|
||||||
style: STextStyles.w600_14(context),
|
style: STextStyles.w600_14(context),
|
||||||
),
|
),
|
||||||
const SizedBox(
|
const SizedBox(
|
||||||
|
|
|
@ -320,14 +320,7 @@ class _ExchangeCurrencySelectionViewState
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(
|
const SizedBox(
|
||||||
height: 10,
|
height: 20,
|
||||||
),
|
|
||||||
Text(
|
|
||||||
"Popular coins",
|
|
||||||
style: STextStyles.smallMed12(context),
|
|
||||||
),
|
|
||||||
const SizedBox(
|
|
||||||
height: 12,
|
|
||||||
),
|
),
|
||||||
Flexible(
|
Flexible(
|
||||||
child: Builder(
|
child: Builder(
|
||||||
|
|
|
@ -5,6 +5,7 @@ import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
import 'package:flutter_svg/flutter_svg.dart';
|
import 'package:flutter_svg/flutter_svg.dart';
|
||||||
import 'package:flutter_svg/svg.dart';
|
import 'package:flutter_svg/svg.dart';
|
||||||
|
import 'package:intl/intl.dart';
|
||||||
import 'package:isar/isar.dart';
|
import 'package:isar/isar.dart';
|
||||||
import 'package:stackwallet/models/exchange/aggregate_currency.dart';
|
import 'package:stackwallet/models/exchange/aggregate_currency.dart';
|
||||||
import 'package:stackwallet/models/exchange/incomplete_exchange.dart';
|
import 'package:stackwallet/models/exchange/incomplete_exchange.dart';
|
||||||
|
@ -109,7 +110,7 @@ class _ExchangeFormState extends ConsumerState<ExchangeForm> {
|
||||||
_sendFieldOnChangedTimer?.cancel();
|
_sendFieldOnChangedTimer?.cancel();
|
||||||
|
|
||||||
_sendFieldOnChangedTimer = Timer(_valueCheckInterval, () async {
|
_sendFieldOnChangedTimer = Timer(_valueCheckInterval, () async {
|
||||||
final newFromAmount = Decimal.tryParse(value);
|
final newFromAmount = _localizedStringToNum(value);
|
||||||
|
|
||||||
await ref
|
await ref
|
||||||
.read(exchangeFormStateProvider)
|
.read(exchangeFormStateProvider)
|
||||||
|
@ -123,7 +124,7 @@ class _ExchangeFormState extends ConsumerState<ExchangeForm> {
|
||||||
_receiveFieldOnChangedTimer?.cancel();
|
_receiveFieldOnChangedTimer?.cancel();
|
||||||
|
|
||||||
_receiveFieldOnChangedTimer = Timer(_valueCheckInterval, () async {
|
_receiveFieldOnChangedTimer = Timer(_valueCheckInterval, () async {
|
||||||
final newToAmount = Decimal.tryParse(value);
|
final newToAmount = _localizedStringToNum(value);
|
||||||
|
|
||||||
await ref
|
await ref
|
||||||
.read(exchangeFormStateProvider)
|
.read(exchangeFormStateProvider)
|
||||||
|
@ -131,6 +132,20 @@ class _ExchangeFormState extends ConsumerState<ExchangeForm> {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Decimal? _localizedStringToNum(String? value) {
|
||||||
|
if (value == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
final numFromLocalised = NumberFormat.decimalPattern(
|
||||||
|
ref.read(localeServiceChangeNotifierProvider).locale)
|
||||||
|
.parse(value);
|
||||||
|
return Decimal.tryParse(numFromLocalised.toString());
|
||||||
|
} catch (_) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Future<AggregateCurrency> _getAggregateCurrency(Currency currency) async {
|
Future<AggregateCurrency> _getAggregateCurrency(Currency currency) async {
|
||||||
final rateType = ref.read(exchangeFormStateProvider).exchangeRateType;
|
final rateType = ref.read(exchangeFormStateProvider).exchangeRateType;
|
||||||
final currencies = await ExchangeDataLoadingService.instance.isar.currencies
|
final currencies = await ExchangeDataLoadingService.instance.isar.currencies
|
||||||
|
|
|
@ -15,18 +15,22 @@ import 'package:stackwallet/pages/send_view/sub_widgets/building_transaction_dia
|
||||||
import 'package:stackwallet/pages/wallet_view/wallet_view.dart';
|
import 'package:stackwallet/pages/wallet_view/wallet_view.dart';
|
||||||
import 'package:stackwallet/providers/providers.dart';
|
import 'package:stackwallet/providers/providers.dart';
|
||||||
import 'package:stackwallet/route_generator.dart';
|
import 'package:stackwallet/route_generator.dart';
|
||||||
|
import 'package:stackwallet/services/coins/firo/firo_wallet.dart';
|
||||||
import 'package:stackwallet/utilities/amount/amount.dart';
|
import 'package:stackwallet/utilities/amount/amount.dart';
|
||||||
import 'package:stackwallet/utilities/assets.dart';
|
import 'package:stackwallet/utilities/assets.dart';
|
||||||
import 'package:stackwallet/utilities/clipboard_interface.dart';
|
import 'package:stackwallet/utilities/clipboard_interface.dart';
|
||||||
|
import 'package:stackwallet/utilities/constants.dart';
|
||||||
import 'package:stackwallet/utilities/enums/coin_enum.dart';
|
import 'package:stackwallet/utilities/enums/coin_enum.dart';
|
||||||
import 'package:stackwallet/utilities/enums/fee_rate_type_enum.dart';
|
import 'package:stackwallet/utilities/enums/fee_rate_type_enum.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/background.dart';
|
import 'package:stackwallet/widgets/background.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';
|
||||||
|
import 'package:tuple/tuple.dart';
|
||||||
|
|
||||||
class Step4View extends ConsumerStatefulWidget {
|
class Step4View extends ConsumerStatefulWidget {
|
||||||
const Step4View({
|
const Step4View({
|
||||||
|
@ -120,6 +124,213 @@ class _Step4ViewState extends ConsumerState<Step4View> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<bool?> _showSendFromFiroBalanceSelectSheet(String walletId) async {
|
||||||
|
final firoWallet = ref
|
||||||
|
.read(walletsChangeNotifierProvider)
|
||||||
|
.getManager(walletId)
|
||||||
|
.wallet as FiroWallet;
|
||||||
|
final locale = ref.read(localeServiceChangeNotifierProvider).locale;
|
||||||
|
|
||||||
|
return await showModalBottomSheet<bool?>(
|
||||||
|
context: context,
|
||||||
|
backgroundColor:
|
||||||
|
Theme.of(context).extension<StackColors>()!.backgroundAppBar,
|
||||||
|
shape: RoundedRectangleBorder(
|
||||||
|
borderRadius: BorderRadius.vertical(
|
||||||
|
top: Radius.circular(
|
||||||
|
Constants.size.circularBorderRadius * 3,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
builder: (context) {
|
||||||
|
return Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(
|
||||||
|
horizontal: 16,
|
||||||
|
),
|
||||||
|
child: Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||||
|
children: [
|
||||||
|
const SizedBox(
|
||||||
|
height: 32,
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
"Select Firo balance",
|
||||||
|
style: STextStyles.pageTitleH2(context),
|
||||||
|
),
|
||||||
|
const SizedBox(
|
||||||
|
height: 32,
|
||||||
|
),
|
||||||
|
SecondaryButton(
|
||||||
|
label:
|
||||||
|
"${firoWallet.balancePrivate.spendable.localizedStringAsFixed(
|
||||||
|
locale: locale,
|
||||||
|
)} (private)",
|
||||||
|
onPressed: () => Navigator.of(context).pop(false),
|
||||||
|
),
|
||||||
|
const SizedBox(
|
||||||
|
height: 16,
|
||||||
|
),
|
||||||
|
SecondaryButton(
|
||||||
|
label: "${firoWallet.balance.spendable.localizedStringAsFixed(
|
||||||
|
locale: locale,
|
||||||
|
)} (public)",
|
||||||
|
onPressed: () => Navigator.of(context).pop(true),
|
||||||
|
),
|
||||||
|
const SizedBox(
|
||||||
|
height: 32,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _confirmSend(Tuple2<String, Coin> tuple) async {
|
||||||
|
final bool firoPublicSend;
|
||||||
|
if (tuple.item2 == Coin.firo) {
|
||||||
|
final result = await _showSendFromFiroBalanceSelectSheet(tuple.item1);
|
||||||
|
if (result == null) {
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
firoPublicSend = result;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
firoPublicSend = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
final manager =
|
||||||
|
ref.read(walletsChangeNotifierProvider).getManager(tuple.item1);
|
||||||
|
|
||||||
|
final Amount amount = model.sendAmount.toAmount(
|
||||||
|
fractionDigits: manager.coin.decimals,
|
||||||
|
);
|
||||||
|
final address = model.trade!.payInAddress;
|
||||||
|
|
||||||
|
bool wasCancelled = false;
|
||||||
|
try {
|
||||||
|
if (!mounted) return;
|
||||||
|
|
||||||
|
unawaited(
|
||||||
|
showDialog<dynamic>(
|
||||||
|
context: context,
|
||||||
|
useSafeArea: false,
|
||||||
|
barrierDismissible: false,
|
||||||
|
builder: (context) {
|
||||||
|
return BuildingTransactionDialog(
|
||||||
|
coin: manager.coin,
|
||||||
|
onCancel: () {
|
||||||
|
wasCancelled = true;
|
||||||
|
},
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
final time = Future<dynamic>.delayed(
|
||||||
|
const Duration(
|
||||||
|
milliseconds: 2500,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
Future<Map<String, dynamic>> txDataFuture;
|
||||||
|
|
||||||
|
if (firoPublicSend) {
|
||||||
|
txDataFuture = (manager.wallet as FiroWallet).prepareSendPublic(
|
||||||
|
address: address,
|
||||||
|
amount: amount,
|
||||||
|
args: {
|
||||||
|
"feeRate": FeeRateType.average,
|
||||||
|
// ref.read(feeRateTypeStateProvider)
|
||||||
|
},
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
txDataFuture = manager.prepareSend(
|
||||||
|
address: address,
|
||||||
|
amount: amount,
|
||||||
|
args: {
|
||||||
|
"feeRate": FeeRateType.average,
|
||||||
|
// ref.read(feeRateTypeStateProvider)
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
final results = await Future.wait([
|
||||||
|
txDataFuture,
|
||||||
|
time,
|
||||||
|
]);
|
||||||
|
|
||||||
|
final txData = results.first as Map<String, dynamic>;
|
||||||
|
|
||||||
|
if (!wasCancelled) {
|
||||||
|
// pop building dialog
|
||||||
|
|
||||||
|
if (mounted) {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
}
|
||||||
|
|
||||||
|
txData["note"] =
|
||||||
|
"${model.trade!.payInCurrency.toUpperCase()}/${model.trade!.payOutCurrency.toUpperCase()} exchange";
|
||||||
|
txData["address"] = address;
|
||||||
|
|
||||||
|
if (mounted) {
|
||||||
|
unawaited(
|
||||||
|
Navigator.of(context).push(
|
||||||
|
RouteGenerator.getRoute(
|
||||||
|
shouldUseMaterialRoute: RouteGenerator.useMaterialPageRoute,
|
||||||
|
builder: (_) => ConfirmChangeNowSendView(
|
||||||
|
transactionInfo: txData,
|
||||||
|
walletId: tuple.item1,
|
||||||
|
routeOnSuccessName: HomeView.routeName,
|
||||||
|
trade: model.trade!,
|
||||||
|
),
|
||||||
|
settings: const RouteSettings(
|
||||||
|
name: ConfirmChangeNowSendView.routeName,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
if (mounted && !wasCancelled) {
|
||||||
|
// pop building dialog
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
|
||||||
|
unawaited(
|
||||||
|
showDialog<dynamic>(
|
||||||
|
context: context,
|
||||||
|
useSafeArea: false,
|
||||||
|
barrierDismissible: true,
|
||||||
|
builder: (context) {
|
||||||
|
return StackDialog(
|
||||||
|
title: "Transaction failed",
|
||||||
|
message: e.toString(),
|
||||||
|
rightButton: TextButton(
|
||||||
|
style: Theme.of(context)
|
||||||
|
.extension<StackColors>()!
|
||||||
|
.getSecondaryEnabledButtonStyle(context),
|
||||||
|
child: Text(
|
||||||
|
"Ok",
|
||||||
|
style: STextStyles.button(context).copyWith(
|
||||||
|
color: Theme.of(context)
|
||||||
|
.extension<StackColors>()!
|
||||||
|
.buttonTextSecondary,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
onPressed: () {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final bool isWalletCoin =
|
final bool isWalletCoin =
|
||||||
|
@ -244,11 +455,15 @@ class _Step4ViewState extends ConsumerState<Step4View> {
|
||||||
text:
|
text:
|
||||||
model.sendAmount.toString());
|
model.sendAmount.toString());
|
||||||
await clipboard.setData(data);
|
await clipboard.setData(data);
|
||||||
unawaited(showFloatingFlushBar(
|
if (mounted) {
|
||||||
type: FlushBarType.info,
|
unawaited(
|
||||||
message: "Copied to clipboard",
|
showFloatingFlushBar(
|
||||||
context: context,
|
type: FlushBarType.info,
|
||||||
));
|
message: "Copied to clipboard",
|
||||||
|
context: context,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
child: Row(
|
child: Row(
|
||||||
children: [
|
children: [
|
||||||
|
@ -302,11 +517,15 @@ class _Step4ViewState extends ConsumerState<Step4View> {
|
||||||
final data = ClipboardData(
|
final data = ClipboardData(
|
||||||
text: model.trade!.payInAddress);
|
text: model.trade!.payInAddress);
|
||||||
await clipboard.setData(data);
|
await clipboard.setData(data);
|
||||||
unawaited(showFloatingFlushBar(
|
if (mounted) {
|
||||||
type: FlushBarType.info,
|
unawaited(
|
||||||
message: "Copied to clipboard",
|
showFloatingFlushBar(
|
||||||
context: context,
|
type: FlushBarType.info,
|
||||||
));
|
message: "Copied to clipboard",
|
||||||
|
context: context,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
child: Row(
|
child: Row(
|
||||||
children: [
|
children: [
|
||||||
|
@ -365,11 +584,15 @@ class _Step4ViewState extends ConsumerState<Step4View> {
|
||||||
final data = ClipboardData(
|
final data = ClipboardData(
|
||||||
text: model.trade!.tradeId);
|
text: model.trade!.tradeId);
|
||||||
await clipboard.setData(data);
|
await clipboard.setData(data);
|
||||||
unawaited(showFloatingFlushBar(
|
if (mounted) {
|
||||||
type: FlushBarType.info,
|
unawaited(
|
||||||
message: "Copied to clipboard",
|
showFloatingFlushBar(
|
||||||
context: context,
|
type: FlushBarType.info,
|
||||||
));
|
message: "Copied to clipboard",
|
||||||
|
context: context,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
child: SvgPicture.asset(
|
child: SvgPicture.asset(
|
||||||
Assets.svg.copy,
|
Assets.svg.copy,
|
||||||
|
@ -521,147 +744,7 @@ class _Step4ViewState extends ConsumerState<Step4View> {
|
||||||
model.sendTicker.toLowerCase() ==
|
model.sendTicker.toLowerCase() ==
|
||||||
tuple.item2.ticker.toLowerCase()
|
tuple.item2.ticker.toLowerCase()
|
||||||
? () async {
|
? () async {
|
||||||
final manager = ref
|
await _confirmSend(tuple);
|
||||||
.read(
|
|
||||||
walletsChangeNotifierProvider)
|
|
||||||
.getManager(tuple.item1);
|
|
||||||
|
|
||||||
final Amount amount =
|
|
||||||
model.sendAmount.toAmount(
|
|
||||||
fractionDigits:
|
|
||||||
manager.coin.decimals,
|
|
||||||
);
|
|
||||||
final address =
|
|
||||||
model.trade!.payInAddress;
|
|
||||||
|
|
||||||
try {
|
|
||||||
bool wasCancelled = false;
|
|
||||||
|
|
||||||
unawaited(
|
|
||||||
showDialog<dynamic>(
|
|
||||||
context: context,
|
|
||||||
useSafeArea: false,
|
|
||||||
barrierDismissible: false,
|
|
||||||
builder: (context) {
|
|
||||||
return BuildingTransactionDialog(
|
|
||||||
coin: manager.coin,
|
|
||||||
onCancel: () {
|
|
||||||
wasCancelled = true;
|
|
||||||
|
|
||||||
Navigator.of(context)
|
|
||||||
.pop();
|
|
||||||
},
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
final time =
|
|
||||||
Future<dynamic>.delayed(
|
|
||||||
const Duration(
|
|
||||||
milliseconds: 2500,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
final txDataFuture =
|
|
||||||
manager.prepareSend(
|
|
||||||
address: address,
|
|
||||||
amount: amount,
|
|
||||||
args: {
|
|
||||||
"feeRate":
|
|
||||||
FeeRateType.average,
|
|
||||||
// ref.read(feeRateTypeStateProvider)
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
final results =
|
|
||||||
await Future.wait([
|
|
||||||
txDataFuture,
|
|
||||||
time,
|
|
||||||
]);
|
|
||||||
|
|
||||||
final txData = results.first
|
|
||||||
as Map<String, dynamic>;
|
|
||||||
|
|
||||||
if (!wasCancelled) {
|
|
||||||
// pop building dialog
|
|
||||||
|
|
||||||
if (mounted) {
|
|
||||||
Navigator.of(context).pop();
|
|
||||||
}
|
|
||||||
|
|
||||||
txData["note"] =
|
|
||||||
"${model.trade!.payInCurrency.toUpperCase()}/${model.trade!.payOutCurrency.toUpperCase()} exchange";
|
|
||||||
txData["address"] = address;
|
|
||||||
|
|
||||||
if (mounted) {
|
|
||||||
unawaited(
|
|
||||||
Navigator.of(context)
|
|
||||||
.push(
|
|
||||||
RouteGenerator.getRoute(
|
|
||||||
shouldUseMaterialRoute:
|
|
||||||
RouteGenerator
|
|
||||||
.useMaterialPageRoute,
|
|
||||||
builder: (_) =>
|
|
||||||
ConfirmChangeNowSendView(
|
|
||||||
transactionInfo: txData,
|
|
||||||
walletId: tuple.item1,
|
|
||||||
routeOnSuccessName:
|
|
||||||
HomeView.routeName,
|
|
||||||
trade: model.trade!,
|
|
||||||
),
|
|
||||||
settings:
|
|
||||||
const RouteSettings(
|
|
||||||
name:
|
|
||||||
ConfirmChangeNowSendView
|
|
||||||
.routeName,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (e) {
|
|
||||||
// if (mounted) {
|
|
||||||
// pop building dialog
|
|
||||||
Navigator.of(context).pop();
|
|
||||||
|
|
||||||
unawaited(showDialog<dynamic>(
|
|
||||||
context: context,
|
|
||||||
useSafeArea: false,
|
|
||||||
barrierDismissible: true,
|
|
||||||
builder: (context) {
|
|
||||||
return StackDialog(
|
|
||||||
title: "Transaction failed",
|
|
||||||
message: e.toString(),
|
|
||||||
rightButton: TextButton(
|
|
||||||
style: Theme.of(context)
|
|
||||||
.extension<
|
|
||||||
StackColors>()!
|
|
||||||
.getSecondaryEnabledButtonStyle(
|
|
||||||
context),
|
|
||||||
child: Text(
|
|
||||||
"Ok",
|
|
||||||
style:
|
|
||||||
STextStyles.button(
|
|
||||||
context)
|
|
||||||
.copyWith(
|
|
||||||
color: Theme.of(
|
|
||||||
context)
|
|
||||||
.extension<
|
|
||||||
StackColors>()!
|
|
||||||
.buttonTextSecondary,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
onPressed: () {
|
|
||||||
Navigator.of(context)
|
|
||||||
.pop();
|
|
||||||
},
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
));
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
: () {
|
: () {
|
||||||
Navigator.of(context).push(
|
Navigator.of(context).push(
|
||||||
|
|
|
@ -13,6 +13,7 @@ import 'package:stackwallet/utilities/amount/amount.dart';
|
||||||
import 'package:stackwallet/utilities/assets.dart';
|
import 'package:stackwallet/utilities/assets.dart';
|
||||||
import 'package:stackwallet/utilities/enums/coin_enum.dart';
|
import 'package:stackwallet/utilities/enums/coin_enum.dart';
|
||||||
import 'package:stackwallet/utilities/logger.dart';
|
import 'package:stackwallet/utilities/logger.dart';
|
||||||
|
import 'package:stackwallet/utilities/show_loading.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/utilities/util.dart';
|
import 'package:stackwallet/utilities/util.dart';
|
||||||
|
@ -94,11 +95,17 @@ class _ExchangeProviderOptionsState
|
||||||
onTap: () {
|
onTap: () {
|
||||||
if (ref.read(exchangeFormStateProvider).exchange.name !=
|
if (ref.read(exchangeFormStateProvider).exchange.name !=
|
||||||
ChangeNowExchange.exchangeName) {
|
ChangeNowExchange.exchangeName) {
|
||||||
ref.read(exchangeFormStateProvider).updateExchange(
|
showLoading(
|
||||||
exchange: ChangeNowExchange.instance,
|
whileFuture:
|
||||||
shouldUpdateData: true,
|
ref.read(exchangeFormStateProvider).updateExchange(
|
||||||
shouldNotifyListeners: true,
|
exchange: ChangeNowExchange.instance,
|
||||||
);
|
shouldUpdateData: true,
|
||||||
|
shouldNotifyListeners: true,
|
||||||
|
),
|
||||||
|
context: context,
|
||||||
|
message: "Updating rates",
|
||||||
|
isDesktop: isDesktop,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
child: Container(
|
child: Container(
|
||||||
|
@ -333,11 +340,17 @@ class _ExchangeProviderOptionsState
|
||||||
onTap: () {
|
onTap: () {
|
||||||
if (ref.read(exchangeFormStateProvider).exchange.name !=
|
if (ref.read(exchangeFormStateProvider).exchange.name !=
|
||||||
MajesticBankExchange.exchangeName) {
|
MajesticBankExchange.exchangeName) {
|
||||||
ref.read(exchangeFormStateProvider).updateExchange(
|
showLoading(
|
||||||
exchange: MajesticBankExchange.instance,
|
whileFuture:
|
||||||
shouldUpdateData: true,
|
ref.read(exchangeFormStateProvider).updateExchange(
|
||||||
shouldNotifyListeners: true,
|
exchange: MajesticBankExchange.instance,
|
||||||
);
|
shouldUpdateData: true,
|
||||||
|
shouldNotifyListeners: true,
|
||||||
|
),
|
||||||
|
context: context,
|
||||||
|
isDesktop: isDesktop,
|
||||||
|
message: "Updating rates",
|
||||||
|
);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
child: Container(
|
child: Container(
|
||||||
|
|
|
@ -1391,77 +1391,88 @@ class _TransactionDetailsViewState
|
||||||
false &&
|
false &&
|
||||||
_transaction.isCancelled == false &&
|
_transaction.isCancelled == false &&
|
||||||
_transaction.type == TransactionType.outgoing)
|
_transaction.type == TransactionType.outgoing)
|
||||||
? SizedBox(
|
? ConditionalParent(
|
||||||
width: MediaQuery.of(context).size.width - 32,
|
condition: isDesktop,
|
||||||
child: TextButton(
|
builder: (child) => Padding(
|
||||||
style: ButtonStyle(
|
padding: const EdgeInsets.symmetric(
|
||||||
backgroundColor: MaterialStateProperty.all<Color>(
|
horizontal: 32,
|
||||||
Theme.of(context).extension<StackColors>()!.textError,
|
vertical: 16,
|
||||||
),
|
|
||||||
),
|
),
|
||||||
onPressed: () async {
|
child: child,
|
||||||
final Manager manager = ref
|
),
|
||||||
.read(walletsChangeNotifierProvider)
|
child: SizedBox(
|
||||||
.getManager(walletId);
|
width: MediaQuery.of(context).size.width - 32,
|
||||||
|
child: TextButton(
|
||||||
|
style: ButtonStyle(
|
||||||
|
backgroundColor: MaterialStateProperty.all<Color>(
|
||||||
|
Theme.of(context).extension<StackColors>()!.textError,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
onPressed: () async {
|
||||||
|
final Manager manager = ref
|
||||||
|
.read(walletsChangeNotifierProvider)
|
||||||
|
.getManager(walletId);
|
||||||
|
|
||||||
if (manager.wallet is EpicCashWallet) {
|
if (manager.wallet is EpicCashWallet) {
|
||||||
final String? id = _transaction.slateId;
|
final String? id = _transaction.slateId;
|
||||||
if (id == null) {
|
if (id == null) {
|
||||||
|
unawaited(showFloatingFlushBar(
|
||||||
|
type: FlushBarType.warning,
|
||||||
|
message: "Could not find Epic transaction ID",
|
||||||
|
context: context,
|
||||||
|
));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
unawaited(showDialog<dynamic>(
|
||||||
|
barrierDismissible: false,
|
||||||
|
context: context,
|
||||||
|
builder: (_) =>
|
||||||
|
const CancellingTransactionProgressDialog(),
|
||||||
|
));
|
||||||
|
|
||||||
|
final result = await (manager.wallet as EpicCashWallet)
|
||||||
|
.cancelPendingTransactionAndPost(id);
|
||||||
|
if (mounted) {
|
||||||
|
// pop progress dialog
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
|
||||||
|
if (result.isEmpty) {
|
||||||
|
await showDialog<dynamic>(
|
||||||
|
context: context,
|
||||||
|
builder: (_) => StackOkDialog(
|
||||||
|
title: "Transaction cancelled",
|
||||||
|
onOkPressed: (_) {
|
||||||
|
manager.refresh();
|
||||||
|
Navigator.of(context).popUntil(
|
||||||
|
ModalRoute.withName(
|
||||||
|
WalletView.routeName));
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
await showDialog<dynamic>(
|
||||||
|
context: context,
|
||||||
|
builder: (_) => StackOkDialog(
|
||||||
|
title: "Failed to cancel transaction",
|
||||||
|
message: result,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
unawaited(showFloatingFlushBar(
|
unawaited(showFloatingFlushBar(
|
||||||
type: FlushBarType.warning,
|
type: FlushBarType.warning,
|
||||||
message: "Could not find Epic transaction ID",
|
message: "ERROR: Wallet type is not Epic Cash",
|
||||||
context: context,
|
context: context,
|
||||||
));
|
));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
},
|
||||||
unawaited(showDialog<dynamic>(
|
child: Text(
|
||||||
barrierDismissible: false,
|
"Cancel Transaction",
|
||||||
context: context,
|
style: STextStyles.button(context),
|
||||||
builder: (_) =>
|
),
|
||||||
const CancellingTransactionProgressDialog(),
|
|
||||||
));
|
|
||||||
|
|
||||||
final result = await (manager.wallet as EpicCashWallet)
|
|
||||||
.cancelPendingTransactionAndPost(id);
|
|
||||||
if (mounted) {
|
|
||||||
// pop progress dialog
|
|
||||||
Navigator.of(context).pop();
|
|
||||||
|
|
||||||
if (result.isEmpty) {
|
|
||||||
await showDialog<dynamic>(
|
|
||||||
context: context,
|
|
||||||
builder: (_) => StackOkDialog(
|
|
||||||
title: "Transaction cancelled",
|
|
||||||
onOkPressed: (_) {
|
|
||||||
manager.refresh();
|
|
||||||
Navigator.of(context).popUntil(
|
|
||||||
ModalRoute.withName(WalletView.routeName));
|
|
||||||
},
|
|
||||||
),
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
await showDialog<dynamic>(
|
|
||||||
context: context,
|
|
||||||
builder: (_) => StackOkDialog(
|
|
||||||
title: "Failed to cancel transaction",
|
|
||||||
message: result,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
unawaited(showFloatingFlushBar(
|
|
||||||
type: FlushBarType.warning,
|
|
||||||
message: "ERROR: Wallet type is not Epic Cash",
|
|
||||||
context: context,
|
|
||||||
));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
child: Text(
|
|
||||||
"Cancel Transaction",
|
|
||||||
style: STextStyles.button(context),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
|
@ -2,6 +2,8 @@ import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
import 'package:flutter_svg/svg.dart';
|
import 'package:flutter_svg/svg.dart';
|
||||||
import 'package:stackwallet/providers/providers.dart';
|
import 'package:stackwallet/providers/providers.dart';
|
||||||
|
import 'package:stackwallet/services/coins/firo/firo_wallet.dart';
|
||||||
|
import 'package:stackwallet/utilities/amount/amount.dart';
|
||||||
import 'package:stackwallet/utilities/assets.dart';
|
import 'package:stackwallet/utilities/assets.dart';
|
||||||
import 'package:stackwallet/utilities/constants.dart';
|
import 'package:stackwallet/utilities/constants.dart';
|
||||||
import 'package:stackwallet/utilities/enums/coin_enum.dart';
|
import 'package:stackwallet/utilities/enums/coin_enum.dart';
|
||||||
|
@ -212,7 +214,7 @@ class _DesktopChooseFromStackState
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
const Spacer(),
|
const Spacer(),
|
||||||
BalanceDisplay(
|
_BalanceDisplay(
|
||||||
walletId: walletIds[index],
|
walletId: walletIds[index],
|
||||||
),
|
),
|
||||||
const SizedBox(
|
const SizedBox(
|
||||||
|
@ -265,8 +267,8 @@ class _DesktopChooseFromStackState
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class BalanceDisplay extends ConsumerWidget {
|
class _BalanceDisplay extends ConsumerWidget {
|
||||||
const BalanceDisplay({
|
const _BalanceDisplay({
|
||||||
Key? key,
|
Key? key,
|
||||||
required this.walletId,
|
required this.walletId,
|
||||||
}) : super(key: key);
|
}) : super(key: key);
|
||||||
|
@ -280,8 +282,14 @@ class BalanceDisplay extends ConsumerWidget {
|
||||||
final locale = ref.watch(
|
final locale = ref.watch(
|
||||||
localeServiceChangeNotifierProvider.select((value) => value.locale));
|
localeServiceChangeNotifierProvider.select((value) => value.locale));
|
||||||
|
|
||||||
|
Amount total = manager.balance.total;
|
||||||
|
if (manager.coin == Coin.firo || manager.coin == Coin.firoTestNet) {
|
||||||
|
final firoWallet = manager.wallet as FiroWallet;
|
||||||
|
total += firoWallet.balancePrivate.total;
|
||||||
|
}
|
||||||
|
|
||||||
return Text(
|
return Text(
|
||||||
"${manager.balance.spendable.localizedStringAsFixed(locale: locale)} "
|
"${total.localizedStringAsFixed(locale: locale)} "
|
||||||
"${manager.coin.ticker}",
|
"${manager.coin.ticker}",
|
||||||
style: STextStyles.desktopTextExtraSmall(context).copyWith(
|
style: STextStyles.desktopTextExtraSmall(context).copyWith(
|
||||||
color: Theme.of(context).extension<StackColors>()!.textSubtitle1,
|
color: Theme.of(context).extension<StackColors>()!.textSubtitle1,
|
||||||
|
|
|
@ -994,10 +994,11 @@ class _DesktopSendState extends ConsumerState<DesktopSend> {
|
||||||
),
|
),
|
||||||
textAlign: TextAlign.left,
|
textAlign: TextAlign.left,
|
||||||
),
|
),
|
||||||
CustomTextButton(
|
if (coin != Coin.ethereum)
|
||||||
text: "Send all ${coin.ticker}",
|
CustomTextButton(
|
||||||
onTap: sendAllTapped,
|
text: "Send all ${coin.ticker}",
|
||||||
),
|
onTap: sendAllTapped,
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
const SizedBox(
|
const SizedBox(
|
||||||
|
|
|
@ -337,7 +337,7 @@ class RouteGenerator {
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
} else if (args
|
} else if (args
|
||||||
is Tuple4<String, CoinControlViewType, int?, Set<UTXO>?>) {
|
is Tuple4<String, CoinControlViewType, Amount?, Set<UTXO>?>) {
|
||||||
return getRoute(
|
return getRoute(
|
||||||
shouldUseMaterialRoute: useMaterialPageRoute,
|
shouldUseMaterialRoute: useMaterialPageRoute,
|
||||||
builder: (_) => CoinControlView(
|
builder: (_) => CoinControlView(
|
||||||
|
|
|
@ -479,7 +479,7 @@ class EpicCashWallet extends CoinServiceAPI
|
||||||
"minimumConfirmations": MINIMUM_CONFIRMATIONS,
|
"minimumConfirmations": MINIMUM_CONFIRMATIONS,
|
||||||
"message": "",
|
"message": "",
|
||||||
"amount": (txData['recipientAmt'] as Amount).raw.toInt(),
|
"amount": (txData['recipientAmt'] as Amount).raw.toInt(),
|
||||||
"address": (txData['addresss'] as Amount).raw.toInt(),
|
"address": txData['addresss'] as String,
|
||||||
}, name: walletName);
|
}, name: walletName);
|
||||||
|
|
||||||
message = await receivePort.first;
|
message = await receivePort.first;
|
||||||
|
@ -497,7 +497,7 @@ class EpicCashWallet extends CoinServiceAPI
|
||||||
"function": "createTransaction",
|
"function": "createTransaction",
|
||||||
"wallet": wallet!,
|
"wallet": wallet!,
|
||||||
"amount": (txData['recipientAmt'] as Amount).raw.toInt(),
|
"amount": (txData['recipientAmt'] as Amount).raw.toInt(),
|
||||||
"address": (txData['addresss'] as Amount).raw.toInt(),
|
"address": txData['addresss'] as String,
|
||||||
"secretKeyIndex": 0,
|
"secretKeyIndex": 0,
|
||||||
"epicboxConfig": epicboxConfig.toString(),
|
"epicboxConfig": epicboxConfig.toString(),
|
||||||
"minimumConfirmations": MINIMUM_CONFIRMATIONS,
|
"minimumConfirmations": MINIMUM_CONFIRMATIONS,
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:lottie/lottie.dart';
|
import 'package:lottie/lottie.dart';
|
||||||
import 'package:stackwallet/utilities/assets.dart';
|
import 'package:stackwallet/utilities/assets.dart';
|
||||||
|
import 'package:stackwallet/utilities/theme/color_theme.dart';
|
||||||
|
import 'package:stackwallet/utilities/theme/stack_colors.dart';
|
||||||
|
|
||||||
class LoadingIndicator extends StatelessWidget {
|
class LoadingIndicator extends StatelessWidget {
|
||||||
const LoadingIndicator({
|
const LoadingIndicator({
|
||||||
|
@ -14,17 +16,28 @@ class LoadingIndicator extends StatelessWidget {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
final isChan = Theme.of(context).extension<StackColors>()!.themeType ==
|
||||||
|
ThemeType.chan ||
|
||||||
|
Theme.of(context).extension<StackColors>()!.themeType ==
|
||||||
|
ThemeType.darkChans;
|
||||||
|
|
||||||
return Container(
|
return Container(
|
||||||
color: Colors.transparent,
|
color: Colors.transparent,
|
||||||
child: Center(
|
child: Center(
|
||||||
child: SizedBox(
|
child: SizedBox(
|
||||||
width: width,
|
width: width,
|
||||||
height: height,
|
height: height,
|
||||||
child: Lottie.asset(
|
child: isChan
|
||||||
Assets.lottie.test2,
|
? Image(
|
||||||
animate: true,
|
image: AssetImage(
|
||||||
repeat: true,
|
Assets.gif.stacyPlain,
|
||||||
),
|
),
|
||||||
|
)
|
||||||
|
: Lottie.asset(
|
||||||
|
Assets.lottie.test2,
|
||||||
|
animate: true,
|
||||||
|
repeat: true,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
|
@ -2,6 +2,7 @@ import 'dart:async';
|
||||||
|
|
||||||
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/isar/models/ethereum/eth_contract.dart';
|
||||||
import 'package:stackwallet/pages/token_view/token_view.dart';
|
import 'package:stackwallet/pages/token_view/token_view.dart';
|
||||||
import 'package:stackwallet/pages/wallet_view/wallet_view.dart';
|
import 'package:stackwallet/pages/wallet_view/wallet_view.dart';
|
||||||
import 'package:stackwallet/pages_desktop_specific/my_stack_view/wallet_view/desktop_token_view.dart';
|
import 'package:stackwallet/pages_desktop_specific/my_stack_view/wallet_view/desktop_token_view.dart';
|
||||||
|
@ -10,6 +11,7 @@ import 'package:stackwallet/providers/db/main_db_provider.dart';
|
||||||
import 'package:stackwallet/providers/global/secure_store_provider.dart';
|
import 'package:stackwallet/providers/global/secure_store_provider.dart';
|
||||||
import 'package:stackwallet/providers/providers.dart';
|
import 'package:stackwallet/providers/providers.dart';
|
||||||
import 'package:stackwallet/services/coins/ethereum/ethereum_wallet.dart';
|
import 'package:stackwallet/services/coins/ethereum/ethereum_wallet.dart';
|
||||||
|
import 'package:stackwallet/services/coins/manager.dart';
|
||||||
import 'package:stackwallet/services/ethereum/ethereum_token_service.dart';
|
import 'package:stackwallet/services/ethereum/ethereum_token_service.dart';
|
||||||
import 'package:stackwallet/services/transaction_notification_tracker.dart';
|
import 'package:stackwallet/services/transaction_notification_tracker.dart';
|
||||||
import 'package:stackwallet/utilities/constants.dart';
|
import 'package:stackwallet/utilities/constants.dart';
|
||||||
|
@ -35,6 +37,24 @@ class SimpleWalletCard extends ConsumerWidget {
|
||||||
final bool popPrevious;
|
final bool popPrevious;
|
||||||
final NavigatorState? desktopNavigatorState;
|
final NavigatorState? desktopNavigatorState;
|
||||||
|
|
||||||
|
Future<void> _loadTokenWallet(
|
||||||
|
BuildContext context,
|
||||||
|
WidgetRef ref,
|
||||||
|
Manager manager,
|
||||||
|
EthContract contract,
|
||||||
|
) async {
|
||||||
|
ref.read(tokenServiceStateProvider.state).state = EthTokenWallet(
|
||||||
|
token: contract,
|
||||||
|
secureStore: ref.read(secureStoreProvider),
|
||||||
|
ethWallet: manager.wallet as EthereumWallet,
|
||||||
|
tracker: TransactionNotificationTracker(
|
||||||
|
walletId: walletId,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
await ref.read(tokenServiceProvider)!.initialize();
|
||||||
|
}
|
||||||
|
|
||||||
void _openWallet(BuildContext context, WidgetRef ref) async {
|
void _openWallet(BuildContext context, WidgetRef ref) async {
|
||||||
final nav = Navigator.of(context);
|
final nav = Navigator.of(context);
|
||||||
|
|
||||||
|
@ -70,24 +90,18 @@ class SimpleWalletCard extends ConsumerWidget {
|
||||||
if (contractAddress != null) {
|
if (contractAddress != null) {
|
||||||
final contract =
|
final contract =
|
||||||
ref.read(mainDBProvider).getEthContractSync(contractAddress!)!;
|
ref.read(mainDBProvider).getEthContractSync(contractAddress!)!;
|
||||||
ref.read(tokenServiceStateProvider.state).state = EthTokenWallet(
|
|
||||||
token: contract,
|
|
||||||
secureStore: ref.read(secureStoreProvider),
|
|
||||||
ethWallet: manager.wallet as EthereumWallet,
|
|
||||||
tracker: TransactionNotificationTracker(
|
|
||||||
walletId: walletId,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
await showLoading<void>(
|
await showLoading<void>(
|
||||||
whileFuture: ref.read(tokenServiceProvider)!.initialize(),
|
whileFuture: _loadTokenWallet(context, ref, manager, contract),
|
||||||
context: context,
|
context: context,
|
||||||
opaqueBG: true,
|
opaqueBG: true,
|
||||||
message: "Loading ${contract.name}",
|
message: "Loading ${contract.name}",
|
||||||
);
|
);
|
||||||
|
|
||||||
// pop loading
|
if (desktopNavigatorState == null) {
|
||||||
nav.pop();
|
// pop loading
|
||||||
|
nav.pop();
|
||||||
|
}
|
||||||
|
|
||||||
if (desktopNavigatorState != null) {
|
if (desktopNavigatorState != null) {
|
||||||
await desktopNavigatorState!.pushNamed(
|
await desktopNavigatorState!.pushNamed(
|
||||||
|
|
Loading…
Reference in a new issue