Merge branch 'dev' of https://github.com/SyncrowIOT/syncrow-app into feat/refactor

This commit is contained in:
hannathkadher
2024-10-31 10:45:08 +04:00
66 changed files with 4004 additions and 1041 deletions

View File

@ -5,6 +5,8 @@ import 'package:flutter/foundation.dart';
class CreateSceneModel {
String spaceUuid;
String iconId;
bool showInDevice;
String sceneName;
String decisionExpr;
List<CreateSceneAction> actions;
@ -12,6 +14,8 @@ class CreateSceneModel {
CreateSceneModel({
required this.spaceUuid,
required this.iconId,
required this.showInDevice,
required this.sceneName,
required this.decisionExpr,
required this.actions,
@ -20,6 +24,8 @@ class CreateSceneModel {
CreateSceneModel copyWith({
String? spaceUuid,
String? iconId,
bool? showInDevice,
String? sceneName,
String? decisionExpr,
List<CreateSceneAction>? actions,
@ -27,6 +33,8 @@ class CreateSceneModel {
}) {
return CreateSceneModel(
spaceUuid: spaceUuid ?? this.spaceUuid,
iconId: iconId ?? this.iconId,
showInDevice: showInDevice ?? this.showInDevice,
sceneName: sceneName ?? this.sceneName,
decisionExpr: decisionExpr ?? this.decisionExpr,
actions: actions ?? this.actions,
@ -37,6 +45,8 @@ class CreateSceneModel {
Map<String, dynamic> toMap([String? sceneId]) {
return {
if (sceneId == null) 'spaceUuid': spaceUuid,
if (iconId.isNotEmpty) 'iconUuid': iconId,
'showInHomePage': showInDevice,
'sceneName': sceneName,
'decisionExpr': decisionExpr,
'actions': actions.map((x) => x.toMap()).toList(),
@ -47,11 +57,13 @@ class CreateSceneModel {
factory CreateSceneModel.fromMap(Map<String, dynamic> map) {
return CreateSceneModel(
spaceUuid: map['spaceUuid'] ?? '',
showInHomePage: map['showInHomePage'] ?? false,
iconId: map['iconUuid'] ?? '',
showInDevice: map['showInHomePage'] ?? false,
sceneName: map['sceneName'] ?? '',
decisionExpr: map['decisionExpr'] ?? '',
actions: List<CreateSceneAction>.from(
map['actions']?.map((x) => CreateSceneAction.fromMap(x))),
showInHomePage: map['showInHomePage'] ?? false,
);
}
@ -71,6 +83,8 @@ class CreateSceneModel {
return other is CreateSceneModel &&
other.spaceUuid == spaceUuid &&
other.iconId == iconId &&
other.showInDevice == showInDevice &&
other.sceneName == sceneName &&
other.decisionExpr == decisionExpr &&
listEquals(other.actions, actions) &&
@ -82,8 +96,7 @@ class CreateSceneModel {
return spaceUuid.hashCode ^
sceneName.hashCode ^
decisionExpr.hashCode ^
actions.hashCode ^
showInHomePage.hashCode;
actions.hashCode;
}
}