mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2026-10-25 21:37:55 +00:00
Add device icons based on device type and update network exception handling
- Add logic to set device icons based on device type in DeviceModel.fromJson method - Update network exception handling to parse HTML response in ServerFailure class - Add html package as a dependency for parsing HTML responses -Added Devices Icons by updateing device types mapping
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import 'package:syncrow_app/features/devices/model/function_model.dart';
|
||||
import 'package:syncrow_app/generated/assets.dart';
|
||||
import 'package:syncrow_app/utils/resource_manager/constants.dart';
|
||||
|
||||
class DeviceModel {
|
||||
@@ -56,13 +57,37 @@ class DeviceModel {
|
||||
}
|
||||
|
||||
factory DeviceModel.fromJson(Map<String, dynamic> json) {
|
||||
print(
|
||||
'type : ${json['productId']} => ${devicesTypesMap[json['productId']]}');
|
||||
|
||||
String icon = '';
|
||||
DeviceType type = devicesTypesMap[json['productId']] ?? DeviceType.Other;
|
||||
|
||||
if (type == DeviceType.LightBulb) {
|
||||
icon = Assets.iconsLight;
|
||||
} else if (type == DeviceType.CeilingSensor ||
|
||||
type == DeviceType.WallSensor) {
|
||||
icon = Assets.iconsSensors;
|
||||
} else if (type == DeviceType.AC) {
|
||||
icon = Assets.iconsAC;
|
||||
} else if (type == DeviceType.DoorLock) {
|
||||
icon = Assets.iconsDoorLock;
|
||||
} else if (type == DeviceType.Curtain) {
|
||||
icon = Assets.iconsCurtain;
|
||||
} else if (type == DeviceType.ThreeGang) {
|
||||
icon = Assets.iconsLight;
|
||||
} else if (type == DeviceType.Gateway) {
|
||||
icon = Assets.iconsGateway;
|
||||
} else {
|
||||
icon = Assets.iconsLogo;
|
||||
}
|
||||
return DeviceModel(
|
||||
activeTime: json['activeTime'],
|
||||
category: json['category'],
|
||||
categoryName: json['categoryName'],
|
||||
createTime: json['createTime'],
|
||||
gatewayId: json['gatewayId'],
|
||||
icon: json['icon'],
|
||||
icon: icon,
|
||||
id: json['id'],
|
||||
ip: json['ip'],
|
||||
lat: double.tryParse(json['lat']),
|
||||
|
||||
Reference in New Issue
Block a user