From f095d29022005472bda8cfbf2272a79895fceb7a Mon Sep 17 00:00:00 2001 From: Mohammad Salameh Date: Thu, 18 Apr 2024 10:01:55 +0300 Subject: [PATCH 1/4] Added wall mounted presence sensor assets --- .../icons/presence-sensor-assets/Distance.svg | 20 +++++++++++++ assets/icons/presence-sensor-assets/Empty.svg | 4 +++ .../Illuminance-Record.svg | 21 ++++++++++++++ .../Illuminance-Value.svg | 18 ++++++++++++ .../presence-sensor-assets/Indicator.svg | 12 ++++++++ .../icons/presence-sensor-assets/Presence.svg | 12 ++++++++ .../icons/presence-sensor-assets/Record.svg | 17 +++++++++++ assets/icons/presence-sensor-assets/Time.svg | 29 +++++++++++++++++++ lib/generated/assets.dart | 16 ++++++++++ 9 files changed, 149 insertions(+) create mode 100644 assets/icons/presence-sensor-assets/Distance.svg create mode 100644 assets/icons/presence-sensor-assets/Empty.svg create mode 100644 assets/icons/presence-sensor-assets/Illuminance-Record.svg create mode 100644 assets/icons/presence-sensor-assets/Illuminance-Value.svg create mode 100644 assets/icons/presence-sensor-assets/Indicator.svg create mode 100644 assets/icons/presence-sensor-assets/Presence.svg create mode 100644 assets/icons/presence-sensor-assets/Record.svg create mode 100644 assets/icons/presence-sensor-assets/Time.svg diff --git a/assets/icons/presence-sensor-assets/Distance.svg b/assets/icons/presence-sensor-assets/Distance.svg new file mode 100644 index 0000000..5057814 --- /dev/null +++ b/assets/icons/presence-sensor-assets/Distance.svg @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/assets/icons/presence-sensor-assets/Empty.svg b/assets/icons/presence-sensor-assets/Empty.svg new file mode 100644 index 0000000..cf1e5df --- /dev/null +++ b/assets/icons/presence-sensor-assets/Empty.svg @@ -0,0 +1,4 @@ + + + + diff --git a/assets/icons/presence-sensor-assets/Illuminance-Record.svg b/assets/icons/presence-sensor-assets/Illuminance-Record.svg new file mode 100644 index 0000000..5f64243 --- /dev/null +++ b/assets/icons/presence-sensor-assets/Illuminance-Record.svg @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/icons/presence-sensor-assets/Illuminance-Value.svg b/assets/icons/presence-sensor-assets/Illuminance-Value.svg new file mode 100644 index 0000000..c087b7c --- /dev/null +++ b/assets/icons/presence-sensor-assets/Illuminance-Value.svg @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + diff --git a/assets/icons/presence-sensor-assets/Indicator.svg b/assets/icons/presence-sensor-assets/Indicator.svg new file mode 100644 index 0000000..600d6da --- /dev/null +++ b/assets/icons/presence-sensor-assets/Indicator.svg @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/assets/icons/presence-sensor-assets/Presence.svg b/assets/icons/presence-sensor-assets/Presence.svg new file mode 100644 index 0000000..638cb39 --- /dev/null +++ b/assets/icons/presence-sensor-assets/Presence.svg @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/assets/icons/presence-sensor-assets/Record.svg b/assets/icons/presence-sensor-assets/Record.svg new file mode 100644 index 0000000..ff39c7f --- /dev/null +++ b/assets/icons/presence-sensor-assets/Record.svg @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + diff --git a/assets/icons/presence-sensor-assets/Time.svg b/assets/icons/presence-sensor-assets/Time.svg new file mode 100644 index 0000000..f5b43ad --- /dev/null +++ b/assets/icons/presence-sensor-assets/Time.svg @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/lib/generated/assets.dart b/lib/generated/assets.dart index 9ac87d4..364a03d 100644 --- a/lib/generated/assets.dart +++ b/lib/generated/assets.dart @@ -158,4 +158,20 @@ class Assets { static const String imagesTestDash2 = 'assets/images/test_dash2.png'; static const String imagesVector = 'assets/images/Vector.png'; static const String imagesWhiteLogo = 'assets/images/white-logo.png'; + static const String presenceSensorAssetsDistance = + 'assets/icons/presence-sensor-assets/Distance.svg'; + static const String presenceSensorAssetsEmpty = + 'assets/icons/presence-sensor-assets/Empty.svg'; + static const String presenceSensorAssetsIlluminanceRecord = + 'assets/icons/presence-sensor-assets/Illuminance-Record.svg'; + static const String presenceSensorAssetsIlluminanceValue = + 'assets/icons/presence-sensor-assets/Illuminance-Value.svg'; + static const String presenceSensorAssetsIndicator = + 'assets/icons/presence-sensor-assets/Indicator.svg'; + static const String presenceSensorAssetsPresence = + 'assets/icons/presence-sensor-assets/Presence.svg'; + static const String presenceSensorAssetsRecord = + 'assets/icons/presence-sensor-assets/Record.svg'; + static const String presenceSensorAssetsTime = + 'assets/icons/presence-sensor-assets/Time.svg'; } From 822de1d9b529c298a3155b350194791932a02574 Mon Sep 17 00:00:00 2001 From: Mohammad Salameh Date: Fri, 19 Apr 2024 17:46:30 +0300 Subject: [PATCH 2/4] Add presence sensor assets to pubspec.yaml --- pubspec.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/pubspec.yaml b/pubspec.yaml index 542c3c7..f2a02a4 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -51,6 +51,7 @@ flutter: - assets/icons/ - assets/fonts/ - assets/icons/doorlock-assets/ + - assets/icons/presence-sensor-assets/ - assets/icons/battery/dmOff/ - assets/icons/battery/dmOn/ From d78394d259f92329f4c3dfd3938b4f810b30a673 Mon Sep 17 00:00:00 2001 From: Mohammad Salameh Date: Fri, 19 Apr 2024 17:47:49 +0300 Subject: [PATCH 3/4] Add presence indicator and wall sensor interface --- .../presence_sensor/parameters_list.dart | 349 ++++++++++++++++++ .../presence_sensor/presence_indicator.dart | 29 ++ .../wall_sensor_interface.dart | 68 ++++ .../view/widgets/room_page_switch.dart | 2 + 4 files changed, 448 insertions(+) create mode 100644 lib/features/devices/view/widgets/presence_sensor/parameters_list.dart create mode 100644 lib/features/devices/view/widgets/presence_sensor/presence_indicator.dart create mode 100644 lib/features/devices/view/widgets/presence_sensor/wall_sensor_interface.dart diff --git a/lib/features/devices/view/widgets/presence_sensor/parameters_list.dart b/lib/features/devices/view/widgets/presence_sensor/parameters_list.dart new file mode 100644 index 0000000..14b5203 --- /dev/null +++ b/lib/features/devices/view/widgets/presence_sensor/parameters_list.dart @@ -0,0 +1,349 @@ +part of "wall_sensor_interface.dart"; + +class ParametersList extends StatelessWidget { + const ParametersList({ + super.key, + required this.wallSensor, + }); + + final DeviceModel wallSensor; + @override + Widget build(BuildContext context) { + return Expanded( + flex: 7, + child: SingleChildScrollView( + child: Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + mainAxisSize: MainAxisSize.min, + children: List.generate( + wallSensorButtons.length, + (index) { + if (index == 3) { + return Column( + mainAxisSize: MainAxisSize.min, + children: [ + DefaultContainer( + padding: const EdgeInsets.symmetric( + vertical: 12, horizontal: 15), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceAround, + children: [ + InkWell( + onTap: () { + showParameterDialog( + context, + 'Motion Detection Sensitivity', + wallSensor, + 5, + 0, + 10, + ); + }, + child: Column( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + mainAxisSize: MainAxisSize.min, + children: [ + const BodySmall( + text: 'Motion\nDetectionn\nSensitivity', + textAlign: TextAlign.center), + BodyLarge( + text: '5', + style: context.bodyLarge + .copyWith(fontWeight: FontsManager.bold), + ), + ], + ), + ), + Padding( + padding: const EdgeInsets.symmetric(horizontal: 10), + child: Container( + width: 1, + height: 45, + color: ColorsManager.greyColor, + ), + ), + Column( + mainAxisSize: MainAxisSize.min, + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + const BodySmall( + text: 'Motionless\nDetection\nSensitivity', + textAlign: TextAlign.center), + BodyLarge( + text: '5', + style: context.bodyLarge.copyWith( + fontWeight: FontsManager.bold, + ), + ), + ], + ), + Padding( + padding: const EdgeInsets.symmetric(horizontal: 10), + child: Container( + width: 1, + height: 45, + color: ColorsManager.greyColor, + ), + ), + Column( + mainAxisSize: MainAxisSize.min, + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + const BodySmall( + text: 'Far\nDetection', + textAlign: TextAlign.center), + BodyLarge( + text: '600cm', + style: context.bodyLarge.copyWith( + fontWeight: FontsManager.bold, + ), + ), + ], + ), + ], + ), + ), + listItem(wallSensorButtons[index], context, wallSensor) + ], + ); + } + return listItem(wallSensorButtons[index], context, wallSensor); + }, + ), + ), + ), + ); + } + + final List> wallSensorButtons = const [ + { + 'icon': Assets.presenceSensorAssetsTime, + 'title': 'Presence Time', + 'value': 0, + 'unit': 'min', + 'page': null, + }, + { + 'icon': Assets.presenceSensorAssetsDistance, + 'title': 'Current Distance', + 'value': 279, + 'unit': 'cm', + 'dialog': null, + }, + { + 'icon': Assets.presenceSensorAssetsIlluminanceValue, + 'title': 'Illuminance Value', + 'value': 0, + 'unit': 'Lux', + 'page': null, + }, + { + 'icon': Assets.presenceSensorAssetsEmpty, + 'title': 'Nobody Time', + 'value': 10, + 'unit': 'sec', + 'dialog': null, + }, + { + 'icon': Assets.presenceSensorAssetsIndicator, + 'title': 'Indicator', + 'page': null, + }, + { + 'icon': Assets.presenceSensorAssetsRecord, + 'title': 'Presence Record', + 'page': null, + }, + { + 'icon': Assets.presenceSensorAssetsIlluminanceRecord, + 'title': 'Illuminance Record', + 'page': null, + }, + ]; +} + +Widget listItem( + Map wallSensorButton, + BuildContext context, + DeviceModel wallSensor, +) { + return DefaultContainer( + margin: const EdgeInsets.only(bottom: 5), + padding: const EdgeInsets.symmetric(vertical: 12, horizontal: 20), + onTap: () { + if (wallSensorButton['page'] != null) { + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => wallSensorButton['page'] as Widget, + ), + ); + } + }, + child: Row( + children: [ + SvgPicture.asset( + wallSensorButton['icon'] as String, + ), + const SizedBox( + width: 25, + ), + BodyMedium(text: wallSensorButton['title'] as String), + if (wallSensorButton['value'] != null) const Spacer(), + if (wallSensorButton['value'] != null) + BodyMedium( + text: '${wallSensorButton['value']}${wallSensorButton['unit']}', + style: context.bodyMedium.copyWith(color: ColorsManager.greyColor), + ), + if (wallSensorButton['value'] != null) + if (wallSensorButton['title'] == 'Indicator') + Expanded( + child: Row( + mainAxisAlignment: MainAxisAlignment.end, + children: [ + Transform.scale( + scale: .8, + child: CupertinoSwitch( + value: false, + onChanged: (value) {}, + applyTheme: true, + )), + ], + ), + ), + // CustomSwitch(device: wallSensor), + if (wallSensorButton['title'] == 'Nobody Time') + const Row( + mainAxisAlignment: MainAxisAlignment.end, + children: [ + Icon( + Icons.arrow_forward_ios, + color: ColorsManager.greyColor, + size: 15, + ), + ], + ), + ], + ), + ); +} + +showParameterDialog( + BuildContext context, + String title, + DeviceModel wallSensor, + int value, + int min, + int max, +) { + showDialog( + context: context, + builder: (context) => Dialog( + child: Container( + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(20), + ), + padding: const EdgeInsets.only(top: 20), + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + BodyMedium( + text: title, + style: context.bodyMedium.copyWith( + color: ColorsManager.primaryColorWithOpacity, + fontWeight: FontsManager.extraBold, + ), + ), + Padding( + padding: const EdgeInsets.symmetric( + vertical: 15, + horizontal: 50, + ), + child: Container( + height: 1, + width: double.infinity, + color: ColorsManager.greyColor, + ), + ), + Padding( + padding: const EdgeInsets.symmetric( + vertical: 10, + ), + child: TitleMedium( + text: value.toString(), + style: context.titleMedium.copyWith( + color: Colors.black, + fontWeight: FontsManager.bold, + ), + ), + ), + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + // Icon(Icons.minus), + IconButton( + onPressed: () { + value--; + }, + icon: const Icon( + Icons.remove, + color: Colors.grey, + ), + ), + Slider( + value: value.toDouble(), + onChanged: (value) { + // value = value; + }, + min: 0, + max: 10, + label: value.toString(), + inactiveColor: ColorsManager.greyColor, + ), + IconButton( + onPressed: () { + value++; + }, + icon: const Icon( + Icons.add, + color: Colors.grey, + ), + ), + ], + ), + Container( + height: 1, + width: double.infinity, + color: ColorsManager.greyColor, + ), + Row( + children: [ + Expanded( + child: Center( + child: BodyMedium( + text: 'Cancel', + style: context.bodyMedium + .copyWith(color: ColorsManager.greyColor), + ), + )), + Container( + height: 50, + width: 1, + color: ColorsManager.greyColor, + ), + Expanded( + child: Center( + child: BodyMedium( + text: 'Confirm', + style: context.bodyMedium.copyWith( + color: ColorsManager.primaryColorWithOpacity), + ), + )), + ], + ) + ], + ), + ), + )); +} diff --git a/lib/features/devices/view/widgets/presence_sensor/presence_indicator.dart b/lib/features/devices/view/widgets/presence_sensor/presence_indicator.dart new file mode 100644 index 0000000..39c4d42 --- /dev/null +++ b/lib/features/devices/view/widgets/presence_sensor/presence_indicator.dart @@ -0,0 +1,29 @@ +part of "wall_sensor_interface.dart"; + +class PresenceIndicator extends StatelessWidget { + const PresenceIndicator({super.key}); + + @override + Widget build(BuildContext context) { + return Expanded( + flex: 6, + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + SvgPicture.asset( + Assets.presenceSensorAssetsPresence, + width: 100, + height: 100, + ), + const SizedBox( + height: 10, + ), + BodyMedium( + text: 'Presence', + style: context.bodyMedium.copyWith(fontWeight: FontsManager.bold), + ), + ], + ), + ); + } +} diff --git a/lib/features/devices/view/widgets/presence_sensor/wall_sensor_interface.dart b/lib/features/devices/view/widgets/presence_sensor/wall_sensor_interface.dart new file mode 100644 index 0000000..50bb721 --- /dev/null +++ b/lib/features/devices/view/widgets/presence_sensor/wall_sensor_interface.dart @@ -0,0 +1,68 @@ +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; +import 'package:flutter_svg/flutter_svg.dart'; +import 'package:syncrow_app/features/devices/model/device_model.dart'; +import 'package:syncrow_app/features/shared_widgets/default_container.dart'; +import 'package:syncrow_app/features/shared_widgets/text_widgets/body_large.dart'; +import 'package:syncrow_app/features/shared_widgets/text_widgets/body_medium.dart'; +import 'package:syncrow_app/features/shared_widgets/text_widgets/body_small.dart'; +import 'package:syncrow_app/features/shared_widgets/text_widgets/title_medium.dart'; +import 'package:syncrow_app/generated/assets.dart'; +import 'package:syncrow_app/utils/context_extension.dart'; +import 'package:syncrow_app/utils/resource_manager/color_manager.dart'; +import 'package:syncrow_app/utils/resource_manager/constants.dart'; +import 'package:syncrow_app/utils/resource_manager/font_manager.dart'; + +part "parameters_list.dart"; +part "presence_indicator.dart"; + +class WallMountedInterface extends StatelessWidget { + const WallMountedInterface({super.key, required this.wallSensor}); + final DeviceModel wallSensor; + @override + Widget build(BuildContext context) { + return AnnotatedRegion( + value: SystemUiOverlayStyle( + statusBarColor: ColorsManager.primaryColor.withOpacity(0.5), + statusBarIconBrightness: Brightness.light, + ), + child: SafeArea( + child: Scaffold( + backgroundColor: ColorsManager.backgroundColor, + extendBodyBehindAppBar: true, + extendBody: true, + appBar: AppBar( + backgroundColor: Colors.transparent, + centerTitle: true, + title: BodyLarge( + text: wallSensor.name ?? "", + fontColor: ColorsManager.primaryColor, + fontWeight: FontsManager.bold, + ), + ), + body: Container( + width: MediaQuery.sizeOf(context).width, + height: MediaQuery.sizeOf(context).height, + padding: const EdgeInsets.all(Constants.defaultPadding), + decoration: const BoxDecoration( + image: DecorationImage( + image: AssetImage( + Assets.imagesBackground, + ), + fit: BoxFit.cover, + opacity: 0.4, + ), + ), + child: Column( + children: [ + const PresenceIndicator(), + ParametersList(wallSensor: wallSensor), + ], + ), + ), + ), + ), + ); + } +} diff --git a/lib/features/devices/view/widgets/room_page_switch.dart b/lib/features/devices/view/widgets/room_page_switch.dart index 95e94c4..78ca6cc 100644 --- a/lib/features/devices/view/widgets/room_page_switch.dart +++ b/lib/features/devices/view/widgets/room_page_switch.dart @@ -11,6 +11,7 @@ import 'package:syncrow_app/features/devices/bloc/devices_cubit.dart'; import 'package:syncrow_app/features/devices/model/device_model.dart'; import 'package:syncrow_app/features/devices/view/widgets/ACs/ac_interface.dart'; import 'package:syncrow_app/features/devices/view/widgets/lights/light_interface.dart'; +import 'package:syncrow_app/features/devices/view/widgets/presence_sensor/wall_sensor_interface.dart'; import 'package:syncrow_app/features/devices/view/widgets/smart_door/door_interface.dart'; import 'package:syncrow_app/features/devices/view/widgets/three_gang/three_gang_interface.dart'; import 'package:syncrow_app/features/shared_widgets/custom_switch.dart'; @@ -85,6 +86,7 @@ void showDeviceInterface(DeviceModel device, BuildContext context) { navigateToInterface(AcInterface(ac: device), context); break; case DeviceType.WallSensor: + navigateToInterface(WallMountedInterface(wallSensor: device), context); break; case DeviceType.CeilingSensor: break; From bb56ea42c598145d98b5aafa70e5272bfc016a88 Mon Sep 17 00:00:00 2001 From: Mohammad Salameh Date: Fri, 19 Apr 2024 17:48:18 +0300 Subject: [PATCH 4/4] Remove unused imports Remove unused imports from multiple files in the project. --- lib/features/app_layout/view/app_layout.dart | 3 --- lib/features/devices/view/widgets/smart_door/door_grid.dart | 3 --- .../devices/view/widgets/smart_door/door_interface.dart | 5 ----- 3 files changed, 11 deletions(-) diff --git a/lib/features/app_layout/view/app_layout.dart b/lib/features/app_layout/view/app_layout.dart index d676045..cdb1725 100644 --- a/lib/features/app_layout/view/app_layout.dart +++ b/lib/features/app_layout/view/app_layout.dart @@ -6,9 +6,6 @@ import 'package:syncrow_app/features/app_layout/bloc/home_cubit.dart'; import 'package:syncrow_app/features/app_layout/view/widgets/app_body.dart'; import 'package:syncrow_app/features/app_layout/view/widgets/default_app_bar.dart'; import 'package:syncrow_app/features/app_layout/view/widgets/default_nav_bar.dart'; -import 'package:syncrow_app/features/auth/bloc/auth_cubit.dart'; -import 'package:syncrow_app/navigation/routing_constants.dart'; -import 'package:syncrow_app/utils/helpers/snack_bar.dart'; import 'package:syncrow_app/utils/resource_manager/color_manager.dart'; class AppLayout extends StatelessWidget { diff --git a/lib/features/devices/view/widgets/smart_door/door_grid.dart b/lib/features/devices/view/widgets/smart_door/door_grid.dart index 24a36cd..f739291 100644 --- a/lib/features/devices/view/widgets/smart_door/door_grid.dart +++ b/lib/features/devices/view/widgets/smart_door/door_grid.dart @@ -1,8 +1,5 @@ -import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; -import 'package:flutter/widgets.dart'; import 'package:flutter_svg/flutter_svg.dart'; -import 'package:syncrow_app/features/devices/view/widgets/smart_door/door_interface.dart'; import 'package:syncrow_app/features/shared_widgets/default_container.dart'; import 'package:syncrow_app/features/shared_widgets/text_widgets/body_small.dart'; import 'package:syncrow_app/generated/assets.dart'; diff --git a/lib/features/devices/view/widgets/smart_door/door_interface.dart b/lib/features/devices/view/widgets/smart_door/door_interface.dart index 8bc2104..cc5bcb2 100644 --- a/lib/features/devices/view/widgets/smart_door/door_interface.dart +++ b/lib/features/devices/view/widgets/smart_door/door_interface.dart @@ -1,16 +1,11 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; -import 'package:flutter/widgets.dart'; -import 'package:flutter_svg/flutter_svg.dart'; import 'package:syncrow_app/features/devices/model/device_model.dart'; import 'package:syncrow_app/features/devices/view/widgets/smart_door/door_button.dart'; import 'package:syncrow_app/features/devices/view/widgets/smart_door/door_grid.dart'; import 'package:syncrow_app/features/devices/view/widgets/smart_door/door_status_bar.dart'; -import 'package:syncrow_app/features/shared_widgets/default_container.dart'; import 'package:syncrow_app/features/shared_widgets/text_widgets/body_large.dart'; -import 'package:syncrow_app/features/shared_widgets/text_widgets/body_small.dart'; import 'package:syncrow_app/generated/assets.dart'; -import 'package:syncrow_app/utils/context_extension.dart'; import 'package:syncrow_app/utils/resource_manager/color_manager.dart'; import 'package:syncrow_app/utils/resource_manager/constants.dart'; import 'package:syncrow_app/utils/resource_manager/font_manager.dart';