push add ac fucntions and handle doplicate adding to the then or if items

This commit is contained in:
ashrafzarkanisala
2024-11-19 00:54:43 +03:00
parent 54143b3ba9
commit 57b8f6b03e
60 changed files with 1392 additions and 24 deletions

View File

@ -2,6 +2,8 @@ import 'package:syncrow_web/pages/device_managment/all_devices/models/device_com
import 'package:syncrow_web/pages/device_managment/all_devices/models/device_space_model.dart';
import 'package:syncrow_web/pages/device_managment/all_devices/models/room.dart';
import 'package:syncrow_web/pages/device_managment/all_devices/models/unit.dart';
import 'package:syncrow_web/pages/routiens/models/ac/ac_function.dart';
import 'package:syncrow_web/pages/routiens/models/device_functions.dart';
import 'package:syncrow_web/utils/constants/assets.dart';
import 'package:syncrow_web/utils/enum/device_types.dart';
@ -69,6 +71,7 @@ class AllDevicesModel {
int? batteryLevel;
String? productName;
List<DeviceSpaceModel>? spaces;
List<DeviceFunction>? _deviceFunctions;
AllDevicesModel({
this.room,
@ -215,6 +218,28 @@ SOS
return tempIcon;
}
List<DeviceFunction> get deviceFunctions {
_deviceFunctions ??= _getDeviceFunctions();
return _deviceFunctions!;
}
List<DeviceFunction> _getDeviceFunctions() {
switch (productType) {
case 'AC':
return [
SwitchFunction(deviceId: uuid ?? '', deviceName: name ?? ''),
ModeFunction(deviceId: uuid ?? '', deviceName: name ?? ''),
TempSetFunction(deviceId: uuid ?? '', deviceName: name ?? ''),
LevelFunction(deviceId: uuid ?? '', deviceName: name ?? ''),
ChildLockFunction(deviceId: uuid ?? '', deviceName: name ?? ''),
];
// other product types
default:
return [];
}
}
Map<String, dynamic> toJson() {
final data = <String, dynamic>{};
if (room != null) {