From 4ae68f5be11d110f2df10d54377d970921e30a21 Mon Sep 17 00:00:00 2001 From: Scott Murray Date: Sun, 17 Dec 2023 15:48:21 -0500 Subject: Implement audio settings Changes: - Rework KUKSA.val "VAL" gRPC API implementation to separate it from the vehicle model + notifier, and more easily allow using it from other notifiers. - Move volume handling from the vehicle model + notifier to the audio set for clarity. - Wire up the new VSS audio signals in the audio notifier. The "rearFront" variable naming has been changed to "fade" in several places to match expected terminology. - Add a balance slider to the audio settings page. - Change the min/max labels on the fade slider to be Text instead of Icon's since we do not have the equivalent to use with the balance slider, and text seems like it'd be what you would want for any potential future internationalization. - Rework configuration file to be usable from anywhere via a RiverPod Provider instead of tied to the vehicle notifier code, and shifted the background and hybrid animation flags to be handled with it. This change removes the built-in asset with defaults in favor of maintaining the defaults for the ICS environment in the AppConfig and KuksaConfig classes, with a goal of avoiding the need for using async methods in the config provider. - Change some notifiers from using StateNotifier to the RiverPod 2.0 Notifier class for improved flexibility. The other notifiers will be updated in future work. - Added select's to several ref.watches in the new hybrid animation code to avoid unnecessary repaints. - Fix several spelling issues in method and parameter names across the codebase. Bug-AGL: SPEC-5001 Change-Id: Iefae417fa870405d659303497d96e519e6b6d1de Signed-off-by: Scott Murray --- lib/data/models/audio.dart | 35 ++++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-) (limited to 'lib/data/models/audio.dart') diff --git a/lib/data/models/audio.dart b/lib/data/models/audio.dart index 69df18b..65490f9 100644 --- a/lib/data/models/audio.dart +++ b/lib/data/models/audio.dart @@ -5,52 +5,59 @@ import 'package:flutter_ics_homescreen/export.dart'; @immutable class Audio { final double volume; + final double balance; + final double fade; final double treble; final double bass; - final double rearFront; const Audio({ required this.volume, + required this.balance, + required this.fade, required this.treble, required this.bass, - required this.rearFront, }); const Audio.initial() : volume = 5.0, + balance = 5.0, + fade = 5.0, treble = 5.0, - bass = 5.0, - rearFront = 5.0; + bass = 5.0; Audio copyWith({ double? volume, + double? balance, + double? fade, double? treble, double? bass, - double? rearFront, }) { return Audio( volume: volume ?? this.volume, + balance: balance ?? this.balance, + fade: fade ?? this.fade, treble: treble ?? this.treble, bass: bass ?? this.bass, - rearFront: rearFront ?? this.rearFront, ); } Map toMap() { return { 'volume': volume, + 'balance': balance, + 'fade': fade, 'treble': treble, 'bass': bass, - 'rearFront': rearFront, }; } factory Audio.fromMap(Map map) { return Audio( volume: map['volume']?.toDouble() ?? 0.0, + balance: map['balance']?.toDouble() ?? 0.0, + fade: map['fade']?.toDouble() ?? 0.0, treble: map['treble']?.toDouble() ?? 0.0, bass: map['bass']?.toDouble() ?? 0.0, - rearFront: map['rearFront']?.toDouble() ?? 0.0, ); } @@ -60,7 +67,7 @@ class Audio { @override String toString() { - return 'Audio(volume: $volume, treble: $treble, bass: $bass, rearFront: $rearFront)'; + return 'Audio(volume: $volume, balance: $balance, fade: $fade, treble: $treble, bass: $bass)'; } @override @@ -69,16 +76,18 @@ class Audio { return other is Audio && other.volume == volume && + other.balance == balance && + other.fade == fade && other.treble == treble && - other.bass == bass && - other.rearFront == rearFront; + other.bass == bass; } @override int get hashCode { return volume.hashCode ^ + balance.hashCode ^ + fade.hashCode ^ treble.hashCode ^ - bass.hashCode ^ - rearFront.hashCode; + bass.hashCode; } } -- cgit 1.2.3-korg