From 09e0695bccd1d624afaa37de31d35912b2b2ec7f Mon Sep 17 00:00:00 2001 From: Mohammad Salameh Date: Wed, 17 Apr 2024 16:29:27 +0300 Subject: [PATCH] syncing to origin/dev --- lib/features/app_layout/bloc/home_cubit.dart | 1 - lib/features/app_layout/view/app_layout.dart | 95 ++++++-------------- lib/features/auth/bloc/auth_cubit.dart | 1 - lib/services/api/http_interceptor.dart | 1 - lib/services/api/http_service.dart | 1 - lib/services/api/spaces_api.dart | 1 - lib/utils/helpers/misc_string_helpers.dart | 1 - 7 files changed, 25 insertions(+), 76 deletions(-) diff --git a/lib/features/app_layout/bloc/home_cubit.dart b/lib/features/app_layout/bloc/home_cubit.dart index 7ea5011..62f2dc5 100644 --- a/lib/features/app_layout/bloc/home_cubit.dart +++ b/lib/features/app_layout/bloc/home_cubit.dart @@ -10,7 +10,6 @@ import 'package:syncrow_app/features/devices/view/widgets/devices_view_body.dart import 'package:syncrow_app/features/menu/view/menu_view.dart'; import 'package:syncrow_app/features/scene/view/scene_view.dart'; import 'package:syncrow_app/generated/assets.dart'; -import 'package:syncrow_app/services/api/network_exception.dart'; import 'package:syncrow_app/services/api/spaces_api.dart'; import 'package:syncrow_app/utils/resource_manager/color_manager.dart'; diff --git a/lib/features/app_layout/view/app_layout.dart b/lib/features/app_layout/view/app_layout.dart index 45a789c..d676045 100644 --- a/lib/features/app_layout/view/app_layout.dart +++ b/lib/features/app_layout/view/app_layout.dart @@ -1,15 +1,14 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; -import 'package:flutter_secure_storage/flutter_secure_storage.dart'; import 'package:syncrow_app/features/app_layout/bloc/home_cubit.dart'; import 'package:syncrow_app/features/app_layout/view/widgets/app_body.dart'; import 'package:syncrow_app/features/app_layout/view/widgets/default_app_bar.dart'; import 'package:syncrow_app/features/app_layout/view/widgets/default_nav_bar.dart'; import 'package:syncrow_app/features/auth/bloc/auth_cubit.dart'; -import 'package:syncrow_app/features/auth/model/token.dart'; import 'package:syncrow_app/navigation/routing_constants.dart'; +import 'package:syncrow_app/utils/helpers/snack_bar.dart'; import 'package:syncrow_app/utils/resource_manager/color_manager.dart'; class AppLayout extends StatelessWidget { @@ -17,74 +16,30 @@ class AppLayout extends StatelessWidget { @override Widget build(BuildContext context) { - return BlocConsumer( - listener: (context, state) { - if (state is AuthError) { - // ScaffoldMessenger.of(context).showSnackBar( - // SnackBar( - // content: Text(state.message), - // ), - // ); - Navigator.of(context) - .popUntil((route) => route.settings.name == Routes.authLogin); - } - }, - builder: (context, state) { - return BlocProvider( - create: (context) => HomeCubit.getInstance(), - child: BlocConsumer( - listener: (context, state) async { - if (state is GetSpacesError) { - // ScaffoldMessenger.of(context).showSnackBar( - // SnackBar( - // content: Text(state.errMessage), - // ), - // ); - Navigator.of(context).popUntil( - (route) => route.settings.name == Routes.authLogin); - } - String? token = await const FlutterSecureStorage() - .read(key: Token.loginAccessTokenKey); - if (token == null) { - // ignore: use_build_context_synchronously - Navigator.of(context).popAndPushNamed(Routes.authLogin); - } - }, - builder: (context, state) { - 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: HomeCubit.getInstance().spaces != null - ? const DefaultAppBar() - : null, - body: const AppBody(), - bottomNavigationBar: const DefaultNavBar(), - // floatingActionButton: FloatingActionButton( - // onPressed: () { - // Navigator.push( - // context, - // CustomPageRoute( - // builder: (context) => - // const ThreeGangSwitchesView(), - // ), - // ); - // }, - // child: const Icon(Icons.arrow_forward_ios_sharp), - // ), - ), - ), - ); - }, - ), - ); - }, + return BlocProvider( + create: (context) => HomeCubit.getInstance(), + child: BlocBuilder( + builder: (context, state) { + 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: HomeCubit.getInstance().spaces != null + ? const DefaultAppBar() + : null, + body: const AppBody(), + bottomNavigationBar: const DefaultNavBar(), + ), + ), + ); + }, + ), ); } } diff --git a/lib/features/auth/bloc/auth_cubit.dart b/lib/features/auth/bloc/auth_cubit.dart index 0c2fcdf..4e10a42 100644 --- a/lib/features/auth/bloc/auth_cubit.dart +++ b/lib/features/auth/bloc/auth_cubit.dart @@ -9,7 +9,6 @@ import 'package:syncrow_app/features/auth/model/user_model.dart'; import 'package:syncrow_app/navigation/navigation_service.dart'; import 'package:syncrow_app/navigation/routing_constants.dart'; import 'package:syncrow_app/services/api/authentication_api.dart'; -import 'package:syncrow_app/services/api/network_exception.dart'; part 'auth_state.dart'; diff --git a/lib/services/api/http_interceptor.dart b/lib/services/api/http_interceptor.dart index 7f3b8be..411732d 100644 --- a/lib/services/api/http_interceptor.dart +++ b/lib/services/api/http_interceptor.dart @@ -7,7 +7,6 @@ import 'package:syncrow_app/features/auth/model/token.dart'; import 'package:syncrow_app/navigation/navigation_service.dart'; import 'package:syncrow_app/services/api/api_links_endpoints.dart'; import 'dart:async'; -import 'dart:developer' as developer; import 'package:syncrow_app/services/api/network_exception.dart'; import 'package:syncrow_app/utils/helpers/snack_bar.dart'; diff --git a/lib/services/api/http_service.dart b/lib/services/api/http_service.dart index dc995ff..e9fb883 100644 --- a/lib/services/api/http_service.dart +++ b/lib/services/api/http_service.dart @@ -1,5 +1,4 @@ import 'package:dio/dio.dart'; -import 'dart:developer' as developer; import 'package:syncrow_app/services/api/api_links_endpoints.dart'; import 'package:syncrow_app/services/api/http_interceptor.dart'; import 'package:syncrow_app/services/locator.dart'; diff --git a/lib/services/api/spaces_api.dart b/lib/services/api/spaces_api.dart index 3aa95dd..664c3a7 100644 --- a/lib/services/api/spaces_api.dart +++ b/lib/services/api/spaces_api.dart @@ -1,7 +1,6 @@ import 'package:flutter_secure_storage/flutter_secure_storage.dart'; import 'package:syncrow_app/features/app_layout/model/space_model.dart'; import 'package:syncrow_app/features/auth/model/user_model.dart'; -import 'package:syncrow_app/features/devices/model/device_model.dart'; import 'package:syncrow_app/features/devices/model/room_model.dart'; import 'package:syncrow_app/services/api/api_links_endpoints.dart'; import 'package:syncrow_app/services/api/http_service.dart'; diff --git a/lib/utils/helpers/misc_string_helpers.dart b/lib/utils/helpers/misc_string_helpers.dart index 616e8a4..d9f9dc3 100644 --- a/lib/utils/helpers/misc_string_helpers.dart +++ b/lib/utils/helpers/misc_string_helpers.dart @@ -1,4 +1,3 @@ -import 'dart:developer' as developer; import 'dart:io'; class StringHelpers {