From 70ec8a79a121471a004e7e4c23157d10157e136f Mon Sep 17 00:00:00 2001 From: Lisandro Pérez Meyer Date: Tue, 14 Nov 2023 17:20:58 -0300 Subject: Initial cleanup push. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- lib/data/models/hybrid.dart | 98 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 98 insertions(+) create mode 100644 lib/data/models/hybrid.dart (limited to 'lib/data/models/hybrid.dart') 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 toMap() { + // return { + // 'hybridState': hybridState.toMap(), + // 'topArrowState': topArrowState.toMap(), + // 'leftArrowState': leftArrowState.toMap(), + // 'rightArrowState': rightArrowState.toMap(), + // 'batteryState': batteryState.toMap(), + // }; + // } + + // factory Hybrid.fromMap(Map 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; + } +} -- cgit 1.2.3-korg