fetch groups

This commit is contained in:
Mohammad Salameh
2024-03-18 11:46:27 +03:00
parent 65cbf10485
commit 13e80fbad7
20 changed files with 273 additions and 164 deletions
@@ -1,6 +1,7 @@
// ignore_for_file: constant_identifier_names
import 'package:syncrow_app/features/devices/model/device_model.dart';
import 'package:syncrow_app/generated/assets.dart';
import 'package:syncrow_app/utils/resource_manager/constants.dart';
class DevicesCategoryModel {
@@ -40,10 +41,16 @@ class DevicesCategoryModel {
DevicesCategoryModel.fromJson(Map<String, dynamic> json)
: name = json['groupName'],
id = json['groupId'],
icon = json['icon'],
type = deviceTypeMap[json['groupName']] ?? DeviceType.Other,
icon = deviceTypeIconMap[
deviceTypeMap[json['groupName']] ?? DeviceType.Other] ??
'',
devices = [],
isSelected = false;
static List<DevicesCategoryModel> fromJsonList(List<dynamic> jsonList) {
return jsonList.map((item) => DevicesCategoryModel.fromJson(item)).toList();
}
}
Map<String, DeviceType> deviceTypeMap = {
@@ -52,4 +59,16 @@ Map<String, DeviceType> deviceTypeMap = {
'Door Locks': DeviceType.DoorLock,
'Gateways': DeviceType.Gateway,
'ACs': DeviceType.AC,
'3Gang': DeviceType.Gang,
};
Map<DeviceType, String> deviceTypeIconMap = {
DeviceType.AC: Assets.iconsAC,
DeviceType.Lights: Assets.iconsLight,
DeviceType.DoorLock: Assets.iconsDoorLock,
DeviceType.Curtain: Assets.iconsCurtain,
DeviceType.Gateway: Assets.iconsGateway,
DeviceType.Sensors: Assets.iconsSensors,
DeviceType.Gang: Assets.iconsGang,
DeviceType.Other: Assets.iconsAC,
};