mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2024-11-17 09:47:37 +00:00
hide fiat currency picker when in incognito and calls are broken
This commit is contained in:
parent
8f2567f340
commit
5f804b3e69
2 changed files with 108 additions and 106 deletions
|
@ -27,6 +27,7 @@ import 'package:stackwallet/utilities/enums/coin_enum.dart';
|
|||
import 'package:stackwallet/utilities/enums/fee_rate_type_enum.dart';
|
||||
import 'package:stackwallet/utilities/format.dart';
|
||||
import 'package:stackwallet/utilities/logger.dart';
|
||||
import 'package:stackwallet/utilities/prefs.dart';
|
||||
import 'package:stackwallet/utilities/text_styles.dart';
|
||||
import 'package:stackwallet/utilities/theme/stack_colors.dart';
|
||||
import 'package:stackwallet/widgets/animated_text.dart';
|
||||
|
@ -1107,115 +1108,120 @@ class _SendViewState extends ConsumerState<SendView> {
|
|||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
TextField(
|
||||
style: STextStyles.smallMed14(context).copyWith(
|
||||
color: Theme.of(context)
|
||||
.extension<StackColors>()!
|
||||
.textDark,
|
||||
if (Prefs.instance.externalCalls)
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
key: const Key("amountInputFieldFiatTextFieldKey"),
|
||||
controller: baseAmountController,
|
||||
focusNode: _baseFocus,
|
||||
keyboardType: const TextInputType.numberWithOptions(
|
||||
signed: false,
|
||||
decimal: true,
|
||||
),
|
||||
textAlign: TextAlign.right,
|
||||
inputFormatters: [
|
||||
// regex to validate a fiat amount with 2 decimal places
|
||||
TextInputFormatter.withFunction((oldValue,
|
||||
newValue) =>
|
||||
RegExp(r'^([0-9]*[,.]?[0-9]{0,2}|[,.][0-9]{0,2})$')
|
||||
.hasMatch(newValue.text)
|
||||
? newValue
|
||||
: oldValue),
|
||||
],
|
||||
onChanged: (baseAmountString) {
|
||||
if (baseAmountString.isNotEmpty &&
|
||||
baseAmountString != "." &&
|
||||
baseAmountString != ",") {
|
||||
final baseAmount = baseAmountString.contains(",")
|
||||
? Decimal.parse(
|
||||
baseAmountString.replaceFirst(",", "."))
|
||||
: Decimal.parse(baseAmountString);
|
||||
if (Prefs.instance.externalCalls)
|
||||
TextField(
|
||||
style: STextStyles.smallMed14(context).copyWith(
|
||||
color: Theme.of(context)
|
||||
.extension<StackColors>()!
|
||||
.textDark,
|
||||
),
|
||||
key: const Key("amountInputFieldFiatTextFieldKey"),
|
||||
controller: baseAmountController,
|
||||
focusNode: _baseFocus,
|
||||
keyboardType: const TextInputType.numberWithOptions(
|
||||
signed: false,
|
||||
decimal: true,
|
||||
),
|
||||
textAlign: TextAlign.right,
|
||||
inputFormatters: [
|
||||
// regex to validate a fiat amount with 2 decimal places
|
||||
TextInputFormatter.withFunction((oldValue,
|
||||
newValue) =>
|
||||
RegExp(r'^([0-9]*[,.]?[0-9]{0,2}|[,.][0-9]{0,2})$')
|
||||
.hasMatch(newValue.text)
|
||||
? newValue
|
||||
: oldValue),
|
||||
],
|
||||
onChanged: (baseAmountString) {
|
||||
if (baseAmountString.isNotEmpty &&
|
||||
baseAmountString != "." &&
|
||||
baseAmountString != ",") {
|
||||
final baseAmount = baseAmountString
|
||||
.contains(",")
|
||||
? Decimal.parse(
|
||||
baseAmountString.replaceFirst(",", "."))
|
||||
: Decimal.parse(baseAmountString);
|
||||
|
||||
var _price = ref
|
||||
.read(priceAnd24hChangeNotifierProvider)
|
||||
.getPrice(coin)
|
||||
.item1;
|
||||
var _price = ref
|
||||
.read(priceAnd24hChangeNotifierProvider)
|
||||
.getPrice(coin)
|
||||
.item1;
|
||||
|
||||
if (_price == Decimal.zero) {
|
||||
_amountToSend = Decimal.zero;
|
||||
if (_price == Decimal.zero) {
|
||||
_amountToSend = Decimal.zero;
|
||||
} else {
|
||||
_amountToSend = baseAmount <= Decimal.zero
|
||||
? Decimal.zero
|
||||
: (baseAmount / _price).toDecimal(
|
||||
scaleOnInfinitePrecision:
|
||||
Constants.decimalPlaces);
|
||||
}
|
||||
if (_cachedAmountToSend != null &&
|
||||
_cachedAmountToSend == _amountToSend) {
|
||||
return;
|
||||
}
|
||||
_cachedAmountToSend = _amountToSend;
|
||||
Logging.instance.log(
|
||||
"it changed $_amountToSend $_cachedAmountToSend",
|
||||
level: LogLevel.Info);
|
||||
|
||||
final amountString =
|
||||
Format.localizedStringAsFixed(
|
||||
value: _amountToSend!,
|
||||
locale: ref
|
||||
.read(localeServiceChangeNotifierProvider)
|
||||
.locale,
|
||||
decimalPlaces: Constants.decimalPlaces,
|
||||
);
|
||||
|
||||
_cryptoAmountChangeLock = true;
|
||||
cryptoAmountController.text = amountString;
|
||||
_cryptoAmountChangeLock = false;
|
||||
} else {
|
||||
_amountToSend = baseAmount <= Decimal.zero
|
||||
? Decimal.zero
|
||||
: (baseAmount / _price).toDecimal(
|
||||
scaleOnInfinitePrecision:
|
||||
Constants.decimalPlaces);
|
||||
_amountToSend = Decimal.zero;
|
||||
_cryptoAmountChangeLock = true;
|
||||
cryptoAmountController.text = "";
|
||||
_cryptoAmountChangeLock = false;
|
||||
}
|
||||
if (_cachedAmountToSend != null &&
|
||||
_cachedAmountToSend == _amountToSend) {
|
||||
return;
|
||||
}
|
||||
_cachedAmountToSend = _amountToSend;
|
||||
Logging.instance.log(
|
||||
"it changed $_amountToSend $_cachedAmountToSend",
|
||||
level: LogLevel.Info);
|
||||
|
||||
final amountString =
|
||||
Format.localizedStringAsFixed(
|
||||
value: _amountToSend!,
|
||||
locale: ref
|
||||
.read(localeServiceChangeNotifierProvider)
|
||||
.locale,
|
||||
decimalPlaces: Constants.decimalPlaces,
|
||||
);
|
||||
|
||||
_cryptoAmountChangeLock = true;
|
||||
cryptoAmountController.text = amountString;
|
||||
_cryptoAmountChangeLock = false;
|
||||
} else {
|
||||
_amountToSend = Decimal.zero;
|
||||
_cryptoAmountChangeLock = true;
|
||||
cryptoAmountController.text = "";
|
||||
_cryptoAmountChangeLock = false;
|
||||
}
|
||||
// setState(() {
|
||||
// _calculateFeesFuture = calculateFees(
|
||||
// Format.decimalAmountToSatoshis(
|
||||
// _amountToSend!));
|
||||
// });
|
||||
_updatePreviewButtonState(_address, _amountToSend);
|
||||
},
|
||||
decoration: InputDecoration(
|
||||
contentPadding: const EdgeInsets.only(
|
||||
top: 12,
|
||||
right: 12,
|
||||
),
|
||||
hintText: "0",
|
||||
hintStyle: STextStyles.fieldLabel(context).copyWith(
|
||||
fontSize: 14,
|
||||
),
|
||||
prefixIcon: FittedBox(
|
||||
fit: BoxFit.scaleDown,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(12),
|
||||
child: Text(
|
||||
ref.watch(prefsChangeNotifierProvider
|
||||
.select((value) => value.currency)),
|
||||
style: STextStyles.smallMed14(context)
|
||||
.copyWith(
|
||||
color: Theme.of(context)
|
||||
.extension<StackColors>()!
|
||||
.accentColorDark),
|
||||
// setState(() {
|
||||
// _calculateFeesFuture = calculateFees(
|
||||
// Format.decimalAmountToSatoshis(
|
||||
// _amountToSend!));
|
||||
// });
|
||||
_updatePreviewButtonState(
|
||||
_address, _amountToSend);
|
||||
},
|
||||
decoration: InputDecoration(
|
||||
contentPadding: const EdgeInsets.only(
|
||||
top: 12,
|
||||
right: 12,
|
||||
),
|
||||
hintText: "0",
|
||||
hintStyle:
|
||||
STextStyles.fieldLabel(context).copyWith(
|
||||
fontSize: 14,
|
||||
),
|
||||
prefixIcon: FittedBox(
|
||||
fit: BoxFit.scaleDown,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(12),
|
||||
child: Text(
|
||||
ref.watch(prefsChangeNotifierProvider
|
||||
.select((value) => value.currency)),
|
||||
style: STextStyles.smallMed14(context)
|
||||
.copyWith(
|
||||
color: Theme.of(context)
|
||||
.extension<StackColors>()!
|
||||
.accentColorDark),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 12,
|
||||
),
|
||||
|
|
|
@ -408,12 +408,11 @@ class ContinueButton extends StatelessWidget {
|
|||
.extension<StackColors>()!
|
||||
.getPrimaryEnabledButtonColor(context),
|
||||
onPressed: () {
|
||||
print("Output of isEasy:");
|
||||
print(isEasy);
|
||||
|
||||
Prefs.instance.externalCalls = isEasy;
|
||||
if (!isSettings) {
|
||||
Navigator.of(context).pushNamed(CreatePinView.routeName);
|
||||
} else {
|
||||
Navigator.pop(context);
|
||||
}
|
||||
},
|
||||
child: Text(
|
||||
|
@ -429,9 +428,6 @@ class ContinueButton extends StatelessWidget {
|
|||
.extension<StackColors>()!
|
||||
.getPrimaryEnabledButtonColor(context),
|
||||
onPressed: () {
|
||||
print("Output of isEasy:");
|
||||
print(isEasy);
|
||||
|
||||
Prefs.instance.externalCalls = isEasy;
|
||||
|
||||
if (!isSettings) {
|
||||
|
|
Loading…
Reference in a new issue