summaryrefslogtreecommitdiffstats
path: root/lib/data/data_providers
diff options
context:
space:
mode:
Diffstat (limited to 'lib/data/data_providers')
-rw-r--r--lib/data/data_providers/app.dart25
-rw-r--r--lib/data/data_providers/app_provider.dart63
-rw-r--r--lib/data/data_providers/audio_notifier.dart25
-rw-r--r--lib/data/data_providers/datetime_notifier.dart14
-rw-r--r--lib/data/data_providers/hybrid_notifier.dart91
-rw-r--r--lib/data/data_providers/signal_notifier.dart14
-rw-r--r--lib/data/data_providers/units_notifier.dart13
-rw-r--r--lib/data/data_providers/users_notifier.dart49
-rw-r--r--lib/data/data_providers/vehicle_notifier.dart367
-rw-r--r--lib/data/data_providers/vss_provider.dart105
10 files changed, 766 insertions, 0 deletions
diff --git a/lib/data/data_providers/app.dart b/lib/data/data_providers/app.dart
new file mode 100644
index 0000000..acfaa01
--- /dev/null
+++ b/lib/data/data_providers/app.dart
@@ -0,0 +1,25 @@
+import '../../export.dart';
+
+class App extends StatelessWidget {
+ const App({super.key});
+
+ @override
+ Widget build(BuildContext context) {
+ return const AppView();
+ }
+}
+
+class AppView extends StatelessWidget {
+ const AppView({super.key});
+
+ @override
+ Widget build(BuildContext context) {
+ return ProviderScope(
+ child: MaterialApp(
+ debugShowCheckedModeBanner: false,
+ theme: theme,
+ home: const HomeScreen(),
+ ),
+ );
+ }
+}
diff --git a/lib/data/data_providers/app_provider.dart b/lib/data/data_providers/app_provider.dart
new file mode 100644
index 0000000..c528a1a
--- /dev/null
+++ b/lib/data/data_providers/app_provider.dart
@@ -0,0 +1,63 @@
+import 'package:flutter_ics_homescreen/data/data_providers/datetime_notifier.dart';
+import 'package:flutter_ics_homescreen/data/data_providers/hybrid_notifier.dart';
+import 'package:flutter_ics_homescreen/data/data_providers/signal_notifier.dart';
+import 'package:flutter_ics_homescreen/data/data_providers/units_notifier.dart';
+import 'package:flutter_ics_homescreen/data/data_providers/audio_notifier.dart';
+import 'package:flutter_ics_homescreen/data/data_providers/users_notifier.dart';
+import 'package:flutter_ics_homescreen/data/models/date_time.dart';
+import 'package:flutter_ics_homescreen/export.dart';
+
+import '../models/users.dart';
+import 'vehicle_notifier.dart';
+
+enum AppState {
+ home,
+ dashboard,
+ hvac,
+ apps,
+ mediaPlayer,
+ settings,
+ splash,
+ dateTime,
+ bluetooth,
+ wifi,
+ wired,
+ audioSettings,
+ profiles,
+ newProfile,
+ units,
+ versionInfo,
+ weather,
+ distanceUnit,
+ tempUnit,
+ clock,
+ date,
+ time
+}
+
+final appProvider = StateProvider<AppState>((ref) => AppState.splash);
+final vehicleProvider = StateNotifierProvider<VehicleNotifier, Vehicle>((ref) {
+ return VehicleNotifier(const Vehicle.initial());
+});
+final signalsProvider = StateNotifierProvider<SignalNotifier, Signals>((ref) {
+ return SignalNotifier(const Signals.initial());
+});
+
+final unitStateProvider = StateNotifierProvider<UnitsNotifier, Units>((ref) {
+ return UnitsNotifier(const Units.initial());
+});
+final audioStateProvider = StateNotifierProvider<AudioNotifier, Audio>((ref) {
+ return AudioNotifier(const Audio.initial());
+});
+
+final usersProvider = StateNotifierProvider<UsersNotifier, Users>((ref) {
+ return UsersNotifier(Users.initial());
+});
+
+final dateTimeStateProvider =
+ StateNotifierProvider<DateTimeNotifier, DateAndTime>((ref) {
+ return DateTimeNotifier(DateAndTime.initial());
+});
+final hybridtateProvider = StateNotifierProvider<HybridNotifier, Hybrid>((ref) {
+ return HybridNotifier(const Hybrid.initial());
+});
diff --git a/lib/data/data_providers/audio_notifier.dart b/lib/data/data_providers/audio_notifier.dart
new file mode 100644
index 0000000..8981036
--- /dev/null
+++ b/lib/data/data_providers/audio_notifier.dart
@@ -0,0 +1,25 @@
+import 'package:flutter_ics_homescreen/export.dart';
+
+class AudioNotifier extends StateNotifier<Audio> {
+ AudioNotifier(super.state);
+
+ void resetToDefaults() {
+ state = state.copyWith(treble: 5.0, bass: 5.0, rearFront: 5.0);
+ }
+
+ void setVolume(double newVal) {
+ state = state.copyWith(volume: newVal);
+ }
+
+ void setTreble(double newVal) {
+ state = state.copyWith(treble: newVal);
+ }
+
+ void setBass(double newVal) {
+ state = state.copyWith(bass: newVal);
+ }
+
+ void setRearFront(double newVal) {
+ state = state.copyWith(rearFront: newVal);
+ }
+}
diff --git a/lib/data/data_providers/datetime_notifier.dart b/lib/data/data_providers/datetime_notifier.dart
new file mode 100644
index 0000000..6947a34
--- /dev/null
+++ b/lib/data/data_providers/datetime_notifier.dart
@@ -0,0 +1,14 @@
+import 'package:flutter_ics_homescreen/data/models/date_time.dart';
+import 'package:flutter_ics_homescreen/export.dart';
+
+class DateTimeNotifier extends StateNotifier<DateAndTime> {
+ DateTimeNotifier(super.state);
+
+ void setDate(String newVal) {
+ state = state.copyWith(date: newVal);
+ }
+
+ void setTime(String newVal) {
+ state = state.copyWith(time: newVal);
+ }
+}
diff --git a/lib/data/data_providers/hybrid_notifier.dart b/lib/data/data_providers/hybrid_notifier.dart
new file mode 100644
index 0000000..a19bf58
--- /dev/null
+++ b/lib/data/data_providers/hybrid_notifier.dart
@@ -0,0 +1,91 @@
+import '../../export.dart';
+
+class HybridNotifier extends StateNotifier<Hybrid> {
+ HybridNotifier(super.state);
+
+ void setHybridState(HybridState hybridState) {
+ switch (hybridState) {
+ case HybridState.idle:
+ state = state.copyWith(
+ topArrowState: ArrowState.blue,
+ leftArrowState: ArrowState.blue,
+ rightArrowState: ArrowState.blue,
+ batteryState: BatteryState.white,
+ );
+ break;
+ case HybridState.engineOutput:
+ state = state.copyWith(
+ topArrowState: ArrowState.red,
+ leftArrowState: ArrowState.red,
+ rightArrowState: ArrowState.blue,
+ batteryState: BatteryState.red,
+ );
+ break;
+ case HybridState.regenerativeBreaking:
+ state = state.copyWith(
+ topArrowState: ArrowState.blue,
+ leftArrowState: ArrowState.blue,
+ rightArrowState: ArrowState.green,
+ batteryState: BatteryState.green);
+
+ break;
+ case HybridState.baterryOutput:
+ state = state.copyWith(
+ topArrowState: ArrowState.blue,
+ leftArrowState: ArrowState.blue,
+ rightArrowState: ArrowState.yellow,
+ batteryState: BatteryState.yellow);
+ break;
+ default:
+ }
+ state = state.copyWith(hybridState: hybridState);
+ }
+
+ void updateHybridState() {
+ // Variable to store the current state
+ HybridState currentState = state.hybridState;
+
+ // Variable to store the previous state
+ HybridState previousState = currentState;
+
+ // Variable to store the average speed value
+ double avgSpeed = 0.0;
+
+ // Variable for storing the average value of RPM
+ double avgRpm = 0.0;
+
+ // Variable to store the brake value state
+ bool brake = false;
+
+ // Collect 10 samples
+ for (int i = 0; i < 10; i++) {
+ // Get the current values for speed, engine rpm and brake status
+
+ // speed = vehicleProvider();
+ // rpm = _rpmFromServer();
+ // brake = _brakeFromServer();
+
+ // Calculate the average speed value
+ // avgSpeed = (avgSpeed * (i + 1) + speed) / (i + 2);
+
+ // Calculate the average engine rpm
+ // avgRpm = (avgRpm * (i + 1) + rpm) / (i + 2);
+ }
+
+ // define new state
+ // if (avgSpeed == 0 && avgRpm == 0) {
+ // currentState = HybridState.idle;
+ // } else if (avgRpm > 0 && avgSpeed > 0) {
+ // currentState = HybridState.engineOutput;
+ // } else if (avgRpm == 0 && brake) {
+ // currentState = HybridState.regenerativeBreaking;
+ // } else if (avgSpeed > 0 && avgRpm <= avgSpeed) {
+ // currentState = HybridState.baterryOutput;
+ // }
+
+ // Zaktualizuj stan
+ if (currentState != previousState) {
+ state = state.copyWith(hybridState: currentState);
+ }
+ }
+}
diff --git a/lib/data/data_providers/signal_notifier.dart b/lib/data/data_providers/signal_notifier.dart
new file mode 100644
index 0000000..3059174
--- /dev/null
+++ b/lib/data/data_providers/signal_notifier.dart
@@ -0,0 +1,14 @@
+import 'package:flutter_ics_homescreen/export.dart';
+
+class SignalNotifier extends StateNotifier<Signals> {
+ SignalNotifier(super.state);
+
+ void startListen() {}
+ void toggleBluetooth() {
+ state = state.copyWith(isBluetoothConnected: !state.isBluetoothConnected);
+ }
+
+ void toggleWifi() {
+ state = state.copyWith(isWifiConnected: !state.isWifiConnected);
+ }
+}
diff --git a/lib/data/data_providers/units_notifier.dart b/lib/data/data_providers/units_notifier.dart
new file mode 100644
index 0000000..f7c25aa
--- /dev/null
+++ b/lib/data/data_providers/units_notifier.dart
@@ -0,0 +1,13 @@
+import '../../export.dart';
+
+class UnitsNotifier extends StateNotifier<Units> {
+ UnitsNotifier(super.state);
+
+ void setDistanceUnit(DistanceUnit unit) {
+ state = state.copyWith(distanceUnit: unit);
+ }
+
+ void setTemperatureUnit(TemperatureUnit unit) {
+ state = state.copyWith(temperatureUnit: unit);
+ }
+}
diff --git a/lib/data/data_providers/users_notifier.dart b/lib/data/data_providers/users_notifier.dart
new file mode 100644
index 0000000..8b48382
--- /dev/null
+++ b/lib/data/data_providers/users_notifier.dart
@@ -0,0 +1,49 @@
+import 'package:flutter_ics_homescreen/data/models/users.dart';
+import 'package:flutter_ics_homescreen/export.dart';
+import 'package:uuid/uuid.dart';
+
+import '../models/user.dart';
+
+class UsersNotifier extends StateNotifier<Users> {
+ UsersNotifier(super.state) {
+ loadUsers();
+ }
+
+ void loadUsers() {
+ state = state.copyWith(users: _users);
+ }
+
+ final List<User> _users = [
+ const User(id: '1', name: 'Heather'),
+ const User(id: '2', name: 'George'),
+ const User(id: '3', name: 'Riley'),
+ ];
+ void selectUser(String userId) {
+ var seletedUser = state.users.firstWhere((user) => user.id == userId);
+ state = state.copyWith(selectedUser: seletedUser);
+ }
+
+ void removeUser(String userId) {
+ state.users.removeWhere((user) => user.id == userId);
+ if (state.users.isNotEmpty) {
+ state = state.copyWith(selectedUser: state.users.first);
+ }
+ if (state.users.isEmpty) {
+ state = state.copyWith(selectedUser: const User(id: '', name: ''));
+ }
+ }
+
+ void addUser(String userName) {
+ final id = const Uuid().v1();
+ final user = User(id: id, name: userName);
+
+ state.users.insert(0, user);
+ state = state.copyWith(selectedUser: state.users.first);
+ }
+
+ void editUser(User user) {
+ // final id = const Uuid().v1();
+ // final user = User(id: id, name: userName);
+ //_users.add(user);
+ }
+}
diff --git a/lib/data/data_providers/vehicle_notifier.dart b/lib/data/data_providers/vehicle_notifier.dart
new file mode 100644
index 0000000..7842311
--- /dev/null
+++ b/lib/data/data_providers/vehicle_notifier.dart
@@ -0,0 +1,367 @@
+import 'dart:async';
+
+import 'package:flutter_ics_homescreen/export.dart';
+import 'package:flutter/services.dart';
+import 'package:protos/protos.dart';
+
+class VehicleNotifier extends StateNotifier<Vehicle> {
+ VehicleNotifier(super.state);
+
+ late ClientChannel channel;
+ late VALClient stub;
+
+ void updateSpeed(double newValue) {
+ state = state.copyWith(speed: newValue);
+ }
+
+ void handleSignalsUpdate(EntryUpdate update) {
+ switch (update.entry.path) {
+ case VSSPath.vehicleSpeed:
+ if (update.entry.value.hasFloat()) {
+ state = state.copyWith(speed: update.entry.value.float);
+ }
+ break;
+ case VSSPath.vehicleInsideTemperature:
+ if (update.entry.value.hasFloat()) {
+ state = state.copyWith(insideTemperature: update.entry.value.float);
+ }
+ break;
+ case VSSPath.vehicleOutsideTemperature:
+ if (update.entry.value.hasFloat()) {
+ state = state.copyWith(outsideTemperature: update.entry.value.float);
+ }
+ break;
+ case VSSPath.vehicleRange:
+ if (update.entry.value.hasUint32()) {
+ state = state.copyWith(range: update.entry.value.uint32);
+ }
+ break;
+ case VSSPath.vehicleFuelLevel:
+ if (update.entry.value.hasFloat()) {
+ state = state.copyWith(fuelLevel: update.entry.value.float);
+ }
+ break;
+ // case VSSPath.vehicleMediaVolume:
+ // if (update.entry.value.hasInt32()) {
+ // ref
+ // .read(vehicleMediaVolume.notifier)
+ // .update((state) => state = update.entry.value.uint32);
+ // }
+ // break;
+ case VSSPath.vehicleIsChildLockActiveLeft:
+ if (update.entry.value.hasBool_12()) {
+ state =
+ state.copyWith(isChildLockActiveLeft: update.entry.value.bool_12);
+ }
+ break;
+ case VSSPath.vehicleIsChildLockActiveRight:
+ if (update.entry.value.hasBool_12()) {
+ state = state.copyWith(
+ isChildLockActiveRight: update.entry.value.bool_12);
+ }
+ break;
+ case VSSPath.vehicleEngineSpeed:
+ if (update.entry.value.hasUint32()) {
+ state = state.copyWith(engineSpeed: update.entry.value.uint32);
+ }
+ break;
+ case VSSPath.vehicleFrontLeftTire:
+ if (update.entry.value.hasUint32()) {
+ state = state.copyWith(frontLeftTire: update.entry.value.uint32);
+ }
+ break;
+ case VSSPath.vehicleFrontRightTire:
+ if (update.entry.value.hasUint32()) {
+ state = state.copyWith(frontRightTire: update.entry.value.uint32);
+ }
+ break;
+ case VSSPath.vehicleRearLeftTire:
+ if (update.entry.value.hasUint32()) {
+ state = state.copyWith(rearLeftTire: update.entry.value.uint32);
+ }
+ break;
+ case VSSPath.vehicleRearRightTire:
+ if (update.entry.value.hasUint32()) {
+ state = state.copyWith(rearRightTire: update.entry.value.uint32);
+ }
+ break;
+
+ ///
+ case VSSPath.vehicleIsAirConditioningActive:
+ if (update.entry.value.hasBool_12()) {
+ state = state.copyWith(
+ isAirConditioningActive: update.entry.value.bool_12);
+ }
+ break;
+ case VSSPath.vehicleIsFrontDefrosterActive:
+ if (update.entry.value.hasBool_12()) {
+ state = state.copyWith(
+ isFrontDefrosterActive: update.entry.value.bool_12);
+ }
+ break;
+ case VSSPath.vehicleIsRearDefrosterActive:
+ if (update.entry.value.hasBool_12()) {
+ state =
+ state.copyWith(isRearDefrosterActive: update.entry.value.bool_12);
+ }
+ break;
+ case VSSPath.vehicleIsRecirculationActive:
+ if (update.entry.value.hasBool_12()) {
+ state =
+ state.copyWith(isRecirculationActive: update.entry.value.bool_12);
+ }
+ break;
+ case VSSPath.vehicleFanSpeed:
+ if (update.entry.value.hasUint32()) {
+ state = state.copyWith(fanSpeed: update.entry.value.uint32);
+ }
+ break;
+
+ // default:
+ // debugPrint("ERROR: Unexpected path ${update.entry.path}");
+ // break;
+ }
+ }
+
+ void startListen() async {
+ String hostName = 'localhost';
+ int port = 8080;
+ try {
+ var data = await rootBundle.loadString('config/config.yaml');
+ final dynamic yamlMap = loadYaml(data);
+
+ if (yamlMap.containsKey('hostname')) {
+ hostName = yamlMap['hostname'];
+ }
+
+ if (yamlMap.containsKey('port')) {
+ port = yamlMap['port'];
+ }
+ } catch (e) {
+ //debugPrint('ERROR: Could not read from file: $configFile');
+ debugPrint(e.toString());
+ }
+ channel = ClientChannel(
+ hostName,
+ port: port,
+ options: const ChannelOptions(
+ credentials: ChannelCredentials.insecure(),
+ ),
+ );
+
+ debugPrint('Start Listen on port: $port');
+ stub = VALClient(channel);
+ List<String> fewSignals = VSSPath().getSignalsList();
+ var request = SubscribeRequest();
+ for (int i = 0; i < fewSignals.length; i++) {
+ var entry = SubscribeEntry();
+ entry.path = fewSignals[i];
+ entry.fields.add(Field.FIELD_PATH);
+ entry.fields.add(Field.FIELD_VALUE);
+ request.entries.add(entry);
+ // _stub.subscribe(request).listen((value) async {
+ // //debugPrint(value.toString());
+ // });
+ }
+ try {
+ // ignore: unused_local_variable
+ Map<String, String> metadata = {};
+ //var responseStream = _stub.subscribe(request);
+ stub.subscribe(request).listen((value) async {
+ for (var update in value.updates) {
+ if (!(update.hasEntry() && update.entry.hasPath())) continue;
+ handleSignalsUpdate(update);
+ }
+ }, onError: (stacktrace, errorDescriptor) {
+ debugPrint(stacktrace.toString());
+ state = const Vehicle.initialForDebug();
+
+ });
+ } catch (e) {
+ debugPrint(e.toString());
+ }
+ }
+
+ void setChildLock({required String side}) {
+ var helper = ValClientHelper(channel: channel, stub: stub);
+ try {
+ switch (side) {
+ case 'left':
+ helper.setBool(
+ VSSPath.vehicleIsChildLockActiveLeft,
+ !state.isChildLockActiveLeft,
+ false,
+ );
+ state = state.copyWith(
+ isChildLockActiveLeft: !state.isChildLockActiveLeft);
+ break;
+ case 'right':
+ helper.setBool(
+ VSSPath.vehicleIsChildLockActiveRight,
+ !state.isChildLockActiveRight,
+ false,
+ );
+ state = state.copyWith(
+ isChildLockActiveRight: !state.isChildLockActiveRight);
+ break;
+ default:
+ debugPrint("ERROR: Unexpected side value $side}");
+ break;
+ }
+ } catch (e) {
+ debugPrint(e.toString());
+ }
+ }
+
+ void updateFanSpeed(int newValue) {
+ state = state.copyWith(fanSpeed: newValue);
+ }
+
+ void setHVACMode({required String mode}) {
+ var helper = ValClientHelper(channel: channel, stub: stub);
+ try {
+ switch (mode) {
+ case 'airCondition':
+ helper.setBool(
+ VSSPath.vehicleIsAirConditioningActive,
+ !state.isAirConditioningActive,
+ false,
+ );
+ state = state.copyWith(
+ isAirConditioningActive: !state.isAirConditioningActive);
+ break;
+ case 'frontDefrost':
+ helper.setBool(
+ VSSPath.vehicleIsFrontDefrosterActive,
+ !state.isFrontDefrosterActive,
+ false,
+ );
+ state = state.copyWith(
+ isFrontDefrosterActive: !state.isFrontDefrosterActive);
+ break;
+ case 'rearDefrost':
+ helper.setBool(
+ VSSPath.vehicleIsRearDefrosterActive,
+ !state.isRearDefrosterActive,
+ false,
+ );
+ state = state.copyWith(
+ isRearDefrosterActive: !state.isRearDefrosterActive);
+ break;
+ case 'recirculation':
+ helper.setBool(
+ VSSPath.vehicleIsRecirculationActive,
+ !state.isRecirculationActive,
+ false,
+ );
+ state = state.copyWith(
+ isRecirculationActive: !state.isRecirculationActive);
+ break;
+ default:
+ debugPrint("ERROR: Unexpected mode value $mode}");
+ break;
+ }
+ } catch (e) {
+ debugPrint(e.toString());
+ }
+ }
+
+ void setInitialState() {
+ var speed = state.speed;
+ var rpm = state.engineSpeed;
+ var fuelLevel = state.fuelLevel;
+ var insideTemp = state.insideTemperature;
+ var outsideTemp = state.outsideTemperature;
+ var range = state.range;
+ var psi = state.frontLeftTire;
+ var actualSpeed = 0.0;
+ var actualRpm = 0;
+ var actualFuelLevel = 0.0;
+ var actualInsideTemp = 0.0;
+ var actualOutsideTemp = 0.0;
+ var actualRange = 0;
+ var actualPsi = 0;
+
+ state = const Vehicle.initial();
+ Timer speedTimer =
+ Timer.periodic(const Duration(milliseconds: 600), (timer) {
+ actualSpeed = actualSpeed + 10;
+
+ if (actualSpeed > speed) {
+ actualSpeed = speed;
+
+ timer.cancel();
+ }
+ state = state.copyWith(speed: actualSpeed);
+ });
+ Timer rpmTimer = Timer.periodic(const Duration(milliseconds: 400), (timer) {
+ actualRpm = actualRpm + 150;
+
+ if (actualRpm > rpm) {
+ actualRpm = rpm;
+ timer.cancel();
+ }
+ state = state.copyWith(engineSpeed: actualRpm);
+ });
+ Timer fuelLevelTimer =
+ Timer.periodic(const Duration(milliseconds: 400), (timer) {
+ actualFuelLevel = actualFuelLevel + 1;
+
+ if (actualFuelLevel > fuelLevel) {
+ actualFuelLevel = fuelLevel;
+
+ timer.cancel();
+ }
+ state = state.copyWith(fuelLevel: actualFuelLevel);
+ });
+ Timer outsideTemperatureTimer =
+ Timer.periodic(const Duration(milliseconds: 300), (timer) {
+ actualOutsideTemp = actualOutsideTemp + 0.5;
+
+ if (actualOutsideTemp > outsideTemp) {
+ actualOutsideTemp = outsideTemp;
+
+ timer.cancel();
+ }
+ state = state.copyWith(outsideTemperature: actualOutsideTemp);
+ });
+ Timer insideTemperatureTimer =
+ Timer.periodic(const Duration(milliseconds: 300), (timer) {
+ actualInsideTemp = actualInsideTemp + 0.5;
+
+ if (actualInsideTemp > insideTemp) {
+ actualInsideTemp = insideTemp;
+
+ timer.cancel();
+ }
+ state = state.copyWith(insideTemperature: actualInsideTemp);
+ });
+ Timer rangeTimer =
+ Timer.periodic(const Duration(milliseconds: 300), (timer) {
+ actualRange = actualRange + 5;
+
+ if (actualRange > range) {
+ actualRange = range;
+
+ timer.cancel();
+ }
+ state = state.copyWith(range: actualRange);
+ });
+ Timer psiTimer =
+ Timer.periodic(const Duration(milliseconds: 1200), (timer) {
+ actualPsi = actualPsi + 5;
+
+ if (actualPsi > psi) {
+ actualPsi = psi;
+
+ timer.cancel();
+ }
+ state = state.copyWith(
+ frontLeftTire: actualPsi,
+ rearLeftTire: actualPsi,
+ frontRightTire: actualPsi,
+ rearRightTire: actualPsi,
+ );
+ });
+ }
+}
diff --git a/lib/data/data_providers/vss_provider.dart b/lib/data/data_providers/vss_provider.dart
new file mode 100644
index 0000000..ca02de6
--- /dev/null
+++ b/lib/data/data_providers/vss_provider.dart
@@ -0,0 +1,105 @@
+import 'package:flutter_ics_homescreen/export.dart';
+import 'package:protos/protos.dart';
+
+class VSS {
+ static handleSignalUpdates(
+ EntryUpdate update,
+ ) {
+ //final ref = ProviderContainer().read(vehicleStateProvider);
+ switch (update.entry.path) {
+ case VSSPath.vehicleSpeed:
+ if (update.entry.value.hasFloat()) {
+ //print(ref);
+ }
+ break;
+ // case VSSPath.vehicleInsideTemperature:
+ // if (update.entry.value.hasFloat()) {
+ // ref
+ // .read(vehicleInsideTemperature.notifier)
+ // .update((state) => state = update.entry.value.float);
+ // }
+ // break;
+ // case VSSPath.vehicleOutsideTemperature:
+ // if (update.entry.value.hasFloat()) {
+ // ref
+ // .read(vehicleOutSideTemperature.notifier)
+ // .update((state) => state = update.entry.value.float);
+ // }
+ // break;
+ // case VSSPath.vehicleRange:
+ // if (update.entry.value.hasInt32()) {
+ // ref
+ // .read(vehicleRange.notifier)
+ // .update((state) => state = update.entry.value.uint32);
+ // }
+ // break;
+ // case VSSPath.vehicleFuelLevel:
+ // if (update.entry.value.hasInt32()) {
+ // ref
+ // .read(vehicleFuelLevel.notifier)
+ // .update((state) => state = update.entry.value.uint32);
+ // }
+ // break;
+ // case VSSPath.vehicleMediaVolume:
+ // if (update.entry.value.hasInt32()) {
+ // ref
+ // .read(vehicleMediaVolume.notifier)
+ // .update((state) => state = update.entry.value.uint32);
+ // }
+ // break;
+ // case VSSPath.vehicleIsChildLockActiveLeft:
+ // if (update.entry.value.hasBool_12()) {
+ // ref
+ // .read(vehicleIsChildLockActiveLeft.notifier)
+ // .update((state) => state = update.entry.value.bool_12);
+ // }
+ // break;
+ // case VSSPath.vehicleIsChildLockActiveRight:
+ // if (update.entry.value.hasBool_12()) {
+ // ref
+ // .read(vehicleIsChildLockActiveRight.notifier)
+ // .update((state) => state = update.entry.value.bool_12);
+ // }
+ // break;
+ // case VSSPath.vehicleEngineSpeed:
+ // if (update.entry.value.hasFloat()) {
+ // ref
+ // .read(vehicleEngineSpeed.notifier)
+ // .update((state) => state = update.entry.value.float);
+ // }
+ // break;
+ // case VSSPath.vehicleFrontLeftTire:
+ // if (update.entry.value.hasFloat()) {
+ // ref
+ // .read(vehicleFrontLeftTire.notifier)
+ // .update((state) => state = update.entry.value.float);
+ // }
+ // break;
+ // case VSSPath.vehicleFrontRightTire:
+ // if (update.entry.value.hasFloat()) {
+ // ref
+ // .read(vehicleFrontRightTire.notifier)
+ // .update((state) => state = update.entry.value.float);
+ // }
+ // break;
+ // case VSSPath.vehicleRearLeftTire:
+ // if (update.entry.value.hasFloat()) {
+ // ref
+ // .read(vehicleRearLeftTire.notifier)
+ // .update((state) => state = update.entry.value.float);
+ // }
+ // break;
+ // case VSSPath.vehicleRearRightTire:
+ // if (update.entry.value.hasFloat()) {
+ // ref
+ // .read(vehicleRearRightTire.notifier)
+ // .update((state) => state = update.entry.value.float);
+ // }
+ // break;
+
+ default:
+ debugPrint("ERROR: Unexpected path ${update.entry.path}");
+ break;
+ }
+ }
+}