Skip to content

Commit

Permalink
Fix none sound labeling
Browse files Browse the repository at this point in the history
  • Loading branch information
a-mabe committed Dec 22, 2024
1 parent 61be619 commit 2db9c67
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 17 deletions.
8 changes: 4 additions & 4 deletions lib/pages/set_sounds/constants/sounds.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@ const List<String> soundsList = <String>[
'ding',
'ding-sequence',
'thunk',
'',
'none',
];

const List<String> countdownSounds = <String>[
'countdown-beep',
'short-rest-beep',
'',
'none',
];

var soundNames = {
final Map<String, String> soundNames = {
"long-bell": "Long bell",
"countdown-beep": "Countdown beep",
"ding-sequence": "Ding sequence",
Expand All @@ -38,5 +38,5 @@ var soundNames = {
"short-rest-beep": "Beep",
"short-whistle": "Short whistle",
"thunk": "Thunk",
"": "None"
"none": "None"
};
39 changes: 26 additions & 13 deletions lib/pages/set_sounds/set_sounds.dart
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,9 @@ class _SetSoundsState extends State<SetSounds> {

var soundIdMap = {};
for (final sound in allSounds) {
soundIdMap[sound] = loadSound(sound, pool);
if (sound != "none") {
soundIdMap[sound] = loadSound(sound, pool);
}
}

return Stack(
Expand Down Expand Up @@ -116,10 +118,12 @@ class _SetSoundsState extends State<SetSounds> {
pool: pool,
soundsList: soundsList,
onFinished: (value) async {
if (value != '') {
if (!value.contains("none")) {
await pool.play(await soundIdMap[value]);
widget.timer.soundSettings.workSound = value!;
} else {
widget.timer.soundSettings.workSound = "";
}
widget.timer.soundSettings.workSound = value!;
}),
SoundDropdown(
dropdownKey: const Key("rest-sound"),
Expand All @@ -129,10 +133,12 @@ class _SetSoundsState extends State<SetSounds> {
pool: pool,
soundsList: soundsList,
onFinished: (value) async {
if (value != '') {
if (!value.contains("none")) {
await pool.play(await soundIdMap[value]);
widget.timer.soundSettings.restSound = value!;
} else {
widget.timer.soundSettings.restSound = "";
}
widget.timer.soundSettings.restSound = value!;
}),
SoundDropdown(
dropdownKey: const Key("halfway-sound"),
Expand All @@ -142,11 +148,13 @@ class _SetSoundsState extends State<SetSounds> {
pool: pool,
soundsList: soundsList,
onFinished: (value) async {
if (value != '') {
if (!value.contains("none")) {
await pool.play(await soundIdMap[value]);
widget.timer.soundSettings.halfwaySound =
value!;
} else {
widget.timer.soundSettings.halfwaySound = "";
}
widget.timer.soundSettings.halfwaySound =
value!;
}),
SoundDropdown(
dropdownKey: const Key("countdown-sound"),
Expand All @@ -156,11 +164,14 @@ class _SetSoundsState extends State<SetSounds> {
pool: pool,
soundsList: countdownSounds,
onFinished: (value) async {
if (value != '') {
if (!value.contains("none")) {
await pool.play(await soundIdMap[value]);
widget.timer.soundSettings.countdownSound =
value!;
} else {
widget.timer.soundSettings.countdownSound =
"";
}
widget.timer.soundSettings.countdownSound =
value!;
}),
SoundDropdown(
dropdownKey: const Key("end-sound"),
Expand All @@ -170,10 +181,12 @@ class _SetSoundsState extends State<SetSounds> {
pool: pool,
soundsList: soundsList,
onFinished: (value) async {
if (value != '') {
if (!value.contains("none")) {
await pool.play(await soundIdMap[value]);
widget.timer.soundSettings.endSound = value!;
} else {
widget.timer.soundSettings.endSound = "";
}
widget.timer.soundSettings.endSound = value!;
}),
],
))))),
Expand Down

0 comments on commit 2db9c67

Please sign in to comment.