diff --git a/lib/pages/device_managment/all_devices/models/devices_model.dart b/lib/pages/device_managment/all_devices/models/devices_model.dart index a814a8b1..e81b7695 100644 --- a/lib/pages/device_managment/all_devices/models/devices_model.dart +++ b/lib/pages/device_managment/all_devices/models/devices_model.dart @@ -1,6 +1,6 @@ - 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/utils/constants/assets.dart'; class AllDevicesModel { /* @@ -106,7 +106,7 @@ class AllDevicesModel { categoryName = json['categoryName']?.toString(); createTime = int.tryParse(json['createTime']?.toString() ?? ''); gatewayId = json['gatewayId']?.toString(); - icon = json['icon']?.toString(); + icon = json['icon'] ?? _getDefaultIcon(productType); ip = json['ip']?.toString(); lat = json['lat']?.toString(); localKey = json['localKey']?.toString(); @@ -122,6 +122,35 @@ class AllDevicesModel { uuid = json['uuid']?.toString(); batteryLevel = int.tryParse(json['battery']?.toString() ?? ''); } + + String _getDefaultIcon(String? productType) { + switch (productType) { + case 'LightBulb': + return Assets.lightBulb; + case 'CeilingSensor': + case 'WallSensor': + return Assets.sensors; + case 'AC': + return Assets.ac; + case 'DoorLock': + return Assets.doorLock; + case 'Curtain': + return Assets.curtain; + case '3G': + case '2G': + case '1G': + return Assets.gangSwitch; + case 'Gateway': + return Assets.gateway; + case 'WH': + return Assets.blackLogo; + case 'DS': + return Assets.sensors; + default: + return Assets.logo; + } + } + Map toJson() { final data = {}; if (room != null) { @@ -159,61 +188,61 @@ class AllDevicesModel { @override bool operator ==(Object other) { if (identical(this, other)) return true; - + return other is AllDevicesModel && - other.room == room && - other.unit == unit && - other.productUuid == productUuid && - other.productType == productType && - other.permissionType == permissionType && - other.activeTime == activeTime && - other.category == category && - other.categoryName == categoryName && - other.createTime == createTime && - other.gatewayId == gatewayId && - other.icon == icon && - other.ip == ip && - other.lat == lat && - other.localKey == localKey && - other.lon == lon && - other.model == model && - other.name == name && - other.nodeId == nodeId && - other.online == online && - other.ownerId == ownerId && - other.sub == sub && - other.timeZone == timeZone && - other.updateTime == updateTime && - other.uuid == uuid && - other.batteryLevel == batteryLevel; + other.room == room && + other.unit == unit && + other.productUuid == productUuid && + other.productType == productType && + other.permissionType == permissionType && + other.activeTime == activeTime && + other.category == category && + other.categoryName == categoryName && + other.createTime == createTime && + other.gatewayId == gatewayId && + other.icon == icon && + other.ip == ip && + other.lat == lat && + other.localKey == localKey && + other.lon == lon && + other.model == model && + other.name == name && + other.nodeId == nodeId && + other.online == online && + other.ownerId == ownerId && + other.sub == sub && + other.timeZone == timeZone && + other.updateTime == updateTime && + other.uuid == uuid && + other.batteryLevel == batteryLevel; } @override int get hashCode { return room.hashCode ^ - unit.hashCode ^ - productUuid.hashCode ^ - productType.hashCode ^ - permissionType.hashCode ^ - activeTime.hashCode ^ - category.hashCode ^ - categoryName.hashCode ^ - createTime.hashCode ^ - gatewayId.hashCode ^ - icon.hashCode ^ - ip.hashCode ^ - lat.hashCode ^ - localKey.hashCode ^ - lon.hashCode ^ - model.hashCode ^ - name.hashCode ^ - nodeId.hashCode ^ - online.hashCode ^ - ownerId.hashCode ^ - sub.hashCode ^ - timeZone.hashCode ^ - updateTime.hashCode ^ - uuid.hashCode ^ - batteryLevel.hashCode; + unit.hashCode ^ + productUuid.hashCode ^ + productType.hashCode ^ + permissionType.hashCode ^ + activeTime.hashCode ^ + category.hashCode ^ + categoryName.hashCode ^ + createTime.hashCode ^ + gatewayId.hashCode ^ + icon.hashCode ^ + ip.hashCode ^ + lat.hashCode ^ + localKey.hashCode ^ + lon.hashCode ^ + model.hashCode ^ + name.hashCode ^ + nodeId.hashCode ^ + online.hashCode ^ + ownerId.hashCode ^ + sub.hashCode ^ + timeZone.hashCode ^ + updateTime.hashCode ^ + uuid.hashCode ^ + batteryLevel.hashCode; } } diff --git a/lib/pages/device_managment/door_lock/bloc/door_lock_event.dart b/lib/pages/device_managment/door_lock/bloc/door_lock_event.dart index 8ee2e6aa..4033676f 100644 --- a/lib/pages/device_managment/door_lock/bloc/door_lock_event.dart +++ b/lib/pages/device_managment/door_lock/bloc/door_lock_event.dart @@ -37,3 +37,5 @@ class UpdateLockEvent extends DoorLockEvent { @override List get props => [value]; } + + diff --git a/lib/pages/device_managment/gateway/view/gateway_view.dart b/lib/pages/device_managment/gateway/view/gateway_view.dart index 718e4d84..ad760a14 100644 --- a/lib/pages/device_managment/gateway/view/gateway_view.dart +++ b/lib/pages/device_managment/gateway/view/gateway_view.dart @@ -86,7 +86,7 @@ class _DeviceItem extends StatelessWidget { const Spacer(), Text( device.name ?? 'Unknown Device', - textAlign: TextAlign.center, + textAlign: TextAlign.start, style: const TextStyle( fontWeight: FontWeight.bold, fontSize: 14, diff --git a/lib/pages/device_managment/main_door_sensor/view/main_door_control_view.dart b/lib/pages/device_managment/main_door_sensor/view/main_door_control_view.dart index 657ebfee..2168be5a 100644 --- a/lib/pages/device_managment/main_door_sensor/view/main_door_control_view.dart +++ b/lib/pages/device_managment/main_door_sensor/view/main_door_control_view.dart @@ -6,6 +6,7 @@ import 'package:syncrow_web/pages/device_managment/main_door_sensor/bloc/main_do import 'package:syncrow_web/pages/device_managment/main_door_sensor/bloc/main_door_sensor_event.dart'; import 'package:syncrow_web/pages/device_managment/main_door_sensor/bloc/main_door_sensor_state.dart'; import 'package:syncrow_web/pages/device_managment/main_door_sensor/models/main_door_status_model.dart'; +import 'package:syncrow_web/pages/device_managment/main_door_sensor/widgets/notification_dialog.dart'; import 'package:syncrow_web/pages/device_managment/shared/device_controls_container.dart'; import 'package:syncrow_web/pages/device_managment/shared/table/report_table.dart'; import 'package:syncrow_web/utils/color_manager.dart'; @@ -82,7 +83,7 @@ class MainDoorSensorControlView extends StatelessWidget paddingAmount: 8, ), IconNameStatusContainer( - name: 'Open/Close\n Record', + name: 'Open/Close\nRecord', icon: Assets.mainDoorReports, onTap: () { final from = DateTime.now() @@ -102,9 +103,14 @@ class MainDoorSensorControlView extends StatelessWidget textColor: ColorsManager.blackColor, ), IconNameStatusContainer( - name: 'Notifications\n Settings', + name: 'Notifications\nSettings', icon: Assets.mainDoorNotifi, - onTap: () {}, + onTap: () { + showDialog( + context: context, + builder: (context) => const NotificationDialog(), + ); + }, status: false, textColor: ColorsManager.blackColor, ), diff --git a/lib/pages/device_managment/main_door_sensor/widgets/notification_dialog.dart b/lib/pages/device_managment/main_door_sensor/widgets/notification_dialog.dart new file mode 100644 index 00000000..d452026d --- /dev/null +++ b/lib/pages/device_managment/main_door_sensor/widgets/notification_dialog.dart @@ -0,0 +1,97 @@ +import 'package:flutter/material.dart'; +import 'package:syncrow_web/pages/device_managment/shared/toggle_widget.dart'; +import 'package:syncrow_web/utils/color_manager.dart'; + +class NotificationDialog extends StatelessWidget { + const NotificationDialog({super.key}); + + @override + Widget build(BuildContext context) { + return Dialog( + backgroundColor: Colors.white, + insetPadding: const EdgeInsets.all(20), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(20), + ), + child: SizedBox( + width: 798, + child: SingleChildScrollView( + child: Padding( + padding: const EdgeInsets.all(20.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + const SizedBox(), + Text( + 'Notification Settings', + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 22, + color: ColorsManager.dialogBlueTitle, + ), + ), + Container( + width: 25, + decoration: BoxDecoration( + color: Colors.transparent, + shape: BoxShape.circle, + border: Border.all( + color: Colors.grey, + width: 1.0, + ), + ), + child: IconButton( + padding: EdgeInsets.all(1), + icon: const Icon( + Icons.close, + color: Colors.grey, + size: 18, + ), + onPressed: () { + Navigator.of(context).pop(); + }, + ), + ), + ], + ), + const SizedBox(height: 20), + Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + ToggleWidget( + value: true, + code: 'notification', + deviceId: '', + label: 'Low Battery', + onChange: (v) {}, + icon: '-1', + ), + ToggleWidget( + value: true, + code: 'notification', + deviceId: '', + label: 'Closing\nReminders', + onChange: (v) {}, + icon: '-1', + ), + ToggleWidget( + value: true, + code: 'notification', + deviceId: '', + label: 'Door Alarm', + onChange: (v) {}, + icon: '-1', + ), + ], + ), + ], + ), + ), + ), + ), + ); + } +} diff --git a/lib/pages/device_managment/shared/toggle_widget.dart b/lib/pages/device_managment/shared/toggle_widget.dart index 71eba26f..5f88b106 100644 --- a/lib/pages/device_managment/shared/toggle_widget.dart +++ b/lib/pages/device_managment/shared/toggle_widget.dart @@ -40,16 +40,21 @@ class ToggleWidget extends StatelessWidget { mainAxisAlignment: MainAxisAlignment.spaceBetween, crossAxisAlignment: CrossAxisAlignment.start, children: [ - ClipOval( - child: Container( - color: ColorsManager.whiteColors, - child: SvgPicture.asset( - icon ?? Assets.lightPulp, - width: 60, - height: 60, - fit: BoxFit.cover, - ), - )), + icon == '-1' + ? const SizedBox( + height: 60, + width: 60, + ) + : ClipOval( + child: Container( + color: ColorsManager.whiteColors, + child: SvgPicture.asset( + icon ?? Assets.lightPulp, + width: 60, + height: 60, + fit: BoxFit.cover, + ), + )), Text( label, style: context.textTheme.titleMedium!.copyWith( diff --git a/lib/pages/home/view/home_page_mobile.dart b/lib/pages/home/view/home_page_mobile.dart index 560ef0d5..8f72f8cb 100644 --- a/lib/pages/home/view/home_page_mobile.dart +++ b/lib/pages/home/view/home_page_mobile.dart @@ -41,7 +41,8 @@ class HomeMobilePage extends StatelessWidget { SizedBox(height: size.height * 0.05), const Text( 'ACCESS YOUR APPS', - style: TextStyle(fontSize: 20, fontWeight: FontWeight.w700), + style: + TextStyle(fontSize: 20, fontWeight: FontWeight.w700), ), const SizedBox(height: 30), Expanded( @@ -51,7 +52,8 @@ class HomeMobilePage extends StatelessWidget { width: size.width * 0.68, child: GridView.builder( itemCount: 8, - gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount( + gridDelegate: + const SliverGridDelegateWithFixedCrossAxisCount( crossAxisCount: 2, crossAxisSpacing: 20.0, mainAxisSpacing: 20.0, @@ -63,7 +65,8 @@ class HomeMobilePage extends StatelessWidget { active: homeItems[index]['active'], name: homeItems[index]['title'], img: homeItems[index]['icon'], - onTap: () => homeBloc.homeItems[index].onPress(context), + onTap: () => + homeBloc.homeItems[index].onPress(context), ); }, ),