exchange form field ui tweak

This commit is contained in:
julian 2023-02-08 11:25:31 -06:00
parent 83bc26921b
commit 7616538248
2 changed files with 14 additions and 20 deletions

View file

@ -708,10 +708,8 @@ class _ExchangeFormState extends ConsumerState<ExchangeForm> {
onChanged: sendFieldOnChanged, onChanged: sendFieldOnChanged,
onButtonTap: selectSendCurrency, onButtonTap: selectSendCurrency,
isWalletCoin: isWalletCoin(coin, true), isWalletCoin: isWalletCoin(coin, true),
image: ref.watch(exchangeFormStateProvider currency: ref.watch(
.select((value) => value.sendCurrency?.image)), exchangeFormStateProvider.select((value) => value.sendCurrency)),
ticker: ref.watch(
exchangeFormStateProvider.select((value) => value.fromTicker)),
), ),
SizedBox( SizedBox(
height: isDesktop ? 10 : 4, height: isDesktop ? 10 : 4,
@ -800,11 +798,8 @@ class _ExchangeFormState extends ConsumerState<ExchangeForm> {
onChanged: receiveFieldOnChanged, onChanged: receiveFieldOnChanged,
onButtonTap: selectReceiveCurrency, onButtonTap: selectReceiveCurrency,
isWalletCoin: isWalletCoin(coin, true), isWalletCoin: isWalletCoin(coin, true),
image: ref.watch(exchangeFormStateProvider currency: ref.watch(exchangeFormStateProvider
.select((value) => value.receiveCurrency?.image)) ?? .select((value) => value.receiveCurrency)),
"",
ticker: ref.watch(
exchangeFormStateProvider.select((value) => value.toTicker)),
readOnly: (rateType) == ExchangeRateType.estimated && readOnly: (rateType) == ExchangeRateType.estimated &&
ref.watch(exchangeProvider).name == ref.watch(exchangeProvider).name ==
ChangeNowExchange.exchangeName, ChangeNowExchange.exchangeName,

View file

@ -1,6 +1,7 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:flutter_svg/svg.dart'; import 'package:flutter_svg/svg.dart';
import 'package:stackwallet/models/isar/exchange_cache/currency.dart';
import 'package:stackwallet/pages/buy_view/sub_widgets/crypto_selection_view.dart'; import 'package:stackwallet/pages/buy_view/sub_widgets/crypto_selection_view.dart';
import 'package:stackwallet/utilities/assets.dart'; import 'package:stackwallet/utilities/assets.dart';
import 'package:stackwallet/utilities/text_styles.dart'; import 'package:stackwallet/utilities/text_styles.dart';
@ -23,8 +24,7 @@ class ExchangeTextField extends StatefulWidget {
this.onSubmitted, this.onSubmitted,
this.onTap, this.onTap,
required this.isWalletCoin, required this.isWalletCoin,
this.image, this.currency,
this.ticker,
this.readOnly = false, this.readOnly = false,
}) : super(key: key); }) : super(key: key);
@ -42,8 +42,7 @@ class ExchangeTextField extends StatefulWidget {
final bool isWalletCoin; final bool isWalletCoin;
final bool readOnly; final bool readOnly;
final String? image; final Currency? currency;
final String? ticker;
@override @override
State<ExchangeTextField> createState() => _ExchangeTextFieldState(); State<ExchangeTextField> createState() => _ExchangeTextFieldState();
@ -115,7 +114,7 @@ class _ExchangeTextFieldState extends State<ExchangeTextField> {
top: 12, top: 12,
left: 12, left: 12,
), ),
hintText: "0", hintText: widget.currency == null ? "select currency" : "0",
hintStyle: STextStyles.fieldLabel(context).copyWith( hintStyle: STextStyles.fieldLabel(context).copyWith(
fontSize: 14, fontSize: 14,
), ),
@ -157,18 +156,18 @@ class _ExchangeTextFieldState extends State<ExchangeTextField> {
), ),
child: Builder( child: Builder(
builder: (context) { builder: (context) {
if (isStackCoin(widget.ticker)) { if (isStackCoin(widget.currency?.ticker)) {
return Center( return Center(
child: getIconForTicker( child: getIconForTicker(
widget.ticker!, widget.currency!.ticker,
size: 18, size: 18,
), ),
); );
} else if (widget.image != null && } else if (widget.currency != null &&
widget.image!.isNotEmpty) { widget.currency!.image.isNotEmpty) {
return Center( return Center(
child: SvgPicture.network( child: SvgPicture.network(
widget.image!, widget.currency!.image,
height: 18, height: 18,
placeholderBuilder: (_) => Container( placeholderBuilder: (_) => Container(
width: 18, width: 18,
@ -215,7 +214,7 @@ class _ExchangeTextFieldState extends State<ExchangeTextField> {
width: 6, width: 6,
), ),
Text( Text(
widget.ticker?.toUpperCase() ?? "-", widget.currency?.ticker.toUpperCase() ?? "n/a",
style: STextStyles.smallMed14(context).copyWith( style: STextStyles.smallMed14(context).copyWith(
color: Theme.of(context) color: Theme.of(context)
.extension<StackColors>()! .extension<StackColors>()!