From 481fe1c0f3a43804bed9da6218328e4938eedf2d Mon Sep 17 00:00:00 2001 From: Mohammad Salameh Date: Sat, 2 Mar 2024 15:52:28 +0300 Subject: [PATCH 1/9] replaced Gap Class with the appropriate SizedBox removed the Gap dependency --- .gitignore | 1 - .../view/widgets/app_bar_home_dropdown.dart | 5 +- .../auth/view/widgets/auth_view_body.dart | 7 +-- .../dashboard/view/dashboard_view.dart | 5 +- .../view/widgets/carbon_emission.dart | 9 ++- .../dashboard/view/widgets/consumption.dart | 3 +- .../view/widgets/live_monitor_widget.dart | 3 +- .../view/widgets/ACs/ac_interface.dart | 3 +- .../widgets/ACs/ac_interface_controls.dart | 7 +-- .../widgets/ACs/ac_mode_control_unit.dart | 3 +- .../devices/view/widgets/ACs/acs_list.dart | 17 +++--- .../view/widgets/devices_mode_tab.dart | 5 +- .../devices/view/widgets/no_devices_view.dart | 5 +- lib/features/menu/view/widgets/menu_list.dart | 7 +-- .../menu/view/widgets/profile_tab.dart | 3 +- lib/features/scene/view/scene_view.dart | 5 +- .../view/widgets/scene_view_no_scenes.dart | 5 +- pubspec.lock | 56 +++---------------- pubspec.yaml | 5 +- 19 files changed, 47 insertions(+), 107 deletions(-) diff --git a/.gitignore b/.gitignore index 29a3a50..add5842 100644 --- a/.gitignore +++ b/.gitignore @@ -28,7 +28,6 @@ migrate_working_dir/ .flutter-plugins .flutter-plugins-dependencies .pub-cache/ -.pub/ /build/ # Symbolication related diff --git a/lib/features/app_layout/view/widgets/app_bar_home_dropdown.dart b/lib/features/app_layout/view/widgets/app_bar_home_dropdown.dart index e12a0aa..a0586a0 100644 --- a/lib/features/app_layout/view/widgets/app_bar_home_dropdown.dart +++ b/lib/features/app_layout/view/widgets/app_bar_home_dropdown.dart @@ -1,6 +1,5 @@ import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; -import 'package:gap/gap.dart'; import 'package:syncrow_app/utils/resource_manager/color_manager.dart'; import '../../../../generated/assets.dart'; @@ -30,9 +29,9 @@ class AppBarHomeDropdown extends StatelessWidget { BlendMode.srcIn, ), ), - const Gap(5), + const SizedBox(width: 5), const BodyLarge(text: 'Home'), - const Gap(5), + const SizedBox(width: 5), const Icon( Icons.expand_more, color: Colors.black, diff --git a/lib/features/auth/view/widgets/auth_view_body.dart b/lib/features/auth/view/widgets/auth_view_body.dart index ad603ed..9a85799 100644 --- a/lib/features/auth/view/widgets/auth_view_body.dart +++ b/lib/features/auth/view/widgets/auth_view_body.dart @@ -1,5 +1,4 @@ import 'package:flutter/material.dart'; -import 'package:gap/gap.dart'; import 'package:syncrow_app/features/shared_widgets/default_text_button.dart'; import 'package:syncrow_app/features/shared_widgets/syncrow_logo.dart'; @@ -26,12 +25,12 @@ class AuthViewBody extends StatelessWidget { Navigator.popAndPushNamed(context, Routes.homeRoute); }, ), - const Gap(15), + const SizedBox(height: 15), const DefaultTextButton( text: 'Sign Up', isSecondary: true, ), - const Gap(20), + const SizedBox(height: 20), Center( child: InkWell( onTap: () {}, @@ -43,7 +42,7 @@ class AuthViewBody extends StatelessWidget { ), ), ), - const Gap(30), + const SizedBox(height: 30), ], ), ); diff --git a/lib/features/dashboard/view/dashboard_view.dart b/lib/features/dashboard/view/dashboard_view.dart index 99a50d7..1a20482 100644 --- a/lib/features/dashboard/view/dashboard_view.dart +++ b/lib/features/dashboard/view/dashboard_view.dart @@ -1,7 +1,6 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter/widgets.dart'; -import 'package:gap/gap.dart'; import 'package:syncrow_app/features/dashboard/view/widgets/carbon_emission.dart'; import 'package:syncrow_app/features/dashboard/view/widgets/consumption.dart'; import 'package:syncrow_app/features/dashboard/view/widgets/live_monitor_tab.dart'; @@ -28,7 +27,7 @@ class DashboardView extends StatelessWidget { ), ), const LiveMonitorTab(), - const Gap(10), + const SizedBox(height: 10), const EnergyUsage(), Container( padding: const EdgeInsets.only(top: 20), @@ -40,7 +39,7 @@ class DashboardView extends StatelessWidget { mainAxisAlignment: MainAxisAlignment.start, children: [ Consumption(), - Gap(20), + SizedBox(height: 20), CarbonEmission(), ], ), diff --git a/lib/features/dashboard/view/widgets/carbon_emission.dart b/lib/features/dashboard/view/widgets/carbon_emission.dart index 87dcb60..0e47a9f 100644 --- a/lib/features/dashboard/view/widgets/carbon_emission.dart +++ b/lib/features/dashboard/view/widgets/carbon_emission.dart @@ -1,6 +1,5 @@ import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; -import 'package:gap/gap.dart'; import 'package:syncrow_app/features/dashboard/view/widgets/card_title.dart'; import 'package:syncrow_app/features/shared_widgets/text_widgets/body_small.dart'; import 'package:syncrow_app/features/shared_widgets/united_text.dart'; @@ -31,7 +30,7 @@ class CarbonEmission extends StatelessWidget { const CardTitle( title: "Carbon Emission", ), - const Gap(10), + const SizedBox(height: 10), Row( mainAxisAlignment: MainAxisAlignment.start, children: [ @@ -46,7 +45,7 @@ class CarbonEmission extends StatelessWidget { fit: BoxFit.contain, ), ), - const Gap(5), + const SizedBox(height: 5), const Column( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, @@ -64,7 +63,7 @@ class CarbonEmission extends StatelessWidget { ), ], ), - const Gap(20), + const SizedBox(width: 20), Row( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, @@ -76,7 +75,7 @@ class CarbonEmission extends StatelessWidget { fit: BoxFit.contain, ), ), - const Gap(5), + const SizedBox(width: 5), const Column( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, diff --git a/lib/features/dashboard/view/widgets/consumption.dart b/lib/features/dashboard/view/widgets/consumption.dart index 0952b87..6cd1e84 100644 --- a/lib/features/dashboard/view/widgets/consumption.dart +++ b/lib/features/dashboard/view/widgets/consumption.dart @@ -1,5 +1,4 @@ import 'package:flutter/material.dart'; -import 'package:gap/gap.dart'; import 'package:syncrow_app/features/dashboard/view/widgets/card_title.dart'; import 'package:syncrow_app/features/shared_widgets/united_text.dart'; import 'package:syncrow_app/utils/resource_manager/strings_manager.dart'; @@ -44,7 +43,7 @@ class Consumption extends StatelessWidget { valueWeight: FontWeight.normal, unit: "Units", ), - const Gap(30), + const SizedBox(width: 30), UnitedText( value: "${MediaQuery.sizeOf(context).height.ceil()}", valueSize: MediaQuery.sizeOf(context).height.ceil() > 680 diff --git a/lib/features/dashboard/view/widgets/live_monitor_widget.dart b/lib/features/dashboard/view/widgets/live_monitor_widget.dart index d670232..87a97b8 100644 --- a/lib/features/dashboard/view/widgets/live_monitor_widget.dart +++ b/lib/features/dashboard/view/widgets/live_monitor_widget.dart @@ -1,6 +1,5 @@ import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; -import 'package:gap/gap.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'; @@ -37,7 +36,7 @@ class LiveMonitorWidget extends StatelessWidget { fit: BoxFit.contain, ), ), - const Gap(5), + const SizedBox(width: 5), Column( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, diff --git a/lib/features/devices/view/widgets/ACs/ac_interface.dart b/lib/features/devices/view/widgets/ACs/ac_interface.dart index 5bf5be2..7e180dc 100644 --- a/lib/features/devices/view/widgets/ACs/ac_interface.dart +++ b/lib/features/devices/view/widgets/ACs/ac_interface.dart @@ -1,7 +1,6 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter/widgets.dart'; -import 'package:gap/gap.dart'; import 'package:syncrow_app/features/devices/model/ac_model.dart'; import 'package:syncrow_app/features/devices/view/widgets/ACs/ac_interface_controls.dart'; import 'package:syncrow_app/features/devices/view/widgets/ACs/ac_interface_temp_unit.dart'; @@ -17,7 +16,7 @@ class AcInterface extends StatelessWidget { child: Column( crossAxisAlignment: CrossAxisAlignment.stretch, children: [ - const Gap(20), + const SizedBox(height: 20), ConstrainedBox( constraints: const BoxConstraints( maxHeight: 400, diff --git a/lib/features/devices/view/widgets/ACs/ac_interface_controls.dart b/lib/features/devices/view/widgets/ACs/ac_interface_controls.dart index b22d69d..d8cc102 100644 --- a/lib/features/devices/view/widgets/ACs/ac_interface_controls.dart +++ b/lib/features/devices/view/widgets/ACs/ac_interface_controls.dart @@ -1,6 +1,5 @@ import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; -import 'package:gap/gap.dart'; import 'package:syncrow_app/features/devices/model/ac_model.dart'; import 'package:syncrow_app/features/devices/view/widgets/ACs/ac_mode_control_unit.dart'; import 'package:syncrow_app/features/shared_widgets/default_container.dart'; @@ -21,9 +20,9 @@ class AcInterfaceControls extends StatelessWidget { flex: 3, child: Column( children: [ - const Gap(10), + const SizedBox(height: 10), ACModeControlUnit(model: acModel), - Gap(10), + const SizedBox(height: 10), Row( children: [ Expanded( @@ -37,7 +36,7 @@ class AcInterfaceControls extends StatelessWidget { ), ), ), - const Gap(10), + const SizedBox(width: 10), Expanded( child: InkWell( onTap: () {}, diff --git a/lib/features/devices/view/widgets/ACs/ac_mode_control_unit.dart b/lib/features/devices/view/widgets/ACs/ac_mode_control_unit.dart index c87e977..08d5328 100644 --- a/lib/features/devices/view/widgets/ACs/ac_mode_control_unit.dart +++ b/lib/features/devices/view/widgets/ACs/ac_mode_control_unit.dart @@ -1,6 +1,5 @@ import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; -import 'package:gap/gap.dart'; import 'package:syncrow_app/features/devices/model/ac_model.dart'; import 'package:syncrow_app/features/shared_widgets/default_container.dart'; @@ -53,7 +52,7 @@ class _ACModeControlUnitState extends State { ), ), ), - const Gap(10), + const SizedBox(width: 10), Expanded( child: InkWell( onTap: () { diff --git a/lib/features/devices/view/widgets/ACs/acs_list.dart b/lib/features/devices/view/widgets/ACs/acs_list.dart index 8079fcb..00b7e4b 100644 --- a/lib/features/devices/view/widgets/ACs/acs_list.dart +++ b/lib/features/devices/view/widgets/ACs/acs_list.dart @@ -1,5 +1,4 @@ import 'package:flutter/material.dart'; -import 'package:gap/gap.dart'; import 'package:syncrow_app/features/devices/bloc/ac_cubit.dart'; import 'package:syncrow_app/features/devices/bloc/devices_cubit.dart'; import 'package:syncrow_app/features/devices/view/widgets/ACs/ac_mode_control_unit.dart'; @@ -21,13 +20,13 @@ class ACsList extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.stretch, children: [ // universal AC controller - const Gap(10), + const SizedBox(height: 10), const BodySmall(text: "All ACs"), - const Gap(5), + const SizedBox(height: 5), const UniversalACSwitch(), - const Gap(10), + const SizedBox(height: 10), const UniversalACTemp(), - const Gap(10), + const SizedBox(height: 10), // other ACs controls ListView.builder( @@ -63,19 +62,19 @@ class ACsList extends StatelessWidget { ), ], ), - const Gap(5), + const SizedBox(height: 5), DevicesDefaultSwitch( model: DevicesCubit.categories[0].devices[index], ), - const Gap(10), + const SizedBox(height: 10), ACTempWidget( index, ), - const Gap(10), + const SizedBox(height: 10), ACModeControlUnit( model: DevicesCubit.categories[0].devices[index], ), - const Gap(10), + const SizedBox(height: 10), ], ); }, diff --git a/lib/features/devices/view/widgets/devices_mode_tab.dart b/lib/features/devices/view/widgets/devices_mode_tab.dart index 3c071c5..4ee9877 100644 --- a/lib/features/devices/view/widgets/devices_mode_tab.dart +++ b/lib/features/devices/view/widgets/devices_mode_tab.dart @@ -1,6 +1,5 @@ import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; -import 'package:gap/gap.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/resource_manager/strings_manager.dart'; @@ -34,7 +33,7 @@ class DevicesModeTab extends StatelessWidget { fit: BoxFit.contain, ), ), - const Gap(5), + const SizedBox(width: 5), const BodySmall( text: StringsManager.winter, fontWeight: FontWeight.bold, @@ -62,7 +61,7 @@ class DevicesModeTab extends StatelessWidget { fit: BoxFit.contain, ), ), - const Gap(5), + const SizedBox(width: 5), const BodySmall( text: StringsManager.summer, fontWeight: FontWeight.bold, diff --git a/lib/features/devices/view/widgets/no_devices_view.dart b/lib/features/devices/view/widgets/no_devices_view.dart index e718b72..27b9029 100644 --- a/lib/features/devices/view/widgets/no_devices_view.dart +++ b/lib/features/devices/view/widgets/no_devices_view.dart @@ -1,5 +1,4 @@ import 'package:flutter/material.dart'; -import 'package:gap/gap.dart'; import 'package:syncrow_app/features/shared_widgets/default_text_button.dart'; import 'package:syncrow_app/generated/assets.dart'; @@ -20,7 +19,7 @@ class NoDevicesView extends StatelessWidget { scale: 1, width: 140, ), - const Gap(15), + const SizedBox(height: 15), const Text( 'No Devices', style: TextStyle( @@ -28,7 +27,7 @@ class NoDevicesView extends StatelessWidget { fontSize: 18, ), ), - const Gap(15), + const SizedBox(height: 15), const DefaultTextButton( text: 'Add Device', ), diff --git a/lib/features/menu/view/widgets/menu_list.dart b/lib/features/menu/view/widgets/menu_list.dart index 8cb2064..88410c2 100644 --- a/lib/features/menu/view/widgets/menu_list.dart +++ b/lib/features/menu/view/widgets/menu_list.dart @@ -1,5 +1,4 @@ import 'package:flutter/material.dart'; -import 'package:gap/gap.dart'; import 'package:syncrow_app/features/menu/model/menu_list_model.dart'; import 'package:syncrow_app/features/menu/view/widgets/menu_list_divider.dart'; import 'package:syncrow_app/features/menu/view/widgets/menu_list_item.dart'; @@ -19,11 +18,11 @@ class MenuList extends StatelessWidget { return Column( crossAxisAlignment: CrossAxisAlignment.stretch, children: [ - const Gap(5), + const SizedBox(height: 5), BodySmall( text: listModel.label!, ), - const Gap(5), + const SizedBox(height: 5), DefaultContainer( child: ListView.separated( shrinkWrap: true, @@ -37,7 +36,7 @@ class MenuList extends StatelessWidget { }, separatorBuilder: (context, index) => const MenuListDivider()), ), - const Gap(5), + const SizedBox(height: 5), ], ); } diff --git a/lib/features/menu/view/widgets/profile_tab.dart b/lib/features/menu/view/widgets/profile_tab.dart index cf030e5..16dc836 100644 --- a/lib/features/menu/view/widgets/profile_tab.dart +++ b/lib/features/menu/view/widgets/profile_tab.dart @@ -1,5 +1,4 @@ import 'package:flutter/material.dart'; -import 'package:gap/gap.dart'; import 'package:syncrow_app/features/shared_widgets/default_container.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'; @@ -20,7 +19,7 @@ class ProfileTab extends StatelessWidget { Column( crossAxisAlignment: CrossAxisAlignment.stretch, children: [ - Gap(20), + SizedBox(height: 20), DefaultContainer( child: Column( crossAxisAlignment: CrossAxisAlignment.start, diff --git a/lib/features/scene/view/scene_view.dart b/lib/features/scene/view/scene_view.dart index 26e51c6..28e87bd 100644 --- a/lib/features/scene/view/scene_view.dart +++ b/lib/features/scene/view/scene_view.dart @@ -1,6 +1,5 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; -import 'package:gap/gap.dart'; import 'package:syncrow_app/features/scene/bloc/scene_cubit.dart'; import 'package:syncrow_app/features/shared_widgets/default_container.dart'; import 'package:syncrow_app/features/shared_widgets/text_widgets/body_medium.dart'; @@ -29,7 +28,7 @@ class SceneView extends StatelessWidget { fontWeight: FontWeight.bold, ), ), - const Gap(20), + const SizedBox(height: 20), const BodySmall( text: StringsManager.tapToRunRoutine, ), @@ -71,7 +70,7 @@ class SceneView extends StatelessWidget { ), ), ), - const Gap(10), + const SizedBox(width: 10), Expanded( child: Padding( padding: const EdgeInsets.symmetric( diff --git a/lib/features/scene/view/widgets/scene_view_no_scenes.dart b/lib/features/scene/view/widgets/scene_view_no_scenes.dart index cd9e8c8..2c884ea 100644 --- a/lib/features/scene/view/widgets/scene_view_no_scenes.dart +++ b/lib/features/scene/view/widgets/scene_view_no_scenes.dart @@ -1,5 +1,4 @@ import 'package:flutter/material.dart'; -import 'package:gap/gap.dart'; import 'package:syncrow_app/features/shared_widgets/default_text_button.dart'; import 'package:syncrow_app/generated/assets.dart'; @@ -22,13 +21,13 @@ class SceneViewNoScenes extends StatelessWidget { opacity: const AlwaysStoppedAnimation(.5), width: 140, ), - const Gap(15), + const SizedBox(height: 15), const Text( 'Home automation saves your time and effort by automating routine tasks.', textAlign: TextAlign.center, style: TextStyle(color: Colors.grey), ), - const Gap(20), + const SizedBox(height: 20), const DefaultTextButton( text: 'Create Scene', ) diff --git a/pubspec.lock b/pubspec.lock index cfe04c8..d2be830 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -349,14 +349,6 @@ packages: description: flutter source: sdk version: "0.0.0" - gap: - dependency: "direct main" - description: - name: gap - sha256: f19387d4e32f849394758b91377f9153a1b41d79513ef7668c088c77dbc6955d - url: "https://pub.dev" - source: hosted - version: "3.0.1" get_it: dependency: "direct main" description: @@ -397,30 +389,6 @@ packages: url: "https://pub.dev" source: hosted version: "0.6.7" - leak_tracker: - dependency: transitive - description: - name: leak_tracker - sha256: "78eb209deea09858f5269f5a5b02be4049535f568c07b275096836f01ea323fa" - url: "https://pub.dev" - source: hosted - version: "10.0.0" - leak_tracker_flutter_testing: - dependency: transitive - description: - name: leak_tracker_flutter_testing - sha256: b46c5e37c19120a8a01918cfaf293547f47269f7cb4b0058f21531c2465d6ef0 - url: "https://pub.dev" - source: hosted - version: "2.0.1" - leak_tracker_testing: - dependency: transitive - description: - name: leak_tracker_testing - sha256: a597f72a664dbd293f3bfc51f9ba69816f84dcd403cdac7066cb3f6003f3ab47 - url: "https://pub.dev" - source: hosted - version: "2.0.1" lints: dependency: transitive description: @@ -433,26 +401,26 @@ packages: dependency: transitive description: name: matcher - sha256: d2323aa2060500f906aa31a895b4030b6da3ebdcc5619d14ce1aada65cd161cb + sha256: "1803e76e6653768d64ed8ff2e1e67bea3ad4b923eb5c56a295c3e634bad5960e" url: "https://pub.dev" source: hosted - version: "0.12.16+1" + version: "0.12.16" material_color_utilities: dependency: transitive description: name: material_color_utilities - sha256: "0e0a020085b65b6083975e499759762399b4475f766c21668c4ecca34ea74e5a" + sha256: "9528f2f296073ff54cb9fee677df673ace1218163c3bc7628093e7eed5203d41" url: "https://pub.dev" source: hosted - version: "0.8.0" + version: "0.5.0" meta: dependency: transitive description: name: meta - sha256: d584fa6707a52763a52446f02cc621b077888fb63b93bbcb1143a7be5a0c0c04 + sha256: a6e590c838b18133bb482a2745ad77c5bb7715fb0451209e1a7567d416678b8e url: "https://pub.dev" source: hosted - version: "1.11.0" + version: "1.10.0" nested: dependency: transitive description: @@ -473,10 +441,10 @@ packages: dependency: transitive description: name: path - sha256: "087ce49c3f0dc39180befefc60fdb4acd8f8620e5682fe2476afd0b3688bb4af" + sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917" url: "https://pub.dev" source: hosted - version: "1.9.0" + version: "1.8.3" path_parsing: dependency: transitive description: @@ -834,14 +802,6 @@ packages: url: "https://pub.dev" source: hosted version: "2.1.4" - vm_service: - dependency: transitive - description: - name: vm_service - sha256: b3d56ff4341b8f182b96aceb2fa20e3dcb336b9f867bc0eafc0de10f1048e957 - url: "https://pub.dev" - source: hosted - version: "13.0.0" web: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index a730530..362751d 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -17,11 +17,9 @@ dependencies: cupertino_icons: ^1.0.6 shared_preferences: ^2.2.2 flutter_animated_dialog: ^2.0.1 - gap: ^3.0.1 flutter_svg: ^2.0.9 - sleek_circular_slider: ^2.0.1 - fl_chart: ^0.66.2 + sleek_circular_slider: ^2.0.1 # Utility Packages flutter_secure_storage: ^9.0.0 @@ -49,7 +47,6 @@ flutter: - assets/images/ - assets/icons/ - assets/fonts/ - - assets/ fonts: - family: Aftika fonts: From 82038363326ecb6fcb961653387fac29edd93a3d Mon Sep 17 00:00:00 2001 From: Mohammad Salameh Date: Sat, 2 Mar 2024 15:59:32 +0300 Subject: [PATCH 2/9] Update firebase and flutter_svg versions. --- pubspec.lock | 52 ++++++++++++++++++++++++++-------------------------- pubspec.yaml | 12 ++++++------ 2 files changed, 32 insertions(+), 32 deletions(-) diff --git a/pubspec.lock b/pubspec.lock index d2be830..842688a 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -5,10 +5,10 @@ packages: dependency: transitive description: name: _flutterfire_internals - sha256: "737321f9be522620ed3794937298fb0027a48a402624fa2500f7532f94aea810" + sha256: fe4c077084ddda88f327dc1c96d16631cd68d4948644593fcbcd911c2c89e2fa url: "https://pub.dev" source: hosted - version: "1.3.22" + version: "1.3.23" args: dependency: transitive description: @@ -149,34 +149,34 @@ packages: dependency: "direct main" description: name: firebase_analytics - sha256: "54681f6a8c35ec782c86680919953edbae66517a718fe7606a7ba52cfa1b36ca" + sha256: c6220b23397f9302a42617227ee8fb1c5d718097a5351fcce53561d73fc10339 url: "https://pub.dev" source: hosted - version: "10.8.6" + version: "10.8.7" firebase_analytics_platform_interface: dependency: transitive description: name: firebase_analytics_platform_interface - sha256: cf7378f407c26fd1f1cc808c0d791f2a15dd4f1fe0626bb2ce6a96663c4d8470 + sha256: "7f1c02cdd93a5e0a561af2f551465ffb6abdd541dbd0c8a9b8628d9ae0a5d024" url: "https://pub.dev" source: hosted - version: "3.9.6" + version: "3.9.7" firebase_analytics_web: dependency: transitive description: name: firebase_analytics_web - sha256: f62c7a2514771f6e122c5b55227c0c7fdaa253cc2fe6efce768897c0fb68a5ab + sha256: ebb857c23f35fed52220b6c3271c12eeb6137de3930845223e3d0590b6fd0649 url: "https://pub.dev" source: hosted - version: "0.5.5+18" + version: "0.5.5+19" firebase_core: dependency: "direct main" description: name: firebase_core - sha256: "7e049e32a9d347616edb39542cf92cd53fdb4a99fb6af0a0bff327c14cd76445" + sha256: "797379ea206eaeeb62499775de812761493d0692890fdc7f90b6183a3369176d" url: "https://pub.dev" source: hosted - version: "2.25.4" + version: "2.25.5" firebase_core_platform_interface: dependency: transitive description: @@ -189,26 +189,26 @@ packages: dependency: transitive description: name: firebase_core_web - sha256: "57e61d6010e253b36d38191cefd6199d7849152cdcd234b61ca290cdb278a0ba" + sha256: c8e1d59385eee98de63c92f961d2a7062c5d9a65e7f45bdc7f1b0b205aab2492 url: "https://pub.dev" source: hosted - version: "2.11.4" + version: "2.11.5" firebase_crashlytics: dependency: "direct main" description: name: firebase_crashlytics - sha256: "4c754db28a7daabe03c4cbf1079dbe81e6f0681284fed6d07e0e640b7f1027c4" + sha256: "0126fa101b74fb981796b3e6f47ccf7fc40237ec918327aaec7c0a06fd1bb4c1" url: "https://pub.dev" source: hosted - version: "3.4.15" + version: "3.4.16" firebase_crashlytics_platform_interface: dependency: transitive description: name: firebase_crashlytics_platform_interface - sha256: "08c5d7b5f93dbad7306d26702935abd8b579313ea256eb27006562a1867df249" + sha256: cdfa0a20d66e1b32de542883c0ddf651ee9b66b12cebf73067e4d2cdc0865d17 url: "https://pub.dev" source: hosted - version: "3.6.22" + version: "3.6.23" fixnum: dependency: transitive description: @@ -335,10 +335,10 @@ packages: dependency: "direct main" description: name: flutter_svg - sha256: d39e7f95621fc84376bc0f7d504f05c3a41488c562f4a8ad410569127507402c + sha256: "7b4ca6cf3304575fe9c8ec64813c8d02ee41d2afe60bcfe0678bcb5375d596a2" url: "https://pub.dev" source: hosted - version: "2.0.9" + version: "2.0.10+1" flutter_test: dependency: "direct dev" description: flutter @@ -702,10 +702,10 @@ packages: dependency: "direct main" description: name: url_launcher - sha256: c512655380d241a337521703af62d2c122bf7b77a46ff7dd750092aa9433499c + sha256: "0ecc004c62fd3ed36a2ffcbe0dd9700aee63bd7532d0b642a488b1ec310f492e" url: "https://pub.dev" source: hosted - version: "6.2.4" + version: "6.2.5" url_launcher_android: dependency: transitive description: @@ -774,26 +774,26 @@ packages: dependency: transitive description: name: vector_graphics - sha256: "4ac59808bbfca6da38c99f415ff2d3a5d7ca0a6b4809c71d9cf30fba5daf9752" + sha256: "32c3c684e02f9bc0afb0ae0aa653337a2fe022e8ab064bcd7ffda27a74e288e3" url: "https://pub.dev" source: hosted - version: "1.1.10+1" + version: "1.1.11+1" vector_graphics_codec: dependency: transitive description: name: vector_graphics_codec - sha256: f3247e7ab0ec77dc759263e68394990edc608fb2b480b80db8aa86ed09279e33 + sha256: c86987475f162fadff579e7320c7ddda04cd2fdeffbe1129227a85d9ac9e03da url: "https://pub.dev" source: hosted - version: "1.1.10+1" + version: "1.1.11+1" vector_graphics_compiler: dependency: transitive description: name: vector_graphics_compiler - sha256: "18489bdd8850de3dd7ca8a34e0c446f719ec63e2bab2e7a8cc66a9028dd76c5a" + sha256: "12faff3f73b1741a36ca7e31b292ddeb629af819ca9efe9953b70bd63fc8cd81" url: "https://pub.dev" source: hosted - version: "1.1.10+1" + version: "1.1.11+1" vector_math: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 362751d..38457fc 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -17,7 +17,7 @@ dependencies: cupertino_icons: ^1.0.6 shared_preferences: ^2.2.2 flutter_animated_dialog: ^2.0.1 - flutter_svg: ^2.0.9 + flutter_svg: ^2.0.10+1 fl_chart: ^0.66.2 sleek_circular_slider: ^2.0.1 @@ -25,15 +25,15 @@ dependencies: flutter_secure_storage: ^9.0.0 cached_network_image: ^3.3.1 flutter_dotenv: ^5.1.0 - intl: ^0.18.1 + intl: ^0.18.0 get_it: ^7.6.7 - url_launcher: ^6.2.4 + url_launcher: ^6.2.5 dio: ^5.4.1 flutter_localization: ^0.2.0 flutter_bloc: ^8.1.4 - firebase_core: ^2.25.4 - firebase_analytics: ^10.8.6 - firebase_crashlytics: ^3.4.15 + firebase_core: ^2.25.5 + firebase_analytics: ^10.8.7 + firebase_crashlytics: ^3.4.16 dev_dependencies: flutter_test: From bcaed7a4b8e3f730d2bc4a5361e4e070e25ecfa7 Mon Sep 17 00:00:00 2001 From: Mohammad Salameh Date: Sat, 2 Mar 2024 21:57:11 +0300 Subject: [PATCH 3/9] Converted all the devices models to extends from DeviceModel for the purpose of unifying. Initialized Lights feature. --- .../devices/bloc/{ => ac}/ac_cubit.dart | 53 ++++++++----------- .../devices/bloc/{ => ac}/ac_state.dart | 0 lib/features/devices/bloc/devices_cubit.dart | 40 ++++++++++++-- .../devices/bloc/lights/lights_cubit.dart | 9 ++++ .../devices/bloc/lights/lights_state.dart | 5 ++ lib/features/devices/model/ac_model.dart | 48 +++++++++++++---- .../devices/model/device_category_model.dart | 7 ++- lib/features/devices/model/device_model.dart | 20 +++++++ lib/features/devices/model/light_model.dart | 51 ++++++++++++++++++ .../widgets/ACs/ac_interface_temp_unit.dart | 2 +- .../view/widgets/ACs/ac_temp_widget.dart | 2 +- .../devices/view/widgets/ACs/acs_list.dart | 31 +++++++---- .../devices/view/widgets/ACs/acs_view.dart | 2 +- .../view/widgets/ACs/universal_ac_switch.dart | 2 +- .../view/widgets/ACs/universal_ac_temp.dart | 2 +- .../view/widgets/lights/lights_view.dart | 12 ++++- .../devices_default_switch.dart | 10 ++-- 17 files changed, 229 insertions(+), 67 deletions(-) rename lib/features/devices/bloc/{ => ac}/ac_cubit.dart (68%) rename lib/features/devices/bloc/{ => ac}/ac_state.dart (100%) create mode 100644 lib/features/devices/bloc/lights/lights_cubit.dart create mode 100644 lib/features/devices/bloc/lights/lights_state.dart create mode 100644 lib/features/devices/model/device_model.dart create mode 100644 lib/features/devices/model/light_model.dart diff --git a/lib/features/devices/bloc/ac_cubit.dart b/lib/features/devices/bloc/ac/ac_cubit.dart similarity index 68% rename from lib/features/devices/bloc/ac_cubit.dart rename to lib/features/devices/bloc/ac/ac_cubit.dart index e6a0a1f..a02e49d 100644 --- a/lib/features/devices/bloc/ac_cubit.dart +++ b/lib/features/devices/bloc/ac/ac_cubit.dart @@ -1,6 +1,5 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; -import 'package:meta/meta.dart'; import 'package:syncrow_app/features/devices/bloc/devices_cubit.dart'; import 'package:syncrow_app/features/devices/model/ac_model.dart'; @@ -8,7 +7,6 @@ part 'ac_state.dart'; class AcCubit extends Cubit { AcCubit() : super(AcInitial()) { - averageTempForAll(); updateACsStatus(); } @@ -21,7 +19,7 @@ class AcCubit extends Cubit { ACModel? getSelectedAC() { for (var ac in DevicesCubit.categories[0].devices) { - if (ac.isSelected) { + if (ac is ACModel && ac.isSelected) { return ac; } } @@ -29,7 +27,7 @@ class AcCubit extends Cubit { } void turnACOn(ACModel model) { - if (!model.status) { + if (model.status == false) { model.status = true; updateACsStatus(); emit(ACTurnedOn()); @@ -37,7 +35,7 @@ class AcCubit extends Cubit { } void turnACOff(ACModel model) { - if (model.status) { + if (model.status == true) { model.status = false; updateACsStatus(); emit(ACTurnedOff()); @@ -45,7 +43,7 @@ class AcCubit extends Cubit { } void updateACsStatus() { - bool tempStatus = DevicesCubit.categories[0].devices[0].status; + bool tempStatus = DevicesCubit.categories[0].devices[0].status ?? false; for (var AC in DevicesCubit.categories[0].devices) { //check if there any AC have a different status than the initial ==> turn off the universal switch if (AC.status != tempStatus) { @@ -75,49 +73,44 @@ class AcCubit extends Cubit { } void setTempToAll(double temperature) { - for (var ac in DevicesCubit.categories[0].devices) { - ac.temperature = temperature; + for (var element in DevicesCubit.categories[0].devices) { + if (element is ACModel) { + element.temperature = temperature; + } } - averageTempForAll(); emit(ACsTempChanged(temperature)); } void increaseACTemp(int index) { - DevicesCubit.categories[0].devices[index].temperature += .5; - averageTempForAll(); - emit(ACsTempChanged(DevicesCubit.categories[0].devices[index].temperature)); + var device = DevicesCubit.categories[0].devices[index]; + if (device is ACModel) { + device.temperature += 0.5; + emit(ACsTempChanged(device.temperature)); + } } void decreaseACTemp(int index) { - DevicesCubit.categories[0].devices[index].temperature -= .5; - averageTempForAll(); - emit(ACsTempChanged(DevicesCubit.categories[0].devices[index].temperature)); + var device = DevicesCubit.categories[0].devices[index]; + if (device is ACModel) { + device.temperature -= 0.5; + emit(ACsTempChanged(device.temperature)); + } } void setACTemp(ACModel model, double temp) { model.temperature = temp; - averageTempForAll(); emit(ACsTempChanged(temp)); } double getTemp(int index) { - return DevicesCubit.categories[0].devices[index].temperature; + var device = DevicesCubit.categories[0].devices[index]; + if (device is ACModel) { + return device.temperature; + } + return 0.0; // or any default value you prefer } static double averageTemp = 0; - void averageTempForAll() { - double tempSum = 0; - for (var ac in DevicesCubit.categories[0].devices) { - tempSum += ac.temperature; - } - - averageTemp = tempSum / DevicesCubit.categories[0].devices.length; - - averageTemp = (averageTemp * 2).round() / 2; - - emit(ACsAverageTemp()); - } - /// implement the fan speed and temp mode change } diff --git a/lib/features/devices/bloc/ac_state.dart b/lib/features/devices/bloc/ac/ac_state.dart similarity index 100% rename from lib/features/devices/bloc/ac_state.dart rename to lib/features/devices/bloc/ac/ac_state.dart diff --git a/lib/features/devices/bloc/devices_cubit.dart b/lib/features/devices/bloc/devices_cubit.dart index 7fe69cf..452632e 100644 --- a/lib/features/devices/bloc/devices_cubit.dart +++ b/lib/features/devices/bloc/devices_cubit.dart @@ -1,6 +1,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:syncrow_app/features/devices/model/ac_model.dart'; +import 'package:syncrow_app/features/devices/model/light_model.dart'; import 'package:syncrow_app/features/devices/view/widgets/curtains/curtain_view.dart'; import 'package:syncrow_app/features/devices/view/widgets/gateway/gateway_view.dart'; import 'package:syncrow_app/features/devices/view/widgets/screens/screens_view.dart'; @@ -28,7 +29,7 @@ class DevicesCubit extends Cubit { static DevicesCubit get(context) => BlocProvider.of(context); - static var categories = [ + static List categories = [ DevicesCategoryModel( devices: [ ACModel( @@ -38,6 +39,10 @@ class DevicesCubit extends Cubit { temperature: 20, fanSpeed: 0, tempMode: 0, + type: '', + location: '', + image: '', + timer: null, ), ACModel( name: "Master Bedroom AC", @@ -46,6 +51,10 @@ class DevicesCubit extends Cubit { temperature: 20, fanSpeed: 0, tempMode: 0, + type: '', + location: '', + image: '', + timer: null, ), ], icon: Assets.iconsAC, @@ -54,7 +63,32 @@ class DevicesCubit extends Cubit { page: const ACsView(), ), DevicesCategoryModel( - devices: [], + devices: [ + LightModel( + name: "Living Room Light", + id: '0', + status: false, + color: 0, + brightness: 20, + lightingMode: 1, + timer: null, + type: '', + location: '', + image: '', + ), + LightModel( + name: "Master Bedroom Light", + id: '1', + status: false, + color: 2, + brightness: 40, + lightingMode: 1, + timer: null, + type: '', + location: '', + image: '', + ), + ], icon: Assets.iconsLight, name: 'Lights', type: DeviceType.Lights, @@ -101,7 +135,7 @@ class DevicesCubit extends Cubit { void areAllDevicesOff(DevicesCategoryModel category) { for (var device in category.devices) { - if (device.status) { + if (device.status ?? false) { category.devicesStatus = false; emit(CategorySwitchChanged()); return; diff --git a/lib/features/devices/bloc/lights/lights_cubit.dart b/lib/features/devices/bloc/lights/lights_cubit.dart new file mode 100644 index 0000000..0ce32e9 --- /dev/null +++ b/lib/features/devices/bloc/lights/lights_cubit.dart @@ -0,0 +1,9 @@ +import 'package:flutter_bloc/flutter_bloc.dart'; + +part 'lights_state.dart'; + +class LightsCubit extends Cubit { + LightsCubit() : super(LightsInitial()); + + static LightsCubit get(context) => BlocProvider.of(context); +} diff --git a/lib/features/devices/bloc/lights/lights_state.dart b/lib/features/devices/bloc/lights/lights_state.dart new file mode 100644 index 0000000..96b8e90 --- /dev/null +++ b/lib/features/devices/bloc/lights/lights_state.dart @@ -0,0 +1,5 @@ +part of 'lights_cubit.dart'; + +abstract class LightsState {} + +class LightsInitial extends LightsState {} diff --git a/lib/features/devices/model/ac_model.dart b/lib/features/devices/model/ac_model.dart index cf342a8..db012e8 100644 --- a/lib/features/devices/model/ac_model.dart +++ b/lib/features/devices/model/ac_model.dart @@ -1,21 +1,51 @@ -class ACModel { - final String name; - final String id; - late bool status; +import 'package:syncrow_app/features/devices/model/device_model.dart'; + +class ACModel extends DeviceModel { late double temperature; late int fanSpeed; late int tempMode; - bool isSelected = false; - ACModel({ - required this.name, - required this.id, - required this.status, required this.temperature, required this.fanSpeed, required this.tempMode, + required super.id, + required super.name, + required super.type, + required super.status, + required super.location, + required super.image, + required super.timer, }); + + Map toJson() { + return { + 'temperature': temperature, + 'fanSpeed': fanSpeed, + 'tempMode': tempMode, + 'id': id, + 'name': name, + 'status': status, + 'type': type, + 'location': location, + 'image': image, + }; + } + + factory ACModel.fromJson(Map json) { + return ACModel( + id: json['id'], + name: json['name'], + status: json['status'], + temperature: json['temperature'], + fanSpeed: json['fanSpeed'], + tempMode: json['tempMode'], + type: json['type'], + location: json['location'], + image: json['image'], + timer: json['timer'], + ); + } } diff --git a/lib/features/devices/model/device_category_model.dart b/lib/features/devices/model/device_category_model.dart index 172bcf4..b6ff99d 100644 --- a/lib/features/devices/model/device_category_model.dart +++ b/lib/features/devices/model/device_category_model.dart @@ -1,6 +1,5 @@ import 'package:flutter/cupertino.dart'; - -import 'ac_model.dart'; +import 'package:syncrow_app/features/devices/model/device_model.dart'; class DevicesCategoryModel { final String name; @@ -9,7 +8,7 @@ class DevicesCategoryModel { final Widget page; bool devicesStatus = false; - final List devices; + final List devices; final DeviceType type; bool isSelected; @@ -23,7 +22,7 @@ class DevicesCategoryModel { required this.devices}) { //sets the initial status of the devices if (devices.isNotEmpty) { - bool tempStatus = devices.first.status; + bool tempStatus = devices.first.status ?? false; for (var device in devices) { if (device.status != tempStatus) { devicesStatus = false; diff --git a/lib/features/devices/model/device_model.dart b/lib/features/devices/model/device_model.dart new file mode 100644 index 0000000..f4c5b9c --- /dev/null +++ b/lib/features/devices/model/device_model.dart @@ -0,0 +1,20 @@ +abstract class DeviceModel { + final String? id; + final String? name; + final String? type; + bool? status; + final String? location; + final String? image; + final double? timer; + bool isSelected = false; + + DeviceModel({ + required this.id, + required this.name, + required this.type, + required this.status, + required this.location, + required this.image, + required this.timer, + }); +} diff --git a/lib/features/devices/model/light_model.dart b/lib/features/devices/model/light_model.dart new file mode 100644 index 0000000..1d694d7 --- /dev/null +++ b/lib/features/devices/model/light_model.dart @@ -0,0 +1,51 @@ +import 'package:syncrow_app/features/devices/model/device_model.dart'; + +class LightModel extends DeviceModel { + final double brightness; + final int color; + + final int lightingMode; + + LightModel({ + required this.brightness, + required this.color, + required this.lightingMode, + required super.id, + required super.name, + required super.type, + required super.status, + required super.location, + required super.image, + required super.timer, + }); + + Map toJson() { + return { + 'luminance': brightness, + 'color': color, + 'lightingMode': lightingMode, + 'timer': timer, + 'id': id, + 'name': name, + 'status': status, + 'type': type, + 'location': location, + 'image': image, + }; + } + + factory LightModel.fromJson(Map json) { + return LightModel( + id: json['id'], + name: json['name'], + status: json['status'], + brightness: json['luminance'], + color: json['color'], + lightingMode: json['lightingMode'], + timer: json['timer'], + type: json['type'], + location: json['location'], + image: json['image'], + ); + } +} diff --git a/lib/features/devices/view/widgets/ACs/ac_interface_temp_unit.dart b/lib/features/devices/view/widgets/ACs/ac_interface_temp_unit.dart index 298689b..3859014 100644 --- a/lib/features/devices/view/widgets/ACs/ac_interface_temp_unit.dart +++ b/lib/features/devices/view/widgets/ACs/ac_interface_temp_unit.dart @@ -2,7 +2,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:sleek_circular_slider/sleek_circular_slider.dart'; -import 'package:syncrow_app/features/devices/bloc/ac_cubit.dart'; +import 'package:syncrow_app/features/devices/bloc/AC/ac_cubit.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'; diff --git a/lib/features/devices/view/widgets/ACs/ac_temp_widget.dart b/lib/features/devices/view/widgets/ACs/ac_temp_widget.dart index daa72c1..22e53b4 100644 --- a/lib/features/devices/view/widgets/ACs/ac_temp_widget.dart +++ b/lib/features/devices/view/widgets/ACs/ac_temp_widget.dart @@ -1,7 +1,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_svg/flutter_svg.dart'; -import 'package:syncrow_app/features/devices/bloc/ac_cubit.dart'; +import 'package:syncrow_app/features/devices/bloc/AC/ac_cubit.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/utils/context_extension.dart'; diff --git a/lib/features/devices/view/widgets/ACs/acs_list.dart b/lib/features/devices/view/widgets/ACs/acs_list.dart index 00b7e4b..f9465de 100644 --- a/lib/features/devices/view/widgets/ACs/acs_list.dart +++ b/lib/features/devices/view/widgets/ACs/acs_list.dart @@ -1,5 +1,5 @@ import 'package:flutter/material.dart'; -import 'package:syncrow_app/features/devices/bloc/ac_cubit.dart'; +import 'package:syncrow_app/features/devices/bloc/AC/ac_cubit.dart'; import 'package:syncrow_app/features/devices/bloc/devices_cubit.dart'; import 'package:syncrow_app/features/devices/view/widgets/ACs/ac_mode_control_unit.dart'; import 'package:syncrow_app/features/devices/view/widgets/ACs/ac_temp_widget.dart'; @@ -8,6 +8,8 @@ import 'package:syncrow_app/features/devices/view/widgets/ACs/universal_ac_temp. import 'package:syncrow_app/features/shared_widgets/devices_default_switch.dart'; import 'package:syncrow_app/features/shared_widgets/text_widgets/body_small.dart'; +import '../../../model/ac_model.dart'; + class ACsList extends StatelessWidget { const ACsList({ super.key, @@ -43,11 +45,16 @@ class ACsList extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.end, children: [ BodySmall( - text: DevicesCubit.categories[0].devices[index].name), + text: + DevicesCubit.categories[0].devices[index].name ?? + ""), IconButton( onPressed: () { - AcCubit.get(context).selectAC( - DevicesCubit.categories[0].devices[index]); + var device = + DevicesCubit.categories[0].devices[index]; + if (device is ACModel) { + AcCubit.get(context).selectAC(device); + } }, icon: const Icon( Icons.arrow_forward_ios, @@ -63,17 +70,21 @@ class ACsList extends StatelessWidget { ], ), const SizedBox(height: 5), - DevicesDefaultSwitch( - model: DevicesCubit.categories[0].devices[index], - ), + if (DevicesCubit.categories[0].devices[index] is ACModel) + DevicesDefaultSwitch( + model: + DevicesCubit.categories[0].devices[index] as ACModel, + ), const SizedBox(height: 10), ACTempWidget( index, ), const SizedBox(height: 10), - ACModeControlUnit( - model: DevicesCubit.categories[0].devices[index], - ), + if (DevicesCubit.categories[0].devices[index] is ACModel) + ACModeControlUnit( + model: + DevicesCubit.categories[0].devices[index] as ACModel, + ), const SizedBox(height: 10), ], ); diff --git a/lib/features/devices/view/widgets/ACs/acs_view.dart b/lib/features/devices/view/widgets/ACs/acs_view.dart index 0df5a6e..a4ff23c 100644 --- a/lib/features/devices/view/widgets/ACs/acs_view.dart +++ b/lib/features/devices/view/widgets/ACs/acs_view.dart @@ -3,7 +3,7 @@ import 'package:flutter/services.dart'; import 'package:flutter_bloc/flutter_bloc.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/devices/bloc/ac_cubit.dart'; +import 'package:syncrow_app/features/devices/bloc/AC/ac_cubit.dart'; import 'package:syncrow_app/features/devices/model/ac_model.dart'; import 'package:syncrow_app/features/devices/view/widgets/ACs/ac_interface.dart'; import 'package:syncrow_app/features/devices/view/widgets/ACs/acs_list.dart'; diff --git a/lib/features/devices/view/widgets/ACs/universal_ac_switch.dart b/lib/features/devices/view/widgets/ACs/universal_ac_switch.dart index 4de5c8e..1d3567d 100644 --- a/lib/features/devices/view/widgets/ACs/universal_ac_switch.dart +++ b/lib/features/devices/view/widgets/ACs/universal_ac_switch.dart @@ -4,7 +4,7 @@ import 'package:syncrow_app/features/devices/bloc/devices_cubit.dart'; import '../../../../../utils/resource_manager/color_manager.dart'; import '../../../../shared_widgets/text_widgets/body_medium.dart'; -import '../../../bloc/ac_cubit.dart'; +import '../../../bloc/AC/ac_cubit.dart'; class UniversalACSwitch extends StatelessWidget { const UniversalACSwitch({ diff --git a/lib/features/devices/view/widgets/ACs/universal_ac_temp.dart b/lib/features/devices/view/widgets/ACs/universal_ac_temp.dart index fdb6ea2..aede043 100644 --- a/lib/features/devices/view/widgets/ACs/universal_ac_temp.dart +++ b/lib/features/devices/view/widgets/ACs/universal_ac_temp.dart @@ -1,7 +1,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_svg/svg.dart'; -import 'package:syncrow_app/features/devices/bloc/ac_cubit.dart'; +import 'package:syncrow_app/features/devices/bloc/AC/ac_cubit.dart'; import 'package:syncrow_app/utils/context_extension.dart'; import '../../../../../generated/assets.dart'; diff --git a/lib/features/devices/view/widgets/lights/lights_view.dart b/lib/features/devices/view/widgets/lights/lights_view.dart index 6ddbae5..979d944 100644 --- a/lib/features/devices/view/widgets/lights/lights_view.dart +++ b/lib/features/devices/view/widgets/lights/lights_view.dart @@ -1,10 +1,20 @@ import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; + +import '../../../bloc/lights/lights_cubit.dart'; class LightsView extends StatelessWidget { const LightsView({super.key}); @override Widget build(BuildContext context) { - return const Placeholder(); + return BlocProvider( + create: (context) => LightsCubit(), + child: BlocBuilder( + builder: (context, state) => const Center( + child: Text('LightsView'), + ), + ), + ); } } diff --git a/lib/features/shared_widgets/devices_default_switch.dart b/lib/features/shared_widgets/devices_default_switch.dart index 5d2a875..02c3337 100644 --- a/lib/features/shared_widgets/devices_default_switch.dart +++ b/lib/features/shared_widgets/devices_default_switch.dart @@ -1,6 +1,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; -import 'package:syncrow_app/features/devices/bloc/ac_cubit.dart'; +import 'package:syncrow_app/features/devices/bloc/AC/ac_cubit.dart'; import 'package:syncrow_app/features/devices/model/ac_model.dart'; import 'package:syncrow_app/features/shared_widgets/text_widgets/body_medium.dart'; import 'package:syncrow_app/utils/resource_manager/color_manager.dart'; @@ -27,7 +27,7 @@ class DevicesDefaultSwitch extends StatelessWidget { child: Container( height: 60, decoration: BoxDecoration( - color: model.status + color: model.status ?? false ? ColorsManager.primaryColor : Colors.white, borderRadius: const BorderRadius.only( @@ -38,7 +38,7 @@ class DevicesDefaultSwitch extends StatelessWidget { child: Center( child: BodyMedium( text: "ON", - fontColor: model.status ? Colors.white : null, + fontColor: model.status ?? false ? Colors.white : null, fontWeight: FontWeight.bold, ), ), @@ -53,7 +53,7 @@ class DevicesDefaultSwitch extends StatelessWidget { child: Container( height: 60, decoration: BoxDecoration( - color: model.status + color: model.status ?? false ? Colors.white : ColorsManager.primaryColor, borderRadius: const BorderRadius.only( @@ -64,7 +64,7 @@ class DevicesDefaultSwitch extends StatelessWidget { child: Center( child: BodyMedium( text: "OFF", - fontColor: model.status ? null : Colors.white, + fontColor: model.status ?? false ? null : Colors.white, fontWeight: FontWeight.bold, ), ), From 7e983297384e14d8840b2b665ee094e814b65ab5 Mon Sep 17 00:00:00 2001 From: Mohammad Salameh Date: Sun, 3 Mar 2024 11:37:30 +0300 Subject: [PATCH 4/9] added Null state from the AC universal switch (in case the status for the ACs are different from each other) --- ios/Podfile.lock | 12 ++--- lib/features/devices/bloc/ac/ac_cubit.dart | 4 +- lib/features/devices/bloc/devices_cubit.dart | 14 ++++-- .../devices/model/device_category_model.dart | 2 +- .../view/widgets/ACs/universal_ac_switch.dart | 35 +++++++++----- .../shared_widgets/custom_switch.dart | 18 ++++--- .../resource_manager/strings_manager.dart | 2 + pubspec.lock | 48 +++++++++++++++---- 8 files changed, 96 insertions(+), 39 deletions(-) diff --git a/ios/Podfile.lock b/ios/Podfile.lock index b19c726..f24671a 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -9,14 +9,14 @@ PODS: - Firebase/Crashlytics (10.20.0): - Firebase/CoreOnly - FirebaseCrashlytics (~> 10.20.0) - - firebase_analytics (10.8.6): + - firebase_analytics (10.8.7): - Firebase/Analytics (= 10.20.0) - firebase_core - Flutter - - firebase_core (2.25.4): + - firebase_core (2.25.5): - Firebase/CoreOnly (= 10.20.0) - Flutter - - firebase_crashlytics (3.4.15): + - firebase_crashlytics (3.4.16): - Firebase/Crashlytics (= 10.20.0) - firebase_core - Flutter @@ -188,9 +188,9 @@ EXTERNAL SOURCES: SPEC CHECKSUMS: Firebase: 10c8cb12fb7ad2ae0c09ffc86cd9c1ab392a0031 - firebase_analytics: 9c600045bfb4d16dd78593d18f32c99bb77e5001 - firebase_core: a46c312d8bae4defa3d009b2aa7b5b413aeb394e - firebase_crashlytics: 3054fbdd2b4a4a91f25a15e57c9f1bd2a9ed81ae + firebase_analytics: 2c1c3057d5da3bd3aab819f7e6ee153a4e46c59e + firebase_core: c8628c7ce80f79439149549052bff22f6784fbf5 + firebase_crashlytics: 012078b4eec6fc9716f97ba3da0f0e44a04e95b1 FirebaseAnalytics: a2731bf3670747ce8f65368b118d18aa8e368246 FirebaseCore: 28045c1560a2600d284b9c45a904fe322dc890b6 FirebaseCoreExtension: 1c044fd46e95036cccb29134757c499613f3f564 diff --git a/lib/features/devices/bloc/ac/ac_cubit.dart b/lib/features/devices/bloc/ac/ac_cubit.dart index a02e49d..dcb8509 100644 --- a/lib/features/devices/bloc/ac/ac_cubit.dart +++ b/lib/features/devices/bloc/ac/ac_cubit.dart @@ -43,11 +43,11 @@ class AcCubit extends Cubit { } void updateACsStatus() { - bool tempStatus = DevicesCubit.categories[0].devices[0].status ?? false; + bool? tempStatus = DevicesCubit.categories[0].devices[0].status; for (var AC in DevicesCubit.categories[0].devices) { //check if there any AC have a different status than the initial ==> turn off the universal switch if (AC.status != tempStatus) { - DevicesCubit.categories[0].devicesStatus = false; + DevicesCubit.categories[0].devicesStatus = null; emit(ACsStatusChanged()); return; } diff --git a/lib/features/devices/bloc/devices_cubit.dart b/lib/features/devices/bloc/devices_cubit.dart index 452632e..39cf86c 100644 --- a/lib/features/devices/bloc/devices_cubit.dart +++ b/lib/features/devices/bloc/devices_cubit.dart @@ -20,10 +20,18 @@ class DevicesCubit extends Cubit { } void changeCategorySwitchValue(DevicesCategoryModel category) { - category.devicesStatus = !category.devicesStatus; - for (var device in category.devices) { - device.status = category.devicesStatus; + if (category.devicesStatus != null) { + category.devicesStatus = !category.devicesStatus!; + for (var device in category.devices) { + device.status = category.devicesStatus; + } + } else { + category.devicesStatus = true; + for (var device in category.devices) { + device.status = true; + } } + emit(CategorySwitchChanged()); } diff --git a/lib/features/devices/model/device_category_model.dart b/lib/features/devices/model/device_category_model.dart index b6ff99d..e075802 100644 --- a/lib/features/devices/model/device_category_model.dart +++ b/lib/features/devices/model/device_category_model.dart @@ -7,7 +7,7 @@ class DevicesCategoryModel { final Widget page; - bool devicesStatus = false; + bool? devicesStatus = false; final List devices; final DeviceType type; diff --git a/lib/features/devices/view/widgets/ACs/universal_ac_switch.dart b/lib/features/devices/view/widgets/ACs/universal_ac_switch.dart index 1d3567d..a6abd5a 100644 --- a/lib/features/devices/view/widgets/ACs/universal_ac_switch.dart +++ b/lib/features/devices/view/widgets/ACs/universal_ac_switch.dart @@ -1,6 +1,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:syncrow_app/features/devices/bloc/devices_cubit.dart'; +import 'package:syncrow_app/utils/resource_manager/strings_manager.dart'; import '../../../../../utils/resource_manager/color_manager.dart'; import '../../../../shared_widgets/text_widgets/body_medium.dart'; @@ -13,9 +14,9 @@ class UniversalACSwitch extends StatelessWidget { @override Widget build(BuildContext context) { - //TODO: Move these to String Manager "ON" and "OFF" return BlocBuilder( builder: (context, state) { + bool? status = DevicesCubit.categories[0].devicesStatus; return Row( children: [ Expanded( @@ -26,8 +27,10 @@ class UniversalACSwitch extends StatelessWidget { child: Container( height: 60, decoration: BoxDecoration( - color: DevicesCubit.categories[0].devicesStatus - ? ColorsManager.primaryColor + color: status != null + ? status + ? ColorsManager.primaryColor + : Colors.white : Colors.white, borderRadius: const BorderRadius.only( topLeft: Radius.circular(15), @@ -36,9 +39,11 @@ class UniversalACSwitch extends StatelessWidget { ), child: Center( child: BodyMedium( - text: "ON", - fontColor: DevicesCubit.categories[0].devicesStatus - ? Colors.white + text: StringsManager.on, + fontColor: status != null + ? status + ? Colors.white + : null : null, fontWeight: FontWeight.bold, ), @@ -54,9 +59,11 @@ class UniversalACSwitch extends StatelessWidget { child: Container( height: 60, decoration: BoxDecoration( - color: DevicesCubit.categories[0].devicesStatus - ? Colors.white - : ColorsManager.primaryColor, + color: status != null + ? status + ? Colors.white + : ColorsManager.primaryColor + : Colors.white, borderRadius: const BorderRadius.only( topRight: Radius.circular(15), bottomRight: Radius.circular(15), @@ -64,10 +71,12 @@ class UniversalACSwitch extends StatelessWidget { ), child: Center( child: BodyMedium( - text: "OFF", - fontColor: DevicesCubit.categories[0].devicesStatus - ? null - : Colors.white, + text: StringsManager.off, + fontColor: status != null + ? status + ? null + : Colors.white + : null, fontWeight: FontWeight.bold, ), ), diff --git a/lib/features/shared_widgets/custom_switch.dart b/lib/features/shared_widgets/custom_switch.dart index 1d853d1..c84e445 100644 --- a/lib/features/shared_widgets/custom_switch.dart +++ b/lib/features/shared_widgets/custom_switch.dart @@ -22,8 +22,10 @@ class CustomSwitch extends StatelessWidget { height: 28.0, decoration: BoxDecoration( borderRadius: BorderRadius.circular(24.0), - color: category.devicesStatus - ? ColorsManager.primaryColor + color: category.devicesStatus != null + ? category.devicesStatus! + ? ColorsManager.primaryColor + : const Color(0xFFD9D9D9) : const Color(0xFFD9D9D9), ), child: Center( @@ -37,16 +39,20 @@ class CustomSwitch extends StatelessWidget { child: Padding( padding: const EdgeInsets.all(2.0), child: Container( - alignment: category.devicesStatus - ? Alignment.centerRight + alignment: category.devicesStatus != null + ? category.devicesStatus! + ? Alignment.centerRight + : Alignment.centerLeft : Alignment.centerLeft, child: Container( width: 20.0, height: 20.0, decoration: BoxDecoration( shape: BoxShape.circle, - color: category.devicesStatus - ? ColorsManager.primaryColor + color: category.devicesStatus != null + ? category.devicesStatus! + ? ColorsManager.primaryColor + : Colors.grey : Colors.grey, ), ), diff --git a/lib/utils/resource_manager/strings_manager.dart b/lib/utils/resource_manager/strings_manager.dart index 40512bb..a60d98e 100644 --- a/lib/utils/resource_manager/strings_manager.dart +++ b/lib/utils/resource_manager/strings_manager.dart @@ -22,4 +22,6 @@ class StringsManager { static const winterMode = 'Winter Mode'; static const summer = 'Summer'; static const summerMode = 'Summer Mode'; + static const on = 'ON'; + static const off = 'OFF'; } diff --git a/pubspec.lock b/pubspec.lock index 842688a..780b314 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -389,6 +389,30 @@ packages: url: "https://pub.dev" source: hosted version: "0.6.7" + leak_tracker: + dependency: transitive + description: + name: leak_tracker + sha256: "78eb209deea09858f5269f5a5b02be4049535f568c07b275096836f01ea323fa" + url: "https://pub.dev" + source: hosted + version: "10.0.0" + leak_tracker_flutter_testing: + dependency: transitive + description: + name: leak_tracker_flutter_testing + sha256: b46c5e37c19120a8a01918cfaf293547f47269f7cb4b0058f21531c2465d6ef0 + url: "https://pub.dev" + source: hosted + version: "2.0.1" + leak_tracker_testing: + dependency: transitive + description: + name: leak_tracker_testing + sha256: a597f72a664dbd293f3bfc51f9ba69816f84dcd403cdac7066cb3f6003f3ab47 + url: "https://pub.dev" + source: hosted + version: "2.0.1" lints: dependency: transitive description: @@ -401,26 +425,26 @@ packages: dependency: transitive description: name: matcher - sha256: "1803e76e6653768d64ed8ff2e1e67bea3ad4b923eb5c56a295c3e634bad5960e" + sha256: d2323aa2060500f906aa31a895b4030b6da3ebdcc5619d14ce1aada65cd161cb url: "https://pub.dev" source: hosted - version: "0.12.16" + version: "0.12.16+1" material_color_utilities: dependency: transitive description: name: material_color_utilities - sha256: "9528f2f296073ff54cb9fee677df673ace1218163c3bc7628093e7eed5203d41" + sha256: "0e0a020085b65b6083975e499759762399b4475f766c21668c4ecca34ea74e5a" url: "https://pub.dev" source: hosted - version: "0.5.0" + version: "0.8.0" meta: dependency: transitive description: name: meta - sha256: a6e590c838b18133bb482a2745ad77c5bb7715fb0451209e1a7567d416678b8e + sha256: d584fa6707a52763a52446f02cc621b077888fb63b93bbcb1143a7be5a0c0c04 url: "https://pub.dev" source: hosted - version: "1.10.0" + version: "1.11.0" nested: dependency: transitive description: @@ -441,10 +465,10 @@ packages: dependency: transitive description: name: path - sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917" + sha256: "087ce49c3f0dc39180befefc60fdb4acd8f8620e5682fe2476afd0b3688bb4af" url: "https://pub.dev" source: hosted - version: "1.8.3" + version: "1.9.0" path_parsing: dependency: transitive description: @@ -802,6 +826,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.1.4" + vm_service: + dependency: transitive + description: + name: vm_service + sha256: b3d56ff4341b8f182b96aceb2fa20e3dcb336b9f867bc0eafc0de10f1048e957 + url: "https://pub.dev" + source: hosted + version: "13.0.0" web: dependency: transitive description: From 136987c56a3733802225adb18746caa1a96962e1 Mon Sep 17 00:00:00 2001 From: Mohammad Salameh Date: Sun, 3 Mar 2024 13:05:34 +0300 Subject: [PATCH 5/9] built Lights List --- lib/features/devices/bloc/ac/ac_cubit.dart | 50 +------------- lib/features/devices/bloc/devices_cubit.dart | 43 +++++++++++- lib/features/devices/bloc/devices_state.dart | 6 +- .../devices/view/widgets/ACs/acs_list.dart | 6 +- .../view/widgets/lights/lights_list.dart | 56 ++++++++++++++++ .../view/widgets/lights/lights_view.dart | 67 ++++++++++++++++++- ...l_ac_switch.dart => universal_switch.dart} | 21 +++--- .../devices_default_switch.dart | 13 ++-- 8 files changed, 185 insertions(+), 77 deletions(-) create mode 100644 lib/features/devices/view/widgets/lights/lights_list.dart rename lib/features/devices/view/widgets/{ACs/universal_ac_switch.dart => universal_switch.dart} (81%) diff --git a/lib/features/devices/bloc/ac/ac_cubit.dart b/lib/features/devices/bloc/ac/ac_cubit.dart index dcb8509..99b44c0 100644 --- a/lib/features/devices/bloc/ac/ac_cubit.dart +++ b/lib/features/devices/bloc/ac/ac_cubit.dart @@ -6,9 +6,7 @@ import 'package:syncrow_app/features/devices/model/ac_model.dart'; part 'ac_state.dart'; class AcCubit extends Cubit { - AcCubit() : super(AcInitial()) { - updateACsStatus(); - } + AcCubit() : super(AcInitial()); static AcCubit get(context) => BlocProvider.of(context); @@ -26,52 +24,6 @@ class AcCubit extends Cubit { return null; } - void turnACOn(ACModel model) { - if (model.status == false) { - model.status = true; - updateACsStatus(); - emit(ACTurnedOn()); - } - } - - void turnACOff(ACModel model) { - if (model.status == true) { - model.status = false; - updateACsStatus(); - emit(ACTurnedOff()); - } - } - - void updateACsStatus() { - bool? tempStatus = DevicesCubit.categories[0].devices[0].status; - for (var AC in DevicesCubit.categories[0].devices) { - //check if there any AC have a different status than the initial ==> turn off the universal switch - if (AC.status != tempStatus) { - DevicesCubit.categories[0].devicesStatus = null; - emit(ACsStatusChanged()); - return; - } - DevicesCubit.categories[0].devicesStatus = tempStatus; - emit(ACsStatusChanged()); - } - } - - void turnAllACsOff() { - for (var ac in DevicesCubit.categories[0].devices) { - ac.status = false; - } - updateACsStatus(); - emit(SwitchACsOff()); - } - - void turnAllACsOn() { - for (var ac in DevicesCubit.categories[0].devices) { - ac.status = true; - } - updateACsStatus(); - emit(SwitchACsOn()); - } - void setTempToAll(double temperature) { for (var element in DevicesCubit.categories[0].devices) { if (element is ACModel) { diff --git a/lib/features/devices/bloc/devices_cubit.dart b/lib/features/devices/bloc/devices_cubit.dart index 39cf86c..27b5fa0 100644 --- a/lib/features/devices/bloc/devices_cubit.dart +++ b/lib/features/devices/bloc/devices_cubit.dart @@ -1,6 +1,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:syncrow_app/features/devices/model/ac_model.dart'; +import 'package:syncrow_app/features/devices/model/device_model.dart'; import 'package:syncrow_app/features/devices/model/light_model.dart'; import 'package:syncrow_app/features/devices/view/widgets/curtains/curtain_view.dart'; import 'package:syncrow_app/features/devices/view/widgets/gateway/gateway_view.dart'; @@ -15,9 +16,7 @@ import '../view/widgets/lights/lights_view.dart'; part 'devices_state.dart'; class DevicesCubit extends Cubit { - DevicesCubit() : super(DevicesInitial()) { - // getCategories(); - } + DevicesCubit() : super(DevicesInitial()); void changeCategorySwitchValue(DevicesCategoryModel category) { if (category.devicesStatus != null) { @@ -37,6 +36,44 @@ class DevicesCubit extends Cubit { static DevicesCubit get(context) => BlocProvider.of(context); + void turnOnOffDevice(DeviceModel device) { + device.status = !device.status!; + DevicesCategoryModel category = + categories.firstWhere((category) => category.devices.contains(device)); + updateDevicesStatus(category); + emit(DeviceSwitchChanged()); + } + + void updateDevicesStatus(DevicesCategoryModel category) { + bool? tempStatus = category.devices[0].status; + for (var AC in category.devices) { + //check if there any AC have a different status than the initial ==> turn off the universal switch + if (AC.status != tempStatus) { + category.devicesStatus = null; + emit(DeviceSwitchChanged()); + return; + } + category.devicesStatus = tempStatus; + emit(DeviceSwitchChanged()); + } + } + + void turnAllDevicesOff(DevicesCategoryModel category) { + for (var device in category.devices) { + device.status = false; + } + updateDevicesStatus(category); + emit(CategorySwitchChanged()); + } + + void turnAllDevicesOn(DevicesCategoryModel category) { + for (var device in category.devices) { + device.status = true; + } + updateDevicesStatus(category); + emit(CategorySwitchChanged()); + } + static List categories = [ DevicesCategoryModel( devices: [ diff --git a/lib/features/devices/bloc/devices_state.dart b/lib/features/devices/bloc/devices_state.dart index f68db64..a25c3f6 100644 --- a/lib/features/devices/bloc/devices_state.dart +++ b/lib/features/devices/bloc/devices_state.dart @@ -17,8 +17,4 @@ class DevicesCategoryChanged extends DevicesState {} class CategorySwitchChanged extends DevicesState {} -class SwitchACsOff extends DevicesState {} - -class SwitchACsOn extends DevicesState {} - -class SetACsTemp extends DevicesState {} +class DeviceSwitchChanged extends DevicesState {} diff --git a/lib/features/devices/view/widgets/ACs/acs_list.dart b/lib/features/devices/view/widgets/ACs/acs_list.dart index f9465de..cf5c03b 100644 --- a/lib/features/devices/view/widgets/ACs/acs_list.dart +++ b/lib/features/devices/view/widgets/ACs/acs_list.dart @@ -3,8 +3,8 @@ import 'package:syncrow_app/features/devices/bloc/AC/ac_cubit.dart'; import 'package:syncrow_app/features/devices/bloc/devices_cubit.dart'; import 'package:syncrow_app/features/devices/view/widgets/ACs/ac_mode_control_unit.dart'; import 'package:syncrow_app/features/devices/view/widgets/ACs/ac_temp_widget.dart'; -import 'package:syncrow_app/features/devices/view/widgets/ACs/universal_ac_switch.dart'; import 'package:syncrow_app/features/devices/view/widgets/ACs/universal_ac_temp.dart'; +import 'package:syncrow_app/features/devices/view/widgets/universal_switch.dart'; import 'package:syncrow_app/features/shared_widgets/devices_default_switch.dart'; import 'package:syncrow_app/features/shared_widgets/text_widgets/body_small.dart'; @@ -25,7 +25,9 @@ class ACsList extends StatelessWidget { const SizedBox(height: 10), const BodySmall(text: "All ACs"), const SizedBox(height: 5), - const UniversalACSwitch(), + UniversalSwitch( + category: DevicesCubit.categories[0], + ), const SizedBox(height: 10), const UniversalACTemp(), const SizedBox(height: 10), diff --git a/lib/features/devices/view/widgets/lights/lights_list.dart b/lib/features/devices/view/widgets/lights/lights_list.dart new file mode 100644 index 0000000..bdedcbf --- /dev/null +++ b/lib/features/devices/view/widgets/lights/lights_list.dart @@ -0,0 +1,56 @@ +import 'package:flutter/material.dart'; + +import '../../../../shared_widgets/devices_default_switch.dart'; +import '../../../../shared_widgets/text_widgets/body_small.dart'; +import '../../../model/light_model.dart'; + +class LightsList extends StatelessWidget { + const LightsList({ + super.key, + required this.lights, + }); + + final List lights; + + @override + Widget build(BuildContext context) { + return ListView.builder( + shrinkWrap: true, + physics: const NeverScrollableScrollPhysics(), + padding: const EdgeInsets.all(0), + itemCount: lights.length, + itemBuilder: (context, index) { + return Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.end, + children: [ + BodySmall(text: lights[index].name ?? ""), + IconButton( + onPressed: () { + var device = lights[index]; + // LightsCubit.get(context).selectAC(device); + }, + icon: const Icon( + Icons.arrow_forward_ios, + ), + style: ButtonStyle( + padding: MaterialStateProperty.all( + const EdgeInsets.all(0), + ), + iconSize: MaterialStateProperty.all(15), + alignment: Alignment.bottomRight, + ), + ), + ], + ), + const SizedBox(height: 5), + DevicesDefaultSwitch(model: lights[index]), + ], + ); + }, + ); + } +} diff --git a/lib/features/devices/view/widgets/lights/lights_view.dart b/lib/features/devices/view/widgets/lights/lights_view.dart index 979d944..8354efe 100644 --- a/lib/features/devices/view/widgets/lights/lights_view.dart +++ b/lib/features/devices/view/widgets/lights/lights_view.dart @@ -1,7 +1,17 @@ import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:syncrow_app/features/devices/view/widgets/lights/lights_list.dart'; +import '../../../../../generated/assets.dart'; +import '../../../../../utils/resource_manager/color_manager.dart'; +import '../../../../app_layout/view/widgets/default_app_bar.dart'; +import '../../../../app_layout/view/widgets/default_nav_bar.dart'; +import '../../../../shared_widgets/text_widgets/body_small.dart'; +import '../../../bloc/devices_cubit.dart'; import '../../../bloc/lights/lights_cubit.dart'; +import '../../../model/light_model.dart'; +import '../universal_switch.dart'; class LightsView extends StatelessWidget { const LightsView({super.key}); @@ -11,9 +21,60 @@ class LightsView extends StatelessWidget { return BlocProvider( create: (context) => LightsCubit(), child: BlocBuilder( - builder: (context, state) => const Center( - child: Text('LightsView'), - ), + builder: (context, state) { + List lights = []; + for (var device in DevicesCubit.categories[1].devices) { + if (device is LightModel) { + lights.add(device); + } + } + 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: const DefaultAppBar(), + body: Container( + width: MediaQuery.sizeOf(context).width, + height: MediaQuery.sizeOf(context).height, + decoration: const BoxDecoration( + image: DecorationImage( + image: AssetImage( + Assets.imagesBackground, + ), + fit: BoxFit.cover, + opacity: 0.4, + ), + ), + child: Padding( + padding: const EdgeInsets.only( + top: 60, right: 15, left: 15, bottom: 80), + child: SizedBox.expand( + child: SingleChildScrollView( + child: Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + const BodySmall(text: "All Lights"), + UniversalSwitch( + category: DevicesCubit.categories[1], + ), + LightsList(lights: lights), + ], + ), + ), + ), + ), + ), + bottomNavigationBar: const DefaultNavBar(), + ), + ), + ); + }, ), ); } diff --git a/lib/features/devices/view/widgets/ACs/universal_ac_switch.dart b/lib/features/devices/view/widgets/universal_switch.dart similarity index 81% rename from lib/features/devices/view/widgets/ACs/universal_ac_switch.dart rename to lib/features/devices/view/widgets/universal_switch.dart index a6abd5a..34a726d 100644 --- a/lib/features/devices/view/widgets/ACs/universal_ac_switch.dart +++ b/lib/features/devices/view/widgets/universal_switch.dart @@ -1,28 +1,31 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:syncrow_app/features/devices/bloc/devices_cubit.dart'; +import 'package:syncrow_app/features/devices/model/device_category_model.dart'; import 'package:syncrow_app/utils/resource_manager/strings_manager.dart'; -import '../../../../../utils/resource_manager/color_manager.dart'; -import '../../../../shared_widgets/text_widgets/body_medium.dart'; -import '../../../bloc/AC/ac_cubit.dart'; +import '../../../../utils/resource_manager/color_manager.dart'; +import '../../../shared_widgets/text_widgets/body_medium.dart'; -class UniversalACSwitch extends StatelessWidget { - const UniversalACSwitch({ +class UniversalSwitch extends StatelessWidget { + const UniversalSwitch({ super.key, + required this.category, }); + final DevicesCategoryModel category; + @override Widget build(BuildContext context) { - return BlocBuilder( + return BlocBuilder( builder: (context, state) { - bool? status = DevicesCubit.categories[0].devicesStatus; + bool? status = category.devicesStatus; return Row( children: [ Expanded( child: InkWell( onTap: () { - AcCubit.get(context).turnAllACsOn(); + DevicesCubit.get(context).turnAllDevicesOn(category); }, child: Container( height: 60, @@ -54,7 +57,7 @@ class UniversalACSwitch extends StatelessWidget { Expanded( child: InkWell( onTap: () { - AcCubit.get(context).turnAllACsOff(); + DevicesCubit.get(context).turnAllDevicesOff(category); }, child: Container( height: 60, diff --git a/lib/features/shared_widgets/devices_default_switch.dart b/lib/features/shared_widgets/devices_default_switch.dart index 02c3337..2d45c10 100644 --- a/lib/features/shared_widgets/devices_default_switch.dart +++ b/lib/features/shared_widgets/devices_default_switch.dart @@ -1,28 +1,29 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; -import 'package:syncrow_app/features/devices/bloc/AC/ac_cubit.dart'; -import 'package:syncrow_app/features/devices/model/ac_model.dart'; +import 'package:syncrow_app/features/devices/model/device_model.dart'; import 'package:syncrow_app/features/shared_widgets/text_widgets/body_medium.dart'; import 'package:syncrow_app/utils/resource_manager/color_manager.dart'; +import '../devices/bloc/devices_cubit.dart'; + class DevicesDefaultSwitch extends StatelessWidget { const DevicesDefaultSwitch({ super.key, required this.model, }); - final ACModel model; + final DeviceModel model; @override Widget build(BuildContext context) { - return BlocBuilder( + return BlocBuilder( builder: (context, state) { return Row( children: [ Expanded( child: InkWell( onTap: () { - AcCubit.get(context).turnACOn(model); + DevicesCubit.get(context).turnOnOffDevice(model); }, child: Container( height: 60, @@ -48,7 +49,7 @@ class DevicesDefaultSwitch extends StatelessWidget { Expanded( child: InkWell( onTap: () { - AcCubit.get(context).turnACOff(model); + DevicesCubit.get(context).turnOnOffDevice(model); }, child: Container( height: 60, From 643b206d4cc903f15e3d0edbb92e5ed083d62b7d Mon Sep 17 00:00:00 2001 From: Mohammad Salameh Date: Sun, 3 Mar 2024 13:10:03 +0300 Subject: [PATCH 6/9] cleaned some warring messages --- lib/features/auth/bloc/auth_cubit.dart | 3 +-- lib/features/auth/bloc/auth_state.dart | 1 - lib/features/dashboard/view/widgets/energy_usage.dart | 6 +++--- lib/features/devices/bloc/devices_cubit.dart | 6 +++--- lib/features/devices/model/device_category_model.dart | 2 ++ lib/features/devices/view/widgets/lights/lights_list.dart | 1 - lib/features/layout/bloc/layout_cubit.dart | 3 +-- lib/features/layout/bloc/layout_state.dart | 1 - lib/features/profile/bloc/profile_cubit.dart | 3 +-- lib/features/profile/bloc/profile_state.dart | 1 - lib/features/scene/bloc/scene_cubit.dart | 1 - lib/features/scene/bloc/scene_state.dart | 1 - lib/utils/resource_manager/strings_manager.dart | 2 +- 13 files changed, 12 insertions(+), 19 deletions(-) diff --git a/lib/features/auth/bloc/auth_cubit.dart b/lib/features/auth/bloc/auth_cubit.dart index 98fcf39..1a4fd4f 100644 --- a/lib/features/auth/bloc/auth_cubit.dart +++ b/lib/features/auth/bloc/auth_cubit.dart @@ -1,5 +1,4 @@ -import 'package:bloc/bloc.dart'; -import 'package:meta/meta.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; part 'auth_state.dart'; diff --git a/lib/features/auth/bloc/auth_state.dart b/lib/features/auth/bloc/auth_state.dart index 85a432a..6c008c2 100644 --- a/lib/features/auth/bloc/auth_state.dart +++ b/lib/features/auth/bloc/auth_state.dart @@ -1,6 +1,5 @@ part of 'auth_cubit.dart'; -@immutable abstract class AuthState {} class AuthInitial extends AuthState {} diff --git a/lib/features/dashboard/view/widgets/energy_usage.dart b/lib/features/dashboard/view/widgets/energy_usage.dart index 79f44e5..9c4dd1a 100644 --- a/lib/features/dashboard/view/widgets/energy_usage.dart +++ b/lib/features/dashboard/view/widgets/energy_usage.dart @@ -65,13 +65,13 @@ class EnergyUsage extends StatelessWidget { case 0: return SideTitleWidget( axisSide: meta.axisSide, - child: BodySmall(text: '1'), + child: const BodySmall(text: '1'), ); case 11: return SideTitleWidget( axisSide: meta.axisSide, - child: BodySmall(text: '28'), + child: const BodySmall(text: '28'), ); default: return Container(); @@ -172,7 +172,7 @@ class EnergyUsage extends StatelessWidget { return SideTitleWidget( axisSide: meta.axisSide, - child: BodySmall(text: 'Feb'), + child: const BodySmall(text: 'Feb'), ); } } diff --git a/lib/features/devices/bloc/devices_cubit.dart b/lib/features/devices/bloc/devices_cubit.dart index 27b5fa0..c8324a5 100644 --- a/lib/features/devices/bloc/devices_cubit.dart +++ b/lib/features/devices/bloc/devices_cubit.dart @@ -46,9 +46,9 @@ class DevicesCubit extends Cubit { void updateDevicesStatus(DevicesCategoryModel category) { bool? tempStatus = category.devices[0].status; - for (var AC in category.devices) { - //check if there any AC have a different status than the initial ==> turn off the universal switch - if (AC.status != tempStatus) { + for (var ac in category.devices) { + //check if there any ac have a different status than the initial ==> turn off the universal switch + if (ac.status != tempStatus) { category.devicesStatus = null; emit(DeviceSwitchChanged()); return; diff --git a/lib/features/devices/model/device_category_model.dart b/lib/features/devices/model/device_category_model.dart index e075802..1023ad8 100644 --- a/lib/features/devices/model/device_category_model.dart +++ b/lib/features/devices/model/device_category_model.dart @@ -1,3 +1,5 @@ +// ignore_for_file: constant_identifier_names + import 'package:flutter/cupertino.dart'; import 'package:syncrow_app/features/devices/model/device_model.dart'; diff --git a/lib/features/devices/view/widgets/lights/lights_list.dart b/lib/features/devices/view/widgets/lights/lights_list.dart index bdedcbf..5e0bafa 100644 --- a/lib/features/devices/view/widgets/lights/lights_list.dart +++ b/lib/features/devices/view/widgets/lights/lights_list.dart @@ -30,7 +30,6 @@ class LightsList extends StatelessWidget { BodySmall(text: lights[index].name ?? ""), IconButton( onPressed: () { - var device = lights[index]; // LightsCubit.get(context).selectAC(device); }, icon: const Icon( diff --git a/lib/features/layout/bloc/layout_cubit.dart b/lib/features/layout/bloc/layout_cubit.dart index 5285190..db65846 100644 --- a/lib/features/layout/bloc/layout_cubit.dart +++ b/lib/features/layout/bloc/layout_cubit.dart @@ -1,5 +1,4 @@ -import 'package:bloc/bloc.dart'; -import 'package:meta/meta.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; part 'layout_state.dart'; diff --git a/lib/features/layout/bloc/layout_state.dart b/lib/features/layout/bloc/layout_state.dart index d09b4e0..7127dc1 100644 --- a/lib/features/layout/bloc/layout_state.dart +++ b/lib/features/layout/bloc/layout_state.dart @@ -1,6 +1,5 @@ part of 'layout_cubit.dart'; -@immutable abstract class LayoutState {} class LayoutInitial extends LayoutState {} diff --git a/lib/features/profile/bloc/profile_cubit.dart b/lib/features/profile/bloc/profile_cubit.dart index 5748d7e..015ab62 100644 --- a/lib/features/profile/bloc/profile_cubit.dart +++ b/lib/features/profile/bloc/profile_cubit.dart @@ -1,5 +1,4 @@ -import 'package:bloc/bloc.dart'; -import 'package:meta/meta.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; part 'profile_state.dart'; diff --git a/lib/features/profile/bloc/profile_state.dart b/lib/features/profile/bloc/profile_state.dart index 471c7d5..1c91759 100644 --- a/lib/features/profile/bloc/profile_state.dart +++ b/lib/features/profile/bloc/profile_state.dart @@ -1,6 +1,5 @@ part of 'profile_cubit.dart'; -@immutable abstract class ProfileState {} class ProfileInitial extends ProfileState {} diff --git a/lib/features/scene/bloc/scene_cubit.dart b/lib/features/scene/bloc/scene_cubit.dart index 0bc5167..fe443d1 100644 --- a/lib/features/scene/bloc/scene_cubit.dart +++ b/lib/features/scene/bloc/scene_cubit.dart @@ -1,5 +1,4 @@ import 'package:flutter_bloc/flutter_bloc.dart'; -import 'package:meta/meta.dart'; import 'package:syncrow_app/features/scene/model/scene_model.dart'; part 'scene_state.dart'; diff --git a/lib/features/scene/bloc/scene_state.dart b/lib/features/scene/bloc/scene_state.dart index 5dce08c..352f8a6 100644 --- a/lib/features/scene/bloc/scene_state.dart +++ b/lib/features/scene/bloc/scene_state.dart @@ -1,6 +1,5 @@ part of 'scene_cubit.dart'; -@immutable abstract class SceneState {} class SceneInitial extends SceneState {} diff --git a/lib/utils/resource_manager/strings_manager.dart b/lib/utils/resource_manager/strings_manager.dart index a60d98e..04ca8cf 100644 --- a/lib/utils/resource_manager/strings_manager.dart +++ b/lib/utils/resource_manager/strings_manager.dart @@ -1,4 +1,4 @@ -// ignore_for_file: lines_longer_than_80_chars +// ignore_for_file: lines_longer_than_80_chars, constant_identifier_names class StringsManager { static const noRouteFound = 'No route found'; From 4cfae85f9c731b1fc5138498cff874f83c9b3cfe Mon Sep 17 00:00:00 2001 From: Mohammad Salameh Date: Sun, 3 Mar 2024 15:00:13 +0300 Subject: [PATCH 7/9] implemented light brightness slider optimised state emit to only emit when change is detected --- .../devices/bloc/lights/lights_cubit.dart | 23 +++++++ .../devices/bloc/lights/lights_state.dart | 16 +++++ lib/features/devices/model/light_model.dart | 6 +- .../view/widgets/lights/light_brightness.dart | 66 +++++++++++++++++++ .../view/widgets/lights/lights_list.dart | 3 + .../view/widgets/lights/lights_view.dart | 2 +- .../shared_widgets/default_container.dart | 5 +- 7 files changed, 116 insertions(+), 5 deletions(-) create mode 100644 lib/features/devices/view/widgets/lights/light_brightness.dart diff --git a/lib/features/devices/bloc/lights/lights_cubit.dart b/lib/features/devices/bloc/lights/lights_cubit.dart index 0ce32e9..700b846 100644 --- a/lib/features/devices/bloc/lights/lights_cubit.dart +++ b/lib/features/devices/bloc/lights/lights_cubit.dart @@ -1,4 +1,5 @@ import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:syncrow_app/features/devices/model/light_model.dart'; part 'lights_state.dart'; @@ -6,4 +7,26 @@ class LightsCubit extends Cubit { LightsCubit() : super(LightsInitial()); static LightsCubit get(context) => BlocProvider.of(context); + + int getBrightness(LightModel light) { + return light.brightness.toInt(); + } + + setBrightness(LightModel light, double value) { + value = (value / 5).ceil() * 5; + if (value != light.brightness) { + light.brightness = value; + emit(LightBrightnessChanged(value)); + } + } + + onHorizontalDragUpdate(LightModel light, double dx, double screenWidth) { + double newBrightness = (dx / (screenWidth - 15) * 100); + if (newBrightness > 100) { + newBrightness = 100; + } else if (newBrightness < 0) { + newBrightness = 0; + } + setBrightness(light, newBrightness); + } } diff --git a/lib/features/devices/bloc/lights/lights_state.dart b/lib/features/devices/bloc/lights/lights_state.dart index 96b8e90..f4a9ebe 100644 --- a/lib/features/devices/bloc/lights/lights_state.dart +++ b/lib/features/devices/bloc/lights/lights_state.dart @@ -3,3 +3,19 @@ part of 'lights_cubit.dart'; abstract class LightsState {} class LightsInitial extends LightsState {} + +class LightsLoading extends LightsState {} + +class LightsSuccess extends LightsState {} + +class LightsFailure extends LightsState { + final String message; + + LightsFailure(this.message); +} + +class LightBrightnessChanged extends LightsState { + final double brightness; + + LightBrightnessChanged(this.brightness); +} diff --git a/lib/features/devices/model/light_model.dart b/lib/features/devices/model/light_model.dart index 1d694d7..ef7f59f 100644 --- a/lib/features/devices/model/light_model.dart +++ b/lib/features/devices/model/light_model.dart @@ -1,10 +1,10 @@ import 'package:syncrow_app/features/devices/model/device_model.dart'; class LightModel extends DeviceModel { - final double brightness; - final int color; + late double brightness; + late int color; - final int lightingMode; + late int lightingMode; LightModel({ required this.brightness, diff --git a/lib/features/devices/view/widgets/lights/light_brightness.dart b/lib/features/devices/view/widgets/lights/light_brightness.dart new file mode 100644 index 0000000..7be2a50 --- /dev/null +++ b/lib/features/devices/view/widgets/lights/light_brightness.dart @@ -0,0 +1,66 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:syncrow_app/features/devices/bloc/lights/lights_cubit.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/utils/context_extension.dart'; +import 'package:syncrow_app/utils/resource_manager/color_manager.dart'; + +import '../../../model/light_model.dart'; + +class LightBrightness extends StatelessWidget { + const LightBrightness({ + super.key, + required this.light, + }); + + final LightModel light; + + @override + Widget build(BuildContext context) { + return BlocBuilder( + builder: (context, state) { + return GestureDetector( + onHorizontalDragUpdate: (details) => LightsCubit.get(context) + .onHorizontalDragUpdate(light, details.localPosition.dx, + MediaQuery.of(context).size.width - 15), + child: Stack( + alignment: Alignment.center, + children: [ + const DefaultContainer( + height: 60, + child: SizedBox.expand(), + ), + AnimatedPositioned( + left: 0, + duration: const Duration(milliseconds: 50), + child: Container( + height: 60, + width: (MediaQuery.of(context).size.width - 30) * + light.brightness / + 100, + decoration: BoxDecoration( + color: ColorsManager.primaryColor.withOpacity(0.6), + borderRadius: light.brightness != 100 + ? const BorderRadius.only( + topLeft: Radius.circular(20), + bottomLeft: Radius.circular(20), + ) + : BorderRadius.circular(20), + ), + ), + ), + BodyLarge( + text: "${light.brightness}%", + style: context.bodyLarge.copyWith( + color: Colors.black, + fontSize: 23, + ), + ), + ], + ), + ); + }, + ); + } +} diff --git a/lib/features/devices/view/widgets/lights/lights_list.dart b/lib/features/devices/view/widgets/lights/lights_list.dart index 5e0bafa..c2f1eee 100644 --- a/lib/features/devices/view/widgets/lights/lights_list.dart +++ b/lib/features/devices/view/widgets/lights/lights_list.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; +import 'package:syncrow_app/features/devices/view/widgets/lights/light_brightness.dart'; import '../../../../shared_widgets/devices_default_switch.dart'; import '../../../../shared_widgets/text_widgets/body_small.dart'; @@ -47,6 +48,8 @@ class LightsList extends StatelessWidget { ), const SizedBox(height: 5), DevicesDefaultSwitch(model: lights[index]), + const SizedBox(height: 10), + LightBrightness(light: lights[index]), ], ); }, diff --git a/lib/features/devices/view/widgets/lights/lights_view.dart b/lib/features/devices/view/widgets/lights/lights_view.dart index 8354efe..43566b3 100644 --- a/lib/features/devices/view/widgets/lights/lights_view.dart +++ b/lib/features/devices/view/widgets/lights/lights_view.dart @@ -53,7 +53,7 @@ class LightsView extends StatelessWidget { ), child: Padding( padding: const EdgeInsets.only( - top: 60, right: 15, left: 15, bottom: 80), + top: 70, right: 15, left: 15, bottom: 80), child: SizedBox.expand( child: SingleChildScrollView( child: Column( diff --git a/lib/features/shared_widgets/default_container.dart b/lib/features/shared_widgets/default_container.dart index a4f0047..48f5eeb 100644 --- a/lib/features/shared_widgets/default_container.dart +++ b/lib/features/shared_widgets/default_container.dart @@ -6,19 +6,22 @@ class DefaultContainer extends StatelessWidget { required this.child, this.height, this.width, + this.color, }); final double? height; final double? width; final Widget child; + final Color? color; + @override Widget build(BuildContext context) { return Container( height: height, width: width, decoration: BoxDecoration( - color: Colors.white, + color: color ?? Colors.white, borderRadius: BorderRadius.circular(20), ), padding: const EdgeInsets.all(10), From 24ccb243d4cbba393c2074de8dc20da9f2429582 Mon Sep 17 00:00:00 2001 From: Mohammad Salameh Date: Sun, 3 Mar 2024 16:17:00 +0300 Subject: [PATCH 8/9] fixed Universal AC temperature control --- lib/features/devices/bloc/ac/ac_cubit.dart | 28 +-- lib/features/devices/bloc/devices_cubit.dart | 172 ++++++++++++------ lib/features/devices/model/ac_model.dart | 5 + .../widgets/ACs/ac_interface_temp_unit.dart | 1 + .../view/widgets/ACs/ac_temp_widget.dart | 16 +- .../devices/view/widgets/ACs/acs_list.dart | 27 ++- .../view/widgets/ACs/universal_ac_temp.dart | 8 +- 7 files changed, 156 insertions(+), 101 deletions(-) diff --git a/lib/features/devices/bloc/ac/ac_cubit.dart b/lib/features/devices/bloc/ac/ac_cubit.dart index 99b44c0..6d2472c 100644 --- a/lib/features/devices/bloc/ac/ac_cubit.dart +++ b/lib/features/devices/bloc/ac/ac_cubit.dart @@ -2,6 +2,7 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:syncrow_app/features/devices/bloc/devices_cubit.dart'; import 'package:syncrow_app/features/devices/model/ac_model.dart'; +import 'package:syncrow_app/features/devices/model/device_model.dart'; part 'ac_state.dart'; @@ -25,30 +26,15 @@ class AcCubit extends Cubit { } void setTempToAll(double temperature) { - for (var element in DevicesCubit.categories[0].devices) { - if (element is ACModel) { - element.temperature = temperature; + for (DeviceModel ac in DevicesCubit.categories[0].devices) { + if (ac is ACModel) { + setACTemp(ac, temperature); } } + universalACTemp = temperature; emit(ACsTempChanged(temperature)); } - void increaseACTemp(int index) { - var device = DevicesCubit.categories[0].devices[index]; - if (device is ACModel) { - device.temperature += 0.5; - emit(ACsTempChanged(device.temperature)); - } - } - - void decreaseACTemp(int index) { - var device = DevicesCubit.categories[0].devices[index]; - if (device is ACModel) { - device.temperature -= 0.5; - emit(ACsTempChanged(device.temperature)); - } - } - void setACTemp(ACModel model, double temp) { model.temperature = temp; emit(ACsTempChanged(temp)); @@ -62,7 +48,5 @@ class AcCubit extends Cubit { return 0.0; // or any default value you prefer } - static double averageTemp = 0; - - /// implement the fan speed and temp mode change + static double universalACTemp = 20; } diff --git a/lib/features/devices/bloc/devices_cubit.dart b/lib/features/devices/bloc/devices_cubit.dart index c8324a5..3106329 100644 --- a/lib/features/devices/bloc/devices_cubit.dart +++ b/lib/features/devices/bloc/devices_cubit.dart @@ -18,62 +18,8 @@ part 'devices_state.dart'; class DevicesCubit extends Cubit { DevicesCubit() : super(DevicesInitial()); - void changeCategorySwitchValue(DevicesCategoryModel category) { - if (category.devicesStatus != null) { - category.devicesStatus = !category.devicesStatus!; - for (var device in category.devices) { - device.status = category.devicesStatus; - } - } else { - category.devicesStatus = true; - for (var device in category.devices) { - device.status = true; - } - } - - emit(CategorySwitchChanged()); - } - static DevicesCubit get(context) => BlocProvider.of(context); - void turnOnOffDevice(DeviceModel device) { - device.status = !device.status!; - DevicesCategoryModel category = - categories.firstWhere((category) => category.devices.contains(device)); - updateDevicesStatus(category); - emit(DeviceSwitchChanged()); - } - - void updateDevicesStatus(DevicesCategoryModel category) { - bool? tempStatus = category.devices[0].status; - for (var ac in category.devices) { - //check if there any ac have a different status than the initial ==> turn off the universal switch - if (ac.status != tempStatus) { - category.devicesStatus = null; - emit(DeviceSwitchChanged()); - return; - } - category.devicesStatus = tempStatus; - emit(DeviceSwitchChanged()); - } - } - - void turnAllDevicesOff(DevicesCategoryModel category) { - for (var device in category.devices) { - device.status = false; - } - updateDevicesStatus(category); - emit(CategorySwitchChanged()); - } - - void turnAllDevicesOn(DevicesCategoryModel category) { - for (var device in category.devices) { - device.status = true; - } - updateDevicesStatus(category); - emit(CategorySwitchChanged()); - } - static List categories = [ DevicesCategoryModel( devices: [ @@ -84,6 +30,7 @@ class DevicesCubit extends Cubit { temperature: 20, fanSpeed: 0, tempMode: 0, + coolTo: 20, type: '', location: '', image: '', @@ -96,6 +43,33 @@ class DevicesCubit extends Cubit { temperature: 20, fanSpeed: 0, tempMode: 0, + coolTo: 20, + type: '', + location: '', + image: '', + timer: null, + ), + ACModel( + name: "Kitchen AC", + id: '2', + status: false, + temperature: 20, + fanSpeed: 0, + tempMode: 0, + coolTo: 20, + type: '', + location: '', + image: '', + timer: null, + ), + ACModel( + name: "Bathroom AC", + id: '3', + status: false, + temperature: 20, + fanSpeed: 0, + tempMode: 0, + coolTo: 20, type: '', location: '', image: '', @@ -133,6 +107,42 @@ class DevicesCubit extends Cubit { location: '', image: '', ), + LightModel( + name: "Kitchen Light", + id: '2', + status: false, + color: 1, + brightness: 60, + lightingMode: 1, + timer: null, + type: '', + location: '', + image: '', + ), + LightModel( + name: "Bathroom Light", + id: '3', + status: false, + color: 3, + brightness: 80, + lightingMode: 1, + timer: null, + type: '', + location: '', + image: '', + ), + LightModel( + name: "Balcony Light", + id: '4', + status: false, + color: 4, + brightness: 100, + lightingMode: 1, + timer: null, + type: '', + location: '', + image: '', + ), ], icon: Assets.iconsLight, name: 'Lights', @@ -178,6 +188,60 @@ class DevicesCubit extends Cubit { return null; } + void changeCategorySwitchValue(DevicesCategoryModel category) { + if (category.devicesStatus != null) { + category.devicesStatus = !category.devicesStatus!; + for (var device in category.devices) { + device.status = category.devicesStatus; + } + } else { + category.devicesStatus = true; + for (var device in category.devices) { + device.status = true; + } + } + + emit(CategorySwitchChanged()); + } + + void turnOnOffDevice(DeviceModel device) { + device.status = !device.status!; + DevicesCategoryModel category = + categories.firstWhere((category) => category.devices.contains(device)); + updateDevicesStatus(category); + emit(DeviceSwitchChanged()); + } + + void updateDevicesStatus(DevicesCategoryModel category) { + bool? tempStatus = category.devices[0].status; + for (var ac in category.devices) { + //check if there any ac have a different status than the initial ==> turn off the universal switch + if (ac.status != tempStatus) { + category.devicesStatus = null; + emit(DeviceSwitchChanged()); + return; + } + category.devicesStatus = tempStatus; + emit(DeviceSwitchChanged()); + } + } + + void turnAllDevicesOff(DevicesCategoryModel category) { + for (var device in category.devices) { + device.status = false; + } + updateDevicesStatus(category); + emit(CategorySwitchChanged()); + } + + void turnAllDevicesOn(DevicesCategoryModel category) { + for (var device in category.devices) { + device.status = true; + } + updateDevicesStatus(category); + emit(CategorySwitchChanged()); + } + void areAllDevicesOff(DevicesCategoryModel category) { for (var device in category.devices) { if (device.status ?? false) { diff --git a/lib/features/devices/model/ac_model.dart b/lib/features/devices/model/ac_model.dart index db012e8..e81b234 100644 --- a/lib/features/devices/model/ac_model.dart +++ b/lib/features/devices/model/ac_model.dart @@ -7,10 +7,13 @@ class ACModel extends DeviceModel { late int tempMode; + late double coolTo; + ACModel({ required this.temperature, required this.fanSpeed, required this.tempMode, + required this.coolTo, required super.id, required super.name, required super.type, @@ -25,6 +28,7 @@ class ACModel extends DeviceModel { 'temperature': temperature, 'fanSpeed': fanSpeed, 'tempMode': tempMode, + 'coolTo': coolTo, 'id': id, 'name': name, 'status': status, @@ -46,6 +50,7 @@ class ACModel extends DeviceModel { location: json['location'], image: json['image'], timer: json['timer'], + coolTo: json['coolTo'], ); } } diff --git a/lib/features/devices/view/widgets/ACs/ac_interface_temp_unit.dart b/lib/features/devices/view/widgets/ACs/ac_interface_temp_unit.dart index 3859014..0b6887d 100644 --- a/lib/features/devices/view/widgets/ACs/ac_interface_temp_unit.dart +++ b/lib/features/devices/view/widgets/ACs/ac_interface_temp_unit.dart @@ -23,6 +23,7 @@ class AcInterfaceTempUnit extends StatelessWidget { @override Widget build(BuildContext context) { + //TODO: use the coolTo value from the model double coolTo = acModel.temperature; return BlocBuilder( builder: (context, state) { diff --git a/lib/features/devices/view/widgets/ACs/ac_temp_widget.dart b/lib/features/devices/view/widgets/ACs/ac_temp_widget.dart index 22e53b4..c3c4d4c 100644 --- a/lib/features/devices/view/widgets/ACs/ac_temp_widget.dart +++ b/lib/features/devices/view/widgets/ACs/ac_temp_widget.dart @@ -1,21 +1,21 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_svg/flutter_svg.dart'; -import 'package:syncrow_app/features/devices/bloc/AC/ac_cubit.dart'; -import 'package:syncrow_app/features/shared_widgets/default_container.dart'; +import 'package:syncrow_app/features/devices/bloc/AC/ac_cubit.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/utils/context_extension.dart'; import 'package:syncrow_app/utils/resource_manager/color_manager.dart'; import '../../../../../generated/assets.dart'; +import '../../../model/ac_model.dart'; class ACTempWidget extends StatelessWidget { const ACTempWidget( - this.index, { + this.acModel, { super.key, }); - final int index; + final ACModel acModel; @override Widget build(BuildContext context) { @@ -30,7 +30,8 @@ class ACTempWidget extends StatelessWidget { dimension: 24, child: InkWell( onTap: () { - AcCubit.get(context).decreaseACTemp(index); + AcCubit.get(context) + .setACTemp(acModel, acModel.temperature - 0.5); }, child: SvgPicture.asset( Assets.iconsMinus, @@ -38,7 +39,7 @@ class ACTempWidget extends StatelessWidget { ), ), BodyLarge( - text: "${AcCubit.get(context).getTemp(index)}° C", + text: "${acModel.temperature}° C", style: context.bodyLarge.copyWith( color: ColorsManager.primaryColor.withOpacity(0.6), fontSize: 23, @@ -48,7 +49,8 @@ class ACTempWidget extends StatelessWidget { dimension: 24, child: InkWell( onTap: () { - AcCubit.get(context).increaseACTemp(index); + AcCubit.get(context) + .setACTemp(acModel, acModel.temperature + 0.5); }, child: SvgPicture.asset( Assets.iconsPlus, diff --git a/lib/features/devices/view/widgets/ACs/acs_list.dart b/lib/features/devices/view/widgets/ACs/acs_list.dart index cf5c03b..9ec0024 100644 --- a/lib/features/devices/view/widgets/ACs/acs_list.dart +++ b/lib/features/devices/view/widgets/ACs/acs_list.dart @@ -1,6 +1,7 @@ import 'package:flutter/material.dart'; import 'package:syncrow_app/features/devices/bloc/AC/ac_cubit.dart'; import 'package:syncrow_app/features/devices/bloc/devices_cubit.dart'; +import 'package:syncrow_app/features/devices/model/device_category_model.dart'; import 'package:syncrow_app/features/devices/view/widgets/ACs/ac_mode_control_unit.dart'; import 'package:syncrow_app/features/devices/view/widgets/ACs/ac_temp_widget.dart'; import 'package:syncrow_app/features/devices/view/widgets/ACs/universal_ac_temp.dart'; @@ -17,6 +18,7 @@ class ACsList extends StatelessWidget { @override Widget build(BuildContext context) { + DevicesCategoryModel category = DevicesCubit.categories[0]; return SingleChildScrollView( child: Column( crossAxisAlignment: CrossAxisAlignment.stretch, @@ -26,7 +28,7 @@ class ACsList extends StatelessWidget { const BodySmall(text: "All ACs"), const SizedBox(height: 5), UniversalSwitch( - category: DevicesCubit.categories[0], + category: category, ), const SizedBox(height: 10), const UniversalACTemp(), @@ -37,8 +39,9 @@ class ACsList extends StatelessWidget { shrinkWrap: true, physics: const NeverScrollableScrollPhysics(), padding: const EdgeInsets.all(0), - itemCount: DevicesCubit.categories[0].devices.length, + itemCount: category.devices.length, itemBuilder: (context, index) { + ACModel ac = category.devices[index] as ACModel; return Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ @@ -46,14 +49,10 @@ class ACsList extends StatelessWidget { mainAxisAlignment: MainAxisAlignment.spaceBetween, crossAxisAlignment: CrossAxisAlignment.end, children: [ - BodySmall( - text: - DevicesCubit.categories[0].devices[index].name ?? - ""), + BodySmall(text: category.devices[index].name ?? ""), IconButton( onPressed: () { - var device = - DevicesCubit.categories[0].devices[index]; + var device = category.devices[index]; if (device is ACModel) { AcCubit.get(context).selectAC(device); } @@ -72,20 +71,18 @@ class ACsList extends StatelessWidget { ], ), const SizedBox(height: 5), - if (DevicesCubit.categories[0].devices[index] is ACModel) + if (category.devices[index] is ACModel) DevicesDefaultSwitch( - model: - DevicesCubit.categories[0].devices[index] as ACModel, + model: ac, ), const SizedBox(height: 10), ACTempWidget( - index, + ac, ), const SizedBox(height: 10), - if (DevicesCubit.categories[0].devices[index] is ACModel) + if (category.devices[index] is ACModel) ACModeControlUnit( - model: - DevicesCubit.categories[0].devices[index] as ACModel, + model: ac, ), const SizedBox(height: 10), ], diff --git a/lib/features/devices/view/widgets/ACs/universal_ac_temp.dart b/lib/features/devices/view/widgets/ACs/universal_ac_temp.dart index aede043..aa5d029 100644 --- a/lib/features/devices/view/widgets/ACs/universal_ac_temp.dart +++ b/lib/features/devices/view/widgets/ACs/universal_ac_temp.dart @@ -27,7 +27,8 @@ class UniversalACTemp extends StatelessWidget { dimension: 24, child: InkWell( onTap: () { - AcCubit.get(context).setTempToAll(AcCubit.averageTemp + .5); + AcCubit.get(context) + .setTempToAll(AcCubit.universalACTemp - .5); }, child: SvgPicture.asset( Assets.iconsMinus, @@ -35,7 +36,7 @@ class UniversalACTemp extends StatelessWidget { ), ), BodyLarge( - text: "${AcCubit.averageTemp}° C", + text: "${AcCubit.universalACTemp}° C", style: context.bodyLarge.copyWith( color: ColorsManager.primaryColor.withOpacity(0.6), fontSize: 23, @@ -45,7 +46,8 @@ class UniversalACTemp extends StatelessWidget { dimension: 24, child: InkWell( onTap: () { - AcCubit.get(context).setTempToAll(AcCubit.averageTemp + .5); + AcCubit.get(context) + .setTempToAll(AcCubit.universalACTemp + .5); }, child: SvgPicture.asset( Assets.iconsPlus, From ad511fe3af2c342322f6089d190d2f52780a1b84 Mon Sep 17 00:00:00 2001 From: Mohammad Salameh Date: Sun, 3 Mar 2024 17:01:08 +0300 Subject: [PATCH 9/9] added smooth_page_indicator for devices view body --- .../widgets/ACs/ac_interface_controls.dart | 57 +++++----- ...view.dart => devices_categories_view.dart} | 6 +- .../view/widgets/devices_view_body.dart | 100 +++++++++++++++++- .../devices/view/widgets/switches.dart | 5 +- lib/utils/helpers/custom_page_route.dart | 11 ++ pubspec.lock | 8 ++ pubspec.yaml | 2 + 7 files changed, 153 insertions(+), 36 deletions(-) rename lib/features/devices/view/widgets/{categories_view.dart => devices_categories_view.dart} (93%) create mode 100644 lib/utils/helpers/custom_page_route.dart diff --git a/lib/features/devices/view/widgets/ACs/ac_interface_controls.dart b/lib/features/devices/view/widgets/ACs/ac_interface_controls.dart index d8cc102..9403e1f 100644 --- a/lib/features/devices/view/widgets/ACs/ac_interface_controls.dart +++ b/lib/features/devices/view/widgets/ACs/ac_interface_controls.dart @@ -16,42 +16,39 @@ class AcInterfaceControls extends StatelessWidget { @override Widget build(BuildContext context) { - return Expanded( - flex: 3, - child: Column( - children: [ - const SizedBox(height: 10), - ACModeControlUnit(model: acModel), - const SizedBox(height: 10), - Row( - children: [ - Expanded( - child: InkWell( - onTap: () {}, - child: DefaultContainer( - height: 55, - child: Center( - child: SvgPicture.asset(Assets.iconsAutomatedClock), - ), + return Column( + children: [ + const SizedBox(height: 10), + ACModeControlUnit(model: acModel), + const SizedBox(height: 10), + Row( + children: [ + Expanded( + child: InkWell( + onTap: () {}, + child: DefaultContainer( + height: 55, + child: Center( + child: SvgPicture.asset(Assets.iconsAutomatedClock), ), ), ), - const SizedBox(width: 10), - Expanded( - child: InkWell( - onTap: () {}, - child: DefaultContainer( - height: 55, - child: Center( - child: SvgPicture.asset(Assets.iconsLock), - ), + ), + const SizedBox(width: 10), + Expanded( + child: InkWell( + onTap: () {}, + child: DefaultContainer( + height: 55, + child: Center( + child: SvgPicture.asset(Assets.iconsLock), ), ), ), - ], - ) - ], - ), + ), + ], + ) + ], ); } } diff --git a/lib/features/devices/view/widgets/categories_view.dart b/lib/features/devices/view/widgets/devices_categories_view.dart similarity index 93% rename from lib/features/devices/view/widgets/categories_view.dart rename to lib/features/devices/view/widgets/devices_categories_view.dart index fc5b41e..83965e2 100644 --- a/lib/features/devices/view/widgets/categories_view.dart +++ b/lib/features/devices/view/widgets/devices_categories_view.dart @@ -4,14 +4,14 @@ import 'package:syncrow_app/features/devices/view/widgets/switches.dart'; import 'package:syncrow_app/features/shared_widgets/text_widgets/title_medium.dart'; import 'package:syncrow_app/utils/resource_manager/strings_manager.dart'; -class CategoriesView extends StatelessWidget { - const CategoriesView({ +class DevicesCategoriesView extends StatelessWidget { + const DevicesCategoriesView({ super.key, }); @override Widget build(BuildContext context) { - return const Column( + return Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Expanded( diff --git a/lib/features/devices/view/widgets/devices_view_body.dart b/lib/features/devices/view/widgets/devices_view_body.dart index e2e28e6..cbc56fd 100644 --- a/lib/features/devices/view/widgets/devices_view_body.dart +++ b/lib/features/devices/view/widgets/devices_view_body.dart @@ -1,8 +1,12 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; -import 'package:syncrow_app/features/devices/view/widgets/categories_view.dart'; +import 'package:smooth_page_indicator/smooth_page_indicator.dart'; +import 'package:syncrow_app/features/devices/view/widgets/devices_categories_view.dart'; +import 'package:syncrow_app/features/shared_widgets/text_widgets/title_medium.dart'; +import '../../../../utils/resource_manager/strings_manager.dart'; import '../../bloc/devices_cubit.dart'; +import 'switches.dart'; class DevicesViewBody extends StatelessWidget { const DevicesViewBody({ @@ -15,9 +19,101 @@ class DevicesViewBody extends StatelessWidget { create: (context) => DevicesCubit(), child: BlocBuilder( builder: (context, state) { + PageController pageController = PageController(); return state is DevicesLoading ? const Center(child: CircularProgressIndicator()) - : const CategoriesView(); + : Column( + children: [ + SizedBox( + width: MediaQuery.sizeOf(context).width, + height: MediaQuery.sizeOf(context).height - 252, + child: PageView( + controller: pageController, + children: const [ + DevicesCategoriesView(), + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + TitleMedium( + text: "Home", + style: TextStyle( + fontSize: 32, + fontWeight: FontWeight.bold, + ), + ), + ], + ), + ), + Expanded( + flex: 3, + child: SingleChildScrollView( + child: Column( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + TitleMedium( + text: StringsManager.wizard, + style: TextStyle( + fontSize: 28, + ), + ), + Switches(), + ], + ), + ), + ) + ], + ), + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + TitleMedium( + text: "Office", + style: TextStyle( + fontSize: 32, + fontWeight: FontWeight.bold, + ), + ), + ], + ), + ), + Expanded( + flex: 3, + child: SingleChildScrollView( + child: Column( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + TitleMedium( + text: StringsManager.wizard, + style: TextStyle( + fontSize: 28, + ), + ), + Switches(), + ], + ), + ), + ) + ], + ), + ], + ), + ), + SmoothPageIndicator( + controller: pageController, + count: 3, + effect: const WormEffect()), + ], + ); }, ), ); diff --git a/lib/features/devices/view/widgets/switches.dart b/lib/features/devices/view/widgets/switches.dart index 1324bed..a5cc2d3 100644 --- a/lib/features/devices/view/widgets/switches.dart +++ b/lib/features/devices/view/widgets/switches.dart @@ -5,6 +5,7 @@ import 'package:syncrow_app/features/shared_widgets/custom_switch.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/utils/context_extension.dart'; +import 'package:syncrow_app/utils/helpers/custom_page_route.dart'; import '../../bloc/devices_cubit.dart'; @@ -32,7 +33,9 @@ class Switches extends StatelessWidget { return InkWell( onTap: () { DevicesCubit.get(context).selectCategory(index); - Navigator.push(context, MaterialPageRoute(builder: (context) { + //Navigate to the chosen category view without animation + + Navigator.push(context, CustomPageRoute(builder: (context) { return DevicesCubit.get(context).chosenCategoryView!; })); }, diff --git a/lib/utils/helpers/custom_page_route.dart b/lib/utils/helpers/custom_page_route.dart new file mode 100644 index 0000000..ee34a24 --- /dev/null +++ b/lib/utils/helpers/custom_page_route.dart @@ -0,0 +1,11 @@ +import 'package:flutter/material.dart'; + +class CustomPageRoute extends MaterialPageRoute { + CustomPageRoute({ + required super.builder, + super.settings, + }); + + @override + Duration get transitionDuration => const Duration(milliseconds: 0); +} diff --git a/pubspec.lock b/pubspec.lock index 780b314..7ddef2b 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -634,6 +634,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.0.1" + smooth_page_indicator: + dependency: "direct main" + description: + name: smooth_page_indicator + sha256: "725bc638d5e79df0c84658e1291449996943f93bacbc2cec49963dbbab48d8ae" + url: "https://pub.dev" + source: hosted + version: "1.1.0" source_span: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 38457fc..388ac93 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -25,6 +25,7 @@ dependencies: flutter_secure_storage: ^9.0.0 cached_network_image: ^3.3.1 flutter_dotenv: ^5.1.0 + # noinspection YAMLSchemaValidation intl: ^0.18.0 get_it: ^7.6.7 url_launcher: ^6.2.5 @@ -34,6 +35,7 @@ dependencies: firebase_core: ^2.25.5 firebase_analytics: ^10.8.7 firebase_crashlytics: ^3.4.16 + smooth_page_indicator: ^1.1.0 dev_dependencies: flutter_test: