From 8a225a696b325af397a10aff30f525475b3a7f18 Mon Sep 17 00:00:00 2001 From: sarbador Date: Mon, 17 Feb 2025 23:10:33 +0500 Subject: [PATCH 01/10] making profile feature --- .../features/profile/view/profile_page.dart | 19 +++++++++++++++++++ .../profile_header_loading_widget.dart | 15 +++++++++++++++ .../profile_header/profile_header_widget.dart | 15 +++++++++++++++ .../profile_settings_loading_widget.dart | 15 +++++++++++++++ .../profile_settings_widget.dart | 15 +++++++++++++++ 5 files changed, 79 insertions(+) create mode 100644 lib/src/features/profile/view/widgets/profile_header/profile_header_loading_widget.dart create mode 100644 lib/src/features/profile/view/widgets/profile_header/profile_header_widget.dart create mode 100644 lib/src/features/profile/view/widgets/profile_settings/profile_settings_loading_widget.dart create mode 100644 lib/src/features/profile/view/widgets/profile_settings/profile_settings_widget.dart diff --git a/lib/src/features/profile/view/profile_page.dart b/lib/src/features/profile/view/profile_page.dart index 655e0d7..ef98ae2 100644 --- a/lib/src/features/profile/view/profile_page.dart +++ b/lib/src/features/profile/view/profile_page.dart @@ -24,6 +24,25 @@ class _ProfilePageState extends State { @override Widget build(BuildContext context) { return Scaffold( + appBar: AppBar( + leading: const SizedBox.shrink(), + leadingWidth: 0.0, + title: const Text("Profile"), + actions: [ + IconButton( + onPressed: () {}, + icon: const Icon( + Icons.qr_code, + ), + ), + IconButton( + onPressed: () {}, + icon: const Icon( + Icons.more_vert, + ), + ), + ], + ), body: Center( child: ElevatedButton( onPressed: () => _profileBloc?.add( diff --git a/lib/src/features/profile/view/widgets/profile_header/profile_header_loading_widget.dart b/lib/src/features/profile/view/widgets/profile_header/profile_header_loading_widget.dart new file mode 100644 index 0000000..e42e900 --- /dev/null +++ b/lib/src/features/profile/view/widgets/profile_header/profile_header_loading_widget.dart @@ -0,0 +1,15 @@ +import 'package:flutter/material.dart'; + +class ProfileHeaderLoadingWidget extends StatefulWidget { + const ProfileHeaderLoadingWidget({super.key}); + + @override + State createState() => _ProfileHeaderLoadingWidgetState(); +} + +class _ProfileHeaderLoadingWidgetState extends State { + @override + Widget build(BuildContext context) { + return const Placeholder(); + } +} diff --git a/lib/src/features/profile/view/widgets/profile_header/profile_header_widget.dart b/lib/src/features/profile/view/widgets/profile_header/profile_header_widget.dart new file mode 100644 index 0000000..1038619 --- /dev/null +++ b/lib/src/features/profile/view/widgets/profile_header/profile_header_widget.dart @@ -0,0 +1,15 @@ +import 'package:flutter/material.dart'; + +class ProfileHeaderWidget extends StatefulWidget { + const ProfileHeaderWidget({super.key}); + + @override + State createState() => _ProfileHeaderWidgetState(); +} + +class _ProfileHeaderWidgetState extends State { + @override + Widget build(BuildContext context) { + return const Placeholder(); + } +} diff --git a/lib/src/features/profile/view/widgets/profile_settings/profile_settings_loading_widget.dart b/lib/src/features/profile/view/widgets/profile_settings/profile_settings_loading_widget.dart new file mode 100644 index 0000000..609c8a9 --- /dev/null +++ b/lib/src/features/profile/view/widgets/profile_settings/profile_settings_loading_widget.dart @@ -0,0 +1,15 @@ +import 'package:flutter/material.dart'; + +class ProfileSettingsLoadingWidget extends StatefulWidget { + const ProfileSettingsLoadingWidget({super.key}); + + @override + State createState() => _ProfileSettingsLoadingWidgetState(); +} + +class _ProfileSettingsLoadingWidgetState extends State { + @override + Widget build(BuildContext context) { + return const Placeholder(); + } +} diff --git a/lib/src/features/profile/view/widgets/profile_settings/profile_settings_widget.dart b/lib/src/features/profile/view/widgets/profile_settings/profile_settings_widget.dart new file mode 100644 index 0000000..dea60c9 --- /dev/null +++ b/lib/src/features/profile/view/widgets/profile_settings/profile_settings_widget.dart @@ -0,0 +1,15 @@ +import 'package:flutter/material.dart'; + +class ProfileSettingsWidget extends StatefulWidget { + const ProfileSettingsWidget({super.key}); + + @override + State createState() => _ProfileSettingsWidgetState(); +} + +class _ProfileSettingsWidgetState extends State { + @override + Widget build(BuildContext context) { + return const Placeholder(); + } +} From d638558fee30b68a8c79f053e1b632fdcae2e679 Mon Sep 17 00:00:00 2001 From: sarbador Date: Tue, 18 Feb 2025 07:06:36 +0500 Subject: [PATCH 02/10] ui for profile --- .../ui_kit/image_loader/image_loaded.dart | 45 +++++++++++-------- .../bloc/state_model/profile_state_model.dart | 33 +++++++++++++- .../profile_header/profile_header_widget.dart | 26 ++++++++++- 3 files changed, 83 insertions(+), 21 deletions(-) diff --git a/lib/src/core/ui_kit/image_loader/image_loaded.dart b/lib/src/core/ui_kit/image_loader/image_loaded.dart index 7773008..2bab30e 100644 --- a/lib/src/core/ui_kit/image_loader/image_loaded.dart +++ b/lib/src/core/ui_kit/image_loader/image_loaded.dart @@ -31,8 +31,9 @@ class ImageLoaderWidget extends StatelessWidget { @override Widget build(BuildContext context) { - return Builder(builder: (context) { - return CachedNetworkImage( + return Builder( + builder: (context) { + return CachedNetworkImage( imageUrl: url, width: width, httpHeaders: const { @@ -44,17 +45,18 @@ class ImageLoaderWidget extends StatelessWidget { placeholder: (context, url) { if (imageBlurHash != null) { return Container( - margin: marginShimmerContainer, - padding: paddingShimmerContainer, - width: width, - height: height, - decoration: BoxDecoration(borderRadius: borderRadius), - child: BlurHash( - hash: imageBlurHash ?? 'L00w16X:L#qZf,fke.e.HXm*y?UH', - imageFit: boxFit ?? BoxFit.scaleDown, - duration: const Duration(seconds: 2), - curve: Curves.linear, - ),); + margin: marginShimmerContainer, + padding: paddingShimmerContainer, + width: width, + height: height, + decoration: BoxDecoration(borderRadius: borderRadius), + child: BlurHash( + hash: imageBlurHash ?? 'L00w16X:L#qZf,fke.e.HXm*y?UH', + imageFit: boxFit ?? BoxFit.scaleDown, + duration: const Duration(seconds: 2), + curve: Curves.linear, + ), + ); } else { return Container( margin: marginShimmerContainer, @@ -68,11 +70,16 @@ class ImageLoaderWidget extends StatelessWidget { ); } }, - errorWidget: (context, url, error) => errorWidget ?? Image.asset( - errorImageUrl ?? Constants.userErrorImage, - height: height, - width: width, - fit: boxFit ?? BoxFit.scaleDown,),); - },); + errorWidget: (context, url, error) => + errorWidget ?? + Image.asset( + errorImageUrl ?? Constants.userErrorImage, + height: height, + width: width, + fit: boxFit ?? BoxFit.scaleDown, + ), + ); + }, + ); } } diff --git a/lib/src/features/profile/bloc/state_model/profile_state_model.dart b/lib/src/features/profile/bloc/state_model/profile_state_model.dart index 754fd0e..54476e1 100644 --- a/lib/src/features/profile/bloc/state_model/profile_state_model.dart +++ b/lib/src/features/profile/bloc/state_model/profile_state_model.dart @@ -1 +1,32 @@ -class ProfileStateModel {} +import 'package:yahay/src/core/models/user_model/user_model.dart'; + +class ProfileStateModel { + final UserModel? userModel; + + const ProfileStateModel({ + this.userModel, + }); + + @override + bool operator ==(Object other) => + identical(this, other) || + (other is ProfileStateModel && + runtimeType == other.runtimeType && + userModel == other.userModel); + + @override + int get hashCode => userModel.hashCode; + + @override + String toString() { + return 'ProfileStateModel{' + ' userModel: $userModel,' + '}'; + } + + ProfileStateModel copyWith({ + UserModel? userModel, + }) { + return ProfileStateModel( + userModel: userModel ?? this.userModel, + ); + } +} diff --git a/lib/src/features/profile/view/widgets/profile_header/profile_header_widget.dart b/lib/src/features/profile/view/widgets/profile_header/profile_header_widget.dart index 1038619..e18a647 100644 --- a/lib/src/features/profile/view/widgets/profile_header/profile_header_widget.dart +++ b/lib/src/features/profile/view/widgets/profile_header/profile_header_widget.dart @@ -1,4 +1,7 @@ import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:yahay/src/core/ui_kit/image_loader/image_loaded.dart'; +import 'package:yahay/src/features/profile/bloc/profile_bloc.dart'; class ProfileHeaderWidget extends StatefulWidget { const ProfileHeaderWidget({super.key}); @@ -10,6 +13,27 @@ class ProfileHeaderWidget extends StatefulWidget { class _ProfileHeaderWidgetState extends State { @override Widget build(BuildContext context) { - return const Placeholder(); + return BlocBuilder( + builder: (context, state) { + return Row( + children: [ + ImageLoaderWidget( + url: state.profileStateModel.userModel?.imageUrl ?? '', + boxFit: BoxFit.cover, + ), + const SizedBox(width: 10), + const Expanded( + child: Column( + children: [ + Text("NAME"), + Text("PHONE NUMBER"), + Text("USERNAME OR EMAIL") + ], + ), + ), + ], + ); + }, + ); } } From 6112fd58020b6be98bbf19f151ba37388aeafb6e Mon Sep 17 00:00:00 2001 From: sarbador Date: Tue, 18 Feb 2025 20:51:15 +0500 Subject: [PATCH 03/10] formatted code --- .gitignore | 3 +- analysis_options.yaml | 2 + lib/src/core/app_routing/app_router.gr.dart | 168 -------- .../global_usages/constants/constants.dart | 1 - .../reusables/reusable_global_functions.dart | 1 - .../chat_participant_model.dart | 4 +- .../chat_participant_status_model.dart | 4 +- .../core/models/room_models/room_model.dart | 3 +- .../core/models/user_model/user_model.dart | 7 +- .../ui_kit/search_widget/search_widget.dart | 13 +- .../user_widgets/add_contact_user_widget.dart | 2 +- .../bloc_observer_manager.dart | 3 +- .../error_reporter/i_error_reporter.dart | 2 - lib/src/core/utils/extensions/extensions.dart | 3 +- .../image_comporessor/image_compressor.dart | 3 +- .../list_pagination_checker.dart | 18 +- .../bloc/add_contact_bloc.dart | 11 +- .../state_model/add_contact_state_model.dart | 2 - .../view/pages/add_contacts_page.dart | 15 +- .../app_theme/bloc/app_theme_bloc.dart | 4 +- .../authorization/bloc/auth_bloc.dart | 2 +- .../bloc/state_model/auth_state_model.dart | 10 +- .../data/repo/authorization_repo_impl.dart | 3 +- .../authorization/view/login_page.dart | 383 +++++++++--------- .../chat_screen/bloc/chat_screen_bloc.dart | 8 +- .../state_model/chat_screen_state_model.dart | 11 +- .../impl/chat_screen_chat_data_souce.dart | 11 +- .../view/app_bar/chat_screen_app_bar.dart | 8 +- .../bottom_chat_widget.dart | 8 +- lib/src/features/chats/bloc/chats_bloc.dart | 9 +- .../chats/view/chat_widget/chat_widget.dart | 2 +- lib/src/features/home_page.dart | 10 +- .../factories/profile_bloc_factory.dart | 2 +- .../initialization/widgets/root_context.dart | 5 +- .../features/profile/bloc/profile_bloc.dart | 2 +- .../bloc/state_model/profile_state_model.dart | 2 +- .../features/profile/view/profile_page.dart | 15 +- .../profile_header/profile_header_widget.dart | 2 +- .../telegram_file_picker_state_model.dart | 14 +- .../bloc/telegram_file_picker_bloc.dart | 53 ++- .../telegram_file_picker_bottom_button.dart | 64 +-- .../entities/telegram_file_folder_enums.dart | 2 +- .../telegram_bottom_sender_button.dart | 2 +- .../telegram_storage_file_widget.dart | 4 +- .../telegram_browse_folder_widget.dart | 2 +- .../telegram_files_picker_screen.dart | 9 +- .../telegram_files_from_storages_widget.dart | 2 +- ...gram_gallery_file_picker_image_widget.dart | 9 +- ...llery_file_picker_video_player_widget.dart | 9 +- .../state_model/video_chat_state_model.dart | 34 +- .../bloc/video_chat_feature_bloc.dart | 2 +- .../double_camera_view_screen.dart | 2 - .../widgets/widgets/call_button_widget.dart | 5 +- .../widgets/hang_up_buttons_widget.dart | 2 - 54 files changed, 425 insertions(+), 552 deletions(-) delete mode 100644 lib/src/core/app_routing/app_router.gr.dart diff --git a/.gitignore b/.gitignore index fb77b0d..2281275 100644 --- a/.gitignore +++ b/.gitignore @@ -48,4 +48,5 @@ app.*.map.json firebase.json **/*.freezed.dart -**/*.g.dart \ No newline at end of file +**/*.g.dart +**/*.gr.dart \ No newline at end of file diff --git a/analysis_options.yaml b/analysis_options.yaml index 7545171..b17401c 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -42,6 +42,8 @@ linter: - avoid_dynamic_calls # reminds to close stream_subscriptions - cancel_subscriptions + - use_colored_box + - use_decorated_box # - prefer_const_constructors # - prefer_const_literals_to_create_immutables # avoid_print: false # Uncomment to disable the `avoid_print` rule diff --git a/lib/src/core/app_routing/app_router.gr.dart b/lib/src/core/app_routing/app_router.gr.dart deleted file mode 100644 index 7ebfbe2..0000000 --- a/lib/src/core/app_routing/app_router.gr.dart +++ /dev/null @@ -1,168 +0,0 @@ -// dart format width=80 -// GENERATED CODE - DO NOT MODIFY BY HAND - -// ************************************************************************** -// AutoRouterGenerator -// ************************************************************************** - -// ignore_for_file: type=lint -// coverage:ignore-file - -part of 'app_router.dart'; - -/// generated route for -/// [ChatScreen] -class ChatRoute extends PageRouteInfo { - ChatRoute({ - Key? key, - required ChatModel? chat, - required UserModel? user, - List? children, - }) : super( - ChatRoute.name, - args: ChatRouteArgs(key: key, chat: chat, user: user), - initialChildren: children, - ); - - static const String name = 'ChatRoute'; - - static PageInfo page = PageInfo( - name, - builder: (data) { - final args = data.argsAs(); - return ChatScreen(key: args.key, chat: args.chat, user: args.user); - }, - ); -} - -class ChatRouteArgs { - const ChatRouteArgs({this.key, required this.chat, required this.user}); - - final Key? key; - - final ChatModel? chat; - - final UserModel? user; - - @override - String toString() { - return 'ChatRouteArgs{key: $key, chat: $chat, user: $user}'; - } -} - -/// generated route for -/// [ChatsPage] -class ChatsRoute extends PageRouteInfo { - const ChatsRoute({List? children}) - : super(ChatsRoute.name, initialChildren: children); - - static const String name = 'ChatsRoute'; - - static PageInfo page = PageInfo( - name, - builder: (data) { - return const ChatsPage(); - }, - ); -} - -/// generated route for -/// [HomePage] -class HomeRoute extends PageRouteInfo { - const HomeRoute({List? children}) - : super(HomeRoute.name, initialChildren: children); - - static const String name = 'HomeRoute'; - - static PageInfo page = PageInfo( - name, - builder: (data) { - return const HomePage(); - }, - ); -} - -/// generated route for -/// [LoadingPage] -class LoadingRoute extends PageRouteInfo { - const LoadingRoute({List? children}) - : super(LoadingRoute.name, initialChildren: children); - - static const String name = 'LoadingRoute'; - - static PageInfo page = PageInfo( - name, - builder: (data) { - return const LoadingPage(); - }, - ); -} - -/// generated route for -/// [LoginPage] -class LoginRoute extends PageRouteInfo { - const LoginRoute({List? children}) - : super(LoginRoute.name, initialChildren: children); - - static const String name = 'LoginRoute'; - - static PageInfo page = PageInfo( - name, - builder: (data) { - return const LoginPage(); - }, - ); -} - -/// generated route for -/// [RegisterPage] -class RegisterRoute extends PageRouteInfo { - const RegisterRoute({List? children}) - : super(RegisterRoute.name, initialChildren: children); - - static const String name = 'RegisterRoute'; - - static PageInfo page = PageInfo( - name, - builder: (data) { - return const RegisterPage(); - }, - ); -} - -/// generated route for -/// [VideoChatFeaturePage] -class VideoChatFeatureRoute extends PageRouteInfo { - VideoChatFeatureRoute({ - Key? key, - required ChatModel? chat, - List? children, - }) : super( - VideoChatFeatureRoute.name, - args: VideoChatFeatureRouteArgs(key: key, chat: chat), - initialChildren: children, - ); - - static const String name = 'VideoChatFeatureRoute'; - - static PageInfo page = PageInfo( - name, - builder: (data) { - final args = data.argsAs(); - return VideoChatFeaturePage(key: args.key, chat: args.chat); - }, - ); -} - -class VideoChatFeatureRouteArgs { - const VideoChatFeatureRouteArgs({this.key, required this.chat}); - - final Key? key; - - final ChatModel? chat; - - @override - String toString() { - return 'VideoChatFeatureRouteArgs{key: $key, chat: $chat}'; - } -} diff --git a/lib/src/core/global_usages/constants/constants.dart b/lib/src/core/global_usages/constants/constants.dart index fba5ef0..1211a22 100644 --- a/lib/src/core/global_usages/constants/constants.dart +++ b/lib/src/core/global_usages/constants/constants.dart @@ -47,5 +47,4 @@ abstract class Constants { static const String somethingWentWrong = "Something went wrong, please, try later"; static const double minimumHeightForShowingRiveTextFieldAnim = 650; - } diff --git a/lib/src/core/global_usages/reusables/reusable_global_functions.dart b/lib/src/core/global_usages/reusables/reusable_global_functions.dart index 08b3005..6bfb42c 100644 --- a/lib/src/core/global_usages/reusables/reusable_global_functions.dart +++ b/lib/src/core/global_usages/reusables/reusable_global_functions.dart @@ -139,7 +139,6 @@ class ReusableGlobalFunctions { return res; } - bool get isMacOsOriOS { return defaultTargetPlatform == TargetPlatform.iOS || defaultTargetPlatform == TargetPlatform.macOS; diff --git a/lib/src/core/models/chat_participant_model/chat_participant_model.dart b/lib/src/core/models/chat_participant_model/chat_participant_model.dart index 5f90422..c591835 100644 --- a/lib/src/core/models/chat_participant_model/chat_participant_model.dart +++ b/lib/src/core/models/chat_participant_model/chat_participant_model.dart @@ -10,7 +10,7 @@ part 'chat_participant_model.freezed.dart'; part 'chat_participant_model.g.dart'; @freezed -class ChatParticipantModel with _$ChatParticipantModel { +class ChatParticipantModel with _$ChatParticipantModel { const factory ChatParticipantModel({ final int? id, final UserModel? user, @@ -22,6 +22,4 @@ class ChatParticipantModel with _$ChatParticipantModel { factory ChatParticipantModel.fromJson(Map json) => _$ChatParticipantModelFromJson(json); - - } diff --git a/lib/src/core/models/chat_participant_status_model/chat_participant_status_model.dart b/lib/src/core/models/chat_participant_status_model/chat_participant_status_model.dart index c69a61a..b9d76cc 100644 --- a/lib/src/core/models/chat_participant_status_model/chat_participant_status_model.dart +++ b/lib/src/core/models/chat_participant_status_model/chat_participant_status_model.dart @@ -7,7 +7,7 @@ part 'chat_participant_status_model.freezed.dart'; part 'chat_participant_status_model.g.dart'; @freezed -class ChatParticipantStatusModel with _$ChatParticipantStatusModel { +class ChatParticipantStatusModel with _$ChatParticipantStatusModel { const factory ChatParticipantStatusModel({ int? id, String? status, @@ -15,6 +15,4 @@ class ChatParticipantStatusModel with _$ChatParticipantStatusModel { factory ChatParticipantStatusModel.fromJson(Map json) => _$ChatParticipantStatusModelFromJson(json); - - } diff --git a/lib/src/core/models/room_models/room_model.dart b/lib/src/core/models/room_models/room_model.dart index d9c8254..db4c861 100644 --- a/lib/src/core/models/room_models/room_model.dart +++ b/lib/src/core/models/room_models/room_model.dart @@ -6,7 +6,7 @@ part 'room_model.freezed.dart'; part 'room_model.g.dart'; @freezed -class RoomModel with _$RoomModel { +class RoomModel with _$RoomModel { factory RoomModel({ final int? id, final int? chatId, @@ -18,5 +18,4 @@ class RoomModel with _$RoomModel { }) = _RoomModel; factory RoomModel.fromJson(Map json) => _$RoomModelFromJson(json); - } diff --git a/lib/src/core/models/user_model/user_model.dart b/lib/src/core/models/user_model/user_model.dart index bbb8559..254ba23 100644 --- a/lib/src/core/models/user_model/user_model.dart +++ b/lib/src/core/models/user_model/user_model.dart @@ -18,8 +18,11 @@ class UserModel with _$UserModel { @JsonKey(name: "birth_day") String? birthDay, @JsonKey(name: "image_url") String? imageUrl, @JsonKey(name: "created_at") String? createdAt, - @JsonKey(includeFromJson: false, includeToJson: false) @Default( - false,) bool? loadingForAddingToContacts, + @JsonKey(includeFromJson: false, includeToJson: false) + @Default( + false, + ) + bool? loadingForAddingToContacts, @JsonKey(name: "user_contact") UserModel? contact, }) = _UserModel; diff --git a/lib/src/core/ui_kit/search_widget/search_widget.dart b/lib/src/core/ui_kit/search_widget/search_widget.dart index a30a922..48852a5 100644 --- a/lib/src/core/ui_kit/search_widget/search_widget.dart +++ b/lib/src/core/ui_kit/search_widget/search_widget.dart @@ -96,12 +96,13 @@ class _SearchWidgetState extends State with SingleTickerProviderSt ), if (_searchController.text.isNotEmpty) IconButton( - onPressed: () { - _searchController.clear(); - setState(() {}); - widget.onDispose(); - }, - icon: const Icon(Icons.close),), + onPressed: () { + _searchController.clear(); + setState(() {}); + widget.onDispose(); + }, + icon: const Icon(Icons.close), + ), ], ), ); diff --git a/lib/src/core/ui_kit/user_widgets/add_contact_user_widget.dart b/lib/src/core/ui_kit/user_widgets/add_contact_user_widget.dart index eea4201..6866c7b 100644 --- a/lib/src/core/ui_kit/user_widgets/add_contact_user_widget.dart +++ b/lib/src/core/ui_kit/user_widgets/add_contact_user_widget.dart @@ -20,7 +20,7 @@ class AddContactUserWidget extends StatelessWidget { Widget build(BuildContext context) { return GestureDetector( onTap: () => [], - child: Container( + child: ColoredBox( color: Colors.transparent, child: IntrinsicHeight( child: Row( diff --git a/lib/src/core/utils/bloc_observer_manager/bloc_observer_manager.dart b/lib/src/core/utils/bloc_observer_manager/bloc_observer_manager.dart index 7db367b..b6404ce 100644 --- a/lib/src/core/utils/bloc_observer_manager/bloc_observer_manager.dart +++ b/lib/src/core/utils/bloc_observer_manager/bloc_observer_manager.dart @@ -56,7 +56,8 @@ class BlocObserverManager extends BlocObserver { ); // Avoid calling super.onError to prevent propagation - super.onError(bloc, error, stackTrace); + // if you use Zones for catching errors it's good, because it will propagate error and zone will catch it + // super.onError(bloc, error, stackTrace); } @override diff --git a/lib/src/core/utils/error_reporter/i_error_reporter.dart b/lib/src/core/utils/error_reporter/i_error_reporter.dart index 4afb73c..ff28788 100644 --- a/lib/src/core/utils/error_reporter/i_error_reporter.dart +++ b/lib/src/core/utils/error_reporter/i_error_reporter.dart @@ -8,5 +8,3 @@ final class NoOpErrorReporter implements IErrorReporter { // No implementation inside } } - - diff --git a/lib/src/core/utils/extensions/extensions.dart b/lib/src/core/utils/extensions/extensions.dart index c0b8a17..e4366ef 100644 --- a/lib/src/core/utils/extensions/extensions.dart +++ b/lib/src/core/utils/extensions/extensions.dart @@ -24,7 +24,6 @@ extension StringEx on String { String limit(int length) => length < this.length ? substring(0, length) : this; } - extension NestedMapExt on Map { T? getNested(List keys) { Object? current = this; @@ -37,4 +36,4 @@ extension NestedMapExt on Map { } return current as T?; } -} \ No newline at end of file +} diff --git a/lib/src/core/utils/image_comporessor/image_compressor.dart b/lib/src/core/utils/image_comporessor/image_compressor.dart index 8ddb5f6..93591ed 100644 --- a/lib/src/core/utils/image_comporessor/image_compressor.dart +++ b/lib/src/core/utils/image_comporessor/image_compressor.dart @@ -11,7 +11,8 @@ abstract final class ImageCompressor { int quality = 60, CompressFormat format = CompressFormat.jpeg, }) async { - final String imagePath = '$directoryPath/${basenameWithoutExtension(file.path)}_temp.${format.name}'; + final String imagePath = + '$directoryPath/${basenameWithoutExtension(file.path)}_temp.${format.name}'; final XFile? compressedImage = await FlutterImageCompress.compressAndGetFile( file.path, diff --git a/lib/src/core/utils/list_pagination_checker/list_pagination_checker.dart b/lib/src/core/utils/list_pagination_checker/list_pagination_checker.dart index b120e32..0337141 100644 --- a/lib/src/core/utils/list_pagination_checker/list_pagination_checker.dart +++ b/lib/src/core/utils/list_pagination_checker/list_pagination_checker.dart @@ -8,8 +8,11 @@ class ListPaginationChecker { ListPaginationChecker._(); // this func will check whether there are more values in list of pag (returns integer) - int checkIsListHasMorePageInt( - {required List list, required int page, int? limitInPage,}) { + int checkIsListHasMorePageInt({ + required List list, + required int page, + int? limitInPage, + }) { if (list.length < (limitInPage ?? Constants.perPage)) { page = 1; } else { @@ -27,11 +30,12 @@ class ListPaginationChecker { } } - List paginateList( - {required List wholeList, - required List currentList, - int perPage = 30, - bool showingCircularProgress = true,}) { + List paginateList({ + required List wholeList, + required List currentList, + int perPage = 30, + bool showingCircularProgress = true, + }) { //if do not want to show any progress indicators in your screen -> set "showingCircularProgress" to "false" //you should not use any check variable, this function parameter "showingCircularProgress" will know automatically //and it checks whether list still has items or not diff --git a/lib/src/features/add_contact_feature/bloc/add_contact_bloc.dart b/lib/src/features/add_contact_feature/bloc/add_contact_bloc.dart index 157fee3..121ced0 100644 --- a/lib/src/features/add_contact_feature/bloc/add_contact_bloc.dart +++ b/lib/src/features/add_contact_feature/bloc/add_contact_bloc.dart @@ -9,7 +9,7 @@ part 'add_contact_bloc.freezed.dart'; @immutable @freezed -class AddContactsEvents with _$AddContactsEvents { +sealed class AddContactsEvents with _$AddContactsEvents { const factory AddContactsEvents.searchContact(final String value) = _SearchContactEvent; const factory AddContactsEvents.addContactEvent(final UserModel? user) = @@ -25,13 +25,16 @@ sealed class AddContactsStates with _$AddContactsStates { InitialAddConstactsState; const factory AddContactsStates.loadingAddContactsState( - final AddContactStateModel addContactStateModel,) = AddContacts$InProgressState; + final AddContactStateModel addContactStateModel, + ) = AddContacts$InProgressState; const factory AddContactsStates.errorAddContactsState( - final AddContactStateModel addContactStateModel,) = AddContacts$ErrorState; + final AddContactStateModel addContactStateModel, + ) = AddContacts$ErrorState; const factory AddContactsStates.loadedAddContactsState( - final AddContactStateModel addContactStateModel,) = AddContacts$SuccessfulState; + final AddContactStateModel addContactStateModel, + ) = AddContacts$SuccessfulState; } class AddContactBloc extends Bloc { diff --git a/lib/src/features/add_contact_feature/bloc/state_model/add_contact_state_model.dart b/lib/src/features/add_contact_feature/bloc/state_model/add_contact_state_model.dart index f81d51e..6b7c41e 100644 --- a/lib/src/features/add_contact_feature/bloc/state_model/add_contact_state_model.dart +++ b/lib/src/features/add_contact_feature/bloc/state_model/add_contact_state_model.dart @@ -73,6 +73,4 @@ final class AddContactStateModel { AddContactStateModel clearData() { return copyWith(users: [], page: 1, hasMore: false); } - - } diff --git a/lib/src/features/add_contact_feature/view/pages/add_contacts_page.dart b/lib/src/features/add_contact_feature/view/pages/add_contacts_page.dart index bcab6a1..d965071 100644 --- a/lib/src/features/add_contact_feature/view/pages/add_contacts_page.dart +++ b/lib/src/features/add_contact_feature/view/pages/add_contacts_page.dart @@ -64,13 +64,14 @@ class _AddContactsPageState extends State { onTapOutside: (v) => FocusManager.instance.primaryFocus?.unfocus(), style: GoogleFonts.aBeeZee(fontSize: 14), decoration: const InputDecoration( - contentPadding: EdgeInsets.symmetric(vertical: 15.0, horizontal: 5), - border: InputBorder.none, - focusedBorder: InputBorder.none, - enabledBorder: InputBorder.none, - isDense: true, - hintText: "Search", - prefixIcon: Icon(Icons.search),), + contentPadding: EdgeInsets.symmetric(vertical: 15.0, horizontal: 5), + border: InputBorder.none, + focusedBorder: InputBorder.none, + enabledBorder: InputBorder.none, + isDense: true, + hintText: "Search", + prefixIcon: Icon(Icons.search), + ), ), ), ), diff --git a/lib/src/features/app_theme/bloc/app_theme_bloc.dart b/lib/src/features/app_theme/bloc/app_theme_bloc.dart index 3b09f02..f8aadd9 100644 --- a/lib/src/features/app_theme/bloc/app_theme_bloc.dart +++ b/lib/src/features/app_theme/bloc/app_theme_bloc.dart @@ -8,7 +8,7 @@ abstract class AppThemeEvents { } @immutable -class AppThemeChangerEvent extends AppThemeEvents { +sealed class AppThemeChangerEvent extends AppThemeEvents { const AppThemeChangerEvent(); } @@ -47,6 +47,6 @@ class AppThemeBloc { return AppColorsScheme.light; case Brightness.light: return AppColorsScheme.dark; - } + } } } diff --git a/lib/src/features/authorization/bloc/auth_bloc.dart b/lib/src/features/authorization/bloc/auth_bloc.dart index 93f09c0..f3e5dc9 100644 --- a/lib/src/features/authorization/bloc/auth_bloc.dart +++ b/lib/src/features/authorization/bloc/auth_bloc.dart @@ -10,7 +10,7 @@ part 'auth_bloc.freezed.dart'; @immutable @freezed -class AuthEvents with _$AuthEvents { +sealed class AuthEvents with _$AuthEvents { const factory AuthEvents.googleAuth({ required final void Function() initDependenciesAfterAuthorization, // required final Future Function() initDioOptions, diff --git a/lib/src/features/authorization/bloc/state_model/auth_state_model.dart b/lib/src/features/authorization/bloc/state_model/auth_state_model.dart index f8afb93..b5a3946 100644 --- a/lib/src/features/authorization/bloc/state_model/auth_state_model.dart +++ b/lib/src/features/authorization/bloc/state_model/auth_state_model.dart @@ -3,12 +3,10 @@ import 'package:flutter/material.dart'; import 'package:yahay/src/core/models/user_model/user_model.dart'; class AuthStateModel { - final UserModel? user; final bool showPassword, loadingRegister, loadingLogin; const AuthStateModel({ - required this.user, required this.showPassword, required this.loadingRegister, @@ -16,7 +14,6 @@ class AuthStateModel { }); factory AuthStateModel.idle() => const AuthStateModel( - user: null, showPassword: true, loadingRegister: false, @@ -28,7 +25,6 @@ class AuthStateModel { identical(this, other) || (other is AuthStateModel && runtimeType == other.runtimeType && - user == other.user && showPassword == other.showPassword && loadingRegister == other.loadingRegister && @@ -36,11 +32,7 @@ class AuthStateModel { @override int get hashCode => - - user.hashCode ^ - showPassword.hashCode ^ - loadingRegister.hashCode ^ - loadingLogin.hashCode; + user.hashCode ^ showPassword.hashCode ^ loadingRegister.hashCode ^ loadingLogin.hashCode; @override String toString() { diff --git a/lib/src/features/authorization/data/repo/authorization_repo_impl.dart b/lib/src/features/authorization/data/repo/authorization_repo_impl.dart index f4b7a26..091d4e5 100644 --- a/lib/src/features/authorization/data/repo/authorization_repo_impl.dart +++ b/lib/src/features/authorization/data/repo/authorization_repo_impl.dart @@ -8,8 +8,7 @@ class AuthorizationRepoImpl implements AuthorizationRepo { AuthorizationRepoImpl(this._laravelAuthDataSource); @override - Future checkAuth() => - _laravelAuthDataSource.checkAuth(); + Future checkAuth() => _laravelAuthDataSource.checkAuth(); @override Future login({ diff --git a/lib/src/features/authorization/view/login_page.dart b/lib/src/features/authorization/view/login_page.dart index 8420b52..f0f3e64 100644 --- a/lib/src/features/authorization/view/login_page.dart +++ b/lib/src/features/authorization/view/login_page.dart @@ -6,6 +6,7 @@ import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:google_fonts/google_fonts.dart'; import 'package:hexcolor/hexcolor.dart'; + // import 'package:rive/rive.dart'; import 'package:yahay/src/core/app_routing/app_router.dart'; import 'package:yahay/src/core/global_usages/constants/constants.dart'; @@ -28,6 +29,7 @@ class _LoginPageState extends State { final TextEditingController _emailOrUserNameController = TextEditingController(text: ''); final TextEditingController _passwordController = TextEditingController(text: ''); late final AuthBloc _authBloc; + // final AnimatedLoginCharacter _animatedLoginCharacter = AnimatedLoginCharacter(); @override @@ -54,217 +56,220 @@ class _LoginPageState extends State { Widget build(BuildContext context) { final dependencies = DependenciesScope.of(context, listen: false); return BlocConsumer( - listener: (context, state) { - if (state is Auth$AuthorizedState) { - AutoRouter.of(context).replaceAll([const HomeRoute()]); - } - // if (state.authStateModel.showPassword) { - // _animatedLoginCharacter.handsUp(false); - // } else { - // _animatedLoginCharacter.handsUp(true); - // } - }, - bloc: _authBloc, - builder: (context, state) { - final authStateModel = state.authStateModel; - return Scaffold( - backgroundColor: HexColor("#d6e2ea"), - body: SingleChildScrollView( - padding: const EdgeInsets.symmetric(horizontal: 8), - child: SizedBox( - height: MediaQuery.of(context).size.height, - child: Form( - key: _loginForm, - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - // 650 was solved before putting value - // if (MediaQuery.of(context).size.hashCode >= - // Constants.minimumHeightForShowingRiveTextFieldAnim && - // _animatedLoginCharacter.artBoard != null) - // SizedBox( - // height: 200, - // child: Rive( - // artboard: _animatedLoginCharacter.artBoard!, - // ), - // ), - Text( - "Sign In", - style: GoogleFonts.aBeeZee( - fontWeight: FontWeight.w400, - fontSize: 20, - ), + listener: (context, state) { + if (state is Auth$AuthorizedState) { + AutoRouter.of(context).replaceAll([const HomeRoute()]); + } + // if (state.authStateModel.showPassword) { + // _animatedLoginCharacter.handsUp(false); + // } else { + // _animatedLoginCharacter.handsUp(true); + // } + }, + bloc: _authBloc, + builder: (context, state) { + final authStateModel = state.authStateModel; + return Scaffold( + backgroundColor: HexColor("#d6e2ea"), + body: SingleChildScrollView( + padding: const EdgeInsets.symmetric(horizontal: 8), + child: SizedBox( + height: MediaQuery.of(context).size.height, + child: Form( + key: _loginForm, + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + // 650 was solved before putting value + // if (MediaQuery.of(context).size.hashCode >= + // Constants.minimumHeightForShowingRiveTextFieldAnim && + // _animatedLoginCharacter.artBoard != null) + // SizedBox( + // height: 200, + // child: Rive( + // artboard: _animatedLoginCharacter.artBoard!, + // ), + // ), + Text( + "Sign In", + style: GoogleFonts.aBeeZee( + fontWeight: FontWeight.w400, + fontSize: 20, ), - const SizedBox(height: 20), - AuthorizationInputWidget( - title: "${Constants.email} or @${Constants.username}", - controller: _emailOrUserNameController, - hintText: Constants.enterEmailOrUserName, - ), - const SizedBox(height: 10), - Stack( - children: [ - AuthorizationInputWidget( - title: Constants.password, - controller: _passwordController, - hintText: Constants.enterPassword, - obscureText: true, - ), - Positioned( - right: 0, - top: 25, - child: IconButton( - onPressed: () => - _authBloc.add(const AuthEvents.changePasswordVisibility()), - icon: Icon( - (authStateModel.showPassword) - ? CupertinoIcons.eye - : CupertinoIcons.eye_slash, - ), + ), + const SizedBox(height: 20), + AuthorizationInputWidget( + title: "${Constants.email} or @${Constants.username}", + controller: _emailOrUserNameController, + hintText: Constants.enterEmailOrUserName, + ), + const SizedBox(height: 10), + Stack( + children: [ + AuthorizationInputWidget( + title: Constants.password, + controller: _passwordController, + hintText: Constants.enterPassword, + obscureText: true, + ), + Positioned( + right: 0, + top: 25, + child: IconButton( + onPressed: () => + _authBloc.add(const AuthEvents.changePasswordVisibility()), + icon: Icon( + (authStateModel.showPassword) + ? CupertinoIcons.eye + : CupertinoIcons.eye_slash, ), ), - ], - ), - const SizedBox(height: 20), - SizedBox( - height: 60, - child: ElevatedButton( - style: ButtonStyle( - shape: WidgetStatePropertyAll( - RoundedRectangleBorder( - borderRadius: BorderRadius.circular(15), - ), + ), + ], + ), + const SizedBox(height: 20), + SizedBox( + height: 60, + child: ElevatedButton( + style: ButtonStyle( + shape: WidgetStatePropertyAll( + RoundedRectangleBorder( + borderRadius: BorderRadius.circular(15), ), - backgroundColor: const WidgetStatePropertyAll(Colors.blueAccent), ), - onPressed: () => _authBloc.add( - AuthEvents.loginEvent( - emailOrUserName: _emailOrUserNameController.text, - password: _passwordController.text, - initDependenciesAfterAuthorization: dependencies.initDependenciesAfterAuthorization, - // initDioOptions: () async { - // await dependencies.restClientBase.initOptions(); - // }, - ), + backgroundColor: const WidgetStatePropertyAll(Colors.blueAccent), + ), + onPressed: () => _authBloc.add( + AuthEvents.loginEvent( + emailOrUserName: _emailOrUserNameController.text, + password: _passwordController.text, + initDependenciesAfterAuthorization: + dependencies.initDependenciesAfterAuthorization, + // initDioOptions: () async { + // await dependencies.restClientBase.initOptions(); + // }, ), - child: Center( - child: (authStateModel.loadingLogin) - ? const SizedBox( - width: 15, - height: 15, - child: CircularProgressIndicator( - strokeWidth: 2, - color: Colors.white, - ), - ) - : Text( - Constants.signIn, - style: GoogleFonts.aBeeZee( - color: Colors.white, - fontWeight: FontWeight.bold, - fontSize: 16, - ), + ), + child: Center( + child: (authStateModel.loadingLogin) + ? const SizedBox( + width: 15, + height: 15, + child: CircularProgressIndicator( + strokeWidth: 2, + color: Colors.white, ), - ), + ) + : Text( + Constants.signIn, + style: GoogleFonts.aBeeZee( + color: Colors.white, + fontWeight: FontWeight.bold, + fontSize: 16, + ), + ), ), ), - const SizedBox(height: 20), - Row( - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - const Expanded( - child: Divider( - height: 0, - thickness: 0.5, - color: Colors.grey, - ), + ), + const SizedBox(height: 20), + Row( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + const Expanded( + child: Divider( + height: 0, + thickness: 0.5, + color: Colors.grey, ), - const SizedBox(width: 15), - Text( - Constants.orSignInWith, - style: GoogleFonts.aBeeZee( - fontWeight: FontWeight.bold, - fontSize: 12, - color: Colors.grey, - ), + ), + const SizedBox(width: 15), + Text( + Constants.orSignInWith, + style: GoogleFonts.aBeeZee( + fontWeight: FontWeight.bold, + fontSize: 12, + color: Colors.grey, ), - const SizedBox(width: 15), - const Expanded( - child: Divider( - height: 0, - thickness: 0.5, - color: Colors.grey, - ), + ), + const SizedBox(width: 15), + const Expanded( + child: Divider( + height: 0, + thickness: 0.5, + color: Colors.grey, ), - ], - ), - const SizedBox(height: 20), - Row( - children: [ - Expanded( - child: OtherAuthorizationButtonWidget( - icon: const FaIcon( - FontAwesomeIcons.google, - ), - text: 'Google', - onTap: () => _authBloc.add( - AuthEvents.googleAuth( - initDependenciesAfterAuthorization: dependencies.initDependenciesAfterAuthorization, - // initDioOptions: () async { - // await dependencies.dioSettings.initOptions(); - // }, - ), + ), + ], + ), + const SizedBox(height: 20), + Row( + children: [ + Expanded( + child: OtherAuthorizationButtonWidget( + icon: const FaIcon( + FontAwesomeIcons.google, + ), + text: 'Google', + onTap: () => _authBloc.add( + AuthEvents.googleAuth( + initDependenciesAfterAuthorization: + dependencies.initDependenciesAfterAuthorization, + // initDioOptions: () async { + // await dependencies.dioSettings.initOptions(); + // }, ), ), ), - const SizedBox(width: 20), - Expanded( - child: OtherAuthorizationButtonWidget( - icon: const FaIcon( - FontAwesomeIcons.facebook, - color: Colors.blue, - ), - text: 'Facebook', - onTap: () => _authBloc.add( - AuthEvents.facebookAuth( - initDependenciesAfterAuthorization: dependencies.initDependenciesAfterAuthorization, - // initDioOptions: () async { - // await dependencies.dioSettings.initOptions(); - // }, - ), + ), + const SizedBox(width: 20), + Expanded( + child: OtherAuthorizationButtonWidget( + icon: const FaIcon( + FontAwesomeIcons.facebook, + color: Colors.blue, + ), + text: 'Facebook', + onTap: () => _authBloc.add( + AuthEvents.facebookAuth( + initDependenciesAfterAuthorization: + dependencies.initDependenciesAfterAuthorization, + // initDioOptions: () async { + // await dependencies.dioSettings.initOptions(); + // }, ), ), ), - ], - ), - const SizedBox(height: 20), - RichText( - text: TextSpan( - style: GoogleFonts.aBeeZee( - fontWeight: FontWeight.bold, - fontSize: 13, - color: Colors.grey, - ), - children: [ - const TextSpan(text: Constants.doNotHaveAnAccount), - const WidgetSpan(child: SizedBox(width: 10)), - TextSpan( - recognizer: TapGestureRecognizer() - ..onTap = - () => AutoRouter.of(context).replace(const RegisterRoute()), - text: Constants.signUp, - style: const TextStyle(color: Colors.blue), - ), - ], ), + ], + ), + const SizedBox(height: 20), + RichText( + text: TextSpan( + style: GoogleFonts.aBeeZee( + fontWeight: FontWeight.bold, + fontSize: 13, + color: Colors.grey, + ), + children: [ + const TextSpan(text: Constants.doNotHaveAnAccount), + const WidgetSpan(child: SizedBox(width: 10)), + TextSpan( + recognizer: TapGestureRecognizer() + ..onTap = () => AutoRouter.of(context).replace(const RegisterRoute()), + text: Constants.signUp, + style: const TextStyle(color: Colors.blue), + ), + ], ), - ], - ), + ), + ], ), ), ), - ); - },); + ), + ); + }, + ); } } diff --git a/lib/src/features/chat_screen/bloc/chat_screen_bloc.dart b/lib/src/features/chat_screen/bloc/chat_screen_bloc.dart index 8f603a4..b9b4dd9 100644 --- a/lib/src/features/chat_screen/bloc/chat_screen_bloc.dart +++ b/lib/src/features/chat_screen/bloc/chat_screen_bloc.dart @@ -20,17 +20,19 @@ part 'chat_screen_bloc.freezed.dart'; @immutable @freezed -abstract class ChatScreenEvents with _$ChatScreenEvents { +sealed class ChatScreenEvents with _$ChatScreenEvents { // init chat on entering to the screen (if chat was already created) const factory ChatScreenEvents.initChatScreenEvent({ final ChatModel? chat, final UserModel? user, // temp for creating temp chat if chat does not exist }) = _ChatScreen$InitEvent; - const factory ChatScreenEvents.removeAllTempCreatedChatsEvent() = _ChatsScreen$RemoveAllTempCreatedEvent; + const factory ChatScreenEvents.removeAllTempCreatedChatsEvent() = + _ChatsScreen$RemoveAllTempCreatedEvent; const factory ChatScreenEvents.handleChatMessageEvent( - ChatMessageStreamTransformerRecord chatMessageTransformer,) = _Chat$HandleMessageEvent; + ChatMessageStreamTransformerRecord chatMessageTransformer, + ) = _Chat$HandleMessageEvent; const factory ChatScreenEvents.sendMessageEvent({ required final String message, diff --git a/lib/src/features/chat_screen/bloc/state_model/chat_screen_state_model.dart b/lib/src/features/chat_screen/bloc/state_model/chat_screen_state_model.dart index 3a26c04..2a0af63 100644 --- a/lib/src/features/chat_screen/bloc/state_model/chat_screen_state_model.dart +++ b/lib/src/features/chat_screen/bloc/state_model/chat_screen_state_model.dart @@ -46,10 +46,13 @@ class ChatScreenStateModel { @override String toString() { return 'ChatScreenStateModel{' - ' messages: $messages,' - ' currentChat: $currentChat,' - ' pickedFile: $pickedFile,' - ' currentUser: $currentUser,' ' relatedUser: $relatedUser,' ' showEmojiPicker: $showEmojiPicker,' '}'; + ' messages: $messages,' + ' currentChat: $currentChat,' + ' pickedFile: $pickedFile,' + ' currentUser: $currentUser,' + ' relatedUser: $relatedUser,' + ' showEmojiPicker: $showEmojiPicker,' + '}'; } ChatScreenStateModel copyWith({ diff --git a/lib/src/features/chat_screen/data/sources/chat_screen_chat_data_source/impl/chat_screen_chat_data_souce.dart b/lib/src/features/chat_screen/data/sources/chat_screen_chat_data_source/impl/chat_screen_chat_data_souce.dart index 26c60f7..02af5f3 100644 --- a/lib/src/features/chat_screen/data/sources/chat_screen_chat_data_source/impl/chat_screen_chat_data_souce.dart +++ b/lib/src/features/chat_screen/data/sources/chat_screen_chat_data_source/impl/chat_screen_chat_data_souce.dart @@ -1,4 +1,3 @@ - import 'package:flutter/foundation.dart'; import 'package:yahay/src/core/utils/dio/src/http_routes/http_routes.dart'; import 'package:yahay/src/core/utils/dio/dio_client.dart'; @@ -16,8 +15,7 @@ class ChatScreenChatDataSourceImpl implements ChatScreenChatDataSource { final RestClientBase _restClientBase; final String _getChatUrl = "${HttpRoutes.chatsPrefix}/get/chat/on/entrance"; - final String _deleteTempCreatedChatsUrl = - "${HttpRoutes.chatsPrefix}/delete/temp/created/chats"; + final String _deleteTempCreatedChatsUrl = "${HttpRoutes.chatsPrefix}/delete/temp/created/chats"; @override Future chat({ChatModel? chat, UserModel? withUser}) async { @@ -40,9 +38,10 @@ class ChatScreenChatDataSourceImpl implements ChatScreenChatDataSource { ); return gettingChat.copyWith( - messages: gettingChat.messages?.map((e) { - return e.copyWith(messageSent: true); - }).toList(),); + messages: gettingChat.messages?.map((e) { + return e.copyWith(messageSent: true); + }).toList(), + ); } on RestClientException { rethrow; } diff --git a/lib/src/features/chat_screen/view/app_bar/chat_screen_app_bar.dart b/lib/src/features/chat_screen/view/app_bar/chat_screen_app_bar.dart index 48b7368..360ac9e 100644 --- a/lib/src/features/chat_screen/view/app_bar/chat_screen_app_bar.dart +++ b/lib/src/features/chat_screen/view/app_bar/chat_screen_app_bar.dart @@ -112,9 +112,11 @@ class _ChatAppBarTitle extends StatelessWidget { if ((chat?.participants?.length ?? 0) > 1) { return Text(chat?.name ?? ''); } else { - return Text(chat?.participants?.firstOrNull?.user?.name ?? - chat?.participants?.firstOrNull?.user?.email ?? - '-',); + return Text( + chat?.participants?.firstOrNull?.user?.name ?? + chat?.participants?.firstOrNull?.user?.email ?? + '-', + ); } } } diff --git a/lib/src/features/chat_screen/view/bottom_chat_widget/bottom_chat_widget.dart b/lib/src/features/chat_screen/view/bottom_chat_widget/bottom_chat_widget.dart index 7d737e1..4e66ff8 100644 --- a/lib/src/features/chat_screen/view/bottom_chat_widget/bottom_chat_widget.dart +++ b/lib/src/features/chat_screen/view/bottom_chat_widget/bottom_chat_widget.dart @@ -122,9 +122,11 @@ class _BottomChatWidgetState extends State { telegramFilePickerBloc: telegramFilePickerBloc, ); }, - ).whenComplete( - telegramFilePickerBloc.close, - ).ignore(); + ) + .whenComplete( + telegramFilePickerBloc.close, + ) + .ignore(); }, icon: const FaIcon(FontAwesomeIcons.paste), ), diff --git a/lib/src/features/chats/bloc/chats_bloc.dart b/lib/src/features/chats/bloc/chats_bloc.dart index 690cd32..2a180de 100644 --- a/lib/src/features/chats/bloc/chats_bloc.dart +++ b/lib/src/features/chats/bloc/chats_bloc.dart @@ -16,7 +16,7 @@ part 'chats_bloc.freezed.dart'; @immutable @freezed -class ChatsEvents with _$ChatsEvents { +sealed class ChatsEvents with _$ChatsEvents { const factory ChatsEvents.getUserChatsEvent({@Default(false) bool refresh}) = _Chats$GetUserEvent; const factory ChatsEvents.chatListenerInitialEvent() = _Chats$ListenerInitialEvent; @@ -34,8 +34,7 @@ sealed class ChatsStates with _$ChatsStates { const factory ChatsStates.inProgress(final ChatsStateModel chatsStateModel) = Chats$InProgressState; - const factory ChatsStates.error(final ChatsStateModel chatsStateModel) = - Chats$ErrorState; + const factory ChatsStates.error(final ChatsStateModel chatsStateModel) = Chats$ErrorState; const factory ChatsStates.successful(final ChatsStateModel chatsStateModel) = Chats$SuccessfulState; @@ -148,7 +147,7 @@ class ChatsBloc extends Bloc { if (event.chatModel != null) { final currentStateModel = state.chatsStateModel.copyWith( - chats: addChat( + chats: _addChat( chat: event.chatModel, currentChats: state.chatsStateModel.chats, ), @@ -189,7 +188,7 @@ class ChatsBloc extends Bloc { } } - List addChat({ + List _addChat({ required ChatModel? chat, required List currentChats, UserModel? user, diff --git a/lib/src/features/chats/view/chat_widget/chat_widget.dart b/lib/src/features/chats/view/chat_widget/chat_widget.dart index 92a1157..6ec583f 100644 --- a/lib/src/features/chats/view/chat_widget/chat_widget.dart +++ b/lib/src/features/chats/view/chat_widget/chat_widget.dart @@ -87,7 +87,7 @@ class _ChatMainImage extends StatelessWidget { borderRadius: BorderRadius.circular(50), child: CircleAvatar( radius: 30, - child: Container( + child: ColoredBox( color: Colors.green, child: Text(chat?.getWrappedName() ?? '-'), ), diff --git a/lib/src/features/home_page.dart b/lib/src/features/home_page.dart index de4251b..c819533 100644 --- a/lib/src/features/home_page.dart +++ b/lib/src/features/home_page.dart @@ -90,10 +90,12 @@ class _HomePageState extends State { unselectedLabelStyle: GoogleFonts.aBeeZee(), selectedLabelStyle: GoogleFonts.aBeeZee(), items: _screens - .map((e) => BottomNavigationBarItem( - icon: e.icon, - label: e.label, - ),) + .map( + (e) => BottomNavigationBarItem( + icon: e.icon, + label: e.label, + ), + ) .toList(), ), body: _screens[_index].screen, diff --git a/lib/src/features/initialization/logic/composition_root/factories/profile_bloc_factory.dart b/lib/src/features/initialization/logic/composition_root/factories/profile_bloc_factory.dart index 9005cb9..92f6468 100644 --- a/lib/src/features/initialization/logic/composition_root/factories/profile_bloc_factory.dart +++ b/lib/src/features/initialization/logic/composition_root/factories/profile_bloc_factory.dart @@ -27,7 +27,7 @@ final class ProfileBlocFactory extends Factory { final IProfileRepository profileRepository = ProfileRepositoryImpl(profileDatasource); // - final initialState = ProfileStates.initial(ProfileStateModel()); + const initialState = ProfileStates.initial(ProfileStateModel()); return ProfileBloc( initialState: initialState, diff --git a/lib/src/features/initialization/widgets/root_context.dart b/lib/src/features/initialization/widgets/root_context.dart index b5c5480..0ebbe11 100644 --- a/lib/src/features/initialization/widgets/root_context.dart +++ b/lib/src/features/initialization/widgets/root_context.dart @@ -4,13 +4,14 @@ import 'package:yahay/src/features/initialization/widgets/dependencies_scope.dar import 'package:yahay/src/features/initialization/widgets/material_context.dart'; class RootContext extends StatelessWidget { - final CompositionResult compositionResult; - + // const RootContext({ super.key, required this.compositionResult, }); + final CompositionResult compositionResult; + @override Widget build(BuildContext context) { return DependenciesScope( diff --git a/lib/src/features/profile/bloc/profile_bloc.dart b/lib/src/features/profile/bloc/profile_bloc.dart index 9a41c30..de1b50f 100644 --- a/lib/src/features/profile/bloc/profile_bloc.dart +++ b/lib/src/features/profile/bloc/profile_bloc.dart @@ -9,7 +9,7 @@ part 'profile_bloc.freezed.dart'; @immutable @freezed -class ProfileEvents with _$ProfileEvents { +sealed class ProfileEvents with _$ProfileEvents { const factory ProfileEvents.profileLogoutEvent(final void Function() logoutEvent) = _Profile$LogoutEvent; } diff --git a/lib/src/features/profile/bloc/state_model/profile_state_model.dart b/lib/src/features/profile/bloc/state_model/profile_state_model.dart index 54476e1..39a6df2 100644 --- a/lib/src/features/profile/bloc/state_model/profile_state_model.dart +++ b/lib/src/features/profile/bloc/state_model/profile_state_model.dart @@ -19,7 +19,7 @@ class ProfileStateModel { @override String toString() { - return 'ProfileStateModel{' + ' userModel: $userModel,' + '}'; + return 'ProfileStateModel{' ' userModel: $userModel,' '}'; } ProfileStateModel copyWith({ diff --git a/lib/src/features/profile/view/profile_page.dart b/lib/src/features/profile/view/profile_page.dart index ef98ae2..85762a4 100644 --- a/lib/src/features/profile/view/profile_page.dart +++ b/lib/src/features/profile/view/profile_page.dart @@ -43,17 +43,10 @@ class _ProfilePageState extends State { ), ], ), - body: Center( - child: ElevatedButton( - onPressed: () => _profileBloc?.add( - ProfileEvents.profileLogoutEvent( - () { - _authBloc.add(const AuthEvents.logOutEvent()); - }, - ), - ), - child: const Icon(Icons.logout), - ), + body: const CustomScrollView( + slivers: [ + + ], ), ); } diff --git a/lib/src/features/profile/view/widgets/profile_header/profile_header_widget.dart b/lib/src/features/profile/view/widgets/profile_header/profile_header_widget.dart index e18a647..960b04c 100644 --- a/lib/src/features/profile/view/widgets/profile_header/profile_header_widget.dart +++ b/lib/src/features/profile/view/widgets/profile_header/profile_header_widget.dart @@ -27,7 +27,7 @@ class _ProfileHeaderWidgetState extends State { children: [ Text("NAME"), Text("PHONE NUMBER"), - Text("USERNAME OR EMAIL") + Text("USERNAME OR EMAIL"), ], ), ), diff --git a/lib/src/features/telegram_file_picker_feature/bloc/state_model/telegram_file_picker_state_model.dart b/lib/src/features/telegram_file_picker_feature/bloc/state_model/telegram_file_picker_state_model.dart index 5629c35..1479551 100644 --- a/lib/src/features/telegram_file_picker_feature/bloc/state_model/telegram_file_picker_state_model.dart +++ b/lib/src/features/telegram_file_picker_feature/bloc/state_model/telegram_file_picker_state_model.dart @@ -23,7 +23,6 @@ class TelegramFilePickerStateModel { final List specificFolderFilesPagination; -// const TelegramFilePickerStateModel({ this.getPathForGettingImagesFrom, this.filePickerScreenSelectedScreen = TelegramFileFolderEnum.recentDownloadsScreen, @@ -78,7 +77,18 @@ class TelegramFilePickerStateModel { @override String toString() { - return 'TelegramFilePickerStateModel{' ' getPathForGettingImagesFrom: $getPathForGettingImagesFrom,' ' openBottomSectionButton: $openBottomSectionButton,' ' filePickerScreenSelectedScreen: $filePickerScreenSelectedScreen,' ' galleryPathFiles: $galleryPathFiles,' ' galleryPathPagination: $galleryPathPagination,' ' recentFiles: $recentFiles,' ' recentFilesPagination: $recentFilesPagination,' ' pickedFiles: $pickedFiles,' ' specificFolderFilesAll: $specificFolderFilesAll,' ' specificFolderFilesPagination: $specificFolderFilesPagination,' '}'; + return 'TelegramFilePickerStateModel{' + ' getPathForGettingImagesFrom: $getPathForGettingImagesFrom,' + ' openBottomSectionButton: $openBottomSectionButton,' + ' filePickerScreenSelectedScreen: $filePickerScreenSelectedScreen,' + ' galleryPathFiles: $galleryPathFiles,' + ' galleryPathPagination: $galleryPathPagination,' + ' recentFiles: $recentFiles,' + ' recentFilesPagination: $recentFilesPagination,' + ' pickedFiles: $pickedFiles,' + ' specificFolderFilesAll: $specificFolderFilesAll,' + ' specificFolderFilesPagination: $specificFolderFilesPagination,' + '}'; } TelegramFilePickerStateModel copyWith({ diff --git a/lib/src/features/telegram_file_picker_feature/bloc/telegram_file_picker_bloc.dart b/lib/src/features/telegram_file_picker_feature/bloc/telegram_file_picker_bloc.dart index 2c2dc40..40fa737 100644 --- a/lib/src/features/telegram_file_picker_feature/bloc/telegram_file_picker_bloc.dart +++ b/lib/src/features/telegram_file_picker_feature/bloc/telegram_file_picker_bloc.dart @@ -24,7 +24,7 @@ part 'telegram_file_picker_bloc.freezed.dart'; @immutable @freezed -class TelegramFilePickerEvents with _$TelegramFilePickerEvents { +sealed class TelegramFilePickerEvents with _$TelegramFilePickerEvents { const factory TelegramFilePickerEvents.justEmitStateEvent( final TelegramFilePickerStateModel currentStateModel, ) = _JustEmitStateEvent; @@ -49,16 +49,19 @@ class TelegramFilePickerEvents with _$TelegramFilePickerEvents { const factory TelegramFilePickerEvents.closePopupEvent() = _ClosePopupEvent; const factory TelegramFilePickerEvents.fileStreamHandlerEvent( - final TelegramPathFolderFile? file,) = _FileStreamHandlerEvent; + final TelegramPathFolderFile? file, + ) = _FileStreamHandlerEvent; const factory TelegramFilePickerEvents.recentFileStreamHandlerEvent( - final TelegramPathFolderFile? file,) = _RecentFileStreamHandlerEvent; + final TelegramPathFolderFile? file, + ) = _RecentFileStreamHandlerEvent; const factory TelegramFilePickerEvents.imagesAndVideoPaginationEvent() = _ImagesAndVideoPaginationEvent; const factory TelegramFilePickerEvents.selectGalleryFileEvent( - final TelegramFileImageEntity? telegramFileImageEntity,) = _SelectGalleryFileEvent; + final TelegramFileImageEntity? telegramFileImageEntity, + ) = _SelectGalleryFileEvent; const factory TelegramFilePickerEvents.clearSelectedGalleryFileEvent() = _ClearSelectedGalleryFileEvent; @@ -69,16 +72,20 @@ class TelegramFilePickerEvents with _$TelegramFilePickerEvents { _BrowseInternalStorageAndSelectFilesEvent; const factory TelegramFilePickerEvents.selectScreenForFilesPickerScreenEvent( - final TelegramFileFolderEnum screen,) = _SelectScreenForFilesPickerScreenEvent; + final TelegramFileFolderEnum screen, + ) = _SelectScreenForFilesPickerScreenEvent; const factory TelegramFilePickerEvents.setSpecificFolderPathInOrderToGetDataFromThereEvent( - final String? path,) = _SetSpecificFolderPathInOrderToGetDataFromThereEvent; + final String? path, + ) = _SetSpecificFolderPathInOrderToGetDataFromThereEvent; - const factory TelegramFilePickerEvents.getSpecificFolderDataEvent( - {required final bool getGalleryData,}) = _GetSpecificFolderDataEvent; + const factory TelegramFilePickerEvents.getSpecificFolderDataEvent({ + required final bool getGalleryData, + }) = _GetSpecificFolderDataEvent; const factory TelegramFilePickerEvents.specificFolderDataStreamHandlerEvent( - final TelegramPathFolderFile? file,) = _SpecificFolderDataStreamHandlerEvent; + final TelegramPathFolderFile? file, + ) = _SpecificFolderDataStreamHandlerEvent; const factory TelegramFilePickerEvents.paginateSpecificFolderDataEvent() = _PaginateSpecificFolderDataEvent; @@ -244,9 +251,11 @@ class TelegramFilePickerBloc extends Bloc emit, ) async { - emit(TelegramFilePickerStates.filesPickerState( - state.telegramFilePickerStateModel, - ),); + emit( + TelegramFilePickerStates.filesPickerState( + state.telegramFilePickerStateModel, + ), + ); } void _initAllAudioEvent( @@ -400,10 +409,12 @@ class TelegramFilePickerBloc extends Bloc [ - TelegramFilePickerBottomButton(Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - GestureDetector( - onTap: () { - telegramBloc.add( - const TelegramFilePickerEvents.changeStateToAllPicturesEvent(), - ); + TelegramFilePickerBottomButton( + Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + GestureDetector( + onTap: () { + telegramBloc.add( + const TelegramFilePickerEvents.changeStateToAllPicturesEvent(), + ); - // telegramBloc.events.add(const InitAllFilesEvent(initFilePickerState: false)); + // telegramBloc.events.add(const InitAllFilesEvent(initFilePickerState: false)); - draggableSheetAnimate(); - }, - child: Container( - width: 60, - height: 60, - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(50), - color: Colors.blue, - ), - child: const Center( - child: Icon( - Icons.image, - color: Colors.white, + draggableSheetAnimate(); + }, + child: Container( + width: 60, + height: 60, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(50), + color: Colors.blue, + ), + child: const Center( + child: Icon( + Icons.image, + color: Colors.white, + ), ), ), ), - ), - const SizedBox(height: 10), - Text( - "Gallery", - style: GoogleFonts.aBeeZee( - fontSize: 16, + const SizedBox(height: 10), + Text( + "Gallery", + style: GoogleFonts.aBeeZee( + fontSize: 16, + ), ), - ), - ], - ),), + ], + ), + ), TelegramFilePickerBottomButton( Column( mainAxisAlignment: MainAxisAlignment.center, diff --git a/lib/src/features/telegram_file_picker_feature/domain/entities/telegram_file_folder_enums.dart b/lib/src/features/telegram_file_picker_feature/domain/entities/telegram_file_folder_enums.dart index a5f9a80..0d6e1f2 100644 --- a/lib/src/features/telegram_file_picker_feature/domain/entities/telegram_file_folder_enums.dart +++ b/lib/src/features/telegram_file_picker_feature/domain/entities/telegram_file_folder_enums.dart @@ -3,4 +3,4 @@ enum TelegramFileFolderEnum { browseTheAppsFolder, browseTheFolder, browseTheGalleryFolder, -} \ No newline at end of file +} diff --git a/lib/src/features/telegram_file_picker_feature/view/bottom_picker_button/telegram_bottom_sender_button.dart b/lib/src/features/telegram_file_picker_feature/view/bottom_picker_button/telegram_bottom_sender_button.dart index 5a1a9da..5e6d01b 100644 --- a/lib/src/features/telegram_file_picker_feature/view/bottom_picker_button/telegram_bottom_sender_button.dart +++ b/lib/src/features/telegram_file_picker_feature/view/bottom_picker_button/telegram_bottom_sender_button.dart @@ -26,7 +26,7 @@ class _TelegramBottomSenderButtonState extends State ), const SizedBox(width: 10), Expanded( - child: Container( + child: DecoratedBox( decoration: BoxDecoration( color: Theme.of(context).cardColor, //Theme.of(context).cardColor ), diff --git a/lib/src/features/telegram_file_picker_feature/view/reusable_widgets/telegram_storage_file_widget.dart b/lib/src/features/telegram_file_picker_feature/view/reusable_widgets/telegram_storage_file_widget.dart index 797b075..637662e 100644 --- a/lib/src/features/telegram_file_picker_feature/view/reusable_widgets/telegram_storage_file_widget.dart +++ b/lib/src/features/telegram_file_picker_feature/view/reusable_widgets/telegram_storage_file_widget.dart @@ -102,7 +102,7 @@ class _TelegramStorageFileWidgetState extends State { ? 1 : 0, duration: const Duration(milliseconds: 150), - child: Container( + child: DecoratedBox( decoration: BoxDecoration( color: Colors.green, borderRadius: BorderRadius.circular(30), @@ -183,7 +183,7 @@ class _VideoItem extends StatelessWidget { ), ), Positioned.fill( - child: Container( + child: DecoratedBox( decoration: BoxDecoration( color: Colors.black87.withOpacity(0.5), borderRadius: BorderRadius.circular(10), diff --git a/lib/src/features/telegram_file_picker_feature/view/screens/telegram_app_folder_screen/telegram_browse_folder_widget.dart b/lib/src/features/telegram_file_picker_feature/view/screens/telegram_app_folder_screen/telegram_browse_folder_widget.dart index 680619a..91ba05d 100644 --- a/lib/src/features/telegram_file_picker_feature/view/screens/telegram_app_folder_screen/telegram_browse_folder_widget.dart +++ b/lib/src/features/telegram_file_picker_feature/view/screens/telegram_app_folder_screen/telegram_browse_folder_widget.dart @@ -14,7 +14,7 @@ class TelegramFolderWidget extends StatelessWidget { Widget build(BuildContext context) { return GestureDetector( onTap: onTap, - child: Container( + child: ColoredBox( color: Colors.transparent, child: IntrinsicHeight( child: Row( diff --git a/lib/src/features/telegram_file_picker_feature/view/screens/telegram_files_picker_screen/telegram_files_picker_screen.dart b/lib/src/features/telegram_file_picker_feature/view/screens/telegram_files_picker_screen/telegram_files_picker_screen.dart index 3faed74..2a3b143 100644 --- a/lib/src/features/telegram_file_picker_feature/view/screens/telegram_files_picker_screen/telegram_files_picker_screen.dart +++ b/lib/src/features/telegram_file_picker_feature/view/screens/telegram_files_picker_screen/telegram_files_picker_screen.dart @@ -145,8 +145,7 @@ class _TelegramFilesPickerScreenState extends State w ? 1 : 0, duration: const Duration(seconds: 1), - child: const TelegramBrowseAppFolderScreen( - ), + child: const TelegramBrowseAppFolderScreen(), ), ), ), @@ -195,7 +194,8 @@ class _TelegramFilesPickerScreenState extends State w ); Future.delayed(const Duration(milliseconds: 300), () { _telegramFilePickerBloc.add( - const TelegramFilePickerEvents.clearSelectedGalleryFileEvent(),); + const TelegramFilePickerEvents.clearSelectedGalleryFileEvent(), + ); }); }, ), @@ -250,7 +250,8 @@ class _TelegramFilesPickerScreenState extends State w Future.delayed(const Duration(milliseconds: 300), () { _telegramFilePickerBloc.add( - const TelegramFilePickerEvents.clearSelectedGalleryFileEvent(),); + const TelegramFilePickerEvents.clearSelectedGalleryFileEvent(), + ); }); }, ), diff --git a/lib/src/features/telegram_file_picker_feature/view/screens/telegram_files_picker_screen/widgets/telegram_files_from_storages_widget.dart b/lib/src/features/telegram_file_picker_feature/view/screens/telegram_files_picker_screen/widgets/telegram_files_from_storages_widget.dart index 3732d01..746c1d8 100644 --- a/lib/src/features/telegram_file_picker_feature/view/screens/telegram_files_picker_screen/widgets/telegram_files_from_storages_widget.dart +++ b/lib/src/features/telegram_file_picker_feature/view/screens/telegram_files_picker_screen/widgets/telegram_files_from_storages_widget.dart @@ -52,7 +52,7 @@ class _TelegramFilesFromStoragesWidgetState extends State widget.telegramFilePickerBloc - .add(TelegramFilePickerEvents.selectGalleryFileEvent( - widget.item, - ),), + onPressed: () => widget.telegramFilePickerBloc.add( + TelegramFilePickerEvents.selectGalleryFileEvent( + widget.item, + ), + ), icon: currentStateModel.isFileInsidePickedFiles(widget.item) ? const Icon(Icons.check_circle) : const Icon(Icons.circle_outlined), diff --git a/lib/src/features/telegram_file_picker_feature/view/screens/telegram_gallery_file_picker_screen/widgets/telegram_gallery_file_picker_video_player_widget.dart b/lib/src/features/telegram_file_picker_feature/view/screens/telegram_gallery_file_picker_screen/widgets/telegram_gallery_file_picker_video_player_widget.dart index c2b32f7..5113703 100644 --- a/lib/src/features/telegram_file_picker_feature/view/screens/telegram_gallery_file_picker_screen/widgets/telegram_gallery_file_picker_video_player_widget.dart +++ b/lib/src/features/telegram_file_picker_feature/view/screens/telegram_gallery_file_picker_screen/widgets/telegram_gallery_file_picker_video_player_widget.dart @@ -51,10 +51,11 @@ class _TelegramGalleryFilePickerVideoPlayerWidgetState right: 0, top: 0, child: IconButton( - onPressed: () => widget.telegramFilePickerBloc - .add(TelegramFilePickerEvents.selectGalleryFileEvent( - widget.item, - ),), + onPressed: () => widget.telegramFilePickerBloc.add( + TelegramFilePickerEvents.selectGalleryFileEvent( + widget.item, + ), + ), icon: _currentStateModel.isFileInsidePickedFiles(widget.item) ? const Icon(Icons.check_circle) : const Icon(Icons.circle_outlined), diff --git a/lib/src/features/video_chat_feature/bloc/state_model/video_chat_state_model.dart b/lib/src/features/video_chat_feature/bloc/state_model/video_chat_state_model.dart index 8d9a52a..a4493c9 100644 --- a/lib/src/features/video_chat_feature/bloc/state_model/video_chat_state_model.dart +++ b/lib/src/features/video_chat_feature/bloc/state_model/video_chat_state_model.dart @@ -3,6 +3,18 @@ import 'package:yahay/src/core/models/user_model/user_model.dart'; import 'package:yahay/src/features/video_chat_feature/models/video_chat_model.dart'; class VideoChatStateModel { + // + const VideoChatStateModel({ + required this.chatStarted, + required this.hasAudio, + required this.hasVideo, + required this.cameraSwitched, + required this.videoChatEntities, + this.chat, + this.currentUser, + this.currentVideoChatEntity, + }); + final bool chatStarted; final bool hasAudio; @@ -19,17 +31,6 @@ class VideoChatStateModel { final List videoChatEntities; - const VideoChatStateModel({ - required this.chatStarted, - required this.hasAudio, - required this.hasVideo, - required this.cameraSwitched, - required this.videoChatEntities, - this.chat, - this.currentUser, - this.currentVideoChatEntity, - }); - factory VideoChatStateModel.idle() => const VideoChatStateModel( chatStarted: false, hasAudio: true, @@ -66,7 +67,16 @@ class VideoChatStateModel { @override String toString() { - return 'VideoChatStateModel{' ' chatStarted: $chatStarted,' ' hasAudio: $hasAudio,' ' hasVideo: $hasVideo,' ' cameraSwitched: $cameraSwitched,' ' chat: $chat,' ' currentUser: $currentUser,' ' _currentVideoChatEntity: $currentVideoChatEntity,' ' _videoChatEntities: $videoChatEntities,' '}'; + return 'VideoChatStateModel{' + ' chatStarted: $chatStarted,' + ' hasAudio: $hasAudio,' + ' hasVideo: $hasVideo,' + ' cameraSwitched: $cameraSwitched,' + ' chat: $chat,' + ' currentUser: $currentUser,' + ' _currentVideoChatEntity: $currentVideoChatEntity,' + ' _videoChatEntities: $videoChatEntities,' + '}'; } VideoChatStateModel copyWith({ diff --git a/lib/src/features/video_chat_feature/bloc/video_chat_feature_bloc.dart b/lib/src/features/video_chat_feature/bloc/video_chat_feature_bloc.dart index 1bf18b7..98198fe 100644 --- a/lib/src/features/video_chat_feature/bloc/video_chat_feature_bloc.dart +++ b/lib/src/features/video_chat_feature/bloc/video_chat_feature_bloc.dart @@ -18,7 +18,7 @@ part 'video_chat_feature_bloc.freezed.dart'; @immutable @freezed -class VideoChatFeatureEvents with _$VideoChatFeatureEvents { +sealed class VideoChatFeatureEvents with _$VideoChatFeatureEvents { const factory VideoChatFeatureEvents.videoChatInitFeatureEvent(final ChatModel? chat) = _VideoChatInitFeatureEvent; diff --git a/lib/src/features/video_chat_feature/widgets/type_of_screens/double_camera_view_screen.dart b/lib/src/features/video_chat_feature/widgets/type_of_screens/double_camera_view_screen.dart index b64c843..6c4610d 100644 --- a/lib/src/features/video_chat_feature/widgets/type_of_screens/double_camera_view_screen.dart +++ b/lib/src/features/video_chat_feature/widgets/type_of_screens/double_camera_view_screen.dart @@ -11,8 +11,6 @@ class DoubleCameraViewScreen extends StatefulWidget { } class _DoubleCameraViewScreenState extends State { - - @override Widget build(BuildContext context) { return BlocBuilder( diff --git a/lib/src/features/video_chat_feature/widgets/widgets/call_button_widget.dart b/lib/src/features/video_chat_feature/widgets/widgets/call_button_widget.dart index 6aaed65..41aa0e4 100644 --- a/lib/src/features/video_chat_feature/widgets/widgets/call_button_widget.dart +++ b/lib/src/features/video_chat_feature/widgets/widgets/call_button_widget.dart @@ -96,7 +96,10 @@ class _CallButtonWidgetState extends State { Text( state.videoChatStateModel.chat?.videoChatRoom != null ? "Accept" : "Call", style: const TextStyle( - color: Colors.white, fontWeight: FontWeight.w500, letterSpacing: 1.5,), + color: Colors.white, + fontWeight: FontWeight.w500, + letterSpacing: 1.5, + ), ), ], ); diff --git a/lib/src/features/video_chat_feature/widgets/widgets/hang_up_buttons_widget.dart b/lib/src/features/video_chat_feature/widgets/widgets/hang_up_buttons_widget.dart index 873dc73..16f7651 100644 --- a/lib/src/features/video_chat_feature/widgets/widgets/hang_up_buttons_widget.dart +++ b/lib/src/features/video_chat_feature/widgets/widgets/hang_up_buttons_widget.dart @@ -11,8 +11,6 @@ class HangUpButtonsWidget extends StatefulWidget { } class _HangUpButtonsWidgetState extends State { - - @override Widget build(BuildContext context) { return Row( From 386421e32b6632dc0fb26e20ba5a038d8cda2b75 Mon Sep 17 00:00:00 2001 From: sb-dor Date: Fri, 7 Mar 2025 15:42:36 +0500 Subject: [PATCH 04/10] uploaded with new version of dart and formatted code in lib folder --- lib/src/core/app_routing/app_router.dart | 37 +- .../global_usages/constants/constants.dart | 3 +- .../reusables/reusable_global_functions.dart | 9 +- .../chat_message_model.dart | 3 +- .../chat_participant_status_model.dart | 6 +- .../core/models/chats_model/chat_model.dart | 3 +- .../core/models/room_models/room_model.dart | 3 +- .../core/models/user_model/user_model.dart | 7 +- .../ui_kit/image_loader/image_loaded.dart | 17 +- .../ui_kit/search_widget/search_widget.dart | 9 +- lib/src/core/ui_kit/shimmer_loader.dart | 24 +- .../user_widgets/add_contact_user_widget.dart | 14 +- .../bloc_observer_manager.dart | 57 ++- .../camera_helper_service.dart | 183 ++++----- .../debug_image_creator_in_apps_folder.dart | 7 +- .../src/exceptions/rest_client_exception.dart | 13 +- .../core/utils/dio/src/rest_client_base.dart | 90 +++-- .../core/utils/dio/src/rest_client_dio.dart | 18 +- .../firebase_error_reporter.dart | 7 +- .../laravel_error_reporter.dart | 5 +- lib/src/core/utils/extensions/extensions.dart | 3 +- .../utils/global_context/global_context.dart | 3 +- .../image_comporessor/image_compressor.dart | 13 +- .../list_pagination_checker.dart | 18 +- .../shared_preferences.dart | 10 +- .../bloc/add_contact_bloc.dart | 28 +- .../state_model/add_contact_state_model.dart | 13 +- .../data/add_contact_repo.dart | 3 +- .../data/add_contact_source.dart | 13 +- .../view/pages/add_contacts_page.dart | 39 +- .../app_theme/bloc/app_theme_bloc.dart | 18 +- .../app_theme/models/app_colors_scheme.dart | 6 +- .../authorization/bloc/auth_bloc.dart | 63 ++-- .../bloc/state_model/auth_state_model.dart | 15 +- .../data/repo/authorization_repo_impl.dart | 20 +- .../impl/laravel_auth_data_source_impl.dart | 27 +- .../impl/other_authorization_impl.dart | 25 +- .../authorization/view/login_page.dart | 125 ++++--- .../authorization/view/register_page.dart | 347 +++++++++--------- .../widgets/authorization_input_widget.dart | 11 +- .../other_authorization_button_widget.dart | 5 +- .../chat_screen/bloc/chat_screen_bloc.dart | 136 +++---- .../chat_message_stream_transformer.dart | 26 +- .../data/repo/chat_screen_chat_repo_impl.dart | 6 +- .../data/repo/chat_screen_repo_impl.dart | 26 +- .../impl/chat_screen_chat_data_souce.dart | 31 +- .../chat_screen_message_data_source_impl.dart | 3 +- .../domain/repo/chat_screen_repo.dart | 4 +- .../view/app_bar/chat_screen_app_bar.dart | 88 ++--- .../bottom_chat_widget.dart | 53 +-- .../emoji_picker_helper.dart | 19 +- .../chat_screen/view/chat_screen.dart | 53 +-- .../loading_messages_widget.dart | 32 +- .../view/message_widget/message_widget.dart | 41 +-- lib/src/features/chats/bloc/chats_bloc.dart | 74 ++-- .../bloc/state_model/chats_state_model.dart | 20 +- .../chats_stream_transformers.dart | 15 +- .../impl/chats_data_source_impl.dart | 9 +- .../view/chat_widget/chat_loading_widget.dart | 5 +- .../chats/view/chat_widget/chat_widget.dart | 43 +-- .../chats/view/chats_appbar/chats_appbar.dart | 18 +- lib/src/features/chats/view/chats_page.dart | 13 +- lib/src/features/home_page.dart | 30 +- .../initialization/logic/app_runner.dart | 59 +-- .../composition_root/composition_root.dart | 50 +-- .../factories/add_contact_bloc_factory.dart | 4 +- .../factories/authorization_bloc_factory.dart | 45 +-- .../factories/chat_screen_bloc_factory.dart | 18 +- .../factories/chats_bloc_factory.dart | 8 +- .../factories/profile_bloc_factory.dart | 8 +- .../telegram_file_picker_bloc_factory.dart | 6 +- .../factories/video_chat_bloc_factory.dart | 17 +- .../models/dependency_container.dart | 22 +- .../widgets/dependencies_scope.dart | 11 +- .../widgets/material_context.dart | 5 +- .../initialization/widgets/root_context.dart | 5 +- lib/src/features/loading_page.dart | 21 +- .../features/profile/bloc/profile_bloc.dart | 27 +- .../bloc/state_model/profile_state_model.dart | 16 +- .../profile/data/profile_datasource.dart | 4 +- .../profile/data/profile_repository.dart | 2 - .../features/profile/view/profile_page.dart | 20 +- .../profile_header_loading_widget.dart | 6 +- .../profile_settings_loading_widget.dart | 6 +- .../telegram_file_picker_state_model.dart | 24 +- .../bloc/telegram_file_picker_bloc.dart | 277 ++++++++------ .../telegram_file_picker_bottom_button.dart | 177 ++++----- ...legram_storage_file_picker_data_model.dart | 100 +++-- .../telegram_path_folder_file_model.dart | 23 +- .../repo/telegram_file_picker_repo_impl.dart | 12 +- .../telegram_file_image_asset_entity.dart | 9 +- .../repo/telegram_file_picker_repo.dart | 4 +- .../app_storage_file_mixin.dart | 12 +- .../mixins/folder_creator/folder_creator.dart | 7 +- .../downloads_path_files.dart | 14 +- .../recent_galley_file_mixin.dart | 65 ++-- .../telegram_bottom_picker_button.dart | 6 +- .../telegram_bottom_sender_button.dart | 22 +- .../telegram_storage_file_widget.dart | 63 ++-- .../telegram_browse_app_folder_screen.dart | 43 +-- .../telegram_browse_folder_data_screen.dart | 21 +- .../telegram_browse_folder_widget.dart | 17 +- .../telegram_files_picker_screen.dart | 169 ++++++--- .../telegram_files_from_storages_widget.dart | 26 +- ...gram_resent_files_from_storage_widget.dart | 16 +- .../telegram_gallery_file_picker_screen.dart | 20 +- ...ram_gallery_file_picker_camera_widget.dart | 4 +- ...gram_gallery_file_picker_image_widget.dart | 32 +- ...llery_file_picker_video_player_widget.dart | 49 ++- ...ram_draggable_scrollable_bottom_sheet.dart | 34 +- .../state_model/video_chat_state_model.dart | 17 +- .../bloc/video_chat_feature_bloc.dart | 76 ++-- .../data/video_chat_feature_data_source.dart | 25 +- .../data/video_chat_feature_repo.dart | 12 +- .../candidate_model/candidate_model.dart | 6 +- .../webrtc_laravel_service.dart | 72 ++-- .../double_camera_view_screen.dart | 16 +- .../widgets/video_chat_feature_page.dart | 35 +- .../widgets/widgets/call_button_widget.dart | 43 +-- .../widgets/hang_up_buttons_widget.dart | 18 +- pubspec.lock | 74 ++-- pubspec.yaml | 2 +- 122 files changed, 2072 insertions(+), 1995 deletions(-) diff --git a/lib/src/core/app_routing/app_router.dart b/lib/src/core/app_routing/app_router.dart index aaa5f06..b497794 100644 --- a/lib/src/core/app_routing/app_router.dart +++ b/lib/src/core/app_routing/app_router.dart @@ -16,33 +16,12 @@ part 'app_router.gr.dart'; class AppRouter extends RootStackRouter { @override List get routes => [ - AutoRoute( - page: LoadingRoute.page, - path: '/', - ), - AutoRoute( - page: LoginRoute.page, - path: '/login', - ), - AutoRoute( - page: RegisterRoute.page, - path: '/register', - ), - AutoRoute( - page: ChatsRoute.page, - path: '/chats', - ), - AutoRoute( - page: HomeRoute.page, - path: '/homepage', - ), - AutoRoute( - page: ChatRoute.page, - path: "/homepage/chat/screen", - ), - AutoRoute( - page: VideoChatFeatureRoute.page, - path: '/videochat', - ), - ]; + AutoRoute(page: LoadingRoute.page, path: '/'), + AutoRoute(page: LoginRoute.page, path: '/login'), + AutoRoute(page: RegisterRoute.page, path: '/register'), + AutoRoute(page: ChatsRoute.page, path: '/chats'), + AutoRoute(page: HomeRoute.page, path: '/homepage'), + AutoRoute(page: ChatRoute.page, path: "/homepage/chat/screen"), + AutoRoute(page: VideoChatFeatureRoute.page, path: '/videochat'), + ]; } diff --git a/lib/src/core/global_usages/constants/constants.dart b/lib/src/core/global_usages/constants/constants.dart index 1211a22..07cdc5e 100644 --- a/lib/src/core/global_usages/constants/constants.dart +++ b/lib/src/core/global_usages/constants/constants.dart @@ -44,7 +44,8 @@ abstract class Constants { // static const String killIsolate = "kill_isolate"; - static const String somethingWentWrong = "Something went wrong, please, try later"; + static const String somethingWentWrong = + "Something went wrong, please, try later"; static const double minimumHeightForShowingRiveTextFieldAnim = 650; } diff --git a/lib/src/core/global_usages/reusables/reusable_global_functions.dart b/lib/src/core/global_usages/reusables/reusable_global_functions.dart index 6bfb42c..79be722 100644 --- a/lib/src/core/global_usages/reusables/reusable_global_functions.dart +++ b/lib/src/core/global_usages/reusables/reusable_global_functions.dart @@ -4,7 +4,8 @@ import 'package:path/path.dart' as path; class ReusableGlobalFunctions { static ReusableGlobalFunctions? _instance; - static ReusableGlobalFunctions get instance => _instance ??= ReusableGlobalFunctions._(); + static ReusableGlobalFunctions get instance => + _instance ??= ReusableGlobalFunctions._(); ReusableGlobalFunctions._(); @@ -122,14 +123,16 @@ class ReusableGlobalFunctions { res += '$hours:'; } } - final int minutes = (duration?.inMinutes ?? 0) - (60 * (duration?.inHours ?? 0)); + final int minutes = + (duration?.inMinutes ?? 0) - (60 * (duration?.inHours ?? 0)); if (minutes >= 0 && minutes <= 9) { res += "0$minutes:"; } else { res += '$minutes:'; } //to get totalSeconds in 60 type second - final int seconds = (duration?.inSeconds ?? 0) - (60 * (duration?.inMinutes ?? 0)); + final int seconds = + (duration?.inSeconds ?? 0) - (60 * (duration?.inMinutes ?? 0)); if (seconds >= 0 && seconds <= 9) { res += "0$seconds"; } else { diff --git a/lib/src/core/models/chat_message_model/chat_message_model.dart b/lib/src/core/models/chat_message_model/chat_message_model.dart index 730d667..267f07f 100644 --- a/lib/src/core/models/chat_message_model/chat_message_model.dart +++ b/lib/src/core/models/chat_message_model/chat_message_model.dart @@ -29,5 +29,6 @@ class ChatMessageModel with _$ChatMessageModel { @JsonKey(includeToJson: false, includeFromJson: false) bool? messageSent, }) = _ChatMessageModel; - factory ChatMessageModel.fromJson(Map json) => _$ChatMessageModelFromJson(json); + factory ChatMessageModel.fromJson(Map json) => + _$ChatMessageModelFromJson(json); } diff --git a/lib/src/core/models/chat_participant_status_model/chat_participant_status_model.dart b/lib/src/core/models/chat_participant_status_model/chat_participant_status_model.dart index b9d76cc..bea4361 100644 --- a/lib/src/core/models/chat_participant_status_model/chat_participant_status_model.dart +++ b/lib/src/core/models/chat_participant_status_model/chat_participant_status_model.dart @@ -8,10 +8,8 @@ part 'chat_participant_status_model.g.dart'; @freezed class ChatParticipantStatusModel with _$ChatParticipantStatusModel { - const factory ChatParticipantStatusModel({ - int? id, - String? status, - }) = _ChatParticipantStatusModel; + const factory ChatParticipantStatusModel({int? id, String? status}) = + _ChatParticipantStatusModel; factory ChatParticipantStatusModel.fromJson(Map json) => _$ChatParticipantStatusModelFromJson(json); diff --git a/lib/src/core/models/chats_model/chat_model.dart b/lib/src/core/models/chats_model/chat_model.dart index 57f9c0a..bd71293 100644 --- a/lib/src/core/models/chats_model/chat_model.dart +++ b/lib/src/core/models/chats_model/chat_model.dart @@ -45,7 +45,8 @@ class ChatModel with _$ChatModel { bool? videoChatStreaming, }) = _ChatModel; - factory ChatModel.fromJson(Map json) => _$ChatModelFromJson(json); + factory ChatModel.fromJson(Map json) => + _$ChatModelFromJson(json); String getWrappedName() { if (name == null) return ''; diff --git a/lib/src/core/models/room_models/room_model.dart b/lib/src/core/models/room_models/room_model.dart index db4c861..dd51002 100644 --- a/lib/src/core/models/room_models/room_model.dart +++ b/lib/src/core/models/room_models/room_model.dart @@ -17,5 +17,6 @@ class RoomModel with _$RoomModel { final DateTime? updatedAt, }) = _RoomModel; - factory RoomModel.fromJson(Map json) => _$RoomModelFromJson(json); + factory RoomModel.fromJson(Map json) => + _$RoomModelFromJson(json); } diff --git a/lib/src/core/models/user_model/user_model.dart b/lib/src/core/models/user_model/user_model.dart index 254ba23..6a78672 100644 --- a/lib/src/core/models/user_model/user_model.dart +++ b/lib/src/core/models/user_model/user_model.dart @@ -19,14 +19,13 @@ class UserModel with _$UserModel { @JsonKey(name: "image_url") String? imageUrl, @JsonKey(name: "created_at") String? createdAt, @JsonKey(includeFromJson: false, includeToJson: false) - @Default( - false, - ) + @Default(false) bool? loadingForAddingToContacts, @JsonKey(name: "user_contact") UserModel? contact, }) = _UserModel; - factory UserModel.fromJson(Map json) => _$UserModelFromJson(json); + factory UserModel.fromJson(Map json) => + _$UserModelFromJson(json); String getFirstAndLastLetterOfName() { if ((name ?? '').isEmpty) return ""; diff --git a/lib/src/core/ui_kit/image_loader/image_loaded.dart b/lib/src/core/ui_kit/image_loader/image_loaded.dart index 2bab30e..d1ad3bb 100644 --- a/lib/src/core/ui_kit/image_loader/image_loaded.dart +++ b/lib/src/core/ui_kit/image_loader/image_loaded.dart @@ -70,14 +70,15 @@ class ImageLoaderWidget extends StatelessWidget { ); } }, - errorWidget: (context, url, error) => - errorWidget ?? - Image.asset( - errorImageUrl ?? Constants.userErrorImage, - height: height, - width: width, - fit: boxFit ?? BoxFit.scaleDown, - ), + errorWidget: + (context, url, error) => + errorWidget ?? + Image.asset( + errorImageUrl ?? Constants.userErrorImage, + height: height, + width: width, + fit: boxFit ?? BoxFit.scaleDown, + ), ); }, ); diff --git a/lib/src/core/ui_kit/search_widget/search_widget.dart b/lib/src/core/ui_kit/search_widget/search_widget.dart index 48852a5..48cdd2d 100644 --- a/lib/src/core/ui_kit/search_widget/search_widget.dart +++ b/lib/src/core/ui_kit/search_widget/search_widget.dart @@ -8,17 +8,14 @@ class SearchWidget extends StatefulWidget { final ValueChanged value; final VoidCallback onDispose; - const SearchWidget({ - super.key, - required this.value, - required this.onDispose, - }); + const SearchWidget({super.key, required this.value, required this.onDispose}); @override State createState() => _SearchWidgetState(); } -class _SearchWidgetState extends State with SingleTickerProviderStateMixin { +class _SearchWidgetState extends State + with SingleTickerProviderStateMixin { late AppThemeBloc _appThemeBloc; late TextEditingController _searchController; late AnimationController _animationController; diff --git a/lib/src/core/ui_kit/shimmer_loader.dart b/lib/src/core/ui_kit/shimmer_loader.dart index 988d496..db49fc4 100644 --- a/lib/src/core/ui_kit/shimmer_loader.dart +++ b/lib/src/core/ui_kit/shimmer_loader.dart @@ -1,31 +1,15 @@ import 'package:flutter/material.dart'; const _shimmerLightGradient = LinearGradient( - colors: [ - Color(0xFFEBEBF4), - Color(0xFFF4F4F4), - Color(0xFFEBEBF4), - ], - stops: [ - 0.1, - 0.3, - 0.4, - ], + colors: [Color(0xFFEBEBF4), Color(0xFFF4F4F4), Color(0xFFEBEBF4)], + stops: [0.1, 0.3, 0.4], begin: Alignment(-1.0, -0.3), end: Alignment(1.0, 0.3), tileMode: TileMode.clamp, ); const _shimmerDarkGradient = LinearGradient( - colors: [ - Color(0xFF2C2C3E), - Color(0xFF1E1E1E), - Color(0xFF2C2C3E), - ], - stops: [ - 0.1, - 0.3, - 0.4, - ], + colors: [Color(0xFF2C2C3E), Color(0xFF1E1E1E), Color(0xFF2C2C3E)], + stops: [0.1, 0.3, 0.4], begin: Alignment(-1.0, -0.3), end: Alignment(1.0, 0.3), tileMode: TileMode.clamp, diff --git a/lib/src/core/ui_kit/user_widgets/add_contact_user_widget.dart b/lib/src/core/ui_kit/user_widgets/add_contact_user_widget.dart index 6866c7b..9473aeb 100644 --- a/lib/src/core/ui_kit/user_widgets/add_contact_user_widget.dart +++ b/lib/src/core/ui_kit/user_widgets/add_contact_user_widget.dart @@ -53,7 +53,10 @@ class AddContactUserWidget extends StatelessWidget { ), Text( "Last seen 3000 y.a", - style: GoogleFonts.aBeeZee(fontSize: 12, color: Colors.grey), + style: GoogleFonts.aBeeZee( + fontSize: 12, + color: Colors.grey, + ), ), ], ), @@ -62,7 +65,9 @@ class AddContactUserWidget extends StatelessWidget { IconButton( onPressed: () { Navigator.pop(context); - AutoRouter.of(context).push(ChatRoute(chat: null, user: user)); + AutoRouter.of( + context, + ).push(ChatRoute(chat: null, user: user)); }, icon: const Icon(CupertinoIcons.chat_bubble_2_fill), ) @@ -74,7 +79,10 @@ class AddContactUserWidget extends StatelessWidget { child: const CircularProgressIndicator(strokeWidth: 2), ) else - IconButton(onPressed: addUser, icon: const Icon(Icons.person_add_alt)), + IconButton( + onPressed: addUser, + icon: const Icon(Icons.person_add_alt), + ), ], ), ), diff --git a/lib/src/core/utils/bloc_observer_manager/bloc_observer_manager.dart b/lib/src/core/utils/bloc_observer_manager/bloc_observer_manager.dart index b6404ce..ce74fd2 100644 --- a/lib/src/core/utils/bloc_observer_manager/bloc_observer_manager.dart +++ b/lib/src/core/utils/bloc_observer_manager/bloc_observer_manager.dart @@ -12,39 +12,38 @@ class BlocObserverManager extends BlocObserver { Bloc bloc, Transition transition, ) { - final logMessage = StringBuffer() - ..writeln('Bloc: ${bloc.runtimeType}') - ..writeln('Event: ${transition.event.runtimeType}') - ..writeln('Transition: ${transition.currentState.runtimeType} => ' - '${transition.nextState.runtimeType}') - ..write('New State: ${transition.nextState?.toString().limit(100)}'); + final logMessage = + StringBuffer() + ..writeln('Bloc: ${bloc.runtimeType}') + ..writeln('Event: ${transition.event.runtimeType}') + ..writeln( + 'Transition: ${transition.currentState.runtimeType} => ' + '${transition.nextState.runtimeType}', + ) + ..write('New State: ${transition.nextState?.toString().limit(100)}'); - logger.log( - Level.info, - logMessage.toString(), - ); + logger.log(Level.info, logMessage.toString()); super.onTransition(bloc, transition); } @override void onEvent(Bloc bloc, Object? event) { - final logMessage = StringBuffer() - ..writeln('Bloc: ${bloc.runtimeType}') - ..writeln('Event: ${event.runtimeType}') - ..write('Details: ${event?.toString().limit(200)}'); + final logMessage = + StringBuffer() + ..writeln('Bloc: ${bloc.runtimeType}') + ..writeln('Event: ${event.runtimeType}') + ..write('Details: ${event?.toString().limit(200)}'); - logger.log( - Level.info, - logMessage.toString(), - ); + logger.log(Level.info, logMessage.toString()); super.onEvent(bloc, event); } @override void onError(BlocBase bloc, Object error, StackTrace stackTrace) { - final logMessage = StringBuffer() - ..writeln('Error from bloc: ${bloc.runtimeType}') - ..writeln(error.toString()); + final logMessage = + StringBuffer() + ..writeln('Error from bloc: ${bloc.runtimeType}') + ..writeln(error.toString()); // you can also send bloc errors to server here @@ -62,23 +61,19 @@ class BlocObserverManager extends BlocObserver { @override void onClose(BlocBase bloc) { - final logMessage = StringBuffer()..writeln('Closed Bloc: ${bloc.runtimeType}'); + final logMessage = + StringBuffer()..writeln('Closed Bloc: ${bloc.runtimeType}'); - logger.log( - Level.info, - logMessage.toString(), - ); + logger.log(Level.info, logMessage.toString()); super.onClose(bloc); } @override void onCreate(BlocBase bloc) { - final logMessage = StringBuffer()..writeln('Opened Bloc: ${bloc.runtimeType}'); + final logMessage = + StringBuffer()..writeln('Opened Bloc: ${bloc.runtimeType}'); - logger.log( - Level.info, - logMessage.toString(), - ); + logger.log(Level.info, logMessage.toString()); super.onCreate(bloc); } } diff --git a/lib/src/core/utils/camera_helper_service/camera_helper_service.dart b/lib/src/core/utils/camera_helper_service/camera_helper_service.dart index 8242e75..2c3430b 100644 --- a/lib/src/core/utils/camera_helper_service/camera_helper_service.dart +++ b/lib/src/core/utils/camera_helper_service/camera_helper_service.dart @@ -10,101 +10,102 @@ import 'package:collection/collection.dart'; class CameraHelperService { late List _cameras; - UnmodifiableListView get cameras => UnmodifiableListView(_cameras); + UnmodifiableListView get cameras => + UnmodifiableListView(_cameras); // init this one in main func Future initCameras() async { _cameras = await availableCameras(); } -// Uint8List convertImageToJpeg(CameraImage image) { -// final int width = image.width; -// final int height = image.height; -// final int uvRowStride = image.planes[1].bytesPerRow; -// final int uvPixelStride = image.planes[1].bytesPerPixel ?? 1; -// -// final img.Image imgImage = img.Image(width: width, height: height); -// -// for (int y = 0; y < height; y++) { -// for (int x = 0; x < width; x++) { -// final int uvIndex = (y ~/ 2) * uvRowStride + (x ~/ 2) * uvPixelStride; -// final int index = y * width + x; -// -// final int yp = image.planes[0].bytes[index]; -// final int up = image.planes[1].bytes[uvIndex]; -// final int vp = image.planes[2].bytes[uvIndex]; -// -// // Compute RGB values -// int r = (yp + 1.402 * (vp - 128)).round(); -// int g = (yp - 0.344136 * (up - 128) - 0.714136 * (vp - 128)).round(); -// int b = (yp + 1.772 * (up - 128)).round(); -// -// imgImage.setPixel( -// x, -// y, -// img.convertColor(img.ColorRgb8(r, g, b)), -// ); -// } -// } -// return Uint8List.fromList(img.encodeJpg(imgImage, quality: 80)); -// } -// -// Uint8List? convertYUV420toImage( -// CameraImage image, { -// bool frontCamera = false, -// }) { -// try { -// final int width = image.width; -// final int height = image.height; -// -// final int yRowStride = image.planes[0].bytesPerRow; -// final int uvRowStride = image.planes[1].bytesPerRow; -// final int uvPixelStride = image.planes[1].bytesPerPixel!; -// -// img.Image rgbImage = img.Image(width: width, height: height); -// -// for (int y = 0; y < height; y++) { -// for (int x = 0; x < width; x++) { -// final int yIndex = y * yRowStride + x; -// final int uvIndex = (y >> 1) * uvRowStride + (x >> 1) * uvPixelStride; -// -// final int yValue = image.planes[0].bytes[yIndex]; -// final int uValue = image.planes[1].bytes[uvIndex]; -// final int vValue = image.planes[2].bytes[uvIndex]; -// -// final int r = (yValue + 1.402 * (vValue - 128)).clamp(0, 255).toInt(); -// final int g = (yValue - 0.344136 * (uValue - 128) - 0.714136 * (vValue - 128)) -// .clamp(0, 255) -// .toInt(); -// final int b = (yValue + 1.772 * (uValue - 128)).clamp(0, 255).toInt(); -// -// rgbImage.setPixel(x, y, img.ColorRgb8(r, g, b)); -// } -// } -// -// // if it's from camera rotate image -90 degrees -// // to fix the front and back camera issue -// if (frontCamera) { -// rgbImage = img.copyRotate(rgbImage, angle: -90); -// } else { -// // if it's not rotate 90 degrees -// rgbImage = img.copyRotate(rgbImage, angle: 90); -// } -// -// return Uint8List.fromList(img.encodeJpg(rgbImage)); -// } catch (e) { -// debugPrint(">>>>>>>>>>>> ERROR:$e"); -// } -// return null; -// } -// -// Uint8List makeImageFromCameraStream(CameraImage image) { -// img.Image createImage = img.Image.fromBytes( -// width: image.width, -// height: image.height, -// bytes: image.planes[0].bytes.buffer, -// ); -// Uint8List jpg = Uint8List.fromList(img.encodeJpg(createImage)); -// return jpg; -// } + // Uint8List convertImageToJpeg(CameraImage image) { + // final int width = image.width; + // final int height = image.height; + // final int uvRowStride = image.planes[1].bytesPerRow; + // final int uvPixelStride = image.planes[1].bytesPerPixel ?? 1; + // + // final img.Image imgImage = img.Image(width: width, height: height); + // + // for (int y = 0; y < height; y++) { + // for (int x = 0; x < width; x++) { + // final int uvIndex = (y ~/ 2) * uvRowStride + (x ~/ 2) * uvPixelStride; + // final int index = y * width + x; + // + // final int yp = image.planes[0].bytes[index]; + // final int up = image.planes[1].bytes[uvIndex]; + // final int vp = image.planes[2].bytes[uvIndex]; + // + // // Compute RGB values + // int r = (yp + 1.402 * (vp - 128)).round(); + // int g = (yp - 0.344136 * (up - 128) - 0.714136 * (vp - 128)).round(); + // int b = (yp + 1.772 * (up - 128)).round(); + // + // imgImage.setPixel( + // x, + // y, + // img.convertColor(img.ColorRgb8(r, g, b)), + // ); + // } + // } + // return Uint8List.fromList(img.encodeJpg(imgImage, quality: 80)); + // } + // + // Uint8List? convertYUV420toImage( + // CameraImage image, { + // bool frontCamera = false, + // }) { + // try { + // final int width = image.width; + // final int height = image.height; + // + // final int yRowStride = image.planes[0].bytesPerRow; + // final int uvRowStride = image.planes[1].bytesPerRow; + // final int uvPixelStride = image.planes[1].bytesPerPixel!; + // + // img.Image rgbImage = img.Image(width: width, height: height); + // + // for (int y = 0; y < height; y++) { + // for (int x = 0; x < width; x++) { + // final int yIndex = y * yRowStride + x; + // final int uvIndex = (y >> 1) * uvRowStride + (x >> 1) * uvPixelStride; + // + // final int yValue = image.planes[0].bytes[yIndex]; + // final int uValue = image.planes[1].bytes[uvIndex]; + // final int vValue = image.planes[2].bytes[uvIndex]; + // + // final int r = (yValue + 1.402 * (vValue - 128)).clamp(0, 255).toInt(); + // final int g = (yValue - 0.344136 * (uValue - 128) - 0.714136 * (vValue - 128)) + // .clamp(0, 255) + // .toInt(); + // final int b = (yValue + 1.772 * (uValue - 128)).clamp(0, 255).toInt(); + // + // rgbImage.setPixel(x, y, img.ColorRgb8(r, g, b)); + // } + // } + // + // // if it's from camera rotate image -90 degrees + // // to fix the front and back camera issue + // if (frontCamera) { + // rgbImage = img.copyRotate(rgbImage, angle: -90); + // } else { + // // if it's not rotate 90 degrees + // rgbImage = img.copyRotate(rgbImage, angle: 90); + // } + // + // return Uint8List.fromList(img.encodeJpg(rgbImage)); + // } catch (e) { + // debugPrint(">>>>>>>>>>>> ERROR:$e"); + // } + // return null; + // } + // + // Uint8List makeImageFromCameraStream(CameraImage image) { + // img.Image createImage = img.Image.fromBytes( + // width: image.width, + // height: image.height, + // bytes: image.planes[0].bytes.buffer, + // ); + // Uint8List jpg = Uint8List.fromList(img.encodeJpg(createImage)); + // return jpg; + // } } diff --git a/lib/src/core/utils/debug_image_creator_in_apps_folder/debug_image_creator_in_apps_folder.dart b/lib/src/core/utils/debug_image_creator_in_apps_folder/debug_image_creator_in_apps_folder.dart index 47ee295..3e75081 100644 --- a/lib/src/core/utils/debug_image_creator_in_apps_folder/debug_image_creator_in_apps_folder.dart +++ b/lib/src/core/utils/debug_image_creator_in_apps_folder/debug_image_creator_in_apps_folder.dart @@ -11,8 +11,8 @@ class DebugImageCreatorInAppsFolder with FolderCreator { DebugImageCreatorInAppsFolder({ required final SharedPreferHelper sharedPreferHelper, Dio? dio, - }) : _sharedPreferHelper = sharedPreferHelper, - _dio = dio ?? Dio(); + }) : _sharedPreferHelper = sharedPreferHelper, + _dio = dio ?? Dio(); final SharedPreferHelper _sharedPreferHelper; @@ -44,7 +44,8 @@ class DebugImageCreatorInAppsFolder with FolderCreator { ); if (response.statusCode == HttpStatus.ok) { - final pathImageForCreation = "${dir?.path}/$each/${DateTime.now()}.jpg"; + final pathImageForCreation = + "${dir?.path}/$each/${DateTime.now()}.jpg"; final File file = File(pathImageForCreation); if ((response.data ?? []).isNotEmpty) { file.writeAsBytesSync(response.data!); diff --git a/lib/src/core/utils/dio/src/exceptions/rest_client_exception.dart b/lib/src/core/utils/dio/src/exceptions/rest_client_exception.dart index b9834ac..310b37c 100644 --- a/lib/src/core/utils/dio/src/exceptions/rest_client_exception.dart +++ b/lib/src/core/utils/dio/src/exceptions/rest_client_exception.dart @@ -27,7 +27,8 @@ final class StructuredBackendException extends RestClientException { final Map error; @override - String toString() => 'StructuredBackendException(' + String toString() => + 'StructuredBackendException(' 'message:, $message' 'cause: $cause, ' 'statusCode: $statusCode, ' @@ -42,7 +43,8 @@ final class ClientException extends RestClientException { }); @override - String toString() => 'ClientException(' + String toString() => + 'ClientException(' 'message: $message, ' 'statusCode: $statusCode, ' 'cause: $cause' @@ -54,13 +56,14 @@ final class UnauthenticatedException extends RestClientException { required DioException exception, super.statusCode, super.cause, - }) : _dioException = exception, - super(message: "User is Unauthenticated"); + }) : _dioException = exception, + super(message: "User is Unauthenticated"); final DioException _dioException; @override - String toString() => 'StructuredBackendException(' + String toString() => + 'StructuredBackendException(' 'message: $message | SERVER_ERROR: ${_dioException.response?.data}' ' | ERROR: ${_dioException.error}, ' 'cause: $cause, ' diff --git a/lib/src/core/utils/dio/src/rest_client_base.dart b/lib/src/core/utils/dio/src/rest_client_base.dart index 3fbae57..dba43ef 100644 --- a/lib/src/core/utils/dio/src/rest_client_base.dart +++ b/lib/src/core/utils/dio/src/rest_client_base.dart @@ -31,14 +31,13 @@ abstract base class RestClientBase implements RestClient { Map? headers, Map? queryParams, bool log = false, - }) => - send( - path: path, - method: DioMethod.get, - headers: headers, - queryParams: queryParams, - log: log, - ); + }) => send( + path: path, + method: DioMethod.get, + headers: headers, + queryParams: queryParams, + log: log, + ); @override Future?> post( @@ -48,16 +47,15 @@ abstract base class RestClientBase implements RestClient { Map? headers, Map? queryParams, bool log = false, - }) => - send( - path: path, - method: DioMethod.post, - data: data, - formData: formData, - headers: headers, - queryParams: queryParams, - log: log, - ); + }) => send( + path: path, + method: DioMethod.post, + data: data, + formData: formData, + headers: headers, + queryParams: queryParams, + log: log, + ); @override Future?> put( @@ -67,16 +65,15 @@ abstract base class RestClientBase implements RestClient { Map? headers, Map? queryParams, bool log = false, - }) => - send( - path: path, - method: DioMethod.put, - data: data, - formData: formData, - headers: headers, - queryParams: queryParams, - log: log, - ); + }) => send( + path: path, + method: DioMethod.put, + data: data, + formData: formData, + headers: headers, + queryParams: queryParams, + log: log, + ); @override Future?> delete( @@ -86,22 +83,19 @@ abstract base class RestClientBase implements RestClient { Map? headers, Map? queryParams, bool log = false, - }) => - send( - path: path, - method: DioMethod.delete, - data: data, - formData: formData, - headers: headers, - queryParams: queryParams, - log: log, - ); - - Uri buildUri({ - required String path, - Map? queryParams, - }) { - final String finalPath = Uri.parse("${_baseURL.path}/api$path").normalizePath().toString(); + }) => send( + path: path, + method: DioMethod.delete, + data: data, + formData: formData, + headers: headers, + queryParams: queryParams, + log: log, + ); + + Uri buildUri({required String path, Map? queryParams}) { + final String finalPath = + Uri.parse("${_baseURL.path}/api$path").normalizePath().toString(); final Map params = Map.of(_baseURL.queryParameters); @@ -122,8 +116,12 @@ abstract base class RestClientBase implements RestClient { }) async { try { final decodedResponse = switch (data) { - StringResponseBody(body: final String body) => await _decodeString(body), - BytesResponseBody(body: final List bytes) => await _decodeBytes(bytes), + StringResponseBody(body: final String body) => await _decodeString( + body, + ), + BytesResponseBody(body: final List bytes) => await _decodeBytes( + bytes, + ), MapResponseBody(body: final Map map) => map, _ => {}, }; diff --git a/lib/src/core/utils/dio/src/rest_client_dio.dart b/lib/src/core/utils/dio/src/rest_client_dio.dart index 1fa937a..8235043 100644 --- a/lib/src/core/utils/dio/src/rest_client_dio.dart +++ b/lib/src/core/utils/dio/src/rest_client_dio.dart @@ -13,9 +13,9 @@ final class RestClientDio extends RestClientBase { required final SharedPreferHelper sharedPrefer, required final Logger logger, Dio? dio, - }) : _dio = dio ?? Dio(), - _sharedPreferHelper = sharedPrefer, - _logger = logger; + }) : _dio = dio ?? Dio(), + _sharedPreferHelper = sharedPrefer, + _logger = logger; final Dio _dio; final SharedPreferHelper _sharedPreferHelper; @@ -68,16 +68,11 @@ final class RestClientDio extends RestClientBase { } final serverError = await decodeResponse( - BytesResponseBody( - body: error.response?.data, - ), + BytesResponseBody(body: error.response?.data), ); Error.throwWithStackTrace( - DioExceptionHandler( - dioException: error, - serverError: "$serverError", - ), + DioExceptionHandler(dioException: error, serverError: "$serverError"), stackTrace, ); // @@ -88,7 +83,8 @@ final class RestClientDio extends RestClientBase { return { 'Content-Type': 'application/json; charset=UTF-8', 'Accept': 'application/json', - 'Authorization': 'Bearer ${_sharedPreferHelper.getStringByKey(key: 'token')}', + 'Authorization': + 'Bearer ${_sharedPreferHelper.getStringByKey(key: 'token')}', }; } } diff --git a/lib/src/core/utils/error_reporter/firebase_error_reporter.dart b/lib/src/core/utils/error_reporter/firebase_error_reporter.dart index 3ee3c60..bcde6a3 100644 --- a/lib/src/core/utils/error_reporter/firebase_error_reporter.dart +++ b/lib/src/core/utils/error_reporter/firebase_error_reporter.dart @@ -14,9 +14,6 @@ final class FirebaseErrorReporter implements IErrorReporter { final FirebaseCrashlytics firebaseCrashlytics; @override - Future report() async => await firebaseCrashlytics.recordError( - exception, - stackTrace, - fatal: true, - ); + Future report() async => + await firebaseCrashlytics.recordError(exception, stackTrace, fatal: true); } diff --git a/lib/src/core/utils/error_reporter/laravel_error_reporter.dart b/lib/src/core/utils/error_reporter/laravel_error_reporter.dart index 76b0c4c..5f9fa38 100644 --- a/lib/src/core/utils/error_reporter/laravel_error_reporter.dart +++ b/lib/src/core/utils/error_reporter/laravel_error_reporter.dart @@ -2,10 +2,7 @@ import 'i_error_reporter.dart'; final class LaravelErrorReporter implements IErrorReporter { // - LaravelErrorReporter({ - required this.exception, - required this.stackTrace, - }); + LaravelErrorReporter({required this.exception, required this.stackTrace}); final Object exception; final StackTrace stackTrace; diff --git a/lib/src/core/utils/extensions/extensions.dart b/lib/src/core/utils/extensions/extensions.dart index e4366ef..13d8478 100644 --- a/lib/src/core/utils/extensions/extensions.dart +++ b/lib/src/core/utils/extensions/extensions.dart @@ -21,7 +21,8 @@ extension ListExtensions on List { } extension StringEx on String { - String limit(int length) => length < this.length ? substring(0, length) : this; + String limit(int length) => + length < this.length ? substring(0, length) : this; } extension NestedMapExt on Map { diff --git a/lib/src/core/utils/global_context/global_context.dart b/lib/src/core/utils/global_context/global_context.dart index 481a863..79656c9 100644 --- a/lib/src/core/utils/global_context/global_context.dart +++ b/lib/src/core/utils/global_context/global_context.dart @@ -7,5 +7,6 @@ class GlobalContext { GlobalContext._(); - final GlobalKey globalContext = GlobalKey(); + final GlobalKey globalContext = + GlobalKey(); } diff --git a/lib/src/core/utils/image_comporessor/image_compressor.dart b/lib/src/core/utils/image_comporessor/image_compressor.dart index 93591ed..ff2cb23 100644 --- a/lib/src/core/utils/image_comporessor/image_compressor.dart +++ b/lib/src/core/utils/image_comporessor/image_compressor.dart @@ -14,12 +14,13 @@ abstract final class ImageCompressor { final String imagePath = '$directoryPath/${basenameWithoutExtension(file.path)}_temp.${format.name}'; - final XFile? compressedImage = await FlutterImageCompress.compressAndGetFile( - file.path, - imagePath, - quality: quality, - format: format, - ); + final XFile? compressedImage = + await FlutterImageCompress.compressAndGetFile( + file.path, + imagePath, + quality: quality, + format: format, + ); if (compressedImage == null) { throw ("Failed to compress the image"); diff --git a/lib/src/core/utils/list_pagination_checker/list_pagination_checker.dart b/lib/src/core/utils/list_pagination_checker/list_pagination_checker.dart index 0337141..8d0fb2d 100644 --- a/lib/src/core/utils/list_pagination_checker/list_pagination_checker.dart +++ b/lib/src/core/utils/list_pagination_checker/list_pagination_checker.dart @@ -3,7 +3,8 @@ import 'package:yahay/src/core/global_usages/constants/constants.dart'; class ListPaginationChecker { static ListPaginationChecker? _instance; - static ListPaginationChecker get instance => _instance ??= ListPaginationChecker._(); + static ListPaginationChecker get instance => + _instance ??= ListPaginationChecker._(); ListPaginationChecker._(); @@ -22,7 +23,10 @@ class ListPaginationChecker { } // this func will check whether there are more values in list of pag (returns boolean) - bool checkIsListHasMorePageBool({required List list, int? limitInPage}) { + bool checkIsListHasMorePageBool({ + required List list, + int? limitInPage, + }) { if (list.length < (limitInPage ?? Constants.perPage)) { return false; } else { @@ -40,13 +44,15 @@ class ListPaginationChecker { //you should not use any check variable, this function parameter "showingCircularProgress" will know automatically //and it checks whether list still has items or not if (!showingCircularProgress) { - final bool hasMore = currentList.length >= wholeList.length ? false : true; + final bool hasMore = + currentList.length >= wholeList.length ? false : true; if (!hasMore) return []; } //check in which list index we are at - final int check = (currentList.length + perPage) > wholeList.length - ? wholeList.length - : (currentList.length + perPage); + final int check = + (currentList.length + perPage) > wholeList.length + ? wholeList.length + : (currentList.length + perPage); final List pagList = []; for (int i = currentList.length; i < check; i++) { pagList.add(wholeList[i]); diff --git a/lib/src/core/utils/shared_preferences/shared_preferences.dart b/lib/src/core/utils/shared_preferences/shared_preferences.dart index e79b85e..aed3d47 100644 --- a/lib/src/core/utils/shared_preferences/shared_preferences.dart +++ b/lib/src/core/utils/shared_preferences/shared_preferences.dart @@ -7,7 +7,10 @@ class SharedPreferHelper { _sharedPrefer = await SharedPreferences.getInstance(); } - Future setStringByKey({required String key, required String value}) async { + Future setStringByKey({ + required String key, + required String value, + }) async { await _sharedPrefer.setString(key, value); } @@ -15,7 +18,10 @@ class SharedPreferHelper { await _sharedPrefer.setInt(key, value); } - Future setDoubleByKey({required String key, required double value}) async { + Future setDoubleByKey({ + required String key, + required double value, + }) async { await _sharedPrefer.setDouble(key, value); } diff --git a/lib/src/features/add_contact_feature/bloc/add_contact_bloc.dart b/lib/src/features/add_contact_feature/bloc/add_contact_bloc.dart index 121ced0..8cfb7ea 100644 --- a/lib/src/features/add_contact_feature/bloc/add_contact_bloc.dart +++ b/lib/src/features/add_contact_feature/bloc/add_contact_bloc.dart @@ -10,7 +10,8 @@ part 'add_contact_bloc.freezed.dart'; @immutable @freezed sealed class AddContactsEvents with _$AddContactsEvents { - const factory AddContactsEvents.searchContact(final String value) = _SearchContactEvent; + const factory AddContactsEvents.searchContact(final String value) = + _SearchContactEvent; const factory AddContactsEvents.addContactEvent(final UserModel? user) = _AddContactEventOnAddContactsEvent; @@ -21,8 +22,9 @@ sealed class AddContactsEvents with _$AddContactsEvents { @immutable @freezed sealed class AddContactsStates with _$AddContactsStates { - const factory AddContactsStates.initial(final AddContactStateModel addContactStateModel) = - InitialAddConstactsState; + const factory AddContactsStates.initial( + final AddContactStateModel addContactStateModel, + ) = InitialAddConstactsState; const factory AddContactsStates.loadingAddContactsState( final AddContactStateModel addContactStateModel, @@ -43,8 +45,8 @@ class AddContactBloc extends Bloc { AddContactBloc({ required AddContactsStates initialState, required AddContactRepo iAddContactRepo, - }) : _iAddContactRepo = iAddContactRepo, - super(initialState) { + }) : _iAddContactRepo = iAddContactRepo, + super(initialState) { on( (event, emit) => event.map( searchContact: (event) => _searchContactEvent(event, emit), @@ -78,7 +80,9 @@ class AddContactBloc extends Bloc { ); // - final List currentUsers = List.from(currentStateModel.users); + final List currentUsers = List.from( + currentStateModel.users, + ); currentUsers.addAll(data); @@ -105,9 +109,13 @@ class AddContactBloc extends Bloc { loadingForAddingToContacts: true, ); - final List tempUsersList = List.from(currentStateModel.users); + final List tempUsersList = List.from( + currentStateModel.users, + ); - final foundIndex = tempUsersList.indexWhere((el) => el.id == event.user?.id); + final foundIndex = tempUsersList.indexWhere( + (el) => el.id == event.user?.id, + ); if (foundIndex != -1) { tempUsersList[foundIndex] = event.user!; @@ -117,9 +125,7 @@ class AddContactBloc extends Bloc { debugPrint("reponse value: $responseValue"); - changingModel = changingModel?.copyWith( - loadingForAddingToContacts: false, - ); + changingModel = changingModel?.copyWith(loadingForAddingToContacts: false); if (foundIndex != -1) { tempUsersList[foundIndex] = event.user!; diff --git a/lib/src/features/add_contact_feature/bloc/state_model/add_contact_state_model.dart b/lib/src/features/add_contact_feature/bloc/state_model/add_contact_state_model.dart index 6b7c41e..1fce116 100644 --- a/lib/src/features/add_contact_feature/bloc/state_model/add_contact_state_model.dart +++ b/lib/src/features/add_contact_feature/bloc/state_model/add_contact_state_model.dart @@ -25,7 +25,11 @@ final class AddContactStateModel { timerForSearch == other.timerForSearch); @override - int get hashCode => users.hashCode ^ page.hashCode ^ hasMore.hashCode ^ timerForSearch.hashCode; + int get hashCode => + users.hashCode ^ + page.hashCode ^ + hasMore.hashCode ^ + timerForSearch.hashCode; @override String toString() { @@ -34,11 +38,8 @@ final class AddContactStateModel { } /// Factory constructor for the initial state - factory AddContactStateModel.idle() => const AddContactStateModel( - users: [], - page: 1, - hasMore: true, - ); + factory AddContactStateModel.idle() => + const AddContactStateModel(users: [], page: 1, hasMore: true); /// Copy constructor with optional overrides AddContactStateModel copyWith({ diff --git a/lib/src/features/add_contact_feature/data/add_contact_repo.dart b/lib/src/features/add_contact_feature/data/add_contact_repo.dart index 2b89d68..42a8293 100644 --- a/lib/src/features/add_contact_feature/data/add_contact_repo.dart +++ b/lib/src/features/add_contact_feature/data/add_contact_repo.dart @@ -18,5 +18,6 @@ class AddContactRepoImpl extends AddContactRepo { _addContactSource.searchContact(value, page); @override - Future addContact(UserModel? user) => _addContactSource.addContact(user); + Future addContact(UserModel? user) => + _addContactSource.addContact(user); } diff --git a/lib/src/features/add_contact_feature/data/add_contact_source.dart b/lib/src/features/add_contact_feature/data/add_contact_source.dart index 797633c..dbc3d66 100644 --- a/lib/src/features/add_contact_feature/data/add_contact_source.dart +++ b/lib/src/features/add_contact_feature/data/add_contact_source.dart @@ -15,8 +15,8 @@ class AddContactSourceImpl implements AddContactSource { AddContactSourceImpl({ required final Logger logger, required final RestClientBase restClientBase, - }) : _logger = logger, - _restClientBase = restClientBase; + }) : _logger = logger, + _restClientBase = restClientBase; final Logger _logger; @@ -31,10 +31,7 @@ class AddContactSourceImpl implements AddContactSource { try { final response = await _restClientBase.get( _searchContactUrl, - queryParams: { - "value": value.trim(), - "page": page.toString(), - }, + queryParams: {"value": value.trim(), "page": page.toString()}, ); if (response == null) return []; @@ -58,9 +55,7 @@ class AddContactSourceImpl implements AddContactSource { @override Future addContact(UserModel? user) async { try { - final body = { - "contact_id": user?.id, - }; + final body = {"contact_id": user?.id}; final response = await _restClientBase.put(_addContactUrl, data: body); diff --git a/lib/src/features/add_contact_feature/view/pages/add_contacts_page.dart b/lib/src/features/add_contact_feature/view/pages/add_contacts_page.dart index d965071..3861963 100644 --- a/lib/src/features/add_contact_feature/view/pages/add_contacts_page.dart +++ b/lib/src/features/add_contact_feature/view/pages/add_contacts_page.dart @@ -22,14 +22,18 @@ class _AddContactsPageState extends State { void initState() { super.initState(); _controller = DraggableScrollableController(); - _addContactBloc = DependenciesScope.of(context, listen: false).addContactBloc; + _addContactBloc = + DependenciesScope.of(context, listen: false).addContactBloc; _addContactBloc.add(const AddContactsEvents.clearDataEvent()); WidgetsBinding.instance.addPostFrameCallback((timeStamp) { const maxHeight = 0.96; final screenHeight = MediaQuery.of(context).size.height * maxHeight; final screenHeightWithAppBar = screenHeight - kToolbarHeight; initialChildSize = - ((screenHeightWithAppBar * maxHeight) / screenHeight).roundIt()?.toDouble() ?? maxHeight; + ((screenHeightWithAppBar * maxHeight) / screenHeight) + .roundIt() + ?.toDouble() ?? + maxHeight; setState(() {}); }); } @@ -59,12 +63,22 @@ class _AddContactsPageState extends State { child: ClipRRect( borderRadius: BorderRadius.circular(4), child: TextField( - onChanged: (v) => _addContactBloc.add(AddContactsEvents.searchContact(v)), - onSubmitted: (v) => _addContactBloc.add(AddContactsEvents.searchContact(v)), - onTapOutside: (v) => FocusManager.instance.primaryFocus?.unfocus(), + onChanged: + (v) => _addContactBloc.add( + AddContactsEvents.searchContact(v), + ), + onSubmitted: + (v) => _addContactBloc.add( + AddContactsEvents.searchContact(v), + ), + onTapOutside: + (v) => FocusManager.instance.primaryFocus?.unfocus(), style: GoogleFonts.aBeeZee(fontSize: 14), decoration: const InputDecoration( - contentPadding: EdgeInsets.symmetric(vertical: 15.0, horizontal: 5), + contentPadding: EdgeInsets.symmetric( + vertical: 15.0, + horizontal: 5, + ), border: InputBorder.none, focusedBorder: InputBorder.none, enabledBorder: InputBorder.none, @@ -77,7 +91,9 @@ class _AddContactsPageState extends State { ), TextButton( onPressed: () { - _addContactBloc.add(const AddContactsEvents.clearDataEvent()); + _addContactBloc.add( + const AddContactsEvents.clearDataEvent(), + ); Navigator.pop(context); }, child: const Text("Cancel"), @@ -97,7 +113,8 @@ class _AddContactsPageState extends State { case AddContacts$SuccessfulState(): final currentStateModel = states.addContactStateModel; return ListView.separated( - separatorBuilder: (context, index) => const SizedBox(height: 10), + separatorBuilder: + (context, index) => const SizedBox(height: 10), shrinkWrap: true, physics: const NeverScrollableScrollPhysics(), itemCount: currentStateModel.users.length, @@ -105,8 +122,10 @@ class _AddContactsPageState extends State { final user = currentStateModel.users[index]; return AddContactUserWidget( user: user, - addUser: () => - _addContactBloc.add(AddContactsEvents.addContactEvent(user)), + addUser: + () => _addContactBloc.add( + AddContactsEvents.addContactEvent(user), + ), ); }, ); diff --git a/lib/src/features/app_theme/bloc/app_theme_bloc.dart b/lib/src/features/app_theme/bloc/app_theme_bloc.dart index f8aadd9..cf802e3 100644 --- a/lib/src/features/app_theme/bloc/app_theme_bloc.dart +++ b/lib/src/features/app_theme/bloc/app_theme_bloc.dart @@ -30,13 +30,17 @@ class AppThemeBloc { _currentState = AppColorsScheme.light; - final themeData = eventBehavior.map((appThemeDataEvent) { - final ThemeData theme = _appThemeChangerEvent(appThemeDataEvent as AppThemeChangerEvent); - return theme; - }).startWith(_currentState); - - final BehaviorSubject themeDataStream = BehaviorSubject() - ..addStream(themeData); + final themeData = eventBehavior + .map((appThemeDataEvent) { + final ThemeData theme = _appThemeChangerEvent( + appThemeDataEvent as AppThemeChangerEvent, + ); + return theme; + }) + .startWith(_currentState); + + final BehaviorSubject themeDataStream = + BehaviorSubject()..addStream(themeData); return AppThemeBloc._(events: eventBehavior.sink, theme: themeDataStream); } diff --git a/lib/src/features/app_theme/models/app_colors_scheme.dart b/lib/src/features/app_theme/models/app_colors_scheme.dart index 2abd790..ad70f2f 100644 --- a/lib/src/features/app_theme/models/app_colors_scheme.dart +++ b/lib/src/features/app_theme/models/app_colors_scheme.dart @@ -3,9 +3,9 @@ import 'package:flutter/material.dart'; abstract class AppColorsScheme { // Theme config for FlexColorScheme version 7.3.x. Make sure you use -// same or higher package version, but still same major version. If you -// use a lower package version, some properties may not be supported. -// In that case remove them after copying this theme to your app. + // same or higher package version, but still same major version. If you + // use a lower package version, some properties may not be supported. + // In that case remove them after copying this theme to your app. static final ThemeData light = FlexThemeData.light( colors: const FlexSchemeColor( primary: Color(0xff004881), diff --git a/lib/src/features/authorization/bloc/auth_bloc.dart b/lib/src/features/authorization/bloc/auth_bloc.dart index f3e5dc9..dba8efa 100644 --- a/lib/src/features/authorization/bloc/auth_bloc.dart +++ b/lib/src/features/authorization/bloc/auth_bloc.dart @@ -41,7 +41,8 @@ sealed class AuthEvents with _$AuthEvents { required void Function(String message) onMessage, }) = _CheckAuthEventOnAuthEvents; - const factory AuthEvents.changePasswordVisibility() = _ChangePasswordVisibilityEvent; + const factory AuthEvents.changePasswordVisibility() = + _ChangePasswordVisibilityEvent; const factory AuthEvents.logOutEvent() = _LogOutEvent; } @@ -49,17 +50,20 @@ sealed class AuthEvents with _$AuthEvents { @immutable @freezed sealed class AuthStates with _$AuthStates { - const factory AuthStates.initial(final AuthStateModel authStateModel) = Auth$InitialState; + const factory AuthStates.initial(final AuthStateModel authStateModel) = + Auth$InitialState; const factory AuthStates.inProgress(final AuthStateModel authStateModel) = AuthStates$InProgressState; - const factory AuthStates.authorized(final AuthStateModel authStateModel) = Auth$AuthorizedState; + const factory AuthStates.authorized(final AuthStateModel authStateModel) = + Auth$AuthorizedState; const factory AuthStates.unAuthorized(final AuthStateModel authStateModel) = Auth$UnAuthorizedState; - const factory AuthStates.error(final AuthStateModel authStateModel) = ErrorStateOnAuthStates; + const factory AuthStates.error(final AuthStateModel authStateModel) = + ErrorStateOnAuthStates; } class AuthBloc extends Bloc { @@ -70,9 +74,9 @@ class AuthBloc extends Bloc { required AuthorizationRepo authorizationRepo, required OtherAuthorizationRepo otherAuthorizationRepo, required AuthStates initialState, - }) : _iAuthorizationRepo = authorizationRepo, - _iOtherAuthorizationRepo = otherAuthorizationRepo, - super(initialState) { + }) : _iAuthorizationRepo = authorizationRepo, + _iOtherAuthorizationRepo = otherAuthorizationRepo, + super(initialState) { // // on( @@ -82,7 +86,8 @@ class AuthBloc extends Bloc { registerEvent: (event) => _registerEvent(event, emit), loginEvent: (event) => _loginEvent(event, emit), checkAuthEvent: (event) => _checkAuthEvent(event, emit), - changePasswordVisibility: (event) => _changePasswordVisibility(event, emit), + changePasswordVisibility: + (event) => _changePasswordVisibility(event, emit), logOutEvent: (event) => _logOutEvent(event, emit), ), ); @@ -102,9 +107,7 @@ class AuthBloc extends Bloc { return; } - currentStateModel = currentStateModel.copyWith( - user: user, - ); + currentStateModel = currentStateModel.copyWith(user: user); // await event.initDioOptions(); @@ -130,9 +133,7 @@ class AuthBloc extends Bloc { return; } - currentStateModel = currentStateModel.copyWith( - user: user, - ); + currentStateModel = currentStateModel.copyWith(user: user); // await event.initDioOptions(); @@ -151,9 +152,7 @@ class AuthBloc extends Bloc { ) async { var currentStateModel = state.authStateModel.copyWith(); try { - currentStateModel = currentStateModel.copyWith( - loadingRegister: true, - ); + currentStateModel = currentStateModel.copyWith(loadingRegister: true); _emitter(currentStateModel, emit); @@ -163,18 +162,14 @@ class AuthBloc extends Bloc { userName: event.userName.trim(), ); - currentStateModel = currentStateModel.copyWith( - loadingRegister: false, - ); + currentStateModel = currentStateModel.copyWith(loadingRegister: false); if (user == null) { emit(AuthStates.unAuthorized(currentStateModel)); return; } - currentStateModel = currentStateModel.copyWith( - user: user, - ); + currentStateModel = currentStateModel.copyWith(user: user); // await event.initDioOptions(); emit(AuthStates.authorized(currentStateModel)); @@ -202,18 +197,14 @@ class AuthBloc extends Bloc { password: event.password.trim(), ); - currentStateModel = currentStateModel.copyWith( - loadingLogin: false, - ); + currentStateModel = currentStateModel.copyWith(loadingLogin: false); if (user == null) { emit(AuthStates.unAuthorized(currentStateModel)); return; } - currentStateModel = currentStateModel.copyWith( - user: user, - ); + currentStateModel = currentStateModel.copyWith(user: user); // await event.initDioOptions(); @@ -241,9 +232,7 @@ class AuthBloc extends Bloc { return; } - currentStateModel = currentStateModel.copyWith( - user: user, - ); + currentStateModel = currentStateModel.copyWith(user: user); emit(AuthStates.authorized(currentStateModel)); @@ -273,10 +262,7 @@ class AuthBloc extends Bloc { _emitter(currentStateModel, emit); } - void _logOutEvent( - _LogOutEvent event, - Emitter emit, - ) async { + void _logOutEvent(_LogOutEvent event, Emitter emit) async { var currentStateModel = state.authStateModel.copyWith(); try { final loggedOut = await _iAuthorizationRepo.logout(); @@ -294,10 +280,7 @@ class AuthBloc extends Bloc { } } - void _emitter( - AuthStateModel authStateModel, - Emitter emit, - ) { + void _emitter(AuthStateModel authStateModel, Emitter emit) { switch (state) { case Auth$InitialState(): emit(AuthStates.initial(authStateModel)); diff --git a/lib/src/features/authorization/bloc/state_model/auth_state_model.dart b/lib/src/features/authorization/bloc/state_model/auth_state_model.dart index b5a3946..0e40dc9 100644 --- a/lib/src/features/authorization/bloc/state_model/auth_state_model.dart +++ b/lib/src/features/authorization/bloc/state_model/auth_state_model.dart @@ -14,11 +14,11 @@ class AuthStateModel { }); factory AuthStateModel.idle() => const AuthStateModel( - user: null, - showPassword: true, - loadingRegister: false, - loadingLogin: false, - ); + user: null, + showPassword: true, + loadingRegister: false, + loadingLogin: false, + ); @override bool operator ==(Object other) => @@ -32,7 +32,10 @@ class AuthStateModel { @override int get hashCode => - user.hashCode ^ showPassword.hashCode ^ loadingRegister.hashCode ^ loadingLogin.hashCode; + user.hashCode ^ + showPassword.hashCode ^ + loadingRegister.hashCode ^ + loadingLogin.hashCode; @override String toString() { diff --git a/lib/src/features/authorization/data/repo/authorization_repo_impl.dart b/lib/src/features/authorization/data/repo/authorization_repo_impl.dart index 091d4e5..cfca02f 100644 --- a/lib/src/features/authorization/data/repo/authorization_repo_impl.dart +++ b/lib/src/features/authorization/data/repo/authorization_repo_impl.dart @@ -14,23 +14,21 @@ class AuthorizationRepoImpl implements AuthorizationRepo { Future login({ required final String emailOrUserName, required final String password, - }) => - _laravelAuthDataSource.login( - emailOrUserName: emailOrUserName, - password: password, - ); + }) => _laravelAuthDataSource.login( + emailOrUserName: emailOrUserName, + password: password, + ); @override Future register({ required final String email, required final String password, required final String userName, - }) => - _laravelAuthDataSource.register( - email: email, - password: password, - userName: userName, - ); + }) => _laravelAuthDataSource.register( + email: email, + password: password, + userName: userName, + ); @override Future logout() => _laravelAuthDataSource.logout(); diff --git a/lib/src/features/authorization/data/sources/laravel/impl/laravel_auth_data_source_impl.dart b/lib/src/features/authorization/data/sources/laravel/impl/laravel_auth_data_source_impl.dart index edb7a5c..084f3ed 100644 --- a/lib/src/features/authorization/data/sources/laravel/impl/laravel_auth_data_source_impl.dart +++ b/lib/src/features/authorization/data/sources/laravel/impl/laravel_auth_data_source_impl.dart @@ -13,10 +13,10 @@ class LaravelAuthDataSourceImpl implements LaravelAuthDataSource { required final Logger logger, required final RestClientBase restClientBase, required final ScreenMessaging screenMessaging, - }) : _sharedPreferences = sharedPreferences, - _logger = logger, - _restClientBase = restClientBase, - _screenMessaging = screenMessaging; + }) : _sharedPreferences = sharedPreferences, + _logger = logger, + _restClientBase = restClientBase, + _screenMessaging = screenMessaging; final SharedPreferHelper _sharedPreferences; final Logger _logger; @@ -64,7 +64,10 @@ class LaravelAuthDataSourceImpl implements LaravelAuthDataSource { if (response == null) return null; - _logger.log(Level.debug, "login response: $response | ${response.runtimeType}"); + _logger.log( + Level.debug, + "login response: $response | ${response.runtimeType}", + ); if (!response.containsKey(HttpServerResponses.serverSuccessResponse)) { return null; @@ -75,7 +78,10 @@ class LaravelAuthDataSourceImpl implements LaravelAuthDataSource { return null; } - await _sharedPreferences.setStringByKey(key: "token", value: response.getNested(['token'])); + await _sharedPreferences.setStringByKey( + key: "token", + value: response.getNested(['token']), + ); return UserModel.fromJson(response.getNested(['user'])); } @@ -109,7 +115,10 @@ class LaravelAuthDataSourceImpl implements LaravelAuthDataSource { return null; } - await _sharedPreferences.setStringByKey(key: "token", value: response.getNested(['token'])); + await _sharedPreferences.setStringByKey( + key: "token", + value: response.getNested(['token']), + ); return UserModel.fromJson(response.getNested(['user'])); } @@ -125,7 +134,9 @@ class LaravelAuthDataSourceImpl implements LaravelAuthDataSource { _logger.log(Level.debug, "logout response: $response"); - if (!response.containsKey(HttpServerResponses.serverSuccessResponse)) return false; + if (!response.containsKey(HttpServerResponses.serverSuccessResponse)) { + return false; + } if (response[HttpServerResponses.serverSuccessResponse] == true) { return true; diff --git a/lib/src/features/authorization/data/sources/other_authorization/impl/other_authorization_impl.dart b/lib/src/features/authorization/data/sources/other_authorization/impl/other_authorization_impl.dart index ea39351..05d4d7f 100644 --- a/lib/src/features/authorization/data/sources/other_authorization/impl/other_authorization_impl.dart +++ b/lib/src/features/authorization/data/sources/other_authorization/impl/other_authorization_impl.dart @@ -15,10 +15,10 @@ class OtherAuthorizationImpl implements OtherAuthorizationDatasource { required final FacebookAuth facebookAuth, required final SharedPreferHelper sharedPreferHelper, required final RestClientBase restClientBase, - }) : _googleSignIn = googleSignIn, - _facebookAuth = facebookAuth, - _sharedPreferHelper = sharedPreferHelper, - _restClientBase = restClientBase; + }) : _googleSignIn = googleSignIn, + _facebookAuth = facebookAuth, + _sharedPreferHelper = sharedPreferHelper, + _restClientBase = restClientBase; final GoogleSignIn _googleSignIn; final FacebookAuth _facebookAuth; @@ -33,7 +33,8 @@ class OtherAuthorizationImpl implements OtherAuthorizationDatasource { Future faceBookAuth() async { final LoginResult loginResult = await _facebookAuth.login(); - if (loginResult.status == LoginStatus.failed || loginResult.status == LoginStatus.cancelled) { + if (loginResult.status == LoginStatus.failed || + loginResult.status == LoginStatus.cancelled) { return null; } @@ -56,9 +57,7 @@ class OtherAuthorizationImpl implements OtherAuthorizationDatasource { await _sharedPreferHelper.setStringByKey( key: "token", - value: response.getNested( - ['token'], - ), + value: response.getNested(['token']), ); return UserModel.fromJson(response.getNested(['user'])); @@ -89,15 +88,9 @@ class OtherAuthorizationImpl implements OtherAuthorizationDatasource { await _sharedPreferHelper.setStringByKey( key: "token", - value: response.getNested( - ['token'], - ), + value: response.getNested(['token']), ); - return UserModel.fromJson( - response.getNested( - ['user'], - ), - ); + return UserModel.fromJson(response.getNested(['user'])); } } diff --git a/lib/src/features/authorization/view/login_page.dart b/lib/src/features/authorization/view/login_page.dart index f0f3e64..0f94dbb 100644 --- a/lib/src/features/authorization/view/login_page.dart +++ b/lib/src/features/authorization/view/login_page.dart @@ -26,8 +26,11 @@ class LoginPage extends StatefulWidget { class _LoginPageState extends State { final GlobalKey _loginForm = GlobalKey(); - final TextEditingController _emailOrUserNameController = TextEditingController(text: ''); - final TextEditingController _passwordController = TextEditingController(text: ''); + final TextEditingController _emailOrUserNameController = + TextEditingController(text: ''); + final TextEditingController _passwordController = TextEditingController( + text: '', + ); late final AuthBloc _authBloc; // final AnimatedLoginCharacter _animatedLoginCharacter = AnimatedLoginCharacter(); @@ -117,8 +120,10 @@ class _LoginPageState extends State { right: 0, top: 25, child: IconButton( - onPressed: () => - _authBloc.add(const AuthEvents.changePasswordVisibility()), + onPressed: + () => _authBloc.add( + const AuthEvents.changePasswordVisibility(), + ), icon: Icon( (authStateModel.showPassword) ? CupertinoIcons.eye @@ -138,37 +143,43 @@ class _LoginPageState extends State { borderRadius: BorderRadius.circular(15), ), ), - backgroundColor: const WidgetStatePropertyAll(Colors.blueAccent), - ), - onPressed: () => _authBloc.add( - AuthEvents.loginEvent( - emailOrUserName: _emailOrUserNameController.text, - password: _passwordController.text, - initDependenciesAfterAuthorization: - dependencies.initDependenciesAfterAuthorization, - // initDioOptions: () async { - // await dependencies.restClientBase.initOptions(); - // }, + backgroundColor: const WidgetStatePropertyAll( + Colors.blueAccent, ), ), + onPressed: + () => _authBloc.add( + AuthEvents.loginEvent( + emailOrUserName: + _emailOrUserNameController.text, + password: _passwordController.text, + initDependenciesAfterAuthorization: + dependencies + .initDependenciesAfterAuthorization, + // initDioOptions: () async { + // await dependencies.restClientBase.initOptions(); + // }, + ), + ), child: Center( - child: (authStateModel.loadingLogin) - ? const SizedBox( - width: 15, - height: 15, - child: CircularProgressIndicator( - strokeWidth: 2, - color: Colors.white, + child: + (authStateModel.loadingLogin) + ? const SizedBox( + width: 15, + height: 15, + child: CircularProgressIndicator( + strokeWidth: 2, + color: Colors.white, + ), + ) + : Text( + Constants.signIn, + style: GoogleFonts.aBeeZee( + color: Colors.white, + fontWeight: FontWeight.bold, + fontSize: 16, + ), ), - ) - : Text( - Constants.signIn, - style: GoogleFonts.aBeeZee( - color: Colors.white, - fontWeight: FontWeight.bold, - fontSize: 16, - ), - ), ), ), ), @@ -207,19 +218,19 @@ class _LoginPageState extends State { children: [ Expanded( child: OtherAuthorizationButtonWidget( - icon: const FaIcon( - FontAwesomeIcons.google, - ), + icon: const FaIcon(FontAwesomeIcons.google), text: 'Google', - onTap: () => _authBloc.add( - AuthEvents.googleAuth( - initDependenciesAfterAuthorization: - dependencies.initDependenciesAfterAuthorization, - // initDioOptions: () async { - // await dependencies.dioSettings.initOptions(); - // }, - ), - ), + onTap: + () => _authBloc.add( + AuthEvents.googleAuth( + initDependenciesAfterAuthorization: + dependencies + .initDependenciesAfterAuthorization, + // initDioOptions: () async { + // await dependencies.dioSettings.initOptions(); + // }, + ), + ), ), ), const SizedBox(width: 20), @@ -230,15 +241,17 @@ class _LoginPageState extends State { color: Colors.blue, ), text: 'Facebook', - onTap: () => _authBloc.add( - AuthEvents.facebookAuth( - initDependenciesAfterAuthorization: - dependencies.initDependenciesAfterAuthorization, - // initDioOptions: () async { - // await dependencies.dioSettings.initOptions(); - // }, - ), - ), + onTap: + () => _authBloc.add( + AuthEvents.facebookAuth( + initDependenciesAfterAuthorization: + dependencies + .initDependenciesAfterAuthorization, + // initDioOptions: () async { + // await dependencies.dioSettings.initOptions(); + // }, + ), + ), ), ), ], @@ -255,8 +268,12 @@ class _LoginPageState extends State { const TextSpan(text: Constants.doNotHaveAnAccount), const WidgetSpan(child: SizedBox(width: 10)), TextSpan( - recognizer: TapGestureRecognizer() - ..onTap = () => AutoRouter.of(context).replace(const RegisterRoute()), + recognizer: + TapGestureRecognizer() + ..onTap = + () => AutoRouter.of( + context, + ).replace(const RegisterRoute()), text: Constants.signUp, style: const TextStyle(color: Colors.blue), ), diff --git a/lib/src/features/authorization/view/register_page.dart b/lib/src/features/authorization/view/register_page.dart index 5ae0efc..9473965 100644 --- a/lib/src/features/authorization/view/register_page.dart +++ b/lib/src/features/authorization/view/register_page.dart @@ -22,9 +22,15 @@ class RegisterPage extends StatefulWidget { class _RegisterPageState extends State { final GlobalKey _registerForm = GlobalKey(); - final TextEditingController _emailController = TextEditingController(text: ''); - final TextEditingController _passwordController = TextEditingController(text: ''); - final TextEditingController _userNameController = TextEditingController(text: ''); + final TextEditingController _emailController = TextEditingController( + text: '', + ); + final TextEditingController _passwordController = TextEditingController( + text: '', + ); + final TextEditingController _userNameController = TextEditingController( + text: '', + ); late final AuthBloc _authBloc; @override @@ -45,90 +51,94 @@ class _RegisterPageState extends State { Widget build(BuildContext context) { final dependencies = DependenciesScope.of(context, listen: false); return BlocConsumer( - bloc: _authBloc, - listener: (context, state) { - if (state is Auth$AuthorizedState) { - AutoRouter.of(context).replaceAll([const HomeRoute()]); - } - }, - builder: (context, state) { - final authState = state.authStateModel; - return Scaffold( - body: SingleChildScrollView( - padding: const EdgeInsets.all(8.0), - child: SizedBox( - height: MediaQuery.of(context).size.height, - child: Form( - key: _registerForm, - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Text( - "Sign Up", - style: GoogleFonts.aBeeZee( - fontWeight: FontWeight.w400, - fontSize: 20, - ), - ), - const SizedBox(height: 20), - AuthorizationInputWidget( - title: Constants.email, - controller: _emailController, - hintText: Constants.enterEmail, - ), - const SizedBox(height: 10), - AuthorizationInputWidget( - title: Constants.username, - controller: _userNameController, - hintText: "@${Constants.username}", + bloc: _authBloc, + listener: (context, state) { + if (state is Auth$AuthorizedState) { + AutoRouter.of(context).replaceAll([const HomeRoute()]); + } + }, + builder: (context, state) { + final authState = state.authStateModel; + return Scaffold( + body: SingleChildScrollView( + padding: const EdgeInsets.all(8.0), + child: SizedBox( + height: MediaQuery.of(context).size.height, + child: Form( + key: _registerForm, + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Text( + "Sign Up", + style: GoogleFonts.aBeeZee( + fontWeight: FontWeight.w400, + fontSize: 20, ), - const SizedBox(height: 10), - Stack( - children: [ - AuthorizationInputWidget( - title: Constants.password, - controller: _passwordController, - hintText: Constants.enterPassword, + ), + const SizedBox(height: 20), + AuthorizationInputWidget( + title: Constants.email, + controller: _emailController, + hintText: Constants.enterEmail, + ), + const SizedBox(height: 10), + AuthorizationInputWidget( + title: Constants.username, + controller: _userNameController, + hintText: "@${Constants.username}", + ), + const SizedBox(height: 10), + Stack( + children: [ + AuthorizationInputWidget( + title: Constants.password, + controller: _passwordController, + hintText: Constants.enterPassword, + ), + Positioned( + right: 0, + top: 25, + child: IconButton( + onPressed: () => [], + icon: const Icon(Icons.remove_red_eye_outlined), ), - Positioned( - right: 0, - top: 25, - child: IconButton( - onPressed: () => [], - icon: const Icon( - Icons.remove_red_eye_outlined, - ), + ), + ], + ), + const SizedBox(height: 20), + SizedBox( + height: 60, + child: ElevatedButton( + style: ButtonStyle( + shape: WidgetStatePropertyAll( + RoundedRectangleBorder( + borderRadius: BorderRadius.circular(15), ), ), - ], - ), - const SizedBox(height: 20), - SizedBox( - height: 60, - child: ElevatedButton( - style: ButtonStyle( - shape: WidgetStatePropertyAll( - RoundedRectangleBorder( - borderRadius: BorderRadius.circular(15), - ), - ), - backgroundColor: const WidgetStatePropertyAll(Colors.blueAccent), + backgroundColor: const WidgetStatePropertyAll( + Colors.blueAccent, ), - onPressed: () => _authBloc.add( - AuthEvents.registerEvent( - email: _emailController.text, - password: _passwordController.text, - userName: _userNameController.text, - initDependenciesAfterAuthorization: dependencies.initDependenciesAfterAuthorization, - // initDioOptions: () async { + ), + onPressed: + () => _authBloc.add( + AuthEvents.registerEvent( + email: _emailController.text, + password: _passwordController.text, + userName: _userNameController.text, + initDependenciesAfterAuthorization: + dependencies + .initDependenciesAfterAuthorization, + // initDioOptions: () async { // await dependencies.dioSettings.initOptions(); - // }, + // }, + ), ), - ), - child: Center( - child: (authState.loadingRegister) - ? const SizedBox( + child: Center( + child: + (authState.loadingRegister) + ? const SizedBox( width: 15, height: 15, child: CircularProgressIndicator( @@ -136,7 +146,7 @@ class _RegisterPageState extends State { color: Colors.white, ), ) - : Text( + : Text( Constants.signUp, style: GoogleFonts.aBeeZee( color: Colors.white, @@ -144,104 +154,113 @@ class _RegisterPageState extends State { fontSize: 16, ), ), - ), ), ), - const SizedBox(height: 20), - Row( - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - const Expanded( - child: Divider( - height: 0, - thickness: 0.5, - color: Colors.grey, - ), + ), + const SizedBox(height: 20), + Row( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + const Expanded( + child: Divider( + height: 0, + thickness: 0.5, + color: Colors.grey, ), - const SizedBox(width: 15), - Text( - Constants.orSignUpWith, - style: GoogleFonts.aBeeZee( - fontWeight: FontWeight.bold, - fontSize: 12, - color: Colors.grey, - ), + ), + const SizedBox(width: 15), + Text( + Constants.orSignUpWith, + style: GoogleFonts.aBeeZee( + fontWeight: FontWeight.bold, + fontSize: 12, + color: Colors.grey, ), - const SizedBox(width: 15), - const Expanded( - child: Divider( - height: 0, - thickness: 0.5, - color: Colors.grey, - ), + ), + const SizedBox(width: 15), + const Expanded( + child: Divider( + height: 0, + thickness: 0.5, + color: Colors.grey, ), - ], - ), - const SizedBox(height: 20), - Row( - children: [ - Expanded( - child: OtherAuthorizationButtonWidget( - icon: const FaIcon( - FontAwesomeIcons.google, - ), - text: 'Google', - onTap: () => _authBloc.add( - AuthEvents.googleAuth( - initDependenciesAfterAuthorization: dependencies.initDependenciesAfterAuthorization, - // initDioOptions: () async { + ), + ], + ), + const SizedBox(height: 20), + Row( + children: [ + Expanded( + child: OtherAuthorizationButtonWidget( + icon: const FaIcon(FontAwesomeIcons.google), + text: 'Google', + onTap: + () => _authBloc.add( + AuthEvents.googleAuth( + initDependenciesAfterAuthorization: + dependencies + .initDependenciesAfterAuthorization, + // initDioOptions: () async { // await dependencies.dioSettings.initOptions(); - // }, + // }, + ), ), - ), - ), ), - const SizedBox(width: 20), - Expanded( - child: OtherAuthorizationButtonWidget( - icon: const FaIcon( - FontAwesomeIcons.facebook, - color: Colors.blue, - ), - text: 'Facebook', - onTap: () => _authBloc.add( - AuthEvents.facebookAuth( - initDependenciesAfterAuthorization: dependencies.initDependenciesAfterAuthorization, - // initDioOptions: () async { + ), + const SizedBox(width: 20), + Expanded( + child: OtherAuthorizationButtonWidget( + icon: const FaIcon( + FontAwesomeIcons.facebook, + color: Colors.blue, + ), + text: 'Facebook', + onTap: + () => _authBloc.add( + AuthEvents.facebookAuth( + initDependenciesAfterAuthorization: + dependencies + .initDependenciesAfterAuthorization, + // initDioOptions: () async { // await dependencies.dioSettings.initOptions(); - // }, + // }, + ), ), - ), - ), - ), - ], - ), - const SizedBox(height: 20), - RichText( - text: TextSpan( - style: GoogleFonts.aBeeZee( - fontWeight: FontWeight.bold, - fontSize: 13, - color: Colors.grey, ), - children: [ - const TextSpan(text: Constants.haveAnAccount), - const WidgetSpan(child: SizedBox(width: 10)), - TextSpan( - recognizer: TapGestureRecognizer() - ..onTap = () => AutoRouter.of(context).replace(const LoginRoute()), - text: Constants.signIn, - style: const TextStyle(color: Colors.blue), - ), - ], ), + ], + ), + const SizedBox(height: 20), + RichText( + text: TextSpan( + style: GoogleFonts.aBeeZee( + fontWeight: FontWeight.bold, + fontSize: 13, + color: Colors.grey, + ), + children: [ + const TextSpan(text: Constants.haveAnAccount), + const WidgetSpan(child: SizedBox(width: 10)), + TextSpan( + recognizer: + TapGestureRecognizer() + ..onTap = + () => AutoRouter.of( + context, + ).replace(const LoginRoute()), + text: Constants.signIn, + style: const TextStyle(color: Colors.blue), + ), + ], ), - ], - ), + ), + ], ), ), ), - ); - },); + ), + ); + }, + ); } } diff --git a/lib/src/features/authorization/view/widgets/authorization_input_widget.dart b/lib/src/features/authorization/view/widgets/authorization_input_widget.dart index 8113732..d06bc36 100644 --- a/lib/src/features/authorization/view/widgets/authorization_input_widget.dart +++ b/lib/src/features/authorization/view/widgets/authorization_input_widget.dart @@ -17,7 +17,8 @@ class AuthorizationInputWidget extends StatefulWidget { }); @override - State createState() => _AuthorizationInputWidgetState(); + State createState() => + _AuthorizationInputWidgetState(); } class _AuthorizationInputWidgetState extends State { @@ -30,9 +31,7 @@ class _AuthorizationInputWidgetState extends State { children: [ Text( widget.title, - style: GoogleFonts.aBeeZee( - fontWeight: FontWeight.w400, - ), + style: GoogleFonts.aBeeZee(fontWeight: FontWeight.w400), ), const SizedBox(height: 5), ClipRRect( @@ -45,9 +44,7 @@ class _AuthorizationInputWidgetState extends State { }, onTapOutside: (v) => FocusManager.instance.primaryFocus?.unfocus(), controller: widget.controller, - style: GoogleFonts.aBeeZee( - fontWeight: FontWeight.w500, - ), + style: GoogleFonts.aBeeZee(fontWeight: FontWeight.w500), decoration: InputDecoration( fillColor: Colors.white, hintText: widget.hintText, diff --git a/lib/src/features/authorization/view/widgets/other_authorization_button_widget.dart b/lib/src/features/authorization/view/widgets/other_authorization_button_widget.dart index 2c4c877..e463004 100644 --- a/lib/src/features/authorization/view/widgets/other_authorization_button_widget.dart +++ b/lib/src/features/authorization/view/widgets/other_authorization_button_widget.dart @@ -26,10 +26,7 @@ class OtherAuthorizationButtonWidget extends StatelessWidget { children: [ icon, const SizedBox(width: 5), - Text( - text, - style: GoogleFonts.aBeeZee(fontWeight: FontWeight.w400), - ), + Text(text, style: GoogleFonts.aBeeZee(fontWeight: FontWeight.w400)), ], ), ), diff --git a/lib/src/features/chat_screen/bloc/chat_screen_bloc.dart b/lib/src/features/chat_screen/bloc/chat_screen_bloc.dart index b9b4dd9..75f470e 100644 --- a/lib/src/features/chat_screen/bloc/chat_screen_bloc.dart +++ b/lib/src/features/chat_screen/bloc/chat_screen_bloc.dart @@ -39,25 +39,28 @@ sealed class ChatScreenEvents with _$ChatScreenEvents { required void Function() clearMessage, }) = _Chat$SendMessageEvent; - const factory ChatScreenEvents.changeEmojiPicker({ - final bool? value, - }) = _Chat$ChangeEmojiPickerEvent; + const factory ChatScreenEvents.changeEmojiPicker({final bool? value}) = + _Chat$ChangeEmojiPickerEvent; } @immutable @freezed sealed class ChatScreenStates with _$ChatScreenStates { - const factory ChatScreenStates.initial(final ChatScreenStateModel chatScreenStateModel) = - ChatScreen$InitialState; + const factory ChatScreenStates.initial( + final ChatScreenStateModel chatScreenStateModel, + ) = ChatScreen$InitialState; - const factory ChatScreenStates.inProgress(final ChatScreenStateModel chatScreenStateModel) = - ChatScreen$InProgressState; + const factory ChatScreenStates.inProgress( + final ChatScreenStateModel chatScreenStateModel, + ) = ChatScreen$InProgressState; - const factory ChatScreenStates.error(final ChatScreenStateModel chatScreenStateModel) = - ErrorChatScreenState; + const factory ChatScreenStates.error( + final ChatScreenStateModel chatScreenStateModel, + ) = ErrorChatScreenState; - const factory ChatScreenStates.successful(final ChatScreenStateModel chatScreenStateModel) = - ChatScreen$SuccessfulState; + const factory ChatScreenStates.successful( + final ChatScreenStateModel chatScreenStateModel, + ) = ChatScreen$SuccessfulState; } class ChatScreenBloc extends Bloc { @@ -80,17 +83,18 @@ class ChatScreenBloc extends Bloc { required PusherChannelsOptions options, required ChatScreenStates initialState, required Logger logger, - }) : _iChatScreenRepo = chatScreenRepo, - _iChatScreenChatRepo = chatScreenChatRepo, - _currentUser = currentUser, - _options = options, - _logger = logger, - super(initialState) { + }) : _iChatScreenRepo = chatScreenRepo, + _iChatScreenChatRepo = chatScreenChatRepo, + _currentUser = currentUser, + _options = options, + _logger = logger, + super(initialState) { // on( (event, emit) => event.map( initChatScreenEvent: (event) => _initChatScreenEvent(event, emit), - removeAllTempCreatedChatsEvent: (event) => _removeAllTempCreatedChatsEvent(event, emit), + removeAllTempCreatedChatsEvent: + (event) => _removeAllTempCreatedChatsEvent(event, emit), handleChatMessageEvent: (event) => _handleChatMessageEvent(event, emit), sendMessageEvent: (event) => _sendMessageEvent(event, emit), changeEmojiPicker: (event) => _changeEmojiPicker(event, emit), @@ -109,7 +113,10 @@ class ChatScreenBloc extends Bloc { currentStateModel = currentStateModel.copyWith(currentUser: _currentUser); - final chat = await _iChatScreenChatRepo.chat(chat: event.chat, withUser: event.user); + final chat = await _iChatScreenChatRepo.chat( + chat: event.chat, + withUser: event.user, + ); // i don't know why after calling function above currentUser from "_currentStateModel.currentUser" disappears // i didn't find a bug @@ -120,12 +127,18 @@ class ChatScreenBloc extends Bloc { // } if (chat == null || chat.uuid == null) { - currentStateModel = _setChat(currentStateModel: currentStateModel, chat: null); + currentStateModel = _setChat( + currentStateModel: currentStateModel, + chat: null, + ); emit(ChatScreenStates.error(currentStateModel)); return; } - currentStateModel = _setChat(currentStateModel: currentStateModel, chat: chat); + currentStateModel = _setChat( + currentStateModel: currentStateModel, + chat: chat, + ); final channelName = "${Constants.chatChannelName}${chat.id}${Constants.chatChannelUUID}${chat.uuid}"; @@ -139,28 +152,26 @@ class ChatScreenBloc extends Bloc { final channel = _pusherChannelsClient?.publicChannel(channelName); - _channelInformationSubscription = _pusherChannelsClient?.onConnectionEstablished.listen( - (e) { - channel?.subscribeIfNotUnsubscribed(); - }, - ); + _channelInformationSubscription = _pusherChannelsClient + ?.onConnectionEstablished + .listen((e) { + channel?.subscribeIfNotUnsubscribed(); + }); await _pusherChannelsClient?.connect(); _channelSubscription = channel ?.bind(Constants.chatChannelEventName) - .transform( - ChatMessageStreamTransformer( - logger: _logger, - ), - ) + .transform(ChatMessageStreamTransformer(logger: _logger)) .listen( - (pusherEvent) { - add(ChatScreenEvents.handleChatMessageEvent(pusherEvent)); - }, - onError: (error, stackTrace) => Error.throwWithStackTrace(error, stackTrace), - onDone: () => _channelSubscription?.cancel(), - ); + (pusherEvent) { + add(ChatScreenEvents.handleChatMessageEvent(pusherEvent)); + }, + onError: + (error, stackTrace) => + Error.throwWithStackTrace(error, stackTrace), + onDone: () => _channelSubscription?.cancel(), + ); emit(ChatScreenStates.successful(currentStateModel)); @@ -236,9 +247,7 @@ class ChatScreenBloc extends Bloc { _emitter(emit: emit, currentStateModel: currentStateModel); - await _iChatScreenRepo.sendMessage( - chatMessage: chatMessage, - ); + await _iChatScreenRepo.sendMessage(chatMessage: chatMessage); } void _changeEmojiPicker( @@ -259,38 +268,39 @@ class ChatScreenBloc extends Bloc { bool setChatMessages = true, }) { if (chat == null) return currentStateModel; - currentStateModel = currentStateModel.copyWith( - currentChat: chat, - ); + currentStateModel = currentStateModel.copyWith(currentChat: chat); if (setChatMessages) { - final List chatMessages = List.from(currentStateModel.messages); - chatMessages.addAll((chat.messages ?? []).reversed.toList()); - currentStateModel = currentStateModel.copyWith( - messages: chatMessages, + final List chatMessages = List.from( + currentStateModel.messages, ); + chatMessages.addAll((chat.messages ?? []).reversed.toList()); + currentStateModel = currentStateModel.copyWith(messages: chatMessages); } return currentStateModel; } -// -// void setToFile(File? file) => _pickedFile = file; -// -// void setToRelatedUser(UserModel? user) => _relatedUser = user; -// -// void setToCurrentUser(UserModel? user) => _currentUser = user; -// + // + // void setToFile(File? file) => _pickedFile = file; + // + // void setToRelatedUser(UserModel? user) => _relatedUser = user; + // + // void setToCurrentUser(UserModel? user) => _currentUser = user; + // ChatScreenStateModel _addMessage({ required ChatMessageModel message, required ChatScreenStateModel currentStateModel, }) { - final listOfMessages = List.from(currentStateModel.messages); + final listOfMessages = List.from( + currentStateModel.messages, + ); - final findMessage = - listOfMessages.firstWhereOrNull((e) => e.chatMessageUUID == message.chatMessageUUID); + final findMessage = listOfMessages.firstWhereOrNull( + (e) => e.chatMessageUUID == message.chatMessageUUID, + ); if (findMessage != null) { - listOfMessages[ - listOfMessages.indexWhere((e) => e.chatMessageUUID == message.chatMessageUUID)] = - findMessage.copyWith(messageSent: true); + listOfMessages[listOfMessages.indexWhere( + (e) => e.chatMessageUUID == message.chatMessageUUID, + )] = findMessage.copyWith(messageSent: true); } else { listOfMessages.add(message); } @@ -300,9 +310,9 @@ class ChatScreenBloc extends Bloc { return currentStateModel; } -// -// void clearMessage() => _messageController.clear(); -// + // + // void clearMessage() => _messageController.clear(); + // ChatScreenStateModel _changeEmojiPickerHelper({ required ChatScreenStateModel currentStateModel, bool? value, diff --git a/lib/src/features/chat_screen/bloc/stream_transformers/chat_message_stream_transformer.dart b/lib/src/features/chat_screen/bloc/stream_transformers/chat_message_stream_transformer.dart index 2be7ff2..d17b2f6 100644 --- a/lib/src/features/chat_screen/bloc/stream_transformers/chat_message_stream_transformer.dart +++ b/lib/src/features/chat_screen/bloc/stream_transformers/chat_message_stream_transformer.dart @@ -6,22 +6,27 @@ import 'package:logger/logger.dart'; import 'package:yahay/src/core/models/chat_message_model/chat_message_model.dart'; import 'package:yahay/src/core/models/chats_model/chat_model.dart'; -typedef ChatMessageStreamTransformerRecord = ({ - ChatModel? chatModel, - ChatMessageModel? chageMessageModel -}); +typedef ChatMessageStreamTransformerRecord = + ({ChatModel? chatModel, ChatMessageModel? chageMessageModel}); // I know that I could create a class that holds chatModel and message // but in order to improve records i had to write final class ChatMessageStreamTransformer - extends StreamTransformerBase { + extends + StreamTransformerBase< + ChannelReadEvent, + ChatMessageStreamTransformerRecord + > { // - ChatMessageStreamTransformer({required final Logger logger}) : _logger = logger; + ChatMessageStreamTransformer({required final Logger logger}) + : _logger = logger; final Logger _logger; @override - Stream bind(Stream stream) { + Stream bind( + Stream stream, + ) { StreamSubscription? subscription; final controller = StreamController( @@ -37,8 +42,11 @@ final class ChatMessageStreamTransformer ChatMessageModel? message; ChatModel? chat; - if (messageJson.containsKey('message') && messageJson['message'] != null) { - message = ChatMessageModel.fromJson(messageJson['message']).copyWith(messageSent: true); + if (messageJson.containsKey('message') && + messageJson['message'] != null) { + message = ChatMessageModel.fromJson( + messageJson['message'], + ).copyWith(messageSent: true); } // find problem here diff --git a/lib/src/features/chat_screen/data/repo/chat_screen_chat_repo_impl.dart b/lib/src/features/chat_screen/data/repo/chat_screen_chat_repo_impl.dart index ed770da..e1171d0 100644 --- a/lib/src/features/chat_screen/data/repo/chat_screen_chat_repo_impl.dart +++ b/lib/src/features/chat_screen/data/repo/chat_screen_chat_repo_impl.dart @@ -10,10 +10,8 @@ class ChatScreenChatRepoImpl implements ChatScreenChatRepo { ChatScreenChatRepoImpl(this._chatScreenChatDataSource); @override - Future chat({ChatModel? chat, UserModel? withUser}) => _chatScreenChatDataSource.chat( - chat: chat, - withUser: withUser, - ); + Future chat({ChatModel? chat, UserModel? withUser}) => + _chatScreenChatDataSource.chat(chat: chat, withUser: withUser); @override Future removeAllTempCreatedChats({required ChatModel? chat}) => diff --git a/lib/src/features/chat_screen/data/repo/chat_screen_repo_impl.dart b/lib/src/features/chat_screen/data/repo/chat_screen_repo_impl.dart index 034d94d..75f4b84 100644 --- a/lib/src/features/chat_screen/data/repo/chat_screen_repo_impl.dart +++ b/lib/src/features/chat_screen/data/repo/chat_screen_repo_impl.dart @@ -21,13 +21,12 @@ class ChatScreenRepoImpl implements ChatScreenRepo { required UserModel? toUser, required File file, String? message, - }) => - _chatScreenMessageDataSource.sendPicture( - chat: chat, - toUser: toUser, - file: file, - message: message, - ); + }) => _chatScreenMessageDataSource.sendPicture( + chat: chat, + toUser: toUser, + file: file, + message: message, + ); @override Future sendVideo({ @@ -35,11 +34,10 @@ class ChatScreenRepoImpl implements ChatScreenRepo { required UserModel? toUser, required File file, String? message, - }) => - _chatScreenMessageDataSource.sendVideo( - chat: chat, - toUser: toUser, - file: file, - message: message, - ); + }) => _chatScreenMessageDataSource.sendVideo( + chat: chat, + toUser: toUser, + file: file, + message: message, + ); } diff --git a/lib/src/features/chat_screen/data/sources/chat_screen_chat_data_source/impl/chat_screen_chat_data_souce.dart b/lib/src/features/chat_screen/data/sources/chat_screen_chat_data_source/impl/chat_screen_chat_data_souce.dart index 02af5f3..4220b0f 100644 --- a/lib/src/features/chat_screen/data/sources/chat_screen_chat_data_source/impl/chat_screen_chat_data_souce.dart +++ b/lib/src/features/chat_screen/data/sources/chat_screen_chat_data_source/impl/chat_screen_chat_data_souce.dart @@ -8,22 +8,19 @@ import 'package:yahay/src/features/chat_screen/data/sources/chat_screen_chat_dat class ChatScreenChatDataSourceImpl implements ChatScreenChatDataSource { // - ChatScreenChatDataSourceImpl({ - required final RestClientBase restClientBase, - }) : _restClientBase = restClientBase; + ChatScreenChatDataSourceImpl({required final RestClientBase restClientBase}) + : _restClientBase = restClientBase; final RestClientBase _restClientBase; final String _getChatUrl = "${HttpRoutes.chatsPrefix}/get/chat/on/entrance"; - final String _deleteTempCreatedChatsUrl = "${HttpRoutes.chatsPrefix}/delete/temp/created/chats"; + final String _deleteTempCreatedChatsUrl = + "${HttpRoutes.chatsPrefix}/delete/temp/created/chats"; @override Future chat({ChatModel? chat, UserModel? withUser}) async { try { - final body = { - "chat_uuid": chat?.uuid, - 'with_user_id': withUser?.id, - }; + final body = {"chat_uuid": chat?.uuid, 'with_user_id': withUser?.id}; final response = await _restClientBase.post(_getChatUrl, data: body); @@ -31,16 +28,13 @@ class ChatScreenChatDataSourceImpl implements ChatScreenChatDataSource { if (!response.containsKey("chat")) return null; - final gettingChat = ChatModel.fromJson( - response.getNested( - ['chat'], - ), - ); + final gettingChat = ChatModel.fromJson(response.getNested(['chat'])); return gettingChat.copyWith( - messages: gettingChat.messages?.map((e) { - return e.copyWith(messageSent: true); - }).toList(), + messages: + gettingChat.messages?.map((e) { + return e.copyWith(messageSent: true); + }).toList(), ); } on RestClientException { rethrow; @@ -52,7 +46,10 @@ class ChatScreenChatDataSourceImpl implements ChatScreenChatDataSource { try { final body = {"chat_id": chat?.id, "chat_uuid": chat?.uuid}; - final response = await _restClientBase.delete(_deleteTempCreatedChatsUrl, data: body); + final response = await _restClientBase.delete( + _deleteTempCreatedChatsUrl, + data: body, + ); debugPrint("coming remove temp created chats: $response"); } on RestClientException { diff --git a/lib/src/features/chat_screen/data/sources/chat_screen_message_data_source/impl/chat_screen_message_data_source_impl.dart b/lib/src/features/chat_screen/data/sources/chat_screen_message_data_source/impl/chat_screen_message_data_source_impl.dart index f14cfb2..752a922 100644 --- a/lib/src/features/chat_screen/data/sources/chat_screen_message_data_source/impl/chat_screen_message_data_source_impl.dart +++ b/lib/src/features/chat_screen/data/sources/chat_screen_message_data_source/impl/chat_screen_message_data_source_impl.dart @@ -17,7 +17,8 @@ class ChatScreenMessageDataSourceImpl extends ChatScreenMessageDataSource { final RestClientBase _restClientBase; - static const String _messageSendUrl = "${HttpRoutes.chatsPrefix}/message/handler"; + static const String _messageSendUrl = + "${HttpRoutes.chatsPrefix}/message/handler"; @override Future sendMessage({required ChatMessageModel chatMessage}) async { diff --git a/lib/src/features/chat_screen/domain/repo/chat_screen_repo.dart b/lib/src/features/chat_screen/domain/repo/chat_screen_repo.dart index 4013301..5867adf 100644 --- a/lib/src/features/chat_screen/domain/repo/chat_screen_repo.dart +++ b/lib/src/features/chat_screen/domain/repo/chat_screen_repo.dart @@ -5,9 +5,7 @@ import 'package:yahay/src/core/models/chat_message_model/chat_message_model.dart import 'package:yahay/src/core/models/user_model/user_model.dart'; abstract class ChatScreenRepo { - Future sendMessage({ - required ChatMessageModel chatMessage, - }); + Future sendMessage({required ChatMessageModel chatMessage}); Future sendPicture({ required ChatModel? chat, diff --git a/lib/src/features/chat_screen/view/app_bar/chat_screen_app_bar.dart b/lib/src/features/chat_screen/view/app_bar/chat_screen_app_bar.dart index 360ac9e..96ac987 100644 --- a/lib/src/features/chat_screen/view/app_bar/chat_screen_app_bar.dart +++ b/lib/src/features/chat_screen/view/app_bar/chat_screen_app_bar.dart @@ -45,55 +45,59 @@ class _ChatScreenAppBarState extends State { }, icon: const Icon(CupertinoIcons.back), ), - title: state is ChatScreen$InProgressState - ? ShimmerLoader( - isLoading: true, - mode: widget.themeData, - child: Container( - width: MediaQuery.of(context).size.width / 2, - height: 20, - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(15), - color: Colors.white, - ), - ), - ) - : _ChatAppBarTitle( - chat: currentStateModel.currentChat, - ), - actions: state is ChatScreen$InProgressState - ? [ - ShimmerLoader( + title: + state is ChatScreen$InProgressState + ? ShimmerLoader( isLoading: true, mode: widget.themeData, child: Container( - width: 25, - height: 25, + width: MediaQuery.of(context).size.width / 2, + height: 20, decoration: BoxDecoration( + borderRadius: BorderRadius.circular(15), color: Colors.white, - borderRadius: BorderRadius.circular(50), ), ), - ), - const SizedBox(width: 10), - ] - : [ - IconButton( - onPressed: () { - AutoRouter.of(context).push( - VideoChatFeatureRoute( - chat: currentStateModel.currentChat, + ) + : _ChatAppBarTitle(chat: currentStateModel.currentChat), + actions: + state is ChatScreen$InProgressState + ? [ + ShimmerLoader( + isLoading: true, + mode: widget.themeData, + child: Container( + width: 25, + height: 25, + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(50), ), - ); - }, - icon: Icon( - CupertinoIcons.videocam, - color: (currentStateModel.currentChat?.videoChatStreaming ?? false) - ? Colors.green - : null, + ), + ), + const SizedBox(width: 10), + ] + : [ + IconButton( + onPressed: () { + AutoRouter.of(context).push( + VideoChatFeatureRoute( + chat: currentStateModel.currentChat, + ), + ); + }, + icon: Icon( + CupertinoIcons.videocam, + color: + (currentStateModel + .currentChat + ?.videoChatStreaming ?? + false) + ? Colors.green + : null, + ), ), - ), - ], + ], ); }, ); @@ -103,9 +107,7 @@ class _ChatScreenAppBarState extends State { class _ChatAppBarTitle extends StatelessWidget { final ChatModel? chat; - const _ChatAppBarTitle({ - required this.chat, - }); + const _ChatAppBarTitle({required this.chat}); @override Widget build(BuildContext context) { diff --git a/lib/src/features/chat_screen/view/bottom_chat_widget/bottom_chat_widget.dart b/lib/src/features/chat_screen/view/bottom_chat_widget/bottom_chat_widget.dart index 4e66ff8..c39f6c4 100644 --- a/lib/src/features/chat_screen/view/bottom_chat_widget/bottom_chat_widget.dart +++ b/lib/src/features/chat_screen/view/bottom_chat_widget/bottom_chat_widget.dart @@ -9,10 +9,7 @@ import 'package:yahay/src/features/telegram_file_picker_feature/view/telegram_dr class BottomChatWidget extends StatefulWidget { final TextEditingController messageController; - const BottomChatWidget({ - super.key, - required this.messageController, - }); + const BottomChatWidget({super.key, required this.messageController}); @override State createState() => _BottomChatWidgetState(); @@ -44,21 +41,32 @@ class _BottomChatWidgetState extends State { child: GestureDetector( onTap: _focusNode.requestFocus, child: Container( - constraints: const BoxConstraints( - maxHeight: 100, - ), + constraints: const BoxConstraints(maxHeight: 100), color: Theme.of(context).inputDecorationTheme.fillColor, - padding: const EdgeInsets.only(top: 10, bottom: 10, left: 10, right: 35), + padding: const EdgeInsets.only( + top: 10, + bottom: 10, + left: 10, + right: 35, + ), width: MediaQuery.of(context).size.width, child: TextField( controller: widget.messageController, textInputAction: TextInputAction.newline, onTap: () { - _chatsBloc.add(const ChatScreenEvents.changeEmojiPicker(value: false)); + _chatsBloc.add( + const ChatScreenEvents.changeEmojiPicker( + value: false, + ), + ); }, focusNode: _focusNode, onTapOutside: (v) { - _chatsBloc.add(const ChatScreenEvents.changeEmojiPicker(value: false)); + _chatsBloc.add( + const ChatScreenEvents.changeEmojiPicker( + value: false, + ), + ); FocusManager.instance.primaryFocus?.unfocus(); }, onChanged: (v) { @@ -90,13 +98,16 @@ class _BottomChatWidgetState extends State { child: IconButton( onPressed: () { FocusManager.instance.primaryFocus?.unfocus(); - _chatsBloc.add(const ChatScreenEvents.changeEmojiPicker()); + _chatsBloc.add( + const ChatScreenEvents.changeEmojiPicker(), + ); }, icon: Icon( Icons.emoji_emotions_outlined, - color: _chatsBloc.state.chatScreenStateModel.showEmojiPicker - ? Colors.blue - : null, + color: + _chatsBloc.state.chatScreenStateModel.showEmojiPicker + ? Colors.blue + : null, ), ), ), @@ -111,9 +122,11 @@ class _BottomChatWidgetState extends State { context, listen: false, ); - final telegramFilePickerBloc = TelegramFilePickerBlocFactory( - cameraHelperService: dependencies.cameraHelperService, - ).create(); + final telegramFilePickerBloc = + TelegramFilePickerBlocFactory( + cameraHelperService: + dependencies.cameraHelperService, + ).create(); showModalBottomSheet( isScrollControlled: true, context: context, @@ -122,11 +135,7 @@ class _BottomChatWidgetState extends State { telegramFilePickerBloc: telegramFilePickerBloc, ); }, - ) - .whenComplete( - telegramFilePickerBloc.close, - ) - .ignore(); + ).whenComplete(telegramFilePickerBloc.close).ignore(); }, icon: const FaIcon(FontAwesomeIcons.paste), ), diff --git a/lib/src/features/chat_screen/view/bottom_chat_widget/emoji_picker_helper.dart b/lib/src/features/chat_screen/view/bottom_chat_widget/emoji_picker_helper.dart index b88dfe7..22646d5 100644 --- a/lib/src/features/chat_screen/view/bottom_chat_widget/emoji_picker_helper.dart +++ b/lib/src/features/chat_screen/view/bottom_chat_widget/emoji_picker_helper.dart @@ -7,10 +7,7 @@ import 'package:yahay/src/features/chat_screen/bloc/chat_screen_bloc.dart'; class EmojiPickerHelper extends StatefulWidget { final TextEditingController messageController; - const EmojiPickerHelper({ - super.key, - required this.messageController, - }); + const EmojiPickerHelper({super.key, required this.messageController}); @override State createState() => _EmojiPickerHelperState(); @@ -34,7 +31,9 @@ class _EmojiPickerHelperState extends State { onBackspacePressed: () { // Do something when the user taps the backspace button (optional) // Set it to null to hide the Backspace-Button - _chatScreenBloc.add(const ChatScreenEvents.changeEmojiPicker(value: false)); + _chatScreenBloc.add( + const ChatScreenEvents.changeEmojiPicker(value: false), + ); }, textEditingController: widget.messageController, // pass here the same [TextEditingController] that is connected to your input field, usually a [TextFormField] @@ -43,7 +42,11 @@ class _EmojiPickerHelperState extends State { checkPlatformCompatibility: true, emojiViewConfig: EmojiViewConfig( // Issue: https://github.com/flutter/flutter/issues/28894 - emojiSizeMax: 28 * (foundation.defaultTargetPlatform == TargetPlatform.iOS ? 1.20 : 1.0), + emojiSizeMax: + 28 * + (foundation.defaultTargetPlatform == TargetPlatform.iOS + ? 1.20 + : 1.0), ), // viewOrderConfig: ViewOrderConfig( // bottom: EmojiPickerItem.categoryBar, @@ -56,9 +59,7 @@ class _EmojiPickerHelperState extends State { buttonColor: Colors.white, buttonIconColor: Colors.grey, ), - searchViewConfig: const SearchViewConfig( - backgroundColor: Colors.white, - ), + searchViewConfig: const SearchViewConfig(backgroundColor: Colors.white), ), ); } diff --git a/lib/src/features/chat_screen/view/chat_screen.dart b/lib/src/features/chat_screen/view/chat_screen.dart index c978603..536013c 100644 --- a/lib/src/features/chat_screen/view/chat_screen.dart +++ b/lib/src/features/chat_screen/view/chat_screen.dart @@ -23,22 +23,21 @@ class ChatScreen extends StatelessWidget { final ChatModel? chat; final UserModel? user; // temp for creating temp chat if chat does not exist - const ChatScreen({ - super.key, - required this.chat, - required this.user, - }); + const ChatScreen({super.key, required this.chat, required this.user}); @override Widget build(BuildContext context) { final dependencyContainer = DependenciesScope.of(context, listen: false); return BlocProvider( - create: (context) => ChatScreenBlocFactory( - user: dependencyContainer.authBloc.state.authStateModel.user, - channelsOptions: dependencyContainer.pusherClientService.options, - restClientBase: dependencyContainer.restClientBase, - logger: dependencyContainer.logger, - ).create(), + create: + (context) => + ChatScreenBlocFactory( + user: dependencyContainer.authBloc.state.authStateModel.user, + channelsOptions: + dependencyContainer.pusherClientService.options, + restClientBase: dependencyContainer.restClientBase, + logger: dependencyContainer.logger, + ).create(), child: _ChatScreenUI(chat: chat, user: user), ); } @@ -48,10 +47,7 @@ class _ChatScreenUI extends StatefulWidget { final ChatModel? chat; final UserModel? user; // temp for creating temp chat if chat does not exist - const _ChatScreenUI({ - required this.chat, - required this.user, - }); + const _ChatScreenUI({required this.chat, required this.user}); @override State<_ChatScreenUI> createState() => _ChatScreenUIState(); @@ -89,7 +85,9 @@ class _ChatScreenUIState extends State<_ChatScreenUI> { void _emojiClearHelper(ChatScreenStateModel currentStateModel) { if (currentStateModel.showEmojiPicker) { - _chatScreenBloc.add(const ChatScreenEvents.changeEmojiPicker(value: false)); + _chatScreenBloc.add( + const ChatScreenEvents.changeEmojiPicker(value: false), + ); } } @@ -104,21 +102,23 @@ class _ChatScreenUIState extends State<_ChatScreenUI> { case ChatScreen$InProgressState(): return const LoadingMessagesWidget(); case ErrorChatScreenState(): - return const Center( - child: Text(Constants.somethingWentWrong), - ); + return const Center(child: Text(Constants.somethingWentWrong)); case ChatScreen$SuccessfulState(): final currentStateModel = state.chatScreenStateModel; return PopScope( canPop: !currentStateModel.showEmojiPicker, - onPopInvokedWithResult: (v, _) => _emojiClearHelper(currentStateModel), + onPopInvokedWithResult: + (v, _) => _emojiClearHelper(currentStateModel), child: GestureDetector( onTap: () { _emojiClearHelper(currentStateModel); }, child: Scaffold( appBar: PreferredSize( - preferredSize: Size(MediaQuery.of(context).size.width, kToolbarHeight), + preferredSize: Size( + MediaQuery.of(context).size.width, + kToolbarHeight, + ), child: ChatScreenAppBar( themeData: _appThemeBloc.theme.value, chat: widget.chat, @@ -134,12 +134,15 @@ class _ChatScreenUIState extends State<_ChatScreenUI> { reverse: true, children: [ ListView.separated( - separatorBuilder: (context, index) => const SizedBox(height: 10), + separatorBuilder: + (context, index) => + const SizedBox(height: 10), shrinkWrap: true, physics: const NeverScrollableScrollPhysics(), itemCount: currentStateModel.messages.length, itemBuilder: (context, index) { - final message = currentStateModel.messages[index]; + final message = + currentStateModel.messages[index]; return MessageWidget( message: message, currentUser: currentUser, @@ -149,9 +152,7 @@ class _ChatScreenUIState extends State<_ChatScreenUI> { ], ), ), - BottomChatWidget( - messageController: _messageController, - ), + BottomChatWidget(messageController: _messageController), if (currentStateModel.showEmojiPicker) EmojiPickerHelper( messageController: _messageController, diff --git a/lib/src/features/chat_screen/view/message_widget/loading_messages_widget.dart b/lib/src/features/chat_screen/view/message_widget/loading_messages_widget.dart index 4035954..ecab3a1 100644 --- a/lib/src/features/chat_screen/view/message_widget/loading_messages_widget.dart +++ b/lib/src/features/chat_screen/view/message_widget/loading_messages_widget.dart @@ -23,12 +23,8 @@ class _LoadingMessagesWidgetState extends State { _appThemeBloc = DependenciesScope.of(context, listen: false).appThemeBloc; final tempWidgets = [ - _RightWidget( - appThemeBloc: _appThemeBloc, - ), - _LeftWidget( - appThemeBloc: _appThemeBloc, - ), + _RightWidget(appThemeBloc: _appThemeBloc), + _LeftWidget(appThemeBloc: _appThemeBloc), ]; _widgets = List.generate(15, (index) => tempWidgets[rnd.nextInt(2)]); @@ -63,7 +59,10 @@ class _RightWidget extends StatelessWidget { mainAxisSize: MainAxisSize.min, children: [ Container( - margin: EdgeInsets.only(left: MediaQuery.of(context).size.width / 4, right: 10), + margin: EdgeInsets.only( + left: MediaQuery.of(context).size.width / 4, + right: 10, + ), padding: const EdgeInsets.symmetric(horizontal: 15, vertical: 10), decoration: const BoxDecoration( color: Colors.blue, @@ -75,12 +74,7 @@ class _RightWidget extends StatelessWidget { ), child: const Column( crossAxisAlignment: CrossAxisAlignment.end, - children: [ - SizedBox( - height: 50, - width: 100, - ), - ], + children: [SizedBox(height: 50, width: 100)], ), ), ], @@ -104,7 +98,10 @@ class _LeftWidget extends StatelessWidget { mainAxisSize: MainAxisSize.min, children: [ Container( - margin: EdgeInsets.only(right: MediaQuery.of(context).size.width / 4, left: 10), + margin: EdgeInsets.only( + right: MediaQuery.of(context).size.width / 4, + left: 10, + ), padding: const EdgeInsets.symmetric(horizontal: 15, vertical: 10), decoration: const BoxDecoration( color: Colors.blue, @@ -116,12 +113,7 @@ class _LeftWidget extends StatelessWidget { ), child: const Column( crossAxisAlignment: CrossAxisAlignment.start, - children: [ - SizedBox( - height: 50, - width: 100, - ), - ], + children: [SizedBox(height: 50, width: 100)], ), ), ], diff --git a/lib/src/features/chat_screen/view/message_widget/message_widget.dart b/lib/src/features/chat_screen/view/message_widget/message_widget.dart index 74a2049..2b5d829 100644 --- a/lib/src/features/chat_screen/view/message_widget/message_widget.dart +++ b/lib/src/features/chat_screen/view/message_widget/message_widget.dart @@ -42,7 +42,10 @@ class _LeftSide extends StatelessWidget { mainAxisSize: MainAxisSize.min, children: [ Container( - margin: EdgeInsets.only(right: MediaQuery.of(context).size.width / 4, left: 10), + margin: EdgeInsets.only( + right: MediaQuery.of(context).size.width / 4, + left: 10, + ), padding: const EdgeInsets.symmetric(horizontal: 15, vertical: 10), decoration: const BoxDecoration( color: Colors.blue, @@ -63,10 +66,7 @@ class _LeftSide extends StatelessWidget { fontWeight: FontWeight.w400, ), ), - _MessageTime( - message: message, - showSeen: false, - ), + _MessageTime(message: message, showSeen: false), ], ), ), @@ -87,7 +87,10 @@ class _RightSide extends StatelessWidget { mainAxisSize: MainAxisSize.min, children: [ Container( - margin: EdgeInsets.only(left: MediaQuery.of(context).size.width / 4, right: 10), + margin: EdgeInsets.only( + left: MediaQuery.of(context).size.width / 4, + right: 10, + ), padding: const EdgeInsets.symmetric(horizontal: 15, vertical: 10), decoration: const BoxDecoration( color: Colors.blue, @@ -102,10 +105,7 @@ class _RightSide extends StatelessWidget { children: [ Text( "${message?.message}", - style: GoogleFonts.aBeeZee( - fontSize: 13, - color: Colors.white, - ), + style: GoogleFonts.aBeeZee(fontSize: 13, color: Colors.white), ), _MessageTime(message: message), ], @@ -120,10 +120,7 @@ class _MessageTime extends StatelessWidget { final bool showSeen; final ChatMessageModel? message; - const _MessageTime({ - required this.message, - this.showSeen = true, - }); + const _MessageTime({required this.message, this.showSeen = true}); @override Widget build(BuildContext context) { @@ -131,7 +128,9 @@ class _MessageTime extends StatelessWidget { mainAxisSize: MainAxisSize.min, children: [ Text( - DateFormat.yMMMd().format(DateTime.parse(message?.createdAt ?? Constants.tempDateTime)), + DateFormat.yMMMd().format( + DateTime.parse(message?.createdAt ?? Constants.tempDateTime), + ), style: GoogleFonts.aBeeZee( fontSize: 9, height: 0, @@ -147,19 +146,11 @@ class _MessageTime extends StatelessWidget { child: Stack( fit: StackFit.passthrough, children: [ - const Icon( - Icons.check, - size: 13, - color: Colors.white, - ), + const Icon(Icons.check, size: 13, color: Colors.white), if (message?.messageSeenAt != null) const Positioned( left: 5, - child: Icon( - Icons.check, - size: 13, - color: Colors.white, - ), + child: Icon(Icons.check, size: 13, color: Colors.white), ), ], ), diff --git a/lib/src/features/chats/bloc/chats_bloc.dart b/lib/src/features/chats/bloc/chats_bloc.dart index 2a180de..d616c63 100644 --- a/lib/src/features/chats/bloc/chats_bloc.dart +++ b/lib/src/features/chats/bloc/chats_bloc.dart @@ -17,24 +17,30 @@ part 'chats_bloc.freezed.dart'; @immutable @freezed sealed class ChatsEvents with _$ChatsEvents { - const factory ChatsEvents.getUserChatsEvent({@Default(false) bool refresh}) = _Chats$GetUserEvent; + const factory ChatsEvents.getUserChatsEvent({@Default(false) bool refresh}) = + _Chats$GetUserEvent; - const factory ChatsEvents.chatListenerInitialEvent() = _Chats$ListenerInitialEvent; + const factory ChatsEvents.chatListenerInitialEvent() = + _Chats$ListenerInitialEvent; - const factory ChatsEvents.chatListenerEvent(final ChatModel? chatModel) = _Chat$ListenerEvent; + const factory ChatsEvents.chatListenerEvent(final ChatModel? chatModel) = + _Chat$ListenerEvent; - const factory ChatsEvents.changeToLoadingState() = _Chats$ChangeToLoadingStateEvent; + const factory ChatsEvents.changeToLoadingState() = + _Chats$ChangeToLoadingStateEvent; } @immutable @freezed sealed class ChatsStates with _$ChatsStates { - const factory ChatsStates.initial(final ChatsStateModel chatsStateModel) = Chats$InitialState; + const factory ChatsStates.initial(final ChatsStateModel chatsStateModel) = + Chats$InitialState; const factory ChatsStates.inProgress(final ChatsStateModel chatsStateModel) = Chats$InProgressState; - const factory ChatsStates.error(final ChatsStateModel chatsStateModel) = Chats$ErrorState; + const factory ChatsStates.error(final ChatsStateModel chatsStateModel) = + Chats$ErrorState; const factory ChatsStates.successful(final ChatsStateModel chatsStateModel) = Chats$SuccessfulState; @@ -58,16 +64,17 @@ class ChatsBloc extends Bloc { required final PusherChannelsOptions pusherChannelsOptions, required final Logger logger, required ChatsStates initialState, - }) : _chatsRepo = chatsRepo, - _currentUser = currentUser, - _pusherChannelsOptions = pusherChannelsOptions, - _logger = logger, - super(initialState) { + }) : _chatsRepo = chatsRepo, + _currentUser = currentUser, + _pusherChannelsOptions = pusherChannelsOptions, + _logger = logger, + super(initialState) { // on( (event, emit) => event.map( getUserChatsEvent: (event) => _getUserChatsEvent(event, emit), - chatListenerInitialEvent: (event) => _chatListenerInitialEvent(event, emit), + chatListenerInitialEvent: + (event) => _chatListenerInitialEvent(event, emit), chatListenerEvent: (event) => _chatListenerEvent(event, emit), changeToLoadingState: (event) => _changeToLoadingState(event, emit), ), @@ -87,7 +94,10 @@ class ChatsBloc extends Bloc { chats: await _chatsRepo.chats(), ); - _logger.log(Level.debug, "chat length is: ${currentStateModel.chats.length}"); + _logger.log( + Level.debug, + "chat length is: ${currentStateModel.chats.length}", + ); emit(ChatsStates.successful(currentStateModel)); } catch (e) { @@ -103,7 +113,8 @@ class ChatsBloc extends Bloc { try { if (_channelSubscription != null) return; - final channelName = "${Constants.channelNotifyOfUserName}${_currentUser?.id}"; + final channelName = + "${Constants.channelNotifyOfUserName}${_currentUser?.id}"; _logger.log(Level.debug, "current whole channel listeners: $channelName"); @@ -114,20 +125,20 @@ class ChatsBloc extends Bloc { final chatChannel = _pusherClientService?.publicChannel(channelName); - _channelSubscriptionInformation = _pusherClientService?.onConnectionEstablished.listen((e) { - chatChannel?.subscribeIfNotUnsubscribed(); - }); + _channelSubscriptionInformation = _pusherClientService + ?.onConnectionEstablished + .listen((e) { + chatChannel?.subscribeIfNotUnsubscribed(); + }); await _pusherClientService?.connect(); _channelSubscription = chatChannel ?.bind(Constants.channelNotifyOfUserEventName) .transform(ChatsStreamTransformers(logger: _logger)) - .listen( - (chatModel) { - add(ChatsEvents.chatListenerEvent(chatModel)); - }, - ); + .listen((chatModel) { + add(ChatsEvents.chatListenerEvent(chatModel)); + }); } catch (e) { _logger.log(Level.debug, "current whole channel listeners error is: $e"); } @@ -138,10 +149,7 @@ class ChatsBloc extends Bloc { Emitter emit, ) async { try { - _logger.log( - Level.debug, - "${event.chatModel}", - ); + _logger.log(Level.debug, "${event.chatModel}"); // debugPrint("chat room decoded data: ${jsonDecode(chat.videoChatRoom?.offer ?? '')}"); @@ -197,13 +205,12 @@ class ChatsBloc extends Bloc { final List resultChats = List.of(currentChats); - final convertedToModelChat = _removeCurrentUserFromParticipants( - chat, - user, - ); + final convertedToModelChat = _removeCurrentUserFromParticipants(chat, user); final chatIndex = resultChats.indexWhere( - (e) => e.id == convertedToModelChat.id && e.uuid == convertedToModelChat.uuid, + (e) => + e.id == convertedToModelChat.id && + e.uuid == convertedToModelChat.uuid, ); if (chatIndex != -1) { @@ -217,7 +224,10 @@ class ChatsBloc extends Bloc { return resultChats; } - ChatModel _removeCurrentUserFromParticipants(ChatModel chatModel, UserModel? user) { + ChatModel _removeCurrentUserFromParticipants( + ChatModel chatModel, + UserModel? user, + ) { final data = List.from( chatModel.participants ?? [], ); diff --git a/lib/src/features/chats/bloc/state_model/chats_state_model.dart b/lib/src/features/chats/bloc/state_model/chats_state_model.dart index 8a2bdd0..2714397 100644 --- a/lib/src/features/chats/bloc/state_model/chats_state_model.dart +++ b/lib/src/features/chats/bloc/state_model/chats_state_model.dart @@ -3,30 +3,28 @@ import 'package:yahay/src/core/models/chats_model/chat_model.dart'; class ChatsStateModel { final List chats; - const ChatsStateModel({ - required this.chats, - }); + const ChatsStateModel({required this.chats}); factory ChatsStateModel.idle() => const ChatsStateModel(chats: []); @override bool operator ==(Object other) => identical(this, other) || - (other is ChatsStateModel && runtimeType == other.runtimeType && chats == other.chats); + (other is ChatsStateModel && + runtimeType == other.runtimeType && + chats == other.chats); @override int get hashCode => chats.hashCode; @override String toString() { - return 'ChatsStateModel{' ' chats: $chats,' '}'; + return 'ChatsStateModel{' + ' chats: $chats,' + '}'; } - ChatsStateModel copyWith({ - List? chats, - }) { - return ChatsStateModel( - chats: chats ?? this.chats, - ); + ChatsStateModel copyWith({List? chats}) { + return ChatsStateModel(chats: chats ?? this.chats); } } diff --git a/lib/src/features/chats/bloc/stream_transformers/chats_stream_transformers.dart b/lib/src/features/chats/bloc/stream_transformers/chats_stream_transformers.dart index e0a7bfb..ffeebcf 100644 --- a/lib/src/features/chats/bloc/stream_transformers/chats_stream_transformers.dart +++ b/lib/src/features/chats/bloc/stream_transformers/chats_stream_transformers.dart @@ -5,7 +5,8 @@ import 'package:dart_pusher_channels/dart_pusher_channels.dart'; import 'package:logger/logger.dart'; import 'package:yahay/src/core/models/chats_model/chat_model.dart'; -class ChatsStreamTransformers extends StreamTransformerBase { +class ChatsStreamTransformers + extends StreamTransformerBase { // ChatsStreamTransformers({required final Logger logger}) : _logger = logger; @@ -24,14 +25,12 @@ class ChatsStreamTransformers extends StreamTransformerBase json = data is String - ? jsonDecode(data) - : data is Map + final Map json = + data is String + ? jsonDecode(data) + : data is Map ? data : {}; diff --git a/lib/src/features/chats/data/sources/chats_data_source/impl/chats_data_source_impl.dart b/lib/src/features/chats/data/sources/chats_data_source/impl/chats_data_source_impl.dart index 8df88ac..adf586e 100644 --- a/lib/src/features/chats/data/sources/chats_data_source/impl/chats_data_source_impl.dart +++ b/lib/src/features/chats/data/sources/chats_data_source/impl/chats_data_source_impl.dart @@ -6,9 +6,8 @@ import 'package:yahay/src/features/chats/data/sources/chats_data_source/chats_da class ChatsDataSourceImpl implements ChatsDataSource { // - ChatsDataSourceImpl({ - required final RestClientBase restClientBase, - }) : _restClientBase = restClientBase; + ChatsDataSourceImpl({required final RestClientBase restClientBase}) + : _restClientBase = restClientBase; final RestClientBase _restClientBase; @@ -21,7 +20,9 @@ class ChatsDataSourceImpl implements ChatsDataSource { if (response == null) return []; - if (!response.containsKey(HttpServerResponses.serverSuccessResponse)) return []; + if (!response.containsKey(HttpServerResponses.serverSuccessResponse)) { + return []; + } final List listD = response.getNested(['chats']); diff --git a/lib/src/features/chats/view/chat_widget/chat_loading_widget.dart b/lib/src/features/chats/view/chat_widget/chat_loading_widget.dart index cbb60e2..9c2df90 100644 --- a/lib/src/features/chats/view/chat_widget/chat_loading_widget.dart +++ b/lib/src/features/chats/view/chat_widget/chat_loading_widget.dart @@ -33,10 +33,7 @@ class _ChatLoadingWidgetState extends State { return IntrinsicHeight( child: Row( children: [ - const CircleAvatar( - radius: 30, - backgroundColor: Colors.white, - ), + const CircleAvatar(radius: 30, backgroundColor: Colors.white), const SizedBox(width: 10), Expanded( child: Column( diff --git a/lib/src/features/chats/view/chat_widget/chat_widget.dart b/lib/src/features/chats/view/chat_widget/chat_widget.dart index 6ec583f..8ef2ba4 100644 --- a/lib/src/features/chats/view/chat_widget/chat_widget.dart +++ b/lib/src/features/chats/view/chat_widget/chat_widget.dart @@ -11,22 +11,14 @@ import 'package:yahay/src/core/ui_kit/splash_button_clicker.dart'; class ChatWidget extends StatelessWidget { final ChatModel? chat; - const ChatWidget({ - super.key, - required this.chat, - }); + const ChatWidget({super.key, required this.chat}); @override Widget build(BuildContext context) { return SplashButtonClicker( splashColor: Colors.green.shade100, onTap: () { - AutoRouter.of(context).push( - ChatRoute( - chat: chat, - user: null, - ), - ); + AutoRouter.of(context).push(ChatRoute(chat: chat, user: null)); }, child: IntrinsicHeight( child: Row( @@ -52,16 +44,11 @@ class ChatWidget extends StatelessWidget { if (chat?.videoChatStreaming ?? false) IconButton( onPressed: () { - AutoRouter.of(context).push( - VideoChatFeatureRoute( - chat: chat, - ), - ); + AutoRouter.of( + context, + ).push(VideoChatFeatureRoute(chat: chat)); }, - icon: const Icon( - CupertinoIcons.videocam, - color: Colors.green, - ), + icon: const Icon(CupertinoIcons.videocam, color: Colors.green), ), ], ), @@ -73,9 +60,7 @@ class ChatWidget extends StatelessWidget { class _ChatMainImage extends StatelessWidget { final ChatModel? chat; - const _ChatMainImage({ - required this.chat, - }); + const _ChatMainImage({required this.chat}); @override Widget build(BuildContext context) { @@ -125,28 +110,20 @@ class _ChatImageBuilder extends StatelessWidget { class _ChatName extends StatelessWidget { final ChatModel? chat; - const _ChatName({ - required this.chat, - }); + const _ChatName({required this.chat}); @override Widget build(BuildContext context) { if ((chat?.participants?.length ?? 0) > 1) { return Text( chat?.name ?? '-', - style: GoogleFonts.aBeeZee( - fontWeight: FontWeight.bold, - fontSize: 18, - ), + style: GoogleFonts.aBeeZee(fontWeight: FontWeight.bold, fontSize: 18), ); } else if ((chat?.participants?.length ?? 0) == 1) { final user = chat?.participants?.first.user; return Text( user?.name ?? user?.email ?? '-', - style: GoogleFonts.aBeeZee( - fontWeight: FontWeight.bold, - fontSize: 18, - ), + style: GoogleFonts.aBeeZee(fontWeight: FontWeight.bold, fontSize: 18), ); } else { return const Text(""); diff --git a/lib/src/features/chats/view/chats_appbar/chats_appbar.dart b/lib/src/features/chats/view/chats_appbar/chats_appbar.dart index f53e5f9..0d3a1ac 100644 --- a/lib/src/features/chats/view/chats_appbar/chats_appbar.dart +++ b/lib/src/features/chats/view/chats_appbar/chats_appbar.dart @@ -10,27 +10,19 @@ class ChatsAppbar extends StatelessWidget { @override Widget build(BuildContext context) { return AppBar( - title: Text( - "Chats", - style: GoogleFonts.aBeeZee(), - ), + title: Text("Chats", style: GoogleFonts.aBeeZee()), centerTitle: true, scrolledUnderElevation: 0.0, leading: IconButton( - onPressed: () => OpenSearchContactsPopup.openSearchContactsPopup(context), + onPressed: + () => OpenSearchContactsPopup.openSearchContactsPopup(context), icon: const Icon(Icons.person_add_alt), ), actions: [ + IconButton(onPressed: () {}, icon: const Icon(CupertinoIcons.search)), IconButton( onPressed: () {}, - icon: const Icon(CupertinoIcons.search), - ), - IconButton( - onPressed: () {}, - icon: const FaIcon( - FontAwesomeIcons.gear, - size: 20, - ), + icon: const FaIcon(FontAwesomeIcons.gear, size: 20), ), ], ); diff --git a/lib/src/features/chats/view/chats_page.dart b/lib/src/features/chats/view/chats_page.dart index cac1032..db27707 100644 --- a/lib/src/features/chats/view/chats_page.dart +++ b/lib/src/features/chats/view/chats_page.dart @@ -34,15 +34,15 @@ class _ChatsPageState extends State { child: const ChatsAppbar(), ), body: RefreshIndicator( - onRefresh: () async => _chatsBloc?.add(const ChatsEvents.getUserChatsEvent(refresh: true)), + onRefresh: + () async => _chatsBloc?.add( + const ChatsEvents.getUserChatsEvent(refresh: true), + ), child: ListView( physics: const AlwaysScrollableScrollPhysics(), padding: const EdgeInsets.all(8), children: [ - SearchWidget( - value: (String value) {}, - onDispose: () {}, - ), + SearchWidget(value: (String value) {}, onDispose: () {}), BlocBuilder( bloc: _chatsBloc, builder: (context, state) { @@ -56,7 +56,8 @@ class _ChatsPageState extends State { case Chats$SuccessfulState(): final currentStateModel = state.chatsStateModel; return ListView.separated( - separatorBuilder: (context, index) => const SizedBox(height: 15), + separatorBuilder: + (context, index) => const SizedBox(height: 15), shrinkWrap: true, physics: const NeverScrollableScrollPhysics(), itemCount: currentStateModel.chats.length, diff --git a/lib/src/features/home_page.dart b/lib/src/features/home_page.dart index c819533..4e74ff2 100644 --- a/lib/src/features/home_page.dart +++ b/lib/src/features/home_page.dart @@ -41,26 +41,17 @@ class _HomePageState extends State { _screens = [ const BottomNavbarItem( screen: ContactsPage(), - icon: Icon( - Icons.people_outline, - size: 28, - ), + icon: Icon(Icons.people_outline, size: 28), label: Constants.contacts, ), const BottomNavbarItem( screen: ChatsPage(), - icon: Icon( - CupertinoIcons.chat_bubble_2, - size: 28, - ), + icon: Icon(CupertinoIcons.chat_bubble_2, size: 28), label: Constants.chats, ), const BottomNavbarItem( screen: ProfilePage(), - icon: Icon( - Icons.person, - size: 28, - ), + icon: Icon(Icons.person, size: 28), label: Constants.profile, ), ]; @@ -89,14 +80,13 @@ class _HomePageState extends State { onTap: (int index) => setState(() => _index = index), unselectedLabelStyle: GoogleFonts.aBeeZee(), selectedLabelStyle: GoogleFonts.aBeeZee(), - items: _screens - .map( - (e) => BottomNavigationBarItem( - icon: e.icon, - label: e.label, - ), - ) - .toList(), + items: + _screens + .map( + (e) => + BottomNavigationBarItem(icon: e.icon, label: e.label), + ) + .toList(), ), body: _screens[_index].screen, ); diff --git a/lib/src/features/initialization/logic/app_runner.dart b/lib/src/features/initialization/logic/app_runner.dart index db266a2..5584f30 100644 --- a/lib/src/features/initialization/logic/app_runner.dart +++ b/lib/src/features/initialization/logic/app_runner.dart @@ -22,9 +22,10 @@ import 'package:bloc_concurrency/bloc_concurrency.dart' as concurrency; class AppRunner with FolderCreator { Future initialize() async { - final Logger logger = AppLoggerFactory( - logFilter: kReleaseMode ? NoOpLogFilter() : DevelopmentFilter(), - ).create(); + final Logger logger = + AppLoggerFactory( + logFilter: kReleaseMode ? NoOpLogFilter() : DevelopmentFilter(), + ).create(); await runZonedGuarded( () async { @@ -55,33 +56,37 @@ class AppRunner with FolderCreator { ); FlutterError.onError = (errorDetails) { - FirebaseCrashlytics.instance.recordFlutterFatalError(errorDetails); + FirebaseCrashlytics.instance.recordFlutterFatalError( + errorDetails, + ); }; PlatformDispatcher.instance.onError = (error, stack) { - FirebaseCrashlytics.instance.recordError(error, stack, fatal: true); + FirebaseCrashlytics.instance.recordError( + error, + stack, + fatal: true, + ); return true; }; await createFolders(sharedPreferences); - final compositionRoot = await CompositionRoot( - logger: logger, - sharedPreferHelper: sharedPreferences, - restClientBase: restClientBase, - ).create(); + final compositionRoot = + await CompositionRoot( + logger: logger, + sharedPreferHelper: sharedPreferences, + restClientBase: restClientBase, + ).create(); if (kDebugMode) { await DebugImageCreatorInAppsFolder( - sharedPreferHelper: compositionRoot.dependencies.sharedPreferHelper, + sharedPreferHelper: + compositionRoot.dependencies.sharedPreferHelper, ).createImagesInAppsFolder(); } - runApp( - RootContext( - compositionResult: compositionRoot, - ), - ); + runApp(RootContext(compositionResult: compositionRoot)); } catch (error) { // } finally { @@ -92,19 +97,15 @@ class AppRunner with FolderCreator { await init(); }, (error, trace) async { - logger.log( - Level.error, - "Zone error", - error: error, - stackTrace: trace, - ); - final IErrorReporter errorReporter = kReleaseMode - ? FirebaseErrorReporter( - exception: error, - stackTrace: trace, - firebaseCrashlytics: FirebaseCrashlytics.instance, - ) - : NoOpErrorReporter(); + logger.log(Level.error, "Zone error", error: error, stackTrace: trace); + final IErrorReporter errorReporter = + kReleaseMode + ? FirebaseErrorReporter( + exception: error, + stackTrace: trace, + firebaseCrashlytics: FirebaseCrashlytics.instance, + ) + : NoOpErrorReporter(); await errorReporter.report(); }, diff --git a/lib/src/features/initialization/logic/composition_root/composition_root.dart b/lib/src/features/initialization/logic/composition_root/composition_root.dart index 01361db..9c1a80d 100644 --- a/lib/src/features/initialization/logic/composition_root/composition_root.dart +++ b/lib/src/features/initialization/logic/composition_root/composition_root.dart @@ -19,9 +19,9 @@ final class CompositionRoot extends AsyncFactory { required Logger logger, required SharedPreferHelper sharedPreferHelper, required RestClientBase restClientBase, - }) : _logger = logger, - _sharedPreferHelper = sharedPreferHelper, - _restClientBase = restClientBase; + }) : _logger = logger, + _sharedPreferHelper = sharedPreferHelper, + _restClientBase = restClientBase; final Logger _logger; final SharedPreferHelper _sharedPreferHelper; @@ -33,11 +33,12 @@ final class CompositionRoot extends AsyncFactory { _logger.log(Level.info, 'Initializing dependencies...'); - final dependencyContainer = await DependencyContainerFactory( - logger: _logger, - sharedPreferHelper: _sharedPreferHelper, - restClientBase: _restClientBase, - ).create(); + final dependencyContainer = + await DependencyContainerFactory( + logger: _logger, + sharedPreferHelper: _sharedPreferHelper, + restClientBase: _restClientBase, + ).create(); stopWatch.stop(); _logger.log( @@ -55,14 +56,15 @@ class CompositionResult { CompositionResult(this.dependencies); } -final class DependencyContainerFactory extends AsyncFactory { +final class DependencyContainerFactory + extends AsyncFactory { DependencyContainerFactory({ required Logger logger, required SharedPreferHelper sharedPreferHelper, required RestClientBase restClientBase, - }) : _logger = logger, - _sharedPreferHelper = sharedPreferHelper, - _restClientBase = restClientBase; + }) : _logger = logger, + _sharedPreferHelper = sharedPreferHelper, + _restClientBase = restClientBase; final Logger _logger; final SharedPreferHelper _sharedPreferHelper; @@ -70,21 +72,23 @@ final class DependencyContainerFactory extends AsyncFactory @override Future create() async { - final authBloc = AuthorizationBlocFactory( - googleSignIn: GoogleSignIn(), - facebookAuth: FacebookAuth.instance, - sharedPreferHelper: _sharedPreferHelper, - logger: _logger, - restClientBase: _restClientBase, - ).create(); + final authBloc = + AuthorizationBlocFactory( + googleSignIn: GoogleSignIn(), + facebookAuth: FacebookAuth.instance, + sharedPreferHelper: _sharedPreferHelper, + logger: _logger, + restClientBase: _restClientBase, + ).create(); final cameraHelperService = CameraHelperService(); await cameraHelperService.initCameras(); - final addContactBloc = AddContactBlocFactory( - logger: _logger, - restClientBase: _restClientBase, - ).create(); + final addContactBloc = + AddContactBlocFactory( + logger: _logger, + restClientBase: _restClientBase, + ).create(); final pusherClientService = PusherClientService(); diff --git a/lib/src/features/initialization/logic/composition_root/factories/add_contact_bloc_factory.dart b/lib/src/features/initialization/logic/composition_root/factories/add_contact_bloc_factory.dart index df1e632..64744b2 100644 --- a/lib/src/features/initialization/logic/composition_root/factories/add_contact_bloc_factory.dart +++ b/lib/src/features/initialization/logic/composition_root/factories/add_contact_bloc_factory.dart @@ -12,8 +12,8 @@ final class AddContactBlocFactory extends Factory { AddContactBlocFactory({ required final Logger logger, required final RestClientBase restClientBase, - }) : _logger = logger, - _restClientBase = restClientBase; + }) : _logger = logger, + _restClientBase = restClientBase; final Logger _logger; final RestClientBase _restClientBase; diff --git a/lib/src/features/initialization/logic/composition_root/factories/authorization_bloc_factory.dart b/lib/src/features/initialization/logic/composition_root/factories/authorization_bloc_factory.dart index 1f6c707..fde8049 100644 --- a/lib/src/features/initialization/logic/composition_root/factories/authorization_bloc_factory.dart +++ b/lib/src/features/initialization/logic/composition_root/factories/authorization_bloc_factory.dart @@ -23,11 +23,11 @@ final class AuthorizationBlocFactory extends Factory { required final SharedPreferHelper sharedPreferHelper, required final Logger logger, required final RestClientBase restClientBase, - }) : _googleSignIn = googleSignIn, - _facebookAuth = facebookAuth, - _sharedPreferHelper = sharedPreferHelper, - _logger = logger, - _restClientBase = restClientBase; + }) : _googleSignIn = googleSignIn, + _facebookAuth = facebookAuth, + _sharedPreferHelper = sharedPreferHelper, + _logger = logger, + _restClientBase = restClientBase; final GoogleSignIn _googleSignIn; final FacebookAuth _facebookAuth; @@ -37,26 +37,29 @@ final class AuthorizationBlocFactory extends Factory { @override AuthBloc create() { - final LaravelAuthDataSource laravelAuthDataSource = LaravelAuthDataSourceImpl( - sharedPreferences: _sharedPreferHelper, - restClientBase: _restClientBase, - screenMessaging: ScreenMessaging.instance, - logger: _logger, - ); - - final OtherAuthorizationDatasource otherAuthorizationDatasource = OtherAuthorizationImpl( - googleSignIn: _googleSignIn, - facebookAuth: _facebookAuth, - sharedPreferHelper: _sharedPreferHelper, - restClientBase: _restClientBase, - ); + final LaravelAuthDataSource laravelAuthDataSource = + LaravelAuthDataSourceImpl( + sharedPreferences: _sharedPreferHelper, + restClientBase: _restClientBase, + screenMessaging: ScreenMessaging.instance, + logger: _logger, + ); - final AuthorizationRepo authorizationRepo = AuthorizationRepoImpl(laravelAuthDataSource); + final OtherAuthorizationDatasource otherAuthorizationDatasource = + OtherAuthorizationImpl( + googleSignIn: _googleSignIn, + facebookAuth: _facebookAuth, + sharedPreferHelper: _sharedPreferHelper, + restClientBase: _restClientBase, + ); - final OtherAuthorizationRepo otherAuthorizationRepo = OtherAuthorizationRepoImpl( - otherAuthorizationDatasource, + final AuthorizationRepo authorizationRepo = AuthorizationRepoImpl( + laravelAuthDataSource, ); + final OtherAuthorizationRepo otherAuthorizationRepo = + OtherAuthorizationRepoImpl(otherAuthorizationDatasource); + final initialState = AuthStates.initial(AuthStateModel.idle()); return AuthBloc( diff --git a/lib/src/features/initialization/logic/composition_root/factories/chat_screen_bloc_factory.dart b/lib/src/features/initialization/logic/composition_root/factories/chat_screen_bloc_factory.dart index 625d4cc..770622c 100644 --- a/lib/src/features/initialization/logic/composition_root/factories/chat_screen_bloc_factory.dart +++ b/lib/src/features/initialization/logic/composition_root/factories/chat_screen_bloc_factory.dart @@ -20,10 +20,10 @@ final class ChatScreenBlocFactory extends Factory { required final PusherChannelsOptions channelsOptions, required final RestClientBase restClientBase, required final Logger logger, - }) : _user = user, - _channelsOptions = channelsOptions, - _restClientBase = restClientBase, - _logger = logger; + }) : _user = user, + _channelsOptions = channelsOptions, + _restClientBase = restClientBase, + _logger = logger; final UserModel? _user; final PusherChannelsOptions _channelsOptions; @@ -32,13 +32,11 @@ final class ChatScreenBlocFactory extends Factory { @override ChatScreenBloc create() { - final ChatScreenMessageDataSource messageDataSource = ChatScreenMessageDataSourceImpl( - restClientBase: _restClientBase, - ); + final ChatScreenMessageDataSource messageDataSource = + ChatScreenMessageDataSourceImpl(restClientBase: _restClientBase); - final ChatScreenChatDataSource chatScreenChatDataSource = ChatScreenChatDataSourceImpl( - restClientBase: _restClientBase, - ); + final ChatScreenChatDataSource chatScreenChatDataSource = + ChatScreenChatDataSourceImpl(restClientBase: _restClientBase); final ChatScreenRepo chatScreenRepo = ChatScreenRepoImpl(messageDataSource); diff --git a/lib/src/features/initialization/logic/composition_root/factories/chats_bloc_factory.dart b/lib/src/features/initialization/logic/composition_root/factories/chats_bloc_factory.dart index f55f319..7cb4cf8 100644 --- a/lib/src/features/initialization/logic/composition_root/factories/chats_bloc_factory.dart +++ b/lib/src/features/initialization/logic/composition_root/factories/chats_bloc_factory.dart @@ -16,10 +16,10 @@ final class ChatsBlocFactory extends Factory { required final PusherChannelsOptions pusherChannelsOption, required final Logger logger, required final RestClientBase restClientBase, - }) : _currentUser = currentUser, - _pusherChannelsOptions = pusherChannelsOption, - _logger = logger, - _restClientBase = restClientBase; + }) : _currentUser = currentUser, + _pusherChannelsOptions = pusherChannelsOption, + _logger = logger, + _restClientBase = restClientBase; final UserModel? _currentUser; final PusherChannelsOptions _pusherChannelsOptions; diff --git a/lib/src/features/initialization/logic/composition_root/factories/profile_bloc_factory.dart b/lib/src/features/initialization/logic/composition_root/factories/profile_bloc_factory.dart index 92f6468..6dbf988 100644 --- a/lib/src/features/initialization/logic/composition_root/factories/profile_bloc_factory.dart +++ b/lib/src/features/initialization/logic/composition_root/factories/profile_bloc_factory.dart @@ -11,8 +11,8 @@ final class ProfileBlocFactory extends Factory { ProfileBlocFactory({ required final Logger logger, required final RestClientBase restClientBase, - }) : _logger = logger, - _restClientBase = restClientBase; + }) : _logger = logger, + _restClientBase = restClientBase; final Logger _logger; final RestClientBase _restClientBase; @@ -24,7 +24,9 @@ final class ProfileBlocFactory extends Factory { restClientBase: _restClientBase, ); - final IProfileRepository profileRepository = ProfileRepositoryImpl(profileDatasource); + final IProfileRepository profileRepository = ProfileRepositoryImpl( + profileDatasource, + ); // const initialState = ProfileStates.initial(ProfileStateModel()); diff --git a/lib/src/features/initialization/logic/composition_root/factories/telegram_file_picker_bloc_factory.dart b/lib/src/features/initialization/logic/composition_root/factories/telegram_file_picker_bloc_factory.dart index 1ee7f7e..827d615 100644 --- a/lib/src/features/initialization/logic/composition_root/factories/telegram_file_picker_bloc_factory.dart +++ b/lib/src/features/initialization/logic/composition_root/factories/telegram_file_picker_bloc_factory.dart @@ -5,7 +5,8 @@ import 'package:yahay/src/features/telegram_file_picker_feature/bloc/telegram_fi import 'package:yahay/src/features/telegram_file_picker_feature/data/repo/telegram_file_picker_repo_impl.dart'; import 'package:yahay/src/features/telegram_file_picker_feature/domain/repo/telegram_file_picker_repo.dart'; -final class TelegramFilePickerBlocFactory extends Factory { +final class TelegramFilePickerBlocFactory + extends Factory { final CameraHelperService _cameraHelperService; TelegramFilePickerBlocFactory({ @@ -15,7 +16,8 @@ final class TelegramFilePickerBlocFactory extends Factory { required final PusherClientService pusherClientService, required final Logger logger, required final RestClientBase restClientBase, - }) : _user = user, - _pusherClientService = pusherClientService, - _logger = logger, - _restClientBase = restClientBase; + }) : _user = user, + _pusherClientService = pusherClientService, + _logger = logger, + _restClientBase = restClientBase; final UserModel? _user; final PusherClientService _pusherClientService; @@ -28,15 +28,16 @@ final class VideoChatBlocFactory extends Factory { VideoChatBloc create() { // - final VideoChatFeatureDataSource videoChatFeatureDataSource = VideoChatFeatureDataSourceImpl( - restClientBase: _restClientBase, - ); + final VideoChatFeatureDataSource videoChatFeatureDataSource = + VideoChatFeatureDataSourceImpl(restClientBase: _restClientBase); final VideoChatFeatureRepo videoChatFeatureRepo = VideoChatFeatureRepoImpl( videoChatFeatureDataSource, ); - final initialState = VideoChatFeatureStates.initial(VideoChatStateModel.idle()); + final initialState = VideoChatFeatureStates.initial( + VideoChatStateModel.idle(), + ); return VideoChatBloc( iVideoChatFeatureRepo: videoChatFeatureRepo, diff --git a/lib/src/features/initialization/models/dependency_container.dart b/lib/src/features/initialization/models/dependency_container.dart index d1f734f..e2d7171 100644 --- a/lib/src/features/initialization/models/dependency_container.dart +++ b/lib/src/features/initialization/models/dependency_container.dart @@ -49,17 +49,19 @@ class DependencyContainer { }); void initDependenciesAfterAuthorization() { - chatsBloc = ChatsBlocFactory( - currentUser: authBloc.state.authStateModel.user, - pusherChannelsOption: pusherClientService.options, - logger: logger, - restClientBase: restClientBase, - ).create(); + chatsBloc = + ChatsBlocFactory( + currentUser: authBloc.state.authStateModel.user, + pusherChannelsOption: pusherClientService.options, + logger: logger, + restClientBase: restClientBase, + ).create(); - profileBloc = ProfileBlocFactory( - logger: logger, - restClientBase: restClientBase, - ).create(); + profileBloc = + ProfileBlocFactory( + logger: logger, + restClientBase: restClientBase, + ).create(); } } diff --git a/lib/src/features/initialization/widgets/dependencies_scope.dart b/lib/src/features/initialization/widgets/dependencies_scope.dart index 87cd3c9..c15e83f 100644 --- a/lib/src/features/initialization/widgets/dependencies_scope.dart +++ b/lib/src/features/initialization/widgets/dependencies_scope.dart @@ -18,7 +18,10 @@ class DependenciesScope extends InheritedWidget { assert(result != null, 'No DependenciesScope found in context'); return result!.dependencies; } else { - final result = context.getElementForInheritedWidgetOfExactType()?.widget; + final result = + context + .getElementForInheritedWidgetOfExactType() + ?.widget; final checkDep = result is DependenciesScope; assert(checkDep, 'No DependenciesScope found in context'); return (result as DependenciesScope).dependencies; @@ -26,8 +29,6 @@ class DependenciesScope extends InheritedWidget { } @override - bool updateShouldNotify(DependenciesScope oldWidget) => !identical( - dependencies, - oldWidget.dependencies, - ); + bool updateShouldNotify(DependenciesScope oldWidget) => + !identical(dependencies, oldWidget.dependencies); } diff --git a/lib/src/features/initialization/widgets/material_context.dart b/lib/src/features/initialization/widgets/material_context.dart index 8ad630d..727f908 100644 --- a/lib/src/features/initialization/widgets/material_context.dart +++ b/lib/src/features/initialization/widgets/material_context.dart @@ -18,10 +18,7 @@ class MaterialContext extends StatelessWidget { GlobalCupertinoLocalizations.delegate, ], locale: const Locale("en"), - supportedLocales: const [ - Locale("ru"), - Locale("en"), - ], + supportedLocales: const [Locale("ru"), Locale("en")], debugShowCheckedModeBanner: false, theme: themeStates.data, // if you will use the auto_route package in order to navigate between screens without context diff --git a/lib/src/features/initialization/widgets/root_context.dart b/lib/src/features/initialization/widgets/root_context.dart index 0ebbe11..7aa2978 100644 --- a/lib/src/features/initialization/widgets/root_context.dart +++ b/lib/src/features/initialization/widgets/root_context.dart @@ -5,10 +5,7 @@ import 'package:yahay/src/features/initialization/widgets/material_context.dart' class RootContext extends StatelessWidget { // - const RootContext({ - super.key, - required this.compositionResult, - }); + const RootContext({super.key, required this.compositionResult}); final CompositionResult compositionResult; diff --git a/lib/src/features/loading_page.dart b/lib/src/features/loading_page.dart index 3d858fe..3024570 100644 --- a/lib/src/features/loading_page.dart +++ b/lib/src/features/loading_page.dart @@ -19,11 +19,9 @@ class _HomePageState extends State { void _onMessage(String message) { if (!mounted) return; - ScaffoldMessenger.of(context).showSnackBar( - SnackBar( - content: Text(message), - ), - ); + ScaffoldMessenger.of( + context, + ).showSnackBar(SnackBar(content: Text(message))); } @override @@ -33,7 +31,8 @@ class _HomePageState extends State { _authBloc = depContainer.authBloc; _authBloc.add( AuthEvents.checkAuthEvent( - initDependenciesAfterAuthorization: depContainer.initDependenciesAfterAuthorization, + initDependenciesAfterAuthorization: + depContainer.initDependenciesAfterAuthorization, onMessage: _onMessage, ), ); @@ -50,19 +49,13 @@ class _HomePageState extends State { AutoRouter.of(context).replaceAll([const LoginRoute()]); } else if (state is ErrorStateOnAuthStates) { ScaffoldMessenger.of(context).showSnackBar( - const SnackBar( - content: Text(Constants.somethingWentWrong), - ), + const SnackBar(content: Text(Constants.somethingWentWrong)), ); } else { // TODO something on error state } }, - child: const Scaffold( - body: Center( - child: CircularProgressIndicator(), - ), - ), + child: const Scaffold(body: Center(child: CircularProgressIndicator())), ); } } diff --git a/lib/src/features/profile/bloc/profile_bloc.dart b/lib/src/features/profile/bloc/profile_bloc.dart index de1b50f..65f58a5 100644 --- a/lib/src/features/profile/bloc/profile_bloc.dart +++ b/lib/src/features/profile/bloc/profile_bloc.dart @@ -10,23 +10,28 @@ part 'profile_bloc.freezed.dart'; @immutable @freezed sealed class ProfileEvents with _$ProfileEvents { - const factory ProfileEvents.profileLogoutEvent(final void Function() logoutEvent) = - _Profile$LogoutEvent; + const factory ProfileEvents.profileLogoutEvent( + final void Function() logoutEvent, + ) = _Profile$LogoutEvent; } @immutable @freezed class ProfileStates with _$ProfileStates { - const factory ProfileStates.initial(final ProfileStateModel profileStateModel) = - InitialProfileState; + const factory ProfileStates.initial( + final ProfileStateModel profileStateModel, + ) = InitialProfileState; - const factory ProfileStates.inProgress(final ProfileStateModel profileStateModel) = - Profile$InProgressState; + const factory ProfileStates.inProgress( + final ProfileStateModel profileStateModel, + ) = Profile$InProgressState; - const factory ProfileStates.error(final ProfileStateModel profileStateModel) = Profile$ErrorState; + const factory ProfileStates.error(final ProfileStateModel profileStateModel) = + Profile$ErrorState; - const factory ProfileStates.successful(final ProfileStateModel profileStateModel) = - Profile$SuccessfulState; + const factory ProfileStates.successful( + final ProfileStateModel profileStateModel, + ) = Profile$SuccessfulState; } class ProfileBloc extends Bloc { @@ -37,8 +42,8 @@ class ProfileBloc extends Bloc { ProfileBloc({ required final IProfileRepository iProfileRepository, required final ProfileStates initialState, - }) : _iProfileRepository = iProfileRepository, - super(initialState) { + }) : _iProfileRepository = iProfileRepository, + super(initialState) { on( (event, emit) => event.map( profileLogoutEvent: (event) => _profileLogoutEvent(event, emit), diff --git a/lib/src/features/profile/bloc/state_model/profile_state_model.dart b/lib/src/features/profile/bloc/state_model/profile_state_model.dart index 39a6df2..25dde69 100644 --- a/lib/src/features/profile/bloc/state_model/profile_state_model.dart +++ b/lib/src/features/profile/bloc/state_model/profile_state_model.dart @@ -3,9 +3,7 @@ import 'package:yahay/src/core/models/user_model/user_model.dart'; class ProfileStateModel { final UserModel? userModel; - const ProfileStateModel({ - this.userModel, - }); + const ProfileStateModel({this.userModel}); @override bool operator ==(Object other) => @@ -19,14 +17,12 @@ class ProfileStateModel { @override String toString() { - return 'ProfileStateModel{' ' userModel: $userModel,' '}'; + return 'ProfileStateModel{' + ' userModel: $userModel,' + '}'; } - ProfileStateModel copyWith({ - UserModel? userModel, - }) { - return ProfileStateModel( - userModel: userModel ?? this.userModel, - ); + ProfileStateModel copyWith({UserModel? userModel}) { + return ProfileStateModel(userModel: userModel ?? this.userModel); } } diff --git a/lib/src/features/profile/data/profile_datasource.dart b/lib/src/features/profile/data/profile_datasource.dart index d42f6f4..29ef094 100644 --- a/lib/src/features/profile/data/profile_datasource.dart +++ b/lib/src/features/profile/data/profile_datasource.dart @@ -8,8 +8,8 @@ final class ProfileDatasourceImpl implements IProfileDatasource { ProfileDatasourceImpl({ required final Logger logger, required final RestClientBase restClientBase, - }) : _logger = logger, - _restClientBase = restClientBase; + }) : _logger = logger, + _restClientBase = restClientBase; final Logger _logger; final RestClientBase _restClientBase; diff --git a/lib/src/features/profile/data/profile_repository.dart b/lib/src/features/profile/data/profile_repository.dart index 5ec7ac4..c1c25ad 100644 --- a/lib/src/features/profile/data/profile_repository.dart +++ b/lib/src/features/profile/data/profile_repository.dart @@ -8,6 +8,4 @@ final class ProfileRepositoryImpl implements IProfileRepository { ProfileRepositoryImpl(this._iProfileDatasource); final IProfileDatasource _iProfileDatasource; - - } diff --git a/lib/src/features/profile/view/profile_page.dart b/lib/src/features/profile/view/profile_page.dart index 85762a4..4feb7b2 100644 --- a/lib/src/features/profile/view/profile_page.dart +++ b/lib/src/features/profile/view/profile_page.dart @@ -29,25 +29,11 @@ class _ProfilePageState extends State { leadingWidth: 0.0, title: const Text("Profile"), actions: [ - IconButton( - onPressed: () {}, - icon: const Icon( - Icons.qr_code, - ), - ), - IconButton( - onPressed: () {}, - icon: const Icon( - Icons.more_vert, - ), - ), - ], - ), - body: const CustomScrollView( - slivers: [ - + IconButton(onPressed: () {}, icon: const Icon(Icons.qr_code)), + IconButton(onPressed: () {}, icon: const Icon(Icons.more_vert)), ], ), + body: const CustomScrollView(slivers: []), ); } } diff --git a/lib/src/features/profile/view/widgets/profile_header/profile_header_loading_widget.dart b/lib/src/features/profile/view/widgets/profile_header/profile_header_loading_widget.dart index e42e900..0b1b2df 100644 --- a/lib/src/features/profile/view/widgets/profile_header/profile_header_loading_widget.dart +++ b/lib/src/features/profile/view/widgets/profile_header/profile_header_loading_widget.dart @@ -4,10 +4,12 @@ class ProfileHeaderLoadingWidget extends StatefulWidget { const ProfileHeaderLoadingWidget({super.key}); @override - State createState() => _ProfileHeaderLoadingWidgetState(); + State createState() => + _ProfileHeaderLoadingWidgetState(); } -class _ProfileHeaderLoadingWidgetState extends State { +class _ProfileHeaderLoadingWidgetState + extends State { @override Widget build(BuildContext context) { return const Placeholder(); diff --git a/lib/src/features/profile/view/widgets/profile_settings/profile_settings_loading_widget.dart b/lib/src/features/profile/view/widgets/profile_settings/profile_settings_loading_widget.dart index 609c8a9..4727db4 100644 --- a/lib/src/features/profile/view/widgets/profile_settings/profile_settings_loading_widget.dart +++ b/lib/src/features/profile/view/widgets/profile_settings/profile_settings_loading_widget.dart @@ -4,10 +4,12 @@ class ProfileSettingsLoadingWidget extends StatefulWidget { const ProfileSettingsLoadingWidget({super.key}); @override - State createState() => _ProfileSettingsLoadingWidgetState(); + State createState() => + _ProfileSettingsLoadingWidgetState(); } -class _ProfileSettingsLoadingWidgetState extends State { +class _ProfileSettingsLoadingWidgetState + extends State { @override Widget build(BuildContext context) { return const Placeholder(); diff --git a/lib/src/features/telegram_file_picker_feature/bloc/state_model/telegram_file_picker_state_model.dart b/lib/src/features/telegram_file_picker_feature/bloc/state_model/telegram_file_picker_state_model.dart index 1479551..d8ce6d3 100644 --- a/lib/src/features/telegram_file_picker_feature/bloc/state_model/telegram_file_picker_state_model.dart +++ b/lib/src/features/telegram_file_picker_feature/bloc/state_model/telegram_file_picker_state_model.dart @@ -25,7 +25,8 @@ class TelegramFilePickerStateModel { const TelegramFilePickerStateModel({ this.getPathForGettingImagesFrom, - this.filePickerScreenSelectedScreen = TelegramFileFolderEnum.recentDownloadsScreen, + this.filePickerScreenSelectedScreen = + TelegramFileFolderEnum.recentDownloadsScreen, this.openBottomSectionButton = true, required this.galleryPathFiles, required this.galleryPathPagination, @@ -36,7 +37,8 @@ class TelegramFilePickerStateModel { required this.specificFolderFilesPagination, }); - factory TelegramFilePickerStateModel.idle() => const TelegramFilePickerStateModel( + factory TelegramFilePickerStateModel.idle() => + const TelegramFilePickerStateModel( galleryPathFiles: [], galleryPathPagination: [], recentFiles: [], @@ -53,7 +55,8 @@ class TelegramFilePickerStateModel { runtimeType == other.runtimeType && getPathForGettingImagesFrom == other.getPathForGettingImagesFrom && openBottomSectionButton == other.openBottomSectionButton && - filePickerScreenSelectedScreen == other.filePickerScreenSelectedScreen && + filePickerScreenSelectedScreen == + other.filePickerScreenSelectedScreen && galleryPathFiles == other.galleryPathFiles && galleryPathPagination == other.galleryPathPagination && recentFiles == other.recentFiles && @@ -104,16 +107,21 @@ class TelegramFilePickerStateModel { List? specificFolderFilesPagination, }) { return TelegramFilePickerStateModel( - getPathForGettingImagesFrom: getPathForGettingImagesFrom ?? this.getPathForGettingImagesFrom, - openBottomSectionButton: openBottomSectionButton ?? this.openBottomSectionButton, + getPathForGettingImagesFrom: + getPathForGettingImagesFrom ?? this.getPathForGettingImagesFrom, + openBottomSectionButton: + openBottomSectionButton ?? this.openBottomSectionButton, filePickerScreenSelectedScreen: filePickerScreenSelectedScreen ?? this.filePickerScreenSelectedScreen, galleryPathFiles: galleryPathFiles ?? this.galleryPathFiles, - galleryPathPagination: galleryPathPagination ?? this.galleryPathPagination, + galleryPathPagination: + galleryPathPagination ?? this.galleryPathPagination, recentFiles: recentFiles ?? this.recentFiles, - recentFilesPagination: recentFilesPagination ?? this.recentFilesPagination, + recentFilesPagination: + recentFilesPagination ?? this.recentFilesPagination, pickedFiles: pickedFiles ?? this.pickedFiles, - specificFolderFilesAll: specificFolderFilesAll ?? this.specificFolderFilesAll, + specificFolderFilesAll: + specificFolderFilesAll ?? this.specificFolderFilesAll, specificFolderFilesPagination: specificFolderFilesPagination ?? this.specificFolderFilesPagination, ); diff --git a/lib/src/features/telegram_file_picker_feature/bloc/telegram_file_picker_bloc.dart b/lib/src/features/telegram_file_picker_feature/bloc/telegram_file_picker_bloc.dart index 40fa737..3012153 100644 --- a/lib/src/features/telegram_file_picker_feature/bloc/telegram_file_picker_bloc.dart +++ b/lib/src/features/telegram_file_picker_feature/bloc/telegram_file_picker_bloc.dart @@ -29,8 +29,9 @@ sealed class TelegramFilePickerEvents with _$TelegramFilePickerEvents { final TelegramFilePickerStateModel currentStateModel, ) = _JustEmitStateEvent; - const factory TelegramFilePickerEvents.initAllPicturesEvent(final bool clearAll) = - _InitAllPicturesEvent; + const factory TelegramFilePickerEvents.initAllPicturesEvent( + final bool clearAll, + ) = _InitAllPicturesEvent; const factory TelegramFilePickerEvents.changeStateToAllPicturesEvent() = _ChangeStateToAllPicturesEvent; @@ -39,12 +40,15 @@ sealed class TelegramFilePickerEvents with _$TelegramFilePickerEvents { required final bool initFilePickerState, }) = _InitAllFilesEvent; - const factory TelegramFilePickerEvents.changeStateToAllFilesState() = _ChangeStateToAllFilesState; + const factory TelegramFilePickerEvents.changeStateToAllFilesState() = + _ChangeStateToAllFilesState; - const factory TelegramFilePickerEvents.initAllAudioEvent() = _InitAllAudioEvent; + const factory TelegramFilePickerEvents.initAllAudioEvent() = + _InitAllAudioEvent; - const factory TelegramFilePickerEvents.openHideBottomTelegramButtonEvent(final bool value) = - _OpenHideBottomTelegramButtonEvent; + const factory TelegramFilePickerEvents.openHideBottomTelegramButtonEvent( + final bool value, + ) = _OpenHideBottomTelegramButtonEvent; const factory TelegramFilePickerEvents.closePopupEvent() = _ClosePopupEvent; @@ -66,7 +70,8 @@ sealed class TelegramFilePickerEvents with _$TelegramFilePickerEvents { const factory TelegramFilePickerEvents.clearSelectedGalleryFileEvent() = _ClearSelectedGalleryFileEvent; - const factory TelegramFilePickerEvents.recentFilesPaginationEvent() = _RecentFilesPaginationEvent; + const factory TelegramFilePickerEvents.recentFilesPaginationEvent() = + _RecentFilesPaginationEvent; const factory TelegramFilePickerEvents.browseInternalStorageAndSelectFilesEvent() = _BrowseInternalStorageAndSelectFilesEvent; @@ -112,7 +117,8 @@ sealed class TelegramFilePickerStates with _$TelegramFilePickerStates { ) = Picker$AudioFilesState; } -class TelegramFilePickerBloc extends Bloc { +class TelegramFilePickerBloc + extends Bloc { // StreamSubscription? _fileStreamData; @@ -131,39 +137,51 @@ class TelegramFilePickerBloc extends Bloc( (event, emit) => event.map( - justEmitStateEvent: (event) => _emitter( - currentStateModel: event.currentStateModel, - emit: emit, - ), + justEmitStateEvent: + (event) => _emitter( + currentStateModel: event.currentStateModel, + emit: emit, + ), initAllPicturesEvent: (event) => _initAllPictureEvents(event, emit), - changeStateToAllPicturesEvent: (event) => _changeStateToAllPicturesEvent(event, emit), + changeStateToAllPicturesEvent: + (event) => _changeStateToAllPicturesEvent(event, emit), initAllFilesEvent: (event) => _initAllFilesEvent(event, emit), - changeStateToAllFilesState: (event) => _changeStateToAllFilesState(event, emit), + changeStateToAllFilesState: + (event) => _changeStateToAllFilesState(event, emit), initAllAudioEvent: (event) => _initAllAudioEvent(event, emit), - openHideBottomTelegramButtonEvent: (event) => - _openHideBottomTelegramButtonEvent(event, emit), + openHideBottomTelegramButtonEvent: + (event) => _openHideBottomTelegramButtonEvent(event, emit), closePopupEvent: (event) => _closePopupEvent(event, emit), fileStreamHandlerEvent: (event) => _fileStreamHandlerEvent(event, emit), - recentFileStreamHandlerEvent: (event) => _recentFileStreamHandlerEvent(event, emit), - imagesAndVideoPaginationEvent: (event) => _imagesAndVideoPaginationEvent(event, emit), + recentFileStreamHandlerEvent: + (event) => _recentFileStreamHandlerEvent(event, emit), + imagesAndVideoPaginationEvent: + (event) => _imagesAndVideoPaginationEvent(event, emit), selectGalleryFileEvent: (event) => _selectGalleryFileEvent(event, emit), - clearSelectedGalleryFileEvent: (event) => _clearSelectedGalleryFileEvent(event, emit), - recentFilesPaginationEvent: (event) => _recentFilesPaginationEvent(event, emit), - browseInternalStorageAndSelectFilesEvent: (event) => - _browseInternalStorageAndSelectFilesEvent(event, emit), - selectScreenForFilesPickerScreenEvent: (event) => - _selectScreenForFilesPickerScreenEvent(event, emit), - setSpecificFolderPathInOrderToGetDataFromThereEvent: (event) => - _setSpecificFolderPathInOrderToGetDataFromThereEvent(event, emit), - getSpecificFolderDataEvent: (event) => _getSpecificFolderDataEvent(event, emit), - specificFolderDataStreamHandlerEvent: (event) => - _specificFolderDataStreamHandlerEvent(event, emit), - paginateSpecificFolderDataEvent: (event) => _paginateSpecificFolderDataEvent(event, emit), + clearSelectedGalleryFileEvent: + (event) => _clearSelectedGalleryFileEvent(event, emit), + recentFilesPaginationEvent: + (event) => _recentFilesPaginationEvent(event, emit), + browseInternalStorageAndSelectFilesEvent: + (event) => _browseInternalStorageAndSelectFilesEvent(event, emit), + selectScreenForFilesPickerScreenEvent: + (event) => _selectScreenForFilesPickerScreenEvent(event, emit), + setSpecificFolderPathInOrderToGetDataFromThereEvent: + (event) => _setSpecificFolderPathInOrderToGetDataFromThereEvent( + event, + emit, + ), + getSpecificFolderDataEvent: + (event) => _getSpecificFolderDataEvent(event, emit), + specificFolderDataStreamHandlerEvent: + (event) => _specificFolderDataStreamHandlerEvent(event, emit), + paginateSpecificFolderDataEvent: + (event) => _paginateSpecificFolderDataEvent(event, emit), ), ); } @@ -190,26 +208,28 @@ class TelegramFilePickerBloc extends Bloc emit, ) async { - emit(TelegramFilePickerStates.galleryFilePickerState(state.telegramFilePickerStateModel)); + emit( + TelegramFilePickerStates.galleryFilePickerState( + state.telegramFilePickerStateModel, + ), + ); } void _initAllFilesEvent( @@ -270,15 +294,12 @@ class TelegramFilePickerBloc extends Bloc emit, ) async { // await DefaultCacheManager().emptyCache(); - if (state.telegramFilePickerStateModel.galleryPathFiles.firstOrNull?.cameraController != null) { - state.telegramFilePickerStateModel.galleryPathFiles.firstOrNull?.cameraController?.dispose(); + if (state + .telegramFilePickerStateModel + .galleryPathFiles + .firstOrNull + ?.cameraController != + null) { + state + .telegramFilePickerStateModel + .galleryPathFiles + .firstOrNull + ?.cameraController + ?.dispose(); } for (final each in state.telegramFilePickerStateModel.galleryPathFiles) { each.videoPlayerController?.dispose(); } - if (state.telegramFilePickerStateModel.galleryPathPagination.firstOrNull?.cameraController != + if (state + .telegramFilePickerStateModel + .galleryPathPagination + .firstOrNull + ?.cameraController != null) { - state.telegramFilePickerStateModel.galleryPathPagination.firstOrNull?.cameraController + state + .telegramFilePickerStateModel + .galleryPathPagination + .firstOrNull + ?.cameraController ?.dispose(); } - for (final each in state.telegramFilePickerStateModel.galleryPathPagination) { + for (final each + in state.telegramFilePickerStateModel.galleryPathPagination) { each.videoPlayerController?.dispose(); } // state.telegramFilePickerStateModel.clearAllGalleryPath(); @@ -319,12 +359,16 @@ class TelegramFilePickerBloc extends Bloc TelegramFileImageModel(file: File(e.path))).toList(); + final convertedData = + files.map((e) => TelegramFileImageModel(file: File(e.path))).toList(); for (final each in convertedData) { currentStateModel = _removeOrAddEntity( currentStateModel: currentStateModel, @@ -501,7 +548,11 @@ class TelegramFilePickerBloc extends Bloc emit, ) async { - if (state.telegramFilePickerStateModel.getPathForGettingImagesFrom == null && + if (state.telegramFilePickerStateModel.getPathForGettingImagesFrom == + null && !event.getGalleryData) { return; } @@ -522,20 +574,26 @@ class TelegramFilePickerBloc extends Bloc= Constants.perPage) { + if (state.telegramFilePickerStateModel.galleryPathPagination.length >= + Constants.perPage) { return state.telegramFilePickerStateModel; } - final currentGalleryPath = List.of(state.telegramFilePickerStateModel.galleryPathPagination); + final currentGalleryPath = List.of( + state.telegramFilePickerStateModel.galleryPathPagination, + ); currentGalleryPath.add(value); final currentStateModel = state.telegramFilePickerStateModel.copyWith( galleryPathPagination: currentGalleryPath, @@ -632,7 +700,10 @@ class TelegramFilePickerBloc extends Bloc el.uuid == value.uuid); + final findEntity = pickedFiles.firstWhereOrNull( + (el) => el.uuid == value.uuid, + ); if (findEntity != null) { pickedFiles.removeWhere((el) => el.uuid == value.uuid); } else { pickedFiles.add(value); } - currentStateModel = currentStateModel.copyWith( - pickedFiles: pickedFiles, - ); + currentStateModel = currentStateModel.copyWith(pickedFiles: pickedFiles); return currentStateModel; } diff --git a/lib/src/features/telegram_file_picker_feature/data/models/data_models/telegram_file_picker_bottom_button.dart b/lib/src/features/telegram_file_picker_feature/data/models/data_models/telegram_file_picker_bottom_button.dart index c88553d..9b82712 100644 --- a/lib/src/features/telegram_file_picker_feature/data/models/data_models/telegram_file_picker_bottom_button.dart +++ b/lib/src/features/telegram_file_picker_feature/data/models/data_models/telegram_file_picker_bottom_button.dart @@ -6,120 +6,95 @@ import 'package:yahay/src/features/telegram_file_picker_feature/bloc/telegram_fi class TelegramFilePickerBottomButton { final Widget icon; - const TelegramFilePickerBottomButton( - this.icon, - ); + const TelegramFilePickerBottomButton(this.icon); static List listOfBottomButtons({ required final TelegramFilePickerBloc telegramBloc, required void Function() draggableSheetAnimate, - }) => - [ - TelegramFilePickerBottomButton( - Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - GestureDetector( - onTap: () { - telegramBloc.add( - const TelegramFilePickerEvents.changeStateToAllPicturesEvent(), - ); + }) => [ + TelegramFilePickerBottomButton( + Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + GestureDetector( + onTap: () { + telegramBloc.add( + const TelegramFilePickerEvents.changeStateToAllPicturesEvent(), + ); - // telegramBloc.events.add(const InitAllFilesEvent(initFilePickerState: false)); + // telegramBloc.events.add(const InitAllFilesEvent(initFilePickerState: false)); - draggableSheetAnimate(); - }, - child: Container( - width: 60, - height: 60, - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(50), - color: Colors.blue, - ), - child: const Center( - child: Icon( - Icons.image, - color: Colors.white, - ), - ), - ), + draggableSheetAnimate(); + }, + child: Container( + width: 60, + height: 60, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(50), + color: Colors.blue, ), - const SizedBox(height: 10), - Text( - "Gallery", - style: GoogleFonts.aBeeZee( - fontSize: 16, - ), + child: const Center( + child: Icon(Icons.image, color: Colors.white), ), - ], + ), ), - ), - TelegramFilePickerBottomButton( - Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - GestureDetector( - onTap: () { - telegramBloc.add(const TelegramFilePickerEvents.changeStateToAllFilesState()); - draggableSheetAnimate(); - }, - child: Container( - width: 60, - height: 60, - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(50), - color: Colors.blue, - ), - child: const Center( - child: Icon( - Icons.file_open_outlined, - color: Colors.white, - ), - ), - ), + const SizedBox(height: 10), + Text("Gallery", style: GoogleFonts.aBeeZee(fontSize: 16)), + ], + ), + ), + TelegramFilePickerBottomButton( + Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + GestureDetector( + onTap: () { + telegramBloc.add( + const TelegramFilePickerEvents.changeStateToAllFilesState(), + ); + draggableSheetAnimate(); + }, + child: Container( + width: 60, + height: 60, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(50), + color: Colors.blue, ), - const SizedBox(height: 10), - Text( - "File", - style: GoogleFonts.aBeeZee( - fontSize: 16, - ), + child: const Center( + child: Icon(Icons.file_open_outlined, color: Colors.white), ), - ], + ), ), - ), - TelegramFilePickerBottomButton( - Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - GestureDetector( - onTap: () { - draggableSheetAnimate(); - }, - child: Container( - width: 60, - height: 60, - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(50), - color: Colors.blue, - ), - child: const Center( - child: Icon( - Icons.file_open_outlined, - color: Colors.white, - ), - ), - ), + const SizedBox(height: 10), + Text("File", style: GoogleFonts.aBeeZee(fontSize: 16)), + ], + ), + ), + TelegramFilePickerBottomButton( + Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + GestureDetector( + onTap: () { + draggableSheetAnimate(); + }, + child: Container( + width: 60, + height: 60, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(50), + color: Colors.blue, ), - const SizedBox(height: 10), - Text( - "Musics", - style: GoogleFonts.aBeeZee( - fontSize: 16, - ), + child: const Center( + child: Icon(Icons.file_open_outlined, color: Colors.white), ), - ], + ), ), - ), - ]; + const SizedBox(height: 10), + Text("Musics", style: GoogleFonts.aBeeZee(fontSize: 16)), + ], + ), + ), + ]; } diff --git a/lib/src/features/telegram_file_picker_feature/data/models/data_models/telegram_storage_file_picker_data_model.dart b/lib/src/features/telegram_file_picker_feature/data/models/data_models/telegram_storage_file_picker_data_model.dart index f0b683a..2f42d99 100644 --- a/lib/src/features/telegram_file_picker_feature/data/models/data_models/telegram_storage_file_picker_data_model.dart +++ b/lib/src/features/telegram_file_picker_feature/data/models/data_models/telegram_storage_file_picker_data_model.dart @@ -19,63 +19,51 @@ class TelegramStorageFilePickerDataModel { static List data( TelegramFilePickerBloc telegramFilerPickerBloc, - ) => - [ - TelegramStorageFilePickerDataModel( - iconBackgroundColor: Colors.green, - icon: const Icon( - Icons.storage, - color: Colors.white, - size: 30, + ) => [ + TelegramStorageFilePickerDataModel( + iconBackgroundColor: Colors.green, + icon: const Icon(Icons.storage, color: Colors.white, size: 30), + title: "Internal Storage", + content: "Browse your file system", + onTap: () { + telegramFilerPickerBloc.add( + const TelegramFilePickerEvents.browseInternalStorageAndSelectFilesEvent(), + ); + }, + ), + TelegramStorageFilePickerDataModel( + iconBackgroundColor: Colors.blue, + icon: const Icon(Icons.folder, color: Colors.white, size: 30), + title: "Yahay", + content: "Browse the app's folder", + onTap: () async { + telegramFilerPickerBloc.add( + const TelegramFilePickerEvents.selectScreenForFilesPickerScreenEvent( + TelegramFileFolderEnum.browseTheAppsFolder, ), - title: "Internal Storage", - content: "Browse your file system", - onTap: () { - telegramFilerPickerBloc - .add(const TelegramFilePickerEvents.browseInternalStorageAndSelectFilesEvent()); - }, - ), - TelegramStorageFilePickerDataModel( - iconBackgroundColor: Colors.blue, - icon: const Icon( - Icons.folder, - color: Colors.white, - size: 30, + ); + }, + ), + TelegramStorageFilePickerDataModel( + iconBackgroundColor: Colors.amber, + icon: const Icon(Icons.folder, color: Colors.white, size: 30), + title: "Gallery", + content: "To send images without compression", + onTap: () async { + telegramFilerPickerBloc.add( + const TelegramFilePickerEvents.selectScreenForFilesPickerScreenEvent( + TelegramFileFolderEnum.browseTheGalleryFolder, ), - title: "Yahay", - content: "Browse the app's folder", - onTap: () async { - telegramFilerPickerBloc.add( - const TelegramFilePickerEvents.selectScreenForFilesPickerScreenEvent( - TelegramFileFolderEnum.browseTheAppsFolder, - ), - ); - }, - ), - TelegramStorageFilePickerDataModel( - iconBackgroundColor: Colors.amber, - icon: const Icon( - Icons.folder, - color: Colors.white, - size: 30, - ), - title: "Gallery", - content: "To send images without compression", - onTap: () async { - telegramFilerPickerBloc.add( - const TelegramFilePickerEvents.selectScreenForFilesPickerScreenEvent( - TelegramFileFolderEnum.browseTheGalleryFolder, - ), - ); + ); - Future.delayed(const Duration(milliseconds: 300), () { - telegramFilerPickerBloc.add( - const TelegramFilePickerEvents.getSpecificFolderDataEvent( - getGalleryData: true, - ), - ); - }); - }, - ), - ]; + Future.delayed(const Duration(milliseconds: 300), () { + telegramFilerPickerBloc.add( + const TelegramFilePickerEvents.getSpecificFolderDataEvent( + getGalleryData: true, + ), + ); + }); + }, + ), + ]; } diff --git a/lib/src/features/telegram_file_picker_feature/data/models/telegram_path_folder_file_model.dart b/lib/src/features/telegram_file_picker_feature/data/models/telegram_path_folder_file_model.dart index 7d09066..f89622d 100644 --- a/lib/src/features/telegram_file_picker_feature/data/models/telegram_path_folder_file_model.dart +++ b/lib/src/features/telegram_file_picker_feature/data/models/telegram_path_folder_file_model.dart @@ -21,20 +21,17 @@ final class TelegramPathFolderFileModel extends TelegramPathFolderFile { bool? isVideo, String? fileExtension, String? fileName, - }) => - TelegramPathFolderFileModel( - file ?? this.file, - originalPath: originalPath ?? this.originalPath, - isFolder: isFolder ?? this.isFolder, - isImage: isImage ?? this.isImage, - isVideo: isVideo ?? this.isVideo, - fileExtension: fileExtension ?? this.fileExtension, - fileName: fileName ?? this.fileName, - ); + }) => TelegramPathFolderFileModel( + file ?? this.file, + originalPath: originalPath ?? this.originalPath, + isFolder: isFolder ?? this.isFolder, + isImage: isImage ?? this.isImage, + isVideo: isVideo ?? this.isVideo, + fileExtension: fileExtension ?? this.fileExtension, + fileName: fileName ?? this.fileName, + ); - TelegramPathFolderFileModel? fromEntity( - TelegramPathFolderFile? entity, - ) { + TelegramPathFolderFileModel? fromEntity(TelegramPathFolderFile? entity) { if (entity == null) return null; return TelegramPathFolderFileModel( entity.file, diff --git a/lib/src/features/telegram_file_picker_feature/data/repo/telegram_file_picker_repo_impl.dart b/lib/src/features/telegram_file_picker_feature/data/repo/telegram_file_picker_repo_impl.dart index c06e058..b15a3fb 100644 --- a/lib/src/features/telegram_file_picker_feature/data/repo/telegram_file_picker_repo_impl.dart +++ b/lib/src/features/telegram_file_picker_feature/data/repo/telegram_file_picker_repo_impl.dart @@ -8,15 +8,15 @@ class TelegramFilePickerRepoImpl with RecentGalleyFileMixin, DownloadsPathFiles, AppStorageFileMixin implements TelegramFilePickerRepo { @override - Stream getRecentImagesAndVideos({RecentFilesOptions? options}) => - getAllImagesAndVideos(options: options); + Stream getRecentImagesAndVideos({ + RecentFilesOptions? options, + }) => getAllImagesAndVideos(options: options); @override - Stream getRecentFiles() => downloadsPathFilesData(); + Stream getRecentFiles() => + downloadsPathFilesData(); @override - Stream getSpecificFolderData( - String path, - ) => + Stream getSpecificFolderData(String path) => getSpecificFolderDataStream(path); } diff --git a/lib/src/features/telegram_file_picker_feature/domain/entities/telegram_file_image_asset_entity.dart b/lib/src/features/telegram_file_picker_feature/domain/entities/telegram_file_image_asset_entity.dart index fd4c230..769db28 100644 --- a/lib/src/features/telegram_file_picker_feature/domain/entities/telegram_file_image_asset_entity.dart +++ b/lib/src/features/telegram_file_picker_feature/domain/entities/telegram_file_image_asset_entity.dart @@ -2,18 +2,13 @@ base class TelegramFileImageAssetEntity { final String imagePath; final Duration? duration; - TelegramFileImageAssetEntity( - this.imagePath, { - this.duration, - }); + TelegramFileImageAssetEntity(this.imagePath, {this.duration}); factory TelegramFileImageAssetEntity.fromJson(Map json) { return TelegramFileImageAssetEntity(json['path']); } Map toJson() { - return { - "path": imagePath, - }; + return {"path": imagePath}; } } diff --git a/lib/src/features/telegram_file_picker_feature/domain/repo/telegram_file_picker_repo.dart b/lib/src/features/telegram_file_picker_feature/domain/repo/telegram_file_picker_repo.dart index 012697b..d240a6f 100644 --- a/lib/src/features/telegram_file_picker_feature/domain/repo/telegram_file_picker_repo.dart +++ b/lib/src/features/telegram_file_picker_feature/domain/repo/telegram_file_picker_repo.dart @@ -5,7 +5,9 @@ import 'package:yahay/src/features/telegram_file_picker_feature/mixins/recent_fi // classes only can "implement" abstract interface class TelegramFilePickerRepo { // for getting recent files -> images and videos - Stream getRecentImagesAndVideos({RecentFilesOptions? options}); + Stream getRecentImagesAndVideos({ + RecentFilesOptions? options, + }); // for getting all download's path files here Stream getRecentFiles(); diff --git a/lib/src/features/telegram_file_picker_feature/mixins/app_storage_file_mixin/app_storage_file_mixin.dart b/lib/src/features/telegram_file_picker_feature/mixins/app_storage_file_mixin/app_storage_file_mixin.dart index e413aa8..7bfa335 100644 --- a/lib/src/features/telegram_file_picker_feature/mixins/app_storage_file_mixin/app_storage_file_mixin.dart +++ b/lib/src/features/telegram_file_picker_feature/mixins/app_storage_file_mixin/app_storage_file_mixin.dart @@ -19,11 +19,7 @@ mixin class AppStorageFileMixin { final rootIsolateToken = RootIsolateToken.instance!; - Isolate.spawn(_isolateHelper, [ - rootIsolateToken, - mainPort.sendPort, - path, - ]); + Isolate.spawn(_isolateHelper, [rootIsolateToken, mainPort.sendPort, path]); await for (final each in mainPort) { if (each is TelegramPathFolderFileModel) { @@ -72,8 +68,7 @@ mixin class AppStorageFileMixin { model = (await ImageCompressor.compressedImageFile( file: model.file, directoryPath: tempPath.path, - )) - ?.clone( + ))?.clone( fileExtension: model.fileExtension, fileName: model.fileName, ); @@ -86,5 +81,6 @@ mixin class AppStorageFileMixin { sendPort.send(Constants.killIsolate); } -// + + // } diff --git a/lib/src/features/telegram_file_picker_feature/mixins/folder_creator/folder_creator.dart b/lib/src/features/telegram_file_picker_feature/mixins/folder_creator/folder_creator.dart index 4a79071..d96eb5c 100644 --- a/lib/src/features/telegram_file_picker_feature/mixins/folder_creator/folder_creator.dart +++ b/lib/src/features/telegram_file_picker_feature/mixins/folder_creator/folder_creator.dart @@ -32,9 +32,10 @@ mixin class FolderCreator { List get foldersName => _foldersName; - Future getApplicationDir() async => defaultTargetPlatform == TargetPlatform.iOS - ? await getApplicationSupportDirectory() - : await getExternalStorageDirectory(); + Future getApplicationDir() async => + defaultTargetPlatform == TargetPlatform.iOS + ? await getApplicationSupportDirectory() + : await getExternalStorageDirectory(); static Future getApplicationDirStatic() async => defaultTargetPlatform == TargetPlatform.iOS diff --git a/lib/src/features/telegram_file_picker_feature/mixins/recent_file_mixin/downloads_path_files.dart b/lib/src/features/telegram_file_picker_feature/mixins/recent_file_mixin/downloads_path_files.dart index 2853f19..fff01c7 100644 --- a/lib/src/features/telegram_file_picker_feature/mixins/recent_file_mixin/downloads_path_files.dart +++ b/lib/src/features/telegram_file_picker_feature/mixins/recent_file_mixin/downloads_path_files.dart @@ -15,10 +15,11 @@ mixin class DownloadsPathFiles { // final _reusables = snoopy(); - Stream downloadsPathFilesData(//{ - // String dirType = DownloadDirectoryTypes.downloads, - //} - ) async* { + Stream downloadsPathFilesData( + //{ + // String dirType = DownloadDirectoryTypes.downloads, + //} + ) async* { try { // final externalStoragePermission = await _permissions.manageExternalStoragePermission(); // @@ -73,7 +74,10 @@ mixin class DownloadsPathFiles { final reusables = ReusableGlobalFunctions.instance; final directoryPath = await getTemporaryDirectory(); - await for (final entity in directory.list(recursive: false, followLinks: false)) { + await for (final entity in directory.list( + recursive: false, + followLinks: false, + )) { if (FileSystemEntity.isDirectorySync(entity.path)) { await _fileFinder([receivingPort, entity.path, rootIsolateToken]); } diff --git a/lib/src/features/telegram_file_picker_feature/mixins/recent_file_mixin/recent_galley_file_mixin.dart b/lib/src/features/telegram_file_picker_feature/mixins/recent_file_mixin/recent_galley_file_mixin.dart index 11543eb..3e2bd82 100644 --- a/lib/src/features/telegram_file_picker_feature/mixins/recent_file_mixin/recent_galley_file_mixin.dart +++ b/lib/src/features/telegram_file_picker_feature/mixins/recent_file_mixin/recent_galley_file_mixin.dart @@ -30,23 +30,23 @@ mixin class RecentGalleyFileMixin { // debugPrint("storage $storagePermission | external: $externalStoragePermission"); if ( - // !externalStoragePermission || - !storagePermission) { + // !externalStoragePermission || + !storagePermission) { return; } - final List toEncodeList = await _RecentFilesHelper( - options: options, - ).getAssets(); + final List toEncodeList = + await _RecentFilesHelper(options: options).getAssets(); final ReceivePort receivePort = ReceivePort(); final rootIsolateToken = RootIsolateToken.instance!; final Map toIsolateImages = { - "list": toEncodeList.map((e) { - return e.toJson(); - }).toList(), + "list": + toEncodeList.map((e) { + return e.toJson(); + }).toList(), }; debugPrint("type of isolate image: $toIsolateImages"); @@ -126,26 +126,26 @@ mixin class RecentGalleyFileMixin { sendPort.send(Constants.killIsolate); } -// Future _compressedFile(File? file) async { -// if (file == null) return null; -// -// final tempDir = await getTemporaryDirectory(); -// final filePath = file.absolute.path; -// final fileName = path.basename(filePath); -// final outPath = path.join(tempDir.path, 'compressed_$fileName'); -// -// final res = await FlutterImageCompress.compressAndGetFile( -// file.path, -// outPath, -// quality: 30, -// ); -// -// final fileFromCompressedImage = File(res?.path ?? ''); -// -// if (!fileFromCompressedImage.existsSync()) return null; -// -// return fileFromCompressedImage; -// } + // Future _compressedFile(File? file) async { + // if (file == null) return null; + // + // final tempDir = await getTemporaryDirectory(); + // final filePath = file.absolute.path; + // final fileName = path.basename(filePath); + // final outPath = path.join(tempDir.path, 'compressed_$fileName'); + // + // final res = await FlutterImageCompress.compressAndGetFile( + // file.path, + // outPath, + // quality: 30, + // ); + // + // final fileFromCompressedImage = File(res?.path ?? ''); + // + // if (!fileFromCompressedImage.existsSync()) return null; + // + // return fileFromCompressedImage; + // } } class RecentFilesOptions { @@ -159,16 +159,11 @@ class RecentFilesOptions { abstract interface class _RecentFilesHelper { Future> getAssets(); - factory _RecentFilesHelper({ - RecentFilesOptions? options, - }) { + factory _RecentFilesHelper({RecentFilesOptions? options}) { switch (options?.getAll) { case null: case false: - return _GetRangedAssetFiles( - start: options?.start, - end: options?.end, - ); + return _GetRangedAssetFiles(start: options?.start, end: options?.end); case true: return _GetAllAssetFiles(); } diff --git a/lib/src/features/telegram_file_picker_feature/view/bottom_picker_button/telegram_bottom_picker_button.dart b/lib/src/features/telegram_file_picker_feature/view/bottom_picker_button/telegram_bottom_picker_button.dart index addb662..ccfd2d1 100644 --- a/lib/src/features/telegram_file_picker_feature/view/bottom_picker_button/telegram_bottom_picker_button.dart +++ b/lib/src/features/telegram_file_picker_feature/view/bottom_picker_button/telegram_bottom_picker_button.dart @@ -12,10 +12,12 @@ class TelegramBottomPickerButton extends StatefulWidget { }); @override - State createState() => _TelegramBottomPickerButtonState(); + State createState() => + _TelegramBottomPickerButtonState(); } -class _TelegramBottomPickerButtonState extends State { +class _TelegramBottomPickerButtonState + extends State { late final List _buttons; @override diff --git a/lib/src/features/telegram_file_picker_feature/view/bottom_picker_button/telegram_bottom_sender_button.dart b/lib/src/features/telegram_file_picker_feature/view/bottom_picker_button/telegram_bottom_sender_button.dart index 5e6d01b..b2ba4eb 100644 --- a/lib/src/features/telegram_file_picker_feature/view/bottom_picker_button/telegram_bottom_sender_button.dart +++ b/lib/src/features/telegram_file_picker_feature/view/bottom_picker_button/telegram_bottom_sender_button.dart @@ -4,10 +4,12 @@ class TelegramBottomSenderButton extends StatefulWidget { const TelegramBottomSenderButton({super.key}); @override - State createState() => _TelegramBottomSenderButtonState(); + State createState() => + _TelegramBottomSenderButtonState(); } -class _TelegramBottomSenderButtonState extends State { +class _TelegramBottomSenderButtonState + extends State { @override Widget build(BuildContext context) { return Container( @@ -20,15 +22,16 @@ class _TelegramBottomSenderButtonState extends State children: [ IconButton( onPressed: () {}, - icon: const Icon( - Icons.emoji_emotions_outlined, - ), + icon: const Icon(Icons.emoji_emotions_outlined), ), const SizedBox(width: 10), Expanded( child: DecoratedBox( decoration: BoxDecoration( - color: Theme.of(context).cardColor, //Theme.of(context).cardColor + color: + Theme.of( + context, + ).cardColor, //Theme.of(context).cardColor ), child: TextField( decoration: InputDecoration( @@ -58,12 +61,7 @@ class _TelegramBottomSenderButtonState extends State ), width: 50, height: 50, - child: const Center( - child: Icon( - Icons.send, - color: Colors.white, - ), - ), + child: const Center(child: Icon(Icons.send, color: Colors.white)), ), ), ], diff --git a/lib/src/features/telegram_file_picker_feature/view/reusable_widgets/telegram_storage_file_widget.dart b/lib/src/features/telegram_file_picker_feature/view/reusable_widgets/telegram_storage_file_widget.dart index 637662e..49f92ac 100644 --- a/lib/src/features/telegram_file_picker_feature/view/reusable_widgets/telegram_storage_file_widget.dart +++ b/lib/src/features/telegram_file_picker_feature/view/reusable_widgets/telegram_storage_file_widget.dart @@ -10,13 +10,11 @@ import 'package:path/path.dart' as path; class TelegramStorageFileWidget extends StatefulWidget { final List list; - const TelegramStorageFileWidget({ - super.key, - required this.list, - }); + const TelegramStorageFileWidget({super.key, required this.list}); @override - State createState() => _TelegramStorageFileWidgetState(); + State createState() => + _TelegramStorageFileWidgetState(); } class _TelegramStorageFileWidgetState extends State { @@ -32,8 +30,8 @@ class _TelegramStorageFileWidgetState extends State { borderRadius: BorderRadius.circular(10), onTap: () { context.read().add( - TelegramFilePickerEvents.selectGalleryFileEvent(item), - ); + TelegramFilePickerEvents.selectGalleryFileEvent(item), + ); }, child: Container( padding: const EdgeInsets.symmetric(vertical: 10, horizontal: 3), @@ -48,9 +46,12 @@ class _TelegramStorageFileWidgetState extends State { Stack( clipBehavior: Clip.none, children: [ - if (item.videoPlayerController != null && item.videoPreview != null) + if (item.videoPlayerController != null && + item.videoPreview != null) _VideoItem(item: item) - else if (ReusableGlobalFunctions.instance.isImageFile(item.file?.path ?? '')) + else if (ReusableGlobalFunctions.instance.isImageFile( + item.file?.path ?? '', + )) ClipRRect( borderRadius: BorderRadius.circular(10), child: SizedBox( @@ -72,9 +73,7 @@ class _TelegramStorageFileWidgetState extends State { borderRadius: BorderRadius.circular(10), ), child: Center( - child: Text( - path.extension(item.file?.path ?? ''), - ), + child: Text(path.extension(item.file?.path ?? '')), ), ) else @@ -86,21 +85,29 @@ class _TelegramStorageFileWidgetState extends State { borderRadius: BorderRadius.circular(10), ), ), - BlocBuilder( + BlocBuilder< + TelegramFilePickerBloc, + TelegramFilePickerStates + >( builder: (context, state) { - final telegramFilePickerStateModel = state.telegramFilePickerStateModel; + final telegramFilePickerStateModel = + state.telegramFilePickerStateModel; return Positioned( bottom: -10, right: 0, child: AnimatedOpacity( duration: const Duration(milliseconds: 150), - opacity: telegramFilePickerStateModel.isFileInsidePickedFiles(item) - ? 1 - : 0, + opacity: + telegramFilePickerStateModel + .isFileInsidePickedFiles(item) + ? 1 + : 0, child: AnimatedScale( - scale: telegramFilePickerStateModel.isFileInsidePickedFiles(item) - ? 1 - : 0, + scale: + telegramFilePickerStateModel + .isFileInsidePickedFiles(item) + ? 1 + : 0, duration: const Duration(milliseconds: 150), child: DecoratedBox( decoration: BoxDecoration( @@ -141,7 +148,8 @@ class _TelegramStorageFileWidgetState extends State { ), ), Text( - TelegramFileImageModel.fromEntity(item)?.fileSize() ?? '', + TelegramFileImageModel.fromEntity(item)?.fileSize() ?? + '', style: GoogleFonts.aBeeZee( fontSize: 14, fontWeight: FontWeight.w400, @@ -171,16 +179,11 @@ class _VideoItem extends StatelessWidget { return Container( width: 50, height: 50, - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(10), - ), + decoration: BoxDecoration(borderRadius: BorderRadius.circular(10)), child: Stack( children: [ Positioned.fill( - child: Image.memory( - fit: BoxFit.cover, - item.videoPreview!, - ), + child: Image.memory(fit: BoxFit.cover, item.videoPreview!), ), Positioned.fill( child: DecoratedBox( @@ -188,9 +191,7 @@ class _VideoItem extends StatelessWidget { color: Colors.black87.withOpacity(0.5), borderRadius: BorderRadius.circular(10), ), - child: const Center( - child: Icon(Icons.play_arrow), - ), + child: const Center(child: Icon(Icons.play_arrow)), ), ), ], diff --git a/lib/src/features/telegram_file_picker_feature/view/screens/telegram_app_folder_screen/telegram_browse_app_folder_screen.dart b/lib/src/features/telegram_file_picker_feature/view/screens/telegram_app_folder_screen/telegram_browse_app_folder_screen.dart index 341f9b4..590439c 100644 --- a/lib/src/features/telegram_file_picker_feature/view/screens/telegram_app_folder_screen/telegram_browse_app_folder_screen.dart +++ b/lib/src/features/telegram_file_picker_feature/view/screens/telegram_app_folder_screen/telegram_browse_app_folder_screen.dart @@ -6,15 +6,15 @@ import 'package:yahay/src/features/telegram_file_picker_feature/mixins/folder_cr import 'telegram_browse_folder_widget.dart'; class TelegramBrowseAppFolderScreen extends StatefulWidget { - const TelegramBrowseAppFolderScreen({ - super.key, - }); + const TelegramBrowseAppFolderScreen({super.key}); @override - State createState() => _TelegramBrowseAppFolderScreenState(); + State createState() => + _TelegramBrowseAppFolderScreenState(); } -class _TelegramBrowseAppFolderScreenState extends State +class _TelegramBrowseAppFolderScreenState + extends State with FolderCreator { @override Widget build(BuildContext context) { @@ -27,14 +27,14 @@ class _TelegramBrowseAppFolderScreenState extends State().add( - const TelegramFilePickerEvents.selectScreenForFilesPickerScreenEvent( - TelegramFileFolderEnum.recentDownloadsScreen, - ), - ); + const TelegramFilePickerEvents.selectScreenForFilesPickerScreenEvent( + TelegramFileFolderEnum.recentDownloadsScreen, + ), + ); Future.delayed(const Duration(milliseconds: 300), () { - context - .read() - .add(const TelegramFilePickerEvents.clearSelectedGalleryFileEvent()); + context.read().add( + const TelegramFilePickerEvents.clearSelectedGalleryFileEvent(), + ); }); }, title: "...", @@ -50,20 +50,21 @@ class _TelegramBrowseAppFolderScreenState extends State().add( - const TelegramFilePickerEvents.selectScreenForFilesPickerScreenEvent( - TelegramFileFolderEnum.browseTheFolder, - ), - ); + const TelegramFilePickerEvents.selectScreenForFilesPickerScreenEvent( + TelegramFileFolderEnum.browseTheFolder, + ), + ); - final dir = "${(await getApplicationDir())?.path}/${foldersName[index]}"; + final dir = + "${(await getApplicationDir())?.path}/${foldersName[index]}"; debugPrint("clicking path: $dir"); // init here for folder data context.read().add( - TelegramFilePickerEvents.setSpecificFolderPathInOrderToGetDataFromThereEvent( - dir, - ), - ); + TelegramFilePickerEvents.setSpecificFolderPathInOrderToGetDataFromThereEvent( + dir, + ), + ); }, title: foldersName[index], ); diff --git a/lib/src/features/telegram_file_picker_feature/view/screens/telegram_app_folder_screen/telegram_browse_folder_data_screen.dart b/lib/src/features/telegram_file_picker_feature/view/screens/telegram_app_folder_screen/telegram_browse_folder_data_screen.dart index cffdf8f..a9a3059 100644 --- a/lib/src/features/telegram_file_picker_feature/view/screens/telegram_app_folder_screen/telegram_browse_folder_data_screen.dart +++ b/lib/src/features/telegram_file_picker_feature/view/screens/telegram_app_folder_screen/telegram_browse_folder_data_screen.dart @@ -7,16 +7,15 @@ import 'telegram_browse_folder_widget.dart'; class TelegramBrowseFolderDataScreen extends StatefulWidget { final VoidCallback onBackFolder; - const TelegramBrowseFolderDataScreen({ - super.key, - required this.onBackFolder, - }); + const TelegramBrowseFolderDataScreen({super.key, required this.onBackFolder}); @override - State createState() => _TelegramBrowseFolderDataScreenState(); + State createState() => + _TelegramBrowseFolderDataScreenState(); } -class _TelegramBrowseFolderDataScreenState extends State { +class _TelegramBrowseFolderDataScreenState + extends State { @override Widget build(BuildContext context) { return ListView( @@ -25,15 +24,15 @@ class _TelegramBrowseFolderDataScreenState extends State( builder: (context, state) { return TelegramStorageFileWidget( - list: state.telegramFilePickerStateModel.specificFolderFilesPagination, + list: + state + .telegramFilePickerStateModel + .specificFolderFilesPagination, ); }, ), diff --git a/lib/src/features/telegram_file_picker_feature/view/screens/telegram_app_folder_screen/telegram_browse_folder_widget.dart b/lib/src/features/telegram_file_picker_feature/view/screens/telegram_app_folder_screen/telegram_browse_folder_widget.dart index 91ba05d..dbcb9a9 100644 --- a/lib/src/features/telegram_file_picker_feature/view/screens/telegram_app_folder_screen/telegram_browse_folder_widget.dart +++ b/lib/src/features/telegram_file_picker_feature/view/screens/telegram_app_folder_screen/telegram_browse_folder_widget.dart @@ -27,10 +27,7 @@ class TelegramFolderWidget extends StatelessWidget { borderRadius: BorderRadius.circular(50), ), child: const Center( - child: Icon( - Icons.folder, - color: Colors.white, - ), + child: Icon(Icons.folder, color: Colors.white), ), ), const SizedBox(width: 10), @@ -39,18 +36,10 @@ class TelegramFolderWidget extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.center, children: [ - Text( - title, - style: const TextStyle( - fontSize: 16, - ), - ), + Text(title, style: const TextStyle(fontSize: 16)), const Text( "Folder", - style: TextStyle( - fontSize: 12, - color: Colors.grey, - ), + style: TextStyle(fontSize: 12, color: Colors.grey), ), ], ), diff --git a/lib/src/features/telegram_file_picker_feature/view/screens/telegram_files_picker_screen/telegram_files_picker_screen.dart b/lib/src/features/telegram_file_picker_feature/view/screens/telegram_files_picker_screen/telegram_files_picker_screen.dart index 2a3b143..7c205e6 100644 --- a/lib/src/features/telegram_file_picker_feature/view/screens/telegram_files_picker_screen/telegram_files_picker_screen.dart +++ b/lib/src/features/telegram_file_picker_feature/view/screens/telegram_files_picker_screen/telegram_files_picker_screen.dart @@ -19,10 +19,12 @@ class TelegramFilesPickerScreen extends StatefulWidget { }); @override - State createState() => _TelegramFilesPickerScreenState(); + State createState() => + _TelegramFilesPickerScreenState(); } -class _TelegramFilesPickerScreenState extends State with FolderCreator { +class _TelegramFilesPickerScreenState extends State + with FolderCreator { late final TelegramFilePickerBloc _telegramFilePickerBloc; late final TelegramFilePickerStateModel _telegramFilePickerStateModel; @@ -30,7 +32,8 @@ class _TelegramFilesPickerScreenState extends State w void initState() { super.initState(); _telegramFilePickerBloc = context.read(); - _telegramFilePickerStateModel = _telegramFilePickerBloc.state.telegramFilePickerStateModel; + _telegramFilePickerStateModel = + _telegramFilePickerBloc.state.telegramFilePickerStateModel; // final currentStateModel = _telegramFilePickerBloc.state.telegramFilePickerStateModel; widget.parentScrollController.addListener(() { if (widget.parentScrollController.offset == @@ -40,11 +43,14 @@ class _TelegramFilesPickerScreenState extends State w TelegramFileFolderEnum.browseTheGalleryFolder || _telegramFilePickerStateModel.filePickerScreenSelectedScreen == TelegramFileFolderEnum.browseTheFolder) { - _telegramFilePickerBloc - .add(const TelegramFilePickerEvents.paginateSpecificFolderDataEvent()); + _telegramFilePickerBloc.add( + const TelegramFilePickerEvents.paginateSpecificFolderDataEvent(), + ); } else { // pagination here - _telegramFilePickerBloc.add(const TelegramFilePickerEvents.recentFilesPaginationEvent()); + _telegramFilePickerBloc.add( + const TelegramFilePickerEvents.recentFilesPaginationEvent(), + ); // if (currentStateModel.recentFilesPagination.length == // currentStateModel.recentFiles.length) { @@ -85,22 +91,31 @@ class _TelegramFilesPickerScreenState extends State w controller: widget.parentScrollController, children: [ Visibility( - visible: state.telegramFilePickerStateModel.filePickerScreenSelectedScreen == + visible: + state + .telegramFilePickerStateModel + .filePickerScreenSelectedScreen == TelegramFileFolderEnum.recentDownloadsScreen, maintainAnimation: true, maintainState: true, child: AnimatedSlide( curve: Curves.fastOutSlowIn, duration: const Duration(milliseconds: 300), - offset: state.telegramFilePickerStateModel.filePickerScreenSelectedScreen == - TelegramFileFolderEnum.recentDownloadsScreen - ? Offset.zero - : const Offset(1, 0), + offset: + state + .telegramFilePickerStateModel + .filePickerScreenSelectedScreen == + TelegramFileFolderEnum.recentDownloadsScreen + ? Offset.zero + : const Offset(1, 0), child: AnimatedOpacity( - opacity: state.telegramFilePickerStateModel.filePickerScreenSelectedScreen == - TelegramFileFolderEnum.recentDownloadsScreen - ? 1 - : 0, + opacity: + state + .telegramFilePickerStateModel + .filePickerScreenSelectedScreen == + TelegramFileFolderEnum.recentDownloadsScreen + ? 1 + : 0, duration: const Duration(seconds: 1), child: ListView( shrinkWrap: true, @@ -118,13 +133,19 @@ class _TelegramFilesPickerScreenState extends State w Visibility( maintainAnimation: true, maintainState: true, - visible: state.telegramFilePickerStateModel.filePickerScreenSelectedScreen == + visible: + state + .telegramFilePickerStateModel + .filePickerScreenSelectedScreen == TelegramFileFolderEnum.browseTheAppsFolder, child: PopScope( - canPop: state.telegramFilePickerStateModel.filePickerScreenSelectedScreen == - TelegramFileFolderEnum.browseTheAppsFolder - ? false - : true, + canPop: + state + .telegramFilePickerStateModel + .filePickerScreenSelectedScreen == + TelegramFileFolderEnum.browseTheAppsFolder + ? false + : true, onPopInvokedWithResult: (v, r) { _telegramFilePickerBloc.add( const TelegramFilePickerEvents.selectScreenForFilesPickerScreenEvent( @@ -135,15 +156,21 @@ class _TelegramFilesPickerScreenState extends State w child: AnimatedSlide( curve: Curves.fastOutSlowIn, duration: const Duration(milliseconds: 300), - offset: state.telegramFilePickerStateModel.filePickerScreenSelectedScreen == - TelegramFileFolderEnum.browseTheAppsFolder - ? Offset.zero - : const Offset(1, 0), + offset: + state + .telegramFilePickerStateModel + .filePickerScreenSelectedScreen == + TelegramFileFolderEnum.browseTheAppsFolder + ? Offset.zero + : const Offset(1, 0), child: AnimatedOpacity( - opacity: state.telegramFilePickerStateModel.filePickerScreenSelectedScreen == - TelegramFileFolderEnum.browseTheAppsFolder - ? 1 - : 0, + opacity: + state + .telegramFilePickerStateModel + .filePickerScreenSelectedScreen == + TelegramFileFolderEnum.browseTheAppsFolder + ? 1 + : 0, duration: const Duration(seconds: 1), child: const TelegramBrowseAppFolderScreen(), ), @@ -152,15 +179,21 @@ class _TelegramFilesPickerScreenState extends State w ), Visibility( - visible: state.telegramFilePickerStateModel.filePickerScreenSelectedScreen == + visible: + state + .telegramFilePickerStateModel + .filePickerScreenSelectedScreen == TelegramFileFolderEnum.browseTheFolder, maintainAnimation: true, maintainState: true, child: PopScope( - canPop: state.telegramFilePickerStateModel.filePickerScreenSelectedScreen == - TelegramFileFolderEnum.browseTheFolder - ? false - : true, + canPop: + state + .telegramFilePickerStateModel + .filePickerScreenSelectedScreen == + TelegramFileFolderEnum.browseTheFolder + ? false + : true, onPopInvokedWithResult: (v, r) { _telegramFilePickerBloc.add( const TelegramFilePickerEvents.selectScreenForFilesPickerScreenEvent( @@ -168,22 +201,29 @@ class _TelegramFilesPickerScreenState extends State w ), ); Future.delayed(const Duration(milliseconds: 300), () { - _telegramFilePickerBloc - .add(const TelegramFilePickerEvents.clearSelectedGalleryFileEvent()); + _telegramFilePickerBloc.add( + const TelegramFilePickerEvents.clearSelectedGalleryFileEvent(), + ); }); }, child: AnimatedSlide( curve: Curves.fastOutSlowIn, duration: const Duration(milliseconds: 300), - offset: state.telegramFilePickerStateModel.filePickerScreenSelectedScreen == - TelegramFileFolderEnum.browseTheFolder - ? Offset.zero - : const Offset(1, 0), + offset: + state + .telegramFilePickerStateModel + .filePickerScreenSelectedScreen == + TelegramFileFolderEnum.browseTheFolder + ? Offset.zero + : const Offset(1, 0), child: AnimatedOpacity( - opacity: state.telegramFilePickerStateModel.filePickerScreenSelectedScreen == - TelegramFileFolderEnum.browseTheFolder - ? 1 - : 0, + opacity: + state + .telegramFilePickerStateModel + .filePickerScreenSelectedScreen == + TelegramFileFolderEnum.browseTheFolder + ? 1 + : 0, duration: const Duration(seconds: 1), child: TelegramBrowseFolderDataScreen( onBackFolder: () async { @@ -206,15 +246,21 @@ class _TelegramFilesPickerScreenState extends State w // gallery folder data Visibility( - visible: state.telegramFilePickerStateModel.filePickerScreenSelectedScreen == + visible: + state + .telegramFilePickerStateModel + .filePickerScreenSelectedScreen == TelegramFileFolderEnum.browseTheGalleryFolder, maintainAnimation: true, maintainState: true, child: PopScope( - canPop: state.telegramFilePickerStateModel.filePickerScreenSelectedScreen == - TelegramFileFolderEnum.browseTheGalleryFolder - ? false - : true, + canPop: + state + .telegramFilePickerStateModel + .filePickerScreenSelectedScreen == + TelegramFileFolderEnum.browseTheGalleryFolder + ? false + : true, onPopInvokedWithResult: (v, r) { _telegramFilePickerBloc.add( const TelegramFilePickerEvents.selectScreenForFilesPickerScreenEvent( @@ -223,22 +269,29 @@ class _TelegramFilesPickerScreenState extends State w ); Future.delayed(const Duration(milliseconds: 300), () { - _telegramFilePickerBloc - .add(const TelegramFilePickerEvents.clearSelectedGalleryFileEvent()); + _telegramFilePickerBloc.add( + const TelegramFilePickerEvents.clearSelectedGalleryFileEvent(), + ); }); }, child: AnimatedSlide( curve: Curves.fastOutSlowIn, duration: const Duration(milliseconds: 300), - offset: state.telegramFilePickerStateModel.filePickerScreenSelectedScreen == - TelegramFileFolderEnum.browseTheGalleryFolder - ? Offset.zero - : const Offset(1, 0), + offset: + state + .telegramFilePickerStateModel + .filePickerScreenSelectedScreen == + TelegramFileFolderEnum.browseTheGalleryFolder + ? Offset.zero + : const Offset(1, 0), child: AnimatedOpacity( - opacity: state.telegramFilePickerStateModel.filePickerScreenSelectedScreen == - TelegramFileFolderEnum.browseTheGalleryFolder - ? 1 - : 0, + opacity: + state + .telegramFilePickerStateModel + .filePickerScreenSelectedScreen == + TelegramFileFolderEnum.browseTheGalleryFolder + ? 1 + : 0, duration: const Duration(seconds: 1), child: TelegramBrowseFolderDataScreen( onBackFolder: () async { diff --git a/lib/src/features/telegram_file_picker_feature/view/screens/telegram_files_picker_screen/widgets/telegram_files_from_storages_widget.dart b/lib/src/features/telegram_file_picker_feature/view/screens/telegram_files_picker_screen/widgets/telegram_files_from_storages_widget.dart index 746c1d8..f18e2f9 100644 --- a/lib/src/features/telegram_file_picker_feature/view/screens/telegram_files_picker_screen/widgets/telegram_files_from_storages_widget.dart +++ b/lib/src/features/telegram_file_picker_feature/view/screens/telegram_files_picker_screen/widgets/telegram_files_from_storages_widget.dart @@ -7,25 +7,22 @@ import 'package:yahay/src/features/telegram_file_picker_feature/bloc/telegram_fi import 'package:yahay/src/features/telegram_file_picker_feature/data/models/data_models/telegram_storage_file_picker_data_model.dart'; class TelegramFilesFromStoragesWidget extends StatefulWidget { - const TelegramFilesFromStoragesWidget({ - super.key, - }); + const TelegramFilesFromStoragesWidget({super.key}); @override - State createState() => _TelegramFilesFromStoragesWidgetState(); + State createState() => + _TelegramFilesFromStoragesWidgetState(); } -class _TelegramFilesFromStoragesWidgetState extends State { +class _TelegramFilesFromStoragesWidgetState + extends State { late AppThemeBloc _appThemeBloc; late List telegramStorageFileDataModels; @override void initState() { super.initState(); - _appThemeBloc = DependenciesScope.of( - context, - listen: false, - ).appThemeBloc; + _appThemeBloc = DependenciesScope.of(context, listen: false).appThemeBloc; telegramStorageFileDataModels = TelegramStorageFilePickerDataModel.data( context.read(), ); @@ -36,9 +33,10 @@ class _TelegramFilesFromStoragesWidgetState extends State createState() => @@ -26,7 +24,10 @@ class _TelegramResentFilesFromStorageWidgetState void initState() { super.initState(); _telegramFilePickerStateModel = - context.read().state.telegramFilePickerStateModel; + context + .read() + .state + .telegramFilePickerStateModel; _appThemeBloc = DependenciesScope.of(context, listen: false).appThemeBloc; } @@ -36,9 +37,10 @@ class _TelegramResentFilesFromStorageWidgetState width: MediaQuery.of(context).size.width, padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 15), decoration: BoxDecoration( - color: _appThemeBloc.theme.value.brightness == Brightness.dark - ? Colors.blueGrey.shade900.withOpacity(0.5) - : Colors.white, + color: + _appThemeBloc.theme.value.brightness == Brightness.dark + ? Colors.blueGrey.shade900.withOpacity(0.5) + : Colors.white, ), child: Column( crossAxisAlignment: CrossAxisAlignment.start, diff --git a/lib/src/features/telegram_file_picker_feature/view/screens/telegram_gallery_file_picker_screen/telegram_gallery_file_picker_screen.dart b/lib/src/features/telegram_file_picker_feature/view/screens/telegram_gallery_file_picker_screen/telegram_gallery_file_picker_screen.dart index 1829ca2..0ef69a1 100644 --- a/lib/src/features/telegram_file_picker_feature/view/screens/telegram_gallery_file_picker_screen/telegram_gallery_file_picker_screen.dart +++ b/lib/src/features/telegram_file_picker_feature/view/screens/telegram_gallery_file_picker_screen/telegram_gallery_file_picker_screen.dart @@ -15,23 +15,28 @@ class TelegramGalleryFilePickerScreen extends StatefulWidget { }); @override - State createState() => _TelegramGalleryFilePickerScreenState(); + State createState() => + _TelegramGalleryFilePickerScreenState(); } -class _TelegramGalleryFilePickerScreenState extends State { +class _TelegramGalleryFilePickerScreenState + extends State { late final TelegramFilePickerBloc _telegramFilePickerBloc; @override void initState() { super.initState(); _telegramFilePickerBloc = context.read(); - final currentStateModel = _telegramFilePickerBloc.state.telegramFilePickerStateModel; + final currentStateModel = + _telegramFilePickerBloc.state.telegramFilePickerStateModel; widget.parentScrollController.addListener(() { if (widget.parentScrollController.offset == widget.parentScrollController.position.maxScrollExtent && _telegramFilePickerBloc.state is Picker$GalleryFileState) { // pagination here - _telegramFilePickerBloc.add(const TelegramFilePickerEvents.imagesAndVideoPaginationEvent()); + _telegramFilePickerBloc.add( + const TelegramFilePickerEvents.imagesAndVideoPaginationEvent(), + ); // why i wrote ".length -1" -> because of galleryPathPagination's first item is entity with // cameraController @@ -78,7 +83,9 @@ class _TelegramGalleryFilePickerScreenState extends State widget.telegramFilePickerBloc.add( - TelegramFilePickerEvents.selectGalleryFileEvent( - widget.item, - ), - ), - icon: currentStateModel.isFileInsidePickedFiles(widget.item) - ? const Icon(Icons.check_circle) - : const Icon(Icons.circle_outlined), - color: currentStateModel.isFileInsidePickedFiles(widget.item) - ? Colors.blue - : Colors.white, + onPressed: + () => widget.telegramFilePickerBloc.add( + TelegramFilePickerEvents.selectGalleryFileEvent( + widget.item, + ), + ), + icon: + currentStateModel.isFileInsidePickedFiles(widget.item) + ? const Icon(Icons.check_circle) + : const Icon(Icons.circle_outlined), + color: + currentStateModel.isFileInsidePickedFiles(widget.item) + ? Colors.blue + : Colors.white, ), ), ], diff --git a/lib/src/features/telegram_file_picker_feature/view/screens/telegram_gallery_file_picker_screen/widgets/telegram_gallery_file_picker_video_player_widget.dart b/lib/src/features/telegram_file_picker_feature/view/screens/telegram_gallery_file_picker_screen/widgets/telegram_gallery_file_picker_video_player_widget.dart index 5113703..b03dd3e 100644 --- a/lib/src/features/telegram_file_picker_feature/view/screens/telegram_gallery_file_picker_screen/widgets/telegram_gallery_file_picker_video_player_widget.dart +++ b/lib/src/features/telegram_file_picker_feature/view/screens/telegram_gallery_file_picker_screen/widgets/telegram_gallery_file_picker_video_player_widget.dart @@ -27,41 +27,43 @@ class _TelegramGalleryFilePickerVideoPlayerWidgetState @override void initState() { super.initState(); - _currentStateModel = widget.telegramFilePickerBloc.state.telegramFilePickerStateModel; + _currentStateModel = + widget.telegramFilePickerBloc.state.telegramFilePickerStateModel; } @override Widget build(BuildContext context) { return AnimatedPadding( duration: const Duration(milliseconds: 100), - padding: _currentStateModel.isFileInsidePickedFiles(widget.item) - ? const EdgeInsets.all(10) - : EdgeInsets.zero, + padding: + _currentStateModel.isFileInsidePickedFiles(widget.item) + ? const EdgeInsets.all(10) + : EdgeInsets.zero, child: ClipRRect( borderRadius: BorderRadius.circular(10), child: Stack( children: [ Positioned.fill( - child: Image.memory( - widget.item.videoPreview!, - fit: BoxFit.cover, - ), + child: Image.memory(widget.item.videoPreview!, fit: BoxFit.cover), ), Positioned( right: 0, top: 0, child: IconButton( - onPressed: () => widget.telegramFilePickerBloc.add( - TelegramFilePickerEvents.selectGalleryFileEvent( - widget.item, - ), - ), - icon: _currentStateModel.isFileInsidePickedFiles(widget.item) - ? const Icon(Icons.check_circle) - : const Icon(Icons.circle_outlined), - color: _currentStateModel.isFileInsidePickedFiles(widget.item) - ? Colors.blue - : Colors.white, + onPressed: + () => widget.telegramFilePickerBloc.add( + TelegramFilePickerEvents.selectGalleryFileEvent( + widget.item, + ), + ), + icon: + _currentStateModel.isFileInsidePickedFiles(widget.item) + ? const Icon(Icons.check_circle) + : const Icon(Icons.circle_outlined), + color: + _currentStateModel.isFileInsidePickedFiles(widget.item) + ? Colors.blue + : Colors.white, ), ), Positioned( @@ -70,17 +72,12 @@ class _TelegramGalleryFilePickerVideoPlayerWidgetState child: Container( padding: const EdgeInsets.symmetric(horizontal: 5, vertical: 3), decoration: BoxDecoration( - color: Colors.black.withValues( - alpha: 0.4, - ), + color: Colors.black.withValues(alpha: 0.4), borderRadius: BorderRadius.circular(5), ), child: Row( children: [ - const Icon( - Icons.play_arrow, - size: 15, - ), + const Icon(Icons.play_arrow, size: 15), const SizedBox(width: 2), Text( ReusableGlobalFunctions.instance.getNormalDuration( diff --git a/lib/src/features/telegram_file_picker_feature/view/telegram_draggable_scrollable_bottom_sheet.dart b/lib/src/features/telegram_file_picker_feature/view/telegram_draggable_scrollable_bottom_sheet.dart index 2573eac..bf1ae4c 100644 --- a/lib/src/features/telegram_file_picker_feature/view/telegram_draggable_scrollable_bottom_sheet.dart +++ b/lib/src/features/telegram_file_picker_feature/view/telegram_draggable_scrollable_bottom_sheet.dart @@ -43,16 +43,11 @@ class _TelegramDraggableScrollableBottomSheetUIState telegramFilePickerBloc.add( const TelegramFilePickerEvents.initAllPicturesEvent(true), ); - Future.delayed( - const Duration(milliseconds: 350), - () { - telegramFilePickerBloc.add( - const TelegramFilePickerEvents.openHideBottomTelegramButtonEvent( - true, - ), - ); - }, - ); + Future.delayed(const Duration(milliseconds: 350), () { + telegramFilePickerBloc.add( + const TelegramFilePickerEvents.openHideBottomTelegramButtonEvent(true), + ); + }); // _telegramFilePickerBloc.events.add(const InitAllFilesEvent(initFilePickerState: false)); } @@ -79,12 +74,13 @@ class _TelegramDraggableScrollableBottomSheetUIState children: [ switch (state) { Picker$InitialState() => const SizedBox(), - Picker$GalleryFileState() => TelegramGalleryFilePickerScreen( + Picker$GalleryFileState() => + TelegramGalleryFilePickerScreen( parentScrollController: scrollController, ), Picker$FilesState() => TelegramFilesPickerScreen( - parentScrollController: scrollController, - ), + parentScrollController: scrollController, + ), Picker$AudioFilesState() => const SizedBox(), }, AnimatedPositioned( @@ -98,14 +94,16 @@ class _TelegramDraggableScrollableBottomSheetUIState AnimatedPositioned( curve: Curves.fastOutSlowIn, duration: const Duration(milliseconds: 1000), - bottom: (currentStateModel.openBottomSectionButton && - currentStateModel.pickedFiles.isEmpty) - ? 0 - : -200, + bottom: + (currentStateModel.openBottomSectionButton && + currentStateModel.pickedFiles.isEmpty) + ? 0 + : -200, right: 0, left: 0, child: TelegramBottomPickerButton( - draggableScrollableController: _draggableScrollableController, + draggableScrollableController: + _draggableScrollableController, ), ), ], diff --git a/lib/src/features/video_chat_feature/bloc/state_model/video_chat_state_model.dart b/lib/src/features/video_chat_feature/bloc/state_model/video_chat_state_model.dart index a4493c9..245f0b3 100644 --- a/lib/src/features/video_chat_feature/bloc/state_model/video_chat_state_model.dart +++ b/lib/src/features/video_chat_feature/bloc/state_model/video_chat_state_model.dart @@ -32,13 +32,13 @@ class VideoChatStateModel { final List videoChatEntities; factory VideoChatStateModel.idle() => const VideoChatStateModel( - chatStarted: false, - hasAudio: true, - hasVideo: true, - cameraSwitched: false, - currentVideoChatEntity: null, - videoChatEntities: [], - ); + chatStarted: false, + hasAudio: true, + hasVideo: true, + cameraSwitched: false, + currentVideoChatEntity: null, + videoChatEntities: [], + ); @override bool operator ==(Object other) => @@ -96,7 +96,8 @@ class VideoChatStateModel { cameraSwitched: cameraSwitched ?? this.cameraSwitched, chat: (chat ?? this.chat)?.copyWith(), currentUser: (currentUser ?? this.currentUser)?.copyWith(), - currentVideoChatEntity: currentVideoChatEntity ?? this.currentVideoChatEntity, + currentVideoChatEntity: + currentVideoChatEntity ?? this.currentVideoChatEntity, videoChatEntities: videoChatEntities ?? this.videoChatEntities, ); } diff --git a/lib/src/features/video_chat_feature/bloc/video_chat_feature_bloc.dart b/lib/src/features/video_chat_feature/bloc/video_chat_feature_bloc.dart index 98198fe..71f9c58 100644 --- a/lib/src/features/video_chat_feature/bloc/video_chat_feature_bloc.dart +++ b/lib/src/features/video_chat_feature/bloc/video_chat_feature_bloc.dart @@ -19,26 +19,33 @@ part 'video_chat_feature_bloc.freezed.dart'; @immutable @freezed sealed class VideoChatFeatureEvents with _$VideoChatFeatureEvents { - const factory VideoChatFeatureEvents.videoChatInitFeatureEvent(final ChatModel? chat) = - _VideoChatInitFeatureEvent; + const factory VideoChatFeatureEvents.videoChatInitFeatureEvent( + final ChatModel? chat, + ) = _VideoChatInitFeatureEvent; - const factory VideoChatFeatureEvents.startVideoChatEvent() = _StartVideoChatEvent; + const factory VideoChatFeatureEvents.startVideoChatEvent() = + _StartVideoChatEvent; - const factory VideoChatFeatureEvents.videoChatEntranceEvent() = _VideoChatEntranceEvent; + const factory VideoChatFeatureEvents.videoChatEntranceEvent() = + _VideoChatEntranceEvent; const factory VideoChatFeatureEvents.finishVideoChatEvent({ required void Function() popScreen, }) = _FinishVideoChatEvent; const factory VideoChatFeatureEvents.onAddRemoteRendererStreamEvent( - final MediaStream mediaStream,) = _OnAddRemoteRendererStreamEvent; + final MediaStream mediaStream, + ) = _OnAddRemoteRendererStreamEvent; - const factory VideoChatFeatureEvents.switchCameraStreamEvent() = _SwitchCameraStreamEvent; + const factory VideoChatFeatureEvents.switchCameraStreamEvent() = + _SwitchCameraStreamEvent; - const factory VideoChatFeatureEvents.turnMicOffAndOnEvent({@Default(true) final bool change}) = - _TurnMicOffAndOnEvent; + const factory VideoChatFeatureEvents.turnMicOffAndOnEvent({ + @Default(true) final bool change, + }) = _TurnMicOffAndOnEvent; - const factory VideoChatFeatureEvents.turnCameraOffAndEvent() = _TurnCameraOffAndEvent; + const factory VideoChatFeatureEvents.turnCameraOffAndEvent() = + _TurnCameraOffAndEvent; } // @immutable @@ -59,10 +66,12 @@ sealed class VideoChatFeatureEvents with _$VideoChatFeatureEvents { @freezed class VideoChatFeatureStates with _$VideoChatFeatureStates { const factory VideoChatFeatureStates.initial( - final VideoChatStateModel videoChatStateModel,) = _VideoChat$InitialState; + final VideoChatStateModel videoChatStateModel, + ) = _VideoChat$InitialState; } -class VideoChatBloc extends Bloc { +class VideoChatBloc + extends Bloc { StreamSubscription? _channelSubscription; PusherChannelsClient? _pusherChannelsClient; WebrtcLaravelService? _webrtcLaravelHelper; @@ -80,22 +89,25 @@ class VideoChatBloc extends Bloc required final VideoChatFeatureStates initialState, required final Logger logger, required final RestClientBase restClientBase, - }) : _iVideoChatFeatureRepo = iVideoChatFeatureRepo, - _currentUser = currentUser, - _pusherClientService = pusherClientService, - _logger = logger, - _restClientBase = restClientBase, - super(initialState) { + }) : _iVideoChatFeatureRepo = iVideoChatFeatureRepo, + _currentUser = currentUser, + _pusherClientService = pusherClientService, + _logger = logger, + _restClientBase = restClientBase, + super(initialState) { // on( (event, emit) => event.map( - videoChatInitFeatureEvent: (event) => _videoChatInitFeatureEvent(event, emit), + videoChatInitFeatureEvent: + (event) => _videoChatInitFeatureEvent(event, emit), startVideoChatEvent: (event) => _startVideoChatEvent(event, emit), videoChatEntranceEvent: (event) => _videoChatEntranceEvent(event, emit), finishVideoChatEvent: (event) => _finishVideoChatEvent(event, emit), - onAddRemoteRendererStreamEvent: (event) => _onAddRemoteRendererStreamEvent(event, emit), - switchCameraStreamEvent: (event) => _switchCameraStreamEvent(event, emit), + onAddRemoteRendererStreamEvent: + (event) => _onAddRemoteRendererStreamEvent(event, emit), + switchCameraStreamEvent: + (event) => _switchCameraStreamEvent(event, emit), turnMicOffAndOnEvent: (event) => _turnMicOffAndOnEvent(event, emit), turnCameraOffAndEvent: (event) => _turnCameraOffAndEvent(event, emit), ), @@ -169,9 +181,7 @@ class VideoChatBloc extends Bloc chatStarted: resultOfJoining, ); - await _webrtcLaravelHelper?.joinRoom( - room.id.toString(), - ); + await _webrtcLaravelHelper?.joinRoom(room.id.toString()); Future.delayed(const Duration(milliseconds: 100), () { add(const VideoChatFeatureEvents.turnMicOffAndOnEvent(change: false)); @@ -218,7 +228,9 @@ class VideoChatBloc extends Bloc // await createLocalMediaStream('key${Random().nextInt(100)}'); videoChatEntity.videoRenderer?.srcObject = event.mediaStream; - final currentChatEntities = List.of(state.videoChatStateModel.videoChatEntities); + final currentChatEntities = List.of( + state.videoChatStateModel.videoChatEntities, + ); currentChatEntities.add(videoChatEntity); @@ -242,7 +254,8 @@ class VideoChatBloc extends Bloc ); Helper.switchCamera( - currentStateModel.currentVideoChatEntity!.videoRenderer!.srcObject!.getVideoTracks()[0], + currentStateModel.currentVideoChatEntity!.videoRenderer!.srcObject! + .getVideoTracks()[0], null, _webrtcLaravelHelper?.localStream, ); @@ -264,7 +277,8 @@ class VideoChatBloc extends Bloc Helper.setMicrophoneMute( !currentStateModel.hasAudio, - currentStateModel.currentVideoChatEntity!.videoRenderer!.srcObject!.getAudioTracks()[0], + currentStateModel.currentVideoChatEntity!.videoRenderer!.srcObject! + .getAudioTracks()[0], ); emit(VideoChatFeatureStates.initial(currentStateModel)); @@ -279,7 +293,8 @@ class VideoChatBloc extends Bloc ); final videoTrack = - currentStateModel.currentVideoChatEntity!.videoRenderer!.srcObject!.getVideoTracks()[0]; + currentStateModel.currentVideoChatEntity!.videoRenderer!.srcObject! + .getVideoTracks()[0]; videoTrack.enabled = currentStateModel.hasVideo; @@ -319,7 +334,9 @@ class VideoChatBloc extends Bloc await currentVideoChatEntity.videoRenderer?.initialize(); // after video render initialization open the media - await _webrtcLaravelHelper?.openUserMedia(currentVideoChatEntity.videoRenderer!); + await _webrtcLaravelHelper?.openUserMedia( + currentVideoChatEntity.videoRenderer!, + ); return currentVideoChatEntity; } @@ -330,7 +347,8 @@ class VideoChatBloc extends Bloc _pusherChannelsClient?.dispose(); _channelSubscription?.cancel(); state.videoChatStateModel.dispose(); - if (state.videoChatStateModel.currentVideoChatEntity?.videoRenderer != null) { + if (state.videoChatStateModel.currentVideoChatEntity?.videoRenderer != + null) { await _webrtcLaravelHelper?.hangUp( state.videoChatStateModel.currentVideoChatEntity!.videoRenderer!, ); diff --git a/lib/src/features/video_chat_feature/data/video_chat_feature_data_source.dart b/lib/src/features/video_chat_feature/data/video_chat_feature_data_source.dart index 489986c..7973c87 100644 --- a/lib/src/features/video_chat_feature/data/video_chat_feature_data_source.dart +++ b/lib/src/features/video_chat_feature/data/video_chat_feature_data_source.dart @@ -16,23 +16,24 @@ abstract interface class VideoChatFeatureDataSource { Future leaveTheChat(VideoChatModel videoChatEntity); // streaming the video data feature - Future streamTheVideo({ - required VideoChatModel videoChatEntity, - }); + Future streamTheVideo({required VideoChatModel videoChatEntity}); } class VideoChatFeatureDataSourceImpl implements VideoChatFeatureDataSource { // - VideoChatFeatureDataSourceImpl({ - required RestClientBase restClientBase, - }) : _restClientBase = restClientBase; + VideoChatFeatureDataSourceImpl({required RestClientBase restClientBase}) + : _restClientBase = restClientBase; final RestClientBase _restClientBase; - final _joinChatPath = "${HttpRoutes.chatsVideoStreamPrefix}/videochat/entrance"; - final _startVideoChatPath = "${HttpRoutes.chatsVideoStreamPrefix}/start/videochat"; - final _leaveVideoChatPath = "${HttpRoutes.chatsVideoStreamPrefix}/leave/videochat"; - final _steamTheVideoPath = "${HttpRoutes.chatsVideoStreamPrefix}/video/stream"; + final _joinChatPath = + "${HttpRoutes.chatsVideoStreamPrefix}/videochat/entrance"; + final _startVideoChatPath = + "${HttpRoutes.chatsVideoStreamPrefix}/start/videochat"; + final _leaveVideoChatPath = + "${HttpRoutes.chatsVideoStreamPrefix}/leave/videochat"; + final _steamTheVideoPath = + "${HttpRoutes.chatsVideoStreamPrefix}/video/stream"; @override Future startVideoChat(VideoChatModel videoChatEntity) async { @@ -96,9 +97,7 @@ class VideoChatFeatureDataSourceImpl implements VideoChatFeatureDataSource { } @override - Future streamTheVideo({ - required VideoChatModel videoChatEntity, - }) async { + Future streamTheVideo({required VideoChatModel videoChatEntity}) async { try { final jsonBody = videoChatEntity.toJson(); log("sending uint8list data: $jsonBody"); diff --git a/lib/src/features/video_chat_feature/data/video_chat_feature_repo.dart b/lib/src/features/video_chat_feature/data/video_chat_feature_repo.dart index 657da84..93f763e 100644 --- a/lib/src/features/video_chat_feature/data/video_chat_feature_repo.dart +++ b/lib/src/features/video_chat_feature/data/video_chat_feature_repo.dart @@ -13,9 +13,7 @@ abstract interface class VideoChatFeatureRepo { Future leaveTheChat(VideoChatModel videoChatEntity); // streaming the video data feature - Future streamTheVideo({ - required VideoChatModel videoChatEntity, - }); + Future streamTheVideo({required VideoChatModel videoChatEntity}); } class VideoChatFeatureRepoImpl implements VideoChatFeatureRepo { @@ -36,10 +34,6 @@ class VideoChatFeatureRepoImpl implements VideoChatFeatureRepo { _dataSource.leaveTheChat(videoChatEntity); @override - Future streamTheVideo({ - required VideoChatModel videoChatEntity, - }) => - _dataSource.streamTheVideo( - videoChatEntity: videoChatEntity, - ); + Future streamTheVideo({required VideoChatModel videoChatEntity}) => + _dataSource.streamTheVideo(videoChatEntity: videoChatEntity); } diff --git a/lib/src/features/video_chat_feature/models/candidate_model/candidate_model.dart b/lib/src/features/video_chat_feature/models/candidate_model/candidate_model.dart index 5eb6f35..61b372b 100644 --- a/lib/src/features/video_chat_feature/models/candidate_model/candidate_model.dart +++ b/lib/src/features/video_chat_feature/models/candidate_model/candidate_model.dart @@ -23,11 +23,13 @@ class CandidateModel with _$CandidateModel { const factory CandidateModel({ required int? id, @JsonKey(name: "room_id") required int? roomId, - @JsonKey(fromJson: _fromJsonInnerCandidate) required InnerCandidateModel? candidate, + @JsonKey(fromJson: _fromJsonInnerCandidate) + required InnerCandidateModel? candidate, required String? role, required DateTime? createdAt, required DateTime? updatedAt, }) = _CandidateModel; - factory CandidateModel.fromJson(Map json) => _$CandidateModelFromJson(json); + factory CandidateModel.fromJson(Map json) => + _$CandidateModelFromJson(json); } diff --git a/lib/src/features/video_chat_feature/webrtc_service/webrtc_laravel_service.dart b/lib/src/features/video_chat_feature/webrtc_service/webrtc_laravel_service.dart index c3c7674..07d4605 100644 --- a/lib/src/features/video_chat_feature/webrtc_service/webrtc_laravel_service.dart +++ b/lib/src/features/video_chat_feature/webrtc_service/webrtc_laravel_service.dart @@ -18,8 +18,8 @@ class WebrtcLaravelService { WebrtcLaravelService({ required final PusherClientService pusherClientService, required RestClientBase restClientBase, - }) : _pusherClientService = pusherClientService, - _restClientBase = restClientBase; + }) : _pusherClientService = pusherClientService, + _restClientBase = restClientBase; final RestClientBase _restClientBase; final PusherClientService _pusherClientService; @@ -49,7 +49,7 @@ class WebrtcLaravelService { 'stun:stun1.l.google.com:19302', 'stun:stun2.l.google.com:19302', ], - } + }, ], }; @@ -70,9 +70,11 @@ class WebrtcLaravelService { SetStateCallbackSignal? setSetStateCallback; - StreamSubscription? calleeStreamSubs; // same channel stream but accepts different data + StreamSubscription? + calleeStreamSubs; // same channel stream but accepts different data - StreamSubscription? callerStreamSubs; // same channel stream but accepts different data + StreamSubscription? + callerStreamSubs; // same channel stream but accepts different data Future createRoom(ChatModel? chat) async { try { @@ -95,10 +97,7 @@ class WebrtcLaravelService { // Send offer to backend final response = await _restClientBase.post( _createRoom, - data: { - 'offer': offer.toMap(), - "chat_id": chat?.id, - }, + data: {'offer': offer.toMap(), "chat_id": chat?.id}, ); final roomId = response?['roomId']; @@ -123,7 +122,9 @@ class WebrtcLaravelService { try { final pusherService = await _pusherClientService.subscriptionCreator(); - final channel = pusherService.publicChannel(Constants.webRtcChannelName); + final channel = pusherService.publicChannel( + Constants.webRtcChannelName, + ); calleeStreamSubs = pusherService.onConnectionEstablished.listen((e) { channel.subscribeIfNotUnsubscribed(); @@ -140,10 +141,7 @@ class WebrtcLaravelService { final String sdp = data['answer']['sdp'] + "\n"; final String type = data['answer']['type']; - final answer = RTCSessionDescription( - sdp, - type, - ); + final answer = RTCSessionDescription(sdp, type); // if (peerConnection?.signalingState == // RTCSignalingState.RTCSignalingStateHaveLocalOffer) { if (await peerConnection?.getRemoteDescription() == null) { @@ -154,10 +152,13 @@ class WebrtcLaravelService { if (responseCandidates == null) return; // - final List listOfCandidates = responseCandidates.getNested(['candidates']); + final List listOfCandidates = responseCandidates + .getNested(['candidates']); final List candidates = - listOfCandidates.map((e) => CandidateModel.fromJson(e)).toList(); + listOfCandidates + .map((e) => CandidateModel.fromJson(e)) + .toList(); for (final each in candidates) { await peerConnection?.addCandidate( @@ -210,9 +211,7 @@ class WebrtcLaravelService { // for getting room configuration final responseForRemoteConfig = await _restClientBase.post( _joinRoom, - data: { - 'roomId': roomId, - }, + data: {'roomId': roomId}, ); if (responseForRemoteConfig == null) return; @@ -249,7 +248,10 @@ class WebrtcLaravelService { // sdp = sdp.replaceAll("\r\na=extmap-allow-mixed", ""); - final RTCSessionDescription remoteDescription = RTCSessionDescription(sdp, type); + final RTCSessionDescription remoteDescription = RTCSessionDescription( + sdp, + type, + ); try { await peerConnection?.setRemoteDescription(remoteDescription); @@ -265,10 +267,7 @@ class WebrtcLaravelService { final response = await _restClientBase.post( _joinRoom, - data: { - 'roomId': roomId, - 'answer': answer.toMap(), - }, + data: {'roomId': roomId, 'answer': answer.toMap()}, ); } catch (e) { debugPrint("creating answer error is: $e"); @@ -288,7 +287,9 @@ class WebrtcLaravelService { ); // - final List listOfCandidates = responseCandidates?.getNested(['candidates']); + final List listOfCandidates = responseCandidates?.getNested([ + 'candidates', + ]); final List candidates = listOfCandidates.map((e) => CandidateModel.fromJson(e)).toList(); @@ -314,9 +315,12 @@ class WebrtcLaravelService { channel.bind(Constants.webRtcChannelEventName).listen((e) async { // code here tomorrow - final Map data = e.data is String ? jsonDecode(e.toString()) : e.data; + final Map data = + e.data is String ? jsonDecode(e.toString()) : e.data; - if (data.containsKey("candidate") && data.containsKey("role") && data['role'] == 'caller') { + if (data.containsKey("candidate") && + data.containsKey("role") && + data['role'] == 'caller') { peerConnection?.addCandidate( RTCIceCandidate( data['candidate']['candidate'], @@ -354,10 +358,10 @@ class WebrtcLaravelService { } // close all - Future hangUp( - RTCVideoRenderer? localVideo, - ) async { - localVideo?.srcObject?.getTracks().forEach(((track) async => await track.stop())); + Future hangUp(RTCVideoRenderer? localVideo) async { + localVideo?.srcObject?.getTracks().forEach( + ((track) async => await track.stop()), + ); if (remoteStream != null) { remoteStream!.getTracks().forEach((track) async => await track.stop()); @@ -401,11 +405,7 @@ class WebrtcLaravelService { ) async { final response = await _restClientBase.post( _addIceCandidates, - data: { - 'roomId': roomId, - 'candidate': candidate.toMap(), - 'role': role, - }, + data: {'roomId': roomId, 'candidate': candidate.toMap(), 'role': role}, ); } diff --git a/lib/src/features/video_chat_feature/widgets/type_of_screens/double_camera_view_screen.dart b/lib/src/features/video_chat_feature/widgets/type_of_screens/double_camera_view_screen.dart index 6c4610d..f32c7df 100644 --- a/lib/src/features/video_chat_feature/widgets/type_of_screens/double_camera_view_screen.dart +++ b/lib/src/features/video_chat_feature/widgets/type_of_screens/double_camera_view_screen.dart @@ -23,17 +23,21 @@ class _DoubleCameraViewScreenState extends State { Expanded( child: RTCVideoView( objectFit: RTCVideoViewObjectFit.RTCVideoViewObjectFitCover, - state.videoChatStateModel.videoChatEntities.first.videoRenderer!, + state + .videoChatStateModel + .videoChatEntities + .first + .videoRenderer!, ), ), - const Divider( - height: 0, - color: Colors.black12, - ), + const Divider(height: 0, color: Colors.black12), Expanded( child: RTCVideoView( objectFit: RTCVideoViewObjectFit.RTCVideoViewObjectFitCover, - state.videoChatStateModel.currentVideoChatEntity!.videoRenderer!, + state + .videoChatStateModel + .currentVideoChatEntity! + .videoRenderer!, mirror: !state.videoChatStateModel.cameraSwitched, ), ), diff --git a/lib/src/features/video_chat_feature/widgets/video_chat_feature_page.dart b/lib/src/features/video_chat_feature/widgets/video_chat_feature_page.dart index e6dfa3a..53c681b 100644 --- a/lib/src/features/video_chat_feature/widgets/video_chat_feature_page.dart +++ b/lib/src/features/video_chat_feature/widgets/video_chat_feature_page.dart @@ -15,21 +15,20 @@ import 'widgets/hang_up_buttons_widget.dart'; class VideoChatFeaturePage extends StatelessWidget { final ChatModel? chat; - const VideoChatFeaturePage({ - super.key, - required this.chat, - }); + const VideoChatFeaturePage({super.key, required this.chat}); @override Widget build(BuildContext context) { final depContainer = DependenciesScope.of(context, listen: false); return BlocProvider( - create: (_) => VideoChatBlocFactory( - user: depContainer.authBloc.state.authStateModel.user, - pusherClientService: depContainer.pusherClientService, - logger: depContainer.logger, - restClientBase: depContainer.restClientBase, - ).create(), + create: + (_) => + VideoChatBlocFactory( + user: depContainer.authBloc.state.authStateModel.user, + pusherClientService: depContainer.pusherClientService, + logger: depContainer.logger, + restClientBase: depContainer.restClientBase, + ).create(), child: _VideoChatFeaturePageUI(chat: chat), ); } @@ -41,7 +40,8 @@ class _VideoChatFeaturePageUI extends StatefulWidget { const _VideoChatFeaturePageUI({required this.chat}); @override - State<_VideoChatFeaturePageUI> createState() => _VideoChatFeaturePageUIState(); + State<_VideoChatFeaturePageUI> createState() => + _VideoChatFeaturePageUIState(); } class _VideoChatFeaturePageUIState extends State<_VideoChatFeaturePageUI> { @@ -49,10 +49,8 @@ class _VideoChatFeaturePageUIState extends State<_VideoChatFeaturePageUI> { void initState() { super.initState(); context.read().add( - VideoChatFeatureEvents.videoChatInitFeatureEvent( - widget.chat, - ), - ); + VideoChatFeatureEvents.videoChatInitFeatureEvent(widget.chat), + ); } @override @@ -77,9 +75,10 @@ class _VideoChatFeaturePageUIState extends State<_VideoChatFeaturePageUI> { left: 0, right: 0, child: Center( - child: currentStateModel.chatStarted - ? const HangUpButtonsWidget() - : const CallButtonWidget(), + child: + currentStateModel.chatStarted + ? const HangUpButtonsWidget() + : const CallButtonWidget(), ), ), ], diff --git a/lib/src/features/video_chat_feature/widgets/widgets/call_button_widget.dart b/lib/src/features/video_chat_feature/widgets/widgets/call_button_widget.dart index 41aa0e4..324f021 100644 --- a/lib/src/features/video_chat_feature/widgets/widgets/call_button_widget.dart +++ b/lib/src/features/video_chat_feature/widgets/widgets/call_button_widget.dart @@ -4,9 +4,7 @@ import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:yahay/src/features/video_chat_feature/bloc/video_chat_feature_bloc.dart'; class CallButtonWidget extends StatefulWidget { - const CallButtonWidget({ - super.key, - }); + const CallButtonWidget({super.key}); @override State createState() => _CallButtonWidgetState(); @@ -50,8 +48,11 @@ class _CallButtonWidgetState extends State { const SizedBox(height: 10), const Text( "Decline", - style: - TextStyle(color: Colors.white, fontWeight: FontWeight.w500, letterSpacing: 1.5), + style: TextStyle( + color: Colors.white, + fontWeight: FontWeight.w500, + letterSpacing: 1.5, + ), ), ], ), @@ -60,41 +61,41 @@ class _CallButtonWidgetState extends State { return Column( children: [ Material( - color: state.videoChatStateModel.chat?.videoChatRoom != null - ? Colors.blue - : Colors.green, + color: + state.videoChatStateModel.chat?.videoChatRoom != null + ? Colors.blue + : Colors.green, borderRadius: BorderRadius.circular(50), child: InkWell( borderRadius: BorderRadius.circular(50), onTap: () { - if (state.videoChatStateModel.chat?.videoChatRoom != null) { + if (state.videoChatStateModel.chat?.videoChatRoom != + null) { debugPrint("working22 here"); - context - .read() - .add(const VideoChatFeatureEvents.videoChatEntranceEvent()); + context.read().add( + const VideoChatFeatureEvents.videoChatEntranceEvent(), + ); } else { debugPrint("working11 here"); - context - .read() - .add(const VideoChatFeatureEvents.startVideoChatEvent()); + context.read().add( + const VideoChatFeatureEvents.startVideoChatEvent(), + ); } }, child: const SizedBox( width: 90, height: 90, child: Center( - child: Icon( - Icons.call, - size: 35, - color: Colors.white, - ), + child: Icon(Icons.call, size: 35, color: Colors.white), ), ), ), ), const SizedBox(height: 10), Text( - state.videoChatStateModel.chat?.videoChatRoom != null ? "Accept" : "Call", + state.videoChatStateModel.chat?.videoChatRoom != null + ? "Accept" + : "Call", style: const TextStyle( color: Colors.white, fontWeight: FontWeight.w500, diff --git a/lib/src/features/video_chat_feature/widgets/widgets/hang_up_buttons_widget.dart b/lib/src/features/video_chat_feature/widgets/widgets/hang_up_buttons_widget.dart index 16f7651..be7942d 100644 --- a/lib/src/features/video_chat_feature/widgets/widgets/hang_up_buttons_widget.dart +++ b/lib/src/features/video_chat_feature/widgets/widgets/hang_up_buttons_widget.dart @@ -22,9 +22,9 @@ class _HangUpButtonsWidgetState extends State { child: InkWell( borderRadius: BorderRadius.circular(50), onTap: () async { - context - .read() - .add(const VideoChatFeatureEvents.switchCameraStreamEvent()); + context.read().add( + const VideoChatFeatureEvents.switchCameraStreamEvent(), + ); }, child: const SizedBox( width: 60, @@ -47,9 +47,9 @@ class _HangUpButtonsWidgetState extends State { child: InkWell( borderRadius: BorderRadius.circular(50), onTap: () { - context - .read() - .add(const VideoChatFeatureEvents.turnCameraOffAndEvent()); + context.read().add( + const VideoChatFeatureEvents.turnCameraOffAndEvent(), + ); }, child: Stack( children: [ @@ -91,9 +91,9 @@ class _HangUpButtonsWidgetState extends State { child: InkWell( borderRadius: BorderRadius.circular(50), onTap: () { - context - .read() - .add(const VideoChatFeatureEvents.turnMicOffAndOnEvent()); + context.read().add( + const VideoChatFeatureEvents.turnMicOffAndOnEvent(), + ); }, child: SizedBox( width: 60, diff --git a/pubspec.lock b/pubspec.lock index 71bf611..e944f58 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -50,10 +50,10 @@ packages: dependency: transitive description: name: async - sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c" + sha256: d2872f9c19731c2e5f10444b14686eb7cc85c76274bd6c16e1816bff9a3bab63 url: "https://pub.dev" source: hosted - version: "2.11.0" + version: "2.12.0" auto_route: dependency: "direct main" description: @@ -90,10 +90,10 @@ packages: dependency: transitive description: name: boolean_selector - sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66" + sha256: "8aab1771e1243a5063b8b0ff68042d67334e3feab9e95b9490f9a6ebf73b42ea" url: "https://pub.dev" source: hosted - version: "2.1.1" + version: "2.1.2" build: dependency: transitive description: @@ -226,10 +226,10 @@ packages: dependency: transitive description: name: characters - sha256: "04a925763edad70e8443c99234dc3328f442e811f1d8fd1a72f1c8ad0f69a605" + sha256: f71061c654a3380576a52b451dd5532377954cf9dbd272a78fc8479606670803 url: "https://pub.dev" source: hosted - version: "1.3.0" + version: "1.4.0" checked_yaml: dependency: transitive description: @@ -242,10 +242,10 @@ packages: dependency: "direct main" description: name: clock - sha256: cb6d7f03e1de671e34607e909a7213e31d7752be4fb66a86d29fe1eb14bfb5cf + sha256: fddb70d9b5277016c77a80201021d40a2247104d9f4aa7bab7157b7e3f05b84b url: "https://pub.dev" source: hosted - version: "1.1.1" + version: "1.1.2" code_builder: dependency: transitive description: @@ -258,10 +258,10 @@ packages: dependency: "direct main" description: name: collection - sha256: a1ace0a119f20aabc852d165077c036cd864315bd99b7eaa10a60100341941bf + sha256: "2f5709ae4d3d59dd8f7cd309b4e023046b57d8a6c82130785d2b0e5868084e76" url: "https://pub.dev" source: hosted - version: "1.19.0" + version: "1.19.1" convert: dependency: transitive description: @@ -378,10 +378,10 @@ packages: dependency: transitive description: name: fake_async - sha256: "511392330127add0b769b75a987850d136345d9227c6b94c96a04cf4a391bf78" + sha256: "6a95e56b2449df2273fd8c45a662d6947ce1ebb7aafe80e550a3f68297f3cacc" url: "https://pub.dev" source: hosted - version: "1.3.1" + version: "1.3.2" ffi: dependency: transitive description: @@ -958,18 +958,18 @@ packages: dependency: transitive description: name: leak_tracker - sha256: "7bb2830ebd849694d1ec25bf1f44582d6ac531a57a365a803a6034ff751d2d06" + sha256: c35baad643ba394b40aac41080300150a4f08fd0fd6a10378f8f7c6bc161acec url: "https://pub.dev" source: hosted - version: "10.0.7" + version: "10.0.8" leak_tracker_flutter_testing: dependency: transitive description: name: leak_tracker_flutter_testing - sha256: "9491a714cca3667b60b5c420da8217e6de0d1ba7a5ec322fab01758f6998f379" + sha256: f8b613e7e6a13ec79cfdc0e97638fddb3ab848452eff057653abd3edba760573 url: "https://pub.dev" source: hosted - version: "3.0.8" + version: "3.0.9" leak_tracker_testing: dependency: transitive description: @@ -1014,10 +1014,10 @@ packages: dependency: transitive description: name: matcher - sha256: d2323aa2060500f906aa31a895b4030b6da3ebdcc5619d14ce1aada65cd161cb + sha256: dc58c723c3c24bf8d3e2d3ad3f2f9d7bd9cf43ec6feaa64181775e60190153f2 url: "https://pub.dev" source: hosted - version: "0.12.16+1" + version: "0.12.17" material_color_utilities: dependency: transitive description: @@ -1030,10 +1030,10 @@ packages: dependency: transitive description: name: meta - sha256: bdb68674043280c3428e9ec998512fb681678676b3c54e773629ffe74419f8c7 + sha256: e3641ec5d63ebf0d9b41bd43201a66e3fc79a65db5f61fc181f04cd27aab950c url: "https://pub.dev" source: hosted - version: "1.15.0" + version: "1.16.0" mime: dependency: transitive description: @@ -1094,10 +1094,10 @@ packages: dependency: "direct main" description: name: path - sha256: "087ce49c3f0dc39180befefc60fdb4acd8f8620e5682fe2476afd0b3688bb4af" + sha256: "75cca69d1490965be98c73ceaea117e8a04dd21217b37b292c9ddbec0d955bc5" url: "https://pub.dev" source: hosted - version: "1.9.0" + version: "1.9.1" path_provider: dependency: "direct main" description: @@ -1387,10 +1387,10 @@ packages: dependency: transitive description: name: source_span - sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c" + sha256: "254ee5351d6cb365c859e20ee823c3bb479bf4a293c22d17a9f1bf144ce86f7c" url: "https://pub.dev" source: hosted - version: "1.10.0" + version: "1.10.1" sprintf: dependency: transitive description: @@ -1443,18 +1443,18 @@ packages: dependency: transitive description: name: stack_trace - sha256: "9f47fd3630d76be3ab26f0ee06d213679aa425996925ff3feffdec504931c377" + sha256: "8b27215b45d22309b5cddda1aa2b19bdfec9df0e765f2de506401c071d38d1b1" url: "https://pub.dev" source: hosted - version: "1.12.0" + version: "1.12.1" stream_channel: dependency: transitive description: name: stream_channel - sha256: ba2aa5d8cc609d96bbb2899c28934f9e1af5cddbd60a827822ea467161eb54e7 + sha256: "969e04c80b8bcdf826f8f16579c7b14d780458bd97f56d107d3950fdbeef059d" url: "https://pub.dev" source: hosted - version: "2.1.2" + version: "2.1.4" stream_transform: dependency: transitive description: @@ -1467,10 +1467,10 @@ packages: dependency: transitive description: name: string_scanner - sha256: "688af5ed3402a4bde5b3a6c15fd768dbf2621a614950b17f04626c431ab3c4c3" + sha256: "921cd31725b72fe181906c6a94d987c78e3b98c2e205b397ea399d4054872b43" url: "https://pub.dev" source: hosted - version: "1.3.0" + version: "1.4.1" synchronized: dependency: transitive description: @@ -1499,18 +1499,18 @@ packages: dependency: transitive description: name: term_glyph - sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84 + sha256: "7f554798625ea768a7518313e58f83891c7f5024f88e46e7182a4558850a4b8e" url: "https://pub.dev" source: hosted - version: "1.2.1" + version: "1.2.2" test_api: dependency: transitive description: name: test_api - sha256: "664d3a9a64782fcdeb83ce9c6b39e78fd2971d4e37827b9b06c3aa1edc5e760c" + sha256: fb31f383e2ee25fbbfe06b40fe21e1e458d14080e3c67e7ba0acfde4df4e0bbd url: "https://pub.dev" source: hosted - version: "0.7.3" + version: "0.7.4" timeago: dependency: "direct main" description: @@ -1603,10 +1603,10 @@ packages: dependency: transitive description: name: vm_service - sha256: f6be3ed8bd01289b34d679c2b62226f63c0e69f9fd2e50a6b3c1c729a961041b + sha256: "0968250880a6c5fe7edc067ed0a13d4bae1577fe2771dcf3010d52c4a9d3ca14" url: "https://pub.dev" source: hosted - version: "14.3.0" + version: "14.3.1" watcher: dependency: transitive description: @@ -1680,5 +1680,5 @@ packages: source: hosted version: "3.1.3" sdks: - dart: ">=3.6.0 <4.0.0" + dart: ">=3.7.0 <4.0.0" flutter: ">=3.27.0" diff --git a/pubspec.yaml b/pubspec.yaml index 850de6a..f19abb6 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -19,7 +19,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev version: 1.0.0+1 environment: - sdk: '>=3.3.4 <4.0.0' + sdk: ^3.7.0 # Dependencies specify other packages that your package needs in order to work. # To automatically upgrade your package dependencies to the latest versions From f0e4061f08bc489d72c5bea697f6ecb6bdfc8713 Mon Sep 17 00:00:00 2001 From: sarbador Date: Fri, 7 Mar 2025 17:44:04 +0500 Subject: [PATCH 05/10] uploaded with new version of dart and formatted lib folder --- .../features/profile/view/profile_page.dart | 20 ++++++++++++++++--- .../ephemeral/Flutter-Generated.xcconfig | 4 ++-- .../ephemeral/flutter_export_environment.sh | 4 ++-- pubspec.yaml | 10 +++++----- 4 files changed, 26 insertions(+), 12 deletions(-) diff --git a/lib/src/features/profile/view/profile_page.dart b/lib/src/features/profile/view/profile_page.dart index 4feb7b2..85762a4 100644 --- a/lib/src/features/profile/view/profile_page.dart +++ b/lib/src/features/profile/view/profile_page.dart @@ -29,11 +29,25 @@ class _ProfilePageState extends State { leadingWidth: 0.0, title: const Text("Profile"), actions: [ - IconButton(onPressed: () {}, icon: const Icon(Icons.qr_code)), - IconButton(onPressed: () {}, icon: const Icon(Icons.more_vert)), + IconButton( + onPressed: () {}, + icon: const Icon( + Icons.qr_code, + ), + ), + IconButton( + onPressed: () {}, + icon: const Icon( + Icons.more_vert, + ), + ), + ], + ), + body: const CustomScrollView( + slivers: [ + ], ), - body: const CustomScrollView(slivers: []), ); } } diff --git a/macos/Flutter/ephemeral/Flutter-Generated.xcconfig b/macos/Flutter/ephemeral/Flutter-Generated.xcconfig index 4d5067d..f0c1f2d 100644 --- a/macos/Flutter/ephemeral/Flutter-Generated.xcconfig +++ b/macos/Flutter/ephemeral/Flutter-Generated.xcconfig @@ -1,6 +1,6 @@ // This is a generated file; do not edit or check into version control. -FLUTTER_ROOT=/Users/avaz/development/flutter -FLUTTER_APPLICATION_PATH=/Users/avaz/StudioProjects/Yahay-Flutter +FLUTTER_ROOT=/home/sarbador_/snap/flutter/common/flutter +FLUTTER_APPLICATION_PATH=/home/sarbador_/StudioProjects/yahay COCOAPODS_PARALLEL_CODE_SIGN=true FLUTTER_BUILD_DIR=build FLUTTER_BUILD_NAME=1.0.0 diff --git a/macos/Flutter/ephemeral/flutter_export_environment.sh b/macos/Flutter/ephemeral/flutter_export_environment.sh index dfc3cb2..12b3f7d 100755 --- a/macos/Flutter/ephemeral/flutter_export_environment.sh +++ b/macos/Flutter/ephemeral/flutter_export_environment.sh @@ -1,7 +1,7 @@ #!/bin/sh # This is a generated file; do not edit or check into version control. -export "FLUTTER_ROOT=/Users/avaz/development/flutter" -export "FLUTTER_APPLICATION_PATH=/Users/avaz/StudioProjects/Yahay-Flutter" +export "FLUTTER_ROOT=/home/sarbador_/snap/flutter/common/flutter" +export "FLUTTER_APPLICATION_PATH=/home/sarbador_/StudioProjects/yahay" export "COCOAPODS_PARALLEL_CODE_SIGN=true" export "FLUTTER_BUILD_DIR=build" export "FLUTTER_BUILD_NAME=1.0.0" diff --git a/pubspec.yaml b/pubspec.yaml index f19abb6..6ed1f1e 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -37,7 +37,7 @@ dependencies: # Use with the CupertinoIcons class for iOS style icons. path: ^1.9.0 path_provider: ^2.1.3 -# lecle_downloads_path_provider: ^0.0.2+8 + # lecle_downloads_path_provider: ^0.0.2+8 cupertino_icons: ^1.0.6 rxdart: ^0.27.7 # get_it: ^7.7.0 @@ -54,7 +54,7 @@ dependencies: flex_color_scheme: ^7.3.1 shared_preferences: ^2.2.3 timeago: ^3.6.1 -# flutter_dotenv: ^5.1.0 + # flutter_dotenv: ^5.1.0 freezed_annotation: ^2.4.1 json_annotation: ^4.9.0 fluttertoast: ^8.2.5 @@ -75,7 +75,7 @@ dependencies: # for file picker feature photo_manager: ^3.6.3 -# wechat_assets_picker: ^9.0.0 + # wechat_assets_picker: ^9.0.0 camera: ^0.11.0+1 video_player: ^2.9.1 get_thumbnail_video: ^0.7.3 @@ -85,7 +85,7 @@ dependencies: flutter_bloc: ^9.0.0 bloc_concurrency: ^0.3.0 provider: ^6.1.2 -# rive: ^0.13.20 + # rive: ^0.13.20 hexcolor: ^3.0.1 clock: ^1.1.1 # flutter_bloc: ^8.1.6 @@ -124,7 +124,7 @@ flutter: # To add assets to your application, add an assets section, like this: assets: -# - .env + # - .env - assets/default_images/ - assets/rive/ From c8e846fbec6698be2926bbca409c0f454071951b Mon Sep 17 00:00:00 2001 From: sarbador Date: Fri, 7 Mar 2025 18:18:03 +0500 Subject: [PATCH 06/10] added formatter width in analysis_option.yaml file --- analysis_options.yaml | 20 +- .../global_usages/constants/constants.dart | 3 +- .../reusables/reusable_global_functions.dart | 9 +- .../bottom_navbar_item.dart | 6 +- .../chat_message_model.dart | 3 +- .../chat_participant_status_model.dart | 3 +- .../core/models/chats_model/chat_model.dart | 3 +- .../core/models/room_models/room_model.dart | 3 +- .../core/models/user_model/user_model.dart | 3 +- .../ui_kit/image_loader/image_loaded.dart | 5 +- .../ui_kit/search_widget/search_widget.dart | 10 +- .../user_widgets/add_contact_user_widget.dart | 25 +- .../bloc_observer_manager.dart | 18 +- .../camera_helper_service.dart | 3 +- .../debug_image_creator_in_apps_folder.dart | 11 +- .../src/exceptions/rest_client_exception.dart | 34 +-- .../core/utils/dio/src/rest_client_base.dart | 25 +- .../core/utils/dio/src/rest_client_dio.dart | 17 +- lib/src/core/utils/extensions/extensions.dart | 3 +- .../utils/global_context/global_context.dart | 3 +- .../image_comporessor/image_compressor.dart | 13 +- .../list_pagination_checker.dart | 11 +- .../screen_messaging/screen_messaging.dart | 6 +- .../shared_preferences.dart | 10 +- .../bloc/add_contact_bloc.dart | 42 +--- .../state_model/add_contact_state_model.dart | 6 +- .../data/add_contact_repo.dart | 3 +- .../data/add_contact_source.dart | 8 +- .../view/pages/add_contacts_page.dart | 37 +-- .../app_theme/bloc/app_theme_bloc.dart | 10 +- .../authorization/bloc/auth_bloc.dart | 49 +--- .../bloc/state_model/auth_state_model.dart | 5 +- .../data/repo/authorization_repo_impl.dart | 11 +- .../impl/laravel_auth_data_source_impl.dart | 26 +-- .../laravel/laravel_auth_data_source.dart | 5 +- .../impl/other_authorization_impl.dart | 13 +- .../domain/repo/authorization_repo.dart | 5 +- .../authorization/view/login_page.dart | 57 ++--- .../authorization/view/register_page.dart | 55 ++--- .../widgets/authorization_input_widget.dart | 8 +- .../chat_screen/bloc/chat_screen_bloc.dart | 77 ++----- .../chat_message_stream_transformer.dart | 20 +- .../impl/chat_screen_chat_data_souce.dart | 8 +- .../chat_screen_message_data_source_impl.dart | 13 +- .../view/app_bar/chat_screen_app_bar.dart | 19 +- .../bottom_chat_widget.dart | 31 +-- .../emoji_picker_helper.dart | 10 +- .../chat_screen/view/chat_screen.dart | 38 +-- .../loading_messages_widget.dart | 10 +- .../view/message_widget/message_widget.dart | 26 +-- lib/src/features/chats/bloc/chats_bloc.dart | 74 ++---- .../bloc/state_model/chats_state_model.dart | 4 +- .../chats_stream_transformers.dart | 3 +- .../chats/view/chat_widget/chat_widget.dart | 19 +- .../chats/view/chats_appbar/chats_appbar.dart | 8 +- lib/src/features/chats/view/chats_page.dart | 8 +- lib/src/features/home_page.dart | 7 +- .../initialization/logic/app_runner.dart | 21 +- .../composition_root/composition_root.dart | 8 +- .../factories/add_contact_bloc_factory.dart | 5 +- .../factories/authorization_bloc_factory.dart | 35 ++- .../factories/chat_screen_bloc_factory.dart | 14 +- .../factories/chats_bloc_factory.dart | 4 +- .../factories/profile_bloc_factory.dart | 17 +- .../telegram_file_picker_bloc_factory.dart | 15 +- .../factories/video_chat_bloc_factory.dart | 9 +- .../models/dependency_container.dart | 6 +- .../widgets/dependencies_scope.dart | 11 +- lib/src/features/loading_page.dart | 13 +- .../features/profile/bloc/profile_bloc.dart | 32 +-- .../features/profile/view/profile_page.dart | 20 +- .../profile_header_loading_widget.dart | 6 +- .../profile_header/profile_header_widget.dart | 6 +- .../profile_settings_loading_widget.dart | 6 +- .../telegram_file_picker_state_model.dart | 40 ++-- .../bloc/telegram_file_picker_bloc.dart | 216 +++++------------- .../telegram_file_picker_bottom_button.dart | 20 +- ...legram_storage_file_picker_data_model.dart | 4 +- .../repo/telegram_file_picker_repo_impl.dart | 8 +- .../repo/telegram_file_picker_repo.dart | 4 +- .../app_storage_file_mixin.dart | 9 +- .../mixins/folder_creator/folder_creator.dart | 9 +- .../downloads_path_files.dart | 11 +- .../recent_galley_file_mixin.dart | 9 +- .../telegram_bottom_picker_button.dart | 11 +- .../telegram_bottom_sender_button.dart | 16 +- .../telegram_storage_file_widget.dart | 52 ++--- .../telegram_browse_app_folder_screen.dart | 13 +- .../telegram_browse_folder_data_screen.dart | 11 +- .../telegram_browse_folder_widget.dart | 15 +- .../telegram_files_picker_screen.dart | 86 ++----- .../telegram_files_from_storages_widget.dart | 11 +- ...gram_resent_files_from_storage_widget.dart | 9 +- .../telegram_gallery_file_picker_screen.dart | 37 +-- ...ram_gallery_file_picker_camera_widget.dart | 13 +- ...gram_gallery_file_picker_image_widget.dart | 4 +- ...llery_file_picker_video_player_widget.dart | 11 +- ...ram_draggable_scrollable_bottom_sheet.dart | 19 +- .../state_model/video_chat_state_model.dart | 3 +- .../bloc/video_chat_feature_bloc.dart | 84 +++---- .../data/video_chat_feature_data_source.dart | 22 +- .../candidate_model/candidate_model.dart | 6 +- .../models/video_chat_model.dart | 7 +- .../webrtc_laravel_service.dart | 56 ++--- .../double_camera_view_screen.dart | 11 +- .../widgets/video_chat_feature_page.dart | 3 +- .../widgets/widgets/call_button_widget.dart | 17 +- .../widgets/hang_up_buttons_widget.dart | 24 +- 108 files changed, 545 insertions(+), 1516 deletions(-) diff --git a/analysis_options.yaml b/analysis_options.yaml index b17401c..6fce0b3 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -1,12 +1,6 @@ -# This file configures the analyzer, which statically analyzes Dart code to -# check for errors, warnings, and lints. -# -# The issues identified by the analyzer are surfaced in the UI of Dart-enabled -# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be -# invoked from the command line by running `flutter analyze`. +formatter: + page_width: 100 -# The following line activates a set of recommended lints for Flutter apps, -# packages, and plugins designed to encourage good coding practices. analyzer: errors: invalid_annotation_target: ignore @@ -17,16 +11,6 @@ analyzer: include: package:flutter_lints/flutter.yaml linter: - # The lint rules applied to this project can be customized in the - # section below to disable rules from the `package:flutter_lints/flutter.yaml` - # included above or to enable additional rules. A list of all available lints - # and their documentation is published at https://dart.dev/lints. - # - # Instead of disabling a lint rule for the entire project in the - # section below, it can also be suppressed for a single line of code - # or a specific dart file by using the `// ignore: name_of_lint` and - # `// ignore_for_file: name_of_lint` syntax on the line or in the file - # producing the lint. rules: # for commas, if code goes far from specific width length # https://dart.dev/tools/linter-rules/require_trailing_commas diff --git a/lib/src/core/global_usages/constants/constants.dart b/lib/src/core/global_usages/constants/constants.dart index 07cdc5e..1211a22 100644 --- a/lib/src/core/global_usages/constants/constants.dart +++ b/lib/src/core/global_usages/constants/constants.dart @@ -44,8 +44,7 @@ abstract class Constants { // static const String killIsolate = "kill_isolate"; - static const String somethingWentWrong = - "Something went wrong, please, try later"; + static const String somethingWentWrong = "Something went wrong, please, try later"; static const double minimumHeightForShowingRiveTextFieldAnim = 650; } diff --git a/lib/src/core/global_usages/reusables/reusable_global_functions.dart b/lib/src/core/global_usages/reusables/reusable_global_functions.dart index 79be722..6bfb42c 100644 --- a/lib/src/core/global_usages/reusables/reusable_global_functions.dart +++ b/lib/src/core/global_usages/reusables/reusable_global_functions.dart @@ -4,8 +4,7 @@ import 'package:path/path.dart' as path; class ReusableGlobalFunctions { static ReusableGlobalFunctions? _instance; - static ReusableGlobalFunctions get instance => - _instance ??= ReusableGlobalFunctions._(); + static ReusableGlobalFunctions get instance => _instance ??= ReusableGlobalFunctions._(); ReusableGlobalFunctions._(); @@ -123,16 +122,14 @@ class ReusableGlobalFunctions { res += '$hours:'; } } - final int minutes = - (duration?.inMinutes ?? 0) - (60 * (duration?.inHours ?? 0)); + final int minutes = (duration?.inMinutes ?? 0) - (60 * (duration?.inHours ?? 0)); if (minutes >= 0 && minutes <= 9) { res += "0$minutes:"; } else { res += '$minutes:'; } //to get totalSeconds in 60 type second - final int seconds = - (duration?.inSeconds ?? 0) - (60 * (duration?.inMinutes ?? 0)); + final int seconds = (duration?.inSeconds ?? 0) - (60 * (duration?.inMinutes ?? 0)); if (seconds >= 0 && seconds <= 9) { res += "0$seconds"; } else { diff --git a/lib/src/core/models/bottom_navbar_item/bottom_navbar_item.dart b/lib/src/core/models/bottom_navbar_item/bottom_navbar_item.dart index 6a4c726..8ca65e9 100644 --- a/lib/src/core/models/bottom_navbar_item/bottom_navbar_item.dart +++ b/lib/src/core/models/bottom_navbar_item/bottom_navbar_item.dart @@ -6,9 +6,5 @@ class BottomNavbarItem { final Widget icon; final String label; - const BottomNavbarItem({ - required this.screen, - required this.icon, - required this.label, - }); + const BottomNavbarItem({required this.screen, required this.icon, required this.label}); } diff --git a/lib/src/core/models/chat_message_model/chat_message_model.dart b/lib/src/core/models/chat_message_model/chat_message_model.dart index 267f07f..730d667 100644 --- a/lib/src/core/models/chat_message_model/chat_message_model.dart +++ b/lib/src/core/models/chat_message_model/chat_message_model.dart @@ -29,6 +29,5 @@ class ChatMessageModel with _$ChatMessageModel { @JsonKey(includeToJson: false, includeFromJson: false) bool? messageSent, }) = _ChatMessageModel; - factory ChatMessageModel.fromJson(Map json) => - _$ChatMessageModelFromJson(json); + factory ChatMessageModel.fromJson(Map json) => _$ChatMessageModelFromJson(json); } diff --git a/lib/src/core/models/chat_participant_status_model/chat_participant_status_model.dart b/lib/src/core/models/chat_participant_status_model/chat_participant_status_model.dart index bea4361..0aec4d1 100644 --- a/lib/src/core/models/chat_participant_status_model/chat_participant_status_model.dart +++ b/lib/src/core/models/chat_participant_status_model/chat_participant_status_model.dart @@ -8,8 +8,7 @@ part 'chat_participant_status_model.g.dart'; @freezed class ChatParticipantStatusModel with _$ChatParticipantStatusModel { - const factory ChatParticipantStatusModel({int? id, String? status}) = - _ChatParticipantStatusModel; + const factory ChatParticipantStatusModel({int? id, String? status}) = _ChatParticipantStatusModel; factory ChatParticipantStatusModel.fromJson(Map json) => _$ChatParticipantStatusModelFromJson(json); diff --git a/lib/src/core/models/chats_model/chat_model.dart b/lib/src/core/models/chats_model/chat_model.dart index bd71293..57f9c0a 100644 --- a/lib/src/core/models/chats_model/chat_model.dart +++ b/lib/src/core/models/chats_model/chat_model.dart @@ -45,8 +45,7 @@ class ChatModel with _$ChatModel { bool? videoChatStreaming, }) = _ChatModel; - factory ChatModel.fromJson(Map json) => - _$ChatModelFromJson(json); + factory ChatModel.fromJson(Map json) => _$ChatModelFromJson(json); String getWrappedName() { if (name == null) return ''; diff --git a/lib/src/core/models/room_models/room_model.dart b/lib/src/core/models/room_models/room_model.dart index dd51002..db4c861 100644 --- a/lib/src/core/models/room_models/room_model.dart +++ b/lib/src/core/models/room_models/room_model.dart @@ -17,6 +17,5 @@ class RoomModel with _$RoomModel { final DateTime? updatedAt, }) = _RoomModel; - factory RoomModel.fromJson(Map json) => - _$RoomModelFromJson(json); + factory RoomModel.fromJson(Map json) => _$RoomModelFromJson(json); } diff --git a/lib/src/core/models/user_model/user_model.dart b/lib/src/core/models/user_model/user_model.dart index 6a78672..53d5083 100644 --- a/lib/src/core/models/user_model/user_model.dart +++ b/lib/src/core/models/user_model/user_model.dart @@ -24,8 +24,7 @@ class UserModel with _$UserModel { @JsonKey(name: "user_contact") UserModel? contact, }) = _UserModel; - factory UserModel.fromJson(Map json) => - _$UserModelFromJson(json); + factory UserModel.fromJson(Map json) => _$UserModelFromJson(json); String getFirstAndLastLetterOfName() { if ((name ?? '').isEmpty) return ""; diff --git a/lib/src/core/ui_kit/image_loader/image_loaded.dart b/lib/src/core/ui_kit/image_loader/image_loaded.dart index d1ad3bb..52513b7 100644 --- a/lib/src/core/ui_kit/image_loader/image_loaded.dart +++ b/lib/src/core/ui_kit/image_loader/image_loaded.dart @@ -63,10 +63,7 @@ class ImageLoaderWidget extends StatelessWidget { padding: paddingShimmerContainer, width: width, height: height, - decoration: BoxDecoration( - color: Colors.grey.shade200, - borderRadius: borderRadius, - ), + decoration: BoxDecoration(color: Colors.grey.shade200, borderRadius: borderRadius), ); } }, diff --git a/lib/src/core/ui_kit/search_widget/search_widget.dart b/lib/src/core/ui_kit/search_widget/search_widget.dart index 48cdd2d..f5e1716 100644 --- a/lib/src/core/ui_kit/search_widget/search_widget.dart +++ b/lib/src/core/ui_kit/search_widget/search_widget.dart @@ -14,8 +14,7 @@ class SearchWidget extends StatefulWidget { State createState() => _SearchWidgetState(); } -class _SearchWidgetState extends State - with SingleTickerProviderStateMixin { +class _SearchWidgetState extends State with SingleTickerProviderStateMixin { late AppThemeBloc _appThemeBloc; late TextEditingController _searchController; late AnimationController _animationController; @@ -33,9 +32,10 @@ class _SearchWidgetState extends State duration: const Duration(milliseconds: 350), ); - _animation = Tween(begin: 0, end: 1).animate( - CurvedAnimation(parent: _animationController, curve: Curves.bounceInOut), - ); + _animation = Tween( + begin: 0, + end: 1, + ).animate(CurvedAnimation(parent: _animationController, curve: Curves.bounceInOut)); _animationController.forward(); } diff --git a/lib/src/core/ui_kit/user_widgets/add_contact_user_widget.dart b/lib/src/core/ui_kit/user_widgets/add_contact_user_widget.dart index 9473aeb..dd5c7e0 100644 --- a/lib/src/core/ui_kit/user_widgets/add_contact_user_widget.dart +++ b/lib/src/core/ui_kit/user_widgets/add_contact_user_widget.dart @@ -10,11 +10,7 @@ class AddContactUserWidget extends StatelessWidget { final UserModel user; final VoidCallback addUser; - const AddContactUserWidget({ - super.key, - required this.user, - required this.addUser, - }); + const AddContactUserWidget({super.key, required this.user, required this.addUser}); @override Widget build(BuildContext context) { @@ -47,16 +43,10 @@ class AddContactUserWidget extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.center, children: [ - Text( - user.name ?? user.email ?? '-', - style: GoogleFonts.aBeeZee(fontSize: 15), - ), + Text(user.name ?? user.email ?? '-', style: GoogleFonts.aBeeZee(fontSize: 15)), Text( "Last seen 3000 y.a", - style: GoogleFonts.aBeeZee( - fontSize: 12, - color: Colors.grey, - ), + style: GoogleFonts.aBeeZee(fontSize: 12, color: Colors.grey), ), ], ), @@ -65,9 +55,7 @@ class AddContactUserWidget extends StatelessWidget { IconButton( onPressed: () { Navigator.pop(context); - AutoRouter.of( - context, - ).push(ChatRoute(chat: null, user: user)); + AutoRouter.of(context).push(ChatRoute(chat: null, user: user)); }, icon: const Icon(CupertinoIcons.chat_bubble_2_fill), ) @@ -79,10 +67,7 @@ class AddContactUserWidget extends StatelessWidget { child: const CircularProgressIndicator(strokeWidth: 2), ) else - IconButton( - onPressed: addUser, - icon: const Icon(Icons.person_add_alt), - ), + IconButton(onPressed: addUser, icon: const Icon(Icons.person_add_alt)), ], ), ), diff --git a/lib/src/core/utils/bloc_observer_manager/bloc_observer_manager.dart b/lib/src/core/utils/bloc_observer_manager/bloc_observer_manager.dart index ce74fd2..52088cf 100644 --- a/lib/src/core/utils/bloc_observer_manager/bloc_observer_manager.dart +++ b/lib/src/core/utils/bloc_observer_manager/bloc_observer_manager.dart @@ -8,10 +8,7 @@ class BlocObserverManager extends BlocObserver { final Logger logger; @override - void onTransition( - Bloc bloc, - Transition transition, - ) { + void onTransition(Bloc bloc, Transition transition) { final logMessage = StringBuffer() ..writeln('Bloc: ${bloc.runtimeType}') @@ -47,12 +44,7 @@ class BlocObserverManager extends BlocObserver { // you can also send bloc errors to server here - logger.log( - Level.error, - logMessage.toString(), - error: error, - stackTrace: stackTrace, - ); + logger.log(Level.error, logMessage.toString(), error: error, stackTrace: stackTrace); // Avoid calling super.onError to prevent propagation // if you use Zones for catching errors it's good, because it will propagate error and zone will catch it @@ -61,8 +53,7 @@ class BlocObserverManager extends BlocObserver { @override void onClose(BlocBase bloc) { - final logMessage = - StringBuffer()..writeln('Closed Bloc: ${bloc.runtimeType}'); + final logMessage = StringBuffer()..writeln('Closed Bloc: ${bloc.runtimeType}'); logger.log(Level.info, logMessage.toString()); super.onClose(bloc); @@ -70,8 +61,7 @@ class BlocObserverManager extends BlocObserver { @override void onCreate(BlocBase bloc) { - final logMessage = - StringBuffer()..writeln('Opened Bloc: ${bloc.runtimeType}'); + final logMessage = StringBuffer()..writeln('Opened Bloc: ${bloc.runtimeType}'); logger.log(Level.info, logMessage.toString()); super.onCreate(bloc); diff --git a/lib/src/core/utils/camera_helper_service/camera_helper_service.dart b/lib/src/core/utils/camera_helper_service/camera_helper_service.dart index 2c3430b..91571bf 100644 --- a/lib/src/core/utils/camera_helper_service/camera_helper_service.dart +++ b/lib/src/core/utils/camera_helper_service/camera_helper_service.dart @@ -10,8 +10,7 @@ import 'package:collection/collection.dart'; class CameraHelperService { late List _cameras; - UnmodifiableListView get cameras => - UnmodifiableListView(_cameras); + UnmodifiableListView get cameras => UnmodifiableListView(_cameras); // init this one in main func Future initCameras() async { diff --git a/lib/src/core/utils/debug_image_creator_in_apps_folder/debug_image_creator_in_apps_folder.dart b/lib/src/core/utils/debug_image_creator_in_apps_folder/debug_image_creator_in_apps_folder.dart index 3e75081..37c8410 100644 --- a/lib/src/core/utils/debug_image_creator_in_apps_folder/debug_image_creator_in_apps_folder.dart +++ b/lib/src/core/utils/debug_image_creator_in_apps_folder/debug_image_creator_in_apps_folder.dart @@ -8,11 +8,9 @@ import 'package:yahay/src/features/telegram_file_picker_feature/mixins/folder_cr class DebugImageCreatorInAppsFolder with FolderCreator { // - DebugImageCreatorInAppsFolder({ - required final SharedPreferHelper sharedPreferHelper, - Dio? dio, - }) : _sharedPreferHelper = sharedPreferHelper, - _dio = dio ?? Dio(); + DebugImageCreatorInAppsFolder({required final SharedPreferHelper sharedPreferHelper, Dio? dio}) + : _sharedPreferHelper = sharedPreferHelper, + _dio = dio ?? Dio(); final SharedPreferHelper _sharedPreferHelper; @@ -44,8 +42,7 @@ class DebugImageCreatorInAppsFolder with FolderCreator { ); if (response.statusCode == HttpStatus.ok) { - final pathImageForCreation = - "${dir?.path}/$each/${DateTime.now()}.jpg"; + final pathImageForCreation = "${dir?.path}/$each/${DateTime.now()}.jpg"; final File file = File(pathImageForCreation); if ((response.data ?? []).isNotEmpty) { file.writeAsBytesSync(response.data!); diff --git a/lib/src/core/utils/dio/src/exceptions/rest_client_exception.dart b/lib/src/core/utils/dio/src/exceptions/rest_client_exception.dart index 310b37c..08ad415 100644 --- a/lib/src/core/utils/dio/src/exceptions/rest_client_exception.dart +++ b/lib/src/core/utils/dio/src/exceptions/rest_client_exception.dart @@ -3,11 +3,7 @@ import 'package:flutter/foundation.dart'; @immutable sealed class RestClientException implements Exception { - const RestClientException({ - required this.message, - this.statusCode, - this.cause, - }); + const RestClientException({required this.message, this.statusCode, this.cause}); // final String message; @@ -18,11 +14,8 @@ sealed class RestClientException implements Exception { final class StructuredBackendException extends RestClientException { /// The error returned by the backend - const StructuredBackendException({ - required this.error, - super.statusCode, - super.cause, - }) : super(message: 'Backend returned structured error'); + const StructuredBackendException({required this.error, super.statusCode, super.cause}) + : super(message: 'Backend returned structured error'); final Map error; @@ -36,11 +29,7 @@ final class StructuredBackendException extends RestClientException { } final class ClientException extends RestClientException { - const ClientException({ - required super.message, - super.statusCode, - super.cause, - }); + const ClientException({required super.message, super.statusCode, super.cause}); @override String toString() => @@ -52,12 +41,9 @@ final class ClientException extends RestClientException { } final class UnauthenticatedException extends RestClientException { - const UnauthenticatedException({ - required DioException exception, - super.statusCode, - super.cause, - }) : _dioException = exception, - super(message: "User is Unauthenticated"); + const UnauthenticatedException({required DioException exception, super.statusCode, super.cause}) + : _dioException = exception, + super(message: "User is Unauthenticated"); final DioException _dioException; @@ -73,10 +59,8 @@ final class UnauthenticatedException extends RestClientException { final class DioExceptionHandler { // - const DioExceptionHandler({ - required DioException dioException, - required this.serverError, - }) : _dioException = dioException; + const DioExceptionHandler({required DioException dioException, required this.serverError}) + : _dioException = dioException; final DioException _dioException; final String serverError; diff --git a/lib/src/core/utils/dio/src/rest_client_base.dart b/lib/src/core/utils/dio/src/rest_client_base.dart index dba43ef..9cf188b 100644 --- a/lib/src/core/utils/dio/src/rest_client_base.dart +++ b/lib/src/core/utils/dio/src/rest_client_base.dart @@ -31,13 +31,8 @@ abstract base class RestClientBase implements RestClient { Map? headers, Map? queryParams, bool log = false, - }) => send( - path: path, - method: DioMethod.get, - headers: headers, - queryParams: queryParams, - log: log, - ); + }) => + send(path: path, method: DioMethod.get, headers: headers, queryParams: queryParams, log: log); @override Future?> post( @@ -94,8 +89,7 @@ abstract base class RestClientBase implements RestClient { ); Uri buildUri({required String path, Map? queryParams}) { - final String finalPath = - Uri.parse("${_baseURL.path}/api$path").normalizePath().toString(); + final String finalPath = Uri.parse("${_baseURL.path}/api$path").normalizePath().toString(); final Map params = Map.of(_baseURL.queryParameters); @@ -104,10 +98,7 @@ abstract base class RestClientBase implements RestClient { params.removeWhere((key, value) => value == null); } - return _baseURL.replace( - path: finalPath, - queryParameters: params.isEmpty ? null : params, - ); + return _baseURL.replace(path: finalPath, queryParameters: params.isEmpty ? null : params); } Future?> decodeResponse( @@ -116,12 +107,8 @@ abstract base class RestClientBase implements RestClient { }) async { try { final decodedResponse = switch (data) { - StringResponseBody(body: final String body) => await _decodeString( - body, - ), - BytesResponseBody(body: final List bytes) => await _decodeBytes( - bytes, - ), + StringResponseBody(body: final String body) => await _decodeString(body), + BytesResponseBody(body: final List bytes) => await _decodeBytes(bytes), MapResponseBody(body: final Map map) => map, _ => {}, }; diff --git a/lib/src/core/utils/dio/src/rest_client_dio.dart b/lib/src/core/utils/dio/src/rest_client_dio.dart index 8235043..cd78bd1 100644 --- a/lib/src/core/utils/dio/src/rest_client_dio.dart +++ b/lib/src/core/utils/dio/src/rest_client_dio.dart @@ -50,10 +50,7 @@ final class RestClientDio extends RestClientBase { // link // https://github.com/hawkkiller/sizzle_starter/blob/main/packages/rest_client/lib/src/rest_client_base.dart - return decodeResponse( - BytesResponseBody(body: request.data), - statusCode: request.statusCode, - ); + return decodeResponse(BytesResponseBody(body: request.data), statusCode: request.statusCode); } on RestClientException { // // rethrow also throws error and stacktrace @@ -61,15 +58,10 @@ final class RestClientDio extends RestClientBase { } on DioException catch (error, stackTrace) { _logger.log(Level.error, error); if (error.response?.statusCode == HttpStatus.unauthorized) { - throw UnauthenticatedException( - exception: error, - statusCode: HttpStatus.unauthorized, - ); + throw UnauthenticatedException(exception: error, statusCode: HttpStatus.unauthorized); } - final serverError = await decodeResponse( - BytesResponseBody(body: error.response?.data), - ); + final serverError = await decodeResponse(BytesResponseBody(body: error.response?.data)); Error.throwWithStackTrace( DioExceptionHandler(dioException: error, serverError: "$serverError"), @@ -83,8 +75,7 @@ final class RestClientDio extends RestClientBase { return { 'Content-Type': 'application/json; charset=UTF-8', 'Accept': 'application/json', - 'Authorization': - 'Bearer ${_sharedPreferHelper.getStringByKey(key: 'token')}', + 'Authorization': 'Bearer ${_sharedPreferHelper.getStringByKey(key: 'token')}', }; } } diff --git a/lib/src/core/utils/extensions/extensions.dart b/lib/src/core/utils/extensions/extensions.dart index 13d8478..e4366ef 100644 --- a/lib/src/core/utils/extensions/extensions.dart +++ b/lib/src/core/utils/extensions/extensions.dart @@ -21,8 +21,7 @@ extension ListExtensions on List { } extension StringEx on String { - String limit(int length) => - length < this.length ? substring(0, length) : this; + String limit(int length) => length < this.length ? substring(0, length) : this; } extension NestedMapExt on Map { diff --git a/lib/src/core/utils/global_context/global_context.dart b/lib/src/core/utils/global_context/global_context.dart index 79656c9..481a863 100644 --- a/lib/src/core/utils/global_context/global_context.dart +++ b/lib/src/core/utils/global_context/global_context.dart @@ -7,6 +7,5 @@ class GlobalContext { GlobalContext._(); - final GlobalKey globalContext = - GlobalKey(); + final GlobalKey globalContext = GlobalKey(); } diff --git a/lib/src/core/utils/image_comporessor/image_compressor.dart b/lib/src/core/utils/image_comporessor/image_compressor.dart index ff2cb23..93591ed 100644 --- a/lib/src/core/utils/image_comporessor/image_compressor.dart +++ b/lib/src/core/utils/image_comporessor/image_compressor.dart @@ -14,13 +14,12 @@ abstract final class ImageCompressor { final String imagePath = '$directoryPath/${basenameWithoutExtension(file.path)}_temp.${format.name}'; - final XFile? compressedImage = - await FlutterImageCompress.compressAndGetFile( - file.path, - imagePath, - quality: quality, - format: format, - ); + final XFile? compressedImage = await FlutterImageCompress.compressAndGetFile( + file.path, + imagePath, + quality: quality, + format: format, + ); if (compressedImage == null) { throw ("Failed to compress the image"); diff --git a/lib/src/core/utils/list_pagination_checker/list_pagination_checker.dart b/lib/src/core/utils/list_pagination_checker/list_pagination_checker.dart index 8d0fb2d..6ecad7c 100644 --- a/lib/src/core/utils/list_pagination_checker/list_pagination_checker.dart +++ b/lib/src/core/utils/list_pagination_checker/list_pagination_checker.dart @@ -3,8 +3,7 @@ import 'package:yahay/src/core/global_usages/constants/constants.dart'; class ListPaginationChecker { static ListPaginationChecker? _instance; - static ListPaginationChecker get instance => - _instance ??= ListPaginationChecker._(); + static ListPaginationChecker get instance => _instance ??= ListPaginationChecker._(); ListPaginationChecker._(); @@ -23,10 +22,7 @@ class ListPaginationChecker { } // this func will check whether there are more values in list of pag (returns boolean) - bool checkIsListHasMorePageBool({ - required List list, - int? limitInPage, - }) { + bool checkIsListHasMorePageBool({required List list, int? limitInPage}) { if (list.length < (limitInPage ?? Constants.perPage)) { return false; } else { @@ -44,8 +40,7 @@ class ListPaginationChecker { //you should not use any check variable, this function parameter "showingCircularProgress" will know automatically //and it checks whether list still has items or not if (!showingCircularProgress) { - final bool hasMore = - currentList.length >= wholeList.length ? false : true; + final bool hasMore = currentList.length >= wholeList.length ? false : true; if (!hasMore) return []; } //check in which list index we are at diff --git a/lib/src/core/utils/screen_messaging/screen_messaging.dart b/lib/src/core/utils/screen_messaging/screen_messaging.dart index 090173f..85cfa78 100644 --- a/lib/src/core/utils/screen_messaging/screen_messaging.dart +++ b/lib/src/core/utils/screen_messaging/screen_messaging.dart @@ -8,11 +8,7 @@ class ScreenMessaging { ScreenMessaging._(); - void toast( - String message, { - bool error = false, - Color textColor = Colors.white, - }) { + void toast(String message, {bool error = false, Color textColor = Colors.white}) { Fluttertoast.cancel(); Fluttertoast.showToast( msg: message, diff --git a/lib/src/core/utils/shared_preferences/shared_preferences.dart b/lib/src/core/utils/shared_preferences/shared_preferences.dart index aed3d47..e79b85e 100644 --- a/lib/src/core/utils/shared_preferences/shared_preferences.dart +++ b/lib/src/core/utils/shared_preferences/shared_preferences.dart @@ -7,10 +7,7 @@ class SharedPreferHelper { _sharedPrefer = await SharedPreferences.getInstance(); } - Future setStringByKey({ - required String key, - required String value, - }) async { + Future setStringByKey({required String key, required String value}) async { await _sharedPrefer.setString(key, value); } @@ -18,10 +15,7 @@ class SharedPreferHelper { await _sharedPrefer.setInt(key, value); } - Future setDoubleByKey({ - required String key, - required double value, - }) async { + Future setDoubleByKey({required String key, required double value}) async { await _sharedPrefer.setDouble(key, value); } diff --git a/lib/src/features/add_contact_feature/bloc/add_contact_bloc.dart b/lib/src/features/add_contact_feature/bloc/add_contact_bloc.dart index 8cfb7ea..3f6d630 100644 --- a/lib/src/features/add_contact_feature/bloc/add_contact_bloc.dart +++ b/lib/src/features/add_contact_feature/bloc/add_contact_bloc.dart @@ -10,8 +10,7 @@ part 'add_contact_bloc.freezed.dart'; @immutable @freezed sealed class AddContactsEvents with _$AddContactsEvents { - const factory AddContactsEvents.searchContact(final String value) = - _SearchContactEvent; + const factory AddContactsEvents.searchContact(final String value) = _SearchContactEvent; const factory AddContactsEvents.addContactEvent(final UserModel? user) = _AddContactEventOnAddContactsEvent; @@ -22,9 +21,8 @@ sealed class AddContactsEvents with _$AddContactsEvents { @immutable @freezed sealed class AddContactsStates with _$AddContactsStates { - const factory AddContactsStates.initial( - final AddContactStateModel addContactStateModel, - ) = InitialAddConstactsState; + const factory AddContactsStates.initial(final AddContactStateModel addContactStateModel) = + InitialAddConstactsState; const factory AddContactsStates.loadingAddContactsState( final AddContactStateModel addContactStateModel, @@ -42,11 +40,9 @@ sealed class AddContactsStates with _$AddContactsStates { class AddContactBloc extends Bloc { final AddContactRepo _iAddContactRepo; - AddContactBloc({ - required AddContactsStates initialState, - required AddContactRepo iAddContactRepo, - }) : _iAddContactRepo = iAddContactRepo, - super(initialState) { + AddContactBloc({required AddContactsStates initialState, required AddContactRepo iAddContactRepo}) + : _iAddContactRepo = iAddContactRepo, + super(initialState) { on( (event, emit) => event.map( searchContact: (event) => _searchContactEvent(event, emit), @@ -61,10 +57,7 @@ class AddContactBloc extends Bloc { ); } - void _searchContactEvent( - _SearchContactEvent event, - Emitter emit, - ) async { + void _searchContactEvent(_SearchContactEvent event, Emitter emit) async { var currentStateModel = state.addContactStateModel.copyWith(); try { @@ -74,15 +67,10 @@ class AddContactBloc extends Bloc { // emit(AddContactsStates.loadingAddContactsState(currentStateModel)); // - final data = await _iAddContactRepo.searchContact( - event.value, - currentStateModel.page, - ); + final data = await _iAddContactRepo.searchContact(event.value, currentStateModel.page); // - final List currentUsers = List.from( - currentStateModel.users, - ); + final List currentUsers = List.from(currentStateModel.users); currentUsers.addAll(data); @@ -105,17 +93,11 @@ class AddContactBloc extends Bloc { // try { if (event.user == null) return; - UserModel? changingModel = event.user?.copyWith( - loadingForAddingToContacts: true, - ); + UserModel? changingModel = event.user?.copyWith(loadingForAddingToContacts: true); - final List tempUsersList = List.from( - currentStateModel.users, - ); + final List tempUsersList = List.from(currentStateModel.users); - final foundIndex = tempUsersList.indexWhere( - (el) => el.id == event.user?.id, - ); + final foundIndex = tempUsersList.indexWhere((el) => el.id == event.user?.id); if (foundIndex != -1) { tempUsersList[foundIndex] = event.user!; diff --git a/lib/src/features/add_contact_feature/bloc/state_model/add_contact_state_model.dart b/lib/src/features/add_contact_feature/bloc/state_model/add_contact_state_model.dart index 1fce116..12ae1f2 100644 --- a/lib/src/features/add_contact_feature/bloc/state_model/add_contact_state_model.dart +++ b/lib/src/features/add_contact_feature/bloc/state_model/add_contact_state_model.dart @@ -25,11 +25,7 @@ final class AddContactStateModel { timerForSearch == other.timerForSearch); @override - int get hashCode => - users.hashCode ^ - page.hashCode ^ - hasMore.hashCode ^ - timerForSearch.hashCode; + int get hashCode => users.hashCode ^ page.hashCode ^ hasMore.hashCode ^ timerForSearch.hashCode; @override String toString() { diff --git a/lib/src/features/add_contact_feature/data/add_contact_repo.dart b/lib/src/features/add_contact_feature/data/add_contact_repo.dart index 42a8293..2b89d68 100644 --- a/lib/src/features/add_contact_feature/data/add_contact_repo.dart +++ b/lib/src/features/add_contact_feature/data/add_contact_repo.dart @@ -18,6 +18,5 @@ class AddContactRepoImpl extends AddContactRepo { _addContactSource.searchContact(value, page); @override - Future addContact(UserModel? user) => - _addContactSource.addContact(user); + Future addContact(UserModel? user) => _addContactSource.addContact(user); } diff --git a/lib/src/features/add_contact_feature/data/add_contact_source.dart b/lib/src/features/add_contact_feature/data/add_contact_source.dart index dbc3d66..7bb4e53 100644 --- a/lib/src/features/add_contact_feature/data/add_contact_source.dart +++ b/lib/src/features/add_contact_feature/data/add_contact_source.dart @@ -12,11 +12,9 @@ abstract class AddContactSource { class AddContactSourceImpl implements AddContactSource { // - AddContactSourceImpl({ - required final Logger logger, - required final RestClientBase restClientBase, - }) : _logger = logger, - _restClientBase = restClientBase; + AddContactSourceImpl({required final Logger logger, required final RestClientBase restClientBase}) + : _logger = logger, + _restClientBase = restClientBase; final Logger _logger; diff --git a/lib/src/features/add_contact_feature/view/pages/add_contacts_page.dart b/lib/src/features/add_contact_feature/view/pages/add_contacts_page.dart index 3861963..a09a7ed 100644 --- a/lib/src/features/add_contact_feature/view/pages/add_contacts_page.dart +++ b/lib/src/features/add_contact_feature/view/pages/add_contacts_page.dart @@ -22,18 +22,14 @@ class _AddContactsPageState extends State { void initState() { super.initState(); _controller = DraggableScrollableController(); - _addContactBloc = - DependenciesScope.of(context, listen: false).addContactBloc; + _addContactBloc = DependenciesScope.of(context, listen: false).addContactBloc; _addContactBloc.add(const AddContactsEvents.clearDataEvent()); WidgetsBinding.instance.addPostFrameCallback((timeStamp) { const maxHeight = 0.96; final screenHeight = MediaQuery.of(context).size.height * maxHeight; final screenHeightWithAppBar = screenHeight - kToolbarHeight; initialChildSize = - ((screenHeightWithAppBar * maxHeight) / screenHeight) - .roundIt() - ?.toDouble() ?? - maxHeight; + ((screenHeightWithAppBar * maxHeight) / screenHeight).roundIt()?.toDouble() ?? maxHeight; setState(() {}); }); } @@ -63,22 +59,12 @@ class _AddContactsPageState extends State { child: ClipRRect( borderRadius: BorderRadius.circular(4), child: TextField( - onChanged: - (v) => _addContactBloc.add( - AddContactsEvents.searchContact(v), - ), - onSubmitted: - (v) => _addContactBloc.add( - AddContactsEvents.searchContact(v), - ), - onTapOutside: - (v) => FocusManager.instance.primaryFocus?.unfocus(), + onChanged: (v) => _addContactBloc.add(AddContactsEvents.searchContact(v)), + onSubmitted: (v) => _addContactBloc.add(AddContactsEvents.searchContact(v)), + onTapOutside: (v) => FocusManager.instance.primaryFocus?.unfocus(), style: GoogleFonts.aBeeZee(fontSize: 14), decoration: const InputDecoration( - contentPadding: EdgeInsets.symmetric( - vertical: 15.0, - horizontal: 5, - ), + contentPadding: EdgeInsets.symmetric(vertical: 15.0, horizontal: 5), border: InputBorder.none, focusedBorder: InputBorder.none, enabledBorder: InputBorder.none, @@ -91,9 +77,7 @@ class _AddContactsPageState extends State { ), TextButton( onPressed: () { - _addContactBloc.add( - const AddContactsEvents.clearDataEvent(), - ); + _addContactBloc.add(const AddContactsEvents.clearDataEvent()); Navigator.pop(context); }, child: const Text("Cancel"), @@ -113,8 +97,7 @@ class _AddContactsPageState extends State { case AddContacts$SuccessfulState(): final currentStateModel = states.addContactStateModel; return ListView.separated( - separatorBuilder: - (context, index) => const SizedBox(height: 10), + separatorBuilder: (context, index) => const SizedBox(height: 10), shrinkWrap: true, physics: const NeverScrollableScrollPhysics(), itemCount: currentStateModel.users.length, @@ -123,9 +106,7 @@ class _AddContactsPageState extends State { return AddContactUserWidget( user: user, addUser: - () => _addContactBloc.add( - AddContactsEvents.addContactEvent(user), - ), + () => _addContactBloc.add(AddContactsEvents.addContactEvent(user)), ); }, ); diff --git a/lib/src/features/app_theme/bloc/app_theme_bloc.dart b/lib/src/features/app_theme/bloc/app_theme_bloc.dart index cf802e3..b56bf20 100644 --- a/lib/src/features/app_theme/bloc/app_theme_bloc.dart +++ b/lib/src/features/app_theme/bloc/app_theme_bloc.dart @@ -20,10 +20,8 @@ class AppThemeBloc { BehaviorSubject get theme => _theme; - const AppThemeBloc._({ - required this.events, - required BehaviorSubject theme, - }) : _theme = theme; + const AppThemeBloc._({required this.events, required BehaviorSubject theme}) + : _theme = theme; factory AppThemeBloc() { final eventBehavior = BehaviorSubject(); @@ -32,9 +30,7 @@ class AppThemeBloc { final themeData = eventBehavior .map((appThemeDataEvent) { - final ThemeData theme = _appThemeChangerEvent( - appThemeDataEvent as AppThemeChangerEvent, - ); + final ThemeData theme = _appThemeChangerEvent(appThemeDataEvent as AppThemeChangerEvent); return theme; }) .startWith(_currentState); diff --git a/lib/src/features/authorization/bloc/auth_bloc.dart b/lib/src/features/authorization/bloc/auth_bloc.dart index dba8efa..b04ee6b 100644 --- a/lib/src/features/authorization/bloc/auth_bloc.dart +++ b/lib/src/features/authorization/bloc/auth_bloc.dart @@ -41,8 +41,7 @@ sealed class AuthEvents with _$AuthEvents { required void Function(String message) onMessage, }) = _CheckAuthEventOnAuthEvents; - const factory AuthEvents.changePasswordVisibility() = - _ChangePasswordVisibilityEvent; + const factory AuthEvents.changePasswordVisibility() = _ChangePasswordVisibilityEvent; const factory AuthEvents.logOutEvent() = _LogOutEvent; } @@ -50,20 +49,17 @@ sealed class AuthEvents with _$AuthEvents { @immutable @freezed sealed class AuthStates with _$AuthStates { - const factory AuthStates.initial(final AuthStateModel authStateModel) = - Auth$InitialState; + const factory AuthStates.initial(final AuthStateModel authStateModel) = Auth$InitialState; const factory AuthStates.inProgress(final AuthStateModel authStateModel) = AuthStates$InProgressState; - const factory AuthStates.authorized(final AuthStateModel authStateModel) = - Auth$AuthorizedState; + const factory AuthStates.authorized(final AuthStateModel authStateModel) = Auth$AuthorizedState; const factory AuthStates.unAuthorized(final AuthStateModel authStateModel) = Auth$UnAuthorizedState; - const factory AuthStates.error(final AuthStateModel authStateModel) = - ErrorStateOnAuthStates; + const factory AuthStates.error(final AuthStateModel authStateModel) = ErrorStateOnAuthStates; } class AuthBloc extends Bloc { @@ -86,17 +82,13 @@ class AuthBloc extends Bloc { registerEvent: (event) => _registerEvent(event, emit), loginEvent: (event) => _loginEvent(event, emit), checkAuthEvent: (event) => _checkAuthEvent(event, emit), - changePasswordVisibility: - (event) => _changePasswordVisibility(event, emit), + changePasswordVisibility: (event) => _changePasswordVisibility(event, emit), logOutEvent: (event) => _logOutEvent(event, emit), ), ); } - void _googleAuth( - _GoogleAuthEventOnAuthEvents event, - Emitter emit, - ) async { + void _googleAuth(_GoogleAuthEventOnAuthEvents event, Emitter emit) async { var currentStateModel = state.authStateModel.copyWith(); try { @@ -120,10 +112,7 @@ class AuthBloc extends Bloc { } } - void _facebookAuth( - _FacebookAuthEventsAuthEvents event, - Emitter emit, - ) async { + void _facebookAuth(_FacebookAuthEventsAuthEvents event, Emitter emit) async { var currentStateModel = state.authStateModel.copyWith(); try { final user = await _iOtherAuthorizationRepo.faceBookAuth(); @@ -146,10 +135,7 @@ class AuthBloc extends Bloc { } } - void _registerEvent( - _RegisterEventOnAuthEvents event, - Emitter emit, - ) async { + void _registerEvent(_RegisterEventOnAuthEvents event, Emitter emit) async { var currentStateModel = state.authStateModel.copyWith(); try { currentStateModel = currentStateModel.copyWith(loadingRegister: true); @@ -181,10 +167,7 @@ class AuthBloc extends Bloc { } } - void _loginEvent( - _LoginEventOnAuthEvents event, - Emitter emit, - ) async { + void _loginEvent(_LoginEventOnAuthEvents event, Emitter emit) async { var currentStateModel = state.authStateModel.copyWith(); try { @@ -217,10 +200,7 @@ class AuthBloc extends Bloc { } } - void _checkAuthEvent( - _CheckAuthEventOnAuthEvents event, - Emitter emit, - ) async { + void _checkAuthEvent(_CheckAuthEventOnAuthEvents event, Emitter emit) async { var currentStateModel = state.authStateModel.copyWith(); try { final user = await _iAuthorizationRepo.checkAuth(); @@ -256,9 +236,7 @@ class AuthBloc extends Bloc { Emitter emit, ) async { var currentStateModel = state.authStateModel.copyWith(); - currentStateModel = currentStateModel.copyWith( - showPassword: !currentStateModel.showPassword, - ); + currentStateModel = currentStateModel.copyWith(showPassword: !currentStateModel.showPassword); _emitter(currentStateModel, emit); } @@ -268,10 +246,7 @@ class AuthBloc extends Bloc { final loggedOut = await _iAuthorizationRepo.logout(); if (loggedOut) { - currentStateModel = currentStateModel.copyWith( - user: null, - setUserOnNull: true, - ); + currentStateModel = currentStateModel.copyWith(user: null, setUserOnNull: true); emit(AuthStates.unAuthorized(currentStateModel)); } } catch (error, stackTrace) { diff --git a/lib/src/features/authorization/bloc/state_model/auth_state_model.dart b/lib/src/features/authorization/bloc/state_model/auth_state_model.dart index 0e40dc9..59dc34b 100644 --- a/lib/src/features/authorization/bloc/state_model/auth_state_model.dart +++ b/lib/src/features/authorization/bloc/state_model/auth_state_model.dart @@ -32,10 +32,7 @@ class AuthStateModel { @override int get hashCode => - user.hashCode ^ - showPassword.hashCode ^ - loadingRegister.hashCode ^ - loadingLogin.hashCode; + user.hashCode ^ showPassword.hashCode ^ loadingRegister.hashCode ^ loadingLogin.hashCode; @override String toString() { diff --git a/lib/src/features/authorization/data/repo/authorization_repo_impl.dart b/lib/src/features/authorization/data/repo/authorization_repo_impl.dart index cfca02f..fcabe40 100644 --- a/lib/src/features/authorization/data/repo/authorization_repo_impl.dart +++ b/lib/src/features/authorization/data/repo/authorization_repo_impl.dart @@ -14,21 +14,14 @@ class AuthorizationRepoImpl implements AuthorizationRepo { Future login({ required final String emailOrUserName, required final String password, - }) => _laravelAuthDataSource.login( - emailOrUserName: emailOrUserName, - password: password, - ); + }) => _laravelAuthDataSource.login(emailOrUserName: emailOrUserName, password: password); @override Future register({ required final String email, required final String password, required final String userName, - }) => _laravelAuthDataSource.register( - email: email, - password: password, - userName: userName, - ); + }) => _laravelAuthDataSource.register(email: email, password: password, userName: userName); @override Future logout() => _laravelAuthDataSource.logout(); diff --git a/lib/src/features/authorization/data/sources/laravel/impl/laravel_auth_data_source_impl.dart b/lib/src/features/authorization/data/sources/laravel/impl/laravel_auth_data_source_impl.dart index 084f3ed..43e9f69 100644 --- a/lib/src/features/authorization/data/sources/laravel/impl/laravel_auth_data_source_impl.dart +++ b/lib/src/features/authorization/data/sources/laravel/impl/laravel_auth_data_source_impl.dart @@ -55,19 +55,13 @@ class LaravelAuthDataSourceImpl implements LaravelAuthDataSource { }) async { final url = "${HttpRoutes.authPrefix}$_login"; - final Map body = { - "email_or_username": emailOrUserName, - "password": password, - }; + final Map body = {"email_or_username": emailOrUserName, "password": password}; final response = await _restClientBase.post(url, data: body); if (response == null) return null; - _logger.log( - Level.debug, - "login response: $response | ${response.runtimeType}", - ); + _logger.log(Level.debug, "login response: $response | ${response.runtimeType}"); if (!response.containsKey(HttpServerResponses.serverSuccessResponse)) { return null; @@ -78,10 +72,7 @@ class LaravelAuthDataSourceImpl implements LaravelAuthDataSource { return null; } - await _sharedPreferences.setStringByKey( - key: "token", - value: response.getNested(['token']), - ); + await _sharedPreferences.setStringByKey(key: "token", value: response.getNested(['token'])); return UserModel.fromJson(response.getNested(['user'])); } @@ -94,11 +85,7 @@ class LaravelAuthDataSourceImpl implements LaravelAuthDataSource { }) async { final url = "${HttpRoutes.authPrefix}$_register"; - final Map body = { - "email": email, - "password": password, - "user_name": userName, - }; + final Map body = {"email": email, "password": password, "user_name": userName}; final response = await _restClientBase.post(url, data: body); @@ -115,10 +102,7 @@ class LaravelAuthDataSourceImpl implements LaravelAuthDataSource { return null; } - await _sharedPreferences.setStringByKey( - key: "token", - value: response.getNested(['token']), - ); + await _sharedPreferences.setStringByKey(key: "token", value: response.getNested(['token'])); return UserModel.fromJson(response.getNested(['user'])); } diff --git a/lib/src/features/authorization/data/sources/laravel/laravel_auth_data_source.dart b/lib/src/features/authorization/data/sources/laravel/laravel_auth_data_source.dart index 15f1426..dd53e47 100644 --- a/lib/src/features/authorization/data/sources/laravel/laravel_auth_data_source.dart +++ b/lib/src/features/authorization/data/sources/laravel/laravel_auth_data_source.dart @@ -7,10 +7,7 @@ abstract interface class LaravelAuthDataSource { required final String userName, }); - Future login({ - required final String emailOrUserName, - required final String password, - }); + Future login({required final String emailOrUserName, required final String password}); Future checkAuth(); diff --git a/lib/src/features/authorization/data/sources/other_authorization/impl/other_authorization_impl.dart b/lib/src/features/authorization/data/sources/other_authorization/impl/other_authorization_impl.dart index 05d4d7f..73e607f 100644 --- a/lib/src/features/authorization/data/sources/other_authorization/impl/other_authorization_impl.dart +++ b/lib/src/features/authorization/data/sources/other_authorization/impl/other_authorization_impl.dart @@ -33,8 +33,7 @@ class OtherAuthorizationImpl implements OtherAuthorizationDatasource { Future faceBookAuth() async { final LoginResult loginResult = await _facebookAuth.login(); - if (loginResult.status == LoginStatus.failed || - loginResult.status == LoginStatus.cancelled) { + if (loginResult.status == LoginStatus.failed || loginResult.status == LoginStatus.cancelled) { return null; } @@ -55,10 +54,7 @@ class OtherAuthorizationImpl implements OtherAuthorizationDatasource { return null; } - await _sharedPreferHelper.setStringByKey( - key: "token", - value: response.getNested(['token']), - ); + await _sharedPreferHelper.setStringByKey(key: "token", value: response.getNested(['token'])); return UserModel.fromJson(response.getNested(['user'])); } @@ -86,10 +82,7 @@ class OtherAuthorizationImpl implements OtherAuthorizationDatasource { return null; } - await _sharedPreferHelper.setStringByKey( - key: "token", - value: response.getNested(['token']), - ); + await _sharedPreferHelper.setStringByKey(key: "token", value: response.getNested(['token'])); return UserModel.fromJson(response.getNested(['user'])); } diff --git a/lib/src/features/authorization/domain/repo/authorization_repo.dart b/lib/src/features/authorization/domain/repo/authorization_repo.dart index 911860b..51bbd11 100644 --- a/lib/src/features/authorization/domain/repo/authorization_repo.dart +++ b/lib/src/features/authorization/domain/repo/authorization_repo.dart @@ -7,10 +7,7 @@ abstract class AuthorizationRepo { required final String userName, }); - Future login({ - required final String emailOrUserName, - required final String password, - }); + Future login({required final String emailOrUserName, required final String password}); Future checkAuth(); diff --git a/lib/src/features/authorization/view/login_page.dart b/lib/src/features/authorization/view/login_page.dart index 0f94dbb..5ab3c37 100644 --- a/lib/src/features/authorization/view/login_page.dart +++ b/lib/src/features/authorization/view/login_page.dart @@ -26,11 +26,8 @@ class LoginPage extends StatefulWidget { class _LoginPageState extends State { final GlobalKey _loginForm = GlobalKey(); - final TextEditingController _emailOrUserNameController = - TextEditingController(text: ''); - final TextEditingController _passwordController = TextEditingController( - text: '', - ); + final TextEditingController _emailOrUserNameController = TextEditingController(text: ''); + final TextEditingController _passwordController = TextEditingController(text: ''); late final AuthBloc _authBloc; // final AnimatedLoginCharacter _animatedLoginCharacter = AnimatedLoginCharacter(); @@ -96,10 +93,7 @@ class _LoginPageState extends State { // ), Text( "Sign In", - style: GoogleFonts.aBeeZee( - fontWeight: FontWeight.w400, - fontSize: 20, - ), + style: GoogleFonts.aBeeZee(fontWeight: FontWeight.w400, fontSize: 20), ), const SizedBox(height: 20), AuthorizationInputWidget( @@ -121,9 +115,7 @@ class _LoginPageState extends State { top: 25, child: IconButton( onPressed: - () => _authBloc.add( - const AuthEvents.changePasswordVisibility(), - ), + () => _authBloc.add(const AuthEvents.changePasswordVisibility()), icon: Icon( (authStateModel.showPassword) ? CupertinoIcons.eye @@ -139,23 +131,17 @@ class _LoginPageState extends State { child: ElevatedButton( style: ButtonStyle( shape: WidgetStatePropertyAll( - RoundedRectangleBorder( - borderRadius: BorderRadius.circular(15), - ), - ), - backgroundColor: const WidgetStatePropertyAll( - Colors.blueAccent, + RoundedRectangleBorder(borderRadius: BorderRadius.circular(15)), ), + backgroundColor: const WidgetStatePropertyAll(Colors.blueAccent), ), onPressed: () => _authBloc.add( AuthEvents.loginEvent( - emailOrUserName: - _emailOrUserNameController.text, + emailOrUserName: _emailOrUserNameController.text, password: _passwordController.text, initDependenciesAfterAuthorization: - dependencies - .initDependenciesAfterAuthorization, + dependencies.initDependenciesAfterAuthorization, // initDioOptions: () async { // await dependencies.restClientBase.initOptions(); // }, @@ -188,11 +174,7 @@ class _LoginPageState extends State { crossAxisAlignment: CrossAxisAlignment.center, children: [ const Expanded( - child: Divider( - height: 0, - thickness: 0.5, - color: Colors.grey, - ), + child: Divider(height: 0, thickness: 0.5, color: Colors.grey), ), const SizedBox(width: 15), Text( @@ -205,11 +187,7 @@ class _LoginPageState extends State { ), const SizedBox(width: 15), const Expanded( - child: Divider( - height: 0, - thickness: 0.5, - color: Colors.grey, - ), + child: Divider(height: 0, thickness: 0.5, color: Colors.grey), ), ], ), @@ -224,8 +202,7 @@ class _LoginPageState extends State { () => _authBloc.add( AuthEvents.googleAuth( initDependenciesAfterAuthorization: - dependencies - .initDependenciesAfterAuthorization, + dependencies.initDependenciesAfterAuthorization, // initDioOptions: () async { // await dependencies.dioSettings.initOptions(); // }, @@ -236,17 +213,13 @@ class _LoginPageState extends State { const SizedBox(width: 20), Expanded( child: OtherAuthorizationButtonWidget( - icon: const FaIcon( - FontAwesomeIcons.facebook, - color: Colors.blue, - ), + icon: const FaIcon(FontAwesomeIcons.facebook, color: Colors.blue), text: 'Facebook', onTap: () => _authBloc.add( AuthEvents.facebookAuth( initDependenciesAfterAuthorization: - dependencies - .initDependenciesAfterAuthorization, + dependencies.initDependenciesAfterAuthorization, // initDioOptions: () async { // await dependencies.dioSettings.initOptions(); // }, @@ -271,9 +244,7 @@ class _LoginPageState extends State { recognizer: TapGestureRecognizer() ..onTap = - () => AutoRouter.of( - context, - ).replace(const RegisterRoute()), + () => AutoRouter.of(context).replace(const RegisterRoute()), text: Constants.signUp, style: const TextStyle(color: Colors.blue), ), diff --git a/lib/src/features/authorization/view/register_page.dart b/lib/src/features/authorization/view/register_page.dart index 9473965..363dc99 100644 --- a/lib/src/features/authorization/view/register_page.dart +++ b/lib/src/features/authorization/view/register_page.dart @@ -22,15 +22,9 @@ class RegisterPage extends StatefulWidget { class _RegisterPageState extends State { final GlobalKey _registerForm = GlobalKey(); - final TextEditingController _emailController = TextEditingController( - text: '', - ); - final TextEditingController _passwordController = TextEditingController( - text: '', - ); - final TextEditingController _userNameController = TextEditingController( - text: '', - ); + final TextEditingController _emailController = TextEditingController(text: ''); + final TextEditingController _passwordController = TextEditingController(text: ''); + final TextEditingController _userNameController = TextEditingController(text: ''); late final AuthBloc _authBloc; @override @@ -72,10 +66,7 @@ class _RegisterPageState extends State { children: [ Text( "Sign Up", - style: GoogleFonts.aBeeZee( - fontWeight: FontWeight.w400, - fontSize: 20, - ), + style: GoogleFonts.aBeeZee(fontWeight: FontWeight.w400, fontSize: 20), ), const SizedBox(height: 20), AuthorizationInputWidget( @@ -113,13 +104,9 @@ class _RegisterPageState extends State { child: ElevatedButton( style: ButtonStyle( shape: WidgetStatePropertyAll( - RoundedRectangleBorder( - borderRadius: BorderRadius.circular(15), - ), - ), - backgroundColor: const WidgetStatePropertyAll( - Colors.blueAccent, + RoundedRectangleBorder(borderRadius: BorderRadius.circular(15)), ), + backgroundColor: const WidgetStatePropertyAll(Colors.blueAccent), ), onPressed: () => _authBloc.add( @@ -128,8 +115,7 @@ class _RegisterPageState extends State { password: _passwordController.text, userName: _userNameController.text, initDependenciesAfterAuthorization: - dependencies - .initDependenciesAfterAuthorization, + dependencies.initDependenciesAfterAuthorization, // initDioOptions: () async { // await dependencies.dioSettings.initOptions(); // }, @@ -162,11 +148,7 @@ class _RegisterPageState extends State { crossAxisAlignment: CrossAxisAlignment.center, children: [ const Expanded( - child: Divider( - height: 0, - thickness: 0.5, - color: Colors.grey, - ), + child: Divider(height: 0, thickness: 0.5, color: Colors.grey), ), const SizedBox(width: 15), Text( @@ -179,11 +161,7 @@ class _RegisterPageState extends State { ), const SizedBox(width: 15), const Expanded( - child: Divider( - height: 0, - thickness: 0.5, - color: Colors.grey, - ), + child: Divider(height: 0, thickness: 0.5, color: Colors.grey), ), ], ), @@ -198,8 +176,7 @@ class _RegisterPageState extends State { () => _authBloc.add( AuthEvents.googleAuth( initDependenciesAfterAuthorization: - dependencies - .initDependenciesAfterAuthorization, + dependencies.initDependenciesAfterAuthorization, // initDioOptions: () async { // await dependencies.dioSettings.initOptions(); // }, @@ -210,17 +187,13 @@ class _RegisterPageState extends State { const SizedBox(width: 20), Expanded( child: OtherAuthorizationButtonWidget( - icon: const FaIcon( - FontAwesomeIcons.facebook, - color: Colors.blue, - ), + icon: const FaIcon(FontAwesomeIcons.facebook, color: Colors.blue), text: 'Facebook', onTap: () => _authBloc.add( AuthEvents.facebookAuth( initDependenciesAfterAuthorization: - dependencies - .initDependenciesAfterAuthorization, + dependencies.initDependenciesAfterAuthorization, // initDioOptions: () async { // await dependencies.dioSettings.initOptions(); // }, @@ -245,9 +218,7 @@ class _RegisterPageState extends State { recognizer: TapGestureRecognizer() ..onTap = - () => AutoRouter.of( - context, - ).replace(const LoginRoute()), + () => AutoRouter.of(context).replace(const LoginRoute()), text: Constants.signIn, style: const TextStyle(color: Colors.blue), ), diff --git a/lib/src/features/authorization/view/widgets/authorization_input_widget.dart b/lib/src/features/authorization/view/widgets/authorization_input_widget.dart index d06bc36..70b5253 100644 --- a/lib/src/features/authorization/view/widgets/authorization_input_widget.dart +++ b/lib/src/features/authorization/view/widgets/authorization_input_widget.dart @@ -17,8 +17,7 @@ class AuthorizationInputWidget extends StatefulWidget { }); @override - State createState() => - _AuthorizationInputWidgetState(); + State createState() => _AuthorizationInputWidgetState(); } class _AuthorizationInputWidgetState extends State { @@ -29,10 +28,7 @@ class _AuthorizationInputWidgetState extends State { return Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Text( - widget.title, - style: GoogleFonts.aBeeZee(fontWeight: FontWeight.w400), - ), + Text(widget.title, style: GoogleFonts.aBeeZee(fontWeight: FontWeight.w400)), const SizedBox(height: 5), ClipRRect( borderRadius: BorderRadius.circular(10), diff --git a/lib/src/features/chat_screen/bloc/chat_screen_bloc.dart b/lib/src/features/chat_screen/bloc/chat_screen_bloc.dart index 75f470e..fcd3a7c 100644 --- a/lib/src/features/chat_screen/bloc/chat_screen_bloc.dart +++ b/lib/src/features/chat_screen/bloc/chat_screen_bloc.dart @@ -46,21 +46,17 @@ sealed class ChatScreenEvents with _$ChatScreenEvents { @immutable @freezed sealed class ChatScreenStates with _$ChatScreenStates { - const factory ChatScreenStates.initial( - final ChatScreenStateModel chatScreenStateModel, - ) = ChatScreen$InitialState; + const factory ChatScreenStates.initial(final ChatScreenStateModel chatScreenStateModel) = + ChatScreen$InitialState; - const factory ChatScreenStates.inProgress( - final ChatScreenStateModel chatScreenStateModel, - ) = ChatScreen$InProgressState; + const factory ChatScreenStates.inProgress(final ChatScreenStateModel chatScreenStateModel) = + ChatScreen$InProgressState; - const factory ChatScreenStates.error( - final ChatScreenStateModel chatScreenStateModel, - ) = ErrorChatScreenState; + const factory ChatScreenStates.error(final ChatScreenStateModel chatScreenStateModel) = + ErrorChatScreenState; - const factory ChatScreenStates.successful( - final ChatScreenStateModel chatScreenStateModel, - ) = ChatScreen$SuccessfulState; + const factory ChatScreenStates.successful(final ChatScreenStateModel chatScreenStateModel) = + ChatScreen$SuccessfulState; } class ChatScreenBloc extends Bloc { @@ -93,8 +89,7 @@ class ChatScreenBloc extends Bloc { on( (event, emit) => event.map( initChatScreenEvent: (event) => _initChatScreenEvent(event, emit), - removeAllTempCreatedChatsEvent: - (event) => _removeAllTempCreatedChatsEvent(event, emit), + removeAllTempCreatedChatsEvent: (event) => _removeAllTempCreatedChatsEvent(event, emit), handleChatMessageEvent: (event) => _handleChatMessageEvent(event, emit), sendMessageEvent: (event) => _sendMessageEvent(event, emit), changeEmojiPicker: (event) => _changeEmojiPicker(event, emit), @@ -103,20 +98,14 @@ class ChatScreenBloc extends Bloc { // } - void _initChatScreenEvent( - _ChatScreen$InitEvent event, - Emitter emit, - ) async { + void _initChatScreenEvent(_ChatScreen$InitEvent event, Emitter emit) async { var currentStateModel = state.chatScreenStateModel.copyWith(); emit(ChatScreenStates.inProgress(currentStateModel)); currentStateModel = currentStateModel.copyWith(currentUser: _currentUser); - final chat = await _iChatScreenChatRepo.chat( - chat: event.chat, - withUser: event.user, - ); + final chat = await _iChatScreenChatRepo.chat(chat: event.chat, withUser: event.user); // i don't know why after calling function above currentUser from "_currentStateModel.currentUser" disappears // i didn't find a bug @@ -127,18 +116,12 @@ class ChatScreenBloc extends Bloc { // } if (chat == null || chat.uuid == null) { - currentStateModel = _setChat( - currentStateModel: currentStateModel, - chat: null, - ); + currentStateModel = _setChat(currentStateModel: currentStateModel, chat: null); emit(ChatScreenStates.error(currentStateModel)); return; } - currentStateModel = _setChat( - currentStateModel: currentStateModel, - chat: chat, - ); + currentStateModel = _setChat(currentStateModel: currentStateModel, chat: chat); final channelName = "${Constants.chatChannelName}${chat.id}${Constants.chatChannelUUID}${chat.uuid}"; @@ -152,11 +135,9 @@ class ChatScreenBloc extends Bloc { final channel = _pusherChannelsClient?.publicChannel(channelName); - _channelInformationSubscription = _pusherChannelsClient - ?.onConnectionEstablished - .listen((e) { - channel?.subscribeIfNotUnsubscribed(); - }); + _channelInformationSubscription = _pusherChannelsClient?.onConnectionEstablished.listen((e) { + channel?.subscribeIfNotUnsubscribed(); + }); await _pusherChannelsClient?.connect(); @@ -167,9 +148,7 @@ class ChatScreenBloc extends Bloc { (pusherEvent) { add(ChatScreenEvents.handleChatMessageEvent(pusherEvent)); }, - onError: - (error, stackTrace) => - Error.throwWithStackTrace(error, stackTrace), + onError: (error, stackTrace) => Error.throwWithStackTrace(error, stackTrace), onDone: () => _channelSubscription?.cancel(), ); @@ -182,9 +161,7 @@ class ChatScreenBloc extends Bloc { _ChatsScreen$RemoveAllTempCreatedEvent event, Emitter emit, ) async { - _iChatScreenChatRepo.removeAllTempCreatedChats( - chat: state.chatScreenStateModel.currentChat, - ); + _iChatScreenChatRepo.removeAllTempCreatedChats(chat: state.chatScreenStateModel.currentChat); } void _handleChatMessageEvent( @@ -218,10 +195,7 @@ class ChatScreenBloc extends Bloc { _emitter(emit: emit, currentStateModel: currentStateModel); } - void _sendMessageEvent( - _Chat$SendMessageEvent event, - Emitter emit, - ) async { + void _sendMessageEvent(_Chat$SendMessageEvent event, Emitter emit) async { var currentStateModel = state.chatScreenStateModel.copyWith(); // if (currentStateModel.pickedFile == null) { // return; @@ -238,10 +212,7 @@ class ChatScreenBloc extends Bloc { messageSent: false, ); - currentStateModel = _addMessage( - message: chatMessage, - currentStateModel: currentStateModel, - ); + currentStateModel = _addMessage(message: chatMessage, currentStateModel: currentStateModel); event.clearMessage(); @@ -270,9 +241,7 @@ class ChatScreenBloc extends Bloc { if (chat == null) return currentStateModel; currentStateModel = currentStateModel.copyWith(currentChat: chat); if (setChatMessages) { - final List chatMessages = List.from( - currentStateModel.messages, - ); + final List chatMessages = List.from(currentStateModel.messages); chatMessages.addAll((chat.messages ?? []).reversed.toList()); currentStateModel = currentStateModel.copyWith(messages: chatMessages); } @@ -290,9 +259,7 @@ class ChatScreenBloc extends Bloc { required ChatMessageModel message, required ChatScreenStateModel currentStateModel, }) { - final listOfMessages = List.from( - currentStateModel.messages, - ); + final listOfMessages = List.from(currentStateModel.messages); final findMessage = listOfMessages.firstWhereOrNull( (e) => e.chatMessageUUID == message.chatMessageUUID, diff --git a/lib/src/features/chat_screen/bloc/stream_transformers/chat_message_stream_transformer.dart b/lib/src/features/chat_screen/bloc/stream_transformers/chat_message_stream_transformer.dart index d17b2f6..e965cef 100644 --- a/lib/src/features/chat_screen/bloc/stream_transformers/chat_message_stream_transformer.dart +++ b/lib/src/features/chat_screen/bloc/stream_transformers/chat_message_stream_transformer.dart @@ -12,21 +12,14 @@ typedef ChatMessageStreamTransformerRecord = // I know that I could create a class that holds chatModel and message // but in order to improve records i had to write final class ChatMessageStreamTransformer - extends - StreamTransformerBase< - ChannelReadEvent, - ChatMessageStreamTransformerRecord - > { + extends StreamTransformerBase { // - ChatMessageStreamTransformer({required final Logger logger}) - : _logger = logger; + ChatMessageStreamTransformer({required final Logger logger}) : _logger = logger; final Logger _logger; @override - Stream bind( - Stream stream, - ) { + Stream bind(Stream stream) { StreamSubscription? subscription; final controller = StreamController( @@ -42,11 +35,8 @@ final class ChatMessageStreamTransformer ChatMessageModel? message; ChatModel? chat; - if (messageJson.containsKey('message') && - messageJson['message'] != null) { - message = ChatMessageModel.fromJson( - messageJson['message'], - ).copyWith(messageSent: true); + if (messageJson.containsKey('message') && messageJson['message'] != null) { + message = ChatMessageModel.fromJson(messageJson['message']).copyWith(messageSent: true); } // find problem here diff --git a/lib/src/features/chat_screen/data/sources/chat_screen_chat_data_source/impl/chat_screen_chat_data_souce.dart b/lib/src/features/chat_screen/data/sources/chat_screen_chat_data_source/impl/chat_screen_chat_data_souce.dart index 4220b0f..f459989 100644 --- a/lib/src/features/chat_screen/data/sources/chat_screen_chat_data_source/impl/chat_screen_chat_data_souce.dart +++ b/lib/src/features/chat_screen/data/sources/chat_screen_chat_data_source/impl/chat_screen_chat_data_souce.dart @@ -14,8 +14,7 @@ class ChatScreenChatDataSourceImpl implements ChatScreenChatDataSource { final RestClientBase _restClientBase; final String _getChatUrl = "${HttpRoutes.chatsPrefix}/get/chat/on/entrance"; - final String _deleteTempCreatedChatsUrl = - "${HttpRoutes.chatsPrefix}/delete/temp/created/chats"; + final String _deleteTempCreatedChatsUrl = "${HttpRoutes.chatsPrefix}/delete/temp/created/chats"; @override Future chat({ChatModel? chat, UserModel? withUser}) async { @@ -46,10 +45,7 @@ class ChatScreenChatDataSourceImpl implements ChatScreenChatDataSource { try { final body = {"chat_id": chat?.id, "chat_uuid": chat?.uuid}; - final response = await _restClientBase.delete( - _deleteTempCreatedChatsUrl, - data: body, - ); + final response = await _restClientBase.delete(_deleteTempCreatedChatsUrl, data: body); debugPrint("coming remove temp created chats: $response"); } on RestClientException { diff --git a/lib/src/features/chat_screen/data/sources/chat_screen_message_data_source/impl/chat_screen_message_data_source_impl.dart b/lib/src/features/chat_screen/data/sources/chat_screen_message_data_source/impl/chat_screen_message_data_source_impl.dart index 752a922..c4831ae 100644 --- a/lib/src/features/chat_screen/data/sources/chat_screen_message_data_source/impl/chat_screen_message_data_source_impl.dart +++ b/lib/src/features/chat_screen/data/sources/chat_screen_message_data_source/impl/chat_screen_message_data_source_impl.dart @@ -11,14 +11,12 @@ import 'package:yahay/src/features/chat_screen/data/sources/chat_screen_message_ class ChatScreenMessageDataSourceImpl extends ChatScreenMessageDataSource { // - ChatScreenMessageDataSourceImpl({ - required final RestClientBase restClientBase, - }) : _restClientBase = restClientBase; + ChatScreenMessageDataSourceImpl({required final RestClientBase restClientBase}) + : _restClientBase = restClientBase; final RestClientBase _restClientBase; - static const String _messageSendUrl = - "${HttpRoutes.chatsPrefix}/message/handler"; + static const String _messageSendUrl = "${HttpRoutes.chatsPrefix}/message/handler"; @override Future sendMessage({required ChatMessageModel chatMessage}) async { @@ -46,10 +44,7 @@ class ChatScreenMessageDataSourceImpl extends ChatScreenMessageDataSource { final formData = FormData.fromMap(toJson); - final response = await _restClientBase.post( - _messageSendUrl, - formData: formData, - ); + final response = await _restClientBase.post(_messageSendUrl, formData: formData); debugPrint("reponseddata: $response"); } on RestClientException { diff --git a/lib/src/features/chat_screen/view/app_bar/chat_screen_app_bar.dart b/lib/src/features/chat_screen/view/app_bar/chat_screen_app_bar.dart index 96ac987..847a5dd 100644 --- a/lib/src/features/chat_screen/view/app_bar/chat_screen_app_bar.dart +++ b/lib/src/features/chat_screen/view/app_bar/chat_screen_app_bar.dart @@ -11,11 +11,7 @@ class ChatScreenAppBar extends StatefulWidget { final ThemeData themeData; final ChatModel? chat; - const ChatScreenAppBar({ - super.key, - required this.themeData, - required this.chat, - }); + const ChatScreenAppBar({super.key, required this.themeData, required this.chat}); @override State createState() => _ChatScreenAppBarState(); @@ -80,19 +76,14 @@ class _ChatScreenAppBarState extends State { : [ IconButton( onPressed: () { - AutoRouter.of(context).push( - VideoChatFeatureRoute( - chat: currentStateModel.currentChat, - ), - ); + AutoRouter.of( + context, + ).push(VideoChatFeatureRoute(chat: currentStateModel.currentChat)); }, icon: Icon( CupertinoIcons.videocam, color: - (currentStateModel - .currentChat - ?.videoChatStreaming ?? - false) + (currentStateModel.currentChat?.videoChatStreaming ?? false) ? Colors.green : null, ), diff --git a/lib/src/features/chat_screen/view/bottom_chat_widget/bottom_chat_widget.dart b/lib/src/features/chat_screen/view/bottom_chat_widget/bottom_chat_widget.dart index c39f6c4..ea47915 100644 --- a/lib/src/features/chat_screen/view/bottom_chat_widget/bottom_chat_widget.dart +++ b/lib/src/features/chat_screen/view/bottom_chat_widget/bottom_chat_widget.dart @@ -43,30 +43,17 @@ class _BottomChatWidgetState extends State { child: Container( constraints: const BoxConstraints(maxHeight: 100), color: Theme.of(context).inputDecorationTheme.fillColor, - padding: const EdgeInsets.only( - top: 10, - bottom: 10, - left: 10, - right: 35, - ), + padding: const EdgeInsets.only(top: 10, bottom: 10, left: 10, right: 35), width: MediaQuery.of(context).size.width, child: TextField( controller: widget.messageController, textInputAction: TextInputAction.newline, onTap: () { - _chatsBloc.add( - const ChatScreenEvents.changeEmojiPicker( - value: false, - ), - ); + _chatsBloc.add(const ChatScreenEvents.changeEmojiPicker(value: false)); }, focusNode: _focusNode, onTapOutside: (v) { - _chatsBloc.add( - const ChatScreenEvents.changeEmojiPicker( - value: false, - ), - ); + _chatsBloc.add(const ChatScreenEvents.changeEmojiPicker(value: false)); FocusManager.instance.primaryFocus?.unfocus(); }, onChanged: (v) { @@ -98,9 +85,7 @@ class _BottomChatWidgetState extends State { child: IconButton( onPressed: () { FocusManager.instance.primaryFocus?.unfocus(); - _chatsBloc.add( - const ChatScreenEvents.changeEmojiPicker(), - ); + _chatsBloc.add(const ChatScreenEvents.changeEmojiPicker()); }, icon: Icon( Icons.emoji_emotions_outlined, @@ -118,14 +103,10 @@ class _BottomChatWidgetState extends State { right: 0, child: IconButton( onPressed: () { - final dependencies = DependenciesScope.of( - context, - listen: false, - ); + final dependencies = DependenciesScope.of(context, listen: false); final telegramFilePickerBloc = TelegramFilePickerBlocFactory( - cameraHelperService: - dependencies.cameraHelperService, + cameraHelperService: dependencies.cameraHelperService, ).create(); showModalBottomSheet( isScrollControlled: true, diff --git a/lib/src/features/chat_screen/view/bottom_chat_widget/emoji_picker_helper.dart b/lib/src/features/chat_screen/view/bottom_chat_widget/emoji_picker_helper.dart index 22646d5..2071b48 100644 --- a/lib/src/features/chat_screen/view/bottom_chat_widget/emoji_picker_helper.dart +++ b/lib/src/features/chat_screen/view/bottom_chat_widget/emoji_picker_helper.dart @@ -31,9 +31,7 @@ class _EmojiPickerHelperState extends State { onBackspacePressed: () { // Do something when the user taps the backspace button (optional) // Set it to null to hide the Backspace-Button - _chatScreenBloc.add( - const ChatScreenEvents.changeEmojiPicker(value: false), - ); + _chatScreenBloc.add(const ChatScreenEvents.changeEmojiPicker(value: false)); }, textEditingController: widget.messageController, // pass here the same [TextEditingController] that is connected to your input field, usually a [TextFormField] @@ -42,11 +40,7 @@ class _EmojiPickerHelperState extends State { checkPlatformCompatibility: true, emojiViewConfig: EmojiViewConfig( // Issue: https://github.com/flutter/flutter/issues/28894 - emojiSizeMax: - 28 * - (foundation.defaultTargetPlatform == TargetPlatform.iOS - ? 1.20 - : 1.0), + emojiSizeMax: 28 * (foundation.defaultTargetPlatform == TargetPlatform.iOS ? 1.20 : 1.0), ), // viewOrderConfig: ViewOrderConfig( // bottom: EmojiPickerItem.categoryBar, diff --git a/lib/src/features/chat_screen/view/chat_screen.dart b/lib/src/features/chat_screen/view/chat_screen.dart index 536013c..63055ec 100644 --- a/lib/src/features/chat_screen/view/chat_screen.dart +++ b/lib/src/features/chat_screen/view/chat_screen.dart @@ -33,8 +33,7 @@ class ChatScreen extends StatelessWidget { (context) => ChatScreenBlocFactory( user: dependencyContainer.authBloc.state.authStateModel.user, - channelsOptions: - dependencyContainer.pusherClientService.options, + channelsOptions: dependencyContainer.pusherClientService.options, restClientBase: dependencyContainer.restClientBase, logger: dependencyContainer.logger, ).create(), @@ -69,12 +68,7 @@ class _ChatScreenUIState extends State<_ChatScreenUI> { _appThemeBloc = dependencyContainer.appThemeBloc; // // - _chatScreenBloc.add( - ChatScreenEvents.initChatScreenEvent( - chat: widget.chat, - user: widget.user, - ), - ); + _chatScreenBloc.add(ChatScreenEvents.initChatScreenEvent(chat: widget.chat, user: widget.user)); } @override @@ -85,9 +79,7 @@ class _ChatScreenUIState extends State<_ChatScreenUI> { void _emojiClearHelper(ChatScreenStateModel currentStateModel) { if (currentStateModel.showEmojiPicker) { - _chatScreenBloc.add( - const ChatScreenEvents.changeEmojiPicker(value: false), - ); + _chatScreenBloc.add(const ChatScreenEvents.changeEmojiPicker(value: false)); } } @@ -107,18 +99,14 @@ class _ChatScreenUIState extends State<_ChatScreenUI> { final currentStateModel = state.chatScreenStateModel; return PopScope( canPop: !currentStateModel.showEmojiPicker, - onPopInvokedWithResult: - (v, _) => _emojiClearHelper(currentStateModel), + onPopInvokedWithResult: (v, _) => _emojiClearHelper(currentStateModel), child: GestureDetector( onTap: () { _emojiClearHelper(currentStateModel); }, child: Scaffold( appBar: PreferredSize( - preferredSize: Size( - MediaQuery.of(context).size.width, - kToolbarHeight, - ), + preferredSize: Size(MediaQuery.of(context).size.width, kToolbarHeight), child: ChatScreenAppBar( themeData: _appThemeBloc.theme.value, chat: widget.chat, @@ -134,19 +122,13 @@ class _ChatScreenUIState extends State<_ChatScreenUI> { reverse: true, children: [ ListView.separated( - separatorBuilder: - (context, index) => - const SizedBox(height: 10), + separatorBuilder: (context, index) => const SizedBox(height: 10), shrinkWrap: true, physics: const NeverScrollableScrollPhysics(), itemCount: currentStateModel.messages.length, itemBuilder: (context, index) { - final message = - currentStateModel.messages[index]; - return MessageWidget( - message: message, - currentUser: currentUser, - ); + final message = currentStateModel.messages[index]; + return MessageWidget(message: message, currentUser: currentUser); }, ), ], @@ -154,9 +136,7 @@ class _ChatScreenUIState extends State<_ChatScreenUI> { ), BottomChatWidget(messageController: _messageController), if (currentStateModel.showEmojiPicker) - EmojiPickerHelper( - messageController: _messageController, - ), + EmojiPickerHelper(messageController: _messageController), ], ), ), diff --git a/lib/src/features/chat_screen/view/message_widget/loading_messages_widget.dart b/lib/src/features/chat_screen/view/message_widget/loading_messages_widget.dart index ecab3a1..f0b473d 100644 --- a/lib/src/features/chat_screen/view/message_widget/loading_messages_widget.dart +++ b/lib/src/features/chat_screen/view/message_widget/loading_messages_widget.dart @@ -59,10 +59,7 @@ class _RightWidget extends StatelessWidget { mainAxisSize: MainAxisSize.min, children: [ Container( - margin: EdgeInsets.only( - left: MediaQuery.of(context).size.width / 4, - right: 10, - ), + margin: EdgeInsets.only(left: MediaQuery.of(context).size.width / 4, right: 10), padding: const EdgeInsets.symmetric(horizontal: 15, vertical: 10), decoration: const BoxDecoration( color: Colors.blue, @@ -98,10 +95,7 @@ class _LeftWidget extends StatelessWidget { mainAxisSize: MainAxisSize.min, children: [ Container( - margin: EdgeInsets.only( - right: MediaQuery.of(context).size.width / 4, - left: 10, - ), + margin: EdgeInsets.only(right: MediaQuery.of(context).size.width / 4, left: 10), padding: const EdgeInsets.symmetric(horizontal: 15, vertical: 10), decoration: const BoxDecoration( color: Colors.blue, diff --git a/lib/src/features/chat_screen/view/message_widget/message_widget.dart b/lib/src/features/chat_screen/view/message_widget/message_widget.dart index 2b5d829..06ef13d 100644 --- a/lib/src/features/chat_screen/view/message_widget/message_widget.dart +++ b/lib/src/features/chat_screen/view/message_widget/message_widget.dart @@ -9,11 +9,7 @@ class MessageWidget extends StatefulWidget { final UserModel? currentUser; final ChatMessageModel? message; - const MessageWidget({ - super.key, - required this.message, - required this.currentUser, - }); + const MessageWidget({super.key, required this.message, required this.currentUser}); @override State createState() => _MessageWidgetState(); @@ -42,10 +38,7 @@ class _LeftSide extends StatelessWidget { mainAxisSize: MainAxisSize.min, children: [ Container( - margin: EdgeInsets.only( - right: MediaQuery.of(context).size.width / 4, - left: 10, - ), + margin: EdgeInsets.only(right: MediaQuery.of(context).size.width / 4, left: 10), padding: const EdgeInsets.symmetric(horizontal: 15, vertical: 10), decoration: const BoxDecoration( color: Colors.blue, @@ -87,10 +80,7 @@ class _RightSide extends StatelessWidget { mainAxisSize: MainAxisSize.min, children: [ Container( - margin: EdgeInsets.only( - left: MediaQuery.of(context).size.width / 4, - right: 10, - ), + margin: EdgeInsets.only(left: MediaQuery.of(context).size.width / 4, right: 10), padding: const EdgeInsets.symmetric(horizontal: 15, vertical: 10), decoration: const BoxDecoration( color: Colors.blue, @@ -128,9 +118,7 @@ class _MessageTime extends StatelessWidget { mainAxisSize: MainAxisSize.min, children: [ Text( - DateFormat.yMMMd().format( - DateTime.parse(message?.createdAt ?? Constants.tempDateTime), - ), + DateFormat.yMMMd().format(DateTime.parse(message?.createdAt ?? Constants.tempDateTime)), style: GoogleFonts.aBeeZee( fontSize: 9, height: 0, @@ -156,11 +144,7 @@ class _MessageTime extends StatelessWidget { ), ) else - const Icon( - Icons.access_time_outlined, - size: 13, - color: Colors.white, - ), + const Icon(Icons.access_time_outlined, size: 13, color: Colors.white), ], ); } diff --git a/lib/src/features/chats/bloc/chats_bloc.dart b/lib/src/features/chats/bloc/chats_bloc.dart index d616c63..4c848a3 100644 --- a/lib/src/features/chats/bloc/chats_bloc.dart +++ b/lib/src/features/chats/bloc/chats_bloc.dart @@ -17,30 +17,24 @@ part 'chats_bloc.freezed.dart'; @immutable @freezed sealed class ChatsEvents with _$ChatsEvents { - const factory ChatsEvents.getUserChatsEvent({@Default(false) bool refresh}) = - _Chats$GetUserEvent; + const factory ChatsEvents.getUserChatsEvent({@Default(false) bool refresh}) = _Chats$GetUserEvent; - const factory ChatsEvents.chatListenerInitialEvent() = - _Chats$ListenerInitialEvent; + const factory ChatsEvents.chatListenerInitialEvent() = _Chats$ListenerInitialEvent; - const factory ChatsEvents.chatListenerEvent(final ChatModel? chatModel) = - _Chat$ListenerEvent; + const factory ChatsEvents.chatListenerEvent(final ChatModel? chatModel) = _Chat$ListenerEvent; - const factory ChatsEvents.changeToLoadingState() = - _Chats$ChangeToLoadingStateEvent; + const factory ChatsEvents.changeToLoadingState() = _Chats$ChangeToLoadingStateEvent; } @immutable @freezed sealed class ChatsStates with _$ChatsStates { - const factory ChatsStates.initial(final ChatsStateModel chatsStateModel) = - Chats$InitialState; + const factory ChatsStates.initial(final ChatsStateModel chatsStateModel) = Chats$InitialState; const factory ChatsStates.inProgress(final ChatsStateModel chatsStateModel) = Chats$InProgressState; - const factory ChatsStates.error(final ChatsStateModel chatsStateModel) = - Chats$ErrorState; + const factory ChatsStates.error(final ChatsStateModel chatsStateModel) = Chats$ErrorState; const factory ChatsStates.successful(final ChatsStateModel chatsStateModel) = Chats$SuccessfulState; @@ -73,31 +67,22 @@ class ChatsBloc extends Bloc { on( (event, emit) => event.map( getUserChatsEvent: (event) => _getUserChatsEvent(event, emit), - chatListenerInitialEvent: - (event) => _chatListenerInitialEvent(event, emit), + chatListenerInitialEvent: (event) => _chatListenerInitialEvent(event, emit), chatListenerEvent: (event) => _chatListenerEvent(event, emit), changeToLoadingState: (event) => _changeToLoadingState(event, emit), ), ); } - void _getUserChatsEvent( - _Chats$GetUserEvent event, - Emitter emit, - ) async { + void _getUserChatsEvent(_Chats$GetUserEvent event, Emitter emit) async { try { if (state is Chats$SuccessfulState && !event.refresh) return; emit(ChatsStates.inProgress(state.chatsStateModel)); - final currentStateModel = state.chatsStateModel.copyWith( - chats: await _chatsRepo.chats(), - ); + final currentStateModel = state.chatsStateModel.copyWith(chats: await _chatsRepo.chats()); - _logger.log( - Level.debug, - "chat length is: ${currentStateModel.chats.length}", - ); + _logger.log(Level.debug, "chat length is: ${currentStateModel.chats.length}"); emit(ChatsStates.successful(currentStateModel)); } catch (e) { @@ -113,8 +98,7 @@ class ChatsBloc extends Bloc { try { if (_channelSubscription != null) return; - final channelName = - "${Constants.channelNotifyOfUserName}${_currentUser?.id}"; + final channelName = "${Constants.channelNotifyOfUserName}${_currentUser?.id}"; _logger.log(Level.debug, "current whole channel listeners: $channelName"); @@ -125,11 +109,9 @@ class ChatsBloc extends Bloc { final chatChannel = _pusherClientService?.publicChannel(channelName); - _channelSubscriptionInformation = _pusherClientService - ?.onConnectionEstablished - .listen((e) { - chatChannel?.subscribeIfNotUnsubscribed(); - }); + _channelSubscriptionInformation = _pusherClientService?.onConnectionEstablished.listen((e) { + chatChannel?.subscribeIfNotUnsubscribed(); + }); await _pusherClientService?.connect(); @@ -144,10 +126,7 @@ class ChatsBloc extends Bloc { } } - void _chatListenerEvent( - _Chat$ListenerEvent event, - Emitter emit, - ) async { + void _chatListenerEvent(_Chat$ListenerEvent event, Emitter emit) async { try { _logger.log(Level.debug, "${event.chatModel}"); @@ -155,10 +134,7 @@ class ChatsBloc extends Bloc { if (event.chatModel != null) { final currentStateModel = state.chatsStateModel.copyWith( - chats: _addChat( - chat: event.chatModel, - currentChats: state.chatsStateModel.chats, - ), + chats: _addChat(chat: event.chatModel, currentChats: state.chatsStateModel.chats), ); _emitter(currentStateModel: currentStateModel, emit: emit); @@ -176,10 +152,7 @@ class ChatsBloc extends Bloc { _emitter(currentStateModel: currentState, emit: emit); } - void _emitter({ - required ChatsStateModel currentStateModel, - required Emitter emit, - }) { + void _emitter({required ChatsStateModel currentStateModel, required Emitter emit}) { switch (state) { case Chats$InitialState(): emit(ChatsStates.initial(currentStateModel)); @@ -208,15 +181,11 @@ class ChatsBloc extends Bloc { final convertedToModelChat = _removeCurrentUserFromParticipants(chat, user); final chatIndex = resultChats.indexWhere( - (e) => - e.id == convertedToModelChat.id && - e.uuid == convertedToModelChat.uuid, + (e) => e.id == convertedToModelChat.id && e.uuid == convertedToModelChat.uuid, ); if (chatIndex != -1) { - resultChats[chatIndex] = convertedToModelChat.copyWith( - lastMessage: chat.lastMessage, - ); + resultChats[chatIndex] = convertedToModelChat.copyWith(lastMessage: chat.lastMessage); } else { resultChats.add(convertedToModelChat); } @@ -224,10 +193,7 @@ class ChatsBloc extends Bloc { return resultChats; } - ChatModel _removeCurrentUserFromParticipants( - ChatModel chatModel, - UserModel? user, - ) { + ChatModel _removeCurrentUserFromParticipants(ChatModel chatModel, UserModel? user) { final data = List.from( chatModel.participants ?? [], ); diff --git a/lib/src/features/chats/bloc/state_model/chats_state_model.dart b/lib/src/features/chats/bloc/state_model/chats_state_model.dart index 2714397..62b86a5 100644 --- a/lib/src/features/chats/bloc/state_model/chats_state_model.dart +++ b/lib/src/features/chats/bloc/state_model/chats_state_model.dart @@ -10,9 +10,7 @@ class ChatsStateModel { @override bool operator ==(Object other) => identical(this, other) || - (other is ChatsStateModel && - runtimeType == other.runtimeType && - chats == other.chats); + (other is ChatsStateModel && runtimeType == other.runtimeType && chats == other.chats); @override int get hashCode => chats.hashCode; diff --git a/lib/src/features/chats/bloc/stream_transformers/chats_stream_transformers.dart b/lib/src/features/chats/bloc/stream_transformers/chats_stream_transformers.dart index ffeebcf..e1b57c0 100644 --- a/lib/src/features/chats/bloc/stream_transformers/chats_stream_transformers.dart +++ b/lib/src/features/chats/bloc/stream_transformers/chats_stream_transformers.dart @@ -5,8 +5,7 @@ import 'package:dart_pusher_channels/dart_pusher_channels.dart'; import 'package:logger/logger.dart'; import 'package:yahay/src/core/models/chats_model/chat_model.dart'; -class ChatsStreamTransformers - extends StreamTransformerBase { +class ChatsStreamTransformers extends StreamTransformerBase { // ChatsStreamTransformers({required final Logger logger}) : _logger = logger; diff --git a/lib/src/features/chats/view/chat_widget/chat_widget.dart b/lib/src/features/chats/view/chat_widget/chat_widget.dart index 8ef2ba4..82b47b1 100644 --- a/lib/src/features/chats/view/chat_widget/chat_widget.dart +++ b/lib/src/features/chats/view/chat_widget/chat_widget.dart @@ -33,10 +33,7 @@ class ChatWidget extends StatelessWidget { _ChatName(chat: chat), Text( chat?.lastMessage?.message ?? '-', - style: GoogleFonts.aBeeZee( - fontSize: 13, - color: Colors.grey, - ), + style: GoogleFonts.aBeeZee(fontSize: 13, color: Colors.grey), ), ], ), @@ -44,9 +41,7 @@ class ChatWidget extends StatelessWidget { if (chat?.videoChatStreaming ?? false) IconButton( onPressed: () { - AutoRouter.of( - context, - ).push(VideoChatFeatureRoute(chat: chat)); + AutoRouter.of(context).push(VideoChatFeatureRoute(chat: chat)); }, icon: const Icon(CupertinoIcons.videocam, color: Colors.green), ), @@ -72,10 +67,7 @@ class _ChatMainImage extends StatelessWidget { borderRadius: BorderRadius.circular(50), child: CircleAvatar( radius: 30, - child: ColoredBox( - color: Colors.green, - child: Text(chat?.getWrappedName() ?? '-'), - ), + child: ColoredBox(color: Colors.green, child: Text(chat?.getWrappedName() ?? '-')), ), ); } @@ -98,10 +90,7 @@ class _ChatImageBuilder extends StatelessWidget { borderRadius: BorderRadius.circular(50), child: CircleAvatar( radius: 30, - child: ImageLoaderWidget( - url: path ?? '', - errorImageUrl: Constants.defaultUserImage, - ), + child: ImageLoaderWidget(url: path ?? '', errorImageUrl: Constants.defaultUserImage), ), ); } diff --git a/lib/src/features/chats/view/chats_appbar/chats_appbar.dart b/lib/src/features/chats/view/chats_appbar/chats_appbar.dart index 0d3a1ac..7de5609 100644 --- a/lib/src/features/chats/view/chats_appbar/chats_appbar.dart +++ b/lib/src/features/chats/view/chats_appbar/chats_appbar.dart @@ -14,16 +14,12 @@ class ChatsAppbar extends StatelessWidget { centerTitle: true, scrolledUnderElevation: 0.0, leading: IconButton( - onPressed: - () => OpenSearchContactsPopup.openSearchContactsPopup(context), + onPressed: () => OpenSearchContactsPopup.openSearchContactsPopup(context), icon: const Icon(Icons.person_add_alt), ), actions: [ IconButton(onPressed: () {}, icon: const Icon(CupertinoIcons.search)), - IconButton( - onPressed: () {}, - icon: const FaIcon(FontAwesomeIcons.gear, size: 20), - ), + IconButton(onPressed: () {}, icon: const FaIcon(FontAwesomeIcons.gear, size: 20)), ], ); } diff --git a/lib/src/features/chats/view/chats_page.dart b/lib/src/features/chats/view/chats_page.dart index db27707..ec33ee1 100644 --- a/lib/src/features/chats/view/chats_page.dart +++ b/lib/src/features/chats/view/chats_page.dart @@ -34,10 +34,7 @@ class _ChatsPageState extends State { child: const ChatsAppbar(), ), body: RefreshIndicator( - onRefresh: - () async => _chatsBloc?.add( - const ChatsEvents.getUserChatsEvent(refresh: true), - ), + onRefresh: () async => _chatsBloc?.add(const ChatsEvents.getUserChatsEvent(refresh: true)), child: ListView( physics: const AlwaysScrollableScrollPhysics(), padding: const EdgeInsets.all(8), @@ -56,8 +53,7 @@ class _ChatsPageState extends State { case Chats$SuccessfulState(): final currentStateModel = state.chatsStateModel; return ListView.separated( - separatorBuilder: - (context, index) => const SizedBox(height: 15), + separatorBuilder: (context, index) => const SizedBox(height: 15), shrinkWrap: true, physics: const NeverScrollableScrollPhysics(), itemCount: currentStateModel.chats.length, diff --git a/lib/src/features/home_page.dart b/lib/src/features/home_page.dart index 4e74ff2..ba820a8 100644 --- a/lib/src/features/home_page.dart +++ b/lib/src/features/home_page.dart @@ -81,12 +81,7 @@ class _HomePageState extends State { unselectedLabelStyle: GoogleFonts.aBeeZee(), selectedLabelStyle: GoogleFonts.aBeeZee(), items: - _screens - .map( - (e) => - BottomNavigationBarItem(icon: e.icon, label: e.label), - ) - .toList(), + _screens.map((e) => BottomNavigationBarItem(icon: e.icon, label: e.label)).toList(), ), body: _screens[_index].screen, ); diff --git a/lib/src/features/initialization/logic/app_runner.dart b/lib/src/features/initialization/logic/app_runner.dart index 5584f30..b567f3e 100644 --- a/lib/src/features/initialization/logic/app_runner.dart +++ b/lib/src/features/initialization/logic/app_runner.dart @@ -23,9 +23,7 @@ import 'package:bloc_concurrency/bloc_concurrency.dart' as concurrency; class AppRunner with FolderCreator { Future initialize() async { final Logger logger = - AppLoggerFactory( - logFilter: kReleaseMode ? NoOpLogFilter() : DevelopmentFilter(), - ).create(); + AppLoggerFactory(logFilter: kReleaseMode ? NoOpLogFilter() : DevelopmentFilter()).create(); await runZonedGuarded( () async { @@ -51,22 +49,14 @@ class AppRunner with FolderCreator { // handles bloc errors, creations, changes, events etc. Bloc.observer = BlocObserverManager(logger); - await Firebase.initializeApp( - options: DefaultFirebaseOptions.currentPlatform, - ); + await Firebase.initializeApp(options: DefaultFirebaseOptions.currentPlatform); FlutterError.onError = (errorDetails) { - FirebaseCrashlytics.instance.recordFlutterFatalError( - errorDetails, - ); + FirebaseCrashlytics.instance.recordFlutterFatalError(errorDetails); }; PlatformDispatcher.instance.onError = (error, stack) { - FirebaseCrashlytics.instance.recordError( - error, - stack, - fatal: true, - ); + FirebaseCrashlytics.instance.recordError(error, stack, fatal: true); return true; }; @@ -81,8 +71,7 @@ class AppRunner with FolderCreator { if (kDebugMode) { await DebugImageCreatorInAppsFolder( - sharedPreferHelper: - compositionRoot.dependencies.sharedPreferHelper, + sharedPreferHelper: compositionRoot.dependencies.sharedPreferHelper, ).createImagesInAppsFolder(); } diff --git a/lib/src/features/initialization/logic/composition_root/composition_root.dart b/lib/src/features/initialization/logic/composition_root/composition_root.dart index 9c1a80d..36d817d 100644 --- a/lib/src/features/initialization/logic/composition_root/composition_root.dart +++ b/lib/src/features/initialization/logic/composition_root/composition_root.dart @@ -56,8 +56,7 @@ class CompositionResult { CompositionResult(this.dependencies); } -final class DependencyContainerFactory - extends AsyncFactory { +final class DependencyContainerFactory extends AsyncFactory { DependencyContainerFactory({ required Logger logger, required SharedPreferHelper sharedPreferHelper, @@ -85,10 +84,7 @@ final class DependencyContainerFactory await cameraHelperService.initCameras(); final addContactBloc = - AddContactBlocFactory( - logger: _logger, - restClientBase: _restClientBase, - ).create(); + AddContactBlocFactory(logger: _logger, restClientBase: _restClientBase).create(); final pusherClientService = PusherClientService(); diff --git a/lib/src/features/initialization/logic/composition_root/factories/add_contact_bloc_factory.dart b/lib/src/features/initialization/logic/composition_root/factories/add_contact_bloc_factory.dart index 64744b2..583f4f5 100644 --- a/lib/src/features/initialization/logic/composition_root/factories/add_contact_bloc_factory.dart +++ b/lib/src/features/initialization/logic/composition_root/factories/add_contact_bloc_factory.dart @@ -30,9 +30,6 @@ final class AddContactBlocFactory extends Factory { final initialState = AddContactsStates.initial(AddContactStateModel.idle()); - return AddContactBloc( - initialState: initialState, - iAddContactRepo: addContactRepo, - ); + return AddContactBloc(initialState: initialState, iAddContactRepo: addContactRepo); } } diff --git a/lib/src/features/initialization/logic/composition_root/factories/authorization_bloc_factory.dart b/lib/src/features/initialization/logic/composition_root/factories/authorization_bloc_factory.dart index fde8049..bc69dac 100644 --- a/lib/src/features/initialization/logic/composition_root/factories/authorization_bloc_factory.dart +++ b/lib/src/features/initialization/logic/composition_root/factories/authorization_bloc_factory.dart @@ -37,28 +37,25 @@ final class AuthorizationBlocFactory extends Factory { @override AuthBloc create() { - final LaravelAuthDataSource laravelAuthDataSource = - LaravelAuthDataSourceImpl( - sharedPreferences: _sharedPreferHelper, - restClientBase: _restClientBase, - screenMessaging: ScreenMessaging.instance, - logger: _logger, - ); - - final OtherAuthorizationDatasource otherAuthorizationDatasource = - OtherAuthorizationImpl( - googleSignIn: _googleSignIn, - facebookAuth: _facebookAuth, - sharedPreferHelper: _sharedPreferHelper, - restClientBase: _restClientBase, - ); + final LaravelAuthDataSource laravelAuthDataSource = LaravelAuthDataSourceImpl( + sharedPreferences: _sharedPreferHelper, + restClientBase: _restClientBase, + screenMessaging: ScreenMessaging.instance, + logger: _logger, + ); - final AuthorizationRepo authorizationRepo = AuthorizationRepoImpl( - laravelAuthDataSource, + final OtherAuthorizationDatasource otherAuthorizationDatasource = OtherAuthorizationImpl( + googleSignIn: _googleSignIn, + facebookAuth: _facebookAuth, + sharedPreferHelper: _sharedPreferHelper, + restClientBase: _restClientBase, ); - final OtherAuthorizationRepo otherAuthorizationRepo = - OtherAuthorizationRepoImpl(otherAuthorizationDatasource); + final AuthorizationRepo authorizationRepo = AuthorizationRepoImpl(laravelAuthDataSource); + + final OtherAuthorizationRepo otherAuthorizationRepo = OtherAuthorizationRepoImpl( + otherAuthorizationDatasource, + ); final initialState = AuthStates.initial(AuthStateModel.idle()); diff --git a/lib/src/features/initialization/logic/composition_root/factories/chat_screen_bloc_factory.dart b/lib/src/features/initialization/logic/composition_root/factories/chat_screen_bloc_factory.dart index 770622c..e5675b0 100644 --- a/lib/src/features/initialization/logic/composition_root/factories/chat_screen_bloc_factory.dart +++ b/lib/src/features/initialization/logic/composition_root/factories/chat_screen_bloc_factory.dart @@ -32,17 +32,17 @@ final class ChatScreenBlocFactory extends Factory { @override ChatScreenBloc create() { - final ChatScreenMessageDataSource messageDataSource = - ChatScreenMessageDataSourceImpl(restClientBase: _restClientBase); + final ChatScreenMessageDataSource messageDataSource = ChatScreenMessageDataSourceImpl( + restClientBase: _restClientBase, + ); - final ChatScreenChatDataSource chatScreenChatDataSource = - ChatScreenChatDataSourceImpl(restClientBase: _restClientBase); + final ChatScreenChatDataSource chatScreenChatDataSource = ChatScreenChatDataSourceImpl( + restClientBase: _restClientBase, + ); final ChatScreenRepo chatScreenRepo = ChatScreenRepoImpl(messageDataSource); - final ChatScreenChatRepo chatScreenChatRepo = ChatScreenChatRepoImpl( - chatScreenChatDataSource, - ); + final ChatScreenChatRepo chatScreenChatRepo = ChatScreenChatRepoImpl(chatScreenChatDataSource); const initialState = ChatScreenStates.initial(ChatScreenStateModel()); diff --git a/lib/src/features/initialization/logic/composition_root/factories/chats_bloc_factory.dart b/lib/src/features/initialization/logic/composition_root/factories/chats_bloc_factory.dart index 7cb4cf8..ba114c0 100644 --- a/lib/src/features/initialization/logic/composition_root/factories/chats_bloc_factory.dart +++ b/lib/src/features/initialization/logic/composition_root/factories/chats_bloc_factory.dart @@ -28,9 +28,7 @@ final class ChatsBlocFactory extends Factory { @override ChatsBloc create() { - final ChatsDataSource chatsDataSource = ChatsDataSourceImpl( - restClientBase: _restClientBase, - ); + final ChatsDataSource chatsDataSource = ChatsDataSourceImpl(restClientBase: _restClientBase); final ChatsRepo chatsRepo = ChatsRepoImpl(chatsDataSource); diff --git a/lib/src/features/initialization/logic/composition_root/factories/profile_bloc_factory.dart b/lib/src/features/initialization/logic/composition_root/factories/profile_bloc_factory.dart index 6dbf988..1dd9d04 100644 --- a/lib/src/features/initialization/logic/composition_root/factories/profile_bloc_factory.dart +++ b/lib/src/features/initialization/logic/composition_root/factories/profile_bloc_factory.dart @@ -8,11 +8,9 @@ import 'package:yahay/src/features/profile/data/profile_repository.dart'; final class ProfileBlocFactory extends Factory { // - ProfileBlocFactory({ - required final Logger logger, - required final RestClientBase restClientBase, - }) : _logger = logger, - _restClientBase = restClientBase; + ProfileBlocFactory({required final Logger logger, required final RestClientBase restClientBase}) + : _logger = logger, + _restClientBase = restClientBase; final Logger _logger; final RestClientBase _restClientBase; @@ -24,16 +22,11 @@ final class ProfileBlocFactory extends Factory { restClientBase: _restClientBase, ); - final IProfileRepository profileRepository = ProfileRepositoryImpl( - profileDatasource, - ); + final IProfileRepository profileRepository = ProfileRepositoryImpl(profileDatasource); // const initialState = ProfileStates.initial(ProfileStateModel()); - return ProfileBloc( - initialState: initialState, - iProfileRepository: profileRepository, - ); + return ProfileBloc(initialState: initialState, iProfileRepository: profileRepository); } } diff --git a/lib/src/features/initialization/logic/composition_root/factories/telegram_file_picker_bloc_factory.dart b/lib/src/features/initialization/logic/composition_root/factories/telegram_file_picker_bloc_factory.dart index 827d615..bdb302d 100644 --- a/lib/src/features/initialization/logic/composition_root/factories/telegram_file_picker_bloc_factory.dart +++ b/lib/src/features/initialization/logic/composition_root/factories/telegram_file_picker_bloc_factory.dart @@ -5,23 +5,18 @@ import 'package:yahay/src/features/telegram_file_picker_feature/bloc/telegram_fi import 'package:yahay/src/features/telegram_file_picker_feature/data/repo/telegram_file_picker_repo_impl.dart'; import 'package:yahay/src/features/telegram_file_picker_feature/domain/repo/telegram_file_picker_repo.dart'; -final class TelegramFilePickerBlocFactory - extends Factory { +final class TelegramFilePickerBlocFactory extends Factory { final CameraHelperService _cameraHelperService; - TelegramFilePickerBlocFactory({ - required CameraHelperService cameraHelperService, - }) : _cameraHelperService = cameraHelperService; + TelegramFilePickerBlocFactory({required CameraHelperService cameraHelperService}) + : _cameraHelperService = cameraHelperService; @override TelegramFilePickerBloc create() { // - final TelegramFilePickerRepo telegramFilePickerRepo = - TelegramFilePickerRepoImpl(); + final TelegramFilePickerRepo telegramFilePickerRepo = TelegramFilePickerRepoImpl(); // - final initialState = TelegramFilePickerStates.initial( - TelegramFilePickerStateModel.idle(), - ); + final initialState = TelegramFilePickerStates.initial(TelegramFilePickerStateModel.idle()); return TelegramFilePickerBloc( telegramFilePickerRepo: telegramFilePickerRepo, diff --git a/lib/src/features/initialization/logic/composition_root/factories/video_chat_bloc_factory.dart b/lib/src/features/initialization/logic/composition_root/factories/video_chat_bloc_factory.dart index 28780e3..43c4253 100644 --- a/lib/src/features/initialization/logic/composition_root/factories/video_chat_bloc_factory.dart +++ b/lib/src/features/initialization/logic/composition_root/factories/video_chat_bloc_factory.dart @@ -28,16 +28,15 @@ final class VideoChatBlocFactory extends Factory { VideoChatBloc create() { // - final VideoChatFeatureDataSource videoChatFeatureDataSource = - VideoChatFeatureDataSourceImpl(restClientBase: _restClientBase); + final VideoChatFeatureDataSource videoChatFeatureDataSource = VideoChatFeatureDataSourceImpl( + restClientBase: _restClientBase, + ); final VideoChatFeatureRepo videoChatFeatureRepo = VideoChatFeatureRepoImpl( videoChatFeatureDataSource, ); - final initialState = VideoChatFeatureStates.initial( - VideoChatStateModel.idle(), - ); + final initialState = VideoChatFeatureStates.initial(VideoChatStateModel.idle()); return VideoChatBloc( iVideoChatFeatureRepo: videoChatFeatureRepo, diff --git a/lib/src/features/initialization/models/dependency_container.dart b/lib/src/features/initialization/models/dependency_container.dart index e2d7171..ef85caa 100644 --- a/lib/src/features/initialization/models/dependency_container.dart +++ b/lib/src/features/initialization/models/dependency_container.dart @@ -57,11 +57,7 @@ class DependencyContainer { restClientBase: restClientBase, ).create(); - profileBloc = - ProfileBlocFactory( - logger: logger, - restClientBase: restClientBase, - ).create(); + profileBloc = ProfileBlocFactory(logger: logger, restClientBase: restClientBase).create(); } } diff --git a/lib/src/features/initialization/widgets/dependencies_scope.dart b/lib/src/features/initialization/widgets/dependencies_scope.dart index c15e83f..f77846d 100644 --- a/lib/src/features/initialization/widgets/dependencies_scope.dart +++ b/lib/src/features/initialization/widgets/dependencies_scope.dart @@ -3,11 +3,7 @@ import 'package:yahay/src/features/initialization/models/dependency_container.da class DependenciesScope extends InheritedWidget { // - const DependenciesScope({ - required this.dependencies, - required super.child, - super.key, - }); + const DependenciesScope({required this.dependencies, required super.child, super.key}); final DependencyContainer dependencies; @@ -18,10 +14,7 @@ class DependenciesScope extends InheritedWidget { assert(result != null, 'No DependenciesScope found in context'); return result!.dependencies; } else { - final result = - context - .getElementForInheritedWidgetOfExactType() - ?.widget; + final result = context.getElementForInheritedWidgetOfExactType()?.widget; final checkDep = result is DependenciesScope; assert(checkDep, 'No DependenciesScope found in context'); return (result as DependenciesScope).dependencies; diff --git a/lib/src/features/loading_page.dart b/lib/src/features/loading_page.dart index 3024570..815c89b 100644 --- a/lib/src/features/loading_page.dart +++ b/lib/src/features/loading_page.dart @@ -19,9 +19,7 @@ class _HomePageState extends State { void _onMessage(String message) { if (!mounted) return; - ScaffoldMessenger.of( - context, - ).showSnackBar(SnackBar(content: Text(message))); + ScaffoldMessenger.of(context).showSnackBar(SnackBar(content: Text(message))); } @override @@ -31,8 +29,7 @@ class _HomePageState extends State { _authBloc = depContainer.authBloc; _authBloc.add( AuthEvents.checkAuthEvent( - initDependenciesAfterAuthorization: - depContainer.initDependenciesAfterAuthorization, + initDependenciesAfterAuthorization: depContainer.initDependenciesAfterAuthorization, onMessage: _onMessage, ), ); @@ -48,9 +45,9 @@ class _HomePageState extends State { } else if (state is Auth$UnAuthorizedState) { AutoRouter.of(context).replaceAll([const LoginRoute()]); } else if (state is ErrorStateOnAuthStates) { - ScaffoldMessenger.of(context).showSnackBar( - const SnackBar(content: Text(Constants.somethingWentWrong)), - ); + ScaffoldMessenger.of( + context, + ).showSnackBar(const SnackBar(content: Text(Constants.somethingWentWrong))); } else { // TODO something on error state } diff --git a/lib/src/features/profile/bloc/profile_bloc.dart b/lib/src/features/profile/bloc/profile_bloc.dart index 65f58a5..7df0678 100644 --- a/lib/src/features/profile/bloc/profile_bloc.dart +++ b/lib/src/features/profile/bloc/profile_bloc.dart @@ -10,28 +10,23 @@ part 'profile_bloc.freezed.dart'; @immutable @freezed sealed class ProfileEvents with _$ProfileEvents { - const factory ProfileEvents.profileLogoutEvent( - final void Function() logoutEvent, - ) = _Profile$LogoutEvent; + const factory ProfileEvents.profileLogoutEvent(final void Function() logoutEvent) = + _Profile$LogoutEvent; } @immutable @freezed class ProfileStates with _$ProfileStates { - const factory ProfileStates.initial( - final ProfileStateModel profileStateModel, - ) = InitialProfileState; + const factory ProfileStates.initial(final ProfileStateModel profileStateModel) = + InitialProfileState; - const factory ProfileStates.inProgress( - final ProfileStateModel profileStateModel, - ) = Profile$InProgressState; + const factory ProfileStates.inProgress(final ProfileStateModel profileStateModel) = + Profile$InProgressState; - const factory ProfileStates.error(final ProfileStateModel profileStateModel) = - Profile$ErrorState; + const factory ProfileStates.error(final ProfileStateModel profileStateModel) = Profile$ErrorState; - const factory ProfileStates.successful( - final ProfileStateModel profileStateModel, - ) = Profile$SuccessfulState; + const factory ProfileStates.successful(final ProfileStateModel profileStateModel) = + Profile$SuccessfulState; } class ProfileBloc extends Bloc { @@ -45,14 +40,9 @@ class ProfileBloc extends Bloc { }) : _iProfileRepository = iProfileRepository, super(initialState) { on( - (event, emit) => event.map( - profileLogoutEvent: (event) => _profileLogoutEvent(event, emit), - ), + (event, emit) => event.map(profileLogoutEvent: (event) => _profileLogoutEvent(event, emit)), ); } - void _profileLogoutEvent( - _Profile$LogoutEvent event, - Emitter emit, - ) async {} + void _profileLogoutEvent(_Profile$LogoutEvent event, Emitter emit) async {} } diff --git a/lib/src/features/profile/view/profile_page.dart b/lib/src/features/profile/view/profile_page.dart index 85762a4..4feb7b2 100644 --- a/lib/src/features/profile/view/profile_page.dart +++ b/lib/src/features/profile/view/profile_page.dart @@ -29,25 +29,11 @@ class _ProfilePageState extends State { leadingWidth: 0.0, title: const Text("Profile"), actions: [ - IconButton( - onPressed: () {}, - icon: const Icon( - Icons.qr_code, - ), - ), - IconButton( - onPressed: () {}, - icon: const Icon( - Icons.more_vert, - ), - ), - ], - ), - body: const CustomScrollView( - slivers: [ - + IconButton(onPressed: () {}, icon: const Icon(Icons.qr_code)), + IconButton(onPressed: () {}, icon: const Icon(Icons.more_vert)), ], ), + body: const CustomScrollView(slivers: []), ); } } diff --git a/lib/src/features/profile/view/widgets/profile_header/profile_header_loading_widget.dart b/lib/src/features/profile/view/widgets/profile_header/profile_header_loading_widget.dart index 0b1b2df..e42e900 100644 --- a/lib/src/features/profile/view/widgets/profile_header/profile_header_loading_widget.dart +++ b/lib/src/features/profile/view/widgets/profile_header/profile_header_loading_widget.dart @@ -4,12 +4,10 @@ class ProfileHeaderLoadingWidget extends StatefulWidget { const ProfileHeaderLoadingWidget({super.key}); @override - State createState() => - _ProfileHeaderLoadingWidgetState(); + State createState() => _ProfileHeaderLoadingWidgetState(); } -class _ProfileHeaderLoadingWidgetState - extends State { +class _ProfileHeaderLoadingWidgetState extends State { @override Widget build(BuildContext context) { return const Placeholder(); diff --git a/lib/src/features/profile/view/widgets/profile_header/profile_header_widget.dart b/lib/src/features/profile/view/widgets/profile_header/profile_header_widget.dart index 960b04c..960e275 100644 --- a/lib/src/features/profile/view/widgets/profile_header/profile_header_widget.dart +++ b/lib/src/features/profile/view/widgets/profile_header/profile_header_widget.dart @@ -24,11 +24,7 @@ class _ProfileHeaderWidgetState extends State { const SizedBox(width: 10), const Expanded( child: Column( - children: [ - Text("NAME"), - Text("PHONE NUMBER"), - Text("USERNAME OR EMAIL"), - ], + children: [Text("NAME"), Text("PHONE NUMBER"), Text("USERNAME OR EMAIL")], ), ), ], diff --git a/lib/src/features/profile/view/widgets/profile_settings/profile_settings_loading_widget.dart b/lib/src/features/profile/view/widgets/profile_settings/profile_settings_loading_widget.dart index 4727db4..609c8a9 100644 --- a/lib/src/features/profile/view/widgets/profile_settings/profile_settings_loading_widget.dart +++ b/lib/src/features/profile/view/widgets/profile_settings/profile_settings_loading_widget.dart @@ -4,12 +4,10 @@ class ProfileSettingsLoadingWidget extends StatefulWidget { const ProfileSettingsLoadingWidget({super.key}); @override - State createState() => - _ProfileSettingsLoadingWidgetState(); + State createState() => _ProfileSettingsLoadingWidgetState(); } -class _ProfileSettingsLoadingWidgetState - extends State { +class _ProfileSettingsLoadingWidgetState extends State { @override Widget build(BuildContext context) { return const Placeholder(); diff --git a/lib/src/features/telegram_file_picker_feature/bloc/state_model/telegram_file_picker_state_model.dart b/lib/src/features/telegram_file_picker_feature/bloc/state_model/telegram_file_picker_state_model.dart index d8ce6d3..a6fce70 100644 --- a/lib/src/features/telegram_file_picker_feature/bloc/state_model/telegram_file_picker_state_model.dart +++ b/lib/src/features/telegram_file_picker_feature/bloc/state_model/telegram_file_picker_state_model.dart @@ -25,8 +25,7 @@ class TelegramFilePickerStateModel { const TelegramFilePickerStateModel({ this.getPathForGettingImagesFrom, - this.filePickerScreenSelectedScreen = - TelegramFileFolderEnum.recentDownloadsScreen, + this.filePickerScreenSelectedScreen = TelegramFileFolderEnum.recentDownloadsScreen, this.openBottomSectionButton = true, required this.galleryPathFiles, required this.galleryPathPagination, @@ -37,16 +36,15 @@ class TelegramFilePickerStateModel { required this.specificFolderFilesPagination, }); - factory TelegramFilePickerStateModel.idle() => - const TelegramFilePickerStateModel( - galleryPathFiles: [], - galleryPathPagination: [], - recentFiles: [], - recentFilesPagination: [], - pickedFiles: [], - specificFolderFilesAll: [], - specificFolderFilesPagination: [], - ); + factory TelegramFilePickerStateModel.idle() => const TelegramFilePickerStateModel( + galleryPathFiles: [], + galleryPathPagination: [], + recentFiles: [], + recentFilesPagination: [], + pickedFiles: [], + specificFolderFilesAll: [], + specificFolderFilesPagination: [], + ); @override bool operator ==(Object other) => @@ -55,8 +53,7 @@ class TelegramFilePickerStateModel { runtimeType == other.runtimeType && getPathForGettingImagesFrom == other.getPathForGettingImagesFrom && openBottomSectionButton == other.openBottomSectionButton && - filePickerScreenSelectedScreen == - other.filePickerScreenSelectedScreen && + filePickerScreenSelectedScreen == other.filePickerScreenSelectedScreen && galleryPathFiles == other.galleryPathFiles && galleryPathPagination == other.galleryPathPagination && recentFiles == other.recentFiles && @@ -107,21 +104,16 @@ class TelegramFilePickerStateModel { List? specificFolderFilesPagination, }) { return TelegramFilePickerStateModel( - getPathForGettingImagesFrom: - getPathForGettingImagesFrom ?? this.getPathForGettingImagesFrom, - openBottomSectionButton: - openBottomSectionButton ?? this.openBottomSectionButton, + getPathForGettingImagesFrom: getPathForGettingImagesFrom ?? this.getPathForGettingImagesFrom, + openBottomSectionButton: openBottomSectionButton ?? this.openBottomSectionButton, filePickerScreenSelectedScreen: filePickerScreenSelectedScreen ?? this.filePickerScreenSelectedScreen, galleryPathFiles: galleryPathFiles ?? this.galleryPathFiles, - galleryPathPagination: - galleryPathPagination ?? this.galleryPathPagination, + galleryPathPagination: galleryPathPagination ?? this.galleryPathPagination, recentFiles: recentFiles ?? this.recentFiles, - recentFilesPagination: - recentFilesPagination ?? this.recentFilesPagination, + recentFilesPagination: recentFilesPagination ?? this.recentFilesPagination, pickedFiles: pickedFiles ?? this.pickedFiles, - specificFolderFilesAll: - specificFolderFilesAll ?? this.specificFolderFilesAll, + specificFolderFilesAll: specificFolderFilesAll ?? this.specificFolderFilesAll, specificFolderFilesPagination: specificFolderFilesPagination ?? this.specificFolderFilesPagination, ); diff --git a/lib/src/features/telegram_file_picker_feature/bloc/telegram_file_picker_bloc.dart b/lib/src/features/telegram_file_picker_feature/bloc/telegram_file_picker_bloc.dart index 3012153..9240938 100644 --- a/lib/src/features/telegram_file_picker_feature/bloc/telegram_file_picker_bloc.dart +++ b/lib/src/features/telegram_file_picker_feature/bloc/telegram_file_picker_bloc.dart @@ -29,9 +29,8 @@ sealed class TelegramFilePickerEvents with _$TelegramFilePickerEvents { final TelegramFilePickerStateModel currentStateModel, ) = _JustEmitStateEvent; - const factory TelegramFilePickerEvents.initAllPicturesEvent( - final bool clearAll, - ) = _InitAllPicturesEvent; + const factory TelegramFilePickerEvents.initAllPicturesEvent(final bool clearAll) = + _InitAllPicturesEvent; const factory TelegramFilePickerEvents.changeStateToAllPicturesEvent() = _ChangeStateToAllPicturesEvent; @@ -40,15 +39,12 @@ sealed class TelegramFilePickerEvents with _$TelegramFilePickerEvents { required final bool initFilePickerState, }) = _InitAllFilesEvent; - const factory TelegramFilePickerEvents.changeStateToAllFilesState() = - _ChangeStateToAllFilesState; + const factory TelegramFilePickerEvents.changeStateToAllFilesState() = _ChangeStateToAllFilesState; - const factory TelegramFilePickerEvents.initAllAudioEvent() = - _InitAllAudioEvent; + const factory TelegramFilePickerEvents.initAllAudioEvent() = _InitAllAudioEvent; - const factory TelegramFilePickerEvents.openHideBottomTelegramButtonEvent( - final bool value, - ) = _OpenHideBottomTelegramButtonEvent; + const factory TelegramFilePickerEvents.openHideBottomTelegramButtonEvent(final bool value) = + _OpenHideBottomTelegramButtonEvent; const factory TelegramFilePickerEvents.closePopupEvent() = _ClosePopupEvent; @@ -70,8 +66,7 @@ sealed class TelegramFilePickerEvents with _$TelegramFilePickerEvents { const factory TelegramFilePickerEvents.clearSelectedGalleryFileEvent() = _ClearSelectedGalleryFileEvent; - const factory TelegramFilePickerEvents.recentFilesPaginationEvent() = - _RecentFilesPaginationEvent; + const factory TelegramFilePickerEvents.recentFilesPaginationEvent() = _RecentFilesPaginationEvent; const factory TelegramFilePickerEvents.browseInternalStorageAndSelectFilesEvent() = _BrowseInternalStorageAndSelectFilesEvent; @@ -117,8 +112,7 @@ sealed class TelegramFilePickerStates with _$TelegramFilePickerStates { ) = Picker$AudioFilesState; } -class TelegramFilePickerBloc - extends Bloc { +class TelegramFilePickerBloc extends Bloc { // StreamSubscription? _fileStreamData; @@ -143,45 +137,31 @@ class TelegramFilePickerBloc on( (event, emit) => event.map( justEmitStateEvent: - (event) => _emitter( - currentStateModel: event.currentStateModel, - emit: emit, - ), + (event) => _emitter(currentStateModel: event.currentStateModel, emit: emit), initAllPicturesEvent: (event) => _initAllPictureEvents(event, emit), - changeStateToAllPicturesEvent: - (event) => _changeStateToAllPicturesEvent(event, emit), + changeStateToAllPicturesEvent: (event) => _changeStateToAllPicturesEvent(event, emit), initAllFilesEvent: (event) => _initAllFilesEvent(event, emit), - changeStateToAllFilesState: - (event) => _changeStateToAllFilesState(event, emit), + changeStateToAllFilesState: (event) => _changeStateToAllFilesState(event, emit), initAllAudioEvent: (event) => _initAllAudioEvent(event, emit), openHideBottomTelegramButtonEvent: (event) => _openHideBottomTelegramButtonEvent(event, emit), closePopupEvent: (event) => _closePopupEvent(event, emit), fileStreamHandlerEvent: (event) => _fileStreamHandlerEvent(event, emit), - recentFileStreamHandlerEvent: - (event) => _recentFileStreamHandlerEvent(event, emit), - imagesAndVideoPaginationEvent: - (event) => _imagesAndVideoPaginationEvent(event, emit), + recentFileStreamHandlerEvent: (event) => _recentFileStreamHandlerEvent(event, emit), + imagesAndVideoPaginationEvent: (event) => _imagesAndVideoPaginationEvent(event, emit), selectGalleryFileEvent: (event) => _selectGalleryFileEvent(event, emit), - clearSelectedGalleryFileEvent: - (event) => _clearSelectedGalleryFileEvent(event, emit), - recentFilesPaginationEvent: - (event) => _recentFilesPaginationEvent(event, emit), + clearSelectedGalleryFileEvent: (event) => _clearSelectedGalleryFileEvent(event, emit), + recentFilesPaginationEvent: (event) => _recentFilesPaginationEvent(event, emit), browseInternalStorageAndSelectFilesEvent: (event) => _browseInternalStorageAndSelectFilesEvent(event, emit), selectScreenForFilesPickerScreenEvent: (event) => _selectScreenForFilesPickerScreenEvent(event, emit), setSpecificFolderPathInOrderToGetDataFromThereEvent: - (event) => _setSpecificFolderPathInOrderToGetDataFromThereEvent( - event, - emit, - ), - getSpecificFolderDataEvent: - (event) => _getSpecificFolderDataEvent(event, emit), + (event) => _setSpecificFolderPathInOrderToGetDataFromThereEvent(event, emit), + getSpecificFolderDataEvent: (event) => _getSpecificFolderDataEvent(event, emit), specificFolderDataStreamHandlerEvent: (event) => _specificFolderDataStreamHandlerEvent(event, emit), - paginateSpecificFolderDataEvent: - (event) => _paginateSpecificFolderDataEvent(event, emit), + paginateSpecificFolderDataEvent: (event) => _paginateSpecificFolderDataEvent(event, emit), ), ); } @@ -215,21 +195,15 @@ class TelegramFilePickerBloc ); } - _fileStreamData = _telegramFilePickerRepo - .getRecentImagesAndVideos() - .listen((value) { - debugPrint("any other image coming here brother: $value"); - add(TelegramFilePickerEvents.fileStreamHandlerEvent(value)); - })..onDone(() { + _fileStreamData = _telegramFilePickerRepo.getRecentImagesAndVideos().listen((value) { + debugPrint("any other image coming here brother: $value"); + add(TelegramFilePickerEvents.fileStreamHandlerEvent(value)); + })..onDone(() { // debugPrint("im done!"); }); - add( - const TelegramFilePickerEvents.initAllFilesEvent( - initFilePickerState: false, - ), - ); + add(const TelegramFilePickerEvents.initAllFilesEvent(initFilePickerState: false)); emit(TelegramFilePickerStates.galleryFilePickerState(currentStateModel)); } catch (error, stackTrace) { @@ -242,17 +216,10 @@ class TelegramFilePickerBloc _ChangeStateToAllPicturesEvent event, Emitter emit, ) async { - emit( - TelegramFilePickerStates.galleryFilePickerState( - state.telegramFilePickerStateModel, - ), - ); + emit(TelegramFilePickerStates.galleryFilePickerState(state.telegramFilePickerStateModel)); } - void _initAllFilesEvent( - _InitAllFilesEvent event, - Emitter emit, - ) async { + void _initAllFilesEvent(_InitAllFilesEvent event, Emitter emit) async { final currentStateModel = state.telegramFilePickerStateModel.copyWith( recentFiles: [], recentFilesPagination: [], @@ -275,17 +242,10 @@ class TelegramFilePickerBloc _ChangeStateToAllFilesState event, Emitter emit, ) async { - emit( - TelegramFilePickerStates.filesPickerState( - state.telegramFilePickerStateModel, - ), - ); + emit(TelegramFilePickerStates.filesPickerState(state.telegramFilePickerStateModel)); } - void _initAllAudioEvent( - _InitAllAudioEvent event, - Emitter emit, - ) async {} + void _initAllAudioEvent(_InitAllAudioEvent event, Emitter emit) async {} void _openHideBottomTelegramButtonEvent( _OpenHideBottomTelegramButtonEvent event, @@ -302,42 +262,20 @@ class TelegramFilePickerBloc }); } - void _closePopupEvent( - _ClosePopupEvent event, - Emitter emit, - ) async { + void _closePopupEvent(_ClosePopupEvent event, Emitter emit) async { // await DefaultCacheManager().emptyCache(); - if (state - .telegramFilePickerStateModel - .galleryPathFiles - .firstOrNull - ?.cameraController != - null) { - state - .telegramFilePickerStateModel - .galleryPathFiles - .firstOrNull - ?.cameraController - ?.dispose(); + if (state.telegramFilePickerStateModel.galleryPathFiles.firstOrNull?.cameraController != null) { + state.telegramFilePickerStateModel.galleryPathFiles.firstOrNull?.cameraController?.dispose(); } for (final each in state.telegramFilePickerStateModel.galleryPathFiles) { each.videoPlayerController?.dispose(); } - if (state - .telegramFilePickerStateModel - .galleryPathPagination - .firstOrNull - ?.cameraController != + if (state.telegramFilePickerStateModel.galleryPathPagination.firstOrNull?.cameraController != null) { - state - .telegramFilePickerStateModel - .galleryPathPagination - .firstOrNull - ?.cameraController + state.telegramFilePickerStateModel.galleryPathPagination.firstOrNull?.cameraController ?.dispose(); } - for (final each - in state.telegramFilePickerStateModel.galleryPathPagination) { + for (final each in state.telegramFilePickerStateModel.galleryPathPagination) { each.videoPlayerController?.dispose(); } // state.telegramFilePickerStateModel.clearAllGalleryPath(); @@ -365,9 +303,7 @@ class TelegramFilePickerBloc : null, videoPreview: ReusableGlobalFunctions.instance.isVideoFile(event.file!.file.path) - ? await VideoThumbnail.thumbnailData( - video: event.file!.file.path, - ) + ? await VideoThumbnail.thumbnailData(video: event.file!.file.path) : null, ); @@ -382,9 +318,7 @@ class TelegramFilePickerBloc // } // } - final galleryPathFiles = List.of( - state.telegramFilePickerStateModel.galleryPathFiles, - ); + final galleryPathFiles = List.of(state.telegramFilePickerStateModel.galleryPathFiles); galleryPathFiles.add(model); @@ -418,9 +352,7 @@ class TelegramFilePickerBloc fileName: basename(event.file!.file.path), videoPreview: ReusableGlobalFunctions.instance.isVideoFile(event.file!.file.path) - ? await VideoThumbnail.thumbnailData( - video: event.file!.file.path, - ) + ? await VideoThumbnail.thumbnailData(video: event.file!.file.path) : null, ); @@ -516,13 +448,9 @@ class TelegramFilePickerBloc if (files.isEmpty) return; var currentStateModel = state.telegramFilePickerStateModel; // convert this files into - final convertedData = - files.map((e) => TelegramFileImageModel(file: File(e.path))).toList(); + final convertedData = files.map((e) => TelegramFileImageModel(file: File(e.path))).toList(); for (final each in convertedData) { - currentStateModel = _removeOrAddEntity( - currentStateModel: currentStateModel, - value: each, - ); + currentStateModel = _removeOrAddEntity(currentStateModel: currentStateModel, value: each); } _emitter(currentStateModel: currentStateModel, emit: emit); @@ -548,11 +476,7 @@ class TelegramFilePickerBloc getPathForGettingImagesFrom: event.path, ); - add( - const TelegramFilePickerEvents.getSpecificFolderDataEvent( - getGalleryData: false, - ), - ); + add(const TelegramFilePickerEvents.getSpecificFolderDataEvent(getGalleryData: false)); _emitter(currentStateModel: currentStateModel, emit: emit); } @@ -561,8 +485,7 @@ class TelegramFilePickerBloc _GetSpecificFolderDataEvent event, Emitter emit, ) async { - if (state.telegramFilePickerStateModel.getPathForGettingImagesFrom == - null && + if (state.telegramFilePickerStateModel.getPathForGettingImagesFrom == null && !event.getGalleryData) { return; } @@ -574,25 +497,15 @@ class TelegramFilePickerBloc _emitter(currentStateModel: currentStateModel, emit: emit); if (event.getGalleryData) { - _specificFolderData = _telegramFilePickerRepo - .getRecentImagesAndVideos() - .listen((data) { - debugPrint("path of data: ${data?.file.path}"); - add( - TelegramFilePickerEvents.specificFolderDataStreamHandlerEvent( - data, - ), - ); - }); + _specificFolderData = _telegramFilePickerRepo.getRecentImagesAndVideos().listen((data) { + debugPrint("path of data: ${data?.file.path}"); + add(TelegramFilePickerEvents.specificFolderDataStreamHandlerEvent(data)); + }); } else { _specificFolderData = _telegramFilePickerRepo .getSpecificFolderData(currentStateModel.getPathForGettingImagesFrom!) .listen((data) { - add( - TelegramFilePickerEvents.specificFolderDataStreamHandlerEvent( - data, - ), - ); + add(TelegramFilePickerEvents.specificFolderDataStreamHandlerEvent(data)); }); } } @@ -609,9 +522,7 @@ class TelegramFilePickerBloc final value = TelegramFileImageEntity( file: event.file!.file, videoPlayerController: - event.file!.isVideo - ? VideoPlayerController.file(event.file!.file) - : null, + event.file!.isVideo ? VideoPlayerController.file(event.file!.file) : null, videoPreview: event.file!.isVideo ? await VideoThumbnail.thumbnailData(video: event.file!.file.path) @@ -619,13 +530,9 @@ class TelegramFilePickerBloc fileName: event.file!.fileName, ); - if (currentStateModel.specificFolderFilesPagination.length < - Constants.perPage) { + if (currentStateModel.specificFolderFilesPagination.length < Constants.perPage) { currentStateModel = currentStateModel.copyWith( - specificFolderFilesPagination: [ - ...currentStateModel.specificFolderFilesPagination, - value, - ], + specificFolderFilesPagination: [...currentStateModel.specificFolderFilesPagination, value], ); } @@ -638,8 +545,7 @@ class TelegramFilePickerBloc ) async { final data = ListPaginationChecker.instance.paginateList( wholeList: state.telegramFilePickerStateModel.specificFolderFilesAll, - currentList: - state.telegramFilePickerStateModel.specificFolderFilesPagination, + currentList: state.telegramFilePickerStateModel.specificFolderFilesPagination, ); final currentStateModel = state.telegramFilePickerStateModel.copyWith( @@ -661,9 +567,7 @@ class TelegramFilePickerBloc emit(TelegramFilePickerStates.initial(currentStateModel)); break; case Picker$GalleryFileState(): - emit( - TelegramFilePickerStates.galleryFilePickerState(currentStateModel), - ); + emit(TelegramFilePickerStates.galleryFilePickerState(currentStateModel)); break; case Picker$FilesState(): emit(TelegramFilePickerStates.filesPickerState(currentStateModel)); @@ -674,16 +578,11 @@ class TelegramFilePickerBloc } } - TelegramFilePickerStateModel addOnStreamOfValuesInPaginationList( - TelegramFileImageEntity value, - ) { - if (state.telegramFilePickerStateModel.galleryPathPagination.length >= - Constants.perPage) { + TelegramFilePickerStateModel addOnStreamOfValuesInPaginationList(TelegramFileImageEntity value) { + if (state.telegramFilePickerStateModel.galleryPathPagination.length >= Constants.perPage) { return state.telegramFilePickerStateModel; } - final currentGalleryPath = List.of( - state.telegramFilePickerStateModel.galleryPathPagination, - ); + final currentGalleryPath = List.of(state.telegramFilePickerStateModel.galleryPathPagination); currentGalleryPath.add(value); final currentStateModel = state.telegramFilePickerStateModel.copyWith( galleryPathPagination: currentGalleryPath, @@ -700,10 +599,7 @@ class TelegramFilePickerBloc ); if (currentStateModel.recentFilesPagination.length < Constants.perPage) { currentStateModel = currentStateModel.copyWith( - recentFilesPagination: [ - ...currentStateModel.recentFilesPagination, - value, - ], + recentFilesPagination: [...currentStateModel.recentFilesPagination, value], ); } return currentStateModel; @@ -715,9 +611,7 @@ class TelegramFilePickerBloc }) { if (value == null) return currentStateModel; final pickedFiles = List.of(currentStateModel.pickedFiles); - final findEntity = pickedFiles.firstWhereOrNull( - (el) => el.uuid == value.uuid, - ); + final findEntity = pickedFiles.firstWhereOrNull((el) => el.uuid == value.uuid); if (findEntity != null) { pickedFiles.removeWhere((el) => el.uuid == value.uuid); } else { diff --git a/lib/src/features/telegram_file_picker_feature/data/models/data_models/telegram_file_picker_bottom_button.dart b/lib/src/features/telegram_file_picker_feature/data/models/data_models/telegram_file_picker_bottom_button.dart index 9b82712..c97125a 100644 --- a/lib/src/features/telegram_file_picker_feature/data/models/data_models/telegram_file_picker_bottom_button.dart +++ b/lib/src/features/telegram_file_picker_feature/data/models/data_models/telegram_file_picker_bottom_button.dart @@ -18,9 +18,7 @@ class TelegramFilePickerBottomButton { children: [ GestureDetector( onTap: () { - telegramBloc.add( - const TelegramFilePickerEvents.changeStateToAllPicturesEvent(), - ); + telegramBloc.add(const TelegramFilePickerEvents.changeStateToAllPicturesEvent()); // telegramBloc.events.add(const InitAllFilesEvent(initFilePickerState: false)); @@ -33,9 +31,7 @@ class TelegramFilePickerBottomButton { borderRadius: BorderRadius.circular(50), color: Colors.blue, ), - child: const Center( - child: Icon(Icons.image, color: Colors.white), - ), + child: const Center(child: Icon(Icons.image, color: Colors.white)), ), ), const SizedBox(height: 10), @@ -49,9 +45,7 @@ class TelegramFilePickerBottomButton { children: [ GestureDetector( onTap: () { - telegramBloc.add( - const TelegramFilePickerEvents.changeStateToAllFilesState(), - ); + telegramBloc.add(const TelegramFilePickerEvents.changeStateToAllFilesState()); draggableSheetAnimate(); }, child: Container( @@ -61,9 +55,7 @@ class TelegramFilePickerBottomButton { borderRadius: BorderRadius.circular(50), color: Colors.blue, ), - child: const Center( - child: Icon(Icons.file_open_outlined, color: Colors.white), - ), + child: const Center(child: Icon(Icons.file_open_outlined, color: Colors.white)), ), ), const SizedBox(height: 10), @@ -86,9 +78,7 @@ class TelegramFilePickerBottomButton { borderRadius: BorderRadius.circular(50), color: Colors.blue, ), - child: const Center( - child: Icon(Icons.file_open_outlined, color: Colors.white), - ), + child: const Center(child: Icon(Icons.file_open_outlined, color: Colors.white)), ), ), const SizedBox(height: 10), diff --git a/lib/src/features/telegram_file_picker_feature/data/models/data_models/telegram_storage_file_picker_data_model.dart b/lib/src/features/telegram_file_picker_feature/data/models/data_models/telegram_storage_file_picker_data_model.dart index 2f42d99..bde9d02 100644 --- a/lib/src/features/telegram_file_picker_feature/data/models/data_models/telegram_storage_file_picker_data_model.dart +++ b/lib/src/features/telegram_file_picker_feature/data/models/data_models/telegram_storage_file_picker_data_model.dart @@ -58,9 +58,7 @@ class TelegramStorageFilePickerDataModel { Future.delayed(const Duration(milliseconds: 300), () { telegramFilerPickerBloc.add( - const TelegramFilePickerEvents.getSpecificFolderDataEvent( - getGalleryData: true, - ), + const TelegramFilePickerEvents.getSpecificFolderDataEvent(getGalleryData: true), ); }); }, diff --git a/lib/src/features/telegram_file_picker_feature/data/repo/telegram_file_picker_repo_impl.dart b/lib/src/features/telegram_file_picker_feature/data/repo/telegram_file_picker_repo_impl.dart index b15a3fb..db03c1f 100644 --- a/lib/src/features/telegram_file_picker_feature/data/repo/telegram_file_picker_repo_impl.dart +++ b/lib/src/features/telegram_file_picker_feature/data/repo/telegram_file_picker_repo_impl.dart @@ -8,13 +8,11 @@ class TelegramFilePickerRepoImpl with RecentGalleyFileMixin, DownloadsPathFiles, AppStorageFileMixin implements TelegramFilePickerRepo { @override - Stream getRecentImagesAndVideos({ - RecentFilesOptions? options, - }) => getAllImagesAndVideos(options: options); + Stream getRecentImagesAndVideos({RecentFilesOptions? options}) => + getAllImagesAndVideos(options: options); @override - Stream getRecentFiles() => - downloadsPathFilesData(); + Stream getRecentFiles() => downloadsPathFilesData(); @override Stream getSpecificFolderData(String path) => diff --git a/lib/src/features/telegram_file_picker_feature/domain/repo/telegram_file_picker_repo.dart b/lib/src/features/telegram_file_picker_feature/domain/repo/telegram_file_picker_repo.dart index d240a6f..012697b 100644 --- a/lib/src/features/telegram_file_picker_feature/domain/repo/telegram_file_picker_repo.dart +++ b/lib/src/features/telegram_file_picker_feature/domain/repo/telegram_file_picker_repo.dart @@ -5,9 +5,7 @@ import 'package:yahay/src/features/telegram_file_picker_feature/mixins/recent_fi // classes only can "implement" abstract interface class TelegramFilePickerRepo { // for getting recent files -> images and videos - Stream getRecentImagesAndVideos({ - RecentFilesOptions? options, - }); + Stream getRecentImagesAndVideos({RecentFilesOptions? options}); // for getting all download's path files here Stream getRecentFiles(); diff --git a/lib/src/features/telegram_file_picker_feature/mixins/app_storage_file_mixin/app_storage_file_mixin.dart b/lib/src/features/telegram_file_picker_feature/mixins/app_storage_file_mixin/app_storage_file_mixin.dart index 7bfa335..8036bcb 100644 --- a/lib/src/features/telegram_file_picker_feature/mixins/app_storage_file_mixin/app_storage_file_mixin.dart +++ b/lib/src/features/telegram_file_picker_feature/mixins/app_storage_file_mixin/app_storage_file_mixin.dart @@ -10,9 +10,7 @@ import 'package:path/path.dart' as p; mixin class AppStorageFileMixin { // - Stream getSpecificFolderDataStream( - String path, - ) async* { + Stream getSpecificFolderDataStream(String path) async* { // final ReceivePort mainPort = ReceivePort(); @@ -68,10 +66,7 @@ mixin class AppStorageFileMixin { model = (await ImageCompressor.compressedImageFile( file: model.file, directoryPath: tempPath.path, - ))?.clone( - fileExtension: model.fileExtension, - fileName: model.fileName, - ); + ))?.clone(fileExtension: model.fileExtension, fileName: model.fileName); } else if (reusables.isVideoFile(each.path)) { model.isVideo = true; } diff --git a/lib/src/features/telegram_file_picker_feature/mixins/folder_creator/folder_creator.dart b/lib/src/features/telegram_file_picker_feature/mixins/folder_creator/folder_creator.dart index d96eb5c..9a0c5a4 100644 --- a/lib/src/features/telegram_file_picker_feature/mixins/folder_creator/folder_creator.dart +++ b/lib/src/features/telegram_file_picker_feature/mixins/folder_creator/folder_creator.dart @@ -43,9 +43,7 @@ mixin class FolderCreator { : await getExternalStorageDirectory(); Future createFolders(SharedPreferHelper sharedPreferHelper) async { - final isFoldersAlreadyCreated = sharedPreferHelper.getBoolByKey( - key: "is_folders_created", - ); + final isFoldersAlreadyCreated = sharedPreferHelper.getBoolByKey(key: "is_folders_created"); final dir = await getApplicationDir(); @@ -56,9 +54,6 @@ mixin class FolderCreator { folderCreator(path: path); } - await sharedPreferHelper.setBoolByKey( - key: "is_folders_created", - value: true, - ); + await sharedPreferHelper.setBoolByKey(key: "is_folders_created", value: true); } } diff --git a/lib/src/features/telegram_file_picker_feature/mixins/recent_file_mixin/downloads_path_files.dart b/lib/src/features/telegram_file_picker_feature/mixins/recent_file_mixin/downloads_path_files.dart index fff01c7..2627f28 100644 --- a/lib/src/features/telegram_file_picker_feature/mixins/recent_file_mixin/downloads_path_files.dart +++ b/lib/src/features/telegram_file_picker_feature/mixins/recent_file_mixin/downloads_path_files.dart @@ -37,11 +37,7 @@ mixin class DownloadsPathFiles { final rootIsolateToken = RootIsolateToken.instance!; - final sendingList = [ - sendingPort.sendPort, - downloadsDirectory.path, - rootIsolateToken, - ]; + final sendingList = [sendingPort.sendPort, downloadsDirectory.path, rootIsolateToken]; debugPrint("sending list length is: $sendingList"); @@ -74,10 +70,7 @@ mixin class DownloadsPathFiles { final reusables = ReusableGlobalFunctions.instance; final directoryPath = await getTemporaryDirectory(); - await for (final entity in directory.list( - recursive: false, - followLinks: false, - )) { + await for (final entity in directory.list(recursive: false, followLinks: false)) { if (FileSystemEntity.isDirectorySync(entity.path)) { await _fileFinder([receivingPort, entity.path, rootIsolateToken]); } diff --git a/lib/src/features/telegram_file_picker_feature/mixins/recent_file_mixin/recent_galley_file_mixin.dart b/lib/src/features/telegram_file_picker_feature/mixins/recent_file_mixin/recent_galley_file_mixin.dart index 3e2bd82..87ccf68 100644 --- a/lib/src/features/telegram_file_picker_feature/mixins/recent_file_mixin/recent_galley_file_mixin.dart +++ b/lib/src/features/telegram_file_picker_feature/mixins/recent_file_mixin/recent_galley_file_mixin.dart @@ -17,9 +17,7 @@ mixin class RecentGalleyFileMixin { // final _reusableFunctions = snoopy(); - Stream getAllImagesAndVideos({ - RecentFilesOptions? options, - }) async* { + Stream getAllImagesAndVideos({RecentFilesOptions? options}) async* { try { final PermissionsService permissionsService = PermissionsService(); @@ -178,10 +176,7 @@ class _GetRangedAssetFiles implements _RecentFilesHelper { @override Future> getAssets() async { - final images = await PhotoManager.getAssetListRange( - start: start ?? 0, - end: end ?? 100, - ); + final images = await PhotoManager.getAssetListRange(start: start ?? 0, end: end ?? 100); final List list = []; diff --git a/lib/src/features/telegram_file_picker_feature/view/bottom_picker_button/telegram_bottom_picker_button.dart b/lib/src/features/telegram_file_picker_feature/view/bottom_picker_button/telegram_bottom_picker_button.dart index ccfd2d1..f6335ad 100644 --- a/lib/src/features/telegram_file_picker_feature/view/bottom_picker_button/telegram_bottom_picker_button.dart +++ b/lib/src/features/telegram_file_picker_feature/view/bottom_picker_button/telegram_bottom_picker_button.dart @@ -6,18 +6,13 @@ import 'package:yahay/src/features/telegram_file_picker_feature/data/models/data class TelegramBottomPickerButton extends StatefulWidget { final DraggableScrollableController draggableScrollableController; - const TelegramBottomPickerButton({ - super.key, - required this.draggableScrollableController, - }); + const TelegramBottomPickerButton({super.key, required this.draggableScrollableController}); @override - State createState() => - _TelegramBottomPickerButtonState(); + State createState() => _TelegramBottomPickerButtonState(); } -class _TelegramBottomPickerButtonState - extends State { +class _TelegramBottomPickerButtonState extends State { late final List _buttons; @override diff --git a/lib/src/features/telegram_file_picker_feature/view/bottom_picker_button/telegram_bottom_sender_button.dart b/lib/src/features/telegram_file_picker_feature/view/bottom_picker_button/telegram_bottom_sender_button.dart index b2ba4eb..6a56a26 100644 --- a/lib/src/features/telegram_file_picker_feature/view/bottom_picker_button/telegram_bottom_sender_button.dart +++ b/lib/src/features/telegram_file_picker_feature/view/bottom_picker_button/telegram_bottom_sender_button.dart @@ -4,12 +4,10 @@ class TelegramBottomSenderButton extends StatefulWidget { const TelegramBottomSenderButton({super.key}); @override - State createState() => - _TelegramBottomSenderButtonState(); + State createState() => _TelegramBottomSenderButtonState(); } -class _TelegramBottomSenderButtonState - extends State { +class _TelegramBottomSenderButtonState extends State { @override Widget build(BuildContext context) { return Container( @@ -20,18 +18,12 @@ class _TelegramBottomSenderButtonState children: [ Row( children: [ - IconButton( - onPressed: () {}, - icon: const Icon(Icons.emoji_emotions_outlined), - ), + IconButton(onPressed: () {}, icon: const Icon(Icons.emoji_emotions_outlined)), const SizedBox(width: 10), Expanded( child: DecoratedBox( decoration: BoxDecoration( - color: - Theme.of( - context, - ).cardColor, //Theme.of(context).cardColor + color: Theme.of(context).cardColor, //Theme.of(context).cardColor ), child: TextField( decoration: InputDecoration( diff --git a/lib/src/features/telegram_file_picker_feature/view/reusable_widgets/telegram_storage_file_widget.dart b/lib/src/features/telegram_file_picker_feature/view/reusable_widgets/telegram_storage_file_widget.dart index 49f92ac..18a03f7 100644 --- a/lib/src/features/telegram_file_picker_feature/view/reusable_widgets/telegram_storage_file_widget.dart +++ b/lib/src/features/telegram_file_picker_feature/view/reusable_widgets/telegram_storage_file_widget.dart @@ -13,8 +13,7 @@ class TelegramStorageFileWidget extends StatefulWidget { const TelegramStorageFileWidget({super.key, required this.list}); @override - State createState() => - _TelegramStorageFileWidgetState(); + State createState() => _TelegramStorageFileWidgetState(); } class _TelegramStorageFileWidgetState extends State { @@ -46,22 +45,15 @@ class _TelegramStorageFileWidgetState extends State { Stack( clipBehavior: Clip.none, children: [ - if (item.videoPlayerController != null && - item.videoPreview != null) + if (item.videoPlayerController != null && item.videoPreview != null) _VideoItem(item: item) - else if (ReusableGlobalFunctions.instance.isImageFile( - item.file?.path ?? '', - )) + else if (ReusableGlobalFunctions.instance.isImageFile(item.file?.path ?? '')) ClipRRect( borderRadius: BorderRadius.circular(10), child: SizedBox( width: 50, height: 50, - child: Image.file( - item.file!, - fit: BoxFit.cover, - gaplessPlayback: true, - ), + child: Image.file(item.file!, fit: BoxFit.cover, gaplessPlayback: true), ), ) else if (item.file != null) @@ -72,9 +64,7 @@ class _TelegramStorageFileWidgetState extends State { color: Colors.amber, borderRadius: BorderRadius.circular(10), ), - child: Center( - child: Text(path.extension(item.file?.path ?? '')), - ), + child: Center(child: Text(path.extension(item.file?.path ?? ''))), ) else Container( @@ -85,27 +75,21 @@ class _TelegramStorageFileWidgetState extends State { borderRadius: BorderRadius.circular(10), ), ), - BlocBuilder< - TelegramFilePickerBloc, - TelegramFilePickerStates - >( + BlocBuilder( builder: (context, state) { - final telegramFilePickerStateModel = - state.telegramFilePickerStateModel; + final telegramFilePickerStateModel = state.telegramFilePickerStateModel; return Positioned( bottom: -10, right: 0, child: AnimatedOpacity( duration: const Duration(milliseconds: 150), opacity: - telegramFilePickerStateModel - .isFileInsidePickedFiles(item) + telegramFilePickerStateModel.isFileInsidePickedFiles(item) ? 1 : 0, child: AnimatedScale( scale: - telegramFilePickerStateModel - .isFileInsidePickedFiles(item) + telegramFilePickerStateModel.isFileInsidePickedFiles(item) ? 1 : 0, duration: const Duration(milliseconds: 150), @@ -115,11 +99,7 @@ class _TelegramStorageFileWidgetState extends State { borderRadius: BorderRadius.circular(30), ), child: const Center( - child: Icon( - Icons.check, - size: 18, - color: Colors.white, - ), + child: Icon(Icons.check, size: 18, color: Colors.white), ), ), ), @@ -142,14 +122,10 @@ class _TelegramStorageFileWidgetState extends State { children: [ Text( item.fileName ?? '-', - style: GoogleFonts.aBeeZee( - fontSize: 14, - fontWeight: FontWeight.w400, - ), + style: GoogleFonts.aBeeZee(fontSize: 14, fontWeight: FontWeight.w400), ), Text( - TelegramFileImageModel.fromEntity(item)?.fileSize() ?? - '', + TelegramFileImageModel.fromEntity(item)?.fileSize() ?? '', style: GoogleFonts.aBeeZee( fontSize: 14, fontWeight: FontWeight.w400, @@ -182,9 +158,7 @@ class _VideoItem extends StatelessWidget { decoration: BoxDecoration(borderRadius: BorderRadius.circular(10)), child: Stack( children: [ - Positioned.fill( - child: Image.memory(fit: BoxFit.cover, item.videoPreview!), - ), + Positioned.fill(child: Image.memory(fit: BoxFit.cover, item.videoPreview!)), Positioned.fill( child: DecoratedBox( decoration: BoxDecoration( diff --git a/lib/src/features/telegram_file_picker_feature/view/screens/telegram_app_folder_screen/telegram_browse_app_folder_screen.dart b/lib/src/features/telegram_file_picker_feature/view/screens/telegram_app_folder_screen/telegram_browse_app_folder_screen.dart index 590439c..d5c6045 100644 --- a/lib/src/features/telegram_file_picker_feature/view/screens/telegram_app_folder_screen/telegram_browse_app_folder_screen.dart +++ b/lib/src/features/telegram_file_picker_feature/view/screens/telegram_app_folder_screen/telegram_browse_app_folder_screen.dart @@ -9,12 +9,10 @@ class TelegramBrowseAppFolderScreen extends StatefulWidget { const TelegramBrowseAppFolderScreen({super.key}); @override - State createState() => - _TelegramBrowseAppFolderScreenState(); + State createState() => _TelegramBrowseAppFolderScreenState(); } -class _TelegramBrowseAppFolderScreenState - extends State +class _TelegramBrowseAppFolderScreenState extends State with FolderCreator { @override Widget build(BuildContext context) { @@ -55,15 +53,12 @@ class _TelegramBrowseAppFolderScreenState ), ); - final dir = - "${(await getApplicationDir())?.path}/${foldersName[index]}"; + final dir = "${(await getApplicationDir())?.path}/${foldersName[index]}"; debugPrint("clicking path: $dir"); // init here for folder data context.read().add( - TelegramFilePickerEvents.setSpecificFolderPathInOrderToGetDataFromThereEvent( - dir, - ), + TelegramFilePickerEvents.setSpecificFolderPathInOrderToGetDataFromThereEvent(dir), ); }, title: foldersName[index], diff --git a/lib/src/features/telegram_file_picker_feature/view/screens/telegram_app_folder_screen/telegram_browse_folder_data_screen.dart b/lib/src/features/telegram_file_picker_feature/view/screens/telegram_app_folder_screen/telegram_browse_folder_data_screen.dart index a9a3059..ef7de85 100644 --- a/lib/src/features/telegram_file_picker_feature/view/screens/telegram_app_folder_screen/telegram_browse_folder_data_screen.dart +++ b/lib/src/features/telegram_file_picker_feature/view/screens/telegram_app_folder_screen/telegram_browse_folder_data_screen.dart @@ -10,12 +10,10 @@ class TelegramBrowseFolderDataScreen extends StatefulWidget { const TelegramBrowseFolderDataScreen({super.key, required this.onBackFolder}); @override - State createState() => - _TelegramBrowseFolderDataScreenState(); + State createState() => _TelegramBrowseFolderDataScreenState(); } -class _TelegramBrowseFolderDataScreenState - extends State { +class _TelegramBrowseFolderDataScreenState extends State { @override Widget build(BuildContext context) { return ListView( @@ -29,10 +27,7 @@ class _TelegramBrowseFolderDataScreenState BlocBuilder( builder: (context, state) { return TelegramStorageFileWidget( - list: - state - .telegramFilePickerStateModel - .specificFolderFilesPagination, + list: state.telegramFilePickerStateModel.specificFolderFilesPagination, ); }, ), diff --git a/lib/src/features/telegram_file_picker_feature/view/screens/telegram_app_folder_screen/telegram_browse_folder_widget.dart b/lib/src/features/telegram_file_picker_feature/view/screens/telegram_app_folder_screen/telegram_browse_folder_widget.dart index dbcb9a9..5eb6b1c 100644 --- a/lib/src/features/telegram_file_picker_feature/view/screens/telegram_app_folder_screen/telegram_browse_folder_widget.dart +++ b/lib/src/features/telegram_file_picker_feature/view/screens/telegram_app_folder_screen/telegram_browse_folder_widget.dart @@ -4,11 +4,7 @@ class TelegramFolderWidget extends StatelessWidget { final VoidCallback onTap; final String title; - const TelegramFolderWidget({ - super.key, - required this.onTap, - required this.title, - }); + const TelegramFolderWidget({super.key, required this.onTap, required this.title}); @override Widget build(BuildContext context) { @@ -26,9 +22,7 @@ class TelegramFolderWidget extends StatelessWidget { color: Colors.blueAccent, borderRadius: BorderRadius.circular(50), ), - child: const Center( - child: Icon(Icons.folder, color: Colors.white), - ), + child: const Center(child: Icon(Icons.folder, color: Colors.white)), ), const SizedBox(width: 10), Expanded( @@ -37,10 +31,7 @@ class TelegramFolderWidget extends StatelessWidget { mainAxisAlignment: MainAxisAlignment.center, children: [ Text(title, style: const TextStyle(fontSize: 16)), - const Text( - "Folder", - style: TextStyle(fontSize: 12, color: Colors.grey), - ), + const Text("Folder", style: TextStyle(fontSize: 12, color: Colors.grey)), ], ), ), diff --git a/lib/src/features/telegram_file_picker_feature/view/screens/telegram_files_picker_screen/telegram_files_picker_screen.dart b/lib/src/features/telegram_file_picker_feature/view/screens/telegram_files_picker_screen/telegram_files_picker_screen.dart index 7c205e6..f7c1669 100644 --- a/lib/src/features/telegram_file_picker_feature/view/screens/telegram_files_picker_screen/telegram_files_picker_screen.dart +++ b/lib/src/features/telegram_file_picker_feature/view/screens/telegram_files_picker_screen/telegram_files_picker_screen.dart @@ -13,18 +13,13 @@ import 'widgets/telegram_resent_files_from_storage_widget.dart'; class TelegramFilesPickerScreen extends StatefulWidget { final ScrollController parentScrollController; - const TelegramFilesPickerScreen({ - super.key, - required this.parentScrollController, - }); + const TelegramFilesPickerScreen({super.key, required this.parentScrollController}); @override - State createState() => - _TelegramFilesPickerScreenState(); + State createState() => _TelegramFilesPickerScreenState(); } -class _TelegramFilesPickerScreenState extends State - with FolderCreator { +class _TelegramFilesPickerScreenState extends State with FolderCreator { late final TelegramFilePickerBloc _telegramFilePickerBloc; late final TelegramFilePickerStateModel _telegramFilePickerStateModel; @@ -32,8 +27,7 @@ class _TelegramFilesPickerScreenState extends State void initState() { super.initState(); _telegramFilePickerBloc = context.read(); - _telegramFilePickerStateModel = - _telegramFilePickerBloc.state.telegramFilePickerStateModel; + _telegramFilePickerStateModel = _telegramFilePickerBloc.state.telegramFilePickerStateModel; // final currentStateModel = _telegramFilePickerBloc.state.telegramFilePickerStateModel; widget.parentScrollController.addListener(() { if (widget.parentScrollController.offset == @@ -48,9 +42,7 @@ class _TelegramFilesPickerScreenState extends State ); } else { // pagination here - _telegramFilePickerBloc.add( - const TelegramFilePickerEvents.recentFilesPaginationEvent(), - ); + _telegramFilePickerBloc.add(const TelegramFilePickerEvents.recentFilesPaginationEvent()); // if (currentStateModel.recentFilesPagination.length == // currentStateModel.recentFiles.length) { @@ -72,15 +64,11 @@ class _TelegramFilesPickerScreenState extends State debugPrint("listening data: ${notification.direction}"); if (notification.direction == ScrollDirection.forward) { _telegramFilePickerBloc.add( - const TelegramFilePickerEvents.openHideBottomTelegramButtonEvent( - true, - ), + const TelegramFilePickerEvents.openHideBottomTelegramButtonEvent(true), ); } else if (notification.direction == ScrollDirection.reverse) { _telegramFilePickerBloc.add( - const TelegramFilePickerEvents.openHideBottomTelegramButtonEvent( - false, - ), + const TelegramFilePickerEvents.openHideBottomTelegramButtonEvent(false), ); } return true; @@ -92,9 +80,7 @@ class _TelegramFilesPickerScreenState extends State children: [ Visibility( visible: - state - .telegramFilePickerStateModel - .filePickerScreenSelectedScreen == + state.telegramFilePickerStateModel.filePickerScreenSelectedScreen == TelegramFileFolderEnum.recentDownloadsScreen, maintainAnimation: true, maintainState: true, @@ -102,17 +88,13 @@ class _TelegramFilesPickerScreenState extends State curve: Curves.fastOutSlowIn, duration: const Duration(milliseconds: 300), offset: - state - .telegramFilePickerStateModel - .filePickerScreenSelectedScreen == + state.telegramFilePickerStateModel.filePickerScreenSelectedScreen == TelegramFileFolderEnum.recentDownloadsScreen ? Offset.zero : const Offset(1, 0), child: AnimatedOpacity( opacity: - state - .telegramFilePickerStateModel - .filePickerScreenSelectedScreen == + state.telegramFilePickerStateModel.filePickerScreenSelectedScreen == TelegramFileFolderEnum.recentDownloadsScreen ? 1 : 0, @@ -134,15 +116,11 @@ class _TelegramFilesPickerScreenState extends State maintainAnimation: true, maintainState: true, visible: - state - .telegramFilePickerStateModel - .filePickerScreenSelectedScreen == + state.telegramFilePickerStateModel.filePickerScreenSelectedScreen == TelegramFileFolderEnum.browseTheAppsFolder, child: PopScope( canPop: - state - .telegramFilePickerStateModel - .filePickerScreenSelectedScreen == + state.telegramFilePickerStateModel.filePickerScreenSelectedScreen == TelegramFileFolderEnum.browseTheAppsFolder ? false : true, @@ -157,17 +135,13 @@ class _TelegramFilesPickerScreenState extends State curve: Curves.fastOutSlowIn, duration: const Duration(milliseconds: 300), offset: - state - .telegramFilePickerStateModel - .filePickerScreenSelectedScreen == + state.telegramFilePickerStateModel.filePickerScreenSelectedScreen == TelegramFileFolderEnum.browseTheAppsFolder ? Offset.zero : const Offset(1, 0), child: AnimatedOpacity( opacity: - state - .telegramFilePickerStateModel - .filePickerScreenSelectedScreen == + state.telegramFilePickerStateModel.filePickerScreenSelectedScreen == TelegramFileFolderEnum.browseTheAppsFolder ? 1 : 0, @@ -180,17 +154,13 @@ class _TelegramFilesPickerScreenState extends State Visibility( visible: - state - .telegramFilePickerStateModel - .filePickerScreenSelectedScreen == + state.telegramFilePickerStateModel.filePickerScreenSelectedScreen == TelegramFileFolderEnum.browseTheFolder, maintainAnimation: true, maintainState: true, child: PopScope( canPop: - state - .telegramFilePickerStateModel - .filePickerScreenSelectedScreen == + state.telegramFilePickerStateModel.filePickerScreenSelectedScreen == TelegramFileFolderEnum.browseTheFolder ? false : true, @@ -210,17 +180,13 @@ class _TelegramFilesPickerScreenState extends State curve: Curves.fastOutSlowIn, duration: const Duration(milliseconds: 300), offset: - state - .telegramFilePickerStateModel - .filePickerScreenSelectedScreen == + state.telegramFilePickerStateModel.filePickerScreenSelectedScreen == TelegramFileFolderEnum.browseTheFolder ? Offset.zero : const Offset(1, 0), child: AnimatedOpacity( opacity: - state - .telegramFilePickerStateModel - .filePickerScreenSelectedScreen == + state.telegramFilePickerStateModel.filePickerScreenSelectedScreen == TelegramFileFolderEnum.browseTheFolder ? 1 : 0, @@ -247,17 +213,13 @@ class _TelegramFilesPickerScreenState extends State // gallery folder data Visibility( visible: - state - .telegramFilePickerStateModel - .filePickerScreenSelectedScreen == + state.telegramFilePickerStateModel.filePickerScreenSelectedScreen == TelegramFileFolderEnum.browseTheGalleryFolder, maintainAnimation: true, maintainState: true, child: PopScope( canPop: - state - .telegramFilePickerStateModel - .filePickerScreenSelectedScreen == + state.telegramFilePickerStateModel.filePickerScreenSelectedScreen == TelegramFileFolderEnum.browseTheGalleryFolder ? false : true, @@ -278,17 +240,13 @@ class _TelegramFilesPickerScreenState extends State curve: Curves.fastOutSlowIn, duration: const Duration(milliseconds: 300), offset: - state - .telegramFilePickerStateModel - .filePickerScreenSelectedScreen == + state.telegramFilePickerStateModel.filePickerScreenSelectedScreen == TelegramFileFolderEnum.browseTheGalleryFolder ? Offset.zero : const Offset(1, 0), child: AnimatedOpacity( opacity: - state - .telegramFilePickerStateModel - .filePickerScreenSelectedScreen == + state.telegramFilePickerStateModel.filePickerScreenSelectedScreen == TelegramFileFolderEnum.browseTheGalleryFolder ? 1 : 0, diff --git a/lib/src/features/telegram_file_picker_feature/view/screens/telegram_files_picker_screen/widgets/telegram_files_from_storages_widget.dart b/lib/src/features/telegram_file_picker_feature/view/screens/telegram_files_picker_screen/widgets/telegram_files_from_storages_widget.dart index f18e2f9..3813b47 100644 --- a/lib/src/features/telegram_file_picker_feature/view/screens/telegram_files_picker_screen/widgets/telegram_files_from_storages_widget.dart +++ b/lib/src/features/telegram_file_picker_feature/view/screens/telegram_files_picker_screen/widgets/telegram_files_from_storages_widget.dart @@ -10,12 +10,10 @@ class TelegramFilesFromStoragesWidget extends StatefulWidget { const TelegramFilesFromStoragesWidget({super.key}); @override - State createState() => - _TelegramFilesFromStoragesWidgetState(); + State createState() => _TelegramFilesFromStoragesWidgetState(); } -class _TelegramFilesFromStoragesWidgetState - extends State { +class _TelegramFilesFromStoragesWidgetState extends State { late AppThemeBloc _appThemeBloc; late List telegramStorageFileDataModels; @@ -78,10 +76,7 @@ class _TelegramFilesFromStoragesWidgetState ), Text( item.content, - style: GoogleFonts.aBeeZee( - fontSize: 16, - color: Colors.grey, - ), + style: GoogleFonts.aBeeZee(fontSize: 16, color: Colors.grey), ), ], ), diff --git a/lib/src/features/telegram_file_picker_feature/view/screens/telegram_files_picker_screen/widgets/telegram_resent_files_from_storage_widget.dart b/lib/src/features/telegram_file_picker_feature/view/screens/telegram_files_picker_screen/widgets/telegram_resent_files_from_storage_widget.dart index 099a83e..0da5a07 100644 --- a/lib/src/features/telegram_file_picker_feature/view/screens/telegram_files_picker_screen/widgets/telegram_resent_files_from_storage_widget.dart +++ b/lib/src/features/telegram_file_picker_feature/view/screens/telegram_files_picker_screen/widgets/telegram_resent_files_from_storage_widget.dart @@ -24,10 +24,7 @@ class _TelegramResentFilesFromStorageWidgetState void initState() { super.initState(); _telegramFilePickerStateModel = - context - .read() - .state - .telegramFilePickerStateModel; + context.read().state.telegramFilePickerStateModel; _appThemeBloc = DependenciesScope.of(context, listen: false).appThemeBloc; } @@ -56,9 +53,7 @@ class _TelegramResentFilesFromStorageWidgetState const SizedBox(height: 15), // // here should be the list of only files not images or videos - TelegramStorageFileWidget( - list: _telegramFilePickerStateModel.recentFilesPagination, - ), + TelegramStorageFileWidget(list: _telegramFilePickerStateModel.recentFilesPagination), ], ), ); diff --git a/lib/src/features/telegram_file_picker_feature/view/screens/telegram_gallery_file_picker_screen/telegram_gallery_file_picker_screen.dart b/lib/src/features/telegram_file_picker_feature/view/screens/telegram_gallery_file_picker_screen/telegram_gallery_file_picker_screen.dart index 0ef69a1..c195a0e 100644 --- a/lib/src/features/telegram_file_picker_feature/view/screens/telegram_gallery_file_picker_screen/telegram_gallery_file_picker_screen.dart +++ b/lib/src/features/telegram_file_picker_feature/view/screens/telegram_gallery_file_picker_screen/telegram_gallery_file_picker_screen.dart @@ -9,43 +9,33 @@ import 'widgets/telegram_gallery_file_picker_video_player_widget.dart'; class TelegramGalleryFilePickerScreen extends StatefulWidget { final ScrollController parentScrollController; - const TelegramGalleryFilePickerScreen({ - super.key, - required this.parentScrollController, - }); + const TelegramGalleryFilePickerScreen({super.key, required this.parentScrollController}); @override - State createState() => - _TelegramGalleryFilePickerScreenState(); + State createState() => _TelegramGalleryFilePickerScreenState(); } -class _TelegramGalleryFilePickerScreenState - extends State { +class _TelegramGalleryFilePickerScreenState extends State { late final TelegramFilePickerBloc _telegramFilePickerBloc; @override void initState() { super.initState(); _telegramFilePickerBloc = context.read(); - final currentStateModel = - _telegramFilePickerBloc.state.telegramFilePickerStateModel; + final currentStateModel = _telegramFilePickerBloc.state.telegramFilePickerStateModel; widget.parentScrollController.addListener(() { if (widget.parentScrollController.offset == widget.parentScrollController.position.maxScrollExtent && _telegramFilePickerBloc.state is Picker$GalleryFileState) { // pagination here - _telegramFilePickerBloc.add( - const TelegramFilePickerEvents.imagesAndVideoPaginationEvent(), - ); + _telegramFilePickerBloc.add(const TelegramFilePickerEvents.imagesAndVideoPaginationEvent()); // why i wrote ".length -1" -> because of galleryPathPagination's first item is entity with // cameraController if (currentStateModel.galleryPathPagination.length - 1 == currentStateModel.galleryPathFiles.length) { _telegramFilePickerBloc.add( - const TelegramFilePickerEvents.openHideBottomTelegramButtonEvent( - false, - ), + const TelegramFilePickerEvents.openHideBottomTelegramButtonEvent(false), ); } } @@ -69,23 +59,17 @@ class _TelegramGalleryFilePickerScreenState debugPrint("listening data: ${notification.direction}"); if (notification.direction == ScrollDirection.forward) { _telegramFilePickerBloc.add( - const TelegramFilePickerEvents.openHideBottomTelegramButtonEvent( - true, - ), + const TelegramFilePickerEvents.openHideBottomTelegramButtonEvent(true), ); } else if (notification.direction == ScrollDirection.reverse) { _telegramFilePickerBloc.add( - const TelegramFilePickerEvents.openHideBottomTelegramButtonEvent( - false, - ), + const TelegramFilePickerEvents.openHideBottomTelegramButtonEvent(false), ); } return true; }, child: GridView.builder( - physics: const AlwaysScrollableScrollPhysics( - parent: ClampingScrollPhysics(), - ), + physics: const AlwaysScrollableScrollPhysics(parent: ClampingScrollPhysics()), padding: const EdgeInsets.all(10), controller: widget.parentScrollController, gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount( @@ -103,8 +87,7 @@ class _TelegramGalleryFilePickerScreenState return TelegramGalleryFilePickerCameraWidget( cameraController: item.cameraController!, ); - } else if (item.videoPlayerController != null && - item.videoPreview != null) { + } else if (item.videoPlayerController != null && item.videoPreview != null) { return TelegramGalleryFilePickerVideoPlayerWidget( item: item, telegramFilePickerBloc: _telegramFilePickerBloc, diff --git a/lib/src/features/telegram_file_picker_feature/view/screens/telegram_gallery_file_picker_screen/widgets/telegram_gallery_file_picker_camera_widget.dart b/lib/src/features/telegram_file_picker_feature/view/screens/telegram_gallery_file_picker_screen/widgets/telegram_gallery_file_picker_camera_widget.dart index 9ff80b7..82b8ecb 100644 --- a/lib/src/features/telegram_file_picker_feature/view/screens/telegram_gallery_file_picker_screen/widgets/telegram_gallery_file_picker_camera_widget.dart +++ b/lib/src/features/telegram_file_picker_feature/view/screens/telegram_gallery_file_picker_screen/widgets/telegram_gallery_file_picker_camera_widget.dart @@ -5,10 +5,7 @@ import 'package:flutter/material.dart'; class TelegramGalleryFilePickerCameraWidget extends StatelessWidget { final CameraController cameraController; - const TelegramGalleryFilePickerCameraWidget({ - super.key, - required this.cameraController, - }); + const TelegramGalleryFilePickerCameraWidget({super.key, required this.cameraController}); @override Widget build(BuildContext context) { @@ -27,13 +24,7 @@ class TelegramGalleryFilePickerCameraWidget extends StatelessWidget { ), ), const Positioned.fill( - child: Center( - child: Icon( - CupertinoIcons.camera_fill, - color: Colors.white, - size: 40, - ), - ), + child: Center(child: Icon(CupertinoIcons.camera_fill, color: Colors.white, size: 40)), ), ], ); diff --git a/lib/src/features/telegram_file_picker_feature/view/screens/telegram_gallery_file_picker_screen/widgets/telegram_gallery_file_picker_image_widget.dart b/lib/src/features/telegram_file_picker_feature/view/screens/telegram_gallery_file_picker_screen/widgets/telegram_gallery_file_picker_image_widget.dart index 555f099..6e5454f 100644 --- a/lib/src/features/telegram_file_picker_feature/view/screens/telegram_gallery_file_picker_screen/widgets/telegram_gallery_file_picker_image_widget.dart +++ b/lib/src/features/telegram_file_picker_feature/view/screens/telegram_gallery_file_picker_screen/widgets/telegram_gallery_file_picker_image_widget.dart @@ -54,9 +54,7 @@ class _TelegramGalleryFilePickerImageWidgetState child: IconButton( onPressed: () => widget.telegramFilePickerBloc.add( - TelegramFilePickerEvents.selectGalleryFileEvent( - widget.item, - ), + TelegramFilePickerEvents.selectGalleryFileEvent(widget.item), ), icon: currentStateModel.isFileInsidePickedFiles(widget.item) diff --git a/lib/src/features/telegram_file_picker_feature/view/screens/telegram_gallery_file_picker_screen/widgets/telegram_gallery_file_picker_video_player_widget.dart b/lib/src/features/telegram_file_picker_feature/view/screens/telegram_gallery_file_picker_screen/widgets/telegram_gallery_file_picker_video_player_widget.dart index b03dd3e..502453f 100644 --- a/lib/src/features/telegram_file_picker_feature/view/screens/telegram_gallery_file_picker_screen/widgets/telegram_gallery_file_picker_video_player_widget.dart +++ b/lib/src/features/telegram_file_picker_feature/view/screens/telegram_gallery_file_picker_screen/widgets/telegram_gallery_file_picker_video_player_widget.dart @@ -27,8 +27,7 @@ class _TelegramGalleryFilePickerVideoPlayerWidgetState @override void initState() { super.initState(); - _currentStateModel = - widget.telegramFilePickerBloc.state.telegramFilePickerStateModel; + _currentStateModel = widget.telegramFilePickerBloc.state.telegramFilePickerStateModel; } @override @@ -43,18 +42,14 @@ class _TelegramGalleryFilePickerVideoPlayerWidgetState borderRadius: BorderRadius.circular(10), child: Stack( children: [ - Positioned.fill( - child: Image.memory(widget.item.videoPreview!, fit: BoxFit.cover), - ), + Positioned.fill(child: Image.memory(widget.item.videoPreview!, fit: BoxFit.cover)), Positioned( right: 0, top: 0, child: IconButton( onPressed: () => widget.telegramFilePickerBloc.add( - TelegramFilePickerEvents.selectGalleryFileEvent( - widget.item, - ), + TelegramFilePickerEvents.selectGalleryFileEvent(widget.item), ), icon: _currentStateModel.isFileInsidePickedFiles(widget.item) diff --git a/lib/src/features/telegram_file_picker_feature/view/telegram_draggable_scrollable_bottom_sheet.dart b/lib/src/features/telegram_file_picker_feature/view/telegram_draggable_scrollable_bottom_sheet.dart index bf1ae4c..b64a9cb 100644 --- a/lib/src/features/telegram_file_picker_feature/view/telegram_draggable_scrollable_bottom_sheet.dart +++ b/lib/src/features/telegram_file_picker_feature/view/telegram_draggable_scrollable_bottom_sheet.dart @@ -9,10 +9,7 @@ import 'screens/telegram_gallery_file_picker_screen/telegram_gallery_file_picker class TelegramDraggableScrollableBottomSheet extends StatelessWidget { final TelegramFilePickerBloc telegramFilePickerBloc; - const TelegramDraggableScrollableBottomSheet({ - super.key, - required this.telegramFilePickerBloc, - }); + const TelegramDraggableScrollableBottomSheet({super.key, required this.telegramFilePickerBloc}); @override Widget build(BuildContext context) { @@ -40,9 +37,7 @@ class _TelegramDraggableScrollableBottomSheetUIState void initState() { super.initState(); final telegramFilePickerBloc = context.read(); - telegramFilePickerBloc.add( - const TelegramFilePickerEvents.initAllPicturesEvent(true), - ); + telegramFilePickerBloc.add(const TelegramFilePickerEvents.initAllPicturesEvent(true)); Future.delayed(const Duration(milliseconds: 350), () { telegramFilePickerBloc.add( const TelegramFilePickerEvents.openHideBottomTelegramButtonEvent(true), @@ -74,10 +69,9 @@ class _TelegramDraggableScrollableBottomSheetUIState children: [ switch (state) { Picker$InitialState() => const SizedBox(), - Picker$GalleryFileState() => - TelegramGalleryFilePickerScreen( - parentScrollController: scrollController, - ), + Picker$GalleryFileState() => TelegramGalleryFilePickerScreen( + parentScrollController: scrollController, + ), Picker$FilesState() => TelegramFilesPickerScreen( parentScrollController: scrollController, ), @@ -102,8 +96,7 @@ class _TelegramDraggableScrollableBottomSheetUIState right: 0, left: 0, child: TelegramBottomPickerButton( - draggableScrollableController: - _draggableScrollableController, + draggableScrollableController: _draggableScrollableController, ), ), ], diff --git a/lib/src/features/video_chat_feature/bloc/state_model/video_chat_state_model.dart b/lib/src/features/video_chat_feature/bloc/state_model/video_chat_state_model.dart index 245f0b3..f243ef9 100644 --- a/lib/src/features/video_chat_feature/bloc/state_model/video_chat_state_model.dart +++ b/lib/src/features/video_chat_feature/bloc/state_model/video_chat_state_model.dart @@ -96,8 +96,7 @@ class VideoChatStateModel { cameraSwitched: cameraSwitched ?? this.cameraSwitched, chat: (chat ?? this.chat)?.copyWith(), currentUser: (currentUser ?? this.currentUser)?.copyWith(), - currentVideoChatEntity: - currentVideoChatEntity ?? this.currentVideoChatEntity, + currentVideoChatEntity: currentVideoChatEntity ?? this.currentVideoChatEntity, videoChatEntities: videoChatEntities ?? this.videoChatEntities, ); } diff --git a/lib/src/features/video_chat_feature/bloc/video_chat_feature_bloc.dart b/lib/src/features/video_chat_feature/bloc/video_chat_feature_bloc.dart index 71f9c58..75b4931 100644 --- a/lib/src/features/video_chat_feature/bloc/video_chat_feature_bloc.dart +++ b/lib/src/features/video_chat_feature/bloc/video_chat_feature_bloc.dart @@ -19,33 +19,26 @@ part 'video_chat_feature_bloc.freezed.dart'; @immutable @freezed sealed class VideoChatFeatureEvents with _$VideoChatFeatureEvents { - const factory VideoChatFeatureEvents.videoChatInitFeatureEvent( - final ChatModel? chat, - ) = _VideoChatInitFeatureEvent; + const factory VideoChatFeatureEvents.videoChatInitFeatureEvent(final ChatModel? chat) = + _VideoChatInitFeatureEvent; - const factory VideoChatFeatureEvents.startVideoChatEvent() = - _StartVideoChatEvent; + const factory VideoChatFeatureEvents.startVideoChatEvent() = _StartVideoChatEvent; - const factory VideoChatFeatureEvents.videoChatEntranceEvent() = - _VideoChatEntranceEvent; + const factory VideoChatFeatureEvents.videoChatEntranceEvent() = _VideoChatEntranceEvent; - const factory VideoChatFeatureEvents.finishVideoChatEvent({ - required void Function() popScreen, - }) = _FinishVideoChatEvent; + const factory VideoChatFeatureEvents.finishVideoChatEvent({required void Function() popScreen}) = + _FinishVideoChatEvent; const factory VideoChatFeatureEvents.onAddRemoteRendererStreamEvent( final MediaStream mediaStream, ) = _OnAddRemoteRendererStreamEvent; - const factory VideoChatFeatureEvents.switchCameraStreamEvent() = - _SwitchCameraStreamEvent; + const factory VideoChatFeatureEvents.switchCameraStreamEvent() = _SwitchCameraStreamEvent; - const factory VideoChatFeatureEvents.turnMicOffAndOnEvent({ - @Default(true) final bool change, - }) = _TurnMicOffAndOnEvent; + const factory VideoChatFeatureEvents.turnMicOffAndOnEvent({@Default(true) final bool change}) = + _TurnMicOffAndOnEvent; - const factory VideoChatFeatureEvents.turnCameraOffAndEvent() = - _TurnCameraOffAndEvent; + const factory VideoChatFeatureEvents.turnCameraOffAndEvent() = _TurnCameraOffAndEvent; } // @immutable @@ -65,13 +58,11 @@ sealed class VideoChatFeatureEvents with _$VideoChatFeatureEvents { @immutable @freezed class VideoChatFeatureStates with _$VideoChatFeatureStates { - const factory VideoChatFeatureStates.initial( - final VideoChatStateModel videoChatStateModel, - ) = _VideoChat$InitialState; + const factory VideoChatFeatureStates.initial(final VideoChatStateModel videoChatStateModel) = + _VideoChat$InitialState; } -class VideoChatBloc - extends Bloc { +class VideoChatBloc extends Bloc { StreamSubscription? _channelSubscription; PusherChannelsClient? _pusherChannelsClient; WebrtcLaravelService? _webrtcLaravelHelper; @@ -99,15 +90,12 @@ class VideoChatBloc on( (event, emit) => event.map( - videoChatInitFeatureEvent: - (event) => _videoChatInitFeatureEvent(event, emit), + videoChatInitFeatureEvent: (event) => _videoChatInitFeatureEvent(event, emit), startVideoChatEvent: (event) => _startVideoChatEvent(event, emit), videoChatEntranceEvent: (event) => _videoChatEntranceEvent(event, emit), finishVideoChatEvent: (event) => _finishVideoChatEvent(event, emit), - onAddRemoteRendererStreamEvent: - (event) => _onAddRemoteRendererStreamEvent(event, emit), - switchCameraStreamEvent: - (event) => _switchCameraStreamEvent(event, emit), + onAddRemoteRendererStreamEvent: (event) => _onAddRemoteRendererStreamEvent(event, emit), + switchCameraStreamEvent: (event) => _switchCameraStreamEvent(event, emit), turnMicOffAndOnEvent: (event) => _turnMicOffAndOnEvent(event, emit), turnCameraOffAndEvent: (event) => _turnCameraOffAndEvent(event, emit), ), @@ -131,9 +119,7 @@ class VideoChatBloc final currentChatVideoEntity = await _initLocalRenderer(); - currentStateModel = currentStateModel.copyWith( - currentVideoChatEntity: currentChatVideoEntity, - ); + currentStateModel = currentStateModel.copyWith(currentVideoChatEntity: currentChatVideoEntity); // in order to listen that someone from other side connected to your data _webrtcLaravelHelper?.onAddRemoteStream = ((stream) async { add(VideoChatFeatureEvents.onAddRemoteRendererStreamEvent(stream)); @@ -152,9 +138,7 @@ class VideoChatBloc if (!initResponse) return; - final roomId = await _webrtcLaravelHelper?.createRoom( - state.videoChatStateModel.chat, - ); + final roomId = await _webrtcLaravelHelper?.createRoom(state.videoChatStateModel.chat); debugPrint("creating room id: $roomId"); // ------------------------------------------------- @@ -177,9 +161,7 @@ class VideoChatBloc _logger.log(Level.debug, "entrance to the chat: $resultOfJoining"); - final currentStateModel = state.videoChatStateModel.copyWith( - chatStarted: resultOfJoining, - ); + final currentStateModel = state.videoChatStateModel.copyWith(chatStarted: resultOfJoining); await _webrtcLaravelHelper?.joinRoom(room.id.toString()); @@ -228,9 +210,7 @@ class VideoChatBloc // await createLocalMediaStream('key${Random().nextInt(100)}'); videoChatEntity.videoRenderer?.srcObject = event.mediaStream; - final currentChatEntities = List.of( - state.videoChatStateModel.videoChatEntities, - ); + final currentChatEntities = List.of(state.videoChatStateModel.videoChatEntities); currentChatEntities.add(videoChatEntity); @@ -254,8 +234,7 @@ class VideoChatBloc ); Helper.switchCamera( - currentStateModel.currentVideoChatEntity!.videoRenderer!.srcObject! - .getVideoTracks()[0], + currentStateModel.currentVideoChatEntity!.videoRenderer!.srcObject!.getVideoTracks()[0], null, _webrtcLaravelHelper?.localStream, ); @@ -270,15 +249,12 @@ class VideoChatBloc var currentStateModel = state.videoChatStateModel; if (event.change) { - currentStateModel = currentStateModel.copyWith( - hasAudio: !currentStateModel.hasAudio, - ); + currentStateModel = currentStateModel.copyWith(hasAudio: !currentStateModel.hasAudio); } Helper.setMicrophoneMute( !currentStateModel.hasAudio, - currentStateModel.currentVideoChatEntity!.videoRenderer!.srcObject! - .getAudioTracks()[0], + currentStateModel.currentVideoChatEntity!.videoRenderer!.srcObject!.getAudioTracks()[0], ); emit(VideoChatFeatureStates.initial(currentStateModel)); @@ -293,8 +269,7 @@ class VideoChatBloc ); final videoTrack = - currentStateModel.currentVideoChatEntity!.videoRenderer!.srcObject! - .getVideoTracks()[0]; + currentStateModel.currentVideoChatEntity!.videoRenderer!.srcObject!.getVideoTracks()[0]; videoTrack.enabled = currentStateModel.hasVideo; @@ -308,9 +283,7 @@ class VideoChatBloc if (!resultOfStart) return false; - final currentStateModel = state.videoChatStateModel.copyWith( - chatStarted: resultOfStart, - ); + final currentStateModel = state.videoChatStateModel.copyWith(chatStarted: resultOfStart); emit(VideoChatFeatureStates.initial(currentStateModel)); @@ -334,9 +307,7 @@ class VideoChatBloc await currentVideoChatEntity.videoRenderer?.initialize(); // after video render initialization open the media - await _webrtcLaravelHelper?.openUserMedia( - currentVideoChatEntity.videoRenderer!, - ); + await _webrtcLaravelHelper?.openUserMedia(currentVideoChatEntity.videoRenderer!); return currentVideoChatEntity; } @@ -347,8 +318,7 @@ class VideoChatBloc _pusherChannelsClient?.dispose(); _channelSubscription?.cancel(); state.videoChatStateModel.dispose(); - if (state.videoChatStateModel.currentVideoChatEntity?.videoRenderer != - null) { + if (state.videoChatStateModel.currentVideoChatEntity?.videoRenderer != null) { await _webrtcLaravelHelper?.hangUp( state.videoChatStateModel.currentVideoChatEntity!.videoRenderer!, ); diff --git a/lib/src/features/video_chat_feature/data/video_chat_feature_data_source.dart b/lib/src/features/video_chat_feature/data/video_chat_feature_data_source.dart index 7973c87..58773b9 100644 --- a/lib/src/features/video_chat_feature/data/video_chat_feature_data_source.dart +++ b/lib/src/features/video_chat_feature/data/video_chat_feature_data_source.dart @@ -26,14 +26,10 @@ class VideoChatFeatureDataSourceImpl implements VideoChatFeatureDataSource { final RestClientBase _restClientBase; - final _joinChatPath = - "${HttpRoutes.chatsVideoStreamPrefix}/videochat/entrance"; - final _startVideoChatPath = - "${HttpRoutes.chatsVideoStreamPrefix}/start/videochat"; - final _leaveVideoChatPath = - "${HttpRoutes.chatsVideoStreamPrefix}/leave/videochat"; - final _steamTheVideoPath = - "${HttpRoutes.chatsVideoStreamPrefix}/video/stream"; + final _joinChatPath = "${HttpRoutes.chatsVideoStreamPrefix}/videochat/entrance"; + final _startVideoChatPath = "${HttpRoutes.chatsVideoStreamPrefix}/start/videochat"; + final _leaveVideoChatPath = "${HttpRoutes.chatsVideoStreamPrefix}/leave/videochat"; + final _steamTheVideoPath = "${HttpRoutes.chatsVideoStreamPrefix}/video/stream"; @override Future startVideoChat(VideoChatModel videoChatEntity) async { @@ -59,10 +55,7 @@ class VideoChatFeatureDataSourceImpl implements VideoChatFeatureDataSource { @override Future videoChatEntrance(VideoChatModel videoChatEntity) async { try { - final response = await _restClientBase.put( - _joinChatPath, - data: videoChatEntity.toJson(), - ); + final response = await _restClientBase.put(_joinChatPath, data: videoChatEntity.toJson()); if (response == null) return false; @@ -102,10 +95,7 @@ class VideoChatFeatureDataSourceImpl implements VideoChatFeatureDataSource { final jsonBody = videoChatEntity.toJson(); log("sending uint8list data: $jsonBody"); - final response = await _restClientBase.put( - _steamTheVideoPath, - data: jsonBody, - ); + final response = await _restClientBase.put(_steamTheVideoPath, data: jsonBody); debugPrint("coming response from stream video: $response"); } on RestClientException { diff --git a/lib/src/features/video_chat_feature/models/candidate_model/candidate_model.dart b/lib/src/features/video_chat_feature/models/candidate_model/candidate_model.dart index 61b372b..5eb6f35 100644 --- a/lib/src/features/video_chat_feature/models/candidate_model/candidate_model.dart +++ b/lib/src/features/video_chat_feature/models/candidate_model/candidate_model.dart @@ -23,13 +23,11 @@ class CandidateModel with _$CandidateModel { const factory CandidateModel({ required int? id, @JsonKey(name: "room_id") required int? roomId, - @JsonKey(fromJson: _fromJsonInnerCandidate) - required InnerCandidateModel? candidate, + @JsonKey(fromJson: _fromJsonInnerCandidate) required InnerCandidateModel? candidate, required String? role, required DateTime? createdAt, required DateTime? updatedAt, }) = _CandidateModel; - factory CandidateModel.fromJson(Map json) => - _$CandidateModelFromJson(json); + factory CandidateModel.fromJson(Map json) => _$CandidateModelFromJson(json); } diff --git a/lib/src/features/video_chat_feature/models/video_chat_model.dart b/lib/src/features/video_chat_feature/models/video_chat_model.dart index 1531e90..90d42ec 100644 --- a/lib/src/features/video_chat_feature/models/video_chat_model.dart +++ b/lib/src/features/video_chat_feature/models/video_chat_model.dart @@ -9,11 +9,8 @@ class VideoChatModel { final ChatModel? chat; final UserModel? user; - VideoChatModel({ - required this.videoRenderer, - required this.chat, - required this.user, - }) : videoChatId = const Uuid().v4(); + VideoChatModel({required this.videoRenderer, required this.chat, required this.user}) + : videoChatId = const Uuid().v4(); Map toJson() { return { diff --git a/lib/src/features/video_chat_feature/webrtc_service/webrtc_laravel_service.dart b/lib/src/features/video_chat_feature/webrtc_service/webrtc_laravel_service.dart index 07d4605..f576a76 100644 --- a/lib/src/features/video_chat_feature/webrtc_service/webrtc_laravel_service.dart +++ b/lib/src/features/video_chat_feature/webrtc_service/webrtc_laravel_service.dart @@ -45,10 +45,7 @@ class WebrtcLaravelService { Map configuration = { 'iceServers': [ { - 'urls': [ - 'stun:stun1.l.google.com:19302', - 'stun:stun2.l.google.com:19302', - ], + 'urls': ['stun:stun1.l.google.com:19302', 'stun:stun2.l.google.com:19302'], }, ], }; @@ -70,11 +67,9 @@ class WebrtcLaravelService { SetStateCallbackSignal? setSetStateCallback; - StreamSubscription? - calleeStreamSubs; // same channel stream but accepts different data + StreamSubscription? calleeStreamSubs; // same channel stream but accepts different data - StreamSubscription? - callerStreamSubs; // same channel stream but accepts different data + StreamSubscription? callerStreamSubs; // same channel stream but accepts different data Future createRoom(ChatModel? chat) async { try { @@ -122,9 +117,7 @@ class WebrtcLaravelService { try { final pusherService = await _pusherClientService.subscriptionCreator(); - final channel = pusherService.publicChannel( - Constants.webRtcChannelName, - ); + final channel = pusherService.publicChannel(Constants.webRtcChannelName); calleeStreamSubs = pusherService.onConnectionEstablished.listen((e) { channel.subscribeIfNotUnsubscribed(); @@ -152,13 +145,10 @@ class WebrtcLaravelService { if (responseCandidates == null) return; // - final List listOfCandidates = responseCandidates - .getNested(['candidates']); + final List listOfCandidates = responseCandidates.getNested(['candidates']); final List candidates = - listOfCandidates - .map((e) => CandidateModel.fromJson(e)) - .toList(); + listOfCandidates.map((e) => CandidateModel.fromJson(e)).toList(); for (final each in candidates) { await peerConnection?.addCandidate( @@ -248,10 +238,7 @@ class WebrtcLaravelService { // sdp = sdp.replaceAll("\r\na=extmap-allow-mixed", ""); - final RTCSessionDescription remoteDescription = RTCSessionDescription( - sdp, - type, - ); + final RTCSessionDescription remoteDescription = RTCSessionDescription(sdp, type); try { await peerConnection?.setRemoteDescription(remoteDescription); @@ -282,14 +269,10 @@ class WebrtcLaravelService { /// // get candidates data before listening them - final responseCandidates = await _restClientBase.get( - "/get-ice-candidates/$roomId/caller", - ); + final responseCandidates = await _restClientBase.get("/get-ice-candidates/$roomId/caller"); // - final List listOfCandidates = responseCandidates?.getNested([ - 'candidates', - ]); + final List listOfCandidates = responseCandidates?.getNested(['candidates']); final List candidates = listOfCandidates.map((e) => CandidateModel.fromJson(e)).toList(); @@ -315,12 +298,9 @@ class WebrtcLaravelService { channel.bind(Constants.webRtcChannelEventName).listen((e) async { // code here tomorrow - final Map data = - e.data is String ? jsonDecode(e.toString()) : e.data; + final Map data = e.data is String ? jsonDecode(e.toString()) : e.data; - if (data.containsKey("candidate") && - data.containsKey("role") && - data['role'] == 'caller') { + if (data.containsKey("candidate") && data.containsKey("role") && data['role'] == 'caller') { peerConnection?.addCandidate( RTCIceCandidate( data['candidate']['candidate'], @@ -359,9 +339,7 @@ class WebrtcLaravelService { // close all Future hangUp(RTCVideoRenderer? localVideo) async { - localVideo?.srcObject?.getTracks().forEach( - ((track) async => await track.stop()), - ); + localVideo?.srcObject?.getTracks().forEach(((track) async => await track.stop())); if (remoteStream != null) { remoteStream!.getTracks().forEach((track) async => await track.stop()); @@ -398,11 +376,7 @@ class WebrtcLaravelService { localVideo = null; } - void addIceCandidate( - RTCIceCandidate candidate, - String roomId, - String role, - ) async { + void addIceCandidate(RTCIceCandidate candidate, String roomId, String role) async { final response = await _restClientBase.post( _addIceCandidates, data: {'roomId': roomId, 'candidate': candidate.toMap(), 'role': role}, @@ -410,9 +384,7 @@ class WebrtcLaravelService { } Future getIceCandidates(String roomId, String role) async { - final response = await _restClientBase.get( - '$_apiGetIceCandidates$roomId/$role', - ); + final response = await _restClientBase.get('$_apiGetIceCandidates$roomId/$role'); final candidates = response?.getNested(['candidates']) as List; diff --git a/lib/src/features/video_chat_feature/widgets/type_of_screens/double_camera_view_screen.dart b/lib/src/features/video_chat_feature/widgets/type_of_screens/double_camera_view_screen.dart index f32c7df..5acb2dc 100644 --- a/lib/src/features/video_chat_feature/widgets/type_of_screens/double_camera_view_screen.dart +++ b/lib/src/features/video_chat_feature/widgets/type_of_screens/double_camera_view_screen.dart @@ -23,21 +23,14 @@ class _DoubleCameraViewScreenState extends State { Expanded( child: RTCVideoView( objectFit: RTCVideoViewObjectFit.RTCVideoViewObjectFitCover, - state - .videoChatStateModel - .videoChatEntities - .first - .videoRenderer!, + state.videoChatStateModel.videoChatEntities.first.videoRenderer!, ), ), const Divider(height: 0, color: Colors.black12), Expanded( child: RTCVideoView( objectFit: RTCVideoViewObjectFit.RTCVideoViewObjectFitCover, - state - .videoChatStateModel - .currentVideoChatEntity! - .videoRenderer!, + state.videoChatStateModel.currentVideoChatEntity!.videoRenderer!, mirror: !state.videoChatStateModel.cameraSwitched, ), ), diff --git a/lib/src/features/video_chat_feature/widgets/video_chat_feature_page.dart b/lib/src/features/video_chat_feature/widgets/video_chat_feature_page.dart index 53c681b..c5ac5e1 100644 --- a/lib/src/features/video_chat_feature/widgets/video_chat_feature_page.dart +++ b/lib/src/features/video_chat_feature/widgets/video_chat_feature_page.dart @@ -40,8 +40,7 @@ class _VideoChatFeaturePageUI extends StatefulWidget { const _VideoChatFeaturePageUI({required this.chat}); @override - State<_VideoChatFeaturePageUI> createState() => - _VideoChatFeaturePageUIState(); + State<_VideoChatFeaturePageUI> createState() => _VideoChatFeaturePageUIState(); } class _VideoChatFeaturePageUIState extends State<_VideoChatFeaturePageUI> { diff --git a/lib/src/features/video_chat_feature/widgets/widgets/call_button_widget.dart b/lib/src/features/video_chat_feature/widgets/widgets/call_button_widget.dart index 324f021..9a53687 100644 --- a/lib/src/features/video_chat_feature/widgets/widgets/call_button_widget.dart +++ b/lib/src/features/video_chat_feature/widgets/widgets/call_button_widget.dart @@ -36,11 +36,7 @@ class _CallButtonWidgetState extends State { width: 90, height: 90, child: Center( - child: Icon( - CupertinoIcons.phone_down, - size: 35, - color: Colors.white, - ), + child: Icon(CupertinoIcons.phone_down, size: 35, color: Colors.white), ), ), ), @@ -69,8 +65,7 @@ class _CallButtonWidgetState extends State { child: InkWell( borderRadius: BorderRadius.circular(50), onTap: () { - if (state.videoChatStateModel.chat?.videoChatRoom != - null) { + if (state.videoChatStateModel.chat?.videoChatRoom != null) { debugPrint("working22 here"); context.read().add( const VideoChatFeatureEvents.videoChatEntranceEvent(), @@ -85,17 +80,13 @@ class _CallButtonWidgetState extends State { child: const SizedBox( width: 90, height: 90, - child: Center( - child: Icon(Icons.call, size: 35, color: Colors.white), - ), + child: Center(child: Icon(Icons.call, size: 35, color: Colors.white)), ), ), ), const SizedBox(height: 10), Text( - state.videoChatStateModel.chat?.videoChatRoom != null - ? "Accept" - : "Call", + state.videoChatStateModel.chat?.videoChatRoom != null ? "Accept" : "Call", style: const TextStyle( color: Colors.white, fontWeight: FontWeight.w500, diff --git a/lib/src/features/video_chat_feature/widgets/widgets/hang_up_buttons_widget.dart b/lib/src/features/video_chat_feature/widgets/widgets/hang_up_buttons_widget.dart index be7942d..ac3ca55 100644 --- a/lib/src/features/video_chat_feature/widgets/widgets/hang_up_buttons_widget.dart +++ b/lib/src/features/video_chat_feature/widgets/widgets/hang_up_buttons_widget.dart @@ -30,11 +30,7 @@ class _HangUpButtonsWidgetState extends State { width: 60, height: 60, child: Center( - child: Icon( - CupertinoIcons.switch_camera, - size: 35, - color: Colors.black, - ), + child: Icon(CupertinoIcons.switch_camera, size: 35, color: Colors.black), ), ), ), @@ -57,11 +53,7 @@ class _HangUpButtonsWidgetState extends State { width: 60, height: 60, child: Center( - child: Icon( - CupertinoIcons.video_camera, - size: 35, - color: Colors.white, - ), + child: Icon(CupertinoIcons.video_camera, size: 35, color: Colors.white), ), ), if (!state.videoChatStateModel.hasVideo) @@ -69,11 +61,7 @@ class _HangUpButtonsWidgetState extends State { child: Center( child: RotationTransition( turns: AlwaysStoppedAnimation(45 / 360), - child: Icon( - Icons.remove, - color: Colors.white, - size: 60, - ), + child: Icon(Icons.remove, color: Colors.white, size: 60), ), ), ), @@ -137,11 +125,7 @@ class _HangUpButtonsWidgetState extends State { width: 60, height: 60, child: Center( - child: Icon( - CupertinoIcons.phone_down, - size: 35, - color: Colors.white, - ), + child: Icon(CupertinoIcons.phone_down, size: 35, color: Colors.white), ), ), ), From c5e2f997fa43899771049a9e2ee6e4f0760db37a Mon Sep 17 00:00:00 2001 From: sarbador Date: Fri, 7 Mar 2025 18:19:08 +0500 Subject: [PATCH 07/10] added some code --- analysis_options.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/analysis_options.yaml b/analysis_options.yaml index 6fce0b3..c57d152 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -1,3 +1,5 @@ +include: package:flutter_lints/flutter.yaml + formatter: page_width: 100 @@ -8,7 +10,6 @@ analyzer: unused_import: warning duplicate_import: info dead_code: error -include: package:flutter_lints/flutter.yaml linter: rules: From d070bb47f6ee54e1e96d1bb603924d62b509d615 Mon Sep 17 00:00:00 2001 From: sb-dor Date: Sat, 26 Apr 2025 13:42:28 +0500 Subject: [PATCH 08/10] added environment that can be used with dart define --- env/.gitignore | 1 + env/dev.json | 9 +++ .../xcshareddata/xcschemes/Runner.xcscheme | 1 + lib/env/.gitignore | 1 - lib/env/env_example.dart | 10 --- .../pusher_client_service.dart | 16 +++-- .../initialization/logic/app_runner.dart | 7 +- .../composition_root/composition_root.dart | 65 ++++++++++--------- .../models/application_config.dart | 15 +++++ .../models/dependency_container.dart | 29 +++++---- .../initialization/models/environment.dart | 16 +++++ 11 files changed, 108 insertions(+), 62 deletions(-) create mode 100644 env/.gitignore create mode 100644 env/dev.json delete mode 100644 lib/env/.gitignore delete mode 100644 lib/env/env_example.dart create mode 100644 lib/src/features/initialization/models/application_config.dart create mode 100644 lib/src/features/initialization/models/environment.dart diff --git a/env/.gitignore b/env/.gitignore new file mode 100644 index 0000000..12e7aa8 --- /dev/null +++ b/env/.gitignore @@ -0,0 +1 @@ +prod.json \ No newline at end of file diff --git a/env/dev.json b/env/dev.json new file mode 100644 index 0000000..a01a65c --- /dev/null +++ b/env/dev.json @@ -0,0 +1,9 @@ +{ + "MAIN_URL": "", + "PUSHER_APP_ID": "", + "PUSHER_APP_KEY": "", + "PUSHER_APP_SECRET": "", + "PUSHER_HOST": "192.168.100.3", + "PUSHER_PORT": 6001, + "PUSHER_SCHEME": "ws" +} \ No newline at end of file diff --git a/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme index 8e3ca5d..15cada4 100644 --- a/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme +++ b/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -59,6 +59,7 @@ ignoresPersistentStateOnLaunch = "NO" debugDocumentVersioning = "YES" debugServiceExtension = "internal" + enableGPUValidationMode = "1" allowLocationSimulation = "YES"> diff --git a/lib/env/.gitignore b/lib/env/.gitignore deleted file mode 100644 index e550a1c..0000000 --- a/lib/env/.gitignore +++ /dev/null @@ -1 +0,0 @@ -env.dart \ No newline at end of file diff --git a/lib/env/env_example.dart b/lib/env/env_example.dart deleted file mode 100644 index a05b8ab..0000000 --- a/lib/env/env_example.dart +++ /dev/null @@ -1,10 +0,0 @@ -abstract class EnvExample { - static const String mainUrl = ''; - static const String pusherAppId = ''; - static const String pusherAppKey = ''; - static const String pusherAppSecret = ''; - static const String pusherHost = ''; - static const int pusherPort = 6001; - static const String pusherScheme = ''; - static const String pusherAppCluster = ''; -} diff --git a/lib/src/core/utils/pusher_client_service/pusher_client_service.dart b/lib/src/core/utils/pusher_client_service/pusher_client_service.dart index 2a56f1d..88cb23b 100644 --- a/lib/src/core/utils/pusher_client_service/pusher_client_service.dart +++ b/lib/src/core/utils/pusher_client_service/pusher_client_service.dart @@ -1,7 +1,11 @@ import 'package:dart_pusher_channels/dart_pusher_channels.dart'; -import 'package:yahay/env/env.dart'; +import 'package:yahay/src/features/initialization/models/application_config.dart'; class PusherClientService { + PusherClientService(this.applicationConfig); + + final ApplicationConfig applicationConfig; + late final PusherChannelsOptions _options; PusherChannelsOptions get options => _options; @@ -10,11 +14,11 @@ class PusherClientService { // just for showing logs PusherChannelsPackageLogger.enableLogs(); - _options = const PusherChannelsOptions.fromHost( - scheme: Env.pusherScheme, // should be -> ws - host: Env.pusherHost, - port: Env.pusherPort, - key: Env.pusherAppKey, + _options = PusherChannelsOptions.fromHost( + scheme: applicationConfig.pusherScheme, // should be -> ws + host: applicationConfig.pusherHost, + port: applicationConfig.pusherPort, + key: applicationConfig.pusherAppKey, ); } diff --git a/lib/src/features/initialization/logic/app_runner.dart b/lib/src/features/initialization/logic/app_runner.dart index b567f3e..78e53c4 100644 --- a/lib/src/features/initialization/logic/app_runner.dart +++ b/lib/src/features/initialization/logic/app_runner.dart @@ -5,7 +5,6 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:logger/logger.dart'; -import 'package:yahay/env/env.dart'; import 'package:yahay/src/core/utils/bloc_observer_manager/bloc_observer_manager.dart'; import 'package:yahay/src/core/utils/debug_image_creator_in_apps_folder/debug_image_creator_in_apps_folder.dart'; import 'package:yahay/src/core/utils/dio/src/rest_client_base.dart'; @@ -15,6 +14,7 @@ import 'package:yahay/src/core/utils/error_reporter/i_error_reporter.dart'; import 'package:yahay/src/core/utils/shared_preferences/shared_preferences.dart'; import 'package:yahay/src/features/initialization/logic/composition_root/composition_root.dart'; import 'package:yahay/src/features/initialization/logic/composition_root/factories/app_logger_factory.dart'; +import 'package:yahay/src/features/initialization/models/application_config.dart'; import 'package:yahay/src/features/initialization/widgets/root_context.dart'; import 'package:yahay/src/features/telegram_file_picker_feature/mixins/folder_creator/folder_creator.dart'; import 'package:yahay/firebase_options.dart'; @@ -35,9 +35,11 @@ class AppRunner with FolderCreator { final sharedPreferences = SharedPreferHelper(); await sharedPreferences.initSharedPrefer(); + final applicationConfig = ApplicationConfig(); + logger.log(Level.debug, "from env main url: ${applicationConfig.mainUrl}"); final RestClientBase restClientBase = RestClientDio( - baseURL: Env.mainUrl, + baseURL: applicationConfig.mainUrl, sharedPrefer: sharedPreferences, logger: logger, ); @@ -67,6 +69,7 @@ class AppRunner with FolderCreator { logger: logger, sharedPreferHelper: sharedPreferences, restClientBase: restClientBase, + applicationConfig: applicationConfig, ).create(); if (kDebugMode) { diff --git a/lib/src/features/initialization/logic/composition_root/composition_root.dart b/lib/src/features/initialization/logic/composition_root/composition_root.dart index 36d817d..adc5286 100644 --- a/lib/src/features/initialization/logic/composition_root/composition_root.dart +++ b/lib/src/features/initialization/logic/composition_root/composition_root.dart @@ -10,38 +10,40 @@ import 'package:yahay/src/core/utils/shared_preferences/shared_preferences.dart' import 'package:yahay/src/features/app_theme/bloc/app_theme_bloc.dart'; import 'package:yahay/src/features/initialization/logic/composition_root/factories/add_contact_bloc_factory.dart'; import 'package:yahay/src/features/initialization/logic/composition_root/factories/authorization_bloc_factory.dart'; +import 'package:yahay/src/features/initialization/models/application_config.dart'; import 'package:yahay/src/features/initialization/models/dependency_container.dart'; final class CompositionRoot extends AsyncFactory { // CompositionRoot({ - required Logger logger, - required SharedPreferHelper sharedPreferHelper, - required RestClientBase restClientBase, - }) : _logger = logger, - _sharedPreferHelper = sharedPreferHelper, - _restClientBase = restClientBase; + required this.logger, + required this.sharedPreferHelper, + required this.restClientBase, + required this.applicationConfig, + }); - final Logger _logger; - final SharedPreferHelper _sharedPreferHelper; - final RestClientBase _restClientBase; + final Logger logger; + final SharedPreferHelper sharedPreferHelper; + final RestClientBase restClientBase; + final ApplicationConfig applicationConfig; @override Future create() async { final stopWatch = clock.stopwatch()..start(); - _logger.log(Level.info, 'Initializing dependencies...'); + logger.log(Level.info, 'Initializing dependencies...'); final dependencyContainer = await DependencyContainerFactory( - logger: _logger, - sharedPreferHelper: _sharedPreferHelper, - restClientBase: _restClientBase, + logger: logger, + sharedPreferHelper: sharedPreferHelper, + restClientBase: restClientBase, + applicationConfig: applicationConfig, ).create(); stopWatch.stop(); - _logger.log( + logger.log( Level.info, 'Dependencies initialized successfully in ${stopWatch.elapsedMilliseconds} ms.', ); @@ -58,16 +60,16 @@ class CompositionResult { final class DependencyContainerFactory extends AsyncFactory { DependencyContainerFactory({ - required Logger logger, - required SharedPreferHelper sharedPreferHelper, - required RestClientBase restClientBase, - }) : _logger = logger, - _sharedPreferHelper = sharedPreferHelper, - _restClientBase = restClientBase; + required this.logger, + required this.sharedPreferHelper, + required this.restClientBase, + required this.applicationConfig, + }); - final Logger _logger; - final SharedPreferHelper _sharedPreferHelper; - final RestClientBase _restClientBase; + final Logger logger; + final SharedPreferHelper sharedPreferHelper; + final RestClientBase restClientBase; + final ApplicationConfig applicationConfig; @override Future create() async { @@ -75,29 +77,30 @@ final class DependencyContainerFactory extends AsyncFactory AuthorizationBlocFactory( googleSignIn: GoogleSignIn(), facebookAuth: FacebookAuth.instance, - sharedPreferHelper: _sharedPreferHelper, - logger: _logger, - restClientBase: _restClientBase, + sharedPreferHelper: sharedPreferHelper, + logger: logger, + restClientBase: restClientBase, ).create(); final cameraHelperService = CameraHelperService(); await cameraHelperService.initCameras(); final addContactBloc = - AddContactBlocFactory(logger: _logger, restClientBase: _restClientBase).create(); + AddContactBlocFactory(logger: logger, restClientBase: restClientBase).create(); - final pusherClientService = PusherClientService(); + final pusherClientService = PusherClientService(applicationConfig); await pusherClientService.init(); return DependencyContainer( - logger: _logger, - sharedPreferHelper: _sharedPreferHelper, - restClientBase: _restClientBase, + logger: logger, + sharedPreferHelper: sharedPreferHelper, + restClientBase: restClientBase, appThemeBloc: AppThemeBloc(), authBloc: authBloc, addContactBloc: addContactBloc, appRouter: AppRouter(), + applicationConfig: applicationConfig, pusherClientService: pusherClientService, cameraHelperService: cameraHelperService, ); diff --git a/lib/src/features/initialization/models/application_config.dart b/lib/src/features/initialization/models/application_config.dart new file mode 100644 index 0000000..982683e --- /dev/null +++ b/lib/src/features/initialization/models/application_config.dart @@ -0,0 +1,15 @@ +class ApplicationConfig { + String get mainUrl => const String.fromEnvironment("MAIN_URL"); + + String get pusherAppId => const String.fromEnvironment("PUSHER_APP_ID"); + + String get pusherAppKey => const String.fromEnvironment("PUSHER_APP_KEY"); + + String get pusherAppSecret => const String.fromEnvironment("PUSHER_APP_SECRET"); + + String get pusherHost => const String.fromEnvironment("PUSHER_HOST"); + + int get pusherPort => const int.fromEnvironment("PUSHER_PORT"); + + String get pusherScheme => const String.fromEnvironment("PUSHER_SCHEME"); +} diff --git a/lib/src/features/initialization/models/dependency_container.dart b/lib/src/features/initialization/models/dependency_container.dart index ef85caa..97c9d6f 100644 --- a/lib/src/features/initialization/models/dependency_container.dart +++ b/lib/src/features/initialization/models/dependency_container.dart @@ -10,10 +10,25 @@ import 'package:yahay/src/features/authorization/bloc/auth_bloc.dart'; import 'package:yahay/src/features/chats/bloc/chats_bloc.dart'; import 'package:yahay/src/features/initialization/logic/composition_root/factories/chats_bloc_factory.dart'; import 'package:yahay/src/features/initialization/logic/composition_root/factories/profile_bloc_factory.dart'; +import 'package:yahay/src/features/initialization/models/application_config.dart'; import 'package:yahay/src/features/profile/bloc/profile_bloc.dart'; class DependencyContainer { // + + DependencyContainer({ + required this.logger, + required this.appThemeBloc, + required this.authBloc, + required this.addContactBloc, + required this.appRouter, + required this.sharedPreferHelper, + required this.pusherClientService, + required this.cameraHelperService, + required this.restClientBase, + required this.applicationConfig, + }); + final Logger logger; final AppThemeBloc appThemeBloc; @@ -32,22 +47,12 @@ class DependencyContainer { final RestClientBase restClientBase; + final ApplicationConfig applicationConfig; + ChatsBloc? chatsBloc; ProfileBloc? profileBloc; - DependencyContainer({ - required this.logger, - required this.appThemeBloc, - required this.authBloc, - required this.addContactBloc, - required this.appRouter, - required this.sharedPreferHelper, - required this.pusherClientService, - required this.cameraHelperService, - required this.restClientBase, - }); - void initDependenciesAfterAuthorization() { chatsBloc = ChatsBlocFactory( diff --git a/lib/src/features/initialization/models/environment.dart b/lib/src/features/initialization/models/environment.dart new file mode 100644 index 0000000..7979452 --- /dev/null +++ b/lib/src/features/initialization/models/environment.dart @@ -0,0 +1,16 @@ +import 'package:flutter/foundation.dart'; + +enum Environment { + dev._('DEV'), + prod._('PROD'); + + final String value; + + const Environment._(this.value); + + static Environment from(String? value) => switch (value) { + "DEV" => Environment.dev, + "PROD" => Environment.prod, + _ => kReleaseMode ? Environment.prod : Environment.dev, + }; +} From b44208281e49c50d2473d63fb4650fad71551b61 Mon Sep 17 00:00:00 2001 From: sb-dor Date: Sun, 27 Apr 2025 07:46:45 +0500 Subject: [PATCH 09/10] configures env file --- .gitignore | 1 - ios/Podfile.lock | 231 ++++++++-------- ios/Runner.xcodeproj/project.pbxproj | 6 +- macos/Runner.xcodeproj/project.pbxproj | 24 +- pubspec.lock | 359 ++++++++++++------------- pubspec.yaml | 24 +- 6 files changed, 309 insertions(+), 336 deletions(-) diff --git a/.gitignore b/.gitignore index 2281275..5e887de 100644 --- a/.gitignore +++ b/.gitignore @@ -44,7 +44,6 @@ app.*.map.json /android/app/profile /android/app/release -*.env firebase.json **/*.freezed.dart diff --git a/ios/Podfile.lock b/ios/Podfile.lock index 57832fe..13e3e72 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -5,6 +5,10 @@ PODS: - AppAuth/Core (1.7.6) - AppAuth/ExternalUserAgent (1.7.6): - AppAuth/Core + - AppCheckCore (11.2.0): + - GoogleUtilities/Environment (~> 8.0) + - GoogleUtilities/UserDefaults (~> 8.0) + - PromisesObjC (~> 2.4) - camera_avfoundation (0.0.1): - Flutter - device_info_plus (0.0.1): @@ -19,49 +23,49 @@ PODS: - FBSDKCoreKit_Basics (17.0.3) - FBSDKLoginKit (17.0.3): - FBSDKCoreKit (= 17.0.3) - - Firebase/CoreOnly (10.25.0): - - FirebaseCore (= 10.25.0) - - Firebase/Crashlytics (10.25.0): + - Firebase/CoreOnly (11.10.0): + - FirebaseCore (~> 11.10.0) + - Firebase/Crashlytics (11.10.0): - Firebase/CoreOnly - - FirebaseCrashlytics (~> 10.25.0) - - firebase_core (2.32.0): - - Firebase/CoreOnly (= 10.25.0) + - FirebaseCrashlytics (~> 11.10.0) + - firebase_core (3.13.0): + - Firebase/CoreOnly (= 11.10.0) - Flutter - - firebase_crashlytics (3.5.7): - - Firebase/Crashlytics (= 10.25.0) + - firebase_crashlytics (4.3.5): + - Firebase/Crashlytics (= 11.10.0) - firebase_core - Flutter - - FirebaseCore (10.25.0): - - FirebaseCoreInternal (~> 10.0) - - GoogleUtilities/Environment (~> 7.12) - - GoogleUtilities/Logger (~> 7.12) - - FirebaseCoreExtension (10.29.0): - - FirebaseCore (~> 10.0) - - FirebaseCoreInternal (10.29.0): - - "GoogleUtilities/NSData+zlib (~> 7.8)" - - FirebaseCrashlytics (10.25.0): - - FirebaseCore (~> 10.5) - - FirebaseInstallations (~> 10.0) - - FirebaseRemoteConfigInterop (~> 10.23) - - FirebaseSessions (~> 10.5) - - GoogleDataTransport (~> 9.2) - - GoogleUtilities/Environment (~> 7.8) - - nanopb (< 2.30911.0, >= 2.30908.0) - - PromisesObjC (~> 2.1) - - FirebaseInstallations (10.29.0): - - FirebaseCore (~> 10.0) - - GoogleUtilities/Environment (~> 7.8) - - GoogleUtilities/UserDefaults (~> 7.8) - - PromisesObjC (~> 2.1) - - FirebaseRemoteConfigInterop (10.29.0) - - FirebaseSessions (10.29.0): - - FirebaseCore (~> 10.5) - - FirebaseCoreExtension (~> 10.0) - - FirebaseInstallations (~> 10.0) - - GoogleDataTransport (~> 9.2) - - GoogleUtilities/Environment (~> 7.13) - - GoogleUtilities/UserDefaults (~> 7.13) - - nanopb (< 2.30911.0, >= 2.30908.0) + - FirebaseCore (11.10.0): + - FirebaseCoreInternal (~> 11.10.0) + - GoogleUtilities/Environment (~> 8.0) + - GoogleUtilities/Logger (~> 8.0) + - FirebaseCoreExtension (11.10.0): + - FirebaseCore (~> 11.10.0) + - FirebaseCoreInternal (11.10.0): + - "GoogleUtilities/NSData+zlib (~> 8.0)" + - FirebaseCrashlytics (11.10.0): + - FirebaseCore (~> 11.10.0) + - FirebaseInstallations (~> 11.0) + - FirebaseRemoteConfigInterop (~> 11.0) + - FirebaseSessions (~> 11.0) + - GoogleDataTransport (~> 10.0) + - GoogleUtilities/Environment (~> 8.0) + - nanopb (~> 3.30910.0) + - PromisesObjC (~> 2.4) + - FirebaseInstallations (11.10.0): + - FirebaseCore (~> 11.10.0) + - GoogleUtilities/Environment (~> 8.0) + - GoogleUtilities/UserDefaults (~> 8.0) + - PromisesObjC (~> 2.4) + - FirebaseRemoteConfigInterop (11.11.0) + - FirebaseSessions (11.10.0): + - FirebaseCore (~> 11.10.0) + - FirebaseCoreExtension (~> 11.10.0) + - FirebaseInstallations (~> 11.0) + - GoogleDataTransport (~> 10.0) + - GoogleUtilities/Environment (~> 8.0) + - GoogleUtilities/UserDefaults (~> 8.0) + - nanopb (~> 3.30910.0) - PromisesSwift (~> 2.1) - Flutter (1.0.0) - flutter_facebook_auth (6.2.0): @@ -74,12 +78,11 @@ PODS: - SDWebImageWebPCoder - flutter_secure_storage (6.0.0): - Flutter - - flutter_webrtc (0.11.3): + - flutter_webrtc (0.12.6): - Flutter - - WebRTC-SDK (= 125.6422.04) + - WebRTC-SDK (= 125.6422.06) - fluttertoast (0.0.2): - Flutter - - Toast - gal (1.0.0): - Flutter - FlutterMacOS @@ -90,26 +93,25 @@ PODS: - AppAuth (>= 1.7.4) - Flutter - FlutterMacOS - - GoogleSignIn (~> 7.1) + - GoogleSignIn (~> 8.0) - GTMSessionFetcher (>= 3.4.0) - - GoogleDataTransport (9.4.1): - - GoogleUtilities/Environment (~> 7.7) - - nanopb (< 2.30911.0, >= 2.30908.0) - - PromisesObjC (< 3.0, >= 1.2) - - GoogleSignIn (7.1.0): + - GoogleDataTransport (10.1.0): + - nanopb (~> 3.30910.0) + - PromisesObjC (~> 2.4) + - GoogleSignIn (8.0.0): - AppAuth (< 2.0, >= 1.7.3) + - AppCheckCore (~> 11.0) - GTMAppAuth (< 5.0, >= 4.1.1) - GTMSessionFetcher/Core (~> 3.3) - - GoogleUtilities/Environment (7.13.3): + - GoogleUtilities/Environment (8.0.2): - GoogleUtilities/Privacy - - PromisesObjC (< 3.0, >= 1.2) - - GoogleUtilities/Logger (7.13.3): + - GoogleUtilities/Logger (8.0.2): - GoogleUtilities/Environment - GoogleUtilities/Privacy - - "GoogleUtilities/NSData+zlib (7.13.3)": + - "GoogleUtilities/NSData+zlib (8.0.2)": - GoogleUtilities/Privacy - - GoogleUtilities/Privacy (7.13.3) - - GoogleUtilities/UserDefaults (7.13.3): + - GoogleUtilities/Privacy (8.0.2) + - GoogleUtilities/UserDefaults (8.0.2): - GoogleUtilities/Logger - GoogleUtilities/Privacy - GTMAppAuth (4.1.1): @@ -122,26 +124,26 @@ PODS: - GTMSessionFetcher/Core - image_picker_ios (0.0.1): - Flutter - - libwebp (1.3.2): - - libwebp/demux (= 1.3.2) - - libwebp/mux (= 1.3.2) - - libwebp/sharpyuv (= 1.3.2) - - libwebp/webp (= 1.3.2) - - libwebp/demux (1.3.2): + - libwebp (1.5.0): + - libwebp/demux (= 1.5.0) + - libwebp/mux (= 1.5.0) + - libwebp/sharpyuv (= 1.5.0) + - libwebp/webp (= 1.5.0) + - libwebp/demux (1.5.0): - libwebp/webp - - libwebp/mux (1.3.2): + - libwebp/mux (1.5.0): - libwebp/demux - - libwebp/sharpyuv (1.3.2) - - libwebp/webp (1.3.2): + - libwebp/sharpyuv (1.5.0) + - libwebp/webp (1.5.0): - libwebp/sharpyuv - Mantle (2.2.0): - Mantle/extobjc (= 2.2.0) - Mantle/extobjc (2.2.0) - - nanopb (2.30910.0): - - nanopb/decode (= 2.30910.0) - - nanopb/encode (= 2.30910.0) - - nanopb/decode (2.30910.0) - - nanopb/encode (2.30910.0) + - nanopb (3.30910.0): + - nanopb/decode (= 3.30910.0) + - nanopb/encode (= 3.30910.0) + - nanopb/decode (3.30910.0) + - nanopb/encode (3.30910.0) - package_info_plus (0.4.5): - Flutter - path_provider_foundation (0.0.1): @@ -155,11 +157,9 @@ PODS: - PromisesObjC (2.4.0) - PromisesSwift (2.4.0): - PromisesObjC (= 2.4.0) - - rive_common (0.0.1): - - Flutter - - SDWebImage (5.20.0): - - SDWebImage/Core (= 5.20.0) - - SDWebImage/Core (5.20.0) + - SDWebImage (5.21.0): + - SDWebImage/Core (= 5.21.0) + - SDWebImage/Core (5.21.0) - SDWebImageWebPCoder (0.14.6): - libwebp (~> 1.0) - SDWebImage/Core (~> 5.17) @@ -169,11 +169,10 @@ PODS: - sqflite_darwin (0.0.4): - Flutter - FlutterMacOS - - Toast (4.1.1) - video_player_avfoundation (0.0.1): - Flutter - FlutterMacOS - - WebRTC-SDK (125.6422.04) + - WebRTC-SDK (125.6422.06) DEPENDENCIES: - camera_avfoundation (from `.symlinks/plugins/camera_avfoundation/ios`) @@ -195,7 +194,6 @@ DEPENDENCIES: - path_provider_foundation (from `.symlinks/plugins/path_provider_foundation/darwin`) - permission_handler_apple (from `.symlinks/plugins/permission_handler_apple/ios`) - photo_manager (from `.symlinks/plugins/photo_manager/ios`) - - rive_common (from `.symlinks/plugins/rive_common/ios`) - shared_preferences_foundation (from `.symlinks/plugins/shared_preferences_foundation/darwin`) - sqflite_darwin (from `.symlinks/plugins/sqflite_darwin/darwin`) - video_player_avfoundation (from `.symlinks/plugins/video_player_avfoundation/darwin`) @@ -203,6 +201,7 @@ DEPENDENCIES: SPEC REPOS: trunk: - AppAuth + - AppCheckCore - FBAEMKit - FBSDKCoreKit - FBSDKCoreKit_Basics @@ -227,7 +226,6 @@ SPEC REPOS: - PromisesSwift - SDWebImage - SDWebImageWebPCoder - - Toast - WebRTC-SDK EXTERNAL SOURCES: @@ -269,8 +267,6 @@ EXTERNAL SOURCES: :path: ".symlinks/plugins/permission_handler_apple/ios" photo_manager: :path: ".symlinks/plugins/photo_manager/ios" - rive_common: - :path: ".symlinks/plugins/rive_common/ios" shared_preferences_foundation: :path: ".symlinks/plugins/shared_preferences_foundation/darwin" sqflite_darwin: @@ -280,56 +276,55 @@ EXTERNAL SOURCES: SPEC CHECKSUMS: AppAuth: d4f13a8fe0baf391b2108511793e4b479691fb73 - camera_avfoundation: dd002b0330f4981e1bbcb46ae9b62829237459a4 - device_info_plus: bf2e3232933866d73fe290f2942f2156cdd10342 - emoji_picker_flutter: 8e50ec5caac456a23a78637e02c6293ea0ac8771 + AppCheckCore: cc8fd0a3a230ddd401f326489c99990b013f0c4f + camera_avfoundation: be3be85408cd4126f250386828e9b1dfa40ab436 + device_info_plus: 21fcca2080fbcd348be798aa36c3e5ed849eefbe + emoji_picker_flutter: ece213fc274bdddefb77d502d33080dc54e616cc FBAEMKit: 9900b2edd99a2d21629a6277e6166f14c6215799 FBSDKCoreKit: 0791f8f68a8630931a4c12aa23a56cc021551596 FBSDKCoreKit_Basics: 46d6b472c0dd0a5a7e972c025033d1c567f54eb4 FBSDKLoginKit: b4a4eba1d62eb452544411824f41689adabd5bd2 - Firebase: 0312a2352584f782ea56f66d91606891d4607f06 - firebase_core: a626d00494efa398e7c54f25f1454a64c8abf197 - firebase_crashlytics: 17e856fabec68d993662abaf2f6fe2413f0abece - FirebaseCore: 7ec4d0484817f12c3373955bc87762d96842d483 - FirebaseCoreExtension: 705ca5b14bf71d2564a0ddc677df1fc86ffa600f - FirebaseCoreInternal: df84dd300b561c27d5571684f389bf60b0a5c934 - FirebaseCrashlytics: 4b96efb0ce73b38b2a85e8b8bd1bd8f63f09d015 - FirebaseInstallations: 913cf60d0400ebd5d6b63a28b290372ab44590dd - FirebaseRemoteConfigInterop: 6efda51fb5e2f15b16585197e26eaa09574e8a4d - FirebaseSessions: dbd14adac65ce996228652c1fc3a3f576bdf3ecc + Firebase: 1fe1c0a7d9aaea32efe01fbea5f0ebd8d70e53a2 + firebase_core: 2d4534e7b489907dcede540c835b48981d890943 + firebase_crashlytics: 961a0812ba79ed8f89a8d5d1e3763daa6267a87a + FirebaseCore: 8344daef5e2661eb004b177488d6f9f0f24251b7 + FirebaseCoreExtension: 6f357679327f3614e995dc7cf3f2d600bdc774ac + FirebaseCoreInternal: ef4505d2afb1d0ebbc33162cb3795382904b5679 + FirebaseCrashlytics: 84b073c997235740e6a951b7ee49608932877e5c + FirebaseInstallations: 9980995bdd06ec8081dfb6ab364162bdd64245c3 + FirebaseRemoteConfigInterop: 85bdce8babed7814816496bb6f082bc05b0a45e1 + FirebaseSessions: 9b3b30947b97a15370e0902ee7a90f50ef60ead6 Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7 - flutter_facebook_auth: 66188df7905bfcaf3d6d2bd6527302c56448f04d - flutter_image_compress_common: ec1d45c362c9d30a3f6a0426c297f47c52007e3e - flutter_secure_storage: d33dac7ae2ea08509be337e775f6b59f1ff45f12 - flutter_webrtc: 75b868e4f9e817c7a9a42ca4b6169063de4eec9f - fluttertoast: e9a18c7be5413da53898f660530c56f35edfba9c - gal: 6a522c75909f1244732d4596d11d6a2f86ff37a5 - get_thumbnail_video: b9a180957daed3e9179e66268db51d8798e41f65 - google_sign_in_ios: 07375bfbf2620bc93a602c0e27160d6afc6ead38 - GoogleDataTransport: 6c09b596d841063d76d4288cc2d2f42cc36e1e2a - GoogleSignIn: d4281ab6cf21542b1cfaff85c191f230b399d2db - GoogleUtilities: ea963c370a38a8069cc5f7ba4ca849a60b6d7d15 + flutter_facebook_auth: 2f28c889d5727b4538ed8d25be3367092b2cbef7 + flutter_image_compress_common: 1697a328fd72bfb335507c6bca1a65fa5ad87df1 + flutter_secure_storage: 1ed9476fba7e7a782b22888f956cce43e2c62f13 + flutter_webrtc: 57f32415b8744e806f9c2a96ccdb60c6a627ba33 + fluttertoast: 2c67e14dce98bbdb200df9e1acf610d7a6264ea1 + gal: baecd024ebfd13c441269ca7404792a7152fde89 + get_thumbnail_video: 1a754d46b860dffefcc57b7290a43089cd5d7e58 + google_sign_in_ios: b48bb9af78576358a168361173155596c845f0b9 + GoogleDataTransport: aae35b7ea0c09004c3797d53c8c41f66f219d6a7 + GoogleSignIn: ce8c89bb9b37fb624b92e7514cc67335d1e277e4 + GoogleUtilities: 26a3abef001b6533cf678d3eb38fd3f614b7872d GTMAppAuth: f69bd07d68cd3b766125f7e072c45d7340dea0de GTMSessionFetcher: 5aea5ba6bd522a239e236100971f10cb71b96ab6 - image_picker_ios: c560581cceedb403a6ff17f2f816d7fea1421fc1 - libwebp: 1786c9f4ff8a279e4dac1e8f385004d5fc253009 + image_picker_ios: 7fe1ff8e34c1790d6fff70a32484959f563a928a + libwebp: 02b23773aedb6ff1fd38cec7a77b81414c6842a8 Mantle: c5aa8794a29a022dfbbfc9799af95f477a69b62d - nanopb: 438bc412db1928dac798aa6fd75726007be04262 - package_info_plus: c0502532a26c7662a62a356cebe2692ec5fe4ec4 - path_provider_foundation: 2b6b4c569c0fb62ec74538f866245ac84301af46 - permission_handler_apple: 9878588469a2b0d0fc1e048d9f43605f92e6cec2 - photo_manager: ff695c7a1dd5bc379974953a2b5c0a293f7c4c8a + nanopb: fad817b59e0457d11a5dfbde799381cd727c1275 + package_info_plus: af8e2ca6888548050f16fa2f1938db7b5a5df499 + path_provider_foundation: 080d55be775b7414fd5a5ef3ac137b97b097e564 + permission_handler_apple: 4ed2196e43d0651e8ff7ca3483a069d469701f2d + photo_manager: d2fbcc0f2d82458700ee6256a15018210a81d413 PromisesObjC: f5707f49cb48b9636751c5b2e7d227e43fba9f47 PromisesSwift: 9d77319bbe72ebf6d872900551f7eeba9bce2851 - rive_common: 4743dbfd2911c99066547a3c6454681e0fa907df - SDWebImage: 73c6079366fea25fa4bb9640d5fb58f0893facd8 + SDWebImage: f84b0feeb08d2d11e6a9b843cb06d75ebf5b8868 SDWebImageWebPCoder: e38c0a70396191361d60c092933e22c20d5b1380 - shared_preferences_foundation: fcdcbc04712aee1108ac7fda236f363274528f78 - sqflite_darwin: 5a7236e3b501866c1c9befc6771dfd73ffb8702d - Toast: 1f5ea13423a1e6674c4abdac5be53587ae481c4e - video_player_avfoundation: 7c6c11d8470e1675df7397027218274b6d2360b3 - WebRTC-SDK: c3d69a87e7185fad3568f6f3cff7c9ac5890acf3 + shared_preferences_foundation: 9e1978ff2562383bd5676f64ec4e9aa8fa06a6f7 + sqflite_darwin: 20b2a3a3b70e43edae938624ce550a3cbf66a3d0 + video_player_avfoundation: 2cef49524dd1f16c5300b9cd6efd9611ce03639b + WebRTC-SDK: 79942c006ea64f6fb48d7da8a4786dfc820bc1db PODFILE CHECKSUM: 0f528ada3f2727a63d1f98aee37c4c790a49a1aa -COCOAPODS: 1.15.2 +COCOAPODS: 1.16.2 diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj index 9b15969..0e13dcf 100644 --- a/ios/Runner.xcodeproj/project.pbxproj +++ b/ios/Runner.xcodeproj/project.pbxproj @@ -204,7 +204,7 @@ 3B06AD1E1E4923F5004D2608 /* Thin Binary */, 8A23D71B75A4EC858F3352E9 /* [CP] Embed Pods Frameworks */, E35502E9921AD26CB18E40D3 /* [CP] Copy Pods Resources */, - BA224EA4A99DDD095FA7D402 /* FlutterFire: "flutterfire upload-crashlytics-symbols" */, + B1FC0B2DF47C04D14213EE41 /* FlutterFire: "flutterfire upload-crashlytics-symbols" */, ); buildRules = ( ); @@ -347,7 +347,7 @@ shellPath = /bin/sh; shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build"; }; - BA224EA4A99DDD095FA7D402 /* FlutterFire: "flutterfire upload-crashlytics-symbols" */ = { + B1FC0B2DF47C04D14213EE41 /* FlutterFire: "flutterfire upload-crashlytics-symbols" */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( @@ -363,7 +363,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "\n#!/bin/bash\nPATH=\"${PATH}:$FLUTTER_ROOT/bin:$HOME/.pub-cache/bin\"\nflutterfire upload-crashlytics-symbols --upload-symbols-script-path=\"$PODS_ROOT/FirebaseCrashlytics/upload-symbols\" --platform=ios --apple-project-path=\"${SRCROOT}\" --env-platform-name=\"${PLATFORM_NAME}\" --env-configuration=\"${CONFIGURATION}\" --env-project-dir=\"${PROJECT_DIR}\" --env-built-products-dir=\"${BUILT_PRODUCTS_DIR}\" --env-dwarf-dsym-folder-path=\"${DWARF_DSYM_FOLDER_PATH}\" --env-dwarf-dsym-file-name=\"${DWARF_DSYM_FILE_NAME}\" --env-infoplist-path=\"${INFOPLIST_PATH}\" --default-config=default\n"; + shellScript = "\n#!/bin/bash\nPATH=\"${PATH}:$FLUTTER_ROOT/bin:${PUB_CACHE}/bin:$HOME/.pub-cache/bin\"\n\nif [ -z \"$PODS_ROOT\" ] || [ ! -d \"$PODS_ROOT/FirebaseCrashlytics\" ]; then\n # Cannot use \"BUILD_DIR%/Build/*\" as per Firebase documentation, it points to \"flutter-project/build/ios/*\" path which doesn't have run script\n DERIVED_DATA_PATH=$(echo \"$BUILD_ROOT\" | sed -E 's|(.*DerivedData/[^/]+).*|\\1|')\n PATH_TO_CRASHLYTICS_UPLOAD_SCRIPT=\"${DERIVED_DATA_PATH}/SourcePackages/checkouts/firebase-ios-sdk/Crashlytics/run\"\nelse\n PATH_TO_CRASHLYTICS_UPLOAD_SCRIPT=\"$PODS_ROOT/FirebaseCrashlytics/run\"\nfi\n\n# Command to upload symbols script used to upload symbols to Firebase server\nflutterfire upload-crashlytics-symbols --upload-symbols-script-path=\"$PATH_TO_CRASHLYTICS_UPLOAD_SCRIPT\" --platform=ios --apple-project-path=\"${SRCROOT}\" --env-platform-name=\"${PLATFORM_NAME}\" --env-configuration=\"${CONFIGURATION}\" --env-project-dir=\"${PROJECT_DIR}\" --env-built-products-dir=\"${BUILT_PRODUCTS_DIR}\" --env-dwarf-dsym-folder-path=\"${DWARF_DSYM_FOLDER_PATH}\" --env-dwarf-dsym-file-name=\"${DWARF_DSYM_FILE_NAME}\" --env-infoplist-path=\"${INFOPLIST_PATH}\" --default-config=default\n"; }; D95487B33638ECFC3E7AEFAB /* [CP] Check Pods Manifest.lock */ = { isa = PBXShellScriptBuildPhase; diff --git a/macos/Runner.xcodeproj/project.pbxproj b/macos/Runner.xcodeproj/project.pbxproj index 41f8068..5652c53 100644 --- a/macos/Runner.xcodeproj/project.pbxproj +++ b/macos/Runner.xcodeproj/project.pbxproj @@ -212,7 +212,7 @@ 33CC10EB2044A3C60003C045 /* Resources */, 33CC110E2044A8840003C045 /* Bundle Framework */, 3399D490228B24CF009A79C7 /* ShellScript */, - 1E62D124ECFFB4DA8DCA3FB3 /* FlutterFire: "flutterfire upload-crashlytics-symbols" */, + 461B1737D2DD0490D19C012B /* FlutterFire: "flutterfire upload-crashlytics-symbols" */, ); buildRules = ( ); @@ -296,8 +296,9 @@ /* End PBXResourcesBuildPhase section */ /* Begin PBXShellScriptBuildPhase section */ - 1E62D124ECFFB4DA8DCA3FB3 /* FlutterFire: "flutterfire upload-crashlytics-symbols" */ = { + 3399D490228B24CF009A79C7 /* ShellScript */ = { isa = PBXShellScriptBuildPhase; + alwaysOutOfDate = 1; buildActionMask = 2147483647; files = ( ); @@ -305,52 +306,51 @@ ); inputPaths = ( ); - name = "FlutterFire: \"flutterfire upload-crashlytics-symbols\""; outputFileListPaths = ( ); outputPaths = ( ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "\n#!/bin/bash\nPATH=\"${PATH}:$FLUTTER_ROOT/bin:$HOME/.pub-cache/bin\"\nflutterfire upload-crashlytics-symbols --upload-symbols-script-path=\"$PODS_ROOT/FirebaseCrashlytics/upload-symbols\" --platform=macos --apple-project-path=\"${SRCROOT}\" --env-platform-name=\"${PLATFORM_NAME}\" --env-configuration=\"${CONFIGURATION}\" --env-project-dir=\"${PROJECT_DIR}\" --env-built-products-dir=\"${BUILT_PRODUCTS_DIR}\" --env-dwarf-dsym-folder-path=\"${DWARF_DSYM_FOLDER_PATH}\" --env-dwarf-dsym-file-name=\"${DWARF_DSYM_FILE_NAME}\" --env-infoplist-path=\"${INFOPLIST_PATH}\" --default-config=default\n"; + shellScript = "echo \"$PRODUCT_NAME.app\" > \"$PROJECT_DIR\"/Flutter/ephemeral/.app_filename && \"$FLUTTER_ROOT\"/packages/flutter_tools/bin/macos_assemble.sh embed\n"; }; - 3399D490228B24CF009A79C7 /* ShellScript */ = { + 33CC111E2044C6BF0003C045 /* ShellScript */ = { isa = PBXShellScriptBuildPhase; - alwaysOutOfDate = 1; buildActionMask = 2147483647; files = ( ); inputFileListPaths = ( + Flutter/ephemeral/FlutterInputs.xcfilelist, ); inputPaths = ( + Flutter/ephemeral/tripwire, ); outputFileListPaths = ( + Flutter/ephemeral/FlutterOutputs.xcfilelist, ); outputPaths = ( ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "echo \"$PRODUCT_NAME.app\" > \"$PROJECT_DIR\"/Flutter/ephemeral/.app_filename && \"$FLUTTER_ROOT\"/packages/flutter_tools/bin/macos_assemble.sh embed\n"; + shellScript = "\"$FLUTTER_ROOT\"/packages/flutter_tools/bin/macos_assemble.sh && touch Flutter/ephemeral/tripwire"; }; - 33CC111E2044C6BF0003C045 /* ShellScript */ = { + 461B1737D2DD0490D19C012B /* FlutterFire: "flutterfire upload-crashlytics-symbols" */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( ); inputFileListPaths = ( - Flutter/ephemeral/FlutterInputs.xcfilelist, ); inputPaths = ( - Flutter/ephemeral/tripwire, ); + name = "FlutterFire: \"flutterfire upload-crashlytics-symbols\""; outputFileListPaths = ( - Flutter/ephemeral/FlutterOutputs.xcfilelist, ); outputPaths = ( ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "\"$FLUTTER_ROOT\"/packages/flutter_tools/bin/macos_assemble.sh && touch Flutter/ephemeral/tripwire"; + shellScript = "\n#!/bin/bash\nPATH=\"${PATH}:$FLUTTER_ROOT/bin:${PUB_CACHE}/bin:$HOME/.pub-cache/bin\"\n\nif [ -z \"$PODS_ROOT\" ] || [ ! -d \"$PODS_ROOT/FirebaseCrashlytics\" ]; then\n # Cannot use \"BUILD_DIR%/Build/*\" as per Firebase documentation, it points to \"flutter-project/build/ios/*\" path which doesn't have run script\n DERIVED_DATA_PATH=$(echo \"$BUILD_ROOT\" | sed -E 's|(.*DerivedData/[^/]+).*|\\1|')\n PATH_TO_CRASHLYTICS_UPLOAD_SCRIPT=\"${DERIVED_DATA_PATH}/SourcePackages/checkouts/firebase-ios-sdk/Crashlytics/run\"\nelse\n PATH_TO_CRASHLYTICS_UPLOAD_SCRIPT=\"$PODS_ROOT/FirebaseCrashlytics/run\"\nfi\n\n# Command to upload symbols script used to upload symbols to Firebase server\nflutterfire upload-crashlytics-symbols --upload-symbols-script-path=\"$PATH_TO_CRASHLYTICS_UPLOAD_SCRIPT\" --platform=macos --apple-project-path=\"${SRCROOT}\" --env-platform-name=\"${PLATFORM_NAME}\" --env-configuration=\"${CONFIGURATION}\" --env-project-dir=\"${PROJECT_DIR}\" --env-built-products-dir=\"${BUILT_PRODUCTS_DIR}\" --env-dwarf-dsym-folder-path=\"${DWARF_DSYM_FOLDER_PATH}\" --env-dwarf-dsym-file-name=\"${DWARF_DSYM_FILE_NAME}\" --env-infoplist-path=\"${INFOPLIST_PATH}\" --default-config=default\n"; }; /* End PBXShellScriptBuildPhase section */ diff --git a/pubspec.lock b/pubspec.lock index e944f58..16f8964 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -5,31 +5,26 @@ packages: dependency: transitive description: name: _fe_analyzer_shared - sha256: "03f6da266a27a4538a69295ec142cb5717d7d4e5727b84658b63e1e1509bac9c" + sha256: e55636ed79578b9abca5fecf9437947798f5ef7456308b5cb85720b793eac92f url: "https://pub.dev" source: hosted - version: "79.0.0" + version: "82.0.0" _flutterfire_internals: dependency: transitive description: name: _flutterfire_internals - sha256: "37a42d06068e2fe3deddb2da079a8c4d105f241225ba27b7122b37e9865fd8f7" + sha256: de9ecbb3ddafd446095f7e833c853aff2fa1682b017921fe63a833f9d6f0e422 url: "https://pub.dev" source: hosted - version: "1.3.35" - _macros: - dependency: transitive - description: dart - source: sdk - version: "0.3.3" + version: "1.3.54" analyzer: dependency: transitive description: name: analyzer - sha256: c9040fc56483c22a5e04a9f6a251313118b1a3c42423770623128fa484115643 + sha256: "13c1e6c6fd460522ea840abec3f677cc226f5fec7872c04ad7b425517ccf54f7" url: "https://pub.dev" source: hosted - version: "7.2.0" + version: "7.4.4" ansicolor: dependency: transitive description: @@ -42,10 +37,10 @@ packages: dependency: transitive description: name: args - sha256: bf9f5caeea8d8fe6721a9c358dd8a5c1947b27f1cfaa18b39c301273594919e6 + sha256: d0481093c50b1da8910eb0bb301626d4d8eb7284aa739614d2b394ee09e3ea04 url: "https://pub.dev" source: hosted - version: "2.6.0" + version: "2.7.0" async: dependency: transitive description: @@ -58,18 +53,18 @@ packages: dependency: "direct main" description: name: auto_route - sha256: "1d1bd908a1fec327719326d5d0791edd37f16caff6493c01003689fb03315ad7" + sha256: "89bc5d17d8c575399891194b8cd02b39f52a8512c730052f17ebe443cdcb9109" url: "https://pub.dev" source: hosted - version: "9.3.0+1" + version: "10.0.1" auto_route_generator: dependency: "direct dev" description: name: auto_route_generator - sha256: c2e359d8932986d4d1bcad7a428143f81384ce10fef8d4aa5bc29e1f83766a46 + sha256: "8e622d26dc6be4bf496d47969e3e9ba555c3abcf2290da6abfa43cbd4f57fa52" url: "https://pub.dev" source: hosted - version: "9.3.1" + version: "10.0.1" bloc: dependency: transitive description: @@ -114,26 +109,26 @@ packages: dependency: transitive description: name: build_daemon - sha256: "294a2edaf4814a378725bfe6358210196f5ea37af89ecd81bfa32960113d4948" + sha256: "8e928697a82be082206edb0b9c99c5a4ad6bc31c9e9b8b2f291ae65cd4a25daa" url: "https://pub.dev" source: hosted - version: "4.0.3" + version: "4.0.4" build_resolvers: dependency: transitive description: name: build_resolvers - sha256: "99d3980049739a985cf9b21f30881f46db3ebc62c5b8d5e60e27440876b1ba1e" + sha256: b9e4fda21d846e192628e7a4f6deda6888c36b5b69ba02ff291a01fd529140f0 url: "https://pub.dev" source: hosted - version: "2.4.3" + version: "2.4.4" build_runner: dependency: "direct dev" description: name: build_runner - sha256: "74691599a5bc750dc96a6b4bfd48f7d9d66453eab04c7f4063134800d6a5c573" + sha256: "058fe9dce1de7d69c4b84fada934df3e0153dd000758c4d65964d0166779aa99" url: "https://pub.dev" source: hosted - version: "2.4.14" + version: "2.4.15" build_runner_core: dependency: transitive description: @@ -154,10 +149,10 @@ packages: dependency: transitive description: name: built_value - sha256: "28a712df2576b63c6c005c465989a348604960c0958d28be5303ba9baa841ac2" + sha256: ea90e81dc4a25a043d9bee692d20ed6d1c4a1662a28c03a96417446c093ed6b4 url: "https://pub.dev" source: hosted - version: "8.9.3" + version: "8.9.5" cached_network_image: dependency: "direct main" description: @@ -186,34 +181,34 @@ packages: dependency: "direct main" description: name: camera - sha256: "26ff41045772153f222ffffecba711a206f670f5834d40ebf5eed3811692f167" + sha256: "413d2b34fe28496c35c69ede5b232fb9dd5ca2c3a4cb606b14efc1c7546cc8cb" url: "https://pub.dev" source: hosted - version: "0.11.0+2" + version: "0.11.1" camera_android_camerax: dependency: transitive description: name: camera_android_camerax - sha256: "7cc6adf1868bdcf4e63a56b24b41692dfbad2bec1cdceea451c77798f6a605c3" + sha256: f0dcbce91623f75030840609de9b64d0d73f86df279c6e9588c1501245a05eb2 url: "https://pub.dev" source: hosted - version: "0.6.13" + version: "0.6.15+2" camera_avfoundation: dependency: transitive description: name: camera_avfoundation - sha256: "3f81ee3e88a79b0b010f0233d42625926299551b05d5dc995267a0b35bc33247" + sha256: a33cd9a250296271cdf556891b7c0986a93772426f286595eccd5f45b185933c url: "https://pub.dev" source: hosted - version: "0.9.18" + version: "0.9.18+14" camera_platform_interface: dependency: transitive description: name: camera_platform_interface - sha256: "953e7baed3a7c8fae92f7200afeb2be503ff1a17c3b4e4ed7b76f008c2810a31" + sha256: "2f757024a48696ff4814a789b0bd90f5660c0fb25f393ab4564fb483327930e2" url: "https://pub.dev" source: hosted - version: "2.9.0" + version: "2.10.0" camera_web: dependency: transitive description: @@ -322,18 +317,18 @@ packages: dependency: transitive description: name: dart_webrtc - sha256: e65506edb452148220efab53d8d2f8bb9d827bd8bcd53cf3a3e6df70b27f3d86 + sha256: "5b76fd85ac95d6f5dee3e7d7de8d4b51bfbec1dc73804647c6aebb52d6297116" url: "https://pub.dev" source: hosted - version: "1.4.10" + version: "1.5.3+hotfix.2" device_info_plus: dependency: "direct main" description: name: device_info_plus - sha256: b37d37c2f912ad4e8ec694187de87d05de2a3cb82b465ff1f65f65a2d05de544 + sha256: "0c6396126421b590089447154c5f98a5de423b70cfb15b1578fd018843ee6f53" url: "https://pub.dev" source: hosted - version: "11.2.1" + version: "11.4.0" device_info_plus_platform_interface: dependency: transitive description: @@ -346,18 +341,18 @@ packages: dependency: "direct main" description: name: dio - sha256: "5598aa796bbf4699afd5c67c0f5f6e2ed542afc956884b9cd58c306966efc260" + sha256: "253a18bbd4851fecba42f7343a1df3a9a4c1d31a2c1b37e221086b4fa8c8dbc9" url: "https://pub.dev" source: hosted - version: "5.7.0" + version: "5.8.0+1" dio_web_adapter: dependency: transitive description: name: dio_web_adapter - sha256: "33259a9276d6cea88774a0000cfae0d861003497755969c92faa223108620dc8" + sha256: "7586e476d70caecaf1686d21eee7247ea43ef5c345eab9e0cc3583ff13378d78" url: "https://pub.dev" source: hosted - version: "2.0.0" + version: "2.1.1" emoji_picker_flutter: dependency: "direct main" description: @@ -386,10 +381,10 @@ packages: dependency: transitive description: name: ffi - sha256: "16ed7b077ef01ad6170a3d0c57caa4a112a38d7a2ed5602e0aca9ca6f3d98da6" + sha256: "289279317b4b16eb2bb7e271abccd4bf84ec9bdcbe999e278a94b804f5630418" url: "https://pub.dev" source: hosted - version: "2.1.3" + version: "2.1.4" file: dependency: transitive description: @@ -426,18 +421,18 @@ packages: dependency: transitive description: name: file_selector_windows - sha256: "8f5d2f6590d51ecd9179ba39c64f722edc15226cc93dcc8698466ad36a4a85a4" + sha256: "320fcfb6f33caa90f0b58380489fc5ac05d99ee94b61aa96ec2bff0ba81d3c2b" url: "https://pub.dev" source: hosted - version: "0.9.3+3" + version: "0.9.3+4" firebase_core: dependency: "direct main" description: name: firebase_core - sha256: "26de145bb9688a90962faec6f838247377b0b0d32cc0abecd9a4e43525fc856c" + sha256: "017d17d9915670e6117497e640b2859e0b868026ea36bf3a57feb28c3b97debe" url: "https://pub.dev" source: hosted - version: "2.32.0" + version: "3.13.0" firebase_core_platform_interface: dependency: transitive description: @@ -450,26 +445,26 @@ packages: dependency: transitive description: name: firebase_core_web - sha256: fbc008cf390d909b823763064b63afefe9f02d8afdb13eb3f485b871afee956b + sha256: "129a34d1e0fb62e2b488d988a1fc26cc15636357e50944ffee2862efe8929b23" url: "https://pub.dev" source: hosted - version: "2.19.0" + version: "2.22.0" firebase_crashlytics: dependency: "direct main" description: name: firebase_crashlytics - sha256: "9897c01efaa950d2f6da8317d12452749a74dc45f33b46390a14cfe28067f271" + sha256: f3fa4a17c2f061b16b2e3ac7aaed889ae954b8952d0fd3e0009a9870cde7bbd2 url: "https://pub.dev" source: hosted - version: "3.5.7" + version: "4.3.5" firebase_crashlytics_platform_interface: dependency: transitive description: name: firebase_crashlytics_platform_interface - sha256: "16a71e08fbf6e00382816e1b13397898c29a54fa0ad969c2c2a3b82a704877f0" + sha256: cedfbe39927711c0e56fc38bfecbd89e17816b21698a3d88d63298c530ed375c url: "https://pub.dev" source: hosted - version: "3.6.35" + version: "3.8.5" fixnum: dependency: transitive description: @@ -482,18 +477,18 @@ packages: dependency: "direct main" description: name: flex_color_scheme - sha256: "32914024a4f404d90ff449f58d279191675b28e7c08824046baf06826e99d984" + sha256: "3344f8f6536c6ce0473b98e9f084ef80ca89024ad3b454f9c32cf840206f4387" url: "https://pub.dev" source: hosted - version: "7.3.1" + version: "8.2.0" flex_seed_scheme: dependency: transitive description: name: flex_seed_scheme - sha256: "4cee2f1d07259f77e8b36f4ec5f35499d19e74e17c7dce5b819554914082bc01" + sha256: b06d8b367b84cbf7ca5c5603c858fa5edae88486c4e4da79ac1044d73b6c62ec url: "https://pub.dev" source: hosted - version: "1.5.0" + version: "3.5.1" flutter: dependency: "direct main" description: flutter @@ -503,18 +498,18 @@ packages: dependency: "direct main" description: name: flutter_bloc - sha256: "153856bdaac302bbdc58a1d1403d50c40557254aa05eaeed40515d88a25a526b" + sha256: "1046d719fbdf230330d3443187cc33cc11963d15c9089f6cc56faa42a4c5f0cc" url: "https://pub.dev" source: hosted - version: "9.0.0" + version: "9.1.0" flutter_blurhash: dependency: "direct main" description: name: flutter_blurhash - sha256: "5e67678e479ac639069d7af1e133f4a4702311491188ff3e0227486430db0c06" + sha256: e97b9aff13b9930bbaa74d0d899fec76e3f320aba3190322dcc5d32104e3d25d url: "https://pub.dev" source: hosted - version: "0.8.2" + version: "0.9.1" flutter_cache_manager: dependency: transitive description: @@ -559,10 +554,10 @@ packages: dependency: transitive description: name: flutter_image_compress_common - sha256: "7f79bc6c8a363063620b4e372fa86bc691e1cb28e58048cd38e030692fbd99ee" + sha256: c5c5d50c15e97dd7dc72ff96bd7077b9f791932f2076c5c5b6c43f2c88607bfb url: "https://pub.dev" source: hosted - version: "1.0.5" + version: "1.0.6" flutter_image_compress_macos: dependency: transitive description: @@ -599,10 +594,10 @@ packages: dependency: "direct dev" description: name: flutter_lints - sha256: "9e8c3858111da373efc5aa341de011d9bd23e2c5c5e0c62bccf32438e192d7b1" + sha256: "5398f14efa795ffb7a33e9b6a08798b26a180edac4ad7db3f231e40f82ce11e1" url: "https://pub.dev" source: hosted - version: "3.0.2" + version: "5.0.0" flutter_localizations: dependency: "direct main" description: flutter @@ -612,10 +607,10 @@ packages: dependency: transitive description: name: flutter_plugin_android_lifecycle - sha256: "615a505aef59b151b46bbeef55b36ce2b6ed299d160c51d84281946f0aa0ce0e" + sha256: f948e346c12f8d5480d2825e03de228d0eb8c3a737e4cdaa122267b89c022b5e url: "https://pub.dev" source: hosted - version: "2.0.24" + version: "2.0.28" flutter_secure_storage: dependency: transitive description: @@ -628,10 +623,10 @@ packages: dependency: transitive description: name: flutter_secure_storage_linux - sha256: bf7404619d7ab5c0a1151d7c4e802edad8f33535abfbeff2f9e1fe1274e2d705 + sha256: be76c1d24a97d0b98f8b54bce6b481a380a6590df992d0098f868ad54dc8f688 url: "https://pub.dev" source: hosted - version: "1.2.2" + version: "1.2.3" flutter_secure_storage_macos: dependency: transitive description: @@ -678,18 +673,18 @@ packages: dependency: "direct main" description: name: flutter_webrtc - sha256: f6800cc2af79018c12e955ddf8ad007891fdfbb8199b0ce3dccd0977ed2add9c + sha256: "23af761bb812e6f32c34263e62df48aaf26bb08582c8be8cc3170e2a018d1155" url: "https://pub.dev" source: hosted - version: "0.11.7" + version: "0.13.1+hotfix.1" fluttertoast: dependency: "direct main" description: name: fluttertoast - sha256: "24467dc20bbe49fd63e57d8e190798c4d22cbbdac30e54209d153a15273721d1" + sha256: "25e51620424d92d3db3832464774a6143b5053f15e382d8ffbfd40b6e795dcf1" url: "https://pub.dev" source: hosted - version: "8.2.10" + version: "8.2.12" font_awesome_flutter: dependency: "direct main" description: @@ -702,18 +697,18 @@ packages: dependency: "direct dev" description: name: freezed - sha256: "59a584c24b3acdc5250bb856d0d3e9c0b798ed14a4af1ddb7dc1c7b41df91c9c" + sha256: "6022db4c7bfa626841b2a10f34dd1e1b68e8f8f9650db6112dcdeeca45ca793c" url: "https://pub.dev" source: hosted - version: "2.5.8" + version: "3.0.6" freezed_annotation: dependency: "direct main" description: name: freezed_annotation - sha256: c2e2d632dd9b8a2b7751117abcfc2b4888ecfe181bd9fca7170d9ef02e595fe2 + sha256: c87ff004c8aa6af2d531668b46a4ea379f7191dc6dfa066acd53d506da6e044b url: "https://pub.dev" source: hosted - version: "2.4.4" + version: "3.0.0" frontend_server_client: dependency: transitive description: @@ -742,66 +737,66 @@ packages: dependency: transitive description: name: glob - sha256: "0e7014b3b7d4dac1ca4d6114f82bf1782ee86745b9b42a92c9289c23d8a0ab63" + sha256: c3f1ee72c96f8f78935e18aa8cecced9ab132419e8625dc187e1c2408efc20de url: "https://pub.dev" source: hosted - version: "2.1.2" + version: "2.1.3" google_fonts: dependency: "direct main" description: name: google_fonts - sha256: "2776c66b3e97c6cdd58d1bd3281548b074b64f1fd5c8f82391f7456e38849567" + sha256: b1ac0fe2832c9cc95e5e88b57d627c5e68c223b9657f4b96e1487aa9098c7b82 url: "https://pub.dev" source: hosted - version: "4.0.5" + version: "6.2.1" google_identity_services_web: dependency: transitive description: name: google_identity_services_web - sha256: "55580f436822d64c8ff9a77e37d61f5fb1e6c7ec9d632a43ee324e2a05c3c6c9" + sha256: "5d187c46dc59e02646e10fe82665fc3884a9b71bc1c90c2b8b749316d33ee454" url: "https://pub.dev" source: hosted - version: "0.3.3" + version: "0.3.3+1" google_sign_in: dependency: "direct main" description: name: google_sign_in - sha256: fad6ddc80c427b0bba705f2116204ce1173e09cf299f85e053d57a55e5b2dd56 + sha256: d0a2c3bcb06e607bb11e4daca48bd4b6120f0bbc4015ccebbe757d24ea60ed2a url: "https://pub.dev" source: hosted - version: "6.2.2" + version: "6.3.0" google_sign_in_android: dependency: transitive description: name: google_sign_in_android - sha256: "3b96f9b6cf61915f73cbe1218a192623e296a9b8b31965702503649477761e36" + sha256: d5e23c56a4b84b6427552f1cf3f98f716db3b1d1a647f16b96dbb5b93afa2805 url: "https://pub.dev" source: hosted - version: "6.1.34" + version: "6.2.1" google_sign_in_ios: dependency: transitive description: name: google_sign_in_ios - sha256: "83f015169102df1ab2905cf8abd8934e28f87db9ace7a5fa676998842fed228a" + sha256: "102005f498ce18442e7158f6791033bbc15ad2dcc0afa4cf4752e2722a516c96" url: "https://pub.dev" source: hosted - version: "5.7.8" + version: "5.9.0" google_sign_in_platform_interface: dependency: transitive description: name: google_sign_in_platform_interface - sha256: "1f6e5787d7a120cc0359ddf315c92309069171306242e181c09472d1b00a2971" + sha256: "5f6f79cf139c197261adb6ac024577518ae48fdff8e53205c5373b5f6430a8aa" url: "https://pub.dev" source: hosted - version: "2.4.5" + version: "2.5.0" google_sign_in_web: dependency: transitive description: name: google_sign_in_web - sha256: ada595df6c30cead48e66b1f3a050edf0c5cf2ba60c185d69690e08adcc6281b + sha256: "460547beb4962b7623ac0fb8122d6b8268c951cf0b646dd150d60498430e4ded" url: "https://pub.dev" source: hosted - version: "0.12.4+3" + version: "0.12.4+4" graphs: dependency: transitive description: @@ -822,18 +817,18 @@ packages: dependency: transitive description: name: html - sha256: "1fc58edeaec4307368c60d59b7e15b9d658b57d7f3125098b6294153c75337ec" + sha256: "6d1264f2dffa1b1101c25a91dff0dc2daee4c18e87cd8538729773c073dbf602" url: "https://pub.dev" source: hosted - version: "0.15.5" + version: "0.15.6" http: dependency: transitive description: name: http - sha256: b9c29a161230ee03d3ccf545097fccd9b87a5264228c5d348202e0f0c28f9010 + sha256: fe7ab022b76f3034adc518fb6ea04a82387620e19977665ea18d30a1cf43442f url: "https://pub.dev" source: hosted - version: "1.2.2" + version: "1.3.0" http_multi_server: dependency: transitive description: @@ -862,10 +857,10 @@ packages: dependency: transitive description: name: image_picker_android - sha256: b62d34a506e12bb965e824b6db4fbf709ee4589cf5d3e99b45ab2287b008ee0c + sha256: "317a5d961cec5b34e777b9252393f2afbd23084aa6e60fcf601dcf6341b9ebeb" url: "https://pub.dev" source: hosted - version: "0.8.12+20" + version: "0.8.12+23" image_picker_for_web: dependency: transitive description: @@ -886,18 +881,18 @@ packages: dependency: transitive description: name: image_picker_linux - sha256: "4ed1d9bb36f7cd60aa6e6cd479779cc56a4cb4e4de8f49d487b1aaad831300fa" + sha256: "34a65f6740df08bbbeb0a1abd8e6d32107941fd4868f67a507b25601651022c9" url: "https://pub.dev" source: hosted - version: "0.2.1+1" + version: "0.2.1+2" image_picker_macos: dependency: transitive description: name: image_picker_macos - sha256: "3f5ad1e8112a9a6111c46d0b57a7be2286a9a07fc6e1976fdf5be2bd31d4ff62" + sha256: "1b90ebbd9dcf98fb6c1d01427e49a55bd96b5d67b8c67cf955d60a5de74207c1" url: "https://pub.dev" source: hosted - version: "0.2.1+1" + version: "0.2.1+2" image_picker_platform_interface: dependency: transitive description: @@ -950,10 +945,10 @@ packages: dependency: "direct dev" description: name: json_serializable - sha256: b0a98230538fe5d0b60a22fb6bf1b6cb03471b53e3324ff6069c591679dd59c9 + sha256: c50ef5fc083d5b5e12eef489503ba3bf5ccc899e487d691584699b4bdefeea8c url: "https://pub.dev" source: hosted - version: "6.9.3" + version: "6.9.5" leak_tracker: dependency: transitive description: @@ -982,10 +977,10 @@ packages: dependency: transitive description: name: lints - sha256: cbf8d4b858bb0134ef3ef87841abdf8d63bfc255c266b7bf6b39daa1085c4290 + sha256: c35bb79562d980e9a453fc715854e1ed39e24e7d0297a880ef54e17f9874a9d7 url: "https://pub.dev" source: hosted - version: "3.0.0" + version: "5.1.1" logger: dependency: "direct main" description: @@ -1002,14 +997,6 @@ packages: url: "https://pub.dev" source: hosted version: "1.3.0" - macros: - dependency: transitive - description: - name: macros - sha256: "1d9e801cd66f7ea3663c45fc708450db1fa57f988142c64289142c9b7ee80656" - url: "https://pub.dev" - source: hosted - version: "0.1.3-main.0" matcher: dependency: transitive description: @@ -1046,10 +1033,10 @@ packages: dependency: "direct main" description: name: mockito - sha256: f99d8d072e249f719a5531735d146d8cf04c580d93920b04de75bef6dfb2daf6 + sha256: "4546eac99e8967ea91bae633d2ca7698181d008e95fa4627330cf903d573277a" url: "https://pub.dev" source: hosted - version: "5.4.5" + version: "5.4.6" nested: dependency: transitive description: @@ -1070,26 +1057,26 @@ packages: dependency: transitive description: name: package_config - sha256: "92d4488434b520a62570293fbd33bb556c7d49230791c1b4bbd973baf6d2dc67" + sha256: f096c55ebb7deb7e384101542bfba8c52696c1b56fca2eb62827989ef2353bbc url: "https://pub.dev" source: hosted - version: "2.1.1" + version: "2.2.0" package_info_plus: dependency: "direct dev" description: name: package_info_plus - sha256: "739e0a5c3c4055152520fa321d0645ee98e932718b4c8efeeb51451968fe0790" + sha256: "7976bfe4c583170d6cdc7077e3237560b364149fcd268b5f53d95a991963b191" url: "https://pub.dev" source: hosted - version: "8.1.3" + version: "8.3.0" package_info_plus_platform_interface: dependency: transitive description: name: package_info_plus_platform_interface - sha256: a5ef9986efc7bf772f2696183a3992615baa76c1ffb1189318dd8803778fb05b + sha256: "6c935fb612dff8e3cc9632c2b301720c77450a126114126ffaafe28d2e87956c" url: "https://pub.dev" source: hosted - version: "3.0.2" + version: "3.2.0" path: dependency: "direct main" description: @@ -1110,10 +1097,10 @@ packages: dependency: transitive description: name: path_provider_android - sha256: "4adf4fd5423ec60a29506c76581bc05854c55e3a0b72d35bb28d661c9686edf2" + sha256: d0d310befe2c8ab9e7f393288ccbb11b60c019c6b5afc21973eeee4dda2b35e9 url: "https://pub.dev" source: hosted - version: "2.2.15" + version: "2.2.17" path_provider_foundation: dependency: transitive description: @@ -1150,26 +1137,26 @@ packages: dependency: "direct main" description: name: permission_handler - sha256: "18bf33f7fefbd812f37e72091a15575e72d5318854877e0e4035a24ac1113ecb" + sha256: "2d070d8684b68efb580a5997eb62f675e8a885ef0be6e754fb9ef489c177470f" url: "https://pub.dev" source: hosted - version: "11.3.1" + version: "12.0.0+1" permission_handler_android: dependency: transitive description: name: permission_handler_android - sha256: "71bbecfee799e65aff7c744761a57e817e73b738fedf62ab7afd5593da21f9f1" + sha256: "1e3bc410ca1bf84662104b100eb126e066cb55791b7451307f9708d4007350e6" url: "https://pub.dev" source: hosted - version: "12.0.13" + version: "13.0.1" permission_handler_apple: dependency: transitive description: name: permission_handler_apple - sha256: e6f6d73b12438ef13e648c4ae56bd106ec60d17e90a59c4545db6781229082a0 + sha256: f000131e755c54cf4d84a5d8bd6e4149e262cc31c5a8b1d698de1ac85fa41023 url: "https://pub.dev" source: hosted - version: "9.4.5" + version: "9.4.7" permission_handler_html: dependency: transitive description: @@ -1182,10 +1169,10 @@ packages: dependency: transitive description: name: permission_handler_platform_interface - sha256: e9c8eadee926c4532d0305dff94b85bf961f16759c3af791486613152af4b4f9 + sha256: eb99b295153abce5d683cac8c02e22faab63e50679b937fa1bf67d58bb282878 url: "https://pub.dev" source: hosted - version: "4.2.3" + version: "4.3.0" permission_handler_windows: dependency: transitive description: @@ -1198,18 +1185,18 @@ packages: dependency: transitive description: name: petitparser - sha256: c15605cd28af66339f8eb6fbe0e541bfe2d1b72d5825efc6598f3e0a31b9ad27 + sha256: "07c8f0b1913bcde1ff0d26e57ace2f3012ccbf2b204e070290dad3bb22797646" url: "https://pub.dev" source: hosted - version: "6.0.2" + version: "6.1.0" photo_manager: dependency: "direct main" description: name: photo_manager - sha256: dc26184676b26d722d656073ca8fe29203d7631ec613aed1a9679de3aa1f52c2 + sha256: "0bc7548fd3111eb93a3b0abf1c57364e40aeda32512c100085a48dade60e574f" url: "https://pub.dev" source: hosted - version: "3.6.3" + version: "3.6.4" pinenacl: dependency: "direct dev" description: @@ -1226,14 +1213,6 @@ packages: url: "https://pub.dev" source: hosted version: "3.1.6" - platform_detect: - dependency: transitive - description: - name: platform_detect - sha256: a62f99417fc4fa2d099ce0ccdbb1bd3977920f2a64292c326271f049d4bc3a4f - url: "https://pub.dev" - source: hosted - version: "2.1.0" plugin_platform_interface: dependency: transitive description: @@ -1254,18 +1233,18 @@ packages: dependency: "direct main" description: name: provider - sha256: c8a055ee5ce3fd98d6fc872478b03823ffdb448699c6ebdbbc71d59b596fd48c + sha256: "489024f942069c2920c844ee18bb3d467c69e48955a4f32d1677f71be103e310" url: "https://pub.dev" source: hosted - version: "6.1.2" + version: "6.1.4" pub_semver: dependency: transitive description: name: pub_semver - sha256: "7b3cfbf654f3edd0c6298ecd5be782ce997ddf0e00531b9464b55245185bbbbd" + sha256: "5bfcf68ca79ef689f8990d1160781b4bad40a3bd5e5218ad4076ddb7f4081585" url: "https://pub.dev" source: hosted - version: "2.1.5" + version: "2.2.0" pubspec_parse: dependency: transitive description: @@ -1294,18 +1273,18 @@ packages: dependency: "direct main" description: name: shared_preferences - sha256: a752ce92ea7540fc35a0d19722816e04d0e72828a4200e83a98cf1a1eb524c9a + sha256: "6e8bf70b7fef813df4e9a36f658ac46d107db4b4cfe1048b477d4e453a8159f5" url: "https://pub.dev" source: hosted - version: "2.3.5" + version: "2.5.3" shared_preferences_android: dependency: transitive description: name: shared_preferences_android - sha256: "138b7bbbc7f59c56236e426c37afb8f78cbc57b094ac64c440e0bb90e380a4f5" + sha256: "20cbd561f743a342c76c151d6ddb93a9ce6005751e7aa458baad3858bfbfb6ac" url: "https://pub.dev" source: hosted - version: "2.4.2" + version: "2.4.10" shared_preferences_foundation: dependency: transitive description: @@ -1334,10 +1313,10 @@ packages: dependency: transitive description: name: shared_preferences_web - sha256: d2ca4132d3946fec2184261726b355836a82c33d7d5b67af32692aff18a4684e + sha256: c49bd060261c9a3f0ff445892695d6212ff603ef3115edbb448509d407600019 url: "https://pub.dev" source: hosted - version: "2.4.2" + version: "2.4.3" shared_preferences_windows: dependency: transitive description: @@ -1358,10 +1337,10 @@ packages: dependency: transitive description: name: shelf_web_socket - sha256: cc36c297b52866d203dbf9332263c94becc2fe0ceaa9681d07b6ef9807023b67 + sha256: "3632775c8e90d6c9712f883e633716432a27758216dfb61bd86a8321c0580925" url: "https://pub.dev" source: hosted - version: "2.0.1" + version: "3.0.0" sky_engine: dependency: transitive description: flutter @@ -1403,34 +1382,34 @@ packages: dependency: transitive description: name: sqflite - sha256: "2d7299468485dca85efeeadf5d38986909c5eb0cd71fd3db2c2f000e6c9454bb" + sha256: e2297b1da52f127bc7a3da11439985d9b536f75070f3325e62ada69a5c585d03 url: "https://pub.dev" source: hosted - version: "2.4.1" + version: "2.4.2" sqflite_android: dependency: transitive description: name: sqflite_android - sha256: "78f489aab276260cdd26676d2169446c7ecd3484bbd5fead4ca14f3ed4dd9ee3" + sha256: "2b3070c5fa881839f8b402ee4a39c1b4d561704d4ebbbcfb808a119bc2a1701b" url: "https://pub.dev" source: hosted - version: "2.4.0" + version: "2.4.1" sqflite_common: dependency: transitive description: name: sqflite_common - sha256: "761b9740ecbd4d3e66b8916d784e581861fd3c3553eda85e167bc49fdb68f709" + sha256: "84731e8bfd8303a3389903e01fb2141b6e59b5973cacbb0929021df08dddbe8b" url: "https://pub.dev" source: hosted - version: "2.5.4+6" + version: "2.5.5" sqflite_darwin: dependency: transitive description: name: sqflite_darwin - sha256: "22adfd9a2c7d634041e96d6241e6e1c8138ca6817018afc5d443fef91dcefa9c" + sha256: "279832e5cde3fe99e8571879498c9211f3ca6391b0d818df4e17d9fff5c6ccb3" url: "https://pub.dev" source: hosted - version: "2.4.1+1" + version: "2.4.2" sqflite_platform_interface: dependency: transitive description: @@ -1475,26 +1454,26 @@ packages: dependency: transitive description: name: synchronized - sha256: "69fe30f3a8b04a0be0c15ae6490fc859a78ef4c43ae2dd5e8a623d45bfcf9225" + sha256: "0669c70faae6270521ee4f05bffd2919892d42d1276e6c495be80174b6bc0ef6" url: "https://pub.dev" source: hosted - version: "3.3.0+3" + version: "3.3.1" talker: dependency: "direct main" description: name: talker - sha256: "4c3b9b7b8c8882fc30253bbbe7c75d2f68d63ea35b7c1b6be2debe4a323c2ec9" + sha256: cbea2c5a10a3d9225e58b5fef4092d6ec00f1fcda43f92a33dfbab1ea7ffca79 url: "https://pub.dev" source: hosted - version: "4.6.4" + version: "4.7.2" talker_logger: dependency: transitive description: name: talker_logger - sha256: "27e4d0ba5c6950643a2500ad6c2e189099d0b9912f67389a49155e48fc2d9a55" + sha256: "416b4d726358764c68c2de23c11bf9f146f2608ac244ec2ed9da741f89c49a6e" url: "https://pub.dev" source: hosted - version: "4.6.4" + version: "4.7.2" term_glyph: dependency: transitive description: @@ -1563,42 +1542,42 @@ packages: dependency: "direct main" description: name: video_player - sha256: "4a8c3492d734f7c39c2588a3206707a05ee80cef52e8c7f3b2078d430c84bc17" + sha256: "7d78f0cfaddc8c19d4cb2d3bebe1bfef11f2103b0a03e5398b303a1bf65eeb14" url: "https://pub.dev" source: hosted - version: "2.9.2" + version: "2.9.5" video_player_android: dependency: transitive description: name: video_player_android - sha256: "7018dbcb395e2bca0b9a898e73989e67c0c4a5db269528e1b036ca38bcca0d0b" + sha256: ae7d4f1b41e3ac6d24dd9b9d5d6831b52d74a61bdd90a7a6262a33d8bb97c29a url: "https://pub.dev" source: hosted - version: "2.7.17" + version: "2.8.2" video_player_avfoundation: dependency: transitive description: name: video_player_avfoundation - sha256: "8a4e73a3faf2b13512978a43cf1cdda66feeeb900a0527f1fbfd7b19cf3458d3" + sha256: "9ee764e5cd2fc1e10911ae8ad588e1a19db3b6aa9a6eb53c127c42d3a3c3f22f" url: "https://pub.dev" source: hosted - version: "2.6.7" + version: "2.7.1" video_player_platform_interface: dependency: transitive description: name: video_player_platform_interface - sha256: "229d7642ccd9f3dc4aba169609dd6b5f3f443bb4cc15b82f7785fcada5af9bbb" + sha256: df534476c341ab2c6a835078066fc681b8265048addd853a1e3c78740316a844 url: "https://pub.dev" source: hosted - version: "6.2.3" + version: "6.3.0" video_player_web: dependency: transitive description: name: video_player_web - sha256: "881b375a934d8ebf868c7fb1423b2bfaa393a0a265fa3f733079a86536064a10" + sha256: e8bba2e5d1e159d5048c9a491bb2a7b29c535c612bb7d10c1e21107f5bd365ba url: "https://pub.dev" source: hosted - version: "2.3.3" + version: "2.3.5" vm_service: dependency: transitive description: @@ -1619,10 +1598,10 @@ packages: dependency: transitive description: name: web - sha256: cd3543bd5798f6ad290ea73d210f423502e71900302dde696f8bff84bf89a1cb + sha256: "868d88a33d8a87b18ffc05f9f030ba328ffefba92d6c127917a2ba740f9cfe4a" url: "https://pub.dev" source: hosted - version: "1.1.0" + version: "1.1.1" web_socket_channel: dependency: transitive description: @@ -1635,26 +1614,26 @@ packages: dependency: transitive description: name: webrtc_interface - sha256: abec3ab7956bd5ac539cf34a42fa0c82ea26675847c0966bb85160400eea9388 + sha256: e92afec11152a9ccb5c9f35482754edd99696e886ab6acaf90c06dd2d09f09eb url: "https://pub.dev" source: hosted - version: "1.2.0" + version: "1.2.2+hotfix.1" win32: dependency: "direct dev" description: name: win32 - sha256: "154360849a56b7b67331c21f09a386562d88903f90a1099c5987afc1912e1f29" + sha256: dc6ecaa00a7c708e5b4d10ee7bec8c270e9276dfcab1783f57e9962d7884305f url: "https://pub.dev" source: hosted - version: "5.10.0" + version: "5.12.0" win32_registry: dependency: transitive description: name: win32_registry - sha256: "21ec76dfc731550fd3e2ce7a33a9ea90b828fdf19a5c3bcf556fa992cfa99852" + sha256: "6f1b564492d0147b330dd794fee8f512cec4977957f310f9951b5f9d83618dae" url: "https://pub.dev" source: hosted - version: "1.1.5" + version: "2.1.0" xdg_directories: dependency: transitive description: @@ -1681,4 +1660,4 @@ packages: version: "3.1.3" sdks: dart: ">=3.7.0 <4.0.0" - flutter: ">=3.27.0" + flutter: ">=3.29.0" diff --git a/pubspec.yaml b/pubspec.yaml index 6ed1f1e..32d14a5 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -47,31 +47,31 @@ dependencies: intl: ^0.19.0 dart_pusher_channels: ^1.1.1 cached_network_image: ^3.3.1 - flutter_blurhash: ^0.8.2 - auto_route: ^9.3.0+1 - permission_handler: ^11.3.1 + flutter_blurhash: ^0.9.1 + auto_route: ^10.0.1 + permission_handler: ^12.0.0+1 gal: ^2.3.0 - flex_color_scheme: ^7.3.1 + flex_color_scheme: ^8.2.0 shared_preferences: ^2.2.3 timeago: ^3.6.1 # flutter_dotenv: ^5.1.0 - freezed_annotation: ^2.4.1 + freezed_annotation: ^3.0.0 json_annotation: ^4.9.0 fluttertoast: ^8.2.5 - google_fonts: ^4.0.4 + google_fonts: ^6.2.1 font_awesome_flutter: ^10.7.0 google_sign_in: ^6.2.1 flutter_facebook_auth: ^6.0.4 rename: ^3.0.2 - firebase_core: ^2.30.1 - firebase_crashlytics: ^3.5.5 + firebase_core: ^3.13.0 + firebase_crashlytics: ^4.3.5 talker: ^4.2.0 uuid: ^4.4.0 emoji_picker_flutter: ^4.3.0 flutter_image_compress: ^2.3.0 # for video streaming - flutter_webrtc: ^0.11.1 + flutter_webrtc: ^0.13.1+hotfix.1 # for file picker feature photo_manager: ^3.6.3 @@ -101,10 +101,10 @@ dev_dependencies: # activated in the `analysis_options.yaml` file located at the root of your # package. See that file for information about deactivating specific lint # rules and activating additional ones. - flutter_lints: ^3.0.0 + flutter_lints: ^5.0.0 json_serializable: ^6.8.0 - freezed: ^2.5.2 - auto_route_generator: ^9.3.1 + freezed: ^3.0.6 + auto_route_generator: ^10.0.1 package_info_plus: any # wakelock_windows: any win32: ^5.5.4 From f4dc29436688d4e732df063c096539092f7063cf Mon Sep 17 00:00:00 2001 From: sb-dor Date: Sun, 27 Apr 2025 07:53:02 +0500 Subject: [PATCH 10/10] was added environment inside applicationConfig --- env/dev.json | 1 + lib/src/features/initialization/logic/app_runner.dart | 1 + .../initialization/models/application_config.dart | 11 +++++++++++ 3 files changed, 13 insertions(+) diff --git a/env/dev.json b/env/dev.json index a01a65c..c3c3c6d 100644 --- a/env/dev.json +++ b/env/dev.json @@ -1,4 +1,5 @@ { + "ENVIRONMENT": "DEV", "MAIN_URL": "", "PUSHER_APP_ID": "", "PUSHER_APP_KEY": "", diff --git a/lib/src/features/initialization/logic/app_runner.dart b/lib/src/features/initialization/logic/app_runner.dart index 78e53c4..b81c22f 100644 --- a/lib/src/features/initialization/logic/app_runner.dart +++ b/lib/src/features/initialization/logic/app_runner.dart @@ -37,6 +37,7 @@ class AppRunner with FolderCreator { await sharedPreferences.initSharedPrefer(); final applicationConfig = ApplicationConfig(); logger.log(Level.debug, "from env main url: ${applicationConfig.mainUrl}"); + logger.log(Level.debug, "type of env: ${applicationConfig.environment}"); final RestClientBase restClientBase = RestClientDio( baseURL: applicationConfig.mainUrl, diff --git a/lib/src/features/initialization/models/application_config.dart b/lib/src/features/initialization/models/application_config.dart index 982683e..68bcca4 100644 --- a/lib/src/features/initialization/models/application_config.dart +++ b/lib/src/features/initialization/models/application_config.dart @@ -1,4 +1,15 @@ +import 'package:yahay/src/features/initialization/models/environment.dart'; + class ApplicationConfig { + const ApplicationConfig(); + + // for checking type of environment + Environment get environment { + final env = const String.fromEnvironment("ENVIRONMENT").trim(); + + return Environment.from(env); + } + String get mainUrl => const String.fromEnvironment("MAIN_URL"); String get pusherAppId => const String.fromEnvironment("PUSHER_APP_ID");