Auto hide balance

This commit is contained in:
Hanh 2023-03-10 18:25:36 +10:00
parent 4d31b1a260
commit cdd5ab7e3e
11 changed files with 65 additions and 20 deletions

View File

@ -166,9 +166,7 @@ class QRAddressState extends State<QRAddressWidget> {
final shortAddress = centerTrim(address);
final showTAddr = active.showTAddr;
final hasTAddr = active.taddress.isNotEmpty;
final flat = settings.flat;
final qrSize = getScreenSize(context) / 2.5;
final hide = settings.autoHide && flat;
final coinDef = active.coinDef;
return Column(children: [
@ -181,7 +179,7 @@ class QRAddressState extends State<QRAddressWidget> {
onTap: hasTAddr ? _onQRTap : null,
onLongPress: _onUpdateTAddr,
child: RotatedBox(
quarterTurns: hide ? 2 : 0,
quarterTurns: 0,
child: QrImage(
data: address,
size: qrSize,
@ -313,7 +311,17 @@ class BalanceWidget extends StatelessWidget {
final s = S.of(context);
final theme = Theme.of(context);
final flat = settings.flat;
final hide = settings.autoHide && flat;
final hide = () {
switch (settings.autoHide) {
case 0:
return false;
case 1:
return flat;
case 2:
return true;
}
return true;
}();
final showTAddr = active.showTAddr;
final balance = showTAddr ? active.tbalance : active.balances.balance;
final balanceColor = !showTAddr
@ -342,7 +350,7 @@ class BalanceWidget extends StatelessWidget {
Text(' $balanceHi', style: balanceStyle),
if (!hide) Text('${_getBalanceLo(balance)}'),
]),
if (hide) Text(s.tiltYourDeviceUpToRevealYourBalance),
if (hide && settings.autoHide == 1) Text(s.tiltYourDeviceUpToRevealYourBalance),
if (!hide && fx != 0.0)
Text("${decimalFormat(balanceFX, 2, symbol: settings.currency)}",
style: theme.textTheme.titleLarge),

View File

@ -110,6 +110,7 @@ class MessageLookup extends MessageLookupByLibrary {
"advanced": MessageLookupByLibrary.simpleMessage("Advanced"),
"advancedOptions":
MessageLookupByLibrary.simpleMessage("Advanced Options"),
"always": MessageLookupByLibrary.simpleMessage("Always"),
"amount": MessageLookupByLibrary.simpleMessage("Amount"),
"amountInSettingscurrency": m0,
"amountMustBeANumber":
@ -301,6 +302,7 @@ class MessageLookup extends MessageLookupByLibrary {
"na": MessageLookupByLibrary.simpleMessage("N/A"),
"name": MessageLookupByLibrary.simpleMessage("Name"),
"nameIsEmpty": MessageLookupByLibrary.simpleMessage("Name is empty"),
"never": MessageLookupByLibrary.simpleMessage("Never"),
"newAccount": MessageLookupByLibrary.simpleMessage("New Account"),
"newLabel": MessageLookupByLibrary.simpleMessage("New"),
"newPassword": MessageLookupByLibrary.simpleMessage("New Password"),

View File

@ -111,6 +111,7 @@ class MessageLookup extends MessageLookupByLibrary {
"advanced": MessageLookupByLibrary.simpleMessage("Avanzado"),
"advancedOptions":
MessageLookupByLibrary.simpleMessage("Opciones Avanzadas"),
"always": MessageLookupByLibrary.simpleMessage("Always"),
"amount": MessageLookupByLibrary.simpleMessage("Monto"),
"amountInSettingscurrency": m0,
"amountMustBeANumber": MessageLookupByLibrary.simpleMessage(
@ -306,6 +307,7 @@ class MessageLookup extends MessageLookupByLibrary {
"na": MessageLookupByLibrary.simpleMessage("N/A"),
"name": MessageLookupByLibrary.simpleMessage("Nombre"),
"nameIsEmpty": MessageLookupByLibrary.simpleMessage("Nombre vacío"),
"never": MessageLookupByLibrary.simpleMessage("Never"),
"newAccount": MessageLookupByLibrary.simpleMessage("Nueva cuenta"),
"newLabel": MessageLookupByLibrary.simpleMessage("Nueva"),
"newPassword": MessageLookupByLibrary.simpleMessage("New Password"),

View File

@ -111,6 +111,7 @@ class MessageLookup extends MessageLookupByLibrary {
"advanced": MessageLookupByLibrary.simpleMessage("Avancé"),
"advancedOptions":
MessageLookupByLibrary.simpleMessage("Options avancées"),
"always": MessageLookupByLibrary.simpleMessage("Toujours"),
"amount": MessageLookupByLibrary.simpleMessage("Montant"),
"amountInSettingscurrency": m0,
"amountMustBeANumber": MessageLookupByLibrary.simpleMessage(
@ -307,6 +308,7 @@ class MessageLookup extends MessageLookupByLibrary {
"na": MessageLookupByLibrary.simpleMessage("N/D"),
"name": MessageLookupByLibrary.simpleMessage("Nom"),
"nameIsEmpty": MessageLookupByLibrary.simpleMessage("Le nom est vide"),
"never": MessageLookupByLibrary.simpleMessage("Jamais"),
"newAccount": MessageLookupByLibrary.simpleMessage("Nouveau Compte"),
"newLabel": MessageLookupByLibrary.simpleMessage("Nouveau"),
"newPassword":

View File

@ -3101,6 +3101,26 @@ class S {
args: [],
);
}
/// `Never`
String get never {
return Intl.message(
'Never',
name: 'never',
desc: '',
args: [],
);
}
/// `Always`
String get always {
return Intl.message(
'Always',
name: 'always',
desc: '',
args: [],
);
}
}
class AppLocalizationDelegate extends LocalizationsDelegate<S> {

View File

@ -303,5 +303,7 @@
"newPasswordsDoNotMatch": "New passwords do not match",
"databaseEncrypted": "Database Encrypted",
"invalidPassword": "Invalid Password",
"databaseRestored": "Database Restored"
"databaseRestored": "Database Restored",
"never": "Never",
"always": "Always"
}

View File

@ -301,5 +301,7 @@
"newPasswordsDoNotMatch": "New passwords do not match",
"databaseEncrypted": "Database Encrypted. Please Restart the App.",
"invalidPassword": "Invalid Password",
"databaseRestored": "Database Restored"
"databaseRestored": "Database Restored",
"never": "Never",
"always": "Always"
}

View File

@ -302,5 +302,7 @@
"newPasswordsDoNotMatch": "Les nouveaux Mots de Passe ne correspondent pas",
"databaseEncrypted": "BD encryptée",
"invalidPassword": "Mot de Passe incorrect",
"databaseRestored": "BD Récupèrée"
"databaseRestored": "BD Récupèrée",
"never": "Jamais",
"always": "Toujours"
}

View File

@ -206,11 +206,17 @@ class SettingsState extends State<SettingsPage>
title: Text(s.retrieveTransactionDetails),
initialValue: settings.getTx,
onSaved: _onGetTx),
FormBuilderCheckbox(
name: 'auto_hide',
title: Text(s.autoHideBalance),
initialValue: settings.autoHide,
onSaved: _onAutoHide),
FormBuilderRadioGroup<int>(
orientation: OptionsOrientation.horizontal,
name: 'auto_hide',
decoration: InputDecoration(labelText: s.autoHideBalance),
initialValue: settings.autoHide,
onSaved: _onAutoHide,
options: [
FormBuilderFieldOption(child: Text(s.never), value: 0),
FormBuilderFieldOption(child: Text(s.auto), value: 1),
FormBuilderFieldOption(child: Text(s.always), value: 2),
]),
DropdownButtonFormField<int>(
decoration:
InputDecoration(labelText: s.minPrivacy),
@ -347,8 +353,6 @@ class SettingsState extends State<SettingsPage>
return r;
}
_onAutoHide(v) {
settings.setAutoHide(v);
}

View File

@ -155,7 +155,7 @@ abstract class _Settings with Store {
bool useUA = false;
@observable
bool autoHide = true;
int autoHide = 1;
@observable
bool includeReplyTo = false;
@ -241,7 +241,8 @@ abstract class _Settings with Store {
chartRange = prefs.getString('chart_range') ?? "1Y";
autoShieldThreshold = prefs.getDouble('autoshield_threshold') ?? 0.0;
useUA = prefs.getBool('use_ua') ?? false;
autoHide = prefs.getBool('auto_hide') ?? true;
final autoHideOld = prefs.getBool('auto_hide') ?? true;
autoHide = prefs.getInt('auto_hide2') ?? (autoHideOld ? 1 : 0);
protectSend = prefs.getBool('protect_send') ?? false;
protectOpen = prefs.getBool('protect_open') ?? false;
includeReplyTo = prefs.getBool('include_reply_to') ?? false;
@ -508,10 +509,10 @@ abstract class _Settings with Store {
}
@action
Future<void> setAutoHide(bool v) async {
Future<void> setAutoHide(int v) async {
final prefs = await SharedPreferences.getInstance();
autoHide = v;
prefs.setBool('auto_hide', autoHide);
prefs.setInt('auto_hide2', autoHide);
}
@action

View File

@ -15,7 +15,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 1.3.6+399
version: 1.3.6+400
environment:
sdk: ">=2.12.0 <3.0.0"