summaryrefslogtreecommitdiffstats
path: root/lib/data/models
diff options
context:
space:
mode:
authorScott Murray <scott.murray@konsulko.com>2023-12-17 15:48:21 -0500
committerJan-Simon Moeller <jsmoeller@linuxfoundation.org>2023-12-18 13:28:28 +0000
commit4ae68f5be11d110f2df10d54377d970921e30a21 (patch)
treeb37b5cb3c6964fbaeaa95edc1edeb44d615912e9 /lib/data/models
parentdda6c8502a3fa1e50654c4cca934b4b846bbca98 (diff)
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 <scott.murray@konsulko.com>
Diffstat (limited to 'lib/data/models')
-rw-r--r--lib/data/models/audio.dart35
-rw-r--r--lib/data/models/hybrid.dart2
-rw-r--r--lib/data/models/vehicle.dart139
3 files changed, 85 insertions, 91 deletions
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<String, dynamic> toMap() {
return {
'volume': volume,
+ 'balance': balance,
+ 'fade': fade,
'treble': treble,
'bass': bass,
- 'rearFront': rearFront,
};
}
factory Audio.fromMap(Map<String, dynamic> 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;
}
}
diff --git a/lib/data/models/hybrid.dart b/lib/data/models/hybrid.dart
index d567f14..5746033 100644
--- a/lib/data/models/hybrid.dart
+++ b/lib/data/models/hybrid.dart
@@ -2,7 +2,7 @@ enum HybridState {
idle,
engineOutput,
regenerativeBreaking,
- baterryOutput,
+ batteryOutput,
}
enum ArrowState { blue, red, green, yellow }
diff --git a/lib/data/models/vehicle.dart b/lib/data/models/vehicle.dart
index 2dea928..ad76620 100644
--- a/lib/data/models/vehicle.dart
+++ b/lib/data/models/vehicle.dart
@@ -10,7 +10,6 @@ class Vehicle {
final double outsideTemperature;
final int range;
final int fuelLevel;
- final int mediaVolume;
final bool isChildLockActiveLeft;
final bool isChildLockActiveRight;
final int frontLeftTire;
@@ -27,27 +26,26 @@ class Vehicle {
final bool temperatureSynced;
const Vehicle(
- this.speed,
- this.engineSpeed,
- this.insideTemperature,
- this.outsideTemperature,
- this.range,
- this.fuelLevel,
- this.mediaVolume,
- this.isChildLockActiveLeft,
- this.isChildLockActiveRight,
- this.frontLeftTire,
- this.frontRightTire,
- this.rearLeftTire,
- this.rearRightTire,
- this.isAirConditioningActive,
- this.isFrontDefrosterActive,
- this.isRearDefrosterActive,
- this.isRecirculationActive,
- this.fanSpeed,
- this.driverTemperature,
- this.passengerTemperature,
- this.temperatureSynced,
+ this.speed,
+ this.engineSpeed,
+ this.insideTemperature,
+ this.outsideTemperature,
+ this.range,
+ this.fuelLevel,
+ this.isChildLockActiveLeft,
+ this.isChildLockActiveRight,
+ this.frontLeftTire,
+ this.frontRightTire,
+ this.rearLeftTire,
+ this.rearRightTire,
+ this.isAirConditioningActive,
+ this.isFrontDefrosterActive,
+ this.isRearDefrosterActive,
+ this.isRecirculationActive,
+ this.fanSpeed,
+ this.driverTemperature,
+ this.passengerTemperature,
+ this.temperatureSynced,
);
const Vehicle.initial()
@@ -57,7 +55,6 @@ class Vehicle {
outsideTemperature = 0,
range = 0,
fuelLevel = 0,
- mediaVolume = 50,
isChildLockActiveLeft = false,
isChildLockActiveRight = true,
frontLeftTire = 33,
@@ -80,7 +77,6 @@ class Vehicle {
outsideTemperature = 32.0,
range = 21,
fuelLevel = 49,
- mediaVolume = 50,
isChildLockActiveLeft = false,
isChildLockActiveRight = true,
frontLeftTire = 33,
@@ -96,51 +92,49 @@ class Vehicle {
passengerTemperature = 26,
temperatureSynced = true;
- Vehicle copyWith(
- {double? speed,
- double? engineSpeed,
- double? insideTemperature,
- double? outsideTemperature,
- int? range,
- int? fuelLevel,
- int? mediaVolume,
- bool? isChildLockActiveLeft,
- bool? isChildLockActiveRight,
- int? frontLeftTire,
- int? frontRightTire,
- int? rearLeftTire,
- int? rearRightTire,
- bool? isAirConditioningActive,
- bool? isFrontDefrosterActive,
- bool? isRearDefrosterActive,
- bool? isRecirculationActive,
- int? fanSpeed,
- int? driverTemperature,
- int? passengerTemperature,
- bool? temperatureSynced,
+ Vehicle copyWith({
+ double? speed,
+ double? engineSpeed,
+ double? insideTemperature,
+ double? outsideTemperature,
+ int? range,
+ int? fuelLevel,
+ bool? isChildLockActiveLeft,
+ bool? isChildLockActiveRight,
+ int? frontLeftTire,
+ int? frontRightTire,
+ int? rearLeftTire,
+ int? rearRightTire,
+ bool? isAirConditioningActive,
+ bool? isFrontDefrosterActive,
+ bool? isRearDefrosterActive,
+ bool? isRecirculationActive,
+ int? fanSpeed,
+ int? driverTemperature,
+ int? passengerTemperature,
+ bool? temperatureSynced,
}) {
return Vehicle(
- speed ?? this.speed,
- engineSpeed ?? this.engineSpeed,
- insideTemperature ?? this.insideTemperature,
- outsideTemperature ?? this.outsideTemperature,
- range ?? this.range,
- fuelLevel ?? this.fuelLevel,
- mediaVolume ?? this.mediaVolume,
- isChildLockActiveLeft ?? this.isChildLockActiveLeft,
- isChildLockActiveRight ?? this.isChildLockActiveRight,
- frontLeftTire ?? this.frontLeftTire,
- frontRightTire ?? this.frontRightTire,
- rearLeftTire ?? this.rearLeftTire,
- rearRightTire ?? this.rearRightTire,
- isAirConditioningActive ?? this.isAirConditioningActive,
- isFrontDefrosterActive ?? this.isFrontDefrosterActive,
- isRearDefrosterActive ?? this.isRearDefrosterActive,
- isRecirculationActive ?? this.isRecirculationActive,
- fanSpeed ?? this.fanSpeed,
- driverTemperature ?? this.driverTemperature,
- passengerTemperature ?? this.passengerTemperature,
- temperatureSynced ?? this.temperatureSynced,
+ speed ?? this.speed,
+ engineSpeed ?? this.engineSpeed,
+ insideTemperature ?? this.insideTemperature,
+ outsideTemperature ?? this.outsideTemperature,
+ range ?? this.range,
+ fuelLevel ?? this.fuelLevel,
+ isChildLockActiveLeft ?? this.isChildLockActiveLeft,
+ isChildLockActiveRight ?? this.isChildLockActiveRight,
+ frontLeftTire ?? this.frontLeftTire,
+ frontRightTire ?? this.frontRightTire,
+ rearLeftTire ?? this.rearLeftTire,
+ rearRightTire ?? this.rearRightTire,
+ isAirConditioningActive ?? this.isAirConditioningActive,
+ isFrontDefrosterActive ?? this.isFrontDefrosterActive,
+ isRearDefrosterActive ?? this.isRearDefrosterActive,
+ isRecirculationActive ?? this.isRecirculationActive,
+ fanSpeed ?? this.fanSpeed,
+ driverTemperature ?? this.driverTemperature,
+ passengerTemperature ?? this.passengerTemperature,
+ temperatureSynced ?? this.temperatureSynced,
);
}
@@ -152,7 +146,6 @@ class Vehicle {
'outsideTemperature': outsideTemperature,
'range': range,
'fuelLevel': fuelLevel,
- 'mediaVolume': mediaVolume,
'isChildLockActiveLeft': isChildLockActiveLeft,
'isChildLockActiveRight': isChildLockActiveRight,
'frontLeftTire': frontLeftTire,
@@ -178,7 +171,6 @@ class Vehicle {
map['outsideTemperature']?.toDouble() ?? 0.0,
map['range']?.toInt() ?? 0,
map['fuelLevel']?.toDouble() ?? 0.0,
- map['mediaVolume']?.toInt() ?? 0,
map['isChildLockActiveLeft'] ?? false,
map['isChildLockActiveRight'] ?? false,
map['frontLeftTire']?.toInt() ?? 0,
@@ -203,7 +195,7 @@ class Vehicle {
@override
String toString() {
- return 'Vehicle(speed: $speed, insideTemperature: $insideTemperature, outsideTemperature: $outsideTemperature, range: $range, fuelLevel: $fuelLevel, mediaVolume: $mediaVolume, isChildLockActiveLeft: $isChildLockActiveLeft, isChildLockActiveRight: $isChildLockActiveRight, engineSpeed: $engineSpeed, frontLeftTire: $frontLeftTire, frontRightTire: $frontRightTire, rearLeftTire: $rearLeftTire, rearRightTire: $rearRightTire, isAirConditioningActive: $isAirConditioningActive, isFrontDefrosterActive: $isFrontDefrosterActive, isRearDefrosterActive: $isRearDefrosterActive, isRecirculationActive: $isRecirculationActive,fanSpeed:$fanSpeed,driverTemperature:$driverTemperature, passengerTemperature:$passengerTemperature)';
+ return 'Vehicle(speed: $speed, insideTemperature: $insideTemperature, outsideTemperature: $outsideTemperature, range: $range, fuelLevel: $fuelLevel, isChildLockActiveLeft: $isChildLockActiveLeft, isChildLockActiveRight: $isChildLockActiveRight, engineSpeed: $engineSpeed, frontLeftTire: $frontLeftTire, frontRightTire: $frontRightTire, rearLeftTire: $rearLeftTire, rearRightTire: $rearRightTire, isAirConditioningActive: $isAirConditioningActive, isFrontDefrosterActive: $isFrontDefrosterActive, isRearDefrosterActive: $isRearDefrosterActive, isRecirculationActive: $isRecirculationActive,fanSpeed:$fanSpeed,driverTemperature:$driverTemperature, passengerTemperature:$passengerTemperature)';
}
@override
@@ -216,7 +208,6 @@ class Vehicle {
other.outsideTemperature == outsideTemperature &&
other.range == range &&
other.fuelLevel == fuelLevel &&
- other.mediaVolume == mediaVolume &&
other.isChildLockActiveLeft == isChildLockActiveLeft &&
other.isChildLockActiveRight == isChildLockActiveRight &&
other.engineSpeed == engineSpeed &&
@@ -241,7 +232,6 @@ class Vehicle {
outsideTemperature.hashCode ^
range.hashCode ^
fuelLevel.hashCode ^
- mediaVolume.hashCode ^
isChildLockActiveLeft.hashCode ^
isChildLockActiveRight.hashCode ^
engineSpeed.hashCode ^
@@ -258,9 +248,4 @@ class Vehicle {
passengerTemperature.hashCode ^
temperatureSynced.hashCode;
}
-// }
-// / class VehicleNotifier extends StateNotifier<Vehicle> {
-// // VehicleNotifier() : super(Vehicle());
-
-// // }
}