From a1ebb930a20774187fc3dae5e8aae01b57a27501 Mon Sep 17 00:00:00 2001 From: ashrafzarkanisala Date: Sun, 25 Aug 2024 04:03:46 +0300 Subject: [PATCH] push living room status --- analysis_options.yaml | 3 + assets/functions_icons/ac_cooling.svg | 12 + assets/functions_icons/ac_fan_auto.svg | 9 + assets/functions_icons/ac_fan_high.svg | 12 + assets/functions_icons/ac_fan_low.svg | 12 + assets/functions_icons/ac_fan_middle.svg | 12 + assets/functions_icons/ac_heating.svg | 14 + assets/functions_icons/ac_power.svg | 5 + assets/functions_icons/ac_power_off.svg | 5 + .../automation_functions/card_unlock.svg | 14 + .../automation_functions/current_temp.svg | 11 + .../automation_functions/doorbell.svg | 13 + .../doorlock_normal_open.svg | 12 + .../automation_functions/double_lock.svg | 12 + .../fingerprint_unlock.svg | 79 +++++ .../automation_functions/hijack_alarm.svg | 13 + .../automation_functions/lock_alarm.svg | 149 ++++++++++ .../automation_functions/motion.svg | 14 + .../automation_functions/password_unlock.svg | 16 + .../automation_functions/presence.svg | 18 ++ .../automation_functions/presence_state.svg | 18 ++ .../remote_unlock_req.svg | 15 + .../remote_unlock_via_app.svg | 40 +++ .../residual_electricity.svg | 4 + .../automation_functions/self_test_result.svg | 23 ++ .../temp_password_unlock.svg | 16 + assets/functions_icons/celsius_degrees.svg | 7 + assets/functions_icons/child_lock.svg | 5 + assets/functions_icons/factory_reset.svg | 10 + assets/functions_icons/fan_speed.svg | 12 + assets/functions_icons/far_detection.svg | 16 + .../far_detection_function.svg | 17 ++ assets/functions_icons/freezing.svg | 3 + assets/functions_icons/indicator.svg | 12 + assets/functions_icons/light_countdown.svg | 42 +++ assets/functions_icons/light_pulb.svg | 37 +++ assets/functions_icons/master_state.svg | 18 ++ assets/functions_icons/motion_detection.svg | 21 ++ .../functions_icons/motionless_detection.svg | 6 + assets/functions_icons/nobody_time.svg | 4 + .../presence-sensor-assets/Distance.svg | 20 ++ .../presence-sensor-assets/Empty.svg | 4 + .../Illuminance-Record.svg | 21 ++ .../Illuminance-Value.svg | 18 ++ .../presence-sensor-assets/Indicator.svg | 12 + .../presence-sensor-assets/Presence.svg | 12 + .../presence-sensor-assets/Record.svg | 17 ++ .../presence-sensor-assets/Sensitivity.svg | 14 + .../presence-sensor-assets/Time.svg | 29 ++ .../help-description.svg | 16 + .../induction-recording.svg | 17 ++ .../maximum_distance.svg | 17 ++ .../parameter-settings.svg | 31 ++ .../presence-sensor-motion.svg | 31 ++ .../space_type_icon.svg | 10 + assets/functions_icons/reset_off.svg | 6 + assets/functions_icons/scene_child_lock.svg | 12 + assets/functions_icons/scene_child_unlock.svg | 12 + assets/functions_icons/scene_refresh.svg | 6 + assets/functions_icons/sensitivity.svg | 14 + .../sesitivity_operation_icon.svg | 5 + assets/functions_icons/switch_alarm_sound.svg | 10 + assets/functions_icons/tempreture.svg | 11 + lib/pages/common/custom_table.dart | 130 +++++---- .../bloc/device_managment_bloc.dart | 11 +- .../bloc/device_managment_event.dart | 9 + .../bloc/device_managment_state.dart | 17 +- .../all_devices/enum/ac_values_type.dart | 5 + .../all_devices/enum/status_type.dart | 9 + .../helper/route_controls_based_code.dart | 24 ++ .../all_devices/models/device_status.dart | 63 ++++ .../models/devices_model.dart | 4 +- .../{ => all_devices}/models/room.dart | 0 .../{ => all_devices}/models/unit.dart | 0 .../view/device_managment_page.dart | 4 +- .../widgets/device_managment_body.dart | 42 ++- .../widgets/device_search_filters.dart | 2 +- .../bloc/living_room_bloc.dart | 42 +++ .../bloc/living_room_event.dart | 29 ++ .../bloc/living_room_state.dart | 43 +++ .../control_list/cieling_light.dart | 70 +++++ .../control_list/spot_light.dart | 70 +++++ .../control_list/wall_light.dart | 70 +++++ .../helper/living_room_helper.dart | 20 ++ .../view/living_room_device_control.dart | 70 +++++ .../shared/device_control_dialog.dart | 275 ++++++++++++++++++ .../shared/increament_decreament.dart | 87 ++++++ lib/pages/home/bloc/home_bloc.dart | 2 +- .../view/add_device_dialog.dart | 2 +- lib/services/auth_api.dart | 2 +- lib/services/devices_mang_api.dart | 42 ++- lib/utils/color_manager.dart | 2 + lib/utils/constants/api_const.dart | 4 + lib/utils/constants/assets.dart | 110 +++++++ pubspec.yaml | 3 + 95 files changed, 2283 insertions(+), 86 deletions(-) create mode 100644 assets/functions_icons/ac_cooling.svg create mode 100644 assets/functions_icons/ac_fan_auto.svg create mode 100644 assets/functions_icons/ac_fan_high.svg create mode 100644 assets/functions_icons/ac_fan_low.svg create mode 100644 assets/functions_icons/ac_fan_middle.svg create mode 100644 assets/functions_icons/ac_heating.svg create mode 100644 assets/functions_icons/ac_power.svg create mode 100644 assets/functions_icons/ac_power_off.svg create mode 100644 assets/functions_icons/automation_functions/card_unlock.svg create mode 100644 assets/functions_icons/automation_functions/current_temp.svg create mode 100644 assets/functions_icons/automation_functions/doorbell.svg create mode 100644 assets/functions_icons/automation_functions/doorlock_normal_open.svg create mode 100644 assets/functions_icons/automation_functions/double_lock.svg create mode 100644 assets/functions_icons/automation_functions/fingerprint_unlock.svg create mode 100644 assets/functions_icons/automation_functions/hijack_alarm.svg create mode 100644 assets/functions_icons/automation_functions/lock_alarm.svg create mode 100644 assets/functions_icons/automation_functions/motion.svg create mode 100644 assets/functions_icons/automation_functions/password_unlock.svg create mode 100644 assets/functions_icons/automation_functions/presence.svg create mode 100644 assets/functions_icons/automation_functions/presence_state.svg create mode 100644 assets/functions_icons/automation_functions/remote_unlock_req.svg create mode 100644 assets/functions_icons/automation_functions/remote_unlock_via_app.svg create mode 100644 assets/functions_icons/automation_functions/residual_electricity.svg create mode 100644 assets/functions_icons/automation_functions/self_test_result.svg create mode 100644 assets/functions_icons/automation_functions/temp_password_unlock.svg create mode 100644 assets/functions_icons/celsius_degrees.svg create mode 100644 assets/functions_icons/child_lock.svg create mode 100644 assets/functions_icons/factory_reset.svg create mode 100644 assets/functions_icons/fan_speed.svg create mode 100644 assets/functions_icons/far_detection.svg create mode 100644 assets/functions_icons/far_detection_function.svg create mode 100644 assets/functions_icons/freezing.svg create mode 100644 assets/functions_icons/indicator.svg create mode 100644 assets/functions_icons/light_countdown.svg create mode 100644 assets/functions_icons/light_pulb.svg create mode 100644 assets/functions_icons/master_state.svg create mode 100644 assets/functions_icons/motion_detection.svg create mode 100644 assets/functions_icons/motionless_detection.svg create mode 100644 assets/functions_icons/nobody_time.svg create mode 100644 assets/functions_icons/presence-sensor-assets/Distance.svg create mode 100644 assets/functions_icons/presence-sensor-assets/Empty.svg create mode 100644 assets/functions_icons/presence-sensor-assets/Illuminance-Record.svg create mode 100644 assets/functions_icons/presence-sensor-assets/Illuminance-Value.svg create mode 100644 assets/functions_icons/presence-sensor-assets/Indicator.svg create mode 100644 assets/functions_icons/presence-sensor-assets/Presence.svg create mode 100644 assets/functions_icons/presence-sensor-assets/Record.svg create mode 100644 assets/functions_icons/presence-sensor-assets/Sensitivity.svg create mode 100644 assets/functions_icons/presence-sensor-assets/Time.svg create mode 100644 assets/functions_icons/presence-sensor-assets/help-description.svg create mode 100644 assets/functions_icons/presence-sensor-assets/induction-recording.svg create mode 100644 assets/functions_icons/presence-sensor-assets/maximum_distance.svg create mode 100644 assets/functions_icons/presence-sensor-assets/parameter-settings.svg create mode 100644 assets/functions_icons/presence-sensor-assets/presence-sensor-motion.svg create mode 100644 assets/functions_icons/presence-sensor-assets/space_type_icon.svg create mode 100644 assets/functions_icons/reset_off.svg create mode 100644 assets/functions_icons/scene_child_lock.svg create mode 100644 assets/functions_icons/scene_child_unlock.svg create mode 100644 assets/functions_icons/scene_refresh.svg create mode 100644 assets/functions_icons/sensitivity.svg create mode 100644 assets/functions_icons/sesitivity_operation_icon.svg create mode 100644 assets/functions_icons/switch_alarm_sound.svg create mode 100644 assets/functions_icons/tempreture.svg rename lib/pages/device_managment/{ => all_devices}/bloc/device_managment_bloc.dart (91%) rename lib/pages/device_managment/{ => all_devices}/bloc/device_managment_event.dart (82%) rename lib/pages/device_managment/{ => all_devices}/bloc/device_managment_state.dart (78%) create mode 100644 lib/pages/device_managment/all_devices/enum/ac_values_type.dart create mode 100644 lib/pages/device_managment/all_devices/enum/status_type.dart create mode 100644 lib/pages/device_managment/all_devices/helper/route_controls_based_code.dart create mode 100644 lib/pages/device_managment/all_devices/models/device_status.dart rename lib/pages/device_managment/{ => all_devices}/models/devices_model.dart (96%) rename lib/pages/device_managment/{ => all_devices}/models/room.dart (100%) rename lib/pages/device_managment/{ => all_devices}/models/unit.dart (100%) rename lib/pages/device_managment/{ => all_devices}/view/device_managment_page.dart (86%) rename lib/pages/device_managment/{ => all_devices}/widgets/device_managment_body.dart (76%) rename lib/pages/device_managment/{ => all_devices}/widgets/device_search_filters.dart (96%) create mode 100644 lib/pages/device_managment/living_room_switch/bloc/living_room_bloc.dart create mode 100644 lib/pages/device_managment/living_room_switch/bloc/living_room_event.dart create mode 100644 lib/pages/device_managment/living_room_switch/bloc/living_room_state.dart create mode 100644 lib/pages/device_managment/living_room_switch/control_list/cieling_light.dart create mode 100644 lib/pages/device_managment/living_room_switch/control_list/spot_light.dart create mode 100644 lib/pages/device_managment/living_room_switch/control_list/wall_light.dart create mode 100644 lib/pages/device_managment/living_room_switch/helper/living_room_helper.dart create mode 100644 lib/pages/device_managment/living_room_switch/view/living_room_device_control.dart create mode 100644 lib/pages/device_managment/shared/device_control_dialog.dart create mode 100644 lib/pages/device_managment/shared/increament_decreament.dart diff --git a/analysis_options.yaml b/analysis_options.yaml index 0d290213..2e349a87 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -7,6 +7,9 @@ # The following line activates a set of recommended lints for Flutter apps, # packages, and plugins designed to encourage good coding practices. +analyzer: + errors: + constant_identifier_names: ignore include: package:flutter_lints/flutter.yaml linter: diff --git a/assets/functions_icons/ac_cooling.svg b/assets/functions_icons/ac_cooling.svg new file mode 100644 index 00000000..e95c0d4e --- /dev/null +++ b/assets/functions_icons/ac_cooling.svg @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/assets/functions_icons/ac_fan_auto.svg b/assets/functions_icons/ac_fan_auto.svg new file mode 100644 index 00000000..0acacfef --- /dev/null +++ b/assets/functions_icons/ac_fan_auto.svg @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/assets/functions_icons/ac_fan_high.svg b/assets/functions_icons/ac_fan_high.svg new file mode 100644 index 00000000..d6131531 --- /dev/null +++ b/assets/functions_icons/ac_fan_high.svg @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/assets/functions_icons/ac_fan_low.svg b/assets/functions_icons/ac_fan_low.svg new file mode 100644 index 00000000..f4bf56b7 --- /dev/null +++ b/assets/functions_icons/ac_fan_low.svg @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/assets/functions_icons/ac_fan_middle.svg b/assets/functions_icons/ac_fan_middle.svg new file mode 100644 index 00000000..ee940238 --- /dev/null +++ b/assets/functions_icons/ac_fan_middle.svg @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/assets/functions_icons/ac_heating.svg b/assets/functions_icons/ac_heating.svg new file mode 100644 index 00000000..47a160c8 --- /dev/null +++ b/assets/functions_icons/ac_heating.svg @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/assets/functions_icons/ac_power.svg b/assets/functions_icons/ac_power.svg new file mode 100644 index 00000000..cc2127f0 --- /dev/null +++ b/assets/functions_icons/ac_power.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/assets/functions_icons/ac_power_off.svg b/assets/functions_icons/ac_power_off.svg new file mode 100644 index 00000000..70f7f9aa --- /dev/null +++ b/assets/functions_icons/ac_power_off.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/assets/functions_icons/automation_functions/card_unlock.svg b/assets/functions_icons/automation_functions/card_unlock.svg new file mode 100644 index 00000000..dd77680a --- /dev/null +++ b/assets/functions_icons/automation_functions/card_unlock.svg @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/assets/functions_icons/automation_functions/current_temp.svg b/assets/functions_icons/automation_functions/current_temp.svg new file mode 100644 index 00000000..42cceb23 --- /dev/null +++ b/assets/functions_icons/automation_functions/current_temp.svg @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/assets/functions_icons/automation_functions/doorbell.svg b/assets/functions_icons/automation_functions/doorbell.svg new file mode 100644 index 00000000..1dc515a9 --- /dev/null +++ b/assets/functions_icons/automation_functions/doorbell.svg @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/assets/functions_icons/automation_functions/doorlock_normal_open.svg b/assets/functions_icons/automation_functions/doorlock_normal_open.svg new file mode 100644 index 00000000..8f4a5901 --- /dev/null +++ b/assets/functions_icons/automation_functions/doorlock_normal_open.svg @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/assets/functions_icons/automation_functions/double_lock.svg b/assets/functions_icons/automation_functions/double_lock.svg new file mode 100644 index 00000000..d8ad971d --- /dev/null +++ b/assets/functions_icons/automation_functions/double_lock.svg @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/assets/functions_icons/automation_functions/fingerprint_unlock.svg b/assets/functions_icons/automation_functions/fingerprint_unlock.svg new file mode 100644 index 00000000..f9f5b84c --- /dev/null +++ b/assets/functions_icons/automation_functions/fingerprint_unlock.svg @@ -0,0 +1,79 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/functions_icons/automation_functions/hijack_alarm.svg b/assets/functions_icons/automation_functions/hijack_alarm.svg new file mode 100644 index 00000000..e32997fb --- /dev/null +++ b/assets/functions_icons/automation_functions/hijack_alarm.svg @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/assets/functions_icons/automation_functions/lock_alarm.svg b/assets/functions_icons/automation_functions/lock_alarm.svg new file mode 100644 index 00000000..8bd2deeb --- /dev/null +++ b/assets/functions_icons/automation_functions/lock_alarm.svg @@ -0,0 +1,149 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/functions_icons/automation_functions/motion.svg b/assets/functions_icons/automation_functions/motion.svg new file mode 100644 index 00000000..8d69463b --- /dev/null +++ b/assets/functions_icons/automation_functions/motion.svg @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/assets/functions_icons/automation_functions/password_unlock.svg b/assets/functions_icons/automation_functions/password_unlock.svg new file mode 100644 index 00000000..1920b69f --- /dev/null +++ b/assets/functions_icons/automation_functions/password_unlock.svg @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + diff --git a/assets/functions_icons/automation_functions/presence.svg b/assets/functions_icons/automation_functions/presence.svg new file mode 100644 index 00000000..d71a474d --- /dev/null +++ b/assets/functions_icons/automation_functions/presence.svg @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + diff --git a/assets/functions_icons/automation_functions/presence_state.svg b/assets/functions_icons/automation_functions/presence_state.svg new file mode 100644 index 00000000..d5de48e1 --- /dev/null +++ b/assets/functions_icons/automation_functions/presence_state.svg @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + diff --git a/assets/functions_icons/automation_functions/remote_unlock_req.svg b/assets/functions_icons/automation_functions/remote_unlock_req.svg new file mode 100644 index 00000000..da128ff7 --- /dev/null +++ b/assets/functions_icons/automation_functions/remote_unlock_req.svg @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff --git a/assets/functions_icons/automation_functions/remote_unlock_via_app.svg b/assets/functions_icons/automation_functions/remote_unlock_via_app.svg new file mode 100644 index 00000000..39fc859b --- /dev/null +++ b/assets/functions_icons/automation_functions/remote_unlock_via_app.svg @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/functions_icons/automation_functions/residual_electricity.svg b/assets/functions_icons/automation_functions/residual_electricity.svg new file mode 100644 index 00000000..6a5b6127 --- /dev/null +++ b/assets/functions_icons/automation_functions/residual_electricity.svg @@ -0,0 +1,4 @@ + + + + diff --git a/assets/functions_icons/automation_functions/self_test_result.svg b/assets/functions_icons/automation_functions/self_test_result.svg new file mode 100644 index 00000000..8739327b --- /dev/null +++ b/assets/functions_icons/automation_functions/self_test_result.svg @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/functions_icons/automation_functions/temp_password_unlock.svg b/assets/functions_icons/automation_functions/temp_password_unlock.svg new file mode 100644 index 00000000..98d7573c --- /dev/null +++ b/assets/functions_icons/automation_functions/temp_password_unlock.svg @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + diff --git a/assets/functions_icons/celsius_degrees.svg b/assets/functions_icons/celsius_degrees.svg new file mode 100644 index 00000000..7acbd6e7 --- /dev/null +++ b/assets/functions_icons/celsius_degrees.svg @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/assets/functions_icons/child_lock.svg b/assets/functions_icons/child_lock.svg new file mode 100644 index 00000000..6b0138bf --- /dev/null +++ b/assets/functions_icons/child_lock.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/assets/functions_icons/factory_reset.svg b/assets/functions_icons/factory_reset.svg new file mode 100644 index 00000000..7a47f24b --- /dev/null +++ b/assets/functions_icons/factory_reset.svg @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/assets/functions_icons/fan_speed.svg b/assets/functions_icons/fan_speed.svg new file mode 100644 index 00000000..07a48834 --- /dev/null +++ b/assets/functions_icons/fan_speed.svg @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/assets/functions_icons/far_detection.svg b/assets/functions_icons/far_detection.svg new file mode 100644 index 00000000..2827d94a --- /dev/null +++ b/assets/functions_icons/far_detection.svg @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + diff --git a/assets/functions_icons/far_detection_function.svg b/assets/functions_icons/far_detection_function.svg new file mode 100644 index 00000000..894b84ed --- /dev/null +++ b/assets/functions_icons/far_detection_function.svg @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + diff --git a/assets/functions_icons/freezing.svg b/assets/functions_icons/freezing.svg new file mode 100644 index 00000000..6c02f2e4 --- /dev/null +++ b/assets/functions_icons/freezing.svg @@ -0,0 +1,3 @@ + + + diff --git a/assets/functions_icons/indicator.svg b/assets/functions_icons/indicator.svg new file mode 100644 index 00000000..b58a976e --- /dev/null +++ b/assets/functions_icons/indicator.svg @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/assets/functions_icons/light_countdown.svg b/assets/functions_icons/light_countdown.svg new file mode 100644 index 00000000..94f65b9a --- /dev/null +++ b/assets/functions_icons/light_countdown.svg @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/functions_icons/light_pulb.svg b/assets/functions_icons/light_pulb.svg new file mode 100644 index 00000000..c442fdaf --- /dev/null +++ b/assets/functions_icons/light_pulb.svg @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/functions_icons/master_state.svg b/assets/functions_icons/master_state.svg new file mode 100644 index 00000000..0aafae1a --- /dev/null +++ b/assets/functions_icons/master_state.svg @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + diff --git a/assets/functions_icons/motion_detection.svg b/assets/functions_icons/motion_detection.svg new file mode 100644 index 00000000..a9b2d685 --- /dev/null +++ b/assets/functions_icons/motion_detection.svg @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/functions_icons/motionless_detection.svg b/assets/functions_icons/motionless_detection.svg new file mode 100644 index 00000000..25a767c1 --- /dev/null +++ b/assets/functions_icons/motionless_detection.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/assets/functions_icons/nobody_time.svg b/assets/functions_icons/nobody_time.svg new file mode 100644 index 00000000..df80b517 --- /dev/null +++ b/assets/functions_icons/nobody_time.svg @@ -0,0 +1,4 @@ + + + + diff --git a/assets/functions_icons/presence-sensor-assets/Distance.svg b/assets/functions_icons/presence-sensor-assets/Distance.svg new file mode 100644 index 00000000..50578147 --- /dev/null +++ b/assets/functions_icons/presence-sensor-assets/Distance.svg @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/assets/functions_icons/presence-sensor-assets/Empty.svg b/assets/functions_icons/presence-sensor-assets/Empty.svg new file mode 100644 index 00000000..cf1e5df5 --- /dev/null +++ b/assets/functions_icons/presence-sensor-assets/Empty.svg @@ -0,0 +1,4 @@ + + + + diff --git a/assets/functions_icons/presence-sensor-assets/Illuminance-Record.svg b/assets/functions_icons/presence-sensor-assets/Illuminance-Record.svg new file mode 100644 index 00000000..5f642436 --- /dev/null +++ b/assets/functions_icons/presence-sensor-assets/Illuminance-Record.svg @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/functions_icons/presence-sensor-assets/Illuminance-Value.svg b/assets/functions_icons/presence-sensor-assets/Illuminance-Value.svg new file mode 100644 index 00000000..c087b7cd --- /dev/null +++ b/assets/functions_icons/presence-sensor-assets/Illuminance-Value.svg @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + diff --git a/assets/functions_icons/presence-sensor-assets/Indicator.svg b/assets/functions_icons/presence-sensor-assets/Indicator.svg new file mode 100644 index 00000000..600d6da4 --- /dev/null +++ b/assets/functions_icons/presence-sensor-assets/Indicator.svg @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/assets/functions_icons/presence-sensor-assets/Presence.svg b/assets/functions_icons/presence-sensor-assets/Presence.svg new file mode 100644 index 00000000..638cb391 --- /dev/null +++ b/assets/functions_icons/presence-sensor-assets/Presence.svg @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/assets/functions_icons/presence-sensor-assets/Record.svg b/assets/functions_icons/presence-sensor-assets/Record.svg new file mode 100644 index 00000000..ff39c7ff --- /dev/null +++ b/assets/functions_icons/presence-sensor-assets/Record.svg @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + diff --git a/assets/functions_icons/presence-sensor-assets/Sensitivity.svg b/assets/functions_icons/presence-sensor-assets/Sensitivity.svg new file mode 100644 index 00000000..bac78f75 --- /dev/null +++ b/assets/functions_icons/presence-sensor-assets/Sensitivity.svg @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/assets/functions_icons/presence-sensor-assets/Time.svg b/assets/functions_icons/presence-sensor-assets/Time.svg new file mode 100644 index 00000000..f5b43adb --- /dev/null +++ b/assets/functions_icons/presence-sensor-assets/Time.svg @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/functions_icons/presence-sensor-assets/help-description.svg b/assets/functions_icons/presence-sensor-assets/help-description.svg new file mode 100644 index 00000000..1dd6f197 --- /dev/null +++ b/assets/functions_icons/presence-sensor-assets/help-description.svg @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + diff --git a/assets/functions_icons/presence-sensor-assets/induction-recording.svg b/assets/functions_icons/presence-sensor-assets/induction-recording.svg new file mode 100644 index 00000000..97e2c460 --- /dev/null +++ b/assets/functions_icons/presence-sensor-assets/induction-recording.svg @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + diff --git a/assets/functions_icons/presence-sensor-assets/maximum_distance.svg b/assets/functions_icons/presence-sensor-assets/maximum_distance.svg new file mode 100644 index 00000000..9b0faa1c --- /dev/null +++ b/assets/functions_icons/presence-sensor-assets/maximum_distance.svg @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + diff --git a/assets/functions_icons/presence-sensor-assets/parameter-settings.svg b/assets/functions_icons/presence-sensor-assets/parameter-settings.svg new file mode 100644 index 00000000..a9966354 --- /dev/null +++ b/assets/functions_icons/presence-sensor-assets/parameter-settings.svg @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/functions_icons/presence-sensor-assets/presence-sensor-motion.svg b/assets/functions_icons/presence-sensor-assets/presence-sensor-motion.svg new file mode 100644 index 00000000..6d33deb7 --- /dev/null +++ b/assets/functions_icons/presence-sensor-assets/presence-sensor-motion.svg @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/functions_icons/presence-sensor-assets/space_type_icon.svg b/assets/functions_icons/presence-sensor-assets/space_type_icon.svg new file mode 100644 index 00000000..198948f2 --- /dev/null +++ b/assets/functions_icons/presence-sensor-assets/space_type_icon.svg @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/assets/functions_icons/reset_off.svg b/assets/functions_icons/reset_off.svg new file mode 100644 index 00000000..eac88f2b --- /dev/null +++ b/assets/functions_icons/reset_off.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/assets/functions_icons/scene_child_lock.svg b/assets/functions_icons/scene_child_lock.svg new file mode 100644 index 00000000..7e56164a --- /dev/null +++ b/assets/functions_icons/scene_child_lock.svg @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/assets/functions_icons/scene_child_unlock.svg b/assets/functions_icons/scene_child_unlock.svg new file mode 100644 index 00000000..4eafbdea --- /dev/null +++ b/assets/functions_icons/scene_child_unlock.svg @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/assets/functions_icons/scene_refresh.svg b/assets/functions_icons/scene_refresh.svg new file mode 100644 index 00000000..c54ffb04 --- /dev/null +++ b/assets/functions_icons/scene_refresh.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/assets/functions_icons/sensitivity.svg b/assets/functions_icons/sensitivity.svg new file mode 100644 index 00000000..b75ebd3e --- /dev/null +++ b/assets/functions_icons/sensitivity.svg @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/assets/functions_icons/sesitivity_operation_icon.svg b/assets/functions_icons/sesitivity_operation_icon.svg new file mode 100644 index 00000000..612148c5 --- /dev/null +++ b/assets/functions_icons/sesitivity_operation_icon.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/assets/functions_icons/switch_alarm_sound.svg b/assets/functions_icons/switch_alarm_sound.svg new file mode 100644 index 00000000..db645338 --- /dev/null +++ b/assets/functions_icons/switch_alarm_sound.svg @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/assets/functions_icons/tempreture.svg b/assets/functions_icons/tempreture.svg new file mode 100644 index 00000000..448083a7 --- /dev/null +++ b/assets/functions_icons/tempreture.svg @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/lib/pages/common/custom_table.dart b/lib/pages/common/custom_table.dart index 63fdc28a..61094c6f 100644 --- a/lib/pages/common/custom_table.dart +++ b/lib/pages/common/custom_table.dart @@ -12,7 +12,7 @@ class DynamicTable extends StatefulWidget { final bool withCheckBox; final bool isEmpty; final void Function(bool?)? selectAll; - final void Function(int, bool?)? onRowCheckboxChanged; + final void Function(int, bool, dynamic)? onRowSelected; final List? initialSelectedIds; const DynamicTable({ @@ -25,7 +25,7 @@ class DynamicTable extends StatefulWidget { this.headerDecoration, this.cellDecoration, this.selectAll, - this.onRowCheckboxChanged, + this.onRowSelected, this.initialSelectedIds, }); @@ -35,7 +35,6 @@ class DynamicTable extends StatefulWidget { class _DynamicTableState extends State { late List _selected; - bool _selectAll = false; @override void initState() { @@ -44,25 +43,19 @@ class _DynamicTableState extends State { return widget.initialSelectedIds != null && widget.initialSelectedIds!.contains(widget.data[index][1]); }); - _selectAll = _selected.every((element) => element == true); } - void _toggleSelectAll(bool? value) { + void _toggleRowSelection(int index) { setState(() { - _selectAll = value ?? false; - _selected = List.filled(widget.data.length, _selectAll); - if (widget.selectAll != null) { - widget.selectAll!(_selectAll); + // Deselect all rows + for (int i = 0; i < _selected.length; i++) { + _selected[i] = false; } - }); - } + // Select the clicked row + _selected[index] = true; - void _toggleRowSelection(int index, bool? value) { - setState(() { - _selected[index] = value ?? false; - _selectAll = _selected.every((element) => element == true); - if (widget.onRowCheckboxChanged != null) { - widget.onRowCheckboxChanged!(index, _selected[index]); + if (widget.onRowSelected != null) { + widget.onRowSelected!(index, true, widget.data[index]); } }); } @@ -108,7 +101,7 @@ class _DynamicTableState extends State { height: 15, ), Text( - 'No Passwords', + 'No Devices', style: Theme.of(context) .textTheme .bodySmall! @@ -157,81 +150,104 @@ class _DynamicTableState extends State { Widget _buildSelectAllCheckbox() { return Container( + width: 50, // Fixed width to align with the checkbox column padding: const EdgeInsets.all(8.0), decoration: const BoxDecoration( - border: Border.symmetric( - vertical: BorderSide(color: ColorsManager.boxDivider))), + border: Border.symmetric( + vertical: BorderSide(color: ColorsManager.boxDivider), + ), + ), child: Checkbox( - value: _selectAll, - onChanged: _toggleSelectAll, + value: _selected.every((element) => element == true), + onChanged: null, // Disabling the toggle as we're not using select all ), ); } - Widget _buildRowCheckbox(int index, size) { + Widget _buildRowCheckbox(int index, double size) { return Container( - padding: const EdgeInsets.all(8.0), - height: size, - decoration: const BoxDecoration( - border: Border( + width: 50, // Fixed width to align with the checkbox column + padding: const EdgeInsets.all(8.0), + height: size, + decoration: const BoxDecoration( + border: Border( bottom: BorderSide( color: ColorsManager.boxDivider, width: 1.0, ), - )), - alignment: Alignment.centerLeft, - child: Center( - child: Checkbox( - value: _selected[index], - onChanged: (bool? value) { - _toggleRowSelection(index, value); - }, - ), - )); + ), + ), + alignment: Alignment.centerLeft, + child: Center( + child: Checkbox( + value: _selected[index], + onChanged: (bool? value) { + _toggleRowSelection(index); + }, + ), + ), + ); } Widget _buildTableHeaderCell(String title) { return Expanded( child: Container( decoration: const BoxDecoration( - border: Border.symmetric( - vertical: BorderSide(color: ColorsManager.boxDivider))), + border: Border.symmetric( + vertical: BorderSide(color: ColorsManager.boxDivider), + ), + ), alignment: Alignment.centerLeft, child: Padding( padding: const EdgeInsets.all(8.0), - child: Text(title, - style: const TextStyle( - fontWeight: FontWeight.w400, - fontSize: 13, - color: Color(0xFF999999))), + child: Text( + title, + style: const TextStyle( + fontWeight: FontWeight.w400, + fontSize: 13, + color: Color(0xFF999999), + ), + ), ), ), ); } - Widget _buildTableCell(String content, size) { + Widget _buildTableCell(String content, double size) { + // Check if the content is a battery level percentage + bool isBatteryLevel = content.endsWith('%'); + double? batteryLevel; + + if (isBatteryLevel) { + batteryLevel = double.tryParse(content.replaceAll('%', '').trim()); + } + return Expanded( child: Container( height: size, padding: const EdgeInsets.all(5.0), decoration: const BoxDecoration( - border: Border( - bottom: BorderSide( - color: ColorsManager.boxDivider, - width: 1.0, + border: Border( + bottom: BorderSide( + color: ColorsManager.boxDivider, + width: 1.0, + ), ), - )), + ), alignment: Alignment.centerLeft, child: Text( content, style: TextStyle( - color: content == 'Online' - ? ColorsManager.green - : content == 'Offline' - ? ColorsManager.red - : Colors.black, - fontSize: 12, - fontWeight: FontWeight.w400), + color: batteryLevel != null && batteryLevel < 20 + ? ColorsManager.red // Red color for low battery + : content == 'Online' + ? ColorsManager.green // Green color for Online + : content == 'Offline' + ? ColorsManager.red // Red color for Offline + : Colors.black, + fontSize: 12, + fontWeight: FontWeight.w400, + ), ), ), ); diff --git a/lib/pages/device_managment/bloc/device_managment_bloc.dart b/lib/pages/device_managment/all_devices/bloc/device_managment_bloc.dart similarity index 91% rename from lib/pages/device_managment/bloc/device_managment_bloc.dart rename to lib/pages/device_managment/all_devices/bloc/device_managment_bloc.dart index edc6e7ba..8f9b9bc3 100644 --- a/lib/pages/device_managment/bloc/device_managment_bloc.dart +++ b/lib/pages/device_managment/all_devices/bloc/device_managment_bloc.dart @@ -1,6 +1,6 @@ import 'package:bloc/bloc.dart'; import 'package:equatable/equatable.dart'; -import 'package:syncrow_web/pages/device_managment/models/devices_model.dart'; +import 'package:syncrow_web/pages/device_managment/all_devices/models/devices_model.dart'; import 'package:syncrow_web/services/devices_mang_api.dart'; part 'device_managment_event.dart'; @@ -13,12 +13,14 @@ class DeviceManagementBloc int _onlineCount = 0; int _offlineCount = 0; int _lowBatteryCount = 0; + AllDevicesModel? _selectedDevice; DeviceManagementBloc() : super(DeviceManagementInitial()) { on(_onFetchDevices); on(_onFilterDevices); on(_onSelectedFilterChanged); on(_onSearchDevices); + on(_onSelectDevice); } Future _onFetchDevices( @@ -71,6 +73,11 @@ class DeviceManagementBloc add(FilterDevices(_getFilterFromIndex(_selectedIndex))); } + void _onSelectDevice( + SelectDevice event, Emitter emit) { + _selectedDevice = event.selectedDevice; + } + void _calculateDeviceCounts() { _onlineCount = _devices.where((device) => device.online == true).length; _offlineCount = _devices.where((device) => device.online == false).length; @@ -127,4 +134,6 @@ class DeviceManagementBloc )); } } + + AllDevicesModel? get selectedDevice => _selectedDevice; } diff --git a/lib/pages/device_managment/bloc/device_managment_event.dart b/lib/pages/device_managment/all_devices/bloc/device_managment_event.dart similarity index 82% rename from lib/pages/device_managment/bloc/device_managment_event.dart rename to lib/pages/device_managment/all_devices/bloc/device_managment_event.dart index a03b2659..444f3406 100644 --- a/lib/pages/device_managment/bloc/device_managment_event.dart +++ b/lib/pages/device_managment/all_devices/bloc/device_managment_event.dart @@ -41,3 +41,12 @@ class SearchDevices extends DeviceManagementEvent { @override List get props => [community, unitName, productName]; } + +class SelectDevice extends DeviceManagementEvent { + final AllDevicesModel selectedDevice; + + const SelectDevice(this.selectedDevice); + + @override + List get props => [selectedDevice]; +} diff --git a/lib/pages/device_managment/bloc/device_managment_state.dart b/lib/pages/device_managment/all_devices/bloc/device_managment_state.dart similarity index 78% rename from lib/pages/device_managment/bloc/device_managment_state.dart rename to lib/pages/device_managment/all_devices/bloc/device_managment_state.dart index 4b2cacd7..48166afb 100644 --- a/lib/pages/device_managment/bloc/device_managment_state.dart +++ b/lib/pages/device_managment/all_devices/bloc/device_managment_state.dart @@ -17,6 +17,7 @@ class DeviceManagementLoaded extends DeviceManagementState { final int onlineCount; final int offlineCount; final int lowBatteryCount; + final AllDevicesModel? selectedDevice; const DeviceManagementLoaded({ required this.devices, @@ -24,11 +25,18 @@ class DeviceManagementLoaded extends DeviceManagementState { required this.onlineCount, required this.offlineCount, required this.lowBatteryCount, + this.selectedDevice, }); @override - List get props => - [devices, selectedIndex, onlineCount, offlineCount, lowBatteryCount]; + List get props => [ + devices, + selectedIndex, + onlineCount, + offlineCount, + lowBatteryCount, + selectedDevice + ]; } class DeviceManagementFiltered extends DeviceManagementState { @@ -37,6 +45,7 @@ class DeviceManagementFiltered extends DeviceManagementState { final int onlineCount; final int offlineCount; final int lowBatteryCount; + final AllDevicesModel? selectedDevice; const DeviceManagementFiltered({ required this.filteredDevices, @@ -44,6 +53,7 @@ class DeviceManagementFiltered extends DeviceManagementState { required this.onlineCount, required this.offlineCount, required this.lowBatteryCount, + this.selectedDevice, }); @override @@ -52,6 +62,7 @@ class DeviceManagementFiltered extends DeviceManagementState { selectedIndex, onlineCount, offlineCount, - lowBatteryCount + lowBatteryCount, + selectedDevice ]; } diff --git a/lib/pages/device_managment/all_devices/enum/ac_values_type.dart b/lib/pages/device_managment/all_devices/enum/ac_values_type.dart new file mode 100644 index 00000000..19611ca5 --- /dev/null +++ b/lib/pages/device_managment/all_devices/enum/ac_values_type.dart @@ -0,0 +1,5 @@ +enum AcValuesEnums { + Cooling, + Heating, + Ventilation, +} diff --git a/lib/pages/device_managment/all_devices/enum/status_type.dart b/lib/pages/device_managment/all_devices/enum/status_type.dart new file mode 100644 index 00000000..b1829b15 --- /dev/null +++ b/lib/pages/device_managment/all_devices/enum/status_type.dart @@ -0,0 +1,9 @@ +enum OperationDialogType { + countdown, + delay, + temperature, + onOff, + integerSteps, + listOfOptions, + none, +} diff --git a/lib/pages/device_managment/all_devices/helper/route_controls_based_code.dart b/lib/pages/device_managment/all_devices/helper/route_controls_based_code.dart new file mode 100644 index 00000000..a4556753 --- /dev/null +++ b/lib/pages/device_managment/all_devices/helper/route_controls_based_code.dart @@ -0,0 +1,24 @@ +import 'package:flutter/material.dart'; +import 'package:syncrow_web/pages/device_managment/all_devices/models/devices_model.dart'; +import 'package:syncrow_web/pages/device_managment/living_room_switch/view/living_room_device_control.dart'; + +mixin RouteControlsBasedCode { + Widget routeControlsWidgets({required AllDevicesModel device}) { + switch (device.categoryName) { + case 'Switch': + return LivingRoomDeviceControl( + device: device, + ); + case 'Gateway': + return const SizedBox(); + case 'Residential Lock PRO': + return const SizedBox(); + case 'Human Presence Sensor': + return const SizedBox(); + case 'Thermostat': + return const SizedBox(); + default: + return const SizedBox(); + } + } +} diff --git a/lib/pages/device_managment/all_devices/models/device_status.dart b/lib/pages/device_managment/all_devices/models/device_status.dart new file mode 100644 index 00000000..b78f2a30 --- /dev/null +++ b/lib/pages/device_managment/all_devices/models/device_status.dart @@ -0,0 +1,63 @@ +import 'dart:convert'; + +class DeviceStatus { + final String productUuid; + final String productType; + final List status; + + DeviceStatus({ + required this.productUuid, + required this.productType, + required this.status, + }); + + factory DeviceStatus.fromMap(Map map) { + return DeviceStatus( + productUuid: map['productUuid'] ?? '', + productType: map['productType'] ?? '', + status: List.from( + map['status']?.map((x) => Status.fromMap(x)) ?? const []), + ); + } + + Map toMap() { + return { + 'productUuid': productUuid, + 'productType': productType, + 'status': status.map((x) => x.toMap()).toList(), + }; + } + + factory DeviceStatus.fromJson(Map json) => + DeviceStatus.fromMap(json); + + String toJson() => json.encode(toMap()); +} + +class Status { + final String code; + final dynamic value; + + Status({ + required this.code, + required this.value, + }); + + factory Status.fromMap(Map map) { + return Status( + code: map['code'] ?? '', + value: map['value'], + ); + } + + Map toMap() { + return { + 'code': code, + 'value': value, + }; + } + + factory Status.fromJson(String source) => Status.fromMap(json.decode(source)); + + String toJson() => json.encode(toMap()); +} diff --git a/lib/pages/device_managment/models/devices_model.dart b/lib/pages/device_managment/all_devices/models/devices_model.dart similarity index 96% rename from lib/pages/device_managment/models/devices_model.dart rename to lib/pages/device_managment/all_devices/models/devices_model.dart index 5ee2d05f..48e99a1a 100644 --- a/lib/pages/device_managment/models/devices_model.dart +++ b/lib/pages/device_managment/all_devices/models/devices_model.dart @@ -1,5 +1,5 @@ -import 'package:syncrow_web/pages/device_managment/models/room.dart'; -import 'package:syncrow_web/pages/device_managment/models/unit.dart'; +import 'package:syncrow_web/pages/device_managment/all_devices/models/room.dart'; +import 'package:syncrow_web/pages/device_managment/all_devices/models/unit.dart'; class AllDevicesModel { /* diff --git a/lib/pages/device_managment/models/room.dart b/lib/pages/device_managment/all_devices/models/room.dart similarity index 100% rename from lib/pages/device_managment/models/room.dart rename to lib/pages/device_managment/all_devices/models/room.dart diff --git a/lib/pages/device_managment/models/unit.dart b/lib/pages/device_managment/all_devices/models/unit.dart similarity index 100% rename from lib/pages/device_managment/models/unit.dart rename to lib/pages/device_managment/all_devices/models/unit.dart diff --git a/lib/pages/device_managment/view/device_managment_page.dart b/lib/pages/device_managment/all_devices/view/device_managment_page.dart similarity index 86% rename from lib/pages/device_managment/view/device_managment_page.dart rename to lib/pages/device_managment/all_devices/view/device_managment_page.dart index 5bb26e1c..5d1abd02 100644 --- a/lib/pages/device_managment/view/device_managment_page.dart +++ b/lib/pages/device_managment/all_devices/view/device_managment_page.dart @@ -1,7 +1,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; -import 'package:syncrow_web/pages/device_managment/bloc/device_managment_bloc.dart'; -import 'package:syncrow_web/pages/device_managment/widgets/device_managment_body.dart'; +import 'package:syncrow_web/pages/device_managment/all_devices/bloc/device_managment_bloc.dart'; +import 'package:syncrow_web/pages/device_managment/all_devices/widgets/device_managment_body.dart'; import 'package:syncrow_web/web_layout/web_scaffold.dart'; class DeviceManagementPage extends StatelessWidget { diff --git a/lib/pages/device_managment/widgets/device_managment_body.dart b/lib/pages/device_managment/all_devices/widgets/device_managment_body.dart similarity index 76% rename from lib/pages/device_managment/widgets/device_managment_body.dart rename to lib/pages/device_managment/all_devices/widgets/device_managment_body.dart index fd72b0ae..a3d2215e 100644 --- a/lib/pages/device_managment/widgets/device_managment_body.dart +++ b/lib/pages/device_managment/all_devices/widgets/device_managment_body.dart @@ -4,9 +4,10 @@ import 'package:syncrow_web/core/extension/build_context_x.dart'; import 'package:syncrow_web/pages/common/buttons/default_button.dart'; import 'package:syncrow_web/pages/common/custom_table.dart'; import 'package:syncrow_web/pages/common/filter/filter_widget.dart'; -import 'package:syncrow_web/pages/device_managment/bloc/device_managment_bloc.dart'; -import 'package:syncrow_web/pages/device_managment/models/devices_model.dart'; -import 'package:syncrow_web/pages/device_managment/widgets/device_search_filters.dart'; +import 'package:syncrow_web/pages/device_managment/all_devices/bloc/device_managment_bloc.dart'; +import 'package:syncrow_web/pages/device_managment/all_devices/models/devices_model.dart'; +import 'package:syncrow_web/pages/device_managment/shared/device_control_dialog.dart'; +import 'package:syncrow_web/pages/device_managment/all_devices/widgets/device_search_filters.dart'; import 'package:syncrow_web/utils/format_date_time.dart'; import 'package:syncrow_web/utils/helpers/responsice_layout_helper/responsive_layout_helper.dart'; import 'package:syncrow_web/utils/style.dart'; @@ -78,7 +79,17 @@ class DeviceManagementBody extends StatelessWidget with HelperResponsiveLayout { decoration: containerDecoration, child: Center( child: DefaultButton( - onPressed: () {}, + onPressed: () { + final selectedDevice = + context.read().selectedDevice; + if (selectedDevice != null) { + showDialog( + context: context, + builder: (context) => + DeviceControlDialog(device: selectedDevice), + ); + } + }, borderRadius: 9, child: const Text('Control'), ), @@ -90,15 +101,12 @@ class DeviceManagementBody extends StatelessWidget with HelperResponsiveLayout { Expanded( child: DynamicTable( cellDecoration: containerDecoration, - selectAll: (p0) { - // visitorBloc.selectedDeviceIds.clear(); - // for (var item in state.data) { - // visitorBloc.add(SelectDeviceEvent(item.uuid)); - // } - }, - onRowCheckboxChanged: (index, isSelected) { - // final deviceId = state.data[index].uuid; - // visitorBloc.add(SelectDeviceEvent(deviceId)); + onRowSelected: (index, isSelected, row) { + if (isSelected) { + context + .read() + .add(SelectDevice(devicesToShow[index])); + } }, withCheckBox: true, size: context.screenSize, @@ -120,12 +128,14 @@ class DeviceManagementBody extends StatelessWidget with HelperResponsiveLayout { device.uuid ?? '', device.unit?.name ?? '', device.room?.name ?? '', - device.batteryLevel?.toString() ?? '', + device.batteryLevel != null + ? '${device.batteryLevel}%' + : '', formatDateTime(DateTime.fromMillisecondsSinceEpoch( - device.createTime ?? 0)), + (device.createTime ?? 0) * 1000)), device.online == true ? 'Online' : 'Offline', formatDateTime(DateTime.fromMillisecondsSinceEpoch( - device.updateTime ?? 0)), + (device.updateTime ?? 0) * 1000)), ]; }).toList(), isEmpty: devicesToShow.isEmpty, diff --git a/lib/pages/device_managment/widgets/device_search_filters.dart b/lib/pages/device_managment/all_devices/widgets/device_search_filters.dart similarity index 96% rename from lib/pages/device_managment/widgets/device_search_filters.dart rename to lib/pages/device_managment/all_devices/widgets/device_search_filters.dart index 988287f4..7af6293e 100644 --- a/lib/pages/device_managment/widgets/device_search_filters.dart +++ b/lib/pages/device_managment/all_devices/widgets/device_search_filters.dart @@ -1,7 +1,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:syncrow_web/pages/common/text_field/custom_text_field.dart'; -import 'package:syncrow_web/pages/device_managment/bloc/device_managment_bloc.dart'; +import 'package:syncrow_web/pages/device_managment/all_devices/bloc/device_managment_bloc.dart'; import 'package:syncrow_web/pages/common/buttons/search_reset_buttons.dart'; import 'package:syncrow_web/utils/helpers/responsice_layout_helper/responsive_layout_helper.dart'; diff --git a/lib/pages/device_managment/living_room_switch/bloc/living_room_bloc.dart b/lib/pages/device_managment/living_room_switch/bloc/living_room_bloc.dart new file mode 100644 index 00000000..2f91175d --- /dev/null +++ b/lib/pages/device_managment/living_room_switch/bloc/living_room_bloc.dart @@ -0,0 +1,42 @@ +import 'dart:async'; + +import 'package:bloc/bloc.dart'; +import 'package:equatable/equatable.dart'; +import 'package:syncrow_web/pages/device_managment/all_devices/models/device_status.dart'; +import 'package:syncrow_web/services/devices_mang_api.dart'; + +part 'living_room_event.dart'; +part 'living_room_state.dart'; + +class LivingRoomBloc extends Bloc { + LivingRoomBloc() : super(LivingRoomInitial()) { + on(_onFetchDeviceStatus); + on(_livingRoomControl); + } + + FutureOr _onFetchDeviceStatus( + LivingRoomFetchDeviceStatus event, Emitter emit) async { + emit(LivingRoomDeviceStatusLoading()); + try { + final status = + await DevicesManagementApi().getDeviceStatus(event.deviceId); + emit(LivingRoomDeviceStatusLoaded(status)); + } catch (e) { + emit(LivingRoomDeviceManagementError(e.toString())); + } + } + + FutureOr _livingRoomControl( + LivingRoomControl event, Emitter emit) async { + emit(LivingRoomControlLoading()); + try { + final status = Status(code: event.code, value: event.value); + + await DevicesManagementApi().deviceControl(event.deviceId, status); + + emit(LivingRoomControlSuccess()); + } catch (e) { + emit(LivingRoomControlError(e.toString())); + } + } +} diff --git a/lib/pages/device_managment/living_room_switch/bloc/living_room_event.dart b/lib/pages/device_managment/living_room_switch/bloc/living_room_event.dart new file mode 100644 index 00000000..f7b57cde --- /dev/null +++ b/lib/pages/device_managment/living_room_switch/bloc/living_room_event.dart @@ -0,0 +1,29 @@ +part of 'living_room_bloc.dart'; + +sealed class LivingRoomEvent extends Equatable { + const LivingRoomEvent(); + + @override + List get props => []; +} + +class LivingRoomFetchDeviceStatus extends LivingRoomEvent { + final String deviceId; + + const LivingRoomFetchDeviceStatus(this.deviceId); + + @override + List get props => [deviceId]; +} + +class LivingRoomControl extends LivingRoomEvent { + final String deviceId; + final String code; + final bool value; + + const LivingRoomControl( + {required this.deviceId, required this.code, required this.value}); + + @override + List get props => [deviceId, code, value]; +} diff --git a/lib/pages/device_managment/living_room_switch/bloc/living_room_state.dart b/lib/pages/device_managment/living_room_switch/bloc/living_room_state.dart new file mode 100644 index 00000000..3579183d --- /dev/null +++ b/lib/pages/device_managment/living_room_switch/bloc/living_room_state.dart @@ -0,0 +1,43 @@ +part of 'living_room_bloc.dart'; + +sealed class LivingRoomState extends Equatable { + const LivingRoomState(); + + @override + List get props => []; +} + +final class LivingRoomInitial extends LivingRoomState {} + +class LivingRoomDeviceStatusLoading extends LivingRoomState {} + +class LivingRoomDeviceStatusLoaded extends LivingRoomState { + final DeviceStatus status; + + const LivingRoomDeviceStatusLoaded(this.status); + + @override + List get props => [status]; +} + +class LivingRoomDeviceManagementError extends LivingRoomState { + final String message; + + const LivingRoomDeviceManagementError(this.message); + + @override + List get props => [message]; +} + +class LivingRoomControlSuccess extends LivingRoomState {} + +class LivingRoomControlError extends LivingRoomState { + final String message; + + const LivingRoomControlError(this.message); + + @override + List get props => [message]; +} + +class LivingRoomControlLoading extends LivingRoomState {} diff --git a/lib/pages/device_managment/living_room_switch/control_list/cieling_light.dart b/lib/pages/device_managment/living_room_switch/control_list/cieling_light.dart new file mode 100644 index 00000000..d8479f3e --- /dev/null +++ b/lib/pages/device_managment/living_room_switch/control_list/cieling_light.dart @@ -0,0 +1,70 @@ +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:flutter_svg/svg.dart'; +import 'package:syncrow_web/pages/device_managment/living_room_switch/bloc/living_room_bloc.dart'; +import 'package:syncrow_web/utils/color_manager.dart'; +import 'package:syncrow_web/utils/constants/assets.dart'; + +class CeilingLight extends StatelessWidget { + const CeilingLight( + {super.key, + required this.value, + required this.code, + required this.deviceId}); + + final bool value; + final String code; + final String deviceId; + + @override + Widget build(BuildContext context) { + return Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + ClipOval( + child: Container( + color: ColorsManager.whiteColors, + child: SvgPicture.asset( + Assets.lightPulp, + width: 60, + height: 60, + fit: BoxFit.cover, + ), + )), + SizedBox( + height: 20, + width: 35, + child: CupertinoSwitch( + value: value, + onChanged: (newValue) { + context.read().add( + LivingRoomControl( + deviceId: deviceId, + code: code, + value: newValue, + ), + ); + }, + ), + ), + ], + ), + const Spacer(), + const Center( + child: Text( + 'Ceiling Light', + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 14, + ), + ), + ), + ], + ); + } +} diff --git a/lib/pages/device_managment/living_room_switch/control_list/spot_light.dart b/lib/pages/device_managment/living_room_switch/control_list/spot_light.dart new file mode 100644 index 00000000..e3717090 --- /dev/null +++ b/lib/pages/device_managment/living_room_switch/control_list/spot_light.dart @@ -0,0 +1,70 @@ +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:flutter_svg/svg.dart'; +import 'package:syncrow_web/pages/device_managment/living_room_switch/bloc/living_room_bloc.dart'; +import 'package:syncrow_web/utils/color_manager.dart'; +import 'package:syncrow_web/utils/constants/assets.dart'; + +class SpotLight extends StatelessWidget { + const SpotLight( + {super.key, + required this.value, + required this.code, + required this.deviceId}); + + final bool value; + final String code; + final String deviceId; + + @override + Widget build(BuildContext context) { + return Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + ClipOval( + child: Container( + color: ColorsManager.whiteColors, + child: SvgPicture.asset( + Assets.lightPulp, + width: 60, + height: 60, + fit: BoxFit.cover, + ), + )), + SizedBox( + height: 20, + width: 35, + child: CupertinoSwitch( + value: value, + onChanged: (newValue) { + context.read().add( + LivingRoomControl( + deviceId: deviceId, + code: code, + value: newValue, + ), + ); + }, + ), + ), + ], + ), + const Spacer(), + const Center( + child: Text( + 'Spotlight', + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 14, + ), + ), + ), + ], + ); + } +} diff --git a/lib/pages/device_managment/living_room_switch/control_list/wall_light.dart b/lib/pages/device_managment/living_room_switch/control_list/wall_light.dart new file mode 100644 index 00000000..c82dd89d --- /dev/null +++ b/lib/pages/device_managment/living_room_switch/control_list/wall_light.dart @@ -0,0 +1,70 @@ +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:flutter_svg/svg.dart'; +import 'package:syncrow_web/pages/device_managment/living_room_switch/bloc/living_room_bloc.dart'; +import 'package:syncrow_web/utils/color_manager.dart'; +import 'package:syncrow_web/utils/constants/assets.dart'; + +class WallLight extends StatelessWidget { + const WallLight( + {super.key, + required this.value, + required this.code, + required this.deviceId}); + + final bool value; + final String code; + final String deviceId; + + @override + Widget build(BuildContext context) { + return Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + ClipOval( + child: Container( + color: ColorsManager.whiteColors, + child: SvgPicture.asset( + Assets.lightPulp, + width: 60, + height: 60, + fit: BoxFit.cover, + ), + )), + SizedBox( + height: 20, + width: 35, + child: CupertinoSwitch( + value: value, + onChanged: (newValue) { + context.read().add( + LivingRoomControl( + deviceId: deviceId, + code: code, + value: newValue, + ), + ); + }, + ), + ), + ], + ), + const Spacer(), + const Center( + child: Text( + 'Wall Light', + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 14, + ), + ), + ), + ], + ); + } +} diff --git a/lib/pages/device_managment/living_room_switch/helper/living_room_helper.dart b/lib/pages/device_managment/living_room_switch/helper/living_room_helper.dart new file mode 100644 index 00000000..91159084 --- /dev/null +++ b/lib/pages/device_managment/living_room_switch/helper/living_room_helper.dart @@ -0,0 +1,20 @@ +import 'package:flutter/material.dart'; +import 'package:syncrow_web/pages/device_managment/living_room_switch/control_list/cieling_light.dart'; +import 'package:syncrow_web/pages/device_managment/living_room_switch/control_list/spot_light.dart'; +import 'package:syncrow_web/pages/device_managment/living_room_switch/control_list/wall_light.dart'; + +mixin LivingRoomHelper { + Widget livingRoomControlWidgets( + {required bool value, required String code, required String deviceId}) { + switch (code) { + case 'switch_1': + return WallLight(value: value, code: code, deviceId: deviceId); + case 'switch_2': + return CeilingLight(value: value, code: code, deviceId: deviceId); + case 'switch_3': + return SpotLight(value: value, code: code, deviceId: deviceId); + default: + return const SizedBox(); + } + } +} diff --git a/lib/pages/device_managment/living_room_switch/view/living_room_device_control.dart b/lib/pages/device_managment/living_room_switch/view/living_room_device_control.dart new file mode 100644 index 00000000..c827ed1f --- /dev/null +++ b/lib/pages/device_managment/living_room_switch/view/living_room_device_control.dart @@ -0,0 +1,70 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:syncrow_web/pages/device_managment/all_devices/models/device_status.dart'; +import 'package:syncrow_web/pages/device_managment/all_devices/models/devices_model.dart'; +import 'package:syncrow_web/pages/device_managment/living_room_switch/bloc/living_room_bloc.dart'; +import 'package:syncrow_web/pages/device_managment/living_room_switch/helper/living_room_helper.dart'; +import 'package:syncrow_web/utils/color_manager.dart'; + +class LivingRoomDeviceControl extends StatelessWidget with LivingRoomHelper { + const LivingRoomDeviceControl({super.key, required this.device}); + + final AllDevicesModel device; + + @override + Widget build(BuildContext context) { + return BlocProvider( + create: (context) => + LivingRoomBloc()..add(LivingRoomFetchDeviceStatus(device.uuid!)), + child: BlocListener( + listener: (context, state) { + if (state is LivingRoomControlSuccess) { + context + .read() + .add(LivingRoomFetchDeviceStatus(device.uuid!)); + } + }, + child: BlocBuilder( + builder: (context, state) { + if (state is LivingRoomDeviceStatusLoading) { + return const Center(child: CircularProgressIndicator()); + } else if (state is LivingRoomDeviceStatusLoaded) { + return _buildStatusControls(state.status.status); + } else { + return const Center(child: Text('Error fetching status')); + } + }, + ), + ), + ); + } + + Widget _buildStatusControls(List statuses) { + return GridView.builder( + padding: const EdgeInsets.symmetric(horizontal: 40), + shrinkWrap: true, + physics: const NeverScrollableScrollPhysics(), + gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount( + crossAxisCount: 3, + mainAxisExtent: 133, + crossAxisSpacing: 12, + mainAxisSpacing: 12, + ), + itemCount: 3, + itemBuilder: (context, index) { + final status = statuses[index]; + + return Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(20), + color: ColorsManager.greyColor.withOpacity(0.2), + border: Border.all(color: ColorsManager.boxDivider), + ), + padding: const EdgeInsets.all(16), + child: livingRoomControlWidgets( + value: status.value, code: status.code, deviceId: device.uuid!), + ); + }, + ); + } +} diff --git a/lib/pages/device_managment/shared/device_control_dialog.dart b/lib/pages/device_managment/shared/device_control_dialog.dart new file mode 100644 index 00000000..190ebd52 --- /dev/null +++ b/lib/pages/device_managment/shared/device_control_dialog.dart @@ -0,0 +1,275 @@ +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; + +import 'package:syncrow_web/core/extension/build_context_x.dart'; +import 'package:syncrow_web/pages/device_managment/all_devices/helper/route_controls_based_code.dart'; + +import 'package:syncrow_web/pages/device_managment/all_devices/models/devices_model.dart'; +import 'package:syncrow_web/utils/color_manager.dart'; + +class DeviceControlDialog extends StatelessWidget with RouteControlsBasedCode { + final AllDevicesModel device; + + const DeviceControlDialog({super.key, required this.device}); + + @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, + height: context.screenHeight * 0.7, + child: SingleChildScrollView( + child: Padding( + padding: const EdgeInsets.all(20.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Center( + child: Text( + device.categoryName ?? 'Device Control', + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 22, + color: ColorsManager.dialogBlueTitle, + ), + ), + ), + const SizedBox(height: 20), + _buildDeviceInfoSection(), + const SizedBox(height: 20), + //// BUILD DEVICE CONTROLS + /// + //// ROUTE TO SPECIFIC CONTROL VIEW BASED ON DEVICE CATEGORY + routeControlsWidgets(device: device), + ], + ), + ), + ), + ), + ); + } + + Widget _buildDeviceInfoSection() { + return Padding( + padding: const EdgeInsets.symmetric(vertical: 40, horizontal: 50), + child: Table( + children: [ + TableRow( + children: [ + _buildInfoRow('Product Name:', device.categoryName ?? 'N/A'), + _buildInfoRow('Device ID:', device.uuid ?? ''), + ], + ), + TableRow(children: [ + _buildInfoRow('Virtual Address:', + 'Area - Street 1 - Building 1 - First Floor'), + const SizedBox.shrink(), + ]), + TableRow( + children: [ + _buildInfoRow('Unit Name:', device.unit?.name ?? 'N/A'), + _buildInfoRow('Room:', device.room?.name ?? 'N/A'), + ], + ), + TableRow( + children: [ + _buildInfoRow('Installation Date and Time:', '09/08/2024 13:30'), + const SizedBox.shrink(), + ], + ), + TableRow( + children: [ + _buildInfoRow('Status:', 'Online', statusColor: Colors.green), + _buildInfoRow('Last Offline Date and Time:', '-'), + ], + ), + ], + ), + ); + } + + Widget _buildInfoRow(String title, String value, {Color? statusColor}) { + return Padding( + padding: const EdgeInsets.symmetric(vertical: 5.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + title, + style: const TextStyle( + fontWeight: FontWeight.normal, + fontSize: 12, + color: ColorsManager.lightGreyColor, + ), + ), + const SizedBox(width: 10), + Text( + value, + style: TextStyle( + fontSize: 16, + color: statusColor ?? Colors.black, + ), + ), + ], + ), + ); + } + +// ////// changing here for devices controls //// +// Widget _buildStatusControls(List statuses) { +// return GridView.builder( +// padding: const EdgeInsets.symmetric(horizontal: 40), +// shrinkWrap: true, +// physics: const NeverScrollableScrollPhysics(), +// gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount( +// crossAxisCount: 3, +// mainAxisExtent: 133, +// crossAxisSpacing: 12, +// mainAxisSpacing: 12, +// ), +// itemCount: statuses.length, +// itemBuilder: (context, index) { +// final status = statuses[index]; + +// return Container( +// decoration: BoxDecoration( +// borderRadius: BorderRadius.circular(20), +// color: ColorsManager.greyColor.withOpacity(0.2), +// border: Border.all(color: ColorsManager.boxDivider), +// ), +// padding: const EdgeInsets.all(16), +// child: _buildControlForStatus(status), +// ); +// }, +// ); +// } + + // Widget _buildControlForStatus(Status status) { + // switch (status.type) { + // case OperationDialogType.onOff: + // return Column( + // crossAxisAlignment: CrossAxisAlignment.start, + // children: [ + // Row( + // mainAxisAlignment: MainAxisAlignment.spaceEvenly, + // crossAxisAlignment: CrossAxisAlignment.center, + // children: [ + // if (status.icon.isNotEmpty) + // ClipOval( + // child: Container( + // color: ColorsManager.whiteColors, + // child: SvgPicture.asset( + // status.icon, + // width: 60, + // height: 60, + // fit: BoxFit.cover, + // ), + // )), + // SizedBox( + // height: 20, + // width: 35, + // child: CupertinoSwitch( + // value: status.value ?? false, + // onChanged: (newValue) { + // // Handle toggle change + // }, + // ), + // ), + // ], + // ), + // const Spacer(), + // Center( + // child: Text( + // status.name, + // style: const TextStyle( + // fontWeight: FontWeight.bold, + // fontSize: 14, + // ), + // ), + // ), + // ], + // ); + // case OperationDialogType.countdown: + // return Column( + // crossAxisAlignment: CrossAxisAlignment.start, + // children: [ + // Center( + // child: Text( + // status.name, + // style: const TextStyle( + // fontWeight: FontWeight.bold, + // fontSize: 14, + // ), + // ), + // ), + // const Spacer(), + // IncrementDecrementWidget( + // value: status.value.toString(), + // description: 'hr', + // onIncrement: () { + // // Handle increment + // }, + // onDecrement: () { + // // Handle decrement + // }, + // ), + // ], + // ); + // case OperationDialogType.integerSteps: + // return IncrementDecrementWidget( + // value: status.value.toString(), + // description: 'm', + // onIncrement: () { + // // Handle increment + // }, + // onDecrement: () { + // // Handle decrement + // }, + // ); + // case OperationDialogType.listOfOptions: + // return Wrap( + // children: [ + // ...status.options!.map((e) => ClipOval( + // child: SvgPicture.asset( + // e.icon, + // width: 40, + // height: 40, + // fit: BoxFit.cover, + // ), + // )) + // ], + // ); + + // default: + // return Column( + // crossAxisAlignment: CrossAxisAlignment.start, + // children: [ + // if (status.icon.isNotEmpty) + // ClipOval( + // child: Container( + // color: ColorsManager.whiteColors, + // child: SvgPicture.asset( + // status.icon, + // width: 60, + // height: 60, + // fit: BoxFit.cover, + // ), + // )), + // const Spacer(), + // Text( + // status.value.toString(), + // style: const TextStyle( + // fontSize: 14, + // color: Colors.black54, + // ), + // ), + // ], + // ); + // } + // } +} diff --git a/lib/pages/device_managment/shared/increament_decreament.dart b/lib/pages/device_managment/shared/increament_decreament.dart new file mode 100644 index 00000000..3e3c8c1d --- /dev/null +++ b/lib/pages/device_managment/shared/increament_decreament.dart @@ -0,0 +1,87 @@ +import 'package:flutter/material.dart'; +import 'package:syncrow_web/utils/color_manager.dart'; + +class IncrementDecrementWidget extends StatelessWidget { + final String value; + final String description; + final VoidCallback onIncrement; + final VoidCallback onDecrement; + + const IncrementDecrementWidget({ + super.key, + required this.value, + required this.description, + required this.onIncrement, + required this.onDecrement, + }); + + @override + Widget build(BuildContext context) { + return Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Material( + type: MaterialType.transparency, + child: ClipRRect( + borderRadius: BorderRadius.circular(100), + child: InkWell( + splashColor: Colors.transparent, + highlightColor: Colors.transparent, + onTap: onDecrement, + child: const Padding( + padding: EdgeInsets.all(8.0), + child: Icon( + Icons.remove, + color: ColorsManager.greyColor, + size: 32, + ), + ), + ), + ), + ), + RichText( + text: TextSpan( + text: '', + children: [ + TextSpan( + text: value, + style: TextStyle( + fontSize: 38, + color: ColorsManager.dialogBlueTitle, + fontWeight: FontWeight.bold, + ), + ), + TextSpan( + text: description, + style: const TextStyle( + fontSize: 12, + color: ColorsManager.blackColor, + fontWeight: FontWeight.bold, + ), + ), + ], + ), + ), + Material( + type: MaterialType.transparency, + child: ClipRRect( + borderRadius: BorderRadius.circular(100), + child: InkWell( + splashColor: Colors.transparent, + highlightColor: Colors.transparent, + onTap: onIncrement, + child: const Padding( + padding: EdgeInsets.all(8.0), + child: Icon( + Icons.add, + color: ColorsManager.greyColor, + size: 32, + ), + ), + ), + ), + ), + ], + ); + } +} diff --git a/lib/pages/home/bloc/home_bloc.dart b/lib/pages/home/bloc/home_bloc.dart index 58d452ae..7d0034a5 100644 --- a/lib/pages/home/bloc/home_bloc.dart +++ b/lib/pages/home/bloc/home_bloc.dart @@ -5,7 +5,7 @@ import 'package:flutter_secure_storage/flutter_secure_storage.dart'; import 'package:graphview/GraphView.dart'; import 'package:syncrow_web/pages/access_management/view/access_management.dart'; import 'package:syncrow_web/pages/auth/model/user_model.dart'; -import 'package:syncrow_web/pages/device_managment/view/device_managment_page.dart'; +import 'package:syncrow_web/pages/device_managment/all_devices/view/device_managment_page.dart'; import 'package:syncrow_web/pages/home/bloc/home_event.dart'; import 'package:syncrow_web/pages/home/bloc/home_state.dart'; import 'package:syncrow_web/pages/home/home_model/home_item_model.dart'; diff --git a/lib/pages/visitor_password/view/add_device_dialog.dart b/lib/pages/visitor_password/view/add_device_dialog.dart index bcf14968..c7d558b8 100644 --- a/lib/pages/visitor_password/view/add_device_dialog.dart +++ b/lib/pages/visitor_password/view/add_device_dialog.dart @@ -178,7 +178,7 @@ class AddDeviceDialog extends StatelessWidget { .add(SelectDeviceEvent(item.uuid)); } }, - onRowCheckboxChanged: (index, isSelected) { + onRowSelected: (index, isSelected, row) { final deviceId = state.data[index].uuid; visitorBloc.add(SelectDeviceEvent(deviceId)); }, diff --git a/lib/services/auth_api.dart b/lib/services/auth_api.dart index 69dbb799..55d12717 100644 --- a/lib/services/auth_api.dart +++ b/lib/services/auth_api.dart @@ -103,6 +103,6 @@ class AuthenticationAPI { .map((zone) => RegionModel.fromJson(zone)) .toList(); }); - return response as List; + return response; } } diff --git a/lib/services/devices_mang_api.dart b/lib/services/devices_mang_api.dart index 21dbbe97..9346d7b1 100644 --- a/lib/services/devices_mang_api.dart +++ b/lib/services/devices_mang_api.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; -import 'package:syncrow_web/pages/device_managment/models/devices_model.dart'; +import 'package:syncrow_web/pages/device_managment/all_devices/models/device_status.dart'; +import 'package:syncrow_web/pages/device_managment/all_devices/models/devices_model.dart'; import 'package:syncrow_web/services/api/http_service.dart'; import 'package:syncrow_web/utils/constants/api_const.dart'; @@ -23,4 +24,43 @@ class DevicesManagementApi { return []; } } + + Future getDeviceStatus(String uuid) async { + try { + final response = await HTTPService().get( + path: ApiEndpoints.getDeviceStatus.replaceAll('{uuid}', uuid), + showServerMessage: true, + expectedResponseModel: (json) { + return DeviceStatus.fromJson(json); + }, + ); + return response; + } catch (e) { + debugPrint('Error fetching $e'); + return DeviceStatus( + productUuid: '', + productType: '', + status: [], + ); + } + } + + //deviceControl + + Future deviceControl (String uuid, Status status) async { + try { + final response = await HTTPService().post( + path: ApiEndpoints.deviceControl.replaceAll('{uuid}', uuid), + body: status.toMap(), + showServerMessage: true, + expectedResponseModel: (json) { + return true; + }, + ); + return response; + } catch (e) { + debugPrint('Error fetching $e'); + return false; + } + } } diff --git a/lib/utils/color_manager.dart b/lib/utils/color_manager.dart index 5fbdb782..fa1d7394 100644 --- a/lib/utils/color_manager.dart +++ b/lib/utils/color_manager.dart @@ -11,6 +11,8 @@ abstract class ColorsManager { static const Color secondaryColor = Color(0xFF023DFE); static const Color onSecondaryColor = Color(0xFF023DFE); + static Color dialogBlueTitle = Color(0xFF023DFE).withOpacity(0.6); + static const Color primaryTextColor = Colors.black; static const Color greyColor = Color(0xFFd5d5d5); diff --git a/lib/utils/constants/api_const.dart b/lib/utils/constants/api_const.dart index 8248cf43..6e92445c 100644 --- a/lib/utils/constants/api_const.dart +++ b/lib/utils/constants/api_const.dart @@ -29,4 +29,8 @@ abstract class ApiEndpoints { ////// Devices Management //////////////// static const String getAllDevices = '$baseUrl/device'; + static const String getDeviceStatus = + '$baseUrl/device/{uuid}/functions/status'; + + static const String deviceControl = '$baseUrl/device/{uuid}/control'; } diff --git a/lib/utils/constants/assets.dart b/lib/utils/constants/assets.dart index 9d580630..8a89358c 100644 --- a/lib/utils/constants/assets.dart +++ b/lib/utils/constants/assets.dart @@ -29,4 +29,114 @@ class Assets { static const String deviceNoteIcon = "assets/images/device_note.svg"; static const String timeIcon = "assets/images/time_icon.svg"; static const String emptyTable = "assets/images/empty_table.svg"; + + // General assets + static const String motionlessDetection = + "assets/functions_icons/motionless_detection.svg"; + static const String acHeating = "assets/functions_icons/ac_heating.svg"; + static const String acPowerOff = "assets/functions_icons/ac_power_off.svg"; + static const String acFanMiddle = "assets/functions_icons/ac_fan_middle.svg"; + static const String switchAlarmSound = + "assets/functions_icons/switch_alarm_sound.svg"; + static const String resetOff = "assets/functions_icons/reset_off.svg"; + static const String sensitivityOperationIcon = + "assets/functions_icons/sesitivity_operation_icon.svg"; + static const String motionDetection = + "assets/functions_icons/motion_detection.svg"; + static const String freezing = "assets/functions_icons/freezing.svg"; + static const String indicator = "assets/functions_icons/indicator.svg"; + static const String sceneRefresh = "assets/functions_icons/scene_refresh.svg"; + static const String temperature = "assets/functions_icons/tempreture.svg"; + static const String acFanHigh = "assets/functions_icons/ac_fan_high.svg"; + static const String fanSpeed = "assets/functions_icons/fan_speed.svg"; + static const String acFanLow = "assets/functions_icons/ac_fan_low.svg"; + static const String sensitivity = "assets/functions_icons/sensitivity.svg"; + static const String lightCountdown = + "assets/functions_icons/light_countdown.svg"; + static const String farDetection = "assets/functions_icons/far_detection.svg"; + static const String sceneChildUnlock = + "assets/functions_icons/scene_child_unlock.svg"; + static const String acFanAuto = "assets/functions_icons/ac_fan_auto.svg"; + static const String childLock = "assets/functions_icons/child_lock.svg"; + static const String factoryReset = "assets/functions_icons/factory_reset.svg"; + static const String acCooling = "assets/functions_icons/ac_cooling.svg"; + static const String sceneChildLock = + "assets/functions_icons/scene_child_lock.svg"; + static const String celsiusDegrees = + "assets/functions_icons/celsius_degrees.svg"; + static const String masterState = "assets/functions_icons/master_state.svg"; + static const String acPower = "assets/functions_icons/ac_power.svg"; + static const String farDetectionFunction = + "assets/functions_icons/far_detection_function.svg"; + static const String nobodyTime = "assets/functions_icons/nobody_time.svg"; + + // Automation functions + static const String tempPasswordUnlock = + "assets/functions_icons/automation_functions/temp_password_unlock.svg"; + static const String doorlockNormalOpen = + "assets/functions_icons/automation_functions/doorlock_normal_open.svg"; + static const String doorbell = + "assets/functions_icons/automation_functions/doorbell.svg"; + static const String remoteUnlockViaApp = + "assets/functions_icons/automation_functions/remote_unlock_via_app.svg"; + static const String doubleLock = + "assets/functions_icons/automation_functions/double_lock.svg"; + static const String selfTestResult = + "assets/functions_icons/automation_functions/self_test_result.svg"; + static const String lockAlarm = + "assets/functions_icons/automation_functions/lock_alarm.svg"; + static const String presenceState = + "assets/functions_icons/automation_functions/presence_state.svg"; + static const String currentTemp = + "assets/functions_icons/automation_functions/current_temp.svg"; + static const String presence = + "assets/functions_icons/automation_functions/presence.svg"; + static const String residualElectricity = + "assets/functions_icons/automation_functions/residual_electricity.svg"; + static const String hijackAlarm = + "assets/functions_icons/automation_functions/hijack_alarm.svg"; + static const String passwordUnlock = + "assets/functions_icons/automation_functions/password_unlock.svg"; + static const String remoteUnlockRequest = + "assets/functions_icons/automation_functions/remote_unlock_req.svg"; + static const String cardUnlock = + "assets/functions_icons/automation_functions/card_unlock.svg"; + static const String motion = + "assets/functions_icons/automation_functions/motion.svg"; + static const String fingerprintUnlock = + "assets/functions_icons/automation_functions/fingerprint_unlock.svg"; + + // Presence Sensor Assets + static const String presenceIlluminanceRecord = + "presence_sensor_assets/presence-sensor-assets/Illuminance-Record.svg"; + static const String presenceMaximumDistance = + "presence_sensor_assets/presence-sensor-assets/maximum_distance.svg"; + static const String presenceDistance = + "presence_sensor_assets/presence-sensor-assets/Distance.svg"; + static const String presenceIlluminanceValue = + "presence_sensor_assets/presence-sensor-assets/Illuminance-Value.svg"; + static const String presenceEmpty = + "presence_sensor_assets/presence-sensor-assets/Empty.svg"; + static const String presenceIndicator = + "presence_sensor_assets/presence-sensor-assets/Indicator.svg"; + static const String presenceTime = + "presence_sensor_assets/presence-sensor-assets/Time.svg"; + static const String presenceSpaceTypeIcon = + "presence_sensor_assets/presence-sensor-assets/space_type_icon.svg"; + static const String presenceRecord = + "presence_sensor_assets/presence-sensor-assets/Record.svg"; + static const String presenceHelpDescription = + "presence_sensor_assets/presence-sensor-assets/help-description.svg"; + static const String presenceSensitivity = + "presence_sensor_assets/presence-sensor-assets/Sensitivity.svg"; + static const String presenceParameterSettings = + "presence_sensor_assets/presence-sensor-assets/parameter-settings.svg"; + static const String presenceInductionRecording = + "presence_sensor_assets/presence-sensor-assets/induction-recording.svg"; + static const String presencePresence = + "presence_sensor_assets/presence-sensor-assets/Presence.svg"; + static const String presenceMotion = + "presence_sensor_assets/presence-sensor-assets/presence-sensor-motion.svg"; + + static const String lightPulp = "functions_icons/light_pulb.svg"; } diff --git a/pubspec.yaml b/pubspec.yaml index faaa7ddb..4236d2ef 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -69,6 +69,9 @@ flutter: # To add assets to your application, add an assets section, like this: assets: + - assets/functions_icons/automation_functions/ + - assets/functions_icons/presence-sensor-assets/ + - assets/functions_icons/ - assets/images/ - assets/