mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2026-10-25 07:37:56 +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']),
|
||||
|
||||
@@ -22,7 +22,6 @@ class DevicesViewBody extends StatelessWidget {
|
||||
builder: (context, state) {
|
||||
return BlocBuilder<DevicesCubit, DevicesState>(
|
||||
builder: (context, state) {
|
||||
//TODO : move to NavigationCubit
|
||||
if (state is DevicesLoading) {
|
||||
return const Center(child: CircularProgressIndicator());
|
||||
} else {
|
||||
|
||||
@@ -21,18 +21,6 @@ class RoomPageSwitch extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
return InkWell(
|
||||
onTap: () {
|
||||
//Navigate to the chosen category view without animation
|
||||
|
||||
// Navigator.push(
|
||||
// context,
|
||||
// CustomPageRoute(
|
||||
// builder: (context) {
|
||||
// return DevicesCubit.get(context)
|
||||
// .chosenCategoryView!;
|
||||
// },
|
||||
// ),
|
||||
// );
|
||||
|
||||
if (device.productType == DeviceType.AC) {
|
||||
Navigator.push(
|
||||
context,
|
||||
|
||||
@@ -61,10 +61,7 @@ class WizartSwitches extends StatelessWidget {
|
||||
DevicesCubit.allCategories![index].icon!,
|
||||
fit: BoxFit.contain,
|
||||
),
|
||||
CustomSwitch(
|
||||
category:
|
||||
DevicesCubit.allCategories![index],
|
||||
),
|
||||
// CustomSwitch(
|
||||
],
|
||||
),
|
||||
Expanded(
|
||||
|
||||
Reference in New Issue
Block a user