Merge remote-tracking branch 'origin_sw/ui-fixes' into ui-fixes

This commit is contained in:
Julian 2023-12-11 13:00:55 -06:00
commit 50a3e8e4da
3 changed files with 36 additions and 9 deletions

View file

@ -108,6 +108,7 @@ class _ExchangeCurrencySelectionViewState
if (widget.pairedTicker == null) { if (widget.pairedTicker == null) {
return await _getCurrencies(); return await _getCurrencies();
} }
await ExchangeDataLoadingService.instance.initDB();
List<Currency> currencies = await ExchangeDataLoadingService List<Currency> currencies = await ExchangeDataLoadingService
.instance.isar.currencies .instance.isar.currencies
.where() .where()
@ -157,6 +158,7 @@ class _ExchangeCurrencySelectionViewState
} }
Future<List<Currency>> _getCurrencies() async { Future<List<Currency>> _getCurrencies() async {
await ExchangeDataLoadingService.instance.initDB();
final currencies = await ExchangeDataLoadingService.instance.isar.currencies final currencies = await ExchangeDataLoadingService.instance.isar.currencies
.where() .where()
.filter() .filter()

View file

@ -88,7 +88,10 @@ class _TradeDetailsViewState extends ConsumerState<TradeDetailsView> {
bool isStackCoin(String ticker) { bool isStackCoin(String ticker) {
try { try {
coinFromTickerCaseInsensitive(ticker); try {
coinFromTickerCaseInsensitive(ticker);
} catch (_) {}
coinFromPrettyName(ticker);
return true; return true;
} on ArgumentError catch (_) { } on ArgumentError catch (_) {
return false; return false;
@ -272,10 +275,17 @@ class _TradeDetailsViewState extends ConsumerState<TradeDetailsView> {
label: "Send from Stack", label: "Send from Stack",
buttonHeight: ButtonHeight.l, buttonHeight: ButtonHeight.l,
onPressed: () { onPressed: () {
final coin = Coin coin;
coinFromTickerCaseInsensitive(trade.payInCurrency); try {
final amount = coin = coinFromTickerCaseInsensitive(
sendAmount.toAmount(fractionDigits: coin.decimals); trade.payInCurrency);
} catch (_) {
coin = coinFromPrettyName(trade.payInCurrency);
}
final amount = Amount.fromDecimal(
sendAmount,
fractionDigits: coin.decimals,
);
final address = trade.payInAddress; final address = trade.payInAddress;
Navigator.of(context).pushNamed( Navigator.of(context).pushNamed(
@ -1347,12 +1357,18 @@ class _TradeDetailsViewState extends ConsumerState<TradeDetailsView> {
SecondaryButton( SecondaryButton(
label: "Send from Stack", label: "Send from Stack",
onPressed: () { onPressed: () {
final amount = sendAmount; Coin coin;
try {
coin = coinFromTickerCaseInsensitive(trade.payInCurrency);
} catch (_) {
coin = coinFromPrettyName(trade.payInCurrency);
}
final amount = Amount.fromDecimal(
sendAmount,
fractionDigits: coin.decimals,
);
final address = trade.payInAddress; final address = trade.payInAddress;
final coin =
coinFromTickerCaseInsensitive(trade.payInCurrency);
Navigator.of(context).pushNamed( Navigator.of(context).pushNamed(
SendFromView.routeName, SendFromView.routeName,
arguments: Tuple4( arguments: Tuple4(

View file

@ -196,6 +196,9 @@ class ExchangeDataLoadingService {
} }
Future<void> _loadChangeNowCurrencies() async { Future<void> _loadChangeNowCurrencies() async {
if (_isar == null) {
await initDB();
}
final exchange = ChangeNowExchange.instance; final exchange = ChangeNowExchange.instance;
final responseCurrencies = await exchange.getAllCurrencies(false); final responseCurrencies = await exchange.getAllCurrencies(false);
if (responseCurrencies.value != null) { if (responseCurrencies.value != null) {
@ -325,6 +328,9 @@ class ExchangeDataLoadingService {
// } // }
Future<void> loadMajesticBankCurrencies() async { Future<void> loadMajesticBankCurrencies() async {
if (_isar == null) {
await initDB();
}
final exchange = MajesticBankExchange.instance; final exchange = MajesticBankExchange.instance;
final responseCurrencies = await exchange.getAllCurrencies(false); final responseCurrencies = await exchange.getAllCurrencies(false);
@ -347,6 +353,9 @@ class ExchangeDataLoadingService {
} }
Future<void> loadTrocadorCurrencies() async { Future<void> loadTrocadorCurrencies() async {
if (_isar == null) {
await initDB();
}
final exchange = TrocadorExchange.instance; final exchange = TrocadorExchange.instance;
final responseCurrencies = await exchange.getAllCurrencies(false); final responseCurrencies = await exchange.getAllCurrencies(false);