summaryrefslogtreecommitdiffstats
path: root/lib/Buttons
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Buttons')
-rw-r--r--lib/Buttons/AC.dart27
-rw-r--r--lib/Buttons/ac_on_face.dart60
-rw-r--r--lib/Buttons/ac_on_foot.dart61
-rw-r--r--lib/Buttons/auto.dart15
-rw-r--r--lib/Buttons/defrost_recirculate.dart85
-rw-r--r--lib/Buttons/fresh_air.dart11
6 files changed, 106 insertions, 153 deletions
diff --git a/lib/Buttons/AC.dart b/lib/Buttons/AC.dart
index e0c610a..f07bf1d 100644
--- a/lib/Buttons/AC.dart
+++ b/lib/Buttons/AC.dart
@@ -4,19 +4,14 @@ import 'dart:io';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
-import 'package:flutter_hvac/kuksa-server/vehicle-provider.dart';
-import 'package:flutter_hvac/kuksa-server/vehicle_methods.dart';
+import 'package:flutter_hvac/vehicle-signals/vehicle_ac_status_provider.dart';
+import 'package:flutter_hvac/vehicle-signals/vss_provider.dart';
+import 'package:flutter_hvac/vehicle-signals/vss_path.dart';
import '../size.dart';
class AC extends ConsumerStatefulWidget {
- WebSocket socket;
- String serverPath;
- AC({
- Key? key,
- required this.serverPath,
- required this.socket,
- }) : super(key: key);
+ AC({Key? key}) : super(key: key);
@override
_ACState createState() => _ACState();
@@ -45,11 +40,10 @@ class _ACState extends ConsumerState<AC> with SingleTickerProviderStateMixin {
});
_controller.addStatusListener((status) {
- if (status == AnimationStatus.completed) {
- VISS.set(widget.socket, ref,widget.serverPath, isAcActive.toString());
- }
- if (status == AnimationStatus.dismissed) {
- VISS.set(widget.socket, ref,widget.serverPath, isAcActive.toString());
+ if (status == AnimationStatus.completed || status == AnimationStatus.dismissed) {
+ var vss = ref.read(vssClientProvider);
+ if (vss != null)
+ vss.setBool(VSSPath.vehicleIsAirConditioningActive, isAcActive, true);
}
});
}
@@ -63,7 +57,8 @@ class _ACState extends ConsumerState<AC> with SingleTickerProviderStateMixin {
@override
Widget build(BuildContext context) {
- isAcActive = ref.watch(vehicleProvider).isAcActive;
+ isAcActive = ref.watch(vehicleAcStatusProvider.select((p) => p.isAcActive));
+
return AnimatedBuilder(
animation: _controller,
builder: (BuildContext context, _) {
@@ -114,7 +109,7 @@ class _ACState extends ConsumerState<AC> with SingleTickerProviderStateMixin {
onTap: () {
isAcActive ? _controller.reverse() : _controller.forward();
ref
- .read(vehicleProvider.notifier)
+ .read(vehicleAcStatusProvider.notifier)
.update(isAcActive: !isAcActive);
},
);
diff --git a/lib/Buttons/ac_on_face.dart b/lib/Buttons/ac_on_face.dart
index f0c0f41..9d8ded3 100644
--- a/lib/Buttons/ac_on_face.dart
+++ b/lib/Buttons/ac_on_face.dart
@@ -5,19 +5,18 @@ import 'dart:io';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:flutter_svg_provider/flutter_svg_provider.dart';
-import 'package:flutter_hvac/kuksa-server/vehicle-provider.dart';
+import 'package:flutter_hvac/vehicle-signals/vehicle_ac_status_provider.dart';
+import 'package:flutter_hvac/vehicle-signals/vss_provider.dart';
+import 'package:flutter_hvac/vehicle-signals/vss_path.dart';
-import '../kuksa-server/vehicle-class.dart';
-import '../kuksa-server/vehicle_methods.dart';
import '../size.dart';
class AcOnFace extends ConsumerStatefulWidget {
final String img;
- WebSocket socket;
+
AcOnFace({
Key? key,
required this.img,
- required this.socket,
}) : super(key: key);
@override
@@ -45,26 +44,20 @@ class _AcOnFaceState extends ConsumerState<AcOnFace>
_controller.addListener(() {});
_controller.addStatusListener((status) {
+ String direction = "";
if (status == AnimationStatus.completed) {
- VISS.set(widget.socket,ref,
- "Vehicle.Cabin.HVAC.Station.Row1.Left.AirDistribution", 'up');
- VISS.set(widget.socket,ref,
- "Vehicle.Cabin.HVAC.Station.Row1.Right.AirDistribution", 'up');
- VISS.set(widget.socket,ref,
- "Vehicle.Cabin.HVAC.Station.Row2.Left.AirDistribution", 'up');
- VISS.set(widget.socket,ref,
- "Vehicle.Cabin.HVAC.Station.Row2.Right.AirDistribution", 'up');
+ direction = "MIDDLE";
+ } else if (status == AnimationStatus.dismissed) {
+ direction = "DOWN";
}
-
- if (status == AnimationStatus.dismissed) {
- VISS.set(widget.socket,ref,
- "Vehicle.Cabin.HVAC.Station.Row1.Left.AirDistribution", 'middle');
- VISS.set(widget.socket,ref,
- "Vehicle.Cabin.HVAC.Station.Row1.Right.AirDistribution", 'middle');
- VISS.set(widget.socket,ref,
- "Vehicle.Cabin.HVAC.Station.Row2.Left.AirDistribution", 'middle');
- VISS.set(widget.socket,ref,
- "Vehicle.Cabin.HVAC.Station.Row2.Right.AirDistribution", 'middle');
+ if (direction.isNotEmpty) {
+ var vss = ref.read(vssClientProvider);
+ if (vss != null) {
+ vss.setString(VSSPath.vehicleFrontLeftAirDistribution, direction, true);
+ vss.setString(VSSPath.vehicleFrontRightAirDistribution, direction, true);
+ vss.setString(VSSPath.vehicleRearLeftAirDistribution, direction, true);
+ vss.setString(VSSPath.vehicleRearRightAirDistribution, direction, true);
+ }
}
});
}
@@ -78,8 +71,9 @@ class _AcOnFaceState extends ConsumerState<AcOnFace>
@override
Widget build(BuildContext context) {
- vehicle vehicledata = ref.watch(vehicleProvider);
- if (vehicledata.isAcDirectionUp == false) {
+ bool isAcDirectionUp = ref.watch(vehicleAcStatusProvider.select((p) => p.isAcDirectionUp));
+ bool isAcDirectionDown = ref.watch(vehicleAcStatusProvider.select((p) => p.isAcDirectionDown));
+ if (isAcDirectionUp == false) {
_controller.reverse();
}
@@ -95,7 +89,7 @@ class _AcOnFaceState extends ConsumerState<AcOnFace>
decoration: BoxDecoration(
- gradient: vehicledata.isAcDirectionUp
+ gradient: isAcDirectionUp
? RadialGradient(
colors: [Colors.black, Colors.lightBlue],
radius: 2,
@@ -122,18 +116,16 @@ class _AcOnFaceState extends ConsumerState<AcOnFace>
),
),
onTap: () {
- if (vehicledata.isAcDirectionDown) {
+ if (isAcDirectionDown) {
ref
- .watch(vehicleProvider.notifier)
- .update(isAcDirectionDown: !vehicledata.isAcDirectionDown);
+ .watch(vehicleAcStatusProvider.notifier)
+ .update(isAcDirectionDown: !isAcDirectionDown);
}
Future.delayed(Duration(milliseconds: 500),(){
- vehicledata.isAcDirectionUp
- ? _controller.reverse()
- : _controller.forward();
+ isAcDirectionUp ? _controller.reverse() : _controller.forward();
- ref.watch(vehicleProvider.notifier).update(
- isAcDirectionUp: !vehicledata.isAcDirectionUp,
+ ref.watch(vehicleAcStatusProvider.notifier).update(
+ isAcDirectionUp: !isAcDirectionUp,
);
});
diff --git a/lib/Buttons/ac_on_foot.dart b/lib/Buttons/ac_on_foot.dart
index 41e2569..d1f2180 100644
--- a/lib/Buttons/ac_on_foot.dart
+++ b/lib/Buttons/ac_on_foot.dart
@@ -5,19 +5,18 @@ import 'dart:io';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:flutter_svg_provider/flutter_svg_provider.dart';
-import 'package:flutter_hvac/kuksa-server/vehicle-provider.dart';
+import 'package:flutter_hvac/vehicle-signals/vehicle_ac_status_provider.dart';
+import 'package:flutter_hvac/vehicle-signals/vss_provider.dart';
+import 'package:flutter_hvac/vehicle-signals/vss_path.dart';
-import '../kuksa-server/vehicle-class.dart';
-import '../kuksa-server/vehicle_methods.dart';
import '../size.dart';
class AcOnFoot extends ConsumerStatefulWidget {
final String img;
- WebSocket socket;
+
AcOnFoot({
Key? key,
required this.img,
- required this.socket,
}) : super(key: key);
@override
@@ -45,27 +44,20 @@ class _AcOnFootState extends ConsumerState<AcOnFoot>
_controller.addListener(() {});
_controller.addStatusListener((status) {
+ String direction = "";
if (status == AnimationStatus.completed) {
- VISS.set(widget.socket,ref,
- "Vehicle.Cabin.HVAC.Station.Row1.Left.AirDistribution", 'down');
- VISS.set(widget.socket,ref,
- "Vehicle.Cabin.HVAC.Station.Row1.Right.AirDistribution", 'down');
- VISS.set(widget.socket,ref,
- "Vehicle.Cabin.HVAC.Station.Row2.Left.AirDistribution", 'down');
- VISS.set(widget.socket,ref,
- "Vehicle.Cabin.HVAC.Station.Row2.Right.AirDistribution", 'down');
-
+ direction = "DOWN";
+ } else if (status == AnimationStatus.dismissed) {
+ direction = "MIDDLE";
}
-
- if (status == AnimationStatus.dismissed) {
- VISS.set(widget.socket,ref,
- "Vehicle.Cabin.HVAC.Station.Row1.Left.AirDistribution", 'middle');
- VISS.set(widget.socket,ref,
- "Vehicle.Cabin.HVAC.Station.Row1.Right.AirDistribution", 'middle');
- VISS.set(widget.socket,ref,
- "Vehicle.Cabin.HVAC.Station.Row2.Left.AirDistribution", 'middle');
- VISS.set(widget.socket,ref,
- "Vehicle.Cabin.HVAC.Station.Row2.Right.AirDistribution", 'middle');
+ if (direction.isNotEmpty) {
+ var vss = ref.read(vssClientProvider);
+ if (vss != null) {
+ vss.setString(VSSPath.vehicleFrontLeftAirDistribution, direction, true);
+ vss.setString(VSSPath.vehicleFrontRightAirDistribution, direction, true);
+ vss.setString(VSSPath.vehicleRearLeftAirDistribution, direction, true);
+ vss.setString(VSSPath.vehicleRearRightAirDistribution, direction, true);
+ }
}
});
}
@@ -79,8 +71,9 @@ class _AcOnFootState extends ConsumerState<AcOnFoot>
@override
Widget build(BuildContext context) {
- vehicle vehicledata = ref.watch(vehicleProvider);
- if (vehicledata.isAcDirectionDown == false) {
+ bool isAcDirectionUp = ref.watch(vehicleAcStatusProvider.select((p) => p.isAcDirectionUp));
+ bool isAcDirectionDown = ref.watch(vehicleAcStatusProvider.select((p) => p.isAcDirectionDown));
+ if (isAcDirectionDown == false) {
_controller.reverse();
}
@@ -96,7 +89,7 @@ class _AcOnFootState extends ConsumerState<AcOnFoot>
decoration: BoxDecoration(
- gradient: vehicledata.isAcDirectionDown
+ gradient: isAcDirectionDown
? RadialGradient(
colors: [Colors.black, Colors.lightBlue],
radius: 2,
@@ -123,18 +116,16 @@ class _AcOnFootState extends ConsumerState<AcOnFoot>
),
),
onTap: () {
- if (vehicledata.isAcDirectionUp == true) {
+ if (isAcDirectionUp == true) {
ref
- .watch(vehicleProvider.notifier)
- .update(isAcDirectionUp: !vehicledata.isAcDirectionUp);
+ .watch(vehicleAcStatusProvider.notifier)
+ .update(isAcDirectionUp: !isAcDirectionUp);
}
Future.delayed(Duration(milliseconds: 500),(){
- vehicledata.isAcDirectionDown
- ? _controller.reverse()
- : _controller.forward();
+ isAcDirectionDown ? _controller.reverse() : _controller.forward();
- ref.watch(vehicleProvider.notifier).update(
- isAcDirectionDown: !vehicledata.isAcDirectionDown,
+ ref.watch(vehicleAcStatusProvider.notifier).update(
+ isAcDirectionDown: !isAcDirectionDown,
);
});
diff --git a/lib/Buttons/auto.dart b/lib/Buttons/auto.dart
index 1bdb045..8e94e63 100644
--- a/lib/Buttons/auto.dart
+++ b/lib/Buttons/auto.dart
@@ -4,18 +4,12 @@ import 'dart:io';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
-import 'package:flutter_hvac/kuksa-server/vehicle-provider.dart';
+import 'package:flutter_hvac/vehicle-signals/vehicle_ac_status_provider.dart';
import '../size.dart';
class Auto extends ConsumerStatefulWidget {
- WebSocket socket;
- String serverPath;
- Auto({
- Key? key,
- required this.serverPath,
- required this.socket,
- }) : super(key: key);
+ Auto({Key? key}) : super(key: key);
@override
_AutoState createState() => _AutoState();
@@ -52,7 +46,8 @@ class _AutoState extends ConsumerState<Auto>
@override
Widget build(BuildContext context) {
- isAutoActive = ref.watch(vehicleProvider).isAutoActive;
+ isAutoActive = ref.watch(vehicleAcStatusProvider.select((p) => p.isAutoActive));
+
return AnimatedBuilder(
animation: _controller,
builder: (BuildContext context, _) {
@@ -100,7 +95,7 @@ class _AutoState extends ConsumerState<Auto>
onTap: () {
isAutoActive ? _controller.reverse() : _controller.forward();
ref
- .read(vehicleProvider.notifier)
+ .read(vehicleAcStatusProvider.notifier)
.update(isAutoActive: !isAutoActive);
},
);
diff --git a/lib/Buttons/defrost_recirculate.dart b/lib/Buttons/defrost_recirculate.dart
index 909bbf5..69adb89 100644
--- a/lib/Buttons/defrost_recirculate.dart
+++ b/lib/Buttons/defrost_recirculate.dart
@@ -5,20 +5,16 @@ import 'dart:io';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:flutter_svg_provider/flutter_svg_provider.dart';
-import 'package:flutter_hvac/kuksa-server/vehicle-class.dart';
-import 'package:flutter_hvac/kuksa-server/vehicle-provider.dart';
-import 'package:flutter_hvac/kuksa-server/vehicle_methods.dart';
+import 'package:flutter_hvac/vehicle-signals/vehicle_ac_status_provider.dart';
+import 'package:flutter_hvac/vehicle-signals/vss_provider.dart';
+import 'package:flutter_hvac/vehicle-signals/vss_path.dart';
import 'package:flutter_hvac/size.dart';
class CustomButton extends ConsumerStatefulWidget {
- WebSocket socket;
- String serverPath;
String img;
String type;
CustomButton({
Key? key,
- required this.serverPath,
- required this.socket,
required this.img,
required this.type,
}) : super(key: key);
@@ -30,7 +26,9 @@ class CustomButton extends ConsumerStatefulWidget {
class _CustomButtonState extends ConsumerState<CustomButton>
with SingleTickerProviderStateMixin {
late AnimationController _controller;
- late vehicle vehicledata;
+ late bool isFrontDefrosterActive;
+ late bool isRearDefrosterActive;
+ late bool isRecirculationActive;
late Animation<Color?> _colorAnimation;
@override
@@ -51,35 +49,18 @@ class _CustomButtonState extends ConsumerState<CustomButton>
});
_controller.addStatusListener((status) {
- if (status == AnimationStatus.completed) {
- if (widget.type == 'Front_defrost') {
- VISS.set(widget.socket,ref, widget.serverPath,
- vehicledata.isFrontDefrosterActive.toString());
- }
- if (widget.type == "Rear_defrost") {
- VISS.set(widget.socket,ref, widget.serverPath,
- vehicledata.isRearDefrosterActive.toString());
- }
- if (widget.type == "Recirculation") {
- VISS.set(widget.socket,ref, widget.serverPath,
- vehicledata.isRecirculationActive.toString());
- }
-
-
-
- }
- if (status == AnimationStatus.dismissed) {
- if (widget.type == 'Front_defrost') {
- VISS.set(widget.socket, ref,widget.serverPath,
- vehicledata.isFrontDefrosterActive.toString());
- }
- if (widget.type == "Rear_defrost") {
- VISS.set(widget.socket, ref,widget.serverPath,
- vehicledata.isRearDefrosterActive.toString());
- }
- if (widget.type == "Recirculation") {
- VISS.set(widget.socket, ref,widget.serverPath,
- vehicledata.isRecirculationActive.toString());
+ if (status == AnimationStatus.completed || status == AnimationStatus.dismissed) {
+ var vss = ref.read(vssClientProvider);
+ if (vss != null) {
+ if (widget.type == 'Front_defrost') {
+ vss.setBool(VSSPath.vehicleIsFrontDefrosterActive, isFrontDefrosterActive, true);
+ }
+ if (widget.type == "Rear_defrost") {
+ vss.setBool(VSSPath.vehicleIsRearDefrosterActive, isRearDefrosterActive, true);
+ }
+ if (widget.type == "Recirculation") {
+ vss.setBool(VSSPath.vehicleIsRecirculationActive, isRecirculationActive, true);
+ }
}
}
});
@@ -94,7 +75,10 @@ class _CustomButtonState extends ConsumerState<CustomButton>
@override
Widget build(BuildContext context) {
- vehicledata = ref.watch(vehicleProvider);
+ isFrontDefrosterActive = ref.watch(vehicleAcStatusProvider.select((p) => p.isFrontDefrosterActive));
+ isRearDefrosterActive = ref.watch(vehicleAcStatusProvider.select((p) => p.isRearDefrosterActive));
+ isRecirculationActive = ref.watch(vehicleAcStatusProvider.select((p) => p.isRecirculationActive));
+
return AnimatedBuilder(
animation: _controller,
builder: (BuildContext context, _) {
@@ -108,20 +92,20 @@ class _CustomButtonState extends ConsumerState<CustomButton>
decoration: BoxDecoration(
gradient: widget.type == "Front_defrost"
- ? vehicledata.isFrontDefrosterActive
+ ? isFrontDefrosterActive
? RadialGradient(
colors: [Colors.black, Colors.lightBlue],
radius: 2,
)
: null
: widget.type == "Rear_defrost"
- ? vehicledata.isRearDefrosterActive
+ ? isRearDefrosterActive
? RadialGradient(
colors: [Colors.black, Colors.lightBlue],
radius: 2,
)
: null
- : vehicledata.isRecirculationActive
+ : isRecirculationActive
? RadialGradient(
colors: [Colors.black, Colors.lightBlue],
radius: 2,
@@ -149,26 +133,25 @@ class _CustomButtonState extends ConsumerState<CustomButton>
),
onTap: () {
if (widget.type == "Front_defrost") {
- vehicledata.isFrontDefrosterActive
+ isFrontDefrosterActive
? _controller.reverse()
: _controller.forward();
- ref.read(vehicleProvider.notifier).update(
- isFrontDefrosterActive:
- !vehicledata.isFrontDefrosterActive);
+ ref.read(vehicleAcStatusProvider.notifier).update(
+ isFrontDefrosterActive: !isFrontDefrosterActive);
}
if (widget.type == "Rear_defrost") {
- vehicledata.isRearDefrosterActive
+ isRearDefrosterActive
? _controller.reverse()
: _controller.forward();
- ref.read(vehicleProvider.notifier).update(
- isRearDefrosterActive: !vehicledata.isRearDefrosterActive);
+ ref.read(vehicleAcStatusProvider.notifier).update(
+ isRearDefrosterActive: !isRearDefrosterActive);
}
if (widget.type == "Recirculation") {
- vehicledata.isRecirculationActive
+ isRecirculationActive
? _controller.reverse()
: _controller.forward();
- ref.read(vehicleProvider.notifier).update(
- isRecirculationActive: !vehicledata.isRecirculationActive);
+ ref.read(vehicleAcStatusProvider.notifier).update(
+ isRecirculationActive: !isRecirculationActive);
}
},
);
diff --git a/lib/Buttons/fresh_air.dart b/lib/Buttons/fresh_air.dart
index 3858cba..edaacd5 100644
--- a/lib/Buttons/fresh_air.dart
+++ b/lib/Buttons/fresh_air.dart
@@ -5,18 +5,14 @@ import 'dart:io';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:flutter_svg_provider/flutter_svg_provider.dart';
-import 'package:flutter_hvac/kuksa-server/vehicle-provider.dart';
+import 'package:flutter_hvac/vehicle-signals/vehicle_ac_status_provider.dart';
import '../size.dart';
class FreshAir extends ConsumerStatefulWidget {
- WebSocket socket;
- String serverPath;
String img;
FreshAir({
Key? key,
- required this.serverPath,
- required this.socket,
required this.img,
}) : super(key: key);
@@ -58,7 +54,8 @@ class _FreshAirState extends ConsumerState<FreshAir> with SingleTickerProviderSt
@override
Widget build(BuildContext context) {
- isFreshAirCirculateActive = ref.watch(vehicleProvider).isFreshAirCirculateActive;
+ isFreshAirCirculateActive = ref.watch(vehicleAcStatusProvider.select((p) => p.isFreshAirCirculateActive));
+
return AnimatedBuilder(
animation: _controller,
builder: (BuildContext context, _) {
@@ -100,7 +97,7 @@ class _FreshAirState extends ConsumerState<FreshAir> with SingleTickerProviderSt
onTap: () {
isFreshAirCirculateActive ? _controller.reverse() : _controller.forward();
ref
- .read(vehicleProvider.notifier)
+ .read(vehicleAcStatusProvider.notifier)
.update(isFreshAirCirculateActive: !isFreshAirCirculateActive);
},
);