diff options
author | Lisandro Pérez Meyer <lpmeyer@ics.com> | 2023-11-14 17:20:58 -0300 |
---|---|---|
committer | Lisandro Pérez Meyer <lpmeyer@ics.com> | 2023-11-14 17:31:12 -0300 |
commit | 70ec8a79a121471a004e7e4c23157d10157e136f (patch) | |
tree | a4f9c0a4fac4e4274ec4324a289b6ef62e1c5653 /lib/data/models/hybrid.dart |
Initial cleanup push.
Based on agldemo2024 on commit 2a5dc04d801134338150c3f6afc67eaa65599763
Disable device preview.
Disable Lottie animation.
The original commit was b3c493c340fcb4bb0a937692838fc830bec3e9ea
but I am just keeping this change, because the json did not really
needed to change. I think.
Signed-off-by: Lisandro Pérez Meyer <lpmeyer@ics.com>
Diffstat (limited to 'lib/data/models/hybrid.dart')
-rw-r--r-- | lib/data/models/hybrid.dart | 98 |
1 files changed, 98 insertions, 0 deletions
diff --git a/lib/data/models/hybrid.dart b/lib/data/models/hybrid.dart new file mode 100644 index 0000000..d567f14 --- /dev/null +++ b/lib/data/models/hybrid.dart @@ -0,0 +1,98 @@ +enum HybridState { + idle, + engineOutput, + regenerativeBreaking, + baterryOutput, +} + +enum ArrowState { blue, red, green, yellow } + +enum BatteryState { white, red, green, yellow, orange } + +class Hybrid { + final HybridState hybridState; + final ArrowState topArrowState; + final ArrowState leftArrowState; + final ArrowState rightArrowState; + final BatteryState batteryState; + Hybrid({ + required this.hybridState, + required this.topArrowState, + required this.leftArrowState, + required this.rightArrowState, + required this.batteryState, + }); + + const Hybrid.initial() + : hybridState = HybridState.idle, + topArrowState = ArrowState.blue, + leftArrowState = ArrowState.blue, + rightArrowState = ArrowState.blue, + batteryState = BatteryState.white; + + Hybrid copyWith({ + HybridState? hybridState, + ArrowState? topArrowState, + ArrowState? leftArrowState, + ArrowState? rightArrowState, + BatteryState? batteryState, + }) { + return Hybrid( + hybridState: hybridState ?? this.hybridState, + topArrowState: topArrowState ?? this.topArrowState, + leftArrowState: leftArrowState ?? this.leftArrowState, + rightArrowState: rightArrowState ?? this.rightArrowState, + batteryState: batteryState ?? this.batteryState, + ); + } + + // Map<String, dynamic> toMap() { + // return { + // 'hybridState': hybridState.toMap(), + // 'topArrowState': topArrowState.toMap(), + // 'leftArrowState': leftArrowState.toMap(), + // 'rightArrowState': rightArrowState.toMap(), + // 'batteryState': batteryState.toMap(), + // }; + // } + + // factory Hybrid.fromMap(Map<String, dynamic> map) { + // return Hybrid( + // hybridState: HybridState.fromMap(map['hybridState']), + // topArrowState: ArrowState.fromMap(map['topArrowState']), + // leftArrowState: ArrowState.fromMap(map['leftArrowState']), + // rightArrowState: ArrowState.fromMap(map['rightArrowState']), + // batteryState: BatteryState.fromMap(map['batteryState']), + // ); + // } + + // String toJson() => json.encode(toMap()); + + // factory Hybrid.fromJson(String source) => Hybrid.fromMap(json.decode(source)); + + @override + String toString() { + return 'Hybrid(hybridState: $hybridState, topArrowState: $topArrowState, leftArrowState: $leftArrowState, rightArrowState: $rightArrowState, batteryState: $batteryState)'; + } + + @override + bool operator ==(Object other) { + if (identical(this, other)) return true; + + return other is Hybrid && + other.hybridState == hybridState && + other.topArrowState == topArrowState && + other.leftArrowState == leftArrowState && + other.rightArrowState == rightArrowState && + other.batteryState == batteryState; + } + + @override + int get hashCode { + return hybridState.hashCode ^ + topArrowState.hashCode ^ + leftArrowState.hashCode ^ + rightArrowState.hashCode ^ + batteryState.hashCode; + } +} |