mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2025-01-10 20:54:33 +00:00
formatting, linter fixes, don't call apis in build method
This commit is contained in:
parent
f80b47d467
commit
2f0824b1f4
2 changed files with 449 additions and 453 deletions
|
@ -247,6 +247,11 @@ class _BuyFormState extends ConsumerState<BuyForm> {
|
||||||
coins = ref.read(supportedSimplexCurrenciesProvider).supportedCryptos;
|
coins = ref.read(supportedSimplexCurrenciesProvider).supportedCryptos;
|
||||||
fiats = ref.read(supportedSimplexCurrenciesProvider).supportedFiats;
|
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
|
// TODO set initial crypto to open wallet if a wallet is open
|
||||||
|
|
||||||
super.initState();
|
super.initState();
|
||||||
|
@ -264,475 +269,466 @@ class _BuyFormState extends ConsumerState<BuyForm> {
|
||||||
buyWithFiat = ref.watch(
|
buyWithFiat = ref.watch(
|
||||||
prefsChangeNotifierProvider.select((value) => value.buyWithFiat));
|
prefsChangeNotifierProvider.select((value) => value.buyWithFiat));
|
||||||
|
|
||||||
BuyDataLoadingService().loadAll(
|
return SizedBox(
|
||||||
ref); // Why does this need to be called here? Shouldn't it already be called by main.dart?
|
width:
|
||||||
|
458, // TODO test that this displays well on mobile or else put in a ternary or something else appropriate to switch here
|
||||||
return Container(
|
child: Column(
|
||||||
width:
|
mainAxisSize: MainAxisSize.min,
|
||||||
458, // TODO test that this displays well on mobile or else put in a ternary or something else appropriate to switch here
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||||
child: Column(
|
children: [
|
||||||
mainAxisSize: MainAxisSize.min,
|
Text(
|
||||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
"I want to buy",
|
||||||
children: [
|
style: STextStyles.itemSubtitle(context).copyWith(
|
||||||
Text(
|
color: Theme.of(context).extension<StackColors>()!.textDark3,
|
||||||
"I want to buy",
|
|
||||||
style: STextStyles.itemSubtitle(context).copyWith(
|
|
||||||
color: Theme.of(context).extension<StackColors>()!.textDark3,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
SizedBox(
|
),
|
||||||
height: isDesktop ? 10 : 4,
|
SizedBox(
|
||||||
),
|
height: isDesktop ? 10 : 4,
|
||||||
MouseRegion(
|
),
|
||||||
cursor: SystemMouseCursors.click,
|
MouseRegion(
|
||||||
onEnter: (_) => setState(() => _hovering1 = true),
|
cursor: SystemMouseCursors.click,
|
||||||
onExit: (_) => setState(() => _hovering1 = false),
|
onEnter: (_) => setState(() => _hovering1 = true),
|
||||||
child: GestureDetector(
|
onExit: (_) => setState(() => _hovering1 = false),
|
||||||
onTap: () {
|
child: GestureDetector(
|
||||||
selectCrypto();
|
onTap: () {
|
||||||
},
|
selectCrypto();
|
||||||
child: RoundedContainer(
|
},
|
||||||
padding:
|
child: RoundedContainer(
|
||||||
const EdgeInsets.symmetric(vertical: 6, horizontal: 6),
|
padding: const EdgeInsets.symmetric(vertical: 6, horizontal: 6),
|
||||||
color: _hovering1
|
color: _hovering1
|
||||||
? Theme.of(context)
|
? Theme.of(context)
|
||||||
.extension<StackColors>()!
|
.extension<StackColors>()!
|
||||||
.highlight
|
.highlight
|
||||||
.withOpacity(_hovering1 ? 0.3 : 0)
|
.withOpacity(_hovering1 ? 0.3 : 0)
|
||||||
: Theme.of(context)
|
: Theme.of(context)
|
||||||
.extension<StackColors>()!
|
.extension<StackColors>()!
|
||||||
.textFieldDefaultBG,
|
.textFieldDefaultBG,
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.all(12),
|
padding: const EdgeInsets.all(12),
|
||||||
child: Row(children: <Widget>[
|
child: Row(children: <Widget>[
|
||||||
SvgPicture.asset(
|
SvgPicture.asset(
|
||||||
Assets.svg.iconFor(
|
Assets.svg.iconFor(
|
||||||
coin: coinFromTickerCaseInsensitive("BTC"),
|
coin: coinFromTickerCaseInsensitive("BTC"),
|
||||||
),
|
|
||||||
height: 18,
|
|
||||||
width: 18,
|
|
||||||
),
|
),
|
||||||
const SizedBox(
|
height: 18,
|
||||||
width: 10,
|
width: 18,
|
||||||
),
|
),
|
||||||
Expanded(
|
const SizedBox(
|
||||||
child: Text(
|
width: 10,
|
||||||
"BTC",
|
),
|
||||||
style: STextStyles.largeMedium14(context),
|
Expanded(
|
||||||
)),
|
|
||||||
SvgPicture.asset(
|
|
||||||
Assets.svg.chevronDown,
|
|
||||||
color: Theme.of(context)
|
|
||||||
.extension<StackColors>()!
|
|
||||||
.buttonTextSecondaryDisabled,
|
|
||||||
width: 10,
|
|
||||||
height: 5,
|
|
||||||
),
|
|
||||||
]),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
SizedBox(
|
|
||||||
height: isDesktop ? 20 : 12,
|
|
||||||
),
|
|
||||||
Row(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.end,
|
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
||||||
children: [
|
|
||||||
Text(
|
|
||||||
"I want to pay with",
|
|
||||||
style: STextStyles.itemSubtitle(context).copyWith(
|
|
||||||
color:
|
|
||||||
Theme.of(context).extension<StackColors>()!.textDark3,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
SizedBox(
|
|
||||||
height: isDesktop ? 10 : 4,
|
|
||||||
),
|
|
||||||
|
|
||||||
MouseRegion(
|
|
||||||
cursor: SystemMouseCursors.click,
|
|
||||||
onEnter: (_) => setState(() => _hovering2 = true),
|
|
||||||
onExit: (_) => setState(() => _hovering2 = false),
|
|
||||||
child: GestureDetector(
|
|
||||||
onTap: () {
|
|
||||||
selectFiat();
|
|
||||||
},
|
|
||||||
child: RoundedContainer(
|
|
||||||
padding:
|
|
||||||
const EdgeInsets.symmetric(vertical: 3, horizontal: 6),
|
|
||||||
color: _hovering2
|
|
||||||
? Theme.of(context)
|
|
||||||
.extension<StackColors>()!
|
|
||||||
.highlight
|
|
||||||
.withOpacity(_hovering2 ? 0.3 : 0)
|
|
||||||
: Theme.of(context)
|
|
||||||
.extension<StackColors>()!
|
|
||||||
.textFieldDefaultBG,
|
|
||||||
child: Padding(
|
|
||||||
padding: const EdgeInsets.all(12),
|
|
||||||
child: Row(children: <Widget>[
|
|
||||||
RoundedContainer(
|
|
||||||
radiusMultiplier: 0.5,
|
|
||||||
padding: const EdgeInsets.symmetric(
|
|
||||||
vertical: 2, horizontal: 4),
|
|
||||||
color: Theme.of(context)
|
|
||||||
.extension<StackColors>()!
|
|
||||||
.highlight,
|
|
||||||
child: Text(
|
child: Text(
|
||||||
"\$",
|
"BTC",
|
||||||
style: STextStyles.itemSubtitle12(context),
|
style: STextStyles.largeMedium14(context),
|
||||||
),
|
)),
|
||||||
|
SvgPicture.asset(
|
||||||
|
Assets.svg.chevronDown,
|
||||||
|
color: Theme.of(context)
|
||||||
|
.extension<StackColors>()!
|
||||||
|
.buttonTextSecondaryDisabled,
|
||||||
|
width: 10,
|
||||||
|
height: 5,
|
||||||
|
),
|
||||||
|
]),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
SizedBox(
|
||||||
|
height: isDesktop ? 20 : 12,
|
||||||
|
),
|
||||||
|
Row(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.end,
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
"I want to pay with",
|
||||||
|
style: STextStyles.itemSubtitle(context).copyWith(
|
||||||
|
color: Theme.of(context).extension<StackColors>()!.textDark3,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
SizedBox(
|
||||||
|
height: isDesktop ? 10 : 4,
|
||||||
|
),
|
||||||
|
|
||||||
|
MouseRegion(
|
||||||
|
cursor: SystemMouseCursors.click,
|
||||||
|
onEnter: (_) => setState(() => _hovering2 = true),
|
||||||
|
onExit: (_) => setState(() => _hovering2 = false),
|
||||||
|
child: GestureDetector(
|
||||||
|
onTap: () {
|
||||||
|
selectFiat();
|
||||||
|
},
|
||||||
|
child: RoundedContainer(
|
||||||
|
padding: const EdgeInsets.symmetric(vertical: 3, horizontal: 6),
|
||||||
|
color: _hovering2
|
||||||
|
? Theme.of(context)
|
||||||
|
.extension<StackColors>()!
|
||||||
|
.highlight
|
||||||
|
.withOpacity(_hovering2 ? 0.3 : 0)
|
||||||
|
: Theme.of(context)
|
||||||
|
.extension<StackColors>()!
|
||||||
|
.textFieldDefaultBG,
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.all(12),
|
||||||
|
child: Row(children: <Widget>[
|
||||||
|
RoundedContainer(
|
||||||
|
radiusMultiplier: 0.5,
|
||||||
|
padding: const EdgeInsets.symmetric(
|
||||||
|
vertical: 2, horizontal: 4),
|
||||||
|
color:
|
||||||
|
Theme.of(context).extension<StackColors>()!.highlight,
|
||||||
|
child: Text(
|
||||||
|
"\$",
|
||||||
|
style: STextStyles.itemSubtitle12(context),
|
||||||
),
|
),
|
||||||
// SvgPicture.asset(
|
),
|
||||||
// Assets.svg.iconFor(
|
// SvgPicture.asset(
|
||||||
// coin: coinFromTickerCaseInsensitive("BTC"),
|
// Assets.svg.iconFor(
|
||||||
// ),
|
// coin: coinFromTickerCaseInsensitive("BTC"),
|
||||||
// height: 18,
|
// ),
|
||||||
// width: 18,
|
// height: 18,
|
||||||
// ),
|
// width: 18,
|
||||||
const SizedBox(
|
// ),
|
||||||
width: 10,
|
const SizedBox(
|
||||||
),
|
width: 10,
|
||||||
Expanded(
|
),
|
||||||
child: Text(
|
Expanded(
|
||||||
"USD",
|
child: Text(
|
||||||
style: STextStyles.largeMedium14(context),
|
"USD",
|
||||||
)),
|
style: STextStyles.largeMedium14(context),
|
||||||
SvgPicture.asset(
|
)),
|
||||||
Assets.svg.chevronDown,
|
SvgPicture.asset(
|
||||||
|
Assets.svg.chevronDown,
|
||||||
|
color: Theme.of(context)
|
||||||
|
.extension<StackColors>()!
|
||||||
|
.buttonTextSecondaryDisabled,
|
||||||
|
width: 10,
|
||||||
|
height: 5,
|
||||||
|
),
|
||||||
|
]),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
SizedBox(
|
||||||
|
height: isDesktop ? 10 : 4,
|
||||||
|
),
|
||||||
|
Row(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.end,
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
buyWithFiat ? "Enter amount" : "Enter crypto amount",
|
||||||
|
style: STextStyles.itemSubtitle(context).copyWith(
|
||||||
|
color: Theme.of(context).extension<StackColors>()!.textDark3,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const FiatCryptoToggle(),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
// // these reads should be watch
|
||||||
|
// if (ref.watch(buyFormStateProvider).fromAmount != null &&
|
||||||
|
// ref.watch(buyFormStateProvider).fromAmount != Decimal.zero)
|
||||||
|
SizedBox(
|
||||||
|
height: isDesktop ? 10 : 4,
|
||||||
|
),
|
||||||
|
TextField(
|
||||||
|
autocorrect: Util.isDesktop ? false : true,
|
||||||
|
enableSuggestions: Util.isDesktop ? false : true,
|
||||||
|
style: STextStyles.smallMed14(context).copyWith(
|
||||||
|
color: Theme.of(context).extension<StackColors>()!.textDark,
|
||||||
|
),
|
||||||
|
key: const Key("amountInputFieldCryptoTextFieldKey"),
|
||||||
|
controller: _buyAmountController,
|
||||||
|
focusNode: _buyAmountFocusNode,
|
||||||
|
keyboardType: Util.isDesktop
|
||||||
|
? null
|
||||||
|
: const TextInputType.numberWithOptions(
|
||||||
|
signed: false,
|
||||||
|
decimal: true,
|
||||||
|
),
|
||||||
|
textAlign: TextAlign.right,
|
||||||
|
inputFormatters: [
|
||||||
|
// TODO reactivate formatter
|
||||||
|
// regex to validate a crypto amount with 8 decimal places
|
||||||
|
// TextInputFormatter.withFunction((oldValue, newValue) =>
|
||||||
|
// RegExp(r'^([0-9]*[,.]?[0-9]{0,8}|[,.][0-9]{0,8})$')
|
||||||
|
// .hasMatch(newValue.text)
|
||||||
|
// ? newValue
|
||||||
|
// : oldValue),
|
||||||
|
],
|
||||||
|
decoration: InputDecoration(
|
||||||
|
contentPadding: const EdgeInsets.only(
|
||||||
|
top: 22,
|
||||||
|
right: 12,
|
||||||
|
bottom: 22,
|
||||||
|
),
|
||||||
|
hintText: "0",
|
||||||
|
hintStyle: STextStyles.desktopTextExtraSmall(context).copyWith(
|
||||||
|
color: Theme.of(context)
|
||||||
|
.extension<StackColors>()!
|
||||||
|
.textFieldDefaultText,
|
||||||
|
),
|
||||||
|
prefixIcon: FittedBox(
|
||||||
|
fit: BoxFit.scaleDown,
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.all(12),
|
||||||
|
child: Text(
|
||||||
|
"BTC",
|
||||||
|
style: STextStyles.smallMed14(context).copyWith(
|
||||||
color: Theme.of(context)
|
color: Theme.of(context)
|
||||||
.extension<StackColors>()!
|
.extension<StackColors>()!
|
||||||
.buttonTextSecondaryDisabled,
|
.accentColorDark),
|
||||||
width: 10,
|
|
||||||
height: 5,
|
|
||||||
),
|
|
||||||
]),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
SizedBox(
|
),
|
||||||
height: isDesktop ? 10 : 4,
|
SizedBox(
|
||||||
),
|
height: isDesktop ? 20 : 12,
|
||||||
Row(
|
),
|
||||||
crossAxisAlignment: CrossAxisAlignment.end,
|
Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
crossAxisAlignment: CrossAxisAlignment.end,
|
||||||
children: [
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
Text(
|
children: [
|
||||||
buyWithFiat ? "Enter amount" : "Enter crypto amount",
|
Text(
|
||||||
style: STextStyles.itemSubtitle(context).copyWith(
|
"Enter receiving address",
|
||||||
color:
|
style: STextStyles.itemSubtitle(context).copyWith(
|
||||||
Theme.of(context).extension<StackColors>()!.textDark3,
|
color: Theme.of(context).extension<StackColors>()!.textDark3,
|
||||||
),
|
|
||||||
),
|
),
|
||||||
const FiatCryptoToggle(),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
// // these reads should be watch
|
|
||||||
// if (ref.watch(buyFormStateProvider).fromAmount != null &&
|
|
||||||
// ref.watch(buyFormStateProvider).fromAmount != Decimal.zero)
|
|
||||||
SizedBox(
|
|
||||||
height: isDesktop ? 10 : 4,
|
|
||||||
),
|
|
||||||
TextField(
|
|
||||||
autocorrect: Util.isDesktop ? false : true,
|
|
||||||
enableSuggestions: Util.isDesktop ? false : true,
|
|
||||||
style: STextStyles.smallMed14(context).copyWith(
|
|
||||||
color: Theme.of(context).extension<StackColors>()!.textDark,
|
|
||||||
),
|
),
|
||||||
key: const Key("amountInputFieldCryptoTextFieldKey"),
|
],
|
||||||
controller: _buyAmountController,
|
),
|
||||||
focusNode: _buyAmountFocusNode,
|
SizedBox(
|
||||||
keyboardType: Util.isDesktop
|
height: isDesktop ? 10 : 4,
|
||||||
? null
|
),
|
||||||
: const TextInputType.numberWithOptions(
|
ClipRRect(
|
||||||
signed: false,
|
borderRadius: BorderRadius.circular(
|
||||||
decimal: true,
|
Constants.size.circularBorderRadius,
|
||||||
),
|
),
|
||||||
textAlign: TextAlign.right,
|
child: TextField(
|
||||||
inputFormatters: [
|
key: const Key("buyViewReceiveAddressFieldKey"),
|
||||||
// TODO reactivate formatter
|
controller: _receiveAddressController,
|
||||||
// regex to validate a crypto amount with 8 decimal places
|
readOnly: false,
|
||||||
// TextInputFormatter.withFunction((oldValue, newValue) =>
|
autocorrect: false,
|
||||||
// RegExp(r'^([0-9]*[,.]?[0-9]{0,8}|[,.][0-9]{0,8})$')
|
enableSuggestions: false,
|
||||||
// .hasMatch(newValue.text)
|
// inputFormatters: <TextInputFormatter>[
|
||||||
// ? newValue
|
// FilteringTextInputFormatter.allow(
|
||||||
// : oldValue),
|
// RegExp("[a-zA-Z0-9]{34}")),
|
||||||
],
|
// ],
|
||||||
decoration: InputDecoration(
|
toolbarOptions: const ToolbarOptions(
|
||||||
|
copy: false,
|
||||||
|
cut: false,
|
||||||
|
paste: true,
|
||||||
|
selectAll: false,
|
||||||
|
),
|
||||||
|
onChanged: (newValue) {
|
||||||
|
_address = newValue;
|
||||||
|
setState(() {
|
||||||
|
_addressToggleFlag = newValue.isNotEmpty;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
focusNode: _receiveAddressFocusNode,
|
||||||
|
style: STextStyles.field(context),
|
||||||
|
decoration: standardInputDecoration(
|
||||||
|
/*"Enter ${coin.ticker} address",*/
|
||||||
|
"Enter address",
|
||||||
|
_receiveAddressFocusNode,
|
||||||
|
context,
|
||||||
|
).copyWith(
|
||||||
contentPadding: const EdgeInsets.only(
|
contentPadding: const EdgeInsets.only(
|
||||||
top: 22,
|
left: 16,
|
||||||
right: 12,
|
top: 6,
|
||||||
bottom: 22,
|
bottom: 8,
|
||||||
|
right: 5,
|
||||||
),
|
),
|
||||||
hintText: "0",
|
suffixIcon: Padding(
|
||||||
hintStyle: STextStyles.desktopTextExtraSmall(context).copyWith(
|
padding: _receiveAddressController.text.isEmpty
|
||||||
color: Theme.of(context)
|
? const EdgeInsets.only(right: 8)
|
||||||
.extension<StackColors>()!
|
: const EdgeInsets.only(right: 0),
|
||||||
.textFieldDefaultText,
|
child: UnconstrainedBox(
|
||||||
),
|
child: Row(
|
||||||
prefixIcon: FittedBox(
|
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||||
fit: BoxFit.scaleDown,
|
children: [
|
||||||
child: Padding(
|
_addressToggleFlag
|
||||||
padding: const EdgeInsets.all(12),
|
? TextFieldIconButton(
|
||||||
child: Text(
|
key: const Key(
|
||||||
"BTC",
|
"buyViewClearAddressFieldButtonKey"),
|
||||||
style: STextStyles.smallMed14(context).copyWith(
|
onTap: () {
|
||||||
color: Theme.of(context)
|
_receiveAddressController.text = "";
|
||||||
.extension<StackColors>()!
|
// _receiveAddress = "";
|
||||||
.accentColorDark),
|
setState(() {
|
||||||
),
|
_addressToggleFlag = false;
|
||||||
),
|
});
|
||||||
),
|
},
|
||||||
),
|
child: const XIcon(),
|
||||||
),
|
)
|
||||||
SizedBox(
|
: TextFieldIconButton(
|
||||||
height: isDesktop ? 20 : 12,
|
key: const Key(
|
||||||
),
|
"buyViewPasteAddressFieldButtonKey"),
|
||||||
Row(
|
onTap: () async {
|
||||||
crossAxisAlignment: CrossAxisAlignment.end,
|
print(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
"TODO paste; Error: 'ClipboardData' isn't a type.");
|
||||||
children: [
|
// final ClipboardData? data = await clipboard
|
||||||
Text(
|
// .getData(Clipboard.kTextPlain);
|
||||||
"Enter receiving address",
|
// if (data?.text != null &&
|
||||||
style: STextStyles.itemSubtitle(context).copyWith(
|
// data!.text!.isNotEmpty) {
|
||||||
color:
|
// String content = data.text!.trim();
|
||||||
Theme.of(context).extension<StackColors>()!.textDark3,
|
// if (content.contains("\n")) {
|
||||||
),
|
// content = content.substring(
|
||||||
),
|
// 0, content.indexOf("\n"));
|
||||||
],
|
|
||||||
),
|
|
||||||
SizedBox(
|
|
||||||
height: isDesktop ? 10 : 4,
|
|
||||||
),
|
|
||||||
ClipRRect(
|
|
||||||
borderRadius: BorderRadius.circular(
|
|
||||||
Constants.size.circularBorderRadius,
|
|
||||||
),
|
|
||||||
child: TextField(
|
|
||||||
key: const Key("buyViewReceiveAddressFieldKey"),
|
|
||||||
controller: _receiveAddressController,
|
|
||||||
readOnly: false,
|
|
||||||
autocorrect: false,
|
|
||||||
enableSuggestions: false,
|
|
||||||
// inputFormatters: <TextInputFormatter>[
|
|
||||||
// FilteringTextInputFormatter.allow(
|
|
||||||
// RegExp("[a-zA-Z0-9]{34}")),
|
|
||||||
// ],
|
|
||||||
toolbarOptions: const ToolbarOptions(
|
|
||||||
copy: false,
|
|
||||||
cut: false,
|
|
||||||
paste: true,
|
|
||||||
selectAll: false,
|
|
||||||
),
|
|
||||||
onChanged: (newValue) {
|
|
||||||
_address = newValue;
|
|
||||||
setState(() {
|
|
||||||
_addressToggleFlag = newValue.isNotEmpty;
|
|
||||||
});
|
|
||||||
},
|
|
||||||
focusNode: _receiveAddressFocusNode,
|
|
||||||
style: STextStyles.field(context),
|
|
||||||
decoration: standardInputDecoration(
|
|
||||||
/*"Enter ${coin.ticker} address",*/
|
|
||||||
"Enter address",
|
|
||||||
_receiveAddressFocusNode,
|
|
||||||
context,
|
|
||||||
).copyWith(
|
|
||||||
contentPadding: const EdgeInsets.only(
|
|
||||||
left: 16,
|
|
||||||
top: 6,
|
|
||||||
bottom: 8,
|
|
||||||
right: 5,
|
|
||||||
),
|
|
||||||
suffixIcon: Padding(
|
|
||||||
padding: _receiveAddressController.text.isEmpty
|
|
||||||
? const EdgeInsets.only(right: 8)
|
|
||||||
: const EdgeInsets.only(right: 0),
|
|
||||||
child: UnconstrainedBox(
|
|
||||||
child: Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
|
||||||
children: [
|
|
||||||
_addressToggleFlag
|
|
||||||
? TextFieldIconButton(
|
|
||||||
key: const Key(
|
|
||||||
"buyViewClearAddressFieldButtonKey"),
|
|
||||||
onTap: () {
|
|
||||||
_receiveAddressController.text = "";
|
|
||||||
// _receiveAddress = "";
|
|
||||||
setState(() {
|
|
||||||
_addressToggleFlag = false;
|
|
||||||
});
|
|
||||||
},
|
|
||||||
child: const XIcon(),
|
|
||||||
)
|
|
||||||
: TextFieldIconButton(
|
|
||||||
key: const Key(
|
|
||||||
"buyViewPasteAddressFieldButtonKey"),
|
|
||||||
onTap: () async {
|
|
||||||
print(
|
|
||||||
"TODO paste; Error: 'ClipboardData' isn't a type.");
|
|
||||||
// final ClipboardData? data = await clipboard
|
|
||||||
// .getData(Clipboard.kTextPlain);
|
|
||||||
// if (data?.text != null &&
|
|
||||||
// data!.text!.isNotEmpty) {
|
|
||||||
// String content = data.text!.trim();
|
|
||||||
// if (content.contains("\n")) {
|
|
||||||
// content = content.substring(
|
|
||||||
// 0, content.indexOf("\n"));
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// _receiveAddressController.text = content;
|
|
||||||
// _address = content;
|
|
||||||
//
|
|
||||||
// setState(() {
|
|
||||||
// _addressToggleFlag =
|
|
||||||
// _receiveAddressController
|
|
||||||
// .text.isNotEmpty;
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
},
|
|
||||||
child: _receiveAddressController.text.isEmpty
|
|
||||||
? const ClipboardIcon()
|
|
||||||
: const XIcon(),
|
|
||||||
),
|
|
||||||
if (_receiveAddressController.text.isEmpty)
|
|
||||||
TextFieldIconButton(
|
|
||||||
key: const Key("buyViewAddressBookButtonKey"),
|
|
||||||
onTap: () {
|
|
||||||
print(
|
|
||||||
'TODO tapped buyViewAddressBookButtonKey');
|
|
||||||
// Navigator.of(context).pushNamed(
|
|
||||||
// AddressBookView.routeName,
|
|
||||||
// arguments: widget.coin,
|
|
||||||
// );
|
|
||||||
},
|
|
||||||
child: const AddressBookIcon(),
|
|
||||||
),
|
|
||||||
if (_receiveAddressController.text.isEmpty &&
|
|
||||||
!isDesktop)
|
|
||||||
TextFieldIconButton(
|
|
||||||
key: const Key("buyViewScanQrButtonKey"),
|
|
||||||
onTap: () async {
|
|
||||||
try {
|
|
||||||
// ref
|
|
||||||
// .read(
|
|
||||||
// shouldShowLockscreenOnResumeStateProvider
|
|
||||||
// .state)
|
|
||||||
// .state = false;
|
|
||||||
if (FocusScope.of(context).hasFocus) {
|
|
||||||
FocusScope.of(context).unfocus();
|
|
||||||
await Future<void>.delayed(
|
|
||||||
const Duration(milliseconds: 75));
|
|
||||||
}
|
|
||||||
|
|
||||||
final qrResult = await scanner.scan();
|
|
||||||
|
|
||||||
Logging.instance.log(
|
|
||||||
"qrResult content: ${qrResult.rawContent}",
|
|
||||||
level: LogLevel.Info);
|
|
||||||
|
|
||||||
final results = AddressUtils.parseUri(
|
|
||||||
qrResult.rawContent);
|
|
||||||
|
|
||||||
Logging.instance.log(
|
|
||||||
"qrResult parsed: $results",
|
|
||||||
level: LogLevel.Info);
|
|
||||||
|
|
||||||
print('TODO implement QR scanning');
|
|
||||||
// if (results.isNotEmpty &&
|
|
||||||
// results["scheme"] == coin.uriScheme) {
|
|
||||||
// // auto fill address
|
|
||||||
// _address = results["address"] ?? "";
|
|
||||||
// sendToController.text = _address!;
|
|
||||||
//
|
|
||||||
// // autofill notes field
|
|
||||||
// if (results["message"] != null) {
|
|
||||||
// noteController.text = results["message"]!;
|
|
||||||
// } else if (results["label"] != null) {
|
|
||||||
// noteController.text = results["label"]!;
|
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// // autofill amount field
|
// _receiveAddressController.text = content;
|
||||||
// if (results["amount"] != null) {
|
// _address = content;
|
||||||
// final amount =
|
|
||||||
// Decimal.parse(results["amount"]!);
|
|
||||||
// cryptoAmountController.text =
|
|
||||||
// Format.localizedStringAsFixed(
|
|
||||||
// value: amount,
|
|
||||||
// locale: ref
|
|
||||||
// .read(
|
|
||||||
// localeServiceChangeNotifierProvider)
|
|
||||||
// .locale,
|
|
||||||
// decimalPlaces:
|
|
||||||
// Constants.decimalPlacesForCoin(
|
|
||||||
// coin),
|
|
||||||
// );
|
|
||||||
// amount.toString();
|
|
||||||
// _amountToSend = amount;
|
|
||||||
// }
|
|
||||||
//
|
//
|
||||||
// _updatePreviewButtonState(
|
|
||||||
// _address, _amountToSend);
|
|
||||||
// setState(() {
|
// setState(() {
|
||||||
// _addressToggleFlag =
|
// _addressToggleFlag =
|
||||||
// sendToController.text.isNotEmpty;
|
// _receiveAddressController
|
||||||
// });
|
// .text.isNotEmpty;
|
||||||
//
|
|
||||||
// // now check for non standard encoded basic address
|
|
||||||
// } else if (ref
|
|
||||||
// .read(walletsChangeNotifierProvider)
|
|
||||||
// .getManager(walletId)
|
|
||||||
// .validateAddress(qrResult.rawContent)) {
|
|
||||||
// _address = qrResult.rawContent;
|
|
||||||
// sendToController.text = _address ?? "";
|
|
||||||
//
|
|
||||||
// _updatePreviewButtonState(
|
|
||||||
// _address, _amountToSend);
|
|
||||||
// setState(() {
|
|
||||||
// _addressToggleFlag =
|
|
||||||
// sendToController.text.isNotEmpty;
|
|
||||||
// });
|
// });
|
||||||
// }
|
// }
|
||||||
} /*on PlatformException*/ catch (e, s) {
|
},
|
||||||
// ref
|
child: _receiveAddressController.text.isEmpty
|
||||||
// .read(
|
? const ClipboardIcon()
|
||||||
// shouldShowLockscreenOnResumeStateProvider
|
: const XIcon(),
|
||||||
// .state)
|
),
|
||||||
// .state = true;
|
if (_receiveAddressController.text.isEmpty)
|
||||||
// here we ignore the exception caused by not giving permission
|
TextFieldIconButton(
|
||||||
// to use the camera to scan a qr code
|
key: const Key("buyViewAddressBookButtonKey"),
|
||||||
Logging.instance.log(
|
onTap: () {
|
||||||
"Failed to get camera permissions while trying to scan qr code in SendView: $e\n$s",
|
print('TODO tapped buyViewAddressBookButtonKey');
|
||||||
level: LogLevel.Warning);
|
// Navigator.of(context).pushNamed(
|
||||||
|
// AddressBookView.routeName,
|
||||||
|
// arguments: widget.coin,
|
||||||
|
// );
|
||||||
|
},
|
||||||
|
child: const AddressBookIcon(),
|
||||||
|
),
|
||||||
|
if (_receiveAddressController.text.isEmpty &&
|
||||||
|
!isDesktop)
|
||||||
|
TextFieldIconButton(
|
||||||
|
key: const Key("buyViewScanQrButtonKey"),
|
||||||
|
onTap: () async {
|
||||||
|
try {
|
||||||
|
// ref
|
||||||
|
// .read(
|
||||||
|
// shouldShowLockscreenOnResumeStateProvider
|
||||||
|
// .state)
|
||||||
|
// .state = false;
|
||||||
|
if (FocusScope.of(context).hasFocus) {
|
||||||
|
FocusScope.of(context).unfocus();
|
||||||
|
await Future<void>.delayed(
|
||||||
|
const Duration(milliseconds: 75));
|
||||||
}
|
}
|
||||||
},
|
|
||||||
child: const QrCodeIcon(),
|
final qrResult = await scanner.scan();
|
||||||
)
|
|
||||||
],
|
Logging.instance.log(
|
||||||
),
|
"qrResult content: ${qrResult.rawContent}",
|
||||||
|
level: LogLevel.Info);
|
||||||
|
|
||||||
|
final results =
|
||||||
|
AddressUtils.parseUri(qrResult.rawContent);
|
||||||
|
|
||||||
|
Logging.instance.log(
|
||||||
|
"qrResult parsed: $results",
|
||||||
|
level: LogLevel.Info);
|
||||||
|
|
||||||
|
print('TODO implement QR scanning');
|
||||||
|
// if (results.isNotEmpty &&
|
||||||
|
// results["scheme"] == coin.uriScheme) {
|
||||||
|
// // auto fill address
|
||||||
|
// _address = results["address"] ?? "";
|
||||||
|
// sendToController.text = _address!;
|
||||||
|
//
|
||||||
|
// // autofill notes field
|
||||||
|
// if (results["message"] != null) {
|
||||||
|
// noteController.text = results["message"]!;
|
||||||
|
// } else if (results["label"] != null) {
|
||||||
|
// noteController.text = results["label"]!;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// // autofill amount field
|
||||||
|
// if (results["amount"] != null) {
|
||||||
|
// final amount =
|
||||||
|
// Decimal.parse(results["amount"]!);
|
||||||
|
// cryptoAmountController.text =
|
||||||
|
// Format.localizedStringAsFixed(
|
||||||
|
// value: amount,
|
||||||
|
// locale: ref
|
||||||
|
// .read(
|
||||||
|
// localeServiceChangeNotifierProvider)
|
||||||
|
// .locale,
|
||||||
|
// decimalPlaces:
|
||||||
|
// Constants.decimalPlacesForCoin(
|
||||||
|
// coin),
|
||||||
|
// );
|
||||||
|
// amount.toString();
|
||||||
|
// _amountToSend = amount;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// _updatePreviewButtonState(
|
||||||
|
// _address, _amountToSend);
|
||||||
|
// setState(() {
|
||||||
|
// _addressToggleFlag =
|
||||||
|
// sendToController.text.isNotEmpty;
|
||||||
|
// });
|
||||||
|
//
|
||||||
|
// // now check for non standard encoded basic address
|
||||||
|
// } else if (ref
|
||||||
|
// .read(walletsChangeNotifierProvider)
|
||||||
|
// .getManager(walletId)
|
||||||
|
// .validateAddress(qrResult.rawContent)) {
|
||||||
|
// _address = qrResult.rawContent;
|
||||||
|
// sendToController.text = _address ?? "";
|
||||||
|
//
|
||||||
|
// _updatePreviewButtonState(
|
||||||
|
// _address, _amountToSend);
|
||||||
|
// setState(() {
|
||||||
|
// _addressToggleFlag =
|
||||||
|
// sendToController.text.isNotEmpty;
|
||||||
|
// });
|
||||||
|
// }
|
||||||
|
} /*on PlatformException*/ catch (e, s) {
|
||||||
|
// ref
|
||||||
|
// .read(
|
||||||
|
// shouldShowLockscreenOnResumeStateProvider
|
||||||
|
// .state)
|
||||||
|
// .state = true;
|
||||||
|
// here we ignore the exception caused by not giving permission
|
||||||
|
// to use the camera to scan a qr code
|
||||||
|
Logging.instance.log(
|
||||||
|
"Failed to get camera permissions while trying to scan qr code in SendView: $e\n$s",
|
||||||
|
level: LogLevel.Warning);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
child: const QrCodeIcon(),
|
||||||
|
)
|
||||||
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
SizedBox(
|
),
|
||||||
height: isDesktop ? 20 : 12,
|
SizedBox(
|
||||||
),
|
height: isDesktop ? 20 : 12,
|
||||||
PrimaryButton(
|
),
|
||||||
buttonHeight: isDesktop ? ButtonHeight.l : null,
|
PrimaryButton(
|
||||||
enabled: ref.watch(exchangeFormStateProvider
|
buttonHeight: isDesktop ? ButtonHeight.l : null,
|
||||||
.select((value) => value.canExchange)),
|
enabled: ref.watch(
|
||||||
onPressed: () {
|
exchangeFormStateProvider.select((value) => value.canExchange)),
|
||||||
// TODO implement buy confirmation dialog
|
onPressed: () {
|
||||||
},
|
// TODO implement buy confirmation dialog
|
||||||
label: "Exchange",
|
},
|
||||||
)
|
label: "Exchange",
|
||||||
],
|
)
|
||||||
));
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,17 +11,17 @@ class BuyView extends StatefulWidget {
|
||||||
class _BuyViewState extends State<BuyView> {
|
class _BuyViewState extends State<BuyView> {
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
//todo: check if print needed
|
debugPrint("BUILD: $runtimeType");
|
||||||
// debugPrint("BUILD: BuyView");
|
|
||||||
|
|
||||||
return SafeArea(
|
return const SafeArea(
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: EdgeInsets.only(
|
padding: EdgeInsets.only(
|
||||||
left: 16,
|
left: 16,
|
||||||
right: 16,
|
right: 16,
|
||||||
top: 16,
|
top: 16,
|
||||||
|
),
|
||||||
|
child: BuyForm(),
|
||||||
),
|
),
|
||||||
child: BuyForm(),
|
);
|
||||||
));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue