From 193d15a456587bcf3928fb99fe0c1aede82d119d Mon Sep 17 00:00:00 2001 From: Lisandro Pérez Meyer Date: Tue, 21 Nov 2023 14:14:02 -0300 Subject: Update volume bar. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Original from: Dominik Wawrzonek Bug-AGL: SPEC-4971 Change-Id: I80ed2fb908488dce3eb88b2cdb361ea9802d9a6b Signed-off-by: Lisandro Pérez Meyer --- lib/presentation/common_widget/volume_bar.dart | 32 +++++++++++----------- .../media_player/widgets/media_volume_bar.dart | 30 ++++++++++---------- 2 files changed, 32 insertions(+), 30 deletions(-) (limited to 'lib/presentation') diff --git a/lib/presentation/common_widget/volume_bar.dart b/lib/presentation/common_widget/volume_bar.dart index a029698..f494332 100644 --- a/lib/presentation/common_widget/volume_bar.dart +++ b/lib/presentation/common_widget/volume_bar.dart @@ -14,32 +14,32 @@ class VolumeBarState extends ConsumerState { @override void initState() { super.initState(); - // "ref" can be used in all life-cycles of a StatefulWidget. - //ref.read(counterProvider); } void increaseVolume() { + val += 10; + if (val > 100) { + val = 100; + } setState(() { - if (val < 20) { - val++; - ref.read(audioStateProvider.notifier).setVolume(val); - } + ref.read(vehicleProvider.notifier).setVolume(val); }); } void decreaseVolume() { + val -= 10; + if (val < 0) { + val = 0; + } setState(() { - if (val > 0) { - val--; - ref.read(audioStateProvider.notifier).setVolume(val); - } + ref.read(vehicleProvider.notifier).setVolume(val); }); } void setVolume(double newWalue) { setState(() { val = newWalue; - ref.read(audioStateProvider.notifier).setVolume(val); + ref.read(vehicleProvider.notifier).setVolume(val); }); } @@ -48,8 +48,8 @@ class VolumeBarState extends ConsumerState { @override Widget build(BuildContext context) { final volumeValue = - ref.watch(audioStateProvider.select((audio) => audio.volume)); - val = volumeValue; + ref.watch(vehicleProvider.select((vehicle) => vehicle.mediaVolume)); + val = volumeValue.toDouble(); return Column( // mainAxisAlignment: MainAxisAlignment.center, // crossAxisAlignment: CrossAxisAlignment.center, @@ -114,9 +114,9 @@ class VolumeBarState extends ConsumerState { ), child: Slider( min: 0, - max: 20, - value: volumeValue, - divisions: 20, + max: 100, + value: volumeValue.toDouble(), + divisions: 10, onChanged: (newValue) { setVolume(newValue); }, diff --git a/lib/presentation/screens/media_player/widgets/media_volume_bar.dart b/lib/presentation/screens/media_player/widgets/media_volume_bar.dart index 2b063b4..ed962a7 100644 --- a/lib/presentation/screens/media_player/widgets/media_volume_bar.dart +++ b/lib/presentation/screens/media_player/widgets/media_volume_bar.dart @@ -14,28 +14,30 @@ class CustomVolumeSlider extends ConsumerStatefulWidget { class CustomVolumeSliderState extends ConsumerState { void _increase() { + _currentVal += 10; + if (_currentVal > 100) { + _currentVal = 100; + } setState(() { - if (_currentVal < 20) { - _currentVal++; - ref.read(audioStateProvider.notifier).setVolume(_currentVal); - } + ref.read(vehicleProvider.notifier).setVolume(_currentVal); }); } void _dercrease() { + _currentVal -= 10; + if (_currentVal < 0) { + _currentVal = 0; + } setState(() { - if (_currentVal > 0) { - _currentVal--; - ref.read(audioStateProvider.notifier).setVolume(_currentVal); - } + ref.read(vehicleProvider.notifier).setVolume(_currentVal); }); } - double _currentVal = 5; + double _currentVal = 50; @override Widget build(BuildContext context) { final volumeValue = - ref.watch(audioStateProvider.select((audio) => audio.volume)); + ref.watch(vehicleProvider.select((audio) => audio.mediaVolume)); return Column( //crossAxisAlignment: CrossAxisAlignment.center, @@ -99,12 +101,12 @@ class CustomVolumeSliderState extends ConsumerState { //trackHeight: 5, ), child: Slider( - divisions: 20, + divisions: 10, min: 0, - max: 20, - value: volumeValue, + max: 100, + value: volumeValue.toDouble(), onChanged: (newValue) { - ref.read(audioStateProvider.notifier).setVolume(newValue); + ref.read(vehicleProvider.notifier).setVolume(newValue); _currentVal = newValue; }, ), -- cgit 1.2.3-korg