Add option to turn off sound effects

This commit is contained in:
Hanh 2023-05-04 19:10:06 +10:00
parent db30dd6980
commit df2def217c
11 changed files with 45 additions and 6 deletions

View File

@ -338,6 +338,7 @@ class MessageLookup extends MessageLookupByLibrary {
"paymentMade": MessageLookupByLibrary.simpleMessage("Payment made"),
"pink": MessageLookupByLibrary.simpleMessage("Pink"),
"pl": MessageLookupByLibrary.simpleMessage("P/L"),
"playSound": MessageLookupByLibrary.simpleMessage("Play Sound"),
"pleaseAuthenticateToSend":
MessageLookupByLibrary.simpleMessage("Please authenticate to Send"),
"pleaseAuthenticateToShowAccountSeed":

View File

@ -343,6 +343,7 @@ class MessageLookup extends MessageLookupByLibrary {
"paymentMade": MessageLookupByLibrary.simpleMessage("Pago enviado"),
"pink": MessageLookupByLibrary.simpleMessage("Rosado"),
"pl": MessageLookupByLibrary.simpleMessage("G/P"),
"playSound": MessageLookupByLibrary.simpleMessage("Sonido"),
"pleaseAuthenticateToSend": MessageLookupByLibrary.simpleMessage(
"Por favor autentíquese para enviar"),
"pleaseAuthenticateToShowAccountSeed":

View File

@ -345,6 +345,7 @@ class MessageLookup extends MessageLookupByLibrary {
"paymentMade": MessageLookupByLibrary.simpleMessage("Payment Envoyé"),
"pink": MessageLookupByLibrary.simpleMessage("Rose"),
"pl": MessageLookupByLibrary.simpleMessage("Profit/Perte"),
"playSound": MessageLookupByLibrary.simpleMessage("Effets Sonores"),
"pleaseAuthenticateToSend": MessageLookupByLibrary.simpleMessage(
"Veillez vous authentifier avant l\'envoi"),
"pleaseAuthenticateToShowAccountSeed":

View File

@ -3161,6 +3161,16 @@ class S {
args: [],
);
}
/// `Play Sound`
String get playSound {
return Intl.message(
'Play Sound',
name: 'playSound',
desc: '',
args: [],
);
}
}
class AppLocalizationDelegate extends LocalizationsDelegate<S> {

View File

@ -309,5 +309,6 @@
"scanTransparentAddresses": "Scan Transparent Addresses",
"scanningAddresses": "Scanning addresses",
"blockExplorer": "Block Explorer",
"tapQrCodeForSaplingAddress": "Tap QR Code for Sapling Address"
"tapQrCodeForSaplingAddress": "Tap QR Code for Sapling Address",
"playSound": "Play Sound"
}

View File

@ -307,5 +307,6 @@
"scanTransparentAddresses": "Scan Transparent Addresses",
"scanningAddresses": "Scanning addresses",
"blockExplorer": "Block Explorer",
"tapQrCodeForSaplingAddress": "Tap QR Code for Sapling Address"
"tapQrCodeForSaplingAddress": "Tap QR Code for Sapling Address",
"playSound": "Sonido"
}

View File

@ -308,5 +308,6 @@
"scanTransparentAddresses": "Scan Transparent Addresses",
"scanningAddresses": "Scanning addresses",
"blockExplorer": "Block Explorer",
"tapQrCodeForSaplingAddress": "Tap QR Code for Sapling Address"
"tapQrCodeForSaplingAddress": "Tap QR Code for Sapling Address",
"playSound": "Effets Sonores"
}

View File

@ -304,6 +304,12 @@ class SettingsState extends State<SettingsPage>
title: Text(s.antispamFilter),
initialValue: settings.antispam,
onSaved: _antispam),
if (!simpleMode)
FormBuilderCheckbox(
name: 'sound',
title: Text(s.playSound),
initialValue: settings.sound,
onSaved: _sound),
if (!simpleMode && WarpApi.hasGPU())
FormBuilderCheckbox(
name: 'gpu',
@ -406,6 +412,10 @@ class SettingsState extends State<SettingsPage>
settings.setAntiSpam(v);
}
_sound(v) {
settings.setSound(v);
}
_useGPU(v) {
settings.setUseGPU(v);
}

View File

@ -196,6 +196,9 @@ abstract class _Settings with Store {
@observable
int minPrivacyLevel = 0;
@observable
bool sound = true;
String dbPasswd = "";
@action
@ -225,6 +228,7 @@ abstract class _Settings with Store {
noteView = ViewStyle.values[(prefs.getInt('note_view') ?? 0)];
txView = ViewStyle.values[(prefs.getInt('tx_view') ?? 0)];
qrOffline = prefs.getBool('qr_offline') ?? true;
sound = prefs.getBool('sound') ?? true;
primaryColorValue = prefs.getInt('primary') ?? Colors.blue.value;
primaryVariantColorValue =
@ -308,6 +312,13 @@ abstract class _Settings with Store {
prefs.setBool('antispam', v);
}
@action
Future<void> setSound(bool v) async {
final prefs = await SharedPreferences.getInstance();
sound = v;
prefs.setBool('sound', v);
}
@action
Future<void> setUseMillis(bool v) async {
final prefs = await SharedPreferences.getInstance();

View File

@ -123,12 +123,14 @@ class TxPlanPage extends StatelessWidget {
await WarpApi.signAndBroadcast(active.coin, active.id, plan);
}
showSnackBar(S.current.txId(txid));
await player.play(AssetSource("success.mp3"));
if (settings.sound)
await player.play(AssetSource("success.mp3"));
active.setDraftRecipient(null);
active.update();
} on String catch (message) {
showSnackBar(message, error: true);
await player.play(AssetSource("fail.mp3"));
if (settings.sound)
await player.play(AssetSource("fail.mp3"));
} finally {
active.setBanner("");
}

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.4.0+434
version: 1.4.0+435
environment:
sdk: ">=2.12.0 <3.0.0"