aboutsummaryrefslogtreecommitdiffstats
path: root/lib/data/data_providers/hybrid_notifier.dart
diff options
context:
space:
mode:
Diffstat (limited to 'lib/data/data_providers/hybrid_notifier.dart')
-rw-r--r--lib/data/data_providers/hybrid_notifier.dart42
1 files changed, 23 insertions, 19 deletions
diff --git a/lib/data/data_providers/hybrid_notifier.dart b/lib/data/data_providers/hybrid_notifier.dart
index 3668f61..7381f5c 100644
--- a/lib/data/data_providers/hybrid_notifier.dart
+++ b/lib/data/data_providers/hybrid_notifier.dart
@@ -1,6 +1,6 @@
// ignore_for_file: unused_local_variable
-import '../../export.dart';
+import 'package:flutter_ics_homescreen/export.dart';
class HybridNotifier extends StateNotifier<Hybrid> {
HybridNotifier(super.state);
@@ -9,38 +9,44 @@ class HybridNotifier extends StateNotifier<Hybrid> {
switch (hybridState) {
case HybridState.idle:
state = state.copyWith(
- topArrowState: ArrowState.blue,
- leftArrowState: ArrowState.blue,
- rightArrowState: ArrowState.blue,
- batteryState: BatteryState.white,
+ hybridState: hybridState,
+ 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,
+ hybridState: hybridState,
+ topArrowState: ArrowState.red,
+ leftArrowState: ArrowState.red,
+ rightArrowState: ArrowState.blue,
+ batteryState: BatteryState.red,
);
break;
case HybridState.regenerativeBreaking:
state = state.copyWith(
+ hybridState: hybridState,
topArrowState: ArrowState.blue,
leftArrowState: ArrowState.blue,
rightArrowState: ArrowState.green,
- batteryState: BatteryState.green);
-
+ batteryState: BatteryState.green
+ );
break;
- case HybridState.baterryOutput:
+ case HybridState.batteryOutput:
state = state.copyWith(
+ hybridState: hybridState,
topArrowState: ArrowState.blue,
leftArrowState: ArrowState.blue,
rightArrowState: ArrowState.yellow,
- batteryState: BatteryState.yellow);
+ batteryState: BatteryState.yellow
+ );
break;
default:
+ state = state.copyWith(hybridState: hybridState);
+ break;
}
- state = state.copyWith(hybridState: hybridState);
}
void updateHybridState(double speed, double engineSpeed, bool brake) {
@@ -55,25 +61,23 @@ class HybridNotifier extends StateNotifier<Hybrid> {
// Variable for storing the average value of RPM
double avgRpm = 0.0;
-
if (speed == 0 && engineSpeed == 0) {
// Set idle state.
currentState = HybridState.idle;
} else if (engineSpeed > 0 && speed > 0) {
- // Set stan na engine output state..
+ // Set engine output state..
currentState = HybridState.engineOutput;
} else if (speed < 0 && brake) {
- // Set regenerative breaking state
+ // Set regenerative breaking state
currentState = HybridState.regenerativeBreaking;
} else if (speed > 0 && engineSpeed <= 0) {
// Set battery output state
- currentState = HybridState.baterryOutput;
+ currentState = HybridState.batteryOutput;
}
// Update hybrid state
if (currentState != previousState) {
- //state = state.copyWith(hybridState: currentState);
setHybridState(currentState);
}
}