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