formatting, linter fixes, don't call apis in build method

This commit is contained in:
julian 2023-01-14 10:41:02 -06:00
parent f80b47d467
commit 2f0824b1f4
2 changed files with 449 additions and 453 deletions

View file

@ -247,6 +247,11 @@ class _BuyFormState extends ConsumerState<BuyForm> {
coins = ref.read(supportedSimplexCurrenciesProvider).supportedCryptos;
fiats = ref.read(supportedSimplexCurrenciesProvider).supportedFiats;
WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
BuyDataLoadingService().loadAll(
ref); // Why does this need to be called here? Shouldn't it already be called by main.dart?
});
// TODO set initial crypto to open wallet if a wallet is open
super.initState();
@ -264,10 +269,7 @@ class _BuyFormState extends ConsumerState<BuyForm> {
buyWithFiat = ref.watch(
prefsChangeNotifierProvider.select((value) => value.buyWithFiat));
BuyDataLoadingService().loadAll(
ref); // Why does this need to be called here? Shouldn't it already be called by main.dart?
return Container(
return SizedBox(
width:
458, // TODO test that this displays well on mobile or else put in a ternary or something else appropriate to switch here
child: Column(
@ -292,8 +294,7 @@ class _BuyFormState extends ConsumerState<BuyForm> {
selectCrypto();
},
child: RoundedContainer(
padding:
const EdgeInsets.symmetric(vertical: 6, horizontal: 6),
padding: const EdgeInsets.symmetric(vertical: 6, horizontal: 6),
color: _hovering1
? Theme.of(context)
.extension<StackColors>()!
@ -343,8 +344,7 @@ class _BuyFormState extends ConsumerState<BuyForm> {
Text(
"I want to pay with",
style: STextStyles.itemSubtitle(context).copyWith(
color:
Theme.of(context).extension<StackColors>()!.textDark3,
color: Theme.of(context).extension<StackColors>()!.textDark3,
),
),
],
@ -362,8 +362,7 @@ class _BuyFormState extends ConsumerState<BuyForm> {
selectFiat();
},
child: RoundedContainer(
padding:
const EdgeInsets.symmetric(vertical: 3, horizontal: 6),
padding: const EdgeInsets.symmetric(vertical: 3, horizontal: 6),
color: _hovering2
? Theme.of(context)
.extension<StackColors>()!
@ -379,9 +378,8 @@ class _BuyFormState extends ConsumerState<BuyForm> {
radiusMultiplier: 0.5,
padding: const EdgeInsets.symmetric(
vertical: 2, horizontal: 4),
color: Theme.of(context)
.extension<StackColors>()!
.highlight,
color:
Theme.of(context).extension<StackColors>()!.highlight,
child: Text(
"\$",
style: STextStyles.itemSubtitle12(context),
@ -425,8 +423,7 @@ class _BuyFormState extends ConsumerState<BuyForm> {
Text(
buyWithFiat ? "Enter amount" : "Enter crypto amount",
style: STextStyles.itemSubtitle(context).copyWith(
color:
Theme.of(context).extension<StackColors>()!.textDark3,
color: Theme.of(context).extension<StackColors>()!.textDark3,
),
),
const FiatCryptoToggle(),
@ -500,8 +497,7 @@ class _BuyFormState extends ConsumerState<BuyForm> {
Text(
"Enter receiving address",
style: STextStyles.itemSubtitle(context).copyWith(
color:
Theme.of(context).extension<StackColors>()!.textDark3,
color: Theme.of(context).extension<StackColors>()!.textDark3,
),
),
],
@ -604,8 +600,7 @@ class _BuyFormState extends ConsumerState<BuyForm> {
TextFieldIconButton(
key: const Key("buyViewAddressBookButtonKey"),
onTap: () {
print(
'TODO tapped buyViewAddressBookButtonKey');
print('TODO tapped buyViewAddressBookButtonKey');
// Navigator.of(context).pushNamed(
// AddressBookView.routeName,
// arguments: widget.coin,
@ -636,8 +631,8 @@ class _BuyFormState extends ConsumerState<BuyForm> {
"qrResult content: ${qrResult.rawContent}",
level: LogLevel.Info);
final results = AddressUtils.parseUri(
qrResult.rawContent);
final results =
AddressUtils.parseUri(qrResult.rawContent);
Logging.instance.log(
"qrResult parsed: $results",
@ -725,14 +720,15 @@ class _BuyFormState extends ConsumerState<BuyForm> {
),
PrimaryButton(
buttonHeight: isDesktop ? ButtonHeight.l : null,
enabled: ref.watch(exchangeFormStateProvider
.select((value) => value.canExchange)),
enabled: ref.watch(
exchangeFormStateProvider.select((value) => value.canExchange)),
onPressed: () {
// TODO implement buy confirmation dialog
},
label: "Exchange",
)
],
));
),
);
}
}

View file

@ -11,10 +11,9 @@ class BuyView extends StatefulWidget {
class _BuyViewState extends State<BuyView> {
@override
Widget build(BuildContext context) {
//todo: check if print needed
// debugPrint("BUILD: BuyView");
debugPrint("BUILD: $runtimeType");
return SafeArea(
return const SafeArea(
child: Padding(
padding: EdgeInsets.only(
left: 16,
@ -22,6 +21,7 @@ class _BuyViewState extends State<BuyView> {
top: 16,
),
child: BuyForm(),
));
),
);
}
}