summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/HomePage.dart82
-rw-r--r--lib/Kuksa-server/vehicle_class.dart75
-rw-r--r--lib/Kuksa-server/vehicle_methods.dart190
-rw-r--r--lib/Kuksa-server/vehicle_provider.dart64
-rw-r--r--lib/Tire_pressure.dart103
-rw-r--r--lib/config.dart2
-rw-r--r--lib/main.dart4
-rw-r--r--lib/size.dart1
-rw-r--r--lib/vehicle-signals/intial_connection.dart (renamed from lib/Kuksa-server/intial_connection.dart)2
-rw-r--r--lib/vehicle-signals/onBoarding_page.dart (renamed from lib/Kuksa-server/onBoarding_page.dart)4
-rw-r--r--lib/vehicle-signals/vehicle_config.dart (renamed from lib/Kuksa-server/vehicle_config.dart)0
-rw-r--r--lib/vehicle-signals/vehicle_methods.dart183
-rw-r--r--lib/vehicle-signals/vehicle_server_path.dart (renamed from lib/Kuksa-server/vehicle_server_path.dart)26
-rw-r--r--lib/vehicle-signals/vss_providers.dart402
-rw-r--r--lib/widgets/child_lock.dart26
-rw-r--r--lib/widgets/fuel_and_speed.dart44
-rw-r--r--lib/widgets/weather.dart29
17 files changed, 766 insertions, 471 deletions
diff --git a/lib/HomePage.dart b/lib/HomePage.dart
index 532a1a1..accf7c1 100644
--- a/lib/HomePage.dart
+++ b/lib/HomePage.dart
@@ -6,21 +6,30 @@ import 'package:dashboard_app/widgets/fuel_and_speed.dart';
import 'package:dashboard_app/widgets/weather.dart';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
+import 'vehicle-signals/vss_providers.dart';
-import 'Kuksa-server/vehicle_provider.dart';
+class FuelRateText extends ConsumerWidget {
+ final TextStyle style;
-class HomePage extends ConsumerStatefulWidget {
- const HomePage({Key? key}) : super(key: key);
+ FuelRateText({Key? key, required this.style}) : super(key: key);
@override
- _HomePageState createState() => _HomePageState();
+ Widget build(BuildContext context, WidgetRef ref) {
+ final vehicleFuelRate = ref.watch(vehicleSignalFuelRateProvider);
+
+ return Text(
+ vehicleFuelRate.rate.toString() + ' km/Litre',
+ style: style,
+ );
+ }
}
-class _HomePageState extends ConsumerState<HomePage> {
+class HomePage extends StatelessWidget {
+ const HomePage({Key? key}) : super(key: key);
+
@override
Widget build(BuildContext context) {
SizeConfig().init(context);
- final vehicle = ref.watch(vehicleSignalProvider);
return Scaffold(
backgroundColor: Colors.black,
@@ -50,18 +59,8 @@ class _HomePageState extends ConsumerState<HomePage> {
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
- Flexible(
- flex: 1,
- child: weather(
- insideTemperatue: vehicle.insideTemperature,
- outsideTempearure: vehicle.outsideTemperature,
- ),
- ),
- Flexible(
- flex: 2,
- child: SpeedAndFuel(
- fuel: vehicle.fuelLevel, speed: vehicle.speed),
- ),
+ Flexible(flex: 1, child: Weather()),
+ Flexible(flex: 2, child: SpeedAndFuel()),
],
),
),
@@ -76,25 +75,11 @@ class _HomePageState extends ConsumerState<HomePage> {
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Container(height: SizeConfig.safeBlockVertical * 6),
- TirePressure(
- tname: 'Left Front',
- tpress: vehicle.frontLeftTP,
- mainAxisAlignment: MainAxisAlignment.end,
- crossAxisAlignment: CrossAxisAlignment.end,
- ),
+ FrontLeftTirePressure(),
Spacer(),
- ChildLockStatus(
- isChildLockActiveLeft:
- vehicle.isChildLockActiveLeft,
- isChildLockActiveRight:
- vehicle.isChildLockActiveRight),
+ ChildLockStatus(),
Spacer(),
- TirePressure(
- tname: 'Left Rear',
- tpress: vehicle.rearLeftTP,
- mainAxisAlignment: MainAxisAlignment.start,
- crossAxisAlignment: CrossAxisAlignment.end,
- ),
+ RearLeftTirePressure(),
Container(
height: SizeConfig.safeBlockVertical * 10),
],
@@ -107,25 +92,11 @@ class _HomePageState extends ConsumerState<HomePage> {
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Container(height: SizeConfig.safeBlockVertical * 6),
- TirePressure(
- tname: 'Right Front',
- tpress: vehicle.frontRightTP,
- mainAxisAlignment: MainAxisAlignment.end,
- crossAxisAlignment: CrossAxisAlignment.start,
- ),
+ FrontRightTirePressure(),
Spacer(),
- ChildLockStatus(
- isChildLockActiveLeft:
- vehicle.isChildLockActiveLeft,
- isChildLockActiveRight:
- vehicle.isChildLockActiveRight),
+ ChildLockStatus(),
Spacer(),
- TirePressure(
- tname: 'Right Rear',
- tpress: vehicle.rearRightTP,
- mainAxisAlignment: MainAxisAlignment.start,
- crossAxisAlignment: CrossAxisAlignment.start,
- ),
+ RearRightTirePressure(),
Container(
height: SizeConfig.safeBlockVertical * 10),
],
@@ -150,14 +121,11 @@ class _HomePageState extends ConsumerState<HomePage> {
'Fuel Consumption',
style: SizeConfig.smallnormalfont2,
),
- Text(
- vehicle.fuelRate.toString() + ' km/Litre',
- style: SizeConfig.smallnormalfont,
- ),
+ FuelRateText(style: SizeConfig.smallnormalfont),
],
),
),
- Flexible(flex: 1, child: Rpm(rpm: vehicle.rpm)),
+ Flexible(flex: 1, child: Rpm()),
],
),
),
diff --git a/lib/Kuksa-server/vehicle_class.dart b/lib/Kuksa-server/vehicle_class.dart
deleted file mode 100644
index c2f2ac2..0000000
--- a/lib/Kuksa-server/vehicle_class.dart
+++ /dev/null
@@ -1,75 +0,0 @@
-// SPDX-License-Identifier: Apache-2.0
-class VehicleSignal {
- VehicleSignal({
- required this.speed,
- required this.rpm,
- required this.fuelLevel,
- required this.frontLeftTP,
- required this.frontRightTP,
- required this.rearLeftTP,
- required this.rearRightTP,
- required this.isBatteryCharging,
- required this.isChildLockActiveLeft,
- required this.isChildLockActiveRight,
- required this.currentLatitude,
- required this.currentLongitude,
- required this.fuelRate,
- required this.insideTemperature,
- required this.outsideTemperature,
- });
-
- final double speed;
- final double rpm;
- final double fuelLevel;
- final double frontLeftTP;
- final double frontRightTP;
- final double rearLeftTP;
- final double rearRightTP;
- final bool isChildLockActiveLeft;
- final bool isChildLockActiveRight;
- final double currentLongitude;
- final double currentLatitude;
- final double fuelRate;
- final int insideTemperature;
- final int outsideTemperature;
-
- final bool isBatteryCharging;
-
- VehicleSignal copyWith({
- double? speed,
- double? rpm,
- double? fuelLevel,
- double? frontLeftTP,
- double? frontRightTP,
- double? rearLeftTP,
- double? rearRightTP,
- bool? isBatteryCharging,
- bool? isChildLockActiveLeft,
- bool? isChildLockActiveRight,
- double? currentLongitude,
- double? currentLatitude,
- double? fuelRate,
- int? insideTemperature,
- int? outsideTemperature,
- }) {
- return VehicleSignal(
- speed: speed ?? this.speed,
- rpm: rpm ?? this.rpm,
- fuelLevel: fuelLevel ?? this.fuelLevel,
- frontLeftTP: frontLeftTP ?? this.frontLeftTP,
- frontRightTP: frontRightTP ?? this.frontRightTP,
- rearLeftTP: rearLeftTP ?? this.rearLeftTP,
- rearRightTP: rearRightTP ?? this.rearRightTP,
- isChildLockActiveLeft:
- isChildLockActiveLeft ?? this.isChildLockActiveLeft,
- isChildLockActiveRight:
- isChildLockActiveRight ?? this.isChildLockActiveRight,
- isBatteryCharging: isBatteryCharging ?? this.isBatteryCharging,
- currentLatitude: currentLatitude ?? this.currentLatitude,
- currentLongitude: currentLongitude ?? this.currentLongitude,
- fuelRate: fuelRate ?? this.fuelRate,
- insideTemperature: insideTemperature ?? this.insideTemperature,
- outsideTemperature: outsideTemperature ?? this.outsideTemperature,
- );
- }
-}
diff --git a/lib/Kuksa-server/vehicle_methods.dart b/lib/Kuksa-server/vehicle_methods.dart
deleted file mode 100644
index 1a99bc7..0000000
--- a/lib/Kuksa-server/vehicle_methods.dart
+++ /dev/null
@@ -1,190 +0,0 @@
-// SPDX-License-Identifier: Apache-2.0
-import 'dart:convert';
-import 'dart:io';
-
-import 'package:dashboard_app/Kuksa-server/vehicle_provider.dart';
-import 'package:dashboard_app/Kuksa-server/vehicle_server_path.dart';
-import 'package:dashboard_app/config.dart';
-import 'package:flutter_riverpod/flutter_riverpod.dart';
-
-class VISS {
- static const requestId = "test-id";
- static void init(WebSocket socket, WidgetRef ref) {
- authorize(socket,ref);
- subscribe(socket,ref, VSPath.vehicleSpeed);
- subscribe(socket,ref, VSPath.vehicleEngineRPM);
- subscribe(socket,ref, VSPath.vehicleFuelLevel);
- subscribe(socket,ref, VSPath.vehicleFrontLeftTire);
- subscribe(socket, ref,VSPath.vehicleFrontRightTire);
- subscribe(socket, ref,VSPath.vehicleRearLeftTire);
- subscribe(socket,ref, VSPath.vehicleRearRightTire);
- subscribe(socket, ref,VSPath.vehicleIsChildLockActiveLeft);
- subscribe(socket,ref, VSPath.vehicleIsChildLockActiveRight);
- subscribe(socket,ref, VSPath.vehicleCurrentLatitude);
- subscribe(socket,ref, VSPath.vehicleCurrentLongitude);
- subscribe(socket,ref, VSPath.vehicleFuelRate);
- subscribe(socket,ref, VSPath.vehicleInsideTemperature);
- subscribe(socket, ref,VSPath.vehicleAmbientAirTemperature);
- }
-
- static void update(WebSocket socket, WidgetRef ref) {
- get(socket,ref, VSPath.vehicleSpeed);
- get(socket,ref, VSPath.vehicleEngineRPM);
- get(socket,ref, VSPath.vehicleFuelLevel);
- get(socket,ref,VSPath.vehicleAmbientAirTemperature);
- get(socket,ref,VSPath.vehicleFrontLeftTire);
- get(socket,ref, VSPath.vehicleFrontRightTire);
- get(socket,ref, VSPath.vehicleRearLeftTire);
- get(socket,ref, VSPath.vehicleRearRightTire);
- get(socket,ref,VSPath.vehicleIsChildLockActiveLeft);
- get(socket,ref, VSPath.vehicleIsChildLockActiveRight);
- get(socket,ref,VSPath.vehicleCurrentLatitude);
- get(socket,ref,VSPath.vehicleCurrentLongitude);
- get(socket,ref,VSPath.vehicleFuelRate);
- get(socket,ref, VSPath.vehicleInsideTemperature);
- }
-
- static void authorize(WebSocket socket,WidgetRef ref) {
- final config = ref.read(ConfigStateprovider);
-
- Map<String, dynamic> map = {
- "action": "authorize",
- "tokens": config.kuksaAuthToken,
- "requestId": requestId
- };
- socket.add(jsonEncode(map));
- }
-
- static void get(WebSocket socket,WidgetRef ref, String path) {
- final config = ref.read(ConfigStateprovider);
-
- Map<String, dynamic> map = {
- "action": "get",
- "tokens": config.kuksaAuthToken,
- "path": path,
- "requestId": requestId
- };
- socket.add(jsonEncode(map));
- }
-
- static void set(WebSocket socket, WidgetRef ref,String path, String value) {
- final config = ref.read(ConfigStateprovider);
- Map<String, dynamic> map = {
- "action": "set",
- "tokens": config.kuksaAuthToken,
- "path": path,
- "requestId": requestId,
- "value": value
- };
- socket.add(jsonEncode(map));
- }
-
- static void subscribe(WebSocket socket,WidgetRef ref, String path) {
- final config = ref.read(ConfigStateprovider);
-
- Map<String, dynamic> map = {
- "action": "subscribe",
- "tokens": config.kuksaAuthToken,
- "path": path,
- "requestId": requestId
- };
- socket.add(jsonEncode(map));
- }
-
- static String? numToGear(int? number) {
- switch (number) {
- case -1:
- return 'R';
- case 0:
- return 'N';
- case 126:
- return 'P';
- case 127:
- return 'D';
- default:
- return null;
- }
- }
-
- static void parseData(WidgetRef ref, String data) {
- final vehicleSignal = ref.read(vehicleSignalProvider.notifier);
- Map<String, dynamic> dataMap = jsonDecode(data);
- if (dataMap["action"] == "subscription" || dataMap["action"] == "get") {
- if (dataMap.containsKey("data")) {
- if ((dataMap["data"] as Map<String, dynamic>).containsKey("dp") &&
- (dataMap["data"] as Map<String, dynamic>).containsKey("path")) {
- String path = dataMap["data"]["path"];
- Map<String, dynamic> dp = dataMap["data"]["dp"];
- if (dp.containsKey("value")) {
- if (dp["value"] != "---") {
- switch (path) {
- case VSPath.vehicleSpeed:
- vehicleSignal.update(speed: dp["value"]);
- break;
- case VSPath.vehicleEngineRPM:
- vehicleSignal.update(rpm: dp["value"].toDouble());
- break;
- case VSPath.vehicleFuelLevel:
- vehicleSignal.update(fuelLevel: dp["value"]);
- break;
- case VSPath.vehicleFrontLeftTire:
- vehicleSignal.update(frontLeftTP: dp["value"]);
- break;
- case VSPath.vehicleFrontRightTire:
- vehicleSignal.update(frontRightTP: dp["value"]);
- break;
- case VSPath.vehicleRearLeftTire:
- vehicleSignal.update(rearLeftTP: dp["value"]);
- break;
- case VSPath.vehicleRearRightTire:
- vehicleSignal.update(rearRightTP: dp["value"]);
- break;
-
-
- case VSPath.vehicleIsChildLockActiveLeft:
- vehicleSignal.update(isChildLockActiveLeft: dp['value']);
- break;
- case VSPath.vehicleIsChildLockActiveRight:
- vehicleSignal.update(isChildLockActiveRight: dp['value']);
- break;
- case VSPath.vehicleCurrentLatitude:
- vehicleSignal.update(
- currentLatitude: dp["value"]);
- break;
- case VSPath.vehicleCurrentLongitude:
- vehicleSignal.update(
- currentLongitude: dp["value"]);
- break;
- case VSPath.vehicleFuelRate:
- vehicleSignal.update(fuelRate: dp["value"]);
- break;
- case VSPath.vehicleInsideTemperature:
- vehicleSignal.update(
- insideTemperature: int.parse(dp["value"]));
- break;
- case VSPath.vehicleAmbientAirTemperature:
- vehicleSignal.update(
- outsideTemperature: int.parse(dp["value"]));
- break;
- default:
- print("$path Not Available yet!");
- }
- } else {
- print("ERROR:Value not available yet! Set Value of $path");
- }
- } else {
- print("ERROR:'value': Key not found!");
- }
- } else if ((!dataMap["data"] as Map<String, dynamic>)
- .containsKey("path")) {
- print("ERROR:'path':key not found !");
- } else if ((dataMap["data"] as Map<String, dynamic>)
- .containsKey("dp")) {
- print("ERROR:'dp':key not found !");
- }
- } else {
- print("ERROR:'data':key not found!");
- }
- }
- }
-}
diff --git a/lib/Kuksa-server/vehicle_provider.dart b/lib/Kuksa-server/vehicle_provider.dart
deleted file mode 100644
index e7b67df..0000000
--- a/lib/Kuksa-server/vehicle_provider.dart
+++ /dev/null
@@ -1,64 +0,0 @@
-// SPDX-License-Identifier: Apache-2.0
-import 'package:dashboard_app/Kuksa-server/vehicle_class.dart';
-import 'package:flutter_riverpod/flutter_riverpod.dart';
-
-final vehicleSignalProvider =
- StateNotifierProvider<VehicleSignalNotifier, VehicleSignal>(
- (ref) => VehicleSignalNotifier(),
-);
-
-class VehicleSignalNotifier extends StateNotifier<VehicleSignal> {
- VehicleSignalNotifier() : super(_initialValue);
- static final VehicleSignal _initialValue = VehicleSignal(
- speed: 140,
- rpm: 7000,
- fuelLevel: 90,
- frontRightTP: 32,
- frontLeftTP: 32,
- rearRightTP: 33,
- rearLeftTP: 34,
- isChildLockActiveLeft: true,
- isChildLockActiveRight: true,
- isBatteryCharging: true,
- currentLatitude: 37.772701,
- currentLongitude: -122.416626,
- fuelRate: 21,
- insideTemperature: 25,
- outsideTemperature: 32,
- );
- void update({
- double? speed,
- double? rpm,
- double? fuelLevel,
- double? frontLeftTP,
- double? frontRightTP,
- double? rearLeftTP,
- double? rearRightTP,
- bool? isBatteryCharging,
- bool? isChildLockActiveLeft,
- bool? isChildLockActiveRight,
- double? currentLatitude,
- double? currentLongitude,
- double? fuelRate,
- int? insideTemperature,
- int? outsideTemperature,
- }) {
- state = state.copyWith(
- speed: speed,
- rpm: rpm,
- fuelLevel: fuelLevel,
- frontLeftTP: frontLeftTP,
- frontRightTP: frontRightTP,
- rearLeftTP: rearLeftTP,
- rearRightTP: rearRightTP,
- isChildLockActiveLeft: isChildLockActiveLeft,
- isChildLockActiveRight: isChildLockActiveRight,
- isBatteryCharging: isBatteryCharging,
- currentLatitude: currentLatitude,
- currentLongitude: currentLongitude,
- fuelRate: fuelRate,
- insideTemperature: insideTemperature,
- outsideTemperature: outsideTemperature,
- );
- }
-}
diff --git a/lib/Tire_pressure.dart b/lib/Tire_pressure.dart
index 2f68bf3..f3a8e73 100644
--- a/lib/Tire_pressure.dart
+++ b/lib/Tire_pressure.dart
@@ -1,55 +1,48 @@
// SPDX-License-Identifier: Apache-2.0
-import 'package:dashboard_app/size.dart';
import 'package:flutter/material.dart';
import 'package:percent_indicator/linear_percent_indicator.dart';
+import 'package:flutter_riverpod/flutter_riverpod.dart';
+import 'package:dashboard_app/size.dart';
+import '../vehicle-signals/vss_providers.dart';
-
-
-class TirePressure extends StatefulWidget {
- String tname;
- double tpress;
+class TirePressure extends StatelessWidget {
+ String tireName;
+ double tirePressure;
CrossAxisAlignment crossAxisAlignment;
MainAxisAlignment mainAxisAlignment;
+
TirePressure(
{Key? key,
- required this.tname,
- required this.tpress,
+ required this.tireName,
+ required this.tirePressure,
required this.crossAxisAlignment,
required this.mainAxisAlignment})
: super(key: key);
@override
- State<TirePressure> createState() => _TirePressureState();
-}
-
-class _TirePressureState extends State<TirePressure> {
- @override
Widget build(BuildContext context) {
return SizedBox(
height: SizeConfig.safeBlockVertical * 12,
width: SizeConfig.safeBlockHorizontal * 14,
child: Column(
- mainAxisAlignment: widget.mainAxisAlignment,
-
+ mainAxisAlignment: mainAxisAlignment,
children: [
Text(
- '${widget.tname}',
+ '${tireName}',
style: SizeConfig.smallnormalfont2,
),
Text(
- widget.tpress.toString() + ' PSI',
+ tirePressure.toString() + ' PSI',
style: SizeConfig.smallnormalfont,
),
LinearPercentIndicator(
width: SizeConfig.safeBlockHorizontal * 11,
-
- progressColor: widget.tpress / 50 > 0.6 ? Colors.green : Colors.red,
+ progressColor: tirePressure / 50 > 0.6 ? Colors.green : Colors.red,
lineHeight: SizeConfig.safeBlockVertical * 1.5,
alignment: MainAxisAlignment.center,
animateFromLastPercent: true,
animation: true,
- percent: widget.tpress / 50,
-
+ percent: tirePressure / 50,
barRadius: Radius.circular(SizeConfig.fontsize / 4),
backgroundColor: Colors.grey,
),
@@ -58,3 +51,71 @@ class _TirePressureState extends State<TirePressure> {
);
}
}
+
+class FrontLeftTirePressure extends ConsumerWidget {
+ FrontLeftTirePressure({Key? key}) : super(key: key);
+
+ @override
+ Widget build(BuildContext context, WidgetRef ref) {
+ final vehicleFrontLeftTP =
+ ref.watch(vehicleSignalFrontLeftTirePressureProvider);
+
+ return TirePressure(
+ tireName: 'Left Front',
+ tirePressure: vehicleFrontLeftTP.pressure,
+ mainAxisAlignment: MainAxisAlignment.end,
+ crossAxisAlignment: CrossAxisAlignment.end,
+ );
+ }
+}
+
+class RearLeftTirePressure extends ConsumerWidget {
+ RearLeftTirePressure({Key? key}) : super(key: key);
+
+ @override
+ Widget build(BuildContext context, WidgetRef ref) {
+ final vehicleRearLeftTP =
+ ref.watch(vehicleSignalRearLeftTirePressureProvider);
+
+ return TirePressure(
+ tireName: 'Left Rear',
+ tirePressure: vehicleRearLeftTP.pressure,
+ mainAxisAlignment: MainAxisAlignment.start,
+ crossAxisAlignment: CrossAxisAlignment.end,
+ );
+ }
+}
+
+class FrontRightTirePressure extends ConsumerWidget {
+ FrontRightTirePressure({Key? key}) : super(key: key);
+
+ @override
+ Widget build(BuildContext context, WidgetRef ref) {
+ final vehicleFrontRightTP =
+ ref.watch(vehicleSignalFrontRightTirePressureProvider);
+
+ return TirePressure(
+ tireName: 'Right Front',
+ tirePressure: vehicleFrontRightTP.pressure,
+ mainAxisAlignment: MainAxisAlignment.end,
+ crossAxisAlignment: CrossAxisAlignment.start,
+ );
+ }
+}
+
+class RearRightTirePressure extends ConsumerWidget {
+ RearRightTirePressure({Key? key}) : super(key: key);
+
+ @override
+ Widget build(BuildContext context, WidgetRef ref) {
+ final vehicleRearRightTP =
+ ref.watch(vehicleSignalRearRightTirePressureProvider);
+
+ return TirePressure(
+ tireName: 'Right Rear',
+ tirePressure: vehicleRearRightTP.pressure,
+ mainAxisAlignment: MainAxisAlignment.start,
+ crossAxisAlignment: CrossAxisAlignment.start,
+ );
+ }
+}
diff --git a/lib/config.dart b/lib/config.dart
index 963f798..817d46f 100644
--- a/lib/config.dart
+++ b/lib/config.dart
@@ -4,7 +4,7 @@ import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:yaml/yaml.dart';
-import 'Kuksa-server/intial_connection.dart';
+import 'vehicle-signals/intial_connection.dart';
class GetConfig extends ConsumerStatefulWidget {
const GetConfig({Key? key, required this.client}) : super(key: key);
diff --git a/lib/main.dart b/lib/main.dart
index 27ba557..163d16c 100644
--- a/lib/main.dart
+++ b/lib/main.dart
@@ -5,8 +5,8 @@ import 'dart:io';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
-import 'Kuksa-server/intial_connection.dart';
-import 'Kuksa-server/vehicle_config.dart';
+import 'vehicle-signals/intial_connection.dart';
+import 'vehicle-signals/vehicle_config.dart';
import 'config.dart';
Future<void> main() async {
diff --git a/lib/size.dart b/lib/size.dart
index 2bcbcd9..d849ba8 100644
--- a/lib/size.dart
+++ b/lib/size.dart
@@ -1,6 +1,5 @@
// SPDX-License-Identifier: Apache-2.0
import 'package:flutter/material.dart';
-import 'package:flutter/widgets.dart';
class SizeConfig {
static late MediaQueryData _mediaQueryData;
diff --git a/lib/Kuksa-server/intial_connection.dart b/lib/vehicle-signals/intial_connection.dart
index dfac031..8e79979 100644
--- a/lib/Kuksa-server/intial_connection.dart
+++ b/lib/vehicle-signals/intial_connection.dart
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: Apache-2.0
import 'dart:io';
-import 'package:dashboard_app/Kuksa-server/vehicle_config.dart';
+import 'package:dashboard_app/vehicle-signals/vehicle_config.dart';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
diff --git a/lib/Kuksa-server/onBoarding_page.dart b/lib/vehicle-signals/onBoarding_page.dart
index 264c7a0..6009c54 100644
--- a/lib/Kuksa-server/onBoarding_page.dart
+++ b/lib/vehicle-signals/onBoarding_page.dart
@@ -2,8 +2,8 @@
import 'dart:async';
import 'dart:io';
-import 'package:dashboard_app/Kuksa-server/vehicle_config.dart';
-import 'package:dashboard_app/Kuksa-server/vehicle_methods.dart';
+import 'package:dashboard_app/vehicle-signals/vehicle_config.dart';
+import 'package:dashboard_app/vehicle-signals/vehicle_methods.dart';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
diff --git a/lib/Kuksa-server/vehicle_config.dart b/lib/vehicle-signals/vehicle_config.dart
index 59682c4..59682c4 100644
--- a/lib/Kuksa-server/vehicle_config.dart
+++ b/lib/vehicle-signals/vehicle_config.dart
diff --git a/lib/vehicle-signals/vehicle_methods.dart b/lib/vehicle-signals/vehicle_methods.dart
new file mode 100644
index 0000000..8259450
--- /dev/null
+++ b/lib/vehicle-signals/vehicle_methods.dart
@@ -0,0 +1,183 @@
+// SPDX-License-Identifier: Apache-2.0
+import 'dart:convert';
+import 'dart:io';
+
+import 'package:dashboard_app/vehicle-signals/vss_providers.dart';
+import 'package:dashboard_app/vehicle-signals/vehicle_server_path.dart';
+import 'package:dashboard_app/config.dart';
+import 'package:flutter_riverpod/flutter_riverpod.dart';
+
+class VISS {
+ static const requestId = "test-id";
+ static void init(WebSocket socket, WidgetRef ref) {
+ authorize(socket, ref);
+ subscribe(socket, ref, VSSPath.vehicleSpeed);
+ subscribe(socket, ref, VSSPath.vehicleEngineSpeed);
+ subscribe(socket, ref, VSSPath.vehicleFuelLevel);
+ subscribe(socket, ref, VSSPath.vehicleFrontLeftTire);
+ subscribe(socket, ref, VSSPath.vehicleFrontRightTire);
+ subscribe(socket, ref, VSSPath.vehicleRearLeftTire);
+ subscribe(socket, ref, VSSPath.vehicleRearRightTire);
+ subscribe(socket, ref, VSSPath.vehicleIsChildLockActiveLeft);
+ subscribe(socket, ref, VSSPath.vehicleIsChildLockActiveRight);
+ subscribe(socket, ref, VSSPath.vehicleFuelRate);
+ subscribe(socket, ref, VSSPath.vehicleInsideTemperature);
+ subscribe(socket, ref, VSSPath.vehicleOutsideTemperature);
+ }
+
+ static void update(WebSocket socket, WidgetRef ref) {
+ get(socket, ref, VSSPath.vehicleSpeed);
+ get(socket, ref, VSSPath.vehicleEngineSpeed);
+ get(socket, ref, VSSPath.vehicleFuelLevel);
+ get(socket, ref, VSSPath.vehicleOutsideTemperature);
+ get(socket, ref, VSSPath.vehicleFrontLeftTire);
+ get(socket, ref, VSSPath.vehicleFrontRightTire);
+ get(socket, ref, VSSPath.vehicleRearLeftTire);
+ get(socket, ref, VSSPath.vehicleRearRightTire);
+ get(socket, ref, VSSPath.vehicleIsChildLockActiveLeft);
+ get(socket, ref, VSSPath.vehicleIsChildLockActiveRight);
+ get(socket, ref, VSSPath.vehicleFuelRate);
+ get(socket, ref, VSSPath.vehicleInsideTemperature);
+ }
+
+ static void authorize(WebSocket socket, WidgetRef ref) {
+ final config = ref.read(ConfigStateprovider);
+
+ Map<String, dynamic> map = {
+ "action": "authorize",
+ "tokens": config.kuksaAuthToken,
+ "requestId": requestId
+ };
+ socket.add(jsonEncode(map));
+ }
+
+ static void get(WebSocket socket, WidgetRef ref, String path) {
+ final config = ref.read(ConfigStateprovider);
+
+ Map<String, dynamic> map = {
+ "action": "get",
+ "tokens": config.kuksaAuthToken,
+ "path": path,
+ "requestId": requestId
+ };
+ socket.add(jsonEncode(map));
+ }
+
+ static void set(WebSocket socket, WidgetRef ref, String path, String value) {
+ final config = ref.read(ConfigStateprovider);
+ Map<String, dynamic> map = {
+ "action": "set",
+ "tokens": config.kuksaAuthToken,
+ "path": path,
+ "requestId": requestId,
+ "value": value
+ };
+ socket.add(jsonEncode(map));
+ }
+
+ static void subscribe(WebSocket socket, WidgetRef ref, String path) {
+ final config = ref.read(ConfigStateprovider);
+
+ Map<String, dynamic> map = {
+ "action": "subscribe",
+ "tokens": config.kuksaAuthToken,
+ "path": path,
+ "requestId": requestId
+ };
+ socket.add(jsonEncode(map));
+ }
+
+ static void parseData(WidgetRef ref, String data) {
+ Map<String, dynamic> dataMap = jsonDecode(data);
+ if (dataMap["action"] == "subscription" || dataMap["action"] == "get") {
+ if (dataMap.containsKey("data")) {
+ if ((dataMap["data"] as Map<String, dynamic>).containsKey("dp") &&
+ (dataMap["data"] as Map<String, dynamic>).containsKey("path")) {
+ String path = dataMap["data"]["path"];
+ Map<String, dynamic> dp = dataMap["data"]["dp"];
+ if (dp.containsKey("value")) {
+ if (dp["value"] != "---") {
+ switch (path) {
+ case VSSPath.vehicleSpeed:
+ ref
+ .read(vehicleSignalSpeedProvider.notifier)
+ .update(speed: dp["value"]);
+ break;
+ case VSSPath.vehicleEngineSpeed:
+ ref
+ .read(vehicleSignalEngineSpeedProvider.notifier)
+ .update(speed: dp["value"].toDouble());
+ break;
+ case VSSPath.vehicleFuelLevel:
+ ref
+ .read(vehicleSignalFuelLevelProvider.notifier)
+ .update(level: dp["value"]);
+ break;
+ case VSSPath.vehicleFuelRate:
+ ref
+ .read(vehicleSignalFuelRateProvider.notifier)
+ .update(rate: dp["value"]);
+ break;
+ case VSSPath.vehicleFrontLeftTire:
+ ref
+ .read(vehicleSignalFrontLeftTirePressureProvider.notifier)
+ .update(pressure: dp["value"]);
+ break;
+ case VSSPath.vehicleFrontRightTire:
+ ref
+ .read(
+ vehicleSignalFrontRightTirePressureProvider.notifier)
+ .update(pressure: dp["value"]);
+ break;
+ case VSSPath.vehicleRearLeftTire:
+ ref
+ .read(vehicleSignalRearLeftTirePressureProvider.notifier)
+ .update(pressure: dp["value"]);
+ break;
+ case VSSPath.vehicleRearRightTire:
+ ref
+ .read(vehicleSignalRearRightTirePressureProvider.notifier)
+ .update(pressure: dp["value"]);
+ break;
+ case VSSPath.vehicleIsChildLockActiveLeft:
+ ref
+ .read(vehicleSignalLeftChildLockActiveProvider.notifier)
+ .update(engaged: dp["value"]);
+ break;
+ case VSSPath.vehicleIsChildLockActiveRight:
+ ref
+ .read(vehicleSignalRightChildLockActiveProvider.notifier)
+ .update(engaged: dp["value"]);
+ break;
+ case VSSPath.vehicleInsideTemperature:
+ ref
+ .read(vehicleSignalInsideTempProvider.notifier)
+ .update(temp: dp["value"]);
+ break;
+ case VSSPath.vehicleOutsideTemperature:
+ ref
+ .read(vehicleSignalOutsideTempProvider.notifier)
+ .update(temp: dp["value"]);
+ break;
+ default:
+ print("$path Not Available yet!");
+ }
+ } else {
+ print("ERROR:Value not available yet! Set Value of $path");
+ }
+ } else {
+ print("ERROR:'value': Key not found!");
+ }
+ } else if ((!dataMap["data"] as Map<String, dynamic>)
+ .containsKey("path")) {
+ print("ERROR:'path':key not found !");
+ } else if ((dataMap["data"] as Map<String, dynamic>)
+ .containsKey("dp")) {
+ print("ERROR:'dp':key not found !");
+ }
+ } else {
+ print("ERROR:'data':key not found!");
+ }
+ }
+ }
+}
diff --git a/lib/Kuksa-server/vehicle_server_path.dart b/lib/vehicle-signals/vehicle_server_path.dart
index 8d8923c..822e304 100644
--- a/lib/Kuksa-server/vehicle_server_path.dart
+++ b/lib/vehicle-signals/vehicle_server_path.dart
@@ -1,34 +1,44 @@
// SPDX-License-Identifier: Apache-2.0
-class VSPath {
+class VSSPath {
static const String vehicleSpeed = "Vehicle.Speed";
- static const String vehicleEngineRPM =
- "Vehicle.Powertrain.CombustionEngine.Speed";
- static const String vehicleFuelLevel = "Vehicle.Powertrain.FuelSystem.Level";
+ static const String vehicleEngineSpeed =
+ "Vehicle.Powertrain.CombustionEngine.Speed";
+ static const String vehicleFuelLevel = "Vehicle.Powertrain.FuelSystem.Level";
+ static const String vehicleInsideTemperature =
+ "Vehicle.Cabin.HVAC.AmbientAirTemperature";
- static const String vehicleAmbientAirTemperature =
- "Vehicle.AmbientAirTemperature";
+ static const String vehicleOutsideTemperature =
+ "Vehicle.Exterior.AirTemperature";
static const String vehicleFrontLeftTire =
"Vehicle.Chassis.Axle.Row1.Wheel.Left.Tire.Pressure";
+
static const String vehicleFrontRightTire =
"Vehicle.Chassis.Axle.Row1.Wheel.Right.Tire.Pressure";
+
static const String vehicleRearLeftTire =
"Vehicle.Chassis.Axle.Row2.Wheel.Left.Tire.Pressure";
static const String vehicleRearRightTire =
"Vehicle.Chassis.Axle.Row2.Wheel.Right.Tire.Pressure";
+
static const String vehicleIsChildLockActiveLeft =
"Vehicle.Cabin.Door.Row2.Left.IsChildLockActive";
+
static const String vehicleIsChildLockActiveRight =
"Vehicle.Cabin.Door.Row2.Right.IsChildLockActive";
+
static const String vehicleCurrentLongitude =
"Vehicle.CurrentLocation.Longitude";
+
static const String vehicleCurrentLatitude =
"Vehicle.CurrentLocation.Latitude";
+
static const String vehicleFuelRate = "Vehicle.OBD.FuelRate";
- static const String vehicleInsideTemperature =
- "Vehicle.Cabin.HVAC.AmbientAirTemperature";
+
+ static const String vehicleMediaVolume =
+ "Vehicle.Cabin.Infotainment.Media.Volume";
}
diff --git a/lib/vehicle-signals/vss_providers.dart b/lib/vehicle-signals/vss_providers.dart
new file mode 100644
index 0000000..6900bdc
--- /dev/null
+++ b/lib/vehicle-signals/vss_providers.dart
@@ -0,0 +1,402 @@
+// SPDX-License-Identifier: Apache-2.0
+//import 'dart:ffi';
+//import 'dart:io';
+import 'package:meta/meta.dart';
+import 'package:flutter_riverpod/flutter_riverpod.dart';
+
+// Vehicle Speed
+
+@immutable
+class VehicleSignalSpeed {
+ const VehicleSignalSpeed({required this.speed});
+
+ final double speed;
+
+ VehicleSignalSpeed copyWith({double? speed}) {
+ return VehicleSignalSpeed(speed: speed ?? this.speed);
+ }
+}
+
+class VehicleSignalSpeedNotifier extends StateNotifier<VehicleSignalSpeed> {
+ VehicleSignalSpeedNotifier() : super(_initialValue);
+
+ static final VehicleSignalSpeed _initialValue = VehicleSignalSpeed(speed: 60);
+
+ void update({double? speed}) {
+ state = state.copyWith(speed: speed);
+ }
+}
+
+final vehicleSignalSpeedProvider =
+ StateNotifierProvider<VehicleSignalSpeedNotifier, VehicleSignalSpeed>(
+ (ref) => VehicleSignalSpeedNotifier(),
+);
+
+// Engine Speed
+
+@immutable
+class VehicleSignalEngineSpeed {
+ const VehicleSignalEngineSpeed({required this.speed});
+
+ final double speed;
+
+ VehicleSignalEngineSpeed copyWith({double? speed}) {
+ return VehicleSignalEngineSpeed(speed: speed ?? this.speed);
+ }
+}
+
+class VehicleSignalEngineSpeedNotifier
+ extends StateNotifier<VehicleSignalEngineSpeed> {
+ VehicleSignalEngineSpeedNotifier() : super(_initialValue);
+
+ static final VehicleSignalEngineSpeed _initialValue =
+ VehicleSignalEngineSpeed(speed: 2000);
+
+ void update({double? speed}) {
+ state = state.copyWith(speed: speed);
+ }
+}
+
+final vehicleSignalEngineSpeedProvider = StateNotifierProvider<
+ VehicleSignalEngineSpeedNotifier, VehicleSignalEngineSpeed>(
+ (ref) => VehicleSignalEngineSpeedNotifier(),
+);
+
+// Fuel Level
+
+@immutable
+class VehicleSignalFuelLevel {
+ const VehicleSignalFuelLevel({required this.level});
+
+ final double level;
+
+ VehicleSignalFuelLevel copyWith({double? level}) {
+ return VehicleSignalFuelLevel(level: level ?? this.level);
+ }
+}
+
+class VehicleSignalFuelLevelNotifier
+ extends StateNotifier<VehicleSignalFuelLevel> {
+ VehicleSignalFuelLevelNotifier() : super(_initialValue);
+
+ static final VehicleSignalFuelLevel _initialValue =
+ VehicleSignalFuelLevel(level: 90);
+
+ void update({double? level}) {
+ state = state.copyWith(level: level);
+ }
+}
+
+final vehicleSignalFuelLevelProvider = StateNotifierProvider<
+ VehicleSignalFuelLevelNotifier, VehicleSignalFuelLevel>(
+ (ref) => VehicleSignalFuelLevelNotifier(),
+);
+
+// Fuel Rate
+
+@immutable
+class VehicleSignalFuelRate {
+ const VehicleSignalFuelRate({required this.rate});
+
+ final double rate;
+
+ VehicleSignalFuelRate copyWith({double? rate}) {
+ return VehicleSignalFuelRate(rate: rate ?? this.rate);
+ }
+}
+
+class VehicleSignalFuelRateNotifier
+ extends StateNotifier<VehicleSignalFuelRate> {
+ VehicleSignalFuelRateNotifier() : super(_initialValue);
+
+ static final VehicleSignalFuelRate _initialValue =
+ VehicleSignalFuelRate(rate: 21);
+
+ void update({double? rate}) {
+ state = state.copyWith(rate: rate);
+ }
+}
+
+final vehicleSignalFuelRateProvider =
+ StateNotifierProvider<VehicleSignalFuelRateNotifier, VehicleSignalFuelRate>(
+ (ref) => VehicleSignalFuelRateNotifier(),
+);
+
+// Front Left Tire Pressure
+
+@immutable
+class VehicleSignalFrontLeftTirePressure {
+ const VehicleSignalFrontLeftTirePressure({required this.pressure});
+
+ final double pressure;
+
+ VehicleSignalFrontLeftTirePressure copyWith({double? pressure}) {
+ return VehicleSignalFrontLeftTirePressure(
+ pressure: pressure ?? this.pressure);
+ }
+}
+
+class VehicleSignalFrontLeftTirePressureNotifier
+ extends StateNotifier<VehicleSignalFrontLeftTirePressure> {
+ VehicleSignalFrontLeftTirePressureNotifier() : super(_initialValue);
+
+ static final VehicleSignalFrontLeftTirePressure _initialValue =
+ VehicleSignalFrontLeftTirePressure(pressure: 32);
+
+ void update({double? pressure}) {
+ state = state.copyWith(pressure: pressure);
+ }
+}
+
+final vehicleSignalFrontLeftTirePressureProvider = StateNotifierProvider<
+ VehicleSignalFrontLeftTirePressureNotifier,
+ VehicleSignalFrontLeftTirePressure>(
+ (ref) => VehicleSignalFrontLeftTirePressureNotifier(),
+);
+
+// Front Right Tire Pressure
+
+@immutable
+class VehicleSignalFrontRightTirePressure {
+ const VehicleSignalFrontRightTirePressure({required this.pressure});
+
+ final double pressure;
+
+ VehicleSignalFrontRightTirePressure copyWith({double? pressure}) {
+ return VehicleSignalFrontRightTirePressure(
+ pressure: pressure ?? this.pressure);
+ }
+}
+
+class VehicleSignalFrontRightTirePressureNotifier
+ extends StateNotifier<VehicleSignalFrontRightTirePressure> {
+ VehicleSignalFrontRightTirePressureNotifier() : super(_initialValue);
+
+ static final VehicleSignalFrontRightTirePressure _initialValue =
+ VehicleSignalFrontRightTirePressure(pressure: 32);
+
+ void update({double? pressure}) {
+ state = state.copyWith(pressure: pressure);
+ }
+}
+
+final vehicleSignalFrontRightTirePressureProvider = StateNotifierProvider<
+ VehicleSignalFrontRightTirePressureNotifier,
+ VehicleSignalFrontRightTirePressure>(
+ (ref) => VehicleSignalFrontRightTirePressureNotifier(),
+);
+
+// Rear Left Tire Pressure
+
+@immutable
+class VehicleSignalRearLeftTirePressure {
+ const VehicleSignalRearLeftTirePressure({required this.pressure});
+
+ final double pressure;
+
+ VehicleSignalRearLeftTirePressure copyWith({double? pressure}) {
+ return VehicleSignalRearLeftTirePressure(
+ pressure: pressure ?? this.pressure);
+ }
+}
+
+class VehicleSignalRearLeftTirePressureNotifier
+ extends StateNotifier<VehicleSignalRearLeftTirePressure> {
+ VehicleSignalRearLeftTirePressureNotifier() : super(_initialValue);
+
+ static final VehicleSignalRearLeftTirePressure _initialValue =
+ VehicleSignalRearLeftTirePressure(pressure: 33);
+
+ void update({double? pressure}) {
+ state = state.copyWith(pressure: pressure);
+ }
+}
+
+final vehicleSignalRearLeftTirePressureProvider = StateNotifierProvider<
+ VehicleSignalRearLeftTirePressureNotifier,
+ VehicleSignalRearLeftTirePressure>(
+ (ref) => VehicleSignalRearLeftTirePressureNotifier(),
+);
+
+// Rear Right Tire Pressure
+
+@immutable
+class VehicleSignalRearRightTirePressure {
+ const VehicleSignalRearRightTirePressure({required this.pressure});
+
+ final double pressure;
+
+ VehicleSignalRearRightTirePressure copyWith({double? pressure}) {
+ return VehicleSignalRearRightTirePressure(
+ pressure: pressure ?? this.pressure);
+ }
+}
+
+class VehicleSignalRearRightTirePressureNotifier
+ extends StateNotifier<VehicleSignalRearRightTirePressure> {
+ VehicleSignalRearRightTirePressureNotifier() : super(_initialValue);
+
+ static final VehicleSignalRearRightTirePressure _initialValue =
+ VehicleSignalRearRightTirePressure(pressure: 34);
+
+ void update({double? pressure}) {
+ state = state.copyWith(pressure: pressure);
+ }
+}
+
+final vehicleSignalRearRightTirePressureProvider = StateNotifierProvider<
+ VehicleSignalRearRightTirePressureNotifier,
+ VehicleSignalRearRightTirePressure>(
+ (ref) => VehicleSignalRearRightTirePressureNotifier(),
+);
+
+// Left Child Lock Active
+
+@immutable
+class VehicleSignalLeftChildLockActive {
+ const VehicleSignalLeftChildLockActive({required this.engaged});
+
+ final bool engaged;
+
+ VehicleSignalLeftChildLockActive copyWith({bool? engaged}) {
+ return VehicleSignalLeftChildLockActive(engaged: engaged ?? this.engaged);
+ }
+}
+
+class VehicleSignalLeftChildLockActiveNotifier
+ extends StateNotifier<VehicleSignalLeftChildLockActive> {
+ VehicleSignalLeftChildLockActiveNotifier() : super(_initialValue);
+
+ static final VehicleSignalLeftChildLockActive _initialValue =
+ VehicleSignalLeftChildLockActive(engaged: true);
+
+ void update({bool? engaged}) {
+ state = state.copyWith(engaged: engaged);
+ }
+}
+
+final vehicleSignalLeftChildLockActiveProvider = StateNotifierProvider<
+ VehicleSignalLeftChildLockActiveNotifier, VehicleSignalLeftChildLockActive>(
+ (ref) => VehicleSignalLeftChildLockActiveNotifier(),
+);
+
+// Right Child Lock Active
+
+@immutable
+class VehicleSignalRightChildLockActive {
+ const VehicleSignalRightChildLockActive({required this.engaged});
+
+ final bool engaged;
+
+ VehicleSignalRightChildLockActive copyWith({bool? engaged}) {
+ return VehicleSignalRightChildLockActive(engaged: engaged ?? this.engaged);
+ }
+}
+
+class VehicleSignalRightChildLockActiveNotifier
+ extends StateNotifier<VehicleSignalRightChildLockActive> {
+ VehicleSignalRightChildLockActiveNotifier() : super(_initialValue);
+
+ static final VehicleSignalRightChildLockActive _initialValue =
+ VehicleSignalRightChildLockActive(engaged: true);
+
+ void update({bool? engaged}) {
+ state = state.copyWith(engaged: engaged);
+ }
+}
+
+final vehicleSignalRightChildLockActiveProvider = StateNotifierProvider<
+ VehicleSignalRightChildLockActiveNotifier,
+ VehicleSignalRightChildLockActive>(
+ (ref) => VehicleSignalRightChildLockActiveNotifier(),
+);
+
+// Battery Charging
+
+@immutable
+class VehicleSignalBatteryCharging {
+ const VehicleSignalBatteryCharging({required this.charging});
+
+ final bool charging;
+
+ VehicleSignalBatteryCharging copyWith({bool? charging}) {
+ return VehicleSignalBatteryCharging(charging: charging ?? this.charging);
+ }
+}
+
+class VehicleSignalBatteryChargingNotifier
+ extends StateNotifier<VehicleSignalBatteryCharging> {
+ VehicleSignalBatteryChargingNotifier() : super(_initialValue);
+
+ static final VehicleSignalBatteryCharging _initialValue =
+ VehicleSignalBatteryCharging(charging: true);
+
+ void update({bool? charging}) {
+ state = state.copyWith(charging: charging);
+ }
+}
+
+final vehicleSignalBatteryChargingProvider = StateNotifierProvider<
+ VehicleSignalBatteryChargingNotifier, VehicleSignalBatteryCharging>(
+ (ref) => VehicleSignalBatteryChargingNotifier(),
+);
+
+// Inside Temperature
+
+@immutable
+class VehicleSignalInsideTemp {
+ const VehicleSignalInsideTemp({required this.temp});
+
+ final double temp;
+
+ VehicleSignalInsideTemp copyWith({double? temp}) {
+ return VehicleSignalInsideTemp(temp: temp ?? this.temp);
+ }
+}
+
+class VehicleSignalInsideTempNotifier
+ extends StateNotifier<VehicleSignalInsideTemp> {
+ VehicleSignalInsideTempNotifier() : super(_initialValue);
+
+ static final VehicleSignalInsideTemp _initialValue =
+ VehicleSignalInsideTemp(temp: 25);
+
+ void update({double? temp}) {
+ state = state.copyWith(temp: temp);
+ }
+}
+
+final vehicleSignalInsideTempProvider = StateNotifierProvider<
+ VehicleSignalInsideTempNotifier, VehicleSignalInsideTemp>(
+ (ref) => VehicleSignalInsideTempNotifier(),
+);
+
+// Outside Temperature
+
+@immutable
+class VehicleSignalOutsideTemp {
+ const VehicleSignalOutsideTemp({required this.temp});
+
+ final double temp;
+
+ VehicleSignalOutsideTemp copyWith({double? temp}) {
+ return VehicleSignalOutsideTemp(temp: temp ?? this.temp);
+ }
+}
+
+class VehicleSignalOutsideTempNotifier
+ extends StateNotifier<VehicleSignalOutsideTemp> {
+ VehicleSignalOutsideTempNotifier() : super(_initialValue);
+
+ static final VehicleSignalOutsideTemp _initialValue =
+ VehicleSignalOutsideTemp(temp: 32);
+
+ void update({double? temp}) {
+ state = state.copyWith(temp: temp);
+ }
+}
+
+final vehicleSignalOutsideTempProvider = StateNotifierProvider<
+ VehicleSignalOutsideTempNotifier, VehicleSignalOutsideTemp>(
+ (ref) => VehicleSignalOutsideTempNotifier(),
+);
diff --git a/lib/widgets/child_lock.dart b/lib/widgets/child_lock.dart
index c2efb0d..0de2350 100644
--- a/lib/widgets/child_lock.dart
+++ b/lib/widgets/child_lock.dart
@@ -1,21 +1,21 @@
// SPDX-License-Identifier: Apache-2.0
-import 'package:dashboard_app/size.dart';
-import 'package:flutter/src/foundation/key.dart';
-import 'package:flutter/src/widgets/framework.dart';
import 'package:flutter/material.dart';
+import 'package:flutter_riverpod/flutter_riverpod.dart';
+import 'package:dashboard_app/size.dart';
+import '../vehicle-signals/vss_providers.dart';
-class ChildLockStatus extends StatelessWidget {
- bool isChildLockActiveLeft;
- bool isChildLockActiveRight;
- ChildLockStatus(
- {Key? key,
- required this.isChildLockActiveLeft,
- required this.isChildLockActiveRight})
- : super(key: key);
+class ChildLockStatus extends ConsumerWidget {
+ ChildLockStatus({Key? key}) : super(key: key);
@override
- Widget build(BuildContext context) {
- return isChildLockActiveLeft && isChildLockActiveRight
+ Widget build(BuildContext context, WidgetRef ref) {
+ final vehicleLeftChildLockActive =
+ ref.watch(vehicleSignalLeftChildLockActiveProvider);
+ final vehicleRightChildLockActive =
+ ref.watch(vehicleSignalRightChildLockActiveProvider);
+
+ return vehicleLeftChildLockActive.engaged &&
+ vehicleRightChildLockActive.engaged
? Column(
children: [
Text(
diff --git a/lib/widgets/fuel_and_speed.dart b/lib/widgets/fuel_and_speed.dart
index d5dd902..4e898e4 100644
--- a/lib/widgets/fuel_and_speed.dart
+++ b/lib/widgets/fuel_and_speed.dart
@@ -1,19 +1,18 @@
// SPDX-License-Identifier: Apache-2.0
-import 'package:dashboard_app/size.dart';
-import 'package:flutter/src/foundation/key.dart';
-import 'package:flutter/src/widgets/framework.dart';
import 'package:flutter/material.dart';
import 'package:percent_indicator/circular_percent_indicator.dart';
import 'package:percent_indicator/linear_percent_indicator.dart';
+import 'package:flutter_riverpod/flutter_riverpod.dart';
+import 'package:dashboard_app/size.dart';
+import '../vehicle-signals/vss_providers.dart';
-class SpeedAndFuel extends StatelessWidget {
- double fuel;
- double speed;
- SpeedAndFuel({Key? key, required this.fuel, required this.speed})
- : super(key: key);
+class SpeedAndFuel extends ConsumerWidget {
+ SpeedAndFuel({Key? key}) : super(key: key);
@override
- Widget build(BuildContext context) {
+ Widget build(BuildContext context, WidgetRef ref) {
+ final vehicleSpeed = ref.watch(vehicleSignalSpeedProvider);
+ final vehicleFuelLevel = ref.watch(vehicleSignalFuelLevelProvider);
double width = MediaQuery.of(context).size.width;
return SizedBox(
width: width * 0.4,
@@ -22,7 +21,7 @@ class SpeedAndFuel extends StatelessWidget {
children: [
CircularPercentIndicator(
radius: SizeConfig.fontsize * 1.6,
- percent: speed / 300,
+ percent: vehicleSpeed.speed / 300,
lineWidth: SizeConfig.fontsize / 2,
backgroundColor: Color.fromARGB(255, 176, 213, 195),
progressColor: Colors.lightBlueAccent,
@@ -30,7 +29,7 @@ class SpeedAndFuel extends StatelessWidget {
circularStrokeCap: CircularStrokeCap.round,
animateFromLastPercent: true,
center: Text(
- speed.toInt().toString(),
+ vehicleSpeed.speed.toInt().toString(),
style: SizeConfig.smallnormalfont,
),
footer: Text(
@@ -40,19 +39,19 @@ class SpeedAndFuel extends StatelessWidget {
),
CircularPercentIndicator(
radius: SizeConfig.fontsize * 1.6,
- percent: fuel / 100,
+ percent: vehicleFuelLevel.level / 100,
lineWidth: SizeConfig.fontsize / 2,
backgroundColor: Colors.lightBlue.shade100,
- progressColor: fuel < 25
+ progressColor: vehicleFuelLevel.level < 25
? Colors.redAccent
- : fuel < 50
+ : vehicleFuelLevel.level < 50
? Colors.orange
: Colors.green,
animation: true,
circularStrokeCap: CircularStrokeCap.round,
animateFromLastPercent: true,
center: Text(
- fuel.toInt().toString() + ' %',
+ vehicleFuelLevel.level.toInt().toString() + ' %',
style: SizeConfig.smallnormalfont,
),
footer: Text(
@@ -66,12 +65,13 @@ class SpeedAndFuel extends StatelessWidget {
}
}
-class Rpm extends StatelessWidget {
- double rpm;
- Rpm({Key? key, required this.rpm}) : super(key: key);
+class Rpm extends ConsumerWidget {
+ Rpm({Key? key}) : super(key: key);
@override
- Widget build(BuildContext context) {
+ Widget build(BuildContext context, WidgetRef ref) {
+ final vehicleEngineSpeed = ref.watch(vehicleSignalEngineSpeedProvider);
+
return SizedBox(
height: SizeConfig.safeBlockVertical * 9,
width: SizeConfig.safeBlockHorizontal * 35,
@@ -90,14 +90,16 @@ class Rpm extends StatelessWidget {
animateFromLastPercent: true,
animation: true,
animationDuration: 500,
- percent: rpm > 9000 ? 9000 : rpm / 9000,
+ percent: vehicleEngineSpeed.speed > 9000
+ ? 9000
+ : vehicleEngineSpeed.speed / 9000,
barRadius: Radius.circular(15),
leading: Text(
'RPM',
style: SizeConfig.smallnormalfont,
),
trailing: Text(
- rpm.toInt().toString(),
+ vehicleEngineSpeed.speed.toInt().toString(),
style: SizeConfig.smallnormalfont2,
),
),
diff --git a/lib/widgets/weather.dart b/lib/widgets/weather.dart
index 0a593cc..73b7014 100644
--- a/lib/widgets/weather.dart
+++ b/lib/widgets/weather.dart
@@ -1,21 +1,17 @@
// SPDX-License-Identifier: Apache-2.0
-import 'package:dashboard_app/size.dart';
-import 'package:flutter/src/foundation/key.dart';
-import 'package:flutter/src/widgets/framework.dart';
-
import 'package:flutter/material.dart';
+import 'package:flutter_riverpod/flutter_riverpod.dart';
+import 'package:dashboard_app/size.dart';
+import '../vehicle-signals/vss_providers.dart';
-class weather extends StatelessWidget {
- int insideTemperatue;
- int outsideTempearure;
- weather(
- {Key? key,
- required this.insideTemperatue,
- required this.outsideTempearure})
- : super(key: key);
+class Weather extends ConsumerWidget {
+ Weather({Key? key}) : super(key: key);
@override
- Widget build(BuildContext context) {
+ Widget build(BuildContext context, WidgetRef ref) {
+ final vehicleInsideTemp = ref.watch(vehicleSignalInsideTempProvider);
+ final vehicleOutsideTemp = ref.watch(vehicleSignalOutsideTempProvider);
+
return Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(SizeConfig.safeBlockVertical * 2),
@@ -60,7 +56,9 @@ class weather extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text('Inside', style: SizeConfig.smallnormalfont2),
- Text(insideTemperatue.toString() + ' \u00B0',
+ Text(
+ vehicleInsideTemp.temp.toInt().toString() +
+ ' \u00B0',
style: SizeConfig.normalfont),
],
),
@@ -75,7 +73,8 @@ class weather extends StatelessWidget {
style: SizeConfig.smallnormalfont2,
),
Text(
- outsideTempearure.toString() + ' \u00B0',
+ vehicleOutsideTemp.temp.toInt().toString() +
+ ' \u00B0',
style: SizeConfig.normalfont,
),
],