Skip to content

Commit

Permalink
disable radio selection for audio player when earable is not connected
Browse files Browse the repository at this point in the history
  • Loading branch information
o-bagge committed Dec 13, 2023
1 parent e7b7f2c commit 84b7077
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class OpenEarableSettings {
selectedBarometerOption = "0";
selectedMicrophoneOption = "0";

selectedAudioPlayerRadio = 0;
selectedAudioPlayerRadio = 3; // no radio is selected
selectedJingle = jingleMap[1]!;
selectedWaveForm = waveFormMap[1]!;
selectedFilename = "filename.wav";
Expand Down
53 changes: 26 additions & 27 deletions open_earable/lib/controls_tab/views/audio_player.dart
Original file line number Diff line number Diff line change
Expand Up @@ -209,18 +209,33 @@ class _AudioPlayerCardState extends State<AudioPlayerCard> {
);
}

Widget _getAudioPlayerRadio(int index) {
return Radio(
value: index,
groupValue: OpenEarableSettings().selectedAudioPlayerRadio,
onChanged: !_openEarable.bleManager.connected
? null
: (int? value) {
setState(() {
OpenEarableSettings().selectedAudioPlayerRadio = value ?? 0;
});
},
activeColor: !_openEarable.bleManager.connected
? Colors.grey
: Theme.of(context).colorScheme.secondary,
fillColor: MaterialStateProperty.resolveWith((states) {
if (states.contains(MaterialState.disabled)) {
return Colors.grey;
}
return Theme.of(context).colorScheme.secondary;
}),
);
}

Widget _getFileNameRow() {
return Row(
children: [
Radio(
value: 0,
groupValue: OpenEarableSettings().selectedAudioPlayerRadio,
onChanged: (int? value) {
setState(() {
OpenEarableSettings().selectedAudioPlayerRadio = value ?? 0;
});
},
),
_getAudioPlayerRadio(0),
Expanded(
child: SizedBox(
height: 37.0,
Expand Down Expand Up @@ -255,15 +270,7 @@ class _AudioPlayerCardState extends State<AudioPlayerCard> {
Widget _getJingleRow() {
return Row(
children: [
Radio(
value: 1,
groupValue: OpenEarableSettings().selectedAudioPlayerRadio,
onChanged: (int? value) {
setState(() {
OpenEarableSettings().selectedAudioPlayerRadio = value ?? 0;
});
},
),
_getAudioPlayerRadio(1),
Expanded(
child: SizedBox(
height: 37.0,
Expand Down Expand Up @@ -300,15 +307,7 @@ class _AudioPlayerCardState extends State<AudioPlayerCard> {
Widget _getFrequencyRow() {
return Row(
children: [
Radio(
value: 2,
groupValue: OpenEarableSettings().selectedAudioPlayerRadio,
onChanged: (int? value) {
setState(() {
OpenEarableSettings().selectedAudioPlayerRadio = value ?? 0;
});
},
),
_getAudioPlayerRadio(2),
SizedBox(
height: 37.0,
width: 75,
Expand Down

0 comments on commit 84b7077

Please sign in to comment.