summaryrefslogtreecommitdiffstats
path: root/lib/screen/home.dart
diff options
context:
space:
mode:
authorScott Murray <scott.murray@konsulko.com>2023-09-24 12:45:03 -0400
committerScott Murray <scott.murray@konsulko.com>2023-09-24 12:55:47 -0400
commit80a4f8d75a66c22a23e825d4c0fb4065e2e58cb8 (patch)
tree07751588fbd9f0a5cecceabe593a716f01facbac /lib/screen/home.dart
parent9bc83e64c508ad8c69a3950d5421774f9b53a31f (diff)
Rework to use KUKSA.val databroker gRPC API
Rework to move from the WebSocket API with the older KUKSA.val server to the gRPC "VAL" API of the databroker. Changes include: - All VISS WebSocket API code has been removed, and the signal providers replumbed to be driven by a new VssClient class with a dashboard-specific child class to hold all the gRPC API handling. - The generated code for the VAL API and its dependencies has been checked in under lib/generated, as there still does not seem to be a good way to generate it during the Flutter build. - The "flutter-" prefix has been dropped from the configuration file name (i.e. it's now just "cluster-dashboard.yaml") to match the naming used for the other Flutter applications. The authorization token field name has been renamed to "authorization", and there are new "use-tls" and "ca-certificate" configuration fields. TLS is disabled by default for now, and the default CA certificate is /etc/kuksa.val/CA.pem. - Bumped minimum SDK version to 2.18 in pubspec.yaml to enable "super" keyword support. This matches what the version was set to in the other applications. - The unused navigation support has been removed to simplify maintenance, as it is more likely that it will be replaced with something else in the future than fixed to be usable. - Removed .dart_tool generated output that had been checked in, and added .gitignore file from flutter-homescreen so that things will hopefully stay clean in the future. Since pubspec.lock is not checked in here, it has also been added to .gitignore. Bug-AGL: SPEC-4762 Signed-off-by: Scott Murray <scott.murray@konsulko.com> Change-Id: Id35c569cdbb8476a527717ece7b4bb369c4874b7
Diffstat (limited to 'lib/screen/home.dart')
-rw-r--r--lib/screen/home.dart128
1 files changed, 68 insertions, 60 deletions
diff --git a/lib/screen/home.dart b/lib/screen/home.dart
index 3bd47a8..f154550 100644
--- a/lib/screen/home.dart
+++ b/lib/screen/home.dart
@@ -2,29 +2,44 @@
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
-import 'package:flutter_cluster_dashboard/map/navigationHome.dart';
import 'package:flutter_cluster_dashboard/provider.dart';
-import 'package:flutter_cluster_dashboard/screen/widgets/guages/guage_props.dart';
+import 'package:flutter_cluster_dashboard/screen/widgets/gauges/gauge_props.dart';
import 'package:flutter_cluster_dashboard/screen/paints/bottombar_paint.dart';
import 'package:flutter_cluster_dashboard/screen/paints/topbar_paint.dart';
-import 'package:flutter_cluster_dashboard/screen/widgets/guages/rpm_guage_animation_wrapper.dart';
+import 'package:flutter_cluster_dashboard/screen/widgets/gauges/rpm_gauge_animation_wrapper.dart';
import 'package:flutter_cluster_dashboard/screen/widgets/left_bar.dart';
import 'package:flutter_cluster_dashboard/screen/widgets/performance_mode.dart';
import 'package:flutter_cluster_dashboard/screen/widgets/right_bar.dart';
-import 'package:flutter_cluster_dashboard/screen/widgets/guages/speed_guage_animation_wrapper.dart';
+import 'package:flutter_cluster_dashboard/screen/widgets/gauges/speed_gauge_animation_wrapper.dart';
import 'package:flutter_cluster_dashboard/screen/widgets/signals.dart';
import 'package:flutter_cluster_dashboard/screen/widgets/turn_signal.dart';
-import 'package:flutter_cluster_dashboard/vehicle_signal/vehicle_signal_provider.dart';
-import 'package:flutter_cluster_dashboard/cluster_config.dart';
+import 'package:flutter_cluster_dashboard/vehicle-signals/vss_client.dart';
+import 'package:flutter_cluster_dashboard/vehicle-signals/vss_provider.dart';
+import 'package:flutter_cluster_dashboard/vehicle-signals/vehicle_status_provider.dart';
import 'package:intl/intl.dart';
-class Home extends ConsumerWidget {
+class Home extends ConsumerStatefulWidget {
const Home({Key? key}) : super(key: key);
- GuageColors? getGuageColor(String mode) {
+
+ @override
+ _HomeState createState() => _HomeState();
+}
+
+class _HomeState extends ConsumerState<Home> {
+ late VssClient vss;
+
+ initState() {
+ vss = ref.read(vssClientProvider);
+ vss.run();
+
+ super.initState();
+ }
+
+ GaugeColors? getGaugeColor(String mode) {
return (mode == "economy")
- ? GuageProps.ecoModeColor
+ ? GaugeProps.ecoModeColor
: (mode == "sport")
- ? GuageProps.sportModeColor
+ ? GaugeProps.sportModeColor
: null;
}
@@ -46,9 +61,12 @@ class Home extends ConsumerWidget {
}
@override
- Widget build(BuildContext context, WidgetRef ref) {
- final clusterConfig = ref.read(clusterConfigStateprovider);
- final vehicle = ref.watch(vehicleSignalProvider);
+ Widget build(BuildContext context) {
+ final bool isLeftIndicator = ref.watch(vehicleStatusProvider.select((p) => p.isLeftIndicator));
+ final bool isRightIndicator = ref.watch(vehicleStatusProvider.select((p) => p.isRightIndicator));
+ final String performanceMode = ref.watch(vehicleStatusProvider.select((p) => p.performanceMode));
+ final String selectedGear = ref.watch(vehicleStatusProvider.select((p) => p.selectedGear));
+ final double ambientAirTemp = ref.watch(vehicleStatusProvider.select((p) => p.ambientAirTemp));
final clock = ref.watch(clockProvider);
final windowHeight = MediaQuery.of(context).size.height;
final windowWidth = MediaQuery.of(context).size.width;
@@ -68,7 +86,7 @@ class Home extends ConsumerWidget {
}
return Scaffold(
- backgroundColor: GuageProps.bgColor,
+ backgroundColor: GaugeProps.bgColor,
body: SafeArea(
child: Center(
child: Center(
@@ -87,8 +105,8 @@ class Home extends ConsumerWidget {
children: [
TurnSignal(
screenHeight: screenHeight,
- isLefton: vehicle.isLeftIndicator,
- isRighton: vehicle.isRightIndicator,
+ isLefton: isLeftIndicator,
+ isRighton: isRightIndicator,
),
Flex(
direction: Axis.horizontal,
@@ -128,7 +146,7 @@ class Home extends ConsumerWidget {
SizedBox(
width: (30 * screenHeight) / 480),
Text(
- "${vehicle.ambientAirTemp} ${"\u00B0"}C",
+ "${ambientAirTemp} ${"\u00B0"}C",
style: TextStyle(
color: const Color.fromARGB(
255, 184, 183, 183),
@@ -216,7 +234,7 @@ class Home extends ConsumerWidget {
child: PerformanceMode(
size: Size((90 * screenHeight) / 480,
(20 * screenHeight) / 480),
- mode: vehicle.performanceMode),
+ mode: performanceMode),
),
// logo
Flexible(
@@ -224,25 +242,18 @@ class Home extends ConsumerWidget {
fit: FlexFit.tight,
child: SizedBox(
width: (330 * screenHeight) / 720,
- child: (clusterConfig
- .enableNavigation &&
- vehicle.isSteeringInfo)
- ? const NavigationHome()
- : Padding(
- padding: EdgeInsets.symmetric(
- vertical:
- (36.0 * screenHeight) /
- 720,
- horizontal:
- (48.0 * screenHeight) /
- 720),
- child: Image.asset(
- "images/logo_agl.png",
- width:
- (90 * screenHeight) / 480,
- color: Colors.grey.shade600,
- ),
- ),
+ child: Padding(
+ padding: EdgeInsets.symmetric(
+ vertical:
+ (36.0 * screenHeight) / 720,
+ horizontal:
+ (48.0 * screenHeight) / 720),
+ child: Image.asset(
+ "images/logo_agl.png",
+ width: (90 * screenHeight) / 480,
+ color: Colors.grey.shade600,
+ ),
+ ),
),
),
const Flexible(
@@ -265,14 +276,11 @@ class Home extends ConsumerWidget {
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
- Signals(
- screenHeight: screenHeight,
- vehicle: vehicle,
- ),
+ Signals(screenHeight: screenHeight),
],
),
),
- // guages
+ // gauges
Padding(
padding: EdgeInsets.fromLTRB(
calcPadding(70, screenHeight),
@@ -283,17 +291,17 @@ class Home extends ConsumerWidget {
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
- // Speed Guage
+ // Speed Gauge
SpeedGauge(
screenHeight: screenHeight,
- guageColor:
- getGuageColor(vehicle.performanceMode),
+ gaugeColor:
+ getGaugeColor(performanceMode),
),
- //RPM Guage
+ //RPM Gauge
RPMGauge(
screenHeight: screenHeight,
- guageColor:
- getGuageColor(vehicle.performanceMode),
+ gaugeColor:
+ getGaugeColor(performanceMode),
),
],
),
@@ -314,33 +322,33 @@ class Home extends ConsumerWidget {
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
- (vehicle.selectedGear == Gear.parking)
+ (selectedGear == Gear.parking)
? Text("P",
- style: GuageProps.activeGearIconStyle(
+ style: GaugeProps.activeGearIconStyle(
screenHeight))
: Text("P",
- style: GuageProps.gearIconStyle(
+ style: GaugeProps.gearIconStyle(
screenHeight)),
- (vehicle.selectedGear == Gear.reverse)
+ (selectedGear == Gear.reverse)
? Text("R",
- style: GuageProps.activeGearIconStyle(
+ style: GaugeProps.activeGearIconStyle(
screenHeight))
: Text("R",
- style: GuageProps.gearIconStyle(
+ style: GaugeProps.gearIconStyle(
screenHeight)),
- (vehicle.selectedGear == Gear.neutral)
+ (selectedGear == Gear.neutral)
? Text("N",
- style: GuageProps.activeGearIconStyle(
+ style: GaugeProps.activeGearIconStyle(
screenHeight))
: Text("N",
- style: GuageProps.gearIconStyle(
+ style: GaugeProps.gearIconStyle(
screenHeight)),
- (vehicle.selectedGear == Gear.drive)
+ (selectedGear == Gear.drive)
? Text("D",
- style: GuageProps.activeGearIconStyle(
+ style: GaugeProps.activeGearIconStyle(
screenHeight))
: Text("D",
- style: GuageProps.gearIconStyle(
+ style: GaugeProps.gearIconStyle(
screenHeight)),
]),
),