diff --git a/open_earable/lib/controls_tab/models/open_earable_settings.dart b/open_earable/lib/controls_tab/models/open_earable_settings.dart index 72ba357..0e5a4a2 100644 --- a/open_earable/lib/controls_tab/models/open_earable_settings.dart +++ b/open_earable/lib/controls_tab/models/open_earable_settings.dart @@ -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"; diff --git a/open_earable/lib/controls_tab/views/audio_player.dart b/open_earable/lib/controls_tab/views/audio_player.dart index 8d10cbb..2f84c3f 100644 --- a/open_earable/lib/controls_tab/views/audio_player.dart +++ b/open_earable/lib/controls_tab/views/audio_player.dart @@ -209,18 +209,33 @@ class _AudioPlayerCardState extends State { ); } + 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, @@ -255,15 +270,7 @@ class _AudioPlayerCardState extends State { 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, @@ -300,15 +307,7 @@ class _AudioPlayerCardState extends State { 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,