Merge pull request #475 from cypherstack/ui-fixes

UI fixes
This commit is contained in:
Diego Salazar 2023-04-12 20:28:27 -06:00 committed by GitHub
commit df15461a81
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 443 additions and 286 deletions

View file

@ -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,8 +682,12 @@ 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(
@ -731,7 +735,7 @@ 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(

View file

@ -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(

View file

@ -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(

View file

@ -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

View file

@ -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) {
unawaited(
showFloatingFlushBar(
type: FlushBarType.info, type: FlushBarType.info,
message: "Copied to clipboard", message: "Copied to clipboard",
context: context, 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) {
unawaited(
showFloatingFlushBar(
type: FlushBarType.info, type: FlushBarType.info,
message: "Copied to clipboard", message: "Copied to clipboard",
context: context, 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) {
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,
@ -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(

View file

@ -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,10 +95,16 @@ class _ExchangeProviderOptionsState
onTap: () { onTap: () {
if (ref.read(exchangeFormStateProvider).exchange.name != if (ref.read(exchangeFormStateProvider).exchange.name !=
ChangeNowExchange.exchangeName) { ChangeNowExchange.exchangeName) {
showLoading(
whileFuture:
ref.read(exchangeFormStateProvider).updateExchange( ref.read(exchangeFormStateProvider).updateExchange(
exchange: ChangeNowExchange.instance, exchange: ChangeNowExchange.instance,
shouldUpdateData: true, shouldUpdateData: true,
shouldNotifyListeners: true, shouldNotifyListeners: true,
),
context: context,
message: "Updating rates",
isDesktop: isDesktop,
); );
} }
}, },
@ -333,10 +340,16 @@ class _ExchangeProviderOptionsState
onTap: () { onTap: () {
if (ref.read(exchangeFormStateProvider).exchange.name != if (ref.read(exchangeFormStateProvider).exchange.name !=
MajesticBankExchange.exchangeName) { MajesticBankExchange.exchangeName) {
showLoading(
whileFuture:
ref.read(exchangeFormStateProvider).updateExchange( ref.read(exchangeFormStateProvider).updateExchange(
exchange: MajesticBankExchange.instance, exchange: MajesticBankExchange.instance,
shouldUpdateData: true, shouldUpdateData: true,
shouldNotifyListeners: true, shouldNotifyListeners: true,
),
context: context,
isDesktop: isDesktop,
message: "Updating rates",
); );
} }
}, },

View file

@ -1391,7 +1391,16 @@ class _TransactionDetailsViewState
false && false &&
_transaction.isCancelled == false && _transaction.isCancelled == false &&
_transaction.type == TransactionType.outgoing) _transaction.type == TransactionType.outgoing)
? SizedBox( ? ConditionalParent(
condition: isDesktop,
builder: (child) => Padding(
padding: const EdgeInsets.symmetric(
horizontal: 32,
vertical: 16,
),
child: child,
),
child: SizedBox(
width: MediaQuery.of(context).size.width - 32, width: MediaQuery.of(context).size.width - 32,
child: TextButton( child: TextButton(
style: ButtonStyle( style: ButtonStyle(
@ -1436,7 +1445,8 @@ class _TransactionDetailsViewState
onOkPressed: (_) { onOkPressed: (_) {
manager.refresh(); manager.refresh();
Navigator.of(context).popUntil( Navigator.of(context).popUntil(
ModalRoute.withName(WalletView.routeName)); ModalRoute.withName(
WalletView.routeName));
}, },
), ),
); );
@ -1464,6 +1474,7 @@ class _TransactionDetailsViewState
style: STextStyles.button(context), style: STextStyles.button(context),
), ),
), ),
),
) )
: null, : null,
), ),

View file

@ -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,

View file

@ -994,6 +994,7 @@ class _DesktopSendState extends ConsumerState<DesktopSend> {
), ),
textAlign: TextAlign.left, textAlign: TextAlign.left,
), ),
if (coin != Coin.ethereum)
CustomTextButton( CustomTextButton(
text: "Send all ${coin.ticker}", text: "Send all ${coin.ticker}",
onTap: sendAllTapped, onTap: sendAllTapped,

View file

@ -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(

View file

@ -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,

View file

@ -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,13 +16,24 @@ 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
? Image(
image: AssetImage(
Assets.gif.stacyPlain,
),
)
: Lottie.asset(
Assets.lottie.test2, Assets.lottie.test2,
animate: true, animate: true,
repeat: true, repeat: true,

View file

@ -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}",
); );
if (desktopNavigatorState == null) {
// pop loading // pop loading
nav.pop(); nav.pop();
}
if (desktopNavigatorState != null) { if (desktopNavigatorState != null) {
await desktopNavigatorState!.pushNamed( await desktopNavigatorState!.pushNamed(