From 304b234398d0cbe26211e842e2007e25ec8429d4 Mon Sep 17 00:00:00 2001 From: Hanh Date: Thu, 24 Feb 2022 11:36:02 +0800 Subject: [PATCH] Default memo --- lib/generated/intl/messages_en.dart | 20 ++++++++++++-------- lib/generated/intl/messages_es.dart | 22 +++++++++++++--------- lib/generated/intl/messages_fr.dart | 20 ++++++++++++-------- lib/generated/l10n.dart | 20 ++++++++++++++++++++ lib/l10n/intl_en.arb | 4 +++- lib/l10n/intl_es.arb | 6 ++++-- lib/l10n/intl_fr.arb | 4 +++- lib/send.dart | 2 ++ lib/settings.dart | 21 ++++++++++++++++----- lib/store.dart | 12 ++++++++++++ pubspec.yaml | 2 +- pubspec.yaml.tpl | 2 +- 12 files changed, 99 insertions(+), 36 deletions(-) diff --git a/lib/generated/intl/messages_en.dart b/lib/generated/intl/messages_en.dart index 9587d7f..7c79050 100644 --- a/lib/generated/intl/messages_en.dart +++ b/lib/generated/intl/messages_en.dart @@ -39,15 +39,17 @@ class MessageLookup extends MessageLookupByLibrary { static String m7(ticker) => "Send ${ticker} to..."; - static String m8(amount, ticker, count) => + static String m8(app) => "Sent from ${app}"; + + static String m9(amount, ticker, count) => "Sending a total of ${amount} ${ticker} to ${count} recipients"; - static String m9(aZEC, ticker, address) => + static String m10(aZEC, ticker, address) => "Sending ${aZEC} ${ticker} to ${address}"; - static String m10(text) => "${text} copied to clipboard"; + static String m11(text) => "${text} copied to clipboard"; - static String m11(currency) => "Use ${currency}"; + static String m12(currency) => "Use ${currency}"; final messages = _notInlinedMessages(_notInlinedMessages); static Map _notInlinedMessages(_) => { @@ -135,6 +137,7 @@ class MessageLookup extends MessageLookupByLibrary { "dark": MessageLookupByLibrary.simpleMessage("Dark"), "date": MessageLookupByLibrary.simpleMessage("Date"), "datetime": MessageLookupByLibrary.simpleMessage("Date/Time"), + "defaultMemo": MessageLookupByLibrary.simpleMessage("Default Memo"), "delete": MessageLookupByLibrary.simpleMessage("DELETE"), "deleteAccount": MessageLookupByLibrary.simpleMessage("Delete Account"), "deleteContact": MessageLookupByLibrary.simpleMessage("Delete contact"), @@ -255,8 +258,9 @@ class MessageLookup extends MessageLookupByLibrary { "send": MessageLookupByLibrary.simpleMessage("Send"), "sendCointicker": m6, "sendCointickerTo": m7, - "sendingATotalOfAmountCointickerToCountRecipients": m8, - "sendingAzecCointickerToAddress": m9, + "sendFrom": m8, + "sendingATotalOfAmountCointickerToCountRecipients": m9, + "sendingAzecCointickerToAddress": m10, "server": MessageLookupByLibrary.simpleMessage("Server"), "settings": MessageLookupByLibrary.simpleMessage("Settings"), "shieldTranspBalance": @@ -287,7 +291,7 @@ class MessageLookup extends MessageLookupByLibrary { "Tap QR Code for Transparent Address"), "tapTransactionForDetails": MessageLookupByLibrary.simpleMessage("Tap Transaction for Details"), - "textCopiedToClipboard": m10, + "textCopiedToClipboard": m11, "theme": MessageLookupByLibrary.simpleMessage("Theme"), "themeEditor": MessageLookupByLibrary.simpleMessage("Theme Editor"), "thisAccountAlreadyExists": MessageLookupByLibrary.simpleMessage( @@ -316,7 +320,7 @@ class MessageLookup extends MessageLookupByLibrary { MessageLookupByLibrary.simpleMessage("Unshielded Balance"), "unsignedTransactionFile": MessageLookupByLibrary.simpleMessage("Unsigned Transaction File"), - "useSettingscurrency": m11, + "useSettingscurrency": m12, "useTransparentBalance": MessageLookupByLibrary.simpleMessage("Use Transparent Balance"), "useUa": MessageLookupByLibrary.simpleMessage("Use UA"), diff --git a/lib/generated/intl/messages_es.dart b/lib/generated/intl/messages_es.dart index 50949a3..0413b7d 100644 --- a/lib/generated/intl/messages_es.dart +++ b/lib/generated/intl/messages_es.dart @@ -37,15 +37,17 @@ class MessageLookup extends MessageLookupByLibrary { static String m7(ticker) => "Enviar ${ticker} a…"; - static String m8(amount, ticker, count) => + static String m8(app) => "Enviado desde ${app}"; + + static String m9(amount, ticker, count) => "Enviando un total de ${amount} ${ticker} a ${count} direcciones"; - static String m9(aZEC, ticker, address) => + static String m10(aZEC, ticker, address) => "Enviado ${aZEC} ${ticker} a ${address}"; - static String m10(text) => "${text} copied to clipboard"; + static String m11(text) => "${text} copied to clipboard"; - static String m11(currency) => "Utilizar ${currency}"; + static String m12(currency) => "Utilizar ${currency}"; final messages = _notInlinedMessages(_notInlinedMessages); static Map _notInlinedMessages(_) => { @@ -75,7 +77,7 @@ class MessageLookup extends MessageLookupByLibrary { "Dirección copiada al portapapeles"), "addressIsEmpty": MessageLookupByLibrary.simpleMessage("Dirección está vacía"), - "advanced": MessageLookupByLibrary.simpleMessage("avanzado"), + "advanced": MessageLookupByLibrary.simpleMessage("Avanzado"), "advancedOptions": MessageLookupByLibrary.simpleMessage("Opciones Avanzadas"), "amount": MessageLookupByLibrary.simpleMessage("Monto"), @@ -135,6 +137,7 @@ class MessageLookup extends MessageLookupByLibrary { "dark": MessageLookupByLibrary.simpleMessage("Noche"), "date": MessageLookupByLibrary.simpleMessage("Fecha"), "datetime": MessageLookupByLibrary.simpleMessage("Fecha/Hora"), + "defaultMemo": MessageLookupByLibrary.simpleMessage("Nota"), "delete": MessageLookupByLibrary.simpleMessage("ELIMINAR"), "deleteAccount": MessageLookupByLibrary.simpleMessage("Borrar Cuenta"), "deleteContact": @@ -254,8 +257,9 @@ class MessageLookup extends MessageLookupByLibrary { "send": MessageLookupByLibrary.simpleMessage("Enviar"), "sendCointicker": m6, "sendCointickerTo": m7, - "sendingATotalOfAmountCointickerToCountRecipients": m8, - "sendingAzecCointickerToAddress": m9, + "sendFrom": m8, + "sendingATotalOfAmountCointickerToCountRecipients": m9, + "sendingAzecCointickerToAddress": m10, "server": MessageLookupByLibrary.simpleMessage("Servidor"), "settings": MessageLookupByLibrary.simpleMessage("Ajustes"), "shieldTranspBalance": @@ -283,7 +287,7 @@ class MessageLookup extends MessageLookupByLibrary { "Pinchar QR para Dirección Transparente"), "tapTransactionForDetails": MessageLookupByLibrary.simpleMessage( "Toque Transacción para detalles"), - "textCopiedToClipboard": m10, + "textCopiedToClipboard": m11, "theme": MessageLookupByLibrary.simpleMessage("Tema"), "themeEditor": MessageLookupByLibrary.simpleMessage("Editora de temas"), "thisAccountAlreadyExists": @@ -312,7 +316,7 @@ class MessageLookup extends MessageLookupByLibrary { MessageLookupByLibrary.simpleMessage("Saldo sin blindaje"), "unsignedTransactionFile": MessageLookupByLibrary.simpleMessage( "Archivo de transaccion sin firmar"), - "useSettingscurrency": m11, + "useSettingscurrency": m12, "useTransparentBalance": MessageLookupByLibrary.simpleMessage("Usar Saldo Transp"), "useUa": MessageLookupByLibrary.simpleMessage("Usar UA"), diff --git a/lib/generated/intl/messages_fr.dart b/lib/generated/intl/messages_fr.dart index 6c985be..7e4624e 100644 --- a/lib/generated/intl/messages_fr.dart +++ b/lib/generated/intl/messages_fr.dart @@ -37,15 +37,17 @@ class MessageLookup extends MessageLookupByLibrary { static String m7(ticker) => "Envoyer ${ticker} à..."; - static String m8(amount, ticker, count) => + static String m8(app) => "Envoyé via ${app}"; + + static String m9(amount, ticker, count) => "Envoi d\'un total de ${amount} ${ticker} à ${count} destinataires"; - static String m9(aZEC, ticker, address) => + static String m10(aZEC, ticker, address) => "Envoi de ${aZEC} ${ticker} à ${address}"; - static String m10(text) => "${text} copied to clipboard"; + static String m11(text) => "${text} copied to clipboard"; - static String m11(currency) => "Utiliser ${currency}"; + static String m12(currency) => "Utiliser ${currency}"; final messages = _notInlinedMessages(_notInlinedMessages); static Map _notInlinedMessages(_) => { @@ -136,6 +138,7 @@ class MessageLookup extends MessageLookupByLibrary { "dark": MessageLookupByLibrary.simpleMessage("Sombre"), "date": MessageLookupByLibrary.simpleMessage("Date"), "datetime": MessageLookupByLibrary.simpleMessage("Jour/Heure"), + "defaultMemo": MessageLookupByLibrary.simpleMessage("Memo"), "delete": MessageLookupByLibrary.simpleMessage("SUPPRIMER"), "deleteAccount": MessageLookupByLibrary.simpleMessage("Effacer un compte"), @@ -255,8 +258,9 @@ class MessageLookup extends MessageLookupByLibrary { "send": MessageLookupByLibrary.simpleMessage("Envoyer"), "sendCointicker": m6, "sendCointickerTo": m7, - "sendingATotalOfAmountCointickerToCountRecipients": m8, - "sendingAzecCointickerToAddress": m9, + "sendFrom": m8, + "sendingATotalOfAmountCointickerToCountRecipients": m9, + "sendingAzecCointickerToAddress": m10, "server": MessageLookupByLibrary.simpleMessage("Serveur"), "settings": MessageLookupByLibrary.simpleMessage("Paramètres"), "shieldTranspBalance": MessageLookupByLibrary.simpleMessage( @@ -285,7 +289,7 @@ class MessageLookup extends MessageLookupByLibrary { "Appuyez sur le code QR pour l\'adresse transparente"), "tapTransactionForDetails": MessageLookupByLibrary.simpleMessage( "Presser sur une Transaction pour plus de details"), - "textCopiedToClipboard": m10, + "textCopiedToClipboard": m11, "theme": MessageLookupByLibrary.simpleMessage("Thème"), "themeEditor": MessageLookupByLibrary.simpleMessage("Editeur de Thème"), "thisAccountAlreadyExists": @@ -314,7 +318,7 @@ class MessageLookup extends MessageLookupByLibrary { MessageLookupByLibrary.simpleMessage("Solde Transparent"), "unsignedTransactionFile": MessageLookupByLibrary.simpleMessage( "Fichier de transaction non signée"), - "useSettingscurrency": m11, + "useSettingscurrency": m12, "useTransparentBalance": MessageLookupByLibrary.simpleMessage( "Utiliser le Solde Transparent"), "useUa": MessageLookupByLibrary.simpleMessage("Utiliser UA"), diff --git a/lib/generated/l10n.dart b/lib/generated/l10n.dart index c6902c8..3b5c871 100644 --- a/lib/generated/l10n.dart +++ b/lib/generated/l10n.dart @@ -1901,6 +1901,26 @@ class S { args: [], ); } + + /// `Sent from {app}` + String sendFrom(Object app) { + return Intl.message( + 'Sent from $app', + name: 'sendFrom', + desc: '', + args: [app], + ); + } + + /// `Default Memo` + String get defaultMemo { + return Intl.message( + 'Default Memo', + name: 'defaultMemo', + desc: '', + args: [], + ); + } } class AppLocalizationDelegate extends LocalizationsDelegate { diff --git a/lib/l10n/intl_en.arb b/lib/l10n/intl_en.arb index bb7b283..ab6f316 100644 --- a/lib/l10n/intl_en.arb +++ b/lib/l10n/intl_en.arb @@ -183,5 +183,7 @@ "mode": "Mode", "simple": "Simple", "advanced": "Advanced", - "changingTheModeWillTakeEffectAtNextRestart": "Changing the mode will take effect at next restart" + "changingTheModeWillTakeEffectAtNextRestart": "Changing the mode will take effect at next restart", + "sendFrom": "Sent from {app}", + "defaultMemo": "Default Memo" } diff --git a/lib/l10n/intl_es.arb b/lib/l10n/intl_es.arb index 52e2172..948bf49 100644 --- a/lib/l10n/intl_es.arb +++ b/lib/l10n/intl_es.arb @@ -180,6 +180,8 @@ "restart": "Reiniciar", "mode": "Modo", "simple": "Sencillo", - "advanced": "avanzado", - "changingTheModeWillTakeEffectAtNextRestart": "Cambiar el modo tendrá efecto en el próximo reinicio" + "advanced": "Avanzado", + "changingTheModeWillTakeEffectAtNextRestart": "Cambiar el modo tendrá efecto en el próximo reinicio", + "sendFrom": "Enviado desde {app}", + "defaultMemo": "Nota" } diff --git a/lib/l10n/intl_fr.arb b/lib/l10n/intl_fr.arb index 7c0d90e..c84f97c 100644 --- a/lib/l10n/intl_fr.arb +++ b/lib/l10n/intl_fr.arb @@ -181,5 +181,7 @@ "mode": "Mode", "simple": "Simple", "advanced": "Avancé", - "changingTheModeWillTakeEffectAtNextRestart": "Changer le mode prendra effet au prochain démarrage" + "changingTheModeWillTakeEffectAtNextRestart": "Changer le mode prendra effet au prochain démarrage", + "sendFrom": "Envoyé via {app}", + "defaultMemo": "Memo" } diff --git a/lib/send.dart b/lib/send.dart index 2e8d31d..1f1b560 100644 --- a/lib/send.dart +++ b/lib/send.dart @@ -98,6 +98,8 @@ class SendState extends State { Widget build(BuildContext context) { final s = S.of(context); final simpleMode = settings.simpleMode; + _memoController.text = settings.memoSignature ?? s.sendFrom(coin.app); + return Scaffold( appBar: AppBar(title: Text(s.sendCointicker(coin.ticker))), body: GestureDetector( diff --git a/lib/settings.dart b/lib/settings.dart index e0fd4d4..9eef931 100644 --- a/lib/settings.dart +++ b/lib/settings.dart @@ -17,6 +17,7 @@ class SettingsState extends State { TextEditingController(text: "${settings.anchorOffset}"); var _thresholdController = TextEditingController( text: decimalFormat(settings.autoShieldThreshold, 3)); + var _memoController = TextEditingController(); var _currency = settings.currency; var _needAuth = false; @@ -24,6 +25,7 @@ class SettingsState extends State { Widget build(BuildContext context) { final s = S.of(context); final simpleMode = settings.simpleMode; + _memoController.text = settings.memoSignature ?? s.sendFrom(coin.app); List options = coin.lwd .map((lwd) => FormBuilderFieldOption( @@ -146,9 +148,7 @@ class SettingsState extends State { ]), if (!simpleMode) FormBuilderTextField( decoration: InputDecoration( - labelText: S - .of(context) - .numberOfConfirmationsNeededBeforeSpending), + labelText: s.numberOfConfirmationsNeededBeforeSpending), name: 'anchor', keyboardType: TextInputType.number, controller: _anchorController, @@ -192,10 +192,17 @@ class SettingsState extends State { validator: _checkAmount), if (!simpleMode) FormBuilderCheckbox( name: 'use_trp', - title: Text(S.of(context).useTransparentBalance), + title: Text(s.useTransparentBalance), initialValue: settings.shieldBalance, onSaved: _shieldBalance), - ButtonBar(children: confirmButtons(context, _onSave)) + FormBuilderTextField( + decoration: InputDecoration( + labelText: s.defaultMemo), + name: 'memo', + keyboardType: TextInputType.number, + controller: _memoController, + onSaved: _onMemo), + ButtonBar(children: confirmButtons(context, _onSave)) ])))))); } @@ -273,6 +280,10 @@ class SettingsState extends State { settings.updateGetTx(v); } + _onMemo(v) { + settings.setMemoSignature(v); + } + _editTheme() { Navigator.of(context).pushNamed('/edit_theme'); } diff --git a/lib/store.dart b/lib/store.dart index 726f256..7f3b5e3 100644 --- a/lib/store.dart +++ b/lib/store.dart @@ -92,6 +92,9 @@ abstract class _Settings with Store { @observable int secondaryVariantColorValue = 0; + @observable + String? memoSignature; + @action Future restore() async { final prefs = await SharedPreferences.getInstance(); @@ -122,6 +125,8 @@ abstract class _Settings with Store { secondaryVariantColorValue = prefs.getInt('secondary.variant') ?? Colors.greenAccent.value; + memoSignature = prefs.getString('memo_signature'); + _updateThemeData(); Future.microtask(_loadCurrencies); // lazily return true; @@ -346,6 +351,13 @@ abstract class _Settings with Store { protectSend = v; prefs.setBool('protect_send', protectSend); } + + @action + Future setMemoSignature(String v) async { + final prefs = await SharedPreferences.getInstance(); + memoSignature = v; + prefs.setString('memo_signature', v); + } } class AccountManager = _AccountManager with _$AccountManager; diff --git a/pubspec.yaml b/pubspec.yaml index 9d67b67..31bb6c5 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -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.1.6+197 +version: 1.1.6+198 environment: sdk: ">=2.12.0 <3.0.0" diff --git a/pubspec.yaml.tpl b/pubspec.yaml.tpl index 9ecfa4d..8cc31da 100644 --- a/pubspec.yaml.tpl +++ b/pubspec.yaml.tpl @@ -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.1.6+197 +version: 1.1.6+198 environment: sdk: ">=2.12.0 <3.0.0"