diff --git a/.DS_Store b/.DS_Store index 3d1c4439..4bd8225b 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/README.md b/README.md index 39b2d892..d7368d78 100644 --- a/README.md +++ b/README.md @@ -1,59 +1 @@ - -# eatvio_app -### Системные требования - -- Flutter (Channel stable, 3.19.0, on Ubuntu 22.04.3 LTS 6.2.0-39-generic, locale en_US.UTF-8) -- Android Studio (version 2023.1) -- VS Code (version 1.85.0) -- Android SDK (version 34.0.0) - устанавливается из Android Studio (Tools->SDK Manager->Android Command Line Tools) -- Эмулятор (2 available) - -### Структура приложения - -``` -. -├── android - Папка для крмпиляции Android приложения -├── assets - Медиа и шрифты -├── ios - Папка для крмпиляции iOS приложения -├── lib - Основной код - ├── main.dart - Файл из которого компилируется приложение - ├── presentation - Виджеты экранов (верстка) - ├── routes - Роутер (пути до экранов) - └── theme - Темы и оформление - └── widgets - Кастомные виджеты -├── pubspec.yaml - Пакеты - -``` - - -### Как запускать? - -Для запуска на эмуляторе в программе VS Code скомпилируйте и запустите файл main.dart (предварительно необходимо установить эмулятор в Android Studio или подключите устройство в режиме разработчика через USB) - -Для тестирования на устройствах Android в корневой папке проекта выполните команду - -`# flutter build apk` - -после чего `.apk` файл скомпилируется в директории `build/app/outputs/flutter-apk/app-release.apk` - -Данный файл установит приложение на устройство с актуальной версией OS - -### Библиотеки и инструменты - - - **flutter_bloc** - контроль состояний - - **cached_network_image** - кеширование картинок из веба - - **flutter_svg** - работа с изображениями - - **equatable** - сравнение без оператора "==" - - **validators** - валидация - - **hive** - локальная бд (1) - - **hive_flutter** - локальная бд (2) - - **isar_flutter_libs** - локальная бд (3) - - **path_provider** - динамичкские пути до файлов - - **fl_chart** - построение графиков - - **flutter_spinkit** - прелоадеры - - **flutter_dotenv** - переменные окружения - - -### Поддержка - -Telegram: @maxx_kim (https://t.me/maxx_kim) +# eatvio_app \ No newline at end of file diff --git a/android/settings.gradle b/android/settings.gradle index 83b4cf1d..5a6de5ce 100644 --- a/android/settings.gradle +++ b/android/settings.gradle @@ -19,7 +19,7 @@ pluginManagement { plugins { id "dev.flutter.flutter-plugin-loader" version "1.0.0" id "com.android.application" version "7.3.1" apply false - id "org.jetbrains.kotlin.android" version "1.9.10" apply false + id "org.jetbrains.kotlin.android" version "2.0.20" apply false } include ":app" diff --git a/assets/audio/recive_message.wav b/assets/audio/recive_message.wav new file mode 100644 index 00000000..db342a8f Binary files /dev/null and b/assets/audio/recive_message.wav differ diff --git a/assets/audio/send_message.wav b/assets/audio/send_message.wav new file mode 100644 index 00000000..ec643aa1 Binary files /dev/null and b/assets/audio/send_message.wav differ diff --git a/assets/icons/calendar.svg b/assets/icons/calendar.svg new file mode 100644 index 00000000..e9d97952 --- /dev/null +++ b/assets/icons/calendar.svg @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/icons/diets.svg b/assets/icons/diets.svg new file mode 100644 index 00000000..7714b3fa --- /dev/null +++ b/assets/icons/diets.svg @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + diff --git a/lib/app_router.dart b/lib/app_router.dart index 83485d40..f872ddc9 100644 --- a/lib/app_router.dart +++ b/lib/app_router.dart @@ -13,6 +13,8 @@ import 'package:eatvio_app/features/feed/models/diets_pagination_model.dart'; import 'package:eatvio_app/features/feed/models/feed_blog_post_model.dart'; import 'package:eatvio_app/features/feed/models/recipes_model.dart'; import 'package:eatvio_app/features/feed/presentation/pages/feed_screen.dart'; +import 'package:eatvio_app/features/menu/presentation/pages/menu_screen.dart'; +import 'package:eatvio_app/features/notifications/presentation/pages/notifications_screen.dart'; import 'package:eatvio_app/features/profile/presentation/pages/profile_screen.dart'; import 'package:eatvio_app/features/recipes/presentation/pages/about_recipes_screen.dart'; import 'package:eatvio_app/features/recipes/presentation/pages/recipe_create_screen.dart'; @@ -24,7 +26,6 @@ import 'package:eatvio_app/presentation/diets/diet_select_screen/diet_select_scr import 'package:eatvio_app/presentation/feed/blog_post_edit_screen/blog_post_edit_screen.dart'; import 'package:eatvio_app/presentation/glossary/glossary_screen/glossary_screen.dart'; import 'package:eatvio_app/presentation/plans/plan_select_screen/plan_select_screen.dart'; -import 'package:eatvio_app/presentation/profile/my_profile_screen/my_profile_screen.dart'; import 'package:eatvio_app/presentation/profile/my_profile_screen/my_settings_screen.dart'; import 'package:eatvio_app/presentation/recipe/recipe_select_screen/recipe_select_screen.dart'; import 'package:flutter/material.dart'; @@ -62,32 +63,43 @@ class AppRouter { }, routes: [ GoRoute( + pageBuilder: (context, state) => NoTransitionPage(child: ProfileScreen()), path: '/my-profile-screen', name: 'myProfileScreen', redirect: (context, state) async { await context.read().runInitialization(); return null; }, - builder: (context, state) => MyProfileScreen(), ), GoRoute( + pageBuilder: (context, state) => NoTransitionPage(child: FeedScreen()), path: '/feed-screen', name: 'feedScreen', - builder: (context, state) => FeedScreen(), ), GoRoute( - path: '/diary-screen', - name: 'diaryScreen', - builder: (context, state) { - if (state.extra != null) - return DiaryScreen(diaryID: state.extra as String); - else - return DiaryScreen(diaryID: '0'); - }), + pageBuilder: (context, state) { + if (state.extra != null) + return NoTransitionPage(child: DiaryScreen(diaryID: state.extra as String)); + else + return NoTransitionPage(child: DiaryScreen(diaryID: '0')); + }, + path: '/diary-screen', + name: 'diaryScreen', + ), GoRoute( + pageBuilder: (context, state) => NoTransitionPage(child: ChatSelectScreen()), path: '/chat-select-screen', name: 'chatSelectScreen', - builder: (context, state) => ChatSelectScreen(), + ), + GoRoute( + pageBuilder: (context, state) => NoTransitionPage(child: NotificationsScreen()), + path: '/notifications-screen', + name: 'notificationsScreen', + ), + GoRoute( + pageBuilder: (context, state) => NoTransitionPage(child: MenuScreen()), + path: '/menu-screen', + name: 'menuScreen', ), ], ), diff --git a/lib/core/app_export.dart b/lib/core/app_export.dart index 76a79551..88b3fe01 100644 --- a/lib/core/app_export.dart +++ b/lib/core/app_export.dart @@ -3,7 +3,6 @@ export 'package:eatvio_app/core/errors/exceptions.dart'; export 'package:eatvio_app/core/utils/date_time_utils.dart'; export 'package:eatvio_app/core/utils/image_constant.dart'; export 'package:eatvio_app/core/utils/logger.dart'; -export 'package:eatvio_app/core/utils/pref_utils.dart'; export 'package:eatvio_app/core/utils/size_utils.dart'; export 'package:eatvio_app/data/models/selectionPopupModel/selection_popup_model.dart'; export 'package:eatvio_app/localization/app_localization.dart'; @@ -12,6 +11,4 @@ export 'package:eatvio_app/theme/custom_text_style.dart'; export 'package:eatvio_app/theme/theme_helper.dart'; export 'package:eatvio_app/widgets/custom_image_view.dart'; export 'package:flutter_bloc/flutter_bloc.dart'; - -export '../theme/bloc/theme_bloc.dart'; export '../theme/custom_button_style.dart'; diff --git a/lib/core/initialization_cubit/initialization_cubit.dart b/lib/core/initialization_cubit/initialization_cubit.dart index 29a42f69..518abeba 100644 --- a/lib/core/initialization_cubit/initialization_cubit.dart +++ b/lib/core/initialization_cubit/initialization_cubit.dart @@ -27,7 +27,7 @@ class InitializationCubit extends Cubit { privateNotificationChannel.subscribe(); privateNotificationChannel.bindToAll().listen((event) { - sl().incrementCounter(); + sl().incrementCounter(event.name); }); } diff --git a/lib/core/initialization_cubit/initialization_state.freezed.dart b/lib/core/initialization_cubit/initialization_state.freezed.dart index b0535c68..3364e440 100644 --- a/lib/core/initialization_cubit/initialization_state.freezed.dart +++ b/lib/core/initialization_cubit/initialization_state.freezed.dart @@ -84,9 +84,6 @@ class _$InitializationStateCopyWithImpl<$Res, $Val extends InitializationState> final $Val _value; // ignore: unused_field final $Res Function($Val) _then; - - /// Create a copy of InitializationState - /// with the given fields replaced by the non-null parameter values. } /// @nodoc @@ -103,9 +100,6 @@ class __$$InitializationStateImplCopyWithImpl<$Res> __$$InitializationStateImplCopyWithImpl(_$InitializationStateImpl _value, $Res Function(_$InitializationStateImpl) _then) : super(_value, _then); - - /// Create a copy of InitializationState - /// with the given fields replaced by the non-null parameter values. } /// @nodoc @@ -224,9 +218,6 @@ class __$$InitializationStateLoadingImplCopyWithImpl<$Res> _$InitializationStateLoadingImpl _value, $Res Function(_$InitializationStateLoadingImpl) _then) : super(_value, _then); - - /// Create a copy of InitializationState - /// with the given fields replaced by the non-null parameter values. } /// @nodoc @@ -348,8 +339,6 @@ class __$$InitializationStateSuccessImplCopyWithImpl<$Res> $Res Function(_$InitializationStateSuccessImpl) _then) : super(_value, _then); - /// Create a copy of InitializationState - /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -388,9 +377,7 @@ class _$InitializationStateSuccessImpl implements InitializationStateSuccess { @override int get hashCode => Object.hash(runtimeType, client); - /// Create a copy of InitializationState - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) @override @pragma('vm:prefer-inline') _$$InitializationStateSuccessImplCopyWith<_$InitializationStateSuccessImpl> @@ -478,10 +465,7 @@ abstract class InitializationStateSuccess implements InitializationState { _$InitializationStateSuccessImpl; PusherChannelsClient get client; - - /// Create a copy of InitializationState - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) _$$InitializationStateSuccessImplCopyWith<_$InitializationStateSuccessImpl> get copyWith => throw _privateConstructorUsedError; } @@ -506,8 +490,6 @@ class __$$InitializationStateErrorImplCopyWithImpl<$Res> $Res Function(_$InitializationStateErrorImpl) _then) : super(_value, _then); - /// Create a copy of InitializationState - /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -547,9 +529,7 @@ class _$InitializationStateErrorImpl implements InitializationStateError { @override int get hashCode => Object.hash(runtimeType, errorMessage); - /// Create a copy of InitializationState - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) @override @pragma('vm:prefer-inline') _$$InitializationStateErrorImplCopyWith<_$InitializationStateErrorImpl> @@ -636,10 +616,7 @@ abstract class InitializationStateError implements InitializationState { _$InitializationStateErrorImpl; String get errorMessage; - - /// Create a copy of InitializationState - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) _$$InitializationStateErrorImplCopyWith<_$InitializationStateErrorImpl> get copyWith => throw _privateConstructorUsedError; } diff --git a/lib/core/token_storage.dart b/lib/core/token_storage.dart index 1179241b..c73e2aba 100644 --- a/lib/core/token_storage.dart +++ b/lib/core/token_storage.dart @@ -1,6 +1,6 @@ import 'package:dio/dio.dart'; import 'package:eatvio_app/locator_service.dart'; -import 'package:hive_flutter/hive_flutter.dart'; +import 'package:flutter_secure_storage/flutter_secure_storage.dart'; abstract class TokenStorage { static _addTokenToDioHeader(String token) { @@ -8,22 +8,20 @@ abstract class TokenStorage { } static haveTokenInStorage() async { - final box = await Hive.openBox('token'); - final token = box.get('token'); - if (token == null) { + if (await FlutterSecureStorage().read(key: 'token') == null) { return false; } else { - _addTokenToDioHeader(token); + _addTokenToDioHeader((await FlutterSecureStorage().read(key: 'token'))!); return true; } } - static Future getTokenFromStorage() async => (await Hive.openBox('token')).get('token'); + static Future getTokenFromStorage() async => (await FlutterSecureStorage().read(key: 'token'))!; static saveTokenInStorage(String token) async { - (await Hive.openBox('token')).put('token', token); + await FlutterSecureStorage().write(key: 'token', value: token); _addTokenToDioHeader(token); } - static removeTokenInStorage() async => (await Hive.openBox('token')).delete('token'); + static removeTokenInStorage() async => (await FlutterSecureStorage().delete(key: 'token')); } diff --git a/lib/core/utils/pref_utils.dart b/lib/core/utils/pref_utils.dart deleted file mode 100644 index 9c49a3d2..00000000 --- a/lib/core/utils/pref_utils.dart +++ /dev/null @@ -1,34 +0,0 @@ -import 'package:shared_preferences/shared_preferences.dart'; - -class PrefUtils { - static SharedPreferences? _sharedPreferences; - - PrefUtils() { - // init(); - SharedPreferences.getInstance().then((value) { - _sharedPreferences = value; - }); - } - - Future init() async { - _sharedPreferences ??= await SharedPreferences.getInstance(); - print('SharedPreference Initialized'); - } - - ///will clear all the data stored in preference - void clearPreferencesData() async { - _sharedPreferences!.clear(); - } - - Future setThemeData(String value) { - return _sharedPreferences!.setString('themeData', value); - } - - String getThemeData() { - try { - return _sharedPreferences!.getString('themeData')!; - } catch (e) { - return 'primary'; - } - } -} diff --git a/lib/data/models/selectionPopupModel/selection_popup_model.freezed.dart b/lib/data/models/selectionPopupModel/selection_popup_model.freezed.dart index 97ab368c..917785c7 100644 --- a/lib/data/models/selectionPopupModel/selection_popup_model.freezed.dart +++ b/lib/data/models/selectionPopupModel/selection_popup_model.freezed.dart @@ -21,9 +21,7 @@ mixin _$SelectionPopupModel { dynamic get value => throw _privateConstructorUsedError; bool get isSelected => throw _privateConstructorUsedError; - /// Create a copy of SelectionPopupModel - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) $SelectionPopupModelCopyWith get copyWith => throw _privateConstructorUsedError; } @@ -47,8 +45,6 @@ class _$SelectionPopupModelCopyWithImpl<$Res, $Val extends SelectionPopupModel> // ignore: unused_field final $Res Function($Val) _then; - /// Create a copy of SelectionPopupModel - /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -97,8 +93,6 @@ class __$$SelectionPopupModelImplCopyWithImpl<$Res> $Res Function(_$SelectionPopupModelImpl) _then) : super(_value, _then); - /// Create a copy of SelectionPopupModel - /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -165,9 +159,7 @@ class _$SelectionPopupModelImpl implements _SelectionPopupModel { int get hashCode => Object.hash(runtimeType, id, title, const DeepCollectionEquality().hash(value), isSelected); - /// Create a copy of SelectionPopupModel - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) @override @pragma('vm:prefer-inline') _$$SelectionPopupModelImplCopyWith<_$SelectionPopupModelImpl> get copyWith => @@ -190,11 +182,8 @@ abstract class _SelectionPopupModel implements SelectionPopupModel { dynamic get value; @override bool get isSelected; - - /// Create a copy of SelectionPopupModel - /// with the given fields replaced by the non-null parameter values. @override - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) _$$SelectionPopupModelImplCopyWith<_$SelectionPopupModelImpl> get copyWith => throw _privateConstructorUsedError; } diff --git a/lib/data/models/tokenModel/token_model.dart b/lib/data/models/tokenModel/token_model.dart deleted file mode 100644 index ce310e2e..00000000 --- a/lib/data/models/tokenModel/token_model.dart +++ /dev/null @@ -1,10 +0,0 @@ -import 'package:hive/hive.dart'; - -/// https://pub.dev/packages/flutter_secure_storage TODO replace hive to secure_storage for token storage -@HiveType(typeId: 0) -class TokenModel { - @HiveField(0) - String token; - - TokenModel({required this.token}); -} diff --git a/lib/data/models/userRegistrationModel/user_registration_model.freezed.dart b/lib/data/models/userRegistrationModel/user_registration_model.freezed.dart index fd835a26..4a15327c 100644 --- a/lib/data/models/userRegistrationModel/user_registration_model.freezed.dart +++ b/lib/data/models/userRegistrationModel/user_registration_model.freezed.dart @@ -68,12 +68,8 @@ mixin _$UserRegistrationSheet { @JsonKey(name: 'activity_coefficient') double get activityCoefficient => throw _privateConstructorUsedError; - /// Serializes this UserRegistrationSheet to a JSON map. Map toJson() => throw _privateConstructorUsedError; - - /// Create a copy of UserRegistrationSheet - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) $UserRegistrationSheetCopyWith get copyWith => throw _privateConstructorUsedError; } @@ -125,8 +121,6 @@ class _$UserRegistrationSheetCopyWithImpl<$Res, // ignore: unused_field final $Res Function($Val) _then; - /// Create a copy of UserRegistrationSheet - /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -319,8 +313,6 @@ class __$$UserRegistrationSheetImplCopyWithImpl<$Res> $Res Function(_$UserRegistrationSheetImpl) _then) : super(_value, _then); - /// Create a copy of UserRegistrationSheet - /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -635,7 +627,7 @@ class _$UserRegistrationSheetImpl implements _UserRegistrationSheet { other.activityCoefficient == activityCoefficient)); } - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) @override int get hashCode => Object.hashAll([ runtimeType, @@ -668,9 +660,7 @@ class _$UserRegistrationSheetImpl implements _UserRegistrationSheet { activityCoefficient ]); - /// Create a copy of UserRegistrationSheet - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) @override @pragma('vm:prefer-inline') _$$UserRegistrationSheetImplCopyWith<_$UserRegistrationSheetImpl> @@ -797,11 +787,8 @@ abstract class _UserRegistrationSheet implements UserRegistrationSheet { @override @JsonKey(name: 'activity_coefficient') double get activityCoefficient; - - /// Create a copy of UserRegistrationSheet - /// with the given fields replaced by the non-null parameter values. @override - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) _$$UserRegistrationSheetImplCopyWith<_$UserRegistrationSheetImpl> get copyWith => throw _privateConstructorUsedError; } diff --git a/lib/features/blog_post_create/presentation/pages/blog_post_create_screen.dart b/lib/features/blog_post_create/presentation/pages/blog_post_create_screen.dart index e1414dbe..d8fc116e 100644 --- a/lib/features/blog_post_create/presentation/pages/blog_post_create_screen.dart +++ b/lib/features/blog_post_create/presentation/pages/blog_post_create_screen.dart @@ -78,7 +78,7 @@ class _BlogPostCreateScreenState extends State { floatingActionButton: SizedBox( width: MediaQuery.of(context).size.width - 32, child: FloatingActionButton.extended( - heroTag: 'nextButtonRegistration', + heroTag: 'createBlogPost', highlightElevation: 0, elevation: 0, focusElevation: 0, diff --git a/lib/features/bottom_navigation_bar/presentation/bloc/new_messages_cubit/new_messages_state.freezed.dart b/lib/features/bottom_navigation_bar/presentation/bloc/new_messages_cubit/new_messages_state.freezed.dart index 7c5d7ffd..02a1c4bd 100644 --- a/lib/features/bottom_navigation_bar/presentation/bloc/new_messages_cubit/new_messages_state.freezed.dart +++ b/lib/features/bottom_navigation_bar/presentation/bloc/new_messages_cubit/new_messages_state.freezed.dart @@ -84,9 +84,6 @@ class _$NewMessagesStateCopyWithImpl<$Res, $Val extends NewMessagesState> final $Val _value; // ignore: unused_field final $Res Function($Val) _then; - - /// Create a copy of NewMessagesState - /// with the given fields replaced by the non-null parameter values. } /// @nodoc @@ -103,9 +100,6 @@ class __$$NewMessagesStateImplCopyWithImpl<$Res> __$$NewMessagesStateImplCopyWithImpl(_$NewMessagesStateImpl _value, $Res Function(_$NewMessagesStateImpl) _then) : super(_value, _then); - - /// Create a copy of NewMessagesState - /// with the given fields replaced by the non-null parameter values. } /// @nodoc @@ -221,9 +215,6 @@ class __$$NewMessagesStateEmptyImplCopyWithImpl<$Res> __$$NewMessagesStateEmptyImplCopyWithImpl(_$NewMessagesStateEmptyImpl _value, $Res Function(_$NewMessagesStateEmptyImpl) _then) : super(_value, _then); - - /// Create a copy of NewMessagesState - /// with the given fields replaced by the non-null parameter values. } /// @nodoc @@ -344,8 +335,6 @@ class __$$NewMessagesStateLoadedImplCopyWithImpl<$Res> $Res Function(_$NewMessagesStateLoadedImpl) _then) : super(_value, _then); - /// Create a copy of NewMessagesState - /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -385,9 +374,7 @@ class _$NewMessagesStateLoadedImpl implements NewMessagesStateLoaded { @override int get hashCode => Object.hash(runtimeType, messagesCount); - /// Create a copy of NewMessagesState - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) @override @pragma('vm:prefer-inline') _$$NewMessagesStateLoadedImplCopyWith<_$NewMessagesStateLoadedImpl> @@ -474,10 +461,7 @@ abstract class NewMessagesStateLoaded implements NewMessagesState { _$NewMessagesStateLoadedImpl; int get messagesCount; - - /// Create a copy of NewMessagesState - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) _$$NewMessagesStateLoadedImplCopyWith<_$NewMessagesStateLoadedImpl> get copyWith => throw _privateConstructorUsedError; } @@ -500,8 +484,6 @@ class __$$NewMessagesStateErrorImplCopyWithImpl<$Res> $Res Function(_$NewMessagesStateErrorImpl) _then) : super(_value, _then); - /// Create a copy of NewMessagesState - /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -541,9 +523,7 @@ class _$NewMessagesStateErrorImpl implements NewMessagesStateError { @override int get hashCode => Object.hash(runtimeType, errorMessage); - /// Create a copy of NewMessagesState - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) @override @pragma('vm:prefer-inline') _$$NewMessagesStateErrorImplCopyWith<_$NewMessagesStateErrorImpl> @@ -630,10 +610,7 @@ abstract class NewMessagesStateError implements NewMessagesState { _$NewMessagesStateErrorImpl; String get errorMessage; - - /// Create a copy of NewMessagesState - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) _$$NewMessagesStateErrorImplCopyWith<_$NewMessagesStateErrorImpl> get copyWith => throw _privateConstructorUsedError; } diff --git a/lib/features/bottom_navigation_bar/presentation/bloc/notifications_cubit/notifications_cubit.dart b/lib/features/bottom_navigation_bar/presentation/bloc/notifications_cubit/notifications_cubit.dart index ba5634cc..8a22b6d5 100644 --- a/lib/features/bottom_navigation_bar/presentation/bloc/notifications_cubit/notifications_cubit.dart +++ b/lib/features/bottom_navigation_bar/presentation/bloc/notifications_cubit/notifications_cubit.dart @@ -3,11 +3,18 @@ import 'package:eatvio_app/features/bottom_navigation_bar/presentation/bloc/noti class NotificationsCubit extends Cubit { int _notificationsCount = 0; + List notifications = []; NotificationsCubit() : super(const NotificationsState.empty()); - incrementCounter() { + incrementCounter(String data) { _notificationsCount++; - emit(NotificationsState.loaded(notificationsCount: _notificationsCount)); + notifications.add(data); + emit( + NotificationsState.loaded( + notifications: notifications, + notificationsCount: _notificationsCount, + ), + ); } } diff --git a/lib/features/bottom_navigation_bar/presentation/bloc/notifications_cubit/notifications_state.dart b/lib/features/bottom_navigation_bar/presentation/bloc/notifications_cubit/notifications_state.dart index 0f20a051..d44c7b2b 100644 --- a/lib/features/bottom_navigation_bar/presentation/bloc/notifications_cubit/notifications_state.dart +++ b/lib/features/bottom_navigation_bar/presentation/bloc/notifications_cubit/notifications_state.dart @@ -9,6 +9,7 @@ abstract class NotificationsState with _$NotificationsState { const factory NotificationsState.empty() = NotificationsStateEmpty; const factory NotificationsState.loaded({ + required List notifications, required int notificationsCount, }) = NotificationsStateLoaded; diff --git a/lib/features/bottom_navigation_bar/presentation/bloc/notifications_cubit/notifications_state.freezed.dart b/lib/features/bottom_navigation_bar/presentation/bloc/notifications_cubit/notifications_state.freezed.dart index 2b969b98..4ba18f06 100644 --- a/lib/features/bottom_navigation_bar/presentation/bloc/notifications_cubit/notifications_state.freezed.dart +++ b/lib/features/bottom_navigation_bar/presentation/bloc/notifications_cubit/notifications_state.freezed.dart @@ -20,7 +20,9 @@ mixin _$NotificationsState { TResult when( TResult Function() $default, { required TResult Function() empty, - required TResult Function(int notificationsCount) loaded, + required TResult Function( + List notifications, int notificationsCount) + loaded, required TResult Function(String errorMessage) error, }) => throw _privateConstructorUsedError; @@ -28,7 +30,8 @@ mixin _$NotificationsState { TResult? whenOrNull( TResult? Function()? $default, { TResult? Function()? empty, - TResult? Function(int notificationsCount)? loaded, + TResult? Function(List notifications, int notificationsCount)? + loaded, TResult? Function(String errorMessage)? error, }) => throw _privateConstructorUsedError; @@ -36,7 +39,8 @@ mixin _$NotificationsState { TResult maybeWhen( TResult Function()? $default, { TResult Function()? empty, - TResult Function(int notificationsCount)? loaded, + TResult Function(List notifications, int notificationsCount)? + loaded, TResult Function(String errorMessage)? error, required TResult orElse(), }) => @@ -84,9 +88,6 @@ class _$NotificationsStateCopyWithImpl<$Res, $Val extends NotificationsState> final $Val _value; // ignore: unused_field final $Res Function($Val) _then; - - /// Create a copy of NotificationsState - /// with the given fields replaced by the non-null parameter values. } /// @nodoc @@ -103,9 +104,6 @@ class __$$NotificationsStateImplCopyWithImpl<$Res> __$$NotificationsStateImplCopyWithImpl(_$NotificationsStateImpl _value, $Res Function(_$NotificationsStateImpl) _then) : super(_value, _then); - - /// Create a copy of NotificationsState - /// with the given fields replaced by the non-null parameter values. } /// @nodoc @@ -132,7 +130,9 @@ class _$NotificationsStateImpl implements _NotificationsState { TResult when( TResult Function() $default, { required TResult Function() empty, - required TResult Function(int notificationsCount) loaded, + required TResult Function( + List notifications, int notificationsCount) + loaded, required TResult Function(String errorMessage) error, }) { return $default(); @@ -143,7 +143,8 @@ class _$NotificationsStateImpl implements _NotificationsState { TResult? whenOrNull( TResult? Function()? $default, { TResult? Function()? empty, - TResult? Function(int notificationsCount)? loaded, + TResult? Function(List notifications, int notificationsCount)? + loaded, TResult? Function(String errorMessage)? error, }) { return $default?.call(); @@ -154,7 +155,8 @@ class _$NotificationsStateImpl implements _NotificationsState { TResult maybeWhen( TResult Function()? $default, { TResult Function()? empty, - TResult Function(int notificationsCount)? loaded, + TResult Function(List notifications, int notificationsCount)? + loaded, TResult Function(String errorMessage)? error, required TResult orElse(), }) { @@ -223,9 +225,6 @@ class __$$NotificationsStateEmptyImplCopyWithImpl<$Res> _$NotificationsStateEmptyImpl _value, $Res Function(_$NotificationsStateEmptyImpl) _then) : super(_value, _then); - - /// Create a copy of NotificationsState - /// with the given fields replaced by the non-null parameter values. } /// @nodoc @@ -253,7 +252,9 @@ class _$NotificationsStateEmptyImpl implements NotificationsStateEmpty { TResult when( TResult Function() $default, { required TResult Function() empty, - required TResult Function(int notificationsCount) loaded, + required TResult Function( + List notifications, int notificationsCount) + loaded, required TResult Function(String errorMessage) error, }) { return empty(); @@ -264,7 +265,8 @@ class _$NotificationsStateEmptyImpl implements NotificationsStateEmpty { TResult? whenOrNull( TResult? Function()? $default, { TResult? Function()? empty, - TResult? Function(int notificationsCount)? loaded, + TResult? Function(List notifications, int notificationsCount)? + loaded, TResult? Function(String errorMessage)? error, }) { return empty?.call(); @@ -275,7 +277,8 @@ class _$NotificationsStateEmptyImpl implements NotificationsStateEmpty { TResult maybeWhen( TResult Function()? $default, { TResult Function()? empty, - TResult Function(int notificationsCount)? loaded, + TResult Function(List notifications, int notificationsCount)? + loaded, TResult Function(String errorMessage)? error, required TResult orElse(), }) { @@ -334,7 +337,7 @@ abstract class _$$NotificationsStateLoadedImplCopyWith<$Res> { $Res Function(_$NotificationsStateLoadedImpl) then) = __$$NotificationsStateLoadedImplCopyWithImpl<$Res>; @useResult - $Res call({int notificationsCount}); + $Res call({List notifications, int notificationsCount}); } /// @nodoc @@ -347,14 +350,17 @@ class __$$NotificationsStateLoadedImplCopyWithImpl<$Res> $Res Function(_$NotificationsStateLoadedImpl) _then) : super(_value, _then); - /// Create a copy of NotificationsState - /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ + Object? notifications = null, Object? notificationsCount = null, }) { return _then(_$NotificationsStateLoadedImpl( + notifications: null == notifications + ? _value._notifications + : notifications // ignore: cast_nullable_to_non_nullable + as List, notificationsCount: null == notificationsCount ? _value.notificationsCount : notificationsCount // ignore: cast_nullable_to_non_nullable @@ -366,14 +372,25 @@ class __$$NotificationsStateLoadedImplCopyWithImpl<$Res> /// @nodoc class _$NotificationsStateLoadedImpl implements NotificationsStateLoaded { - const _$NotificationsStateLoadedImpl({required this.notificationsCount}); + const _$NotificationsStateLoadedImpl( + {required final List notifications, + required this.notificationsCount}) + : _notifications = notifications; + + final List _notifications; + @override + List get notifications { + if (_notifications is EqualUnmodifiableListView) return _notifications; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(_notifications); + } @override final int notificationsCount; @override String toString() { - return 'NotificationsState.loaded(notificationsCount: $notificationsCount)'; + return 'NotificationsState.loaded(notifications: $notifications, notificationsCount: $notificationsCount)'; } @override @@ -381,16 +398,17 @@ class _$NotificationsStateLoadedImpl implements NotificationsStateLoaded { return identical(this, other) || (other.runtimeType == runtimeType && other is _$NotificationsStateLoadedImpl && + const DeepCollectionEquality() + .equals(other._notifications, _notifications) && (identical(other.notificationsCount, notificationsCount) || other.notificationsCount == notificationsCount)); } @override - int get hashCode => Object.hash(runtimeType, notificationsCount); + int get hashCode => Object.hash(runtimeType, + const DeepCollectionEquality().hash(_notifications), notificationsCount); - /// Create a copy of NotificationsState - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) @override @pragma('vm:prefer-inline') _$$NotificationsStateLoadedImplCopyWith<_$NotificationsStateLoadedImpl> @@ -402,10 +420,12 @@ class _$NotificationsStateLoadedImpl implements NotificationsStateLoaded { TResult when( TResult Function() $default, { required TResult Function() empty, - required TResult Function(int notificationsCount) loaded, + required TResult Function( + List notifications, int notificationsCount) + loaded, required TResult Function(String errorMessage) error, }) { - return loaded(notificationsCount); + return loaded(notifications, notificationsCount); } @override @@ -413,10 +433,11 @@ class _$NotificationsStateLoadedImpl implements NotificationsStateLoaded { TResult? whenOrNull( TResult? Function()? $default, { TResult? Function()? empty, - TResult? Function(int notificationsCount)? loaded, + TResult? Function(List notifications, int notificationsCount)? + loaded, TResult? Function(String errorMessage)? error, }) { - return loaded?.call(notificationsCount); + return loaded?.call(notifications, notificationsCount); } @override @@ -424,12 +445,13 @@ class _$NotificationsStateLoadedImpl implements NotificationsStateLoaded { TResult maybeWhen( TResult Function()? $default, { TResult Function()? empty, - TResult Function(int notificationsCount)? loaded, + TResult Function(List notifications, int notificationsCount)? + loaded, TResult Function(String errorMessage)? error, required TResult orElse(), }) { if (loaded != null) { - return loaded(notificationsCount); + return loaded(notifications, notificationsCount); } return orElse(); } @@ -474,13 +496,12 @@ class _$NotificationsStateLoadedImpl implements NotificationsStateLoaded { abstract class NotificationsStateLoaded implements NotificationsState { const factory NotificationsStateLoaded( - {required final int notificationsCount}) = _$NotificationsStateLoadedImpl; + {required final List notifications, + required final int notificationsCount}) = _$NotificationsStateLoadedImpl; + List get notifications; int get notificationsCount; - - /// Create a copy of NotificationsState - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) _$$NotificationsStateLoadedImplCopyWith<_$NotificationsStateLoadedImpl> get copyWith => throw _privateConstructorUsedError; } @@ -505,8 +526,6 @@ class __$$NotificationsStateErrorImplCopyWithImpl<$Res> $Res Function(_$NotificationsStateErrorImpl) _then) : super(_value, _then); - /// Create a copy of NotificationsState - /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -546,9 +565,7 @@ class _$NotificationsStateErrorImpl implements NotificationsStateError { @override int get hashCode => Object.hash(runtimeType, errorMessage); - /// Create a copy of NotificationsState - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) @override @pragma('vm:prefer-inline') _$$NotificationsStateErrorImplCopyWith<_$NotificationsStateErrorImpl> @@ -560,7 +577,9 @@ class _$NotificationsStateErrorImpl implements NotificationsStateError { TResult when( TResult Function() $default, { required TResult Function() empty, - required TResult Function(int notificationsCount) loaded, + required TResult Function( + List notifications, int notificationsCount) + loaded, required TResult Function(String errorMessage) error, }) { return error(errorMessage); @@ -571,7 +590,8 @@ class _$NotificationsStateErrorImpl implements NotificationsStateError { TResult? whenOrNull( TResult? Function()? $default, { TResult? Function()? empty, - TResult? Function(int notificationsCount)? loaded, + TResult? Function(List notifications, int notificationsCount)? + loaded, TResult? Function(String errorMessage)? error, }) { return error?.call(errorMessage); @@ -582,7 +602,8 @@ class _$NotificationsStateErrorImpl implements NotificationsStateError { TResult maybeWhen( TResult Function()? $default, { TResult Function()? empty, - TResult Function(int notificationsCount)? loaded, + TResult Function(List notifications, int notificationsCount)? + loaded, TResult Function(String errorMessage)? error, required TResult orElse(), }) { @@ -635,10 +656,7 @@ abstract class NotificationsStateError implements NotificationsState { _$NotificationsStateErrorImpl; String get errorMessage; - - /// Create a copy of NotificationsState - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) _$$NotificationsStateErrorImplCopyWith<_$NotificationsStateErrorImpl> get copyWith => throw _privateConstructorUsedError; } diff --git a/lib/features/bottom_navigation_bar/presentation/bloc/profile_avatar_cubit/profile_avatar_cubit.dart b/lib/features/bottom_navigation_bar/presentation/bloc/profile_avatar_cubit/profile_avatar_cubit.dart new file mode 100644 index 00000000..e2bfd48b --- /dev/null +++ b/lib/features/bottom_navigation_bar/presentation/bloc/profile_avatar_cubit/profile_avatar_cubit.dart @@ -0,0 +1,22 @@ +import 'package:eatvio_app/features/bottom_navigation_bar/presentation/bloc/profile_avatar_cubit/profile_avatar_state.dart'; +import 'package:eatvio_app/features/profile/repositories/profile_repository.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; + +class ProfileAvatarCubit extends Cubit { + final ProfileRepository profileRepository; + + ProfileAvatarCubit({ + required this.profileRepository, + }) : super(const ProfileAvatarState.loading()); + + getMyProfile() async { + try { + emit(ProfileAvatarState.loaded( + profile: await profileRepository.getMyProfile(), + )); + } catch (e) { + emit(ProfileAvatarState.error(errorMessage: e.toString())); + print(e); + } + } +} \ No newline at end of file diff --git a/lib/features/bottom_navigation_bar/presentation/bloc/profile_avatar_cubit/profile_avatar_state.dart b/lib/features/bottom_navigation_bar/presentation/bloc/profile_avatar_cubit/profile_avatar_state.dart new file mode 100644 index 00000000..fe90fb6f --- /dev/null +++ b/lib/features/bottom_navigation_bar/presentation/bloc/profile_avatar_cubit/profile_avatar_state.dart @@ -0,0 +1,19 @@ +import 'package:eatvio_app/features/profile/models/profile_model.dart'; +import 'package:freezed_annotation/freezed_annotation.dart'; + +part 'profile_avatar_state.freezed.dart'; + +@freezed +abstract class ProfileAvatarState with _$ProfileAvatarState { + const factory ProfileAvatarState() = _ProfileAvatarState; + + const factory ProfileAvatarState.loading() = ProfileAvatarStateLoading; + + const factory ProfileAvatarState.loaded({ + required ProfileModel profile, + }) = ProfileAvatarStateLoaded; + + const factory ProfileAvatarState.error({ + required String errorMessage, + }) = ProfileAvatarStateError; +} diff --git a/lib/features/bottom_navigation_bar/presentation/bloc/profile_avatar_cubit/profile_avatar_state.freezed.dart b/lib/features/bottom_navigation_bar/presentation/bloc/profile_avatar_cubit/profile_avatar_state.freezed.dart new file mode 100644 index 00000000..5d8de7ff --- /dev/null +++ b/lib/features/bottom_navigation_bar/presentation/bloc/profile_avatar_cubit/profile_avatar_state.freezed.dart @@ -0,0 +1,630 @@ +// coverage:ignore-file +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint +// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark + +part of 'profile_avatar_state.dart'; + +// ************************************************************************** +// FreezedGenerator +// ************************************************************************** + +T _$identity(T value) => value; + +final _privateConstructorUsedError = UnsupportedError( + 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models'); + +/// @nodoc +mixin _$ProfileAvatarState { + @optionalTypeArgs + TResult when( + TResult Function() $default, { + required TResult Function() loading, + required TResult Function(ProfileModel profile) loaded, + required TResult Function(String errorMessage) error, + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult? whenOrNull( + TResult? Function()? $default, { + TResult? Function()? loading, + TResult? Function(ProfileModel profile)? loaded, + TResult? Function(String errorMessage)? error, + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult maybeWhen( + TResult Function()? $default, { + TResult Function()? loading, + TResult Function(ProfileModel profile)? loaded, + TResult Function(String errorMessage)? error, + required TResult orElse(), + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult map( + TResult Function(_ProfileAvatarState value) $default, { + required TResult Function(ProfileAvatarStateLoading value) loading, + required TResult Function(ProfileAvatarStateLoaded value) loaded, + required TResult Function(ProfileAvatarStateError value) error, + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult? mapOrNull( + TResult? Function(_ProfileAvatarState value)? $default, { + TResult? Function(ProfileAvatarStateLoading value)? loading, + TResult? Function(ProfileAvatarStateLoaded value)? loaded, + TResult? Function(ProfileAvatarStateError value)? error, + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult maybeMap( + TResult Function(_ProfileAvatarState value)? $default, { + TResult Function(ProfileAvatarStateLoading value)? loading, + TResult Function(ProfileAvatarStateLoaded value)? loaded, + TResult Function(ProfileAvatarStateError value)? error, + required TResult orElse(), + }) => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $ProfileAvatarStateCopyWith<$Res> { + factory $ProfileAvatarStateCopyWith( + ProfileAvatarState value, $Res Function(ProfileAvatarState) then) = + _$ProfileAvatarStateCopyWithImpl<$Res, ProfileAvatarState>; +} + +/// @nodoc +class _$ProfileAvatarStateCopyWithImpl<$Res, $Val extends ProfileAvatarState> + implements $ProfileAvatarStateCopyWith<$Res> { + _$ProfileAvatarStateCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; +} + +/// @nodoc +abstract class _$$ProfileAvatarStateImplCopyWith<$Res> { + factory _$$ProfileAvatarStateImplCopyWith(_$ProfileAvatarStateImpl value, + $Res Function(_$ProfileAvatarStateImpl) then) = + __$$ProfileAvatarStateImplCopyWithImpl<$Res>; +} + +/// @nodoc +class __$$ProfileAvatarStateImplCopyWithImpl<$Res> + extends _$ProfileAvatarStateCopyWithImpl<$Res, _$ProfileAvatarStateImpl> + implements _$$ProfileAvatarStateImplCopyWith<$Res> { + __$$ProfileAvatarStateImplCopyWithImpl(_$ProfileAvatarStateImpl _value, + $Res Function(_$ProfileAvatarStateImpl) _then) + : super(_value, _then); +} + +/// @nodoc + +class _$ProfileAvatarStateImpl implements _ProfileAvatarState { + const _$ProfileAvatarStateImpl(); + + @override + String toString() { + return 'ProfileAvatarState()'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && other is _$ProfileAvatarStateImpl); + } + + @override + int get hashCode => runtimeType.hashCode; + + @override + @optionalTypeArgs + TResult when( + TResult Function() $default, { + required TResult Function() loading, + required TResult Function(ProfileModel profile) loaded, + required TResult Function(String errorMessage) error, + }) { + return $default(); + } + + @override + @optionalTypeArgs + TResult? whenOrNull( + TResult? Function()? $default, { + TResult? Function()? loading, + TResult? Function(ProfileModel profile)? loaded, + TResult? Function(String errorMessage)? error, + }) { + return $default?.call(); + } + + @override + @optionalTypeArgs + TResult maybeWhen( + TResult Function()? $default, { + TResult Function()? loading, + TResult Function(ProfileModel profile)? loaded, + TResult Function(String errorMessage)? error, + required TResult orElse(), + }) { + if ($default != null) { + return $default(); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map( + TResult Function(_ProfileAvatarState value) $default, { + required TResult Function(ProfileAvatarStateLoading value) loading, + required TResult Function(ProfileAvatarStateLoaded value) loaded, + required TResult Function(ProfileAvatarStateError value) error, + }) { + return $default(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull( + TResult? Function(_ProfileAvatarState value)? $default, { + TResult? Function(ProfileAvatarStateLoading value)? loading, + TResult? Function(ProfileAvatarStateLoaded value)? loaded, + TResult? Function(ProfileAvatarStateError value)? error, + }) { + return $default?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap( + TResult Function(_ProfileAvatarState value)? $default, { + TResult Function(ProfileAvatarStateLoading value)? loading, + TResult Function(ProfileAvatarStateLoaded value)? loaded, + TResult Function(ProfileAvatarStateError value)? error, + required TResult orElse(), + }) { + if ($default != null) { + return $default(this); + } + return orElse(); + } +} + +abstract class _ProfileAvatarState implements ProfileAvatarState { + const factory _ProfileAvatarState() = _$ProfileAvatarStateImpl; +} + +/// @nodoc +abstract class _$$ProfileAvatarStateLoadingImplCopyWith<$Res> { + factory _$$ProfileAvatarStateLoadingImplCopyWith( + _$ProfileAvatarStateLoadingImpl value, + $Res Function(_$ProfileAvatarStateLoadingImpl) then) = + __$$ProfileAvatarStateLoadingImplCopyWithImpl<$Res>; +} + +/// @nodoc +class __$$ProfileAvatarStateLoadingImplCopyWithImpl<$Res> + extends _$ProfileAvatarStateCopyWithImpl<$Res, + _$ProfileAvatarStateLoadingImpl> + implements _$$ProfileAvatarStateLoadingImplCopyWith<$Res> { + __$$ProfileAvatarStateLoadingImplCopyWithImpl( + _$ProfileAvatarStateLoadingImpl _value, + $Res Function(_$ProfileAvatarStateLoadingImpl) _then) + : super(_value, _then); +} + +/// @nodoc + +class _$ProfileAvatarStateLoadingImpl implements ProfileAvatarStateLoading { + const _$ProfileAvatarStateLoadingImpl(); + + @override + String toString() { + return 'ProfileAvatarState.loading()'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$ProfileAvatarStateLoadingImpl); + } + + @override + int get hashCode => runtimeType.hashCode; + + @override + @optionalTypeArgs + TResult when( + TResult Function() $default, { + required TResult Function() loading, + required TResult Function(ProfileModel profile) loaded, + required TResult Function(String errorMessage) error, + }) { + return loading(); + } + + @override + @optionalTypeArgs + TResult? whenOrNull( + TResult? Function()? $default, { + TResult? Function()? loading, + TResult? Function(ProfileModel profile)? loaded, + TResult? Function(String errorMessage)? error, + }) { + return loading?.call(); + } + + @override + @optionalTypeArgs + TResult maybeWhen( + TResult Function()? $default, { + TResult Function()? loading, + TResult Function(ProfileModel profile)? loaded, + TResult Function(String errorMessage)? error, + required TResult orElse(), + }) { + if (loading != null) { + return loading(); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map( + TResult Function(_ProfileAvatarState value) $default, { + required TResult Function(ProfileAvatarStateLoading value) loading, + required TResult Function(ProfileAvatarStateLoaded value) loaded, + required TResult Function(ProfileAvatarStateError value) error, + }) { + return loading(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull( + TResult? Function(_ProfileAvatarState value)? $default, { + TResult? Function(ProfileAvatarStateLoading value)? loading, + TResult? Function(ProfileAvatarStateLoaded value)? loaded, + TResult? Function(ProfileAvatarStateError value)? error, + }) { + return loading?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap( + TResult Function(_ProfileAvatarState value)? $default, { + TResult Function(ProfileAvatarStateLoading value)? loading, + TResult Function(ProfileAvatarStateLoaded value)? loaded, + TResult Function(ProfileAvatarStateError value)? error, + required TResult orElse(), + }) { + if (loading != null) { + return loading(this); + } + return orElse(); + } +} + +abstract class ProfileAvatarStateLoading implements ProfileAvatarState { + const factory ProfileAvatarStateLoading() = _$ProfileAvatarStateLoadingImpl; +} + +/// @nodoc +abstract class _$$ProfileAvatarStateLoadedImplCopyWith<$Res> { + factory _$$ProfileAvatarStateLoadedImplCopyWith( + _$ProfileAvatarStateLoadedImpl value, + $Res Function(_$ProfileAvatarStateLoadedImpl) then) = + __$$ProfileAvatarStateLoadedImplCopyWithImpl<$Res>; + @useResult + $Res call({ProfileModel profile}); + + $ProfileModelCopyWith<$Res> get profile; +} + +/// @nodoc +class __$$ProfileAvatarStateLoadedImplCopyWithImpl<$Res> + extends _$ProfileAvatarStateCopyWithImpl<$Res, + _$ProfileAvatarStateLoadedImpl> + implements _$$ProfileAvatarStateLoadedImplCopyWith<$Res> { + __$$ProfileAvatarStateLoadedImplCopyWithImpl( + _$ProfileAvatarStateLoadedImpl _value, + $Res Function(_$ProfileAvatarStateLoadedImpl) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? profile = null, + }) { + return _then(_$ProfileAvatarStateLoadedImpl( + profile: null == profile + ? _value.profile + : profile // ignore: cast_nullable_to_non_nullable + as ProfileModel, + )); + } + + @override + @pragma('vm:prefer-inline') + $ProfileModelCopyWith<$Res> get profile { + return $ProfileModelCopyWith<$Res>(_value.profile, (value) { + return _then(_value.copyWith(profile: value)); + }); + } +} + +/// @nodoc + +class _$ProfileAvatarStateLoadedImpl implements ProfileAvatarStateLoaded { + const _$ProfileAvatarStateLoadedImpl({required this.profile}); + + @override + final ProfileModel profile; + + @override + String toString() { + return 'ProfileAvatarState.loaded(profile: $profile)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$ProfileAvatarStateLoadedImpl && + (identical(other.profile, profile) || other.profile == profile)); + } + + @override + int get hashCode => Object.hash(runtimeType, profile); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$ProfileAvatarStateLoadedImplCopyWith<_$ProfileAvatarStateLoadedImpl> + get copyWith => __$$ProfileAvatarStateLoadedImplCopyWithImpl< + _$ProfileAvatarStateLoadedImpl>(this, _$identity); + + @override + @optionalTypeArgs + TResult when( + TResult Function() $default, { + required TResult Function() loading, + required TResult Function(ProfileModel profile) loaded, + required TResult Function(String errorMessage) error, + }) { + return loaded(profile); + } + + @override + @optionalTypeArgs + TResult? whenOrNull( + TResult? Function()? $default, { + TResult? Function()? loading, + TResult? Function(ProfileModel profile)? loaded, + TResult? Function(String errorMessage)? error, + }) { + return loaded?.call(profile); + } + + @override + @optionalTypeArgs + TResult maybeWhen( + TResult Function()? $default, { + TResult Function()? loading, + TResult Function(ProfileModel profile)? loaded, + TResult Function(String errorMessage)? error, + required TResult orElse(), + }) { + if (loaded != null) { + return loaded(profile); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map( + TResult Function(_ProfileAvatarState value) $default, { + required TResult Function(ProfileAvatarStateLoading value) loading, + required TResult Function(ProfileAvatarStateLoaded value) loaded, + required TResult Function(ProfileAvatarStateError value) error, + }) { + return loaded(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull( + TResult? Function(_ProfileAvatarState value)? $default, { + TResult? Function(ProfileAvatarStateLoading value)? loading, + TResult? Function(ProfileAvatarStateLoaded value)? loaded, + TResult? Function(ProfileAvatarStateError value)? error, + }) { + return loaded?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap( + TResult Function(_ProfileAvatarState value)? $default, { + TResult Function(ProfileAvatarStateLoading value)? loading, + TResult Function(ProfileAvatarStateLoaded value)? loaded, + TResult Function(ProfileAvatarStateError value)? error, + required TResult orElse(), + }) { + if (loaded != null) { + return loaded(this); + } + return orElse(); + } +} + +abstract class ProfileAvatarStateLoaded implements ProfileAvatarState { + const factory ProfileAvatarStateLoaded( + {required final ProfileModel profile}) = _$ProfileAvatarStateLoadedImpl; + + ProfileModel get profile; + @JsonKey(ignore: true) + _$$ProfileAvatarStateLoadedImplCopyWith<_$ProfileAvatarStateLoadedImpl> + get copyWith => throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class _$$ProfileAvatarStateErrorImplCopyWith<$Res> { + factory _$$ProfileAvatarStateErrorImplCopyWith( + _$ProfileAvatarStateErrorImpl value, + $Res Function(_$ProfileAvatarStateErrorImpl) then) = + __$$ProfileAvatarStateErrorImplCopyWithImpl<$Res>; + @useResult + $Res call({String errorMessage}); +} + +/// @nodoc +class __$$ProfileAvatarStateErrorImplCopyWithImpl<$Res> + extends _$ProfileAvatarStateCopyWithImpl<$Res, + _$ProfileAvatarStateErrorImpl> + implements _$$ProfileAvatarStateErrorImplCopyWith<$Res> { + __$$ProfileAvatarStateErrorImplCopyWithImpl( + _$ProfileAvatarStateErrorImpl _value, + $Res Function(_$ProfileAvatarStateErrorImpl) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? errorMessage = null, + }) { + return _then(_$ProfileAvatarStateErrorImpl( + errorMessage: null == errorMessage + ? _value.errorMessage + : errorMessage // ignore: cast_nullable_to_non_nullable + as String, + )); + } +} + +/// @nodoc + +class _$ProfileAvatarStateErrorImpl implements ProfileAvatarStateError { + const _$ProfileAvatarStateErrorImpl({required this.errorMessage}); + + @override + final String errorMessage; + + @override + String toString() { + return 'ProfileAvatarState.error(errorMessage: $errorMessage)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$ProfileAvatarStateErrorImpl && + (identical(other.errorMessage, errorMessage) || + other.errorMessage == errorMessage)); + } + + @override + int get hashCode => Object.hash(runtimeType, errorMessage); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$ProfileAvatarStateErrorImplCopyWith<_$ProfileAvatarStateErrorImpl> + get copyWith => __$$ProfileAvatarStateErrorImplCopyWithImpl< + _$ProfileAvatarStateErrorImpl>(this, _$identity); + + @override + @optionalTypeArgs + TResult when( + TResult Function() $default, { + required TResult Function() loading, + required TResult Function(ProfileModel profile) loaded, + required TResult Function(String errorMessage) error, + }) { + return error(errorMessage); + } + + @override + @optionalTypeArgs + TResult? whenOrNull( + TResult? Function()? $default, { + TResult? Function()? loading, + TResult? Function(ProfileModel profile)? loaded, + TResult? Function(String errorMessage)? error, + }) { + return error?.call(errorMessage); + } + + @override + @optionalTypeArgs + TResult maybeWhen( + TResult Function()? $default, { + TResult Function()? loading, + TResult Function(ProfileModel profile)? loaded, + TResult Function(String errorMessage)? error, + required TResult orElse(), + }) { + if (error != null) { + return error(errorMessage); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map( + TResult Function(_ProfileAvatarState value) $default, { + required TResult Function(ProfileAvatarStateLoading value) loading, + required TResult Function(ProfileAvatarStateLoaded value) loaded, + required TResult Function(ProfileAvatarStateError value) error, + }) { + return error(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull( + TResult? Function(_ProfileAvatarState value)? $default, { + TResult? Function(ProfileAvatarStateLoading value)? loading, + TResult? Function(ProfileAvatarStateLoaded value)? loaded, + TResult? Function(ProfileAvatarStateError value)? error, + }) { + return error?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap( + TResult Function(_ProfileAvatarState value)? $default, { + TResult Function(ProfileAvatarStateLoading value)? loading, + TResult Function(ProfileAvatarStateLoaded value)? loaded, + TResult Function(ProfileAvatarStateError value)? error, + required TResult orElse(), + }) { + if (error != null) { + return error(this); + } + return orElse(); + } +} + +abstract class ProfileAvatarStateError implements ProfileAvatarState { + const factory ProfileAvatarStateError({required final String errorMessage}) = + _$ProfileAvatarStateErrorImpl; + + String get errorMessage; + @JsonKey(ignore: true) + _$$ProfileAvatarStateErrorImplCopyWith<_$ProfileAvatarStateErrorImpl> + get copyWith => throw _privateConstructorUsedError; +} diff --git a/lib/features/bottom_navigation_bar/presentation/widgets/bottom_navigation_bar_widget.dart b/lib/features/bottom_navigation_bar/presentation/widgets/bottom_navigation_bar_widget.dart index b3f74075..356d3cc7 100644 --- a/lib/features/bottom_navigation_bar/presentation/widgets/bottom_navigation_bar_widget.dart +++ b/lib/features/bottom_navigation_bar/presentation/widgets/bottom_navigation_bar_widget.dart @@ -4,7 +4,8 @@ import 'package:eatvio_app/features/bottom_navigation_bar/presentation/bloc/new_ import 'package:eatvio_app/features/bottom_navigation_bar/presentation/bloc/new_messages_cubit/new_messages_state.dart'; import 'package:eatvio_app/features/bottom_navigation_bar/presentation/bloc/notifications_cubit/notifications_cubit.dart'; import 'package:eatvio_app/features/bottom_navigation_bar/presentation/bloc/notifications_cubit/notifications_state.dart'; -import 'package:eatvio_app/widgets/custom_navigation_menu.dart'; +import 'package:eatvio_app/features/bottom_navigation_bar/presentation/bloc/profile_avatar_cubit/profile_avatar_cubit.dart'; +import 'package:eatvio_app/features/bottom_navigation_bar/presentation/bloc/profile_avatar_cubit/profile_avatar_state.dart'; import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:go_router/go_router.dart'; @@ -44,22 +45,10 @@ class _BottomNavigationBarWidgetState extends State { GoRouter.of(context).replace('/chat-select-screen'); break; case 4: + GoRouter.of(context).replace('/notifications-screen'); break; case 5: - final RenderBox overlay = Overlay.of(context).context.findRenderObject() as RenderBox; - final size = overlay.size; - showMenu( - context: context, - color: Colors.white, - shadowColor: Colors.white, - surfaceTintColor: Colors.white, - items: [ - PopupMenuItem( - child: CustomNavigationMenu(), - ), - ], - position: RelativeRect.fromLTRB(size.width, size.height, 0, 0), - ); + GoRouter.of(context).replace('/menu-screen'); break; } } @@ -68,119 +57,154 @@ class _BottomNavigationBarWidgetState extends State { Widget build(BuildContext context) { return Scaffold( body: widget.child, - bottomNavigationBar: BottomNavigationBar( - type: BottomNavigationBarType.fixed, - onTap: _onItemTapped, - selectedFontSize: 12, - unselectedFontSize: 12, - selectedItemColor: appTheme.blueA400, - currentIndex: currentBottomNavBarIndex, - items: [ - BottomNavigationBarItem( - label: '', - icon: SvgPicture.asset( - ImageConstant.imgLogo, - ), - ), - BottomNavigationBarItem( - label: 'Лента', - icon: SvgPicture.asset( - colorFilter: ColorFilter.mode(Colors.grey, BlendMode.srcIn), - width: 24, - height: 24, - ImageConstant.icnFeed, - ), - activeIcon: SvgPicture.asset( - ImageConstant.icnFeed, - width: 24, - height: 24, - colorFilter: ColorFilter.mode( - appTheme.blueA400, - BlendMode.srcIn, + bottomNavigationBar: SizedBox( + height: 58, + child: BottomNavigationBar( + type: BottomNavigationBarType.fixed, + onTap: _onItemTapped, + selectedFontSize: 10, + unselectedFontSize: 10, + selectedItemColor: appTheme.blueA400, + currentIndex: currentBottomNavBarIndex, + items: [ + BottomNavigationBarItem( + label: '', + icon: SvgPicture.asset( + ImageConstant.imgLogo, + height: 32, ), ), - ), - BottomNavigationBarItem( - label: "diary".tr, - icon: SvgPicture.asset( - colorFilter: ColorFilter.mode(Colors.grey, BlendMode.srcIn), - ImageConstant.icnDiary, - width: 24, - height: 24, - ), - activeIcon: SvgPicture.asset( - ImageConstant.icnDiary, - width: 24, - height: 24, - colorFilter: ColorFilter.mode( - appTheme.blueA400, - BlendMode.srcIn, + BottomNavigationBarItem( + label: 'Лента', + icon: Padding( + padding: const EdgeInsets.only(bottom: 2), + child: SvgPicture.asset( + colorFilter: ColorFilter.mode(Colors.grey, BlendMode.srcIn), + width: 20, + height: 20, + ImageConstant.icnFeed, + ), + ), + activeIcon: Padding( + padding: const EdgeInsets.only(bottom: 2), + child: SvgPicture.asset( + ImageConstant.icnFeed, + width: 20, + height: 20, + colorFilter: ColorFilter.mode( + appTheme.blueA400, + BlendMode.srcIn, + ), + ), ), ), - ), - BottomNavigationBarItem( - label: "chat".tr, - icon: BlocBuilder( - builder: (BuildContext context, NewMessagesState state) { - return badges.Badge( - position: badges.BadgePosition.topEnd(), - badgeContent: Text( - (state is NewMessagesStateLoaded) ? state.messagesCount.toString() : '0', - style: TextStyle( - color: Colors.white, + BottomNavigationBarItem( + label: "diary".tr, + icon: Padding( + padding: const EdgeInsets.only(bottom: 2), + child: SvgPicture.asset( + colorFilter: ColorFilter.mode(Colors.grey, BlendMode.srcIn), + ImageConstant.icnDiary, + width: 20, + height: 20, + ), + ), + activeIcon: Padding( + padding: const EdgeInsets.only(bottom: 2), + child: SvgPicture.asset( + ImageConstant.icnDiary, + width: 20, + height: 20, + colorFilter: ColorFilter.mode( + appTheme.blueA400, + BlendMode.srcIn, + ), + ), + ), + ), + BottomNavigationBarItem( + label: "chat".tr, + icon: BlocBuilder( + builder: (BuildContext context, NewMessagesState state) { + return badges.Badge( + position: badges.BadgePosition.topEnd(), + badgeAnimation: badges.BadgeAnimation.fade(), + badgeContent: Text( + (state is NewMessagesStateLoaded) ? state.messagesCount.toString() : '0', + style: TextStyle( + color: Colors.white, + fontSize: 8, + ), ), - ), - child: SvgPicture.asset( - ImageConstant.icnChat, - width: 24, - height: 24, - colorFilter: currentBottomNavBarIndex == 3 - ? ColorFilter.mode( - appTheme.blueA400, - BlendMode.srcIn, - ) - : ColorFilter.mode(Colors.grey, BlendMode.srcIn), - ), - ); - }, - ), - ), - BottomNavigationBarItem( - label: '', - icon: BlocBuilder( - builder: (BuildContext context, NotificationsState state) { - return badges.Badge( - position: badges.BadgePosition.topEnd(), - badgeContent: Text( - (state is NotificationsStateLoaded) ? state.notificationsCount.toString() : '0', - style: TextStyle( - color: Colors.white, + child: Padding( + padding: const EdgeInsets.only(bottom: 2), + child: SvgPicture.asset( + ImageConstant.icnChat, + width: 20, + height: 20, + colorFilter: currentBottomNavBarIndex == 3 + ? ColorFilter.mode( + appTheme.blueA400, + BlendMode.srcIn, + ) + : ColorFilter.mode(Colors.grey, BlendMode.srcIn), + ), ), - ), - child: SvgPicture.asset( - ImageConstant.icnBell, - colorFilter: currentBottomNavBarIndex == 4 - ? ColorFilter.mode( - appTheme.blueA400, - BlendMode.srcIn, - ) - : ColorFilter.mode(Colors.grey, BlendMode.srcIn), - width: 24, - height: 24, - ), - ); - }, + ); + }, + ), ), - ), - BottomNavigationBarItem( - label: '', - icon: Image.asset( - ImageConstant.imgEllipse1, - width: 32, - height: 32, + BottomNavigationBarItem( + label: 'Уведомления', + icon: BlocBuilder( + builder: (BuildContext context, NotificationsState state) { + return badges.Badge( + position: badges.BadgePosition.topEnd(), + badgeAnimation: badges.BadgeAnimation.fade(), + badgeContent: Text( + (state is NotificationsStateLoaded) ? state.notificationsCount.toString() : '0', + style: TextStyle( + color: Colors.white, + fontSize: 8, + ), + ), + child: Padding( + padding: const EdgeInsets.only(bottom: 2), + child: SvgPicture.asset( + ImageConstant.icnBell, + colorFilter: currentBottomNavBarIndex == 4 + ? ColorFilter.mode( + appTheme.blueA400, + BlendMode.srcIn, + ) + : ColorFilter.mode(Colors.grey, BlendMode.srcIn), + width: 20, + height: 20, + ), + ), + ); + }, + ), ), - ), - ], + BottomNavigationBarItem( + label: '', + icon: BlocBuilder( + builder: (BuildContext context, ProfileAvatarState state) { + if (state is ProfileAvatarStateLoaded && state.profile.user.profilePhotoUrl.isNotEmpty) { + return CircleAvatar( + backgroundImage: NetworkImage(state.profile.user.profilePhotoUrl), + radius: 16, + ); + } + return CircleAvatar( + radius: 16, + backgroundColor: Colors.black12, + ); + }, + ), + ), + ], + ), ), ); } diff --git a/lib/features/calendar/models/calendar_model.freezed.dart b/lib/features/calendar/models/calendar_model.freezed.dart index d10fc8f2..5e47f848 100644 --- a/lib/features/calendar/models/calendar_model.freezed.dart +++ b/lib/features/calendar/models/calendar_model.freezed.dart @@ -25,12 +25,8 @@ mixin _$CalendarModel { throw _privateConstructorUsedError; Object? get diary => throw _privateConstructorUsedError; - /// Serializes this CalendarModel to a JSON map. Map toJson() => throw _privateConstructorUsedError; - - /// Create a copy of CalendarModel - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) $CalendarModelCopyWith get copyWith => throw _privateConstructorUsedError; } @@ -57,8 +53,6 @@ class _$CalendarModelCopyWithImpl<$Res, $Val extends CalendarModel> // ignore: unused_field final $Res Function($Val) _then; - /// Create a copy of CalendarModel - /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -103,8 +97,6 @@ class __$$CalendarModelImplCopyWithImpl<$Res> _$CalendarModelImpl _value, $Res Function(_$CalendarModelImpl) _then) : super(_value, _then); - /// Create a copy of CalendarModel - /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -165,7 +157,7 @@ class _$CalendarModelImpl implements _CalendarModel { const DeepCollectionEquality().equals(other.diary, diary)); } - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) @override int get hashCode => Object.hash( runtimeType, @@ -173,9 +165,7 @@ class _$CalendarModelImpl implements _CalendarModel { is_current_day_included_in_the_chosen_diet_progression, const DeepCollectionEquality().hash(diary)); - /// Create a copy of CalendarModel - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) @override @pragma('vm:prefer-inline') _$$CalendarModelImplCopyWith<_$CalendarModelImpl> get copyWith => @@ -205,11 +195,8 @@ abstract class _CalendarModel implements CalendarModel { bool get is_current_day_included_in_the_chosen_diet_progression; @override Object? get diary; - - /// Create a copy of CalendarModel - /// with the given fields replaced by the non-null parameter values. @override - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) _$$CalendarModelImplCopyWith<_$CalendarModelImpl> get copyWith => throw _privateConstructorUsedError; } diff --git a/lib/features/calendar/presentation/bloc/calendar_state.freezed.dart b/lib/features/calendar/presentation/bloc/calendar_state.freezed.dart index 0e7bdbcd..c71d5226 100644 --- a/lib/features/calendar/presentation/bloc/calendar_state.freezed.dart +++ b/lib/features/calendar/presentation/bloc/calendar_state.freezed.dart @@ -84,9 +84,6 @@ class _$CalendarStateCopyWithImpl<$Res, $Val extends CalendarState> final $Val _value; // ignore: unused_field final $Res Function($Val) _then; - - /// Create a copy of CalendarState - /// with the given fields replaced by the non-null parameter values. } /// @nodoc @@ -103,9 +100,6 @@ class __$$CalendarStateImplCopyWithImpl<$Res> __$$CalendarStateImplCopyWithImpl( _$CalendarStateImpl _value, $Res Function(_$CalendarStateImpl) _then) : super(_value, _then); - - /// Create a copy of CalendarState - /// with the given fields replaced by the non-null parameter values. } /// @nodoc @@ -220,9 +214,6 @@ class __$$CalendarStateLoadingImplCopyWithImpl<$Res> __$$CalendarStateLoadingImplCopyWithImpl(_$CalendarStateLoadingImpl _value, $Res Function(_$CalendarStateLoadingImpl) _then) : super(_value, _then); - - /// Create a copy of CalendarState - /// with the given fields replaced by the non-null parameter values. } /// @nodoc @@ -341,8 +332,6 @@ class __$$CalendarStateLoadedImplCopyWithImpl<$Res> $Res Function(_$CalendarStateLoadedImpl) _then) : super(_value, _then); - /// Create a copy of CalendarState - /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -390,9 +379,7 @@ class _$CalendarStateLoadedImpl implements CalendarStateLoaded { int get hashCode => Object.hash( runtimeType, const DeepCollectionEquality().hash(_calendarList)); - /// Create a copy of CalendarState - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) @override @pragma('vm:prefer-inline') _$$CalendarStateLoadedImplCopyWith<_$CalendarStateLoadedImpl> get copyWith => @@ -480,10 +467,7 @@ abstract class CalendarStateLoaded implements CalendarState { _$CalendarStateLoadedImpl; List get calendarList; - - /// Create a copy of CalendarState - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) _$$CalendarStateLoadedImplCopyWith<_$CalendarStateLoadedImpl> get copyWith => throw _privateConstructorUsedError; } @@ -505,8 +489,6 @@ class __$$CalendarStateErrorImplCopyWithImpl<$Res> $Res Function(_$CalendarStateErrorImpl) _then) : super(_value, _then); - /// Create a copy of CalendarState - /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -546,9 +528,7 @@ class _$CalendarStateErrorImpl implements CalendarStateError { @override int get hashCode => Object.hash(runtimeType, errorMessage); - /// Create a copy of CalendarState - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) @override @pragma('vm:prefer-inline') _$$CalendarStateErrorImplCopyWith<_$CalendarStateErrorImpl> get copyWith => @@ -635,10 +615,7 @@ abstract class CalendarStateError implements CalendarState { _$CalendarStateErrorImpl; String get errorMessage; - - /// Create a copy of CalendarState - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) _$$CalendarStateErrorImplCopyWith<_$CalendarStateErrorImpl> get copyWith => throw _privateConstructorUsedError; } diff --git a/lib/features/chat/models/chat_message_model.freezed.dart b/lib/features/chat/models/chat_message_model.freezed.dart index 8f921425..76a91cbc 100644 --- a/lib/features/chat/models/chat_message_model.freezed.dart +++ b/lib/features/chat/models/chat_message_model.freezed.dart @@ -29,12 +29,8 @@ mixin _$ChatMessageModel { @JsonKey(name: 'updated_at') String get updatedAt => throw _privateConstructorUsedError; - /// Serializes this ChatMessageModel to a JSON map. Map toJson() => throw _privateConstructorUsedError; - - /// Create a copy of ChatMessageModel - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) $ChatMessageModelCopyWith get copyWith => throw _privateConstructorUsedError; } @@ -63,8 +59,6 @@ class _$ChatMessageModelCopyWithImpl<$Res, $Val extends ChatMessageModel> // ignore: unused_field final $Res Function($Val) _then; - /// Create a copy of ChatMessageModel - /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -123,8 +117,6 @@ class __$$ChatMessageModelImplCopyWithImpl<$Res> $Res Function(_$ChatMessageModelImpl) _then) : super(_value, _then); - /// Create a copy of ChatMessageModel - /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -215,14 +207,12 @@ class _$ChatMessageModelImpl implements _ChatMessageModel { other.updatedAt == updatedAt)); } - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) @override int get hashCode => Object.hash(runtimeType, id, data, const DeepCollectionEquality().hash(_mediaData), authorId, updatedAt); - /// Create a copy of ChatMessageModel - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) @override @pragma('vm:prefer-inline') _$$ChatMessageModelImplCopyWith<_$ChatMessageModelImpl> get copyWith => @@ -262,11 +252,8 @@ abstract class _ChatMessageModel implements ChatMessageModel { @override @JsonKey(name: 'updated_at') String get updatedAt; - - /// Create a copy of ChatMessageModel - /// with the given fields replaced by the non-null parameter values. @override - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) _$$ChatMessageModelImplCopyWith<_$ChatMessageModelImpl> get copyWith => throw _privateConstructorUsedError; } diff --git a/lib/features/chat/models/chat_messages_model.freezed.dart b/lib/features/chat/models/chat_messages_model.freezed.dart index 852b33e4..a970241c 100644 --- a/lib/features/chat/models/chat_messages_model.freezed.dart +++ b/lib/features/chat/models/chat_messages_model.freezed.dart @@ -24,12 +24,8 @@ mixin _$ChatMessagesModel { List get messagesList => throw _privateConstructorUsedError; ChatMetaModel get meta => throw _privateConstructorUsedError; - /// Serializes this ChatMessagesModel to a JSON map. Map toJson() => throw _privateConstructorUsedError; - - /// Create a copy of ChatMessagesModel - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) $ChatMessagesModelCopyWith get copyWith => throw _privateConstructorUsedError; } @@ -57,8 +53,6 @@ class _$ChatMessagesModelCopyWithImpl<$Res, $Val extends ChatMessagesModel> // ignore: unused_field final $Res Function($Val) _then; - /// Create a copy of ChatMessagesModel - /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -77,8 +71,6 @@ class _$ChatMessagesModelCopyWithImpl<$Res, $Val extends ChatMessagesModel> ) as $Val); } - /// Create a copy of ChatMessagesModel - /// with the given fields replaced by the non-null parameter values. @override @pragma('vm:prefer-inline') $ChatMetaModelCopyWith<$Res> get meta { @@ -112,8 +104,6 @@ class __$$ChatMessagesModelImplCopyWithImpl<$Res> $Res Function(_$ChatMessagesModelImpl) _then) : super(_value, _then); - /// Create a copy of ChatMessagesModel - /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -172,14 +162,12 @@ class _$ChatMessagesModelImpl implements _ChatMessagesModel { (identical(other.meta, meta) || other.meta == meta)); } - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) @override int get hashCode => Object.hash( runtimeType, const DeepCollectionEquality().hash(_messagesList), meta); - /// Create a copy of ChatMessagesModel - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) @override @pragma('vm:prefer-inline') _$$ChatMessagesModelImplCopyWith<_$ChatMessagesModelImpl> get copyWith => @@ -208,11 +196,8 @@ abstract class _ChatMessagesModel implements ChatMessagesModel { List get messagesList; @override ChatMetaModel get meta; - - /// Create a copy of ChatMessagesModel - /// with the given fields replaced by the non-null parameter values. @override - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) _$$ChatMessagesModelImplCopyWith<_$ChatMessagesModelImpl> get copyWith => throw _privateConstructorUsedError; } diff --git a/lib/features/chat/models/chat_meta_model.freezed.dart b/lib/features/chat/models/chat_meta_model.freezed.dart index e8e4e96b..11ecb9e2 100644 --- a/lib/features/chat/models/chat_meta_model.freezed.dart +++ b/lib/features/chat/models/chat_meta_model.freezed.dart @@ -23,12 +23,8 @@ mixin _$ChatMetaModel { @JsonKey(name: "last_page") int get lastPage => throw _privateConstructorUsedError; - /// Serializes this ChatMetaModel to a JSON map. Map toJson() => throw _privateConstructorUsedError; - - /// Create a copy of ChatMetaModel - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) $ChatMetaModelCopyWith get copyWith => throw _privateConstructorUsedError; } @@ -52,8 +48,6 @@ class _$ChatMetaModelCopyWithImpl<$Res, $Val extends ChatMetaModel> // ignore: unused_field final $Res Function($Val) _then; - /// Create a copy of ChatMetaModel - /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -87,8 +81,6 @@ class __$$ChatMetaModelImplCopyWithImpl<$Res> _$ChatMetaModelImpl _value, $Res Function(_$ChatMetaModelImpl) _then) : super(_value, _then); - /// Create a copy of ChatMetaModel - /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -130,13 +122,11 @@ class _$ChatMetaModelImpl implements _ChatMetaModel { other.lastPage == lastPage)); } - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) @override int get hashCode => Object.hash(runtimeType, lastPage); - /// Create a copy of ChatMetaModel - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) @override @pragma('vm:prefer-inline') _$$ChatMetaModelImplCopyWith<_$ChatMetaModelImpl> get copyWith => @@ -161,11 +151,8 @@ abstract class _ChatMetaModel implements ChatMetaModel { @override @JsonKey(name: "last_page") int get lastPage; - - /// Create a copy of ChatMetaModel - /// with the given fields replaced by the non-null parameter values. @override - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) _$$ChatMetaModelImplCopyWith<_$ChatMetaModelImpl> get copyWith => throw _privateConstructorUsedError; } diff --git a/lib/features/chat/models/chat_room_model.freezed.dart b/lib/features/chat/models/chat_room_model.freezed.dart index 6afb3a94..5a0b6e62 100644 --- a/lib/features/chat/models/chat_room_model.freezed.dart +++ b/lib/features/chat/models/chat_room_model.freezed.dart @@ -26,12 +26,8 @@ mixin _$ChatRoomModel { throw _privateConstructorUsedError; Map get users => throw _privateConstructorUsedError; - /// Serializes this ChatRoomModel to a JSON map. Map toJson() => throw _privateConstructorUsedError; - - /// Create a copy of ChatRoomModel - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) $ChatRoomModelCopyWith get copyWith => throw _privateConstructorUsedError; } @@ -61,8 +57,6 @@ class _$ChatRoomModelCopyWithImpl<$Res, $Val extends ChatRoomModel> // ignore: unused_field final $Res Function($Val) _then; - /// Create a copy of ChatRoomModel - /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -86,8 +80,6 @@ class _$ChatRoomModelCopyWithImpl<$Res, $Val extends ChatRoomModel> ) as $Val); } - /// Create a copy of ChatRoomModel - /// with the given fields replaced by the non-null parameter values. @override @pragma('vm:prefer-inline') $ChatRoomSettingsModelCopyWith<$Res> get chatRoomSettings { @@ -124,8 +116,6 @@ class __$$ChatRoomModelImplCopyWithImpl<$Res> _$ChatRoomModelImpl _value, $Res Function(_$ChatRoomModelImpl) _then) : super(_value, _then); - /// Create a copy of ChatRoomModel - /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -191,14 +181,12 @@ class _$ChatRoomModelImpl implements _ChatRoomModel { const DeepCollectionEquality().equals(other._users, _users)); } - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) @override int get hashCode => Object.hash(runtimeType, id, chatRoomSettings, const DeepCollectionEquality().hash(_users)); - /// Create a copy of ChatRoomModel - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) @override @pragma('vm:prefer-inline') _$$ChatRoomModelImplCopyWith<_$ChatRoomModelImpl> get copyWith => @@ -229,11 +217,8 @@ abstract class _ChatRoomModel implements ChatRoomModel { ChatRoomSettingsModel get chatRoomSettings; @override Map get users; - - /// Create a copy of ChatRoomModel - /// with the given fields replaced by the non-null parameter values. @override - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) _$$ChatRoomModelImplCopyWith<_$ChatRoomModelImpl> get copyWith => throw _privateConstructorUsedError; } diff --git a/lib/features/chat/models/chat_room_preview_model.freezed.dart b/lib/features/chat/models/chat_room_preview_model.freezed.dart index 4b006cf0..8d41bd4b 100644 --- a/lib/features/chat/models/chat_room_preview_model.freezed.dart +++ b/lib/features/chat/models/chat_room_preview_model.freezed.dart @@ -23,12 +23,8 @@ mixin _$ChatRoomPreviewModel { @JsonKey(name: "chatRooms") List get chatRooms => throw _privateConstructorUsedError; - /// Serializes this ChatRoomPreviewModel to a JSON map. Map toJson() => throw _privateConstructorUsedError; - - /// Create a copy of ChatRoomPreviewModel - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) $ChatRoomPreviewModelCopyWith get copyWith => throw _privateConstructorUsedError; } @@ -53,8 +49,6 @@ class _$ChatRoomPreviewModelCopyWithImpl<$Res, // ignore: unused_field final $Res Function($Val) _then; - /// Create a copy of ChatRoomPreviewModel - /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -88,8 +82,6 @@ class __$$ChatRoomPreviewModelImplCopyWithImpl<$Res> $Res Function(_$ChatRoomPreviewModelImpl) _then) : super(_value, _then); - /// Create a copy of ChatRoomPreviewModel - /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -137,14 +129,12 @@ class _$ChatRoomPreviewModelImpl implements _ChatRoomPreviewModel { .equals(other._chatRooms, _chatRooms)); } - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) @override int get hashCode => Object.hash(runtimeType, const DeepCollectionEquality().hash(_chatRooms)); - /// Create a copy of ChatRoomPreviewModel - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) @override @pragma('vm:prefer-inline') _$$ChatRoomPreviewModelImplCopyWith<_$ChatRoomPreviewModelImpl> @@ -171,11 +161,8 @@ abstract class _ChatRoomPreviewModel implements ChatRoomPreviewModel { @override @JsonKey(name: "chatRooms") List get chatRooms; - - /// Create a copy of ChatRoomPreviewModel - /// with the given fields replaced by the non-null parameter values. @override - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) _$$ChatRoomPreviewModelImplCopyWith<_$ChatRoomPreviewModelImpl> get copyWith => throw _privateConstructorUsedError; } @@ -195,12 +182,8 @@ mixin _$ChatRoom { @JsonKey(name: "users") Users get users => throw _privateConstructorUsedError; - /// Serializes this ChatRoom to a JSON map. Map toJson() => throw _privateConstructorUsedError; - - /// Create a copy of ChatRoom - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) $ChatRoomCopyWith get copyWith => throw _privateConstructorUsedError; } @@ -229,8 +212,6 @@ class _$ChatRoomCopyWithImpl<$Res, $Val extends ChatRoom> // ignore: unused_field final $Res Function($Val) _then; - /// Create a copy of ChatRoom - /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -259,8 +240,6 @@ class _$ChatRoomCopyWithImpl<$Res, $Val extends ChatRoom> ) as $Val); } - /// Create a copy of ChatRoom - /// with the given fields replaced by the non-null parameter values. @override @pragma('vm:prefer-inline') $UsersCopyWith<$Res> get users { @@ -296,8 +275,6 @@ class __$$ChatRoomImplCopyWithImpl<$Res> _$ChatRoomImpl _value, $Res Function(_$ChatRoomImpl) _then) : super(_value, _then); - /// Create a copy of ChatRoom - /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -370,14 +347,12 @@ class _$ChatRoomImpl implements _ChatRoom { (identical(other.users, users) || other.users == users)); } - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) @override int get hashCode => Object.hash(runtimeType, id, roomName, const DeepCollectionEquality().hash(lastMessage), users); - /// Create a copy of ChatRoom - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) @override @pragma('vm:prefer-inline') _$$ChatRoomImplCopyWith<_$ChatRoomImpl> get copyWith => @@ -413,11 +388,8 @@ abstract class _ChatRoom implements ChatRoom { @override @JsonKey(name: "users") Users get users; - - /// Create a copy of ChatRoom - /// with the given fields replaced by the non-null parameter values. @override - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) _$$ChatRoomImplCopyWith<_$ChatRoomImpl> get copyWith => throw _privateConstructorUsedError; } @@ -443,12 +415,8 @@ mixin _$LastMessageClass { @JsonKey(name: "updated_at") DateTime get updatedAt => throw _privateConstructorUsedError; - /// Serializes this LastMessageClass to a JSON map. Map toJson() => throw _privateConstructorUsedError; - - /// Create a copy of LastMessageClass - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) $LastMessageClassCopyWith get copyWith => throw _privateConstructorUsedError; } @@ -480,8 +448,6 @@ class _$LastMessageClassCopyWithImpl<$Res, $Val extends LastMessageClass> // ignore: unused_field final $Res Function($Val) _then; - /// Create a copy of LastMessageClass - /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -553,8 +519,6 @@ class __$$LastMessageClassImplCopyWithImpl<$Res> $Res Function(_$LastMessageClassImpl) _then) : super(_value, _then); - /// Create a copy of LastMessageClass - /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -669,7 +633,7 @@ class _$LastMessageClassImpl implements _LastMessageClass { other.updatedAt == updatedAt)); } - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) @override int get hashCode => Object.hash( runtimeType, @@ -681,9 +645,7 @@ class _$LastMessageClassImpl implements _LastMessageClass { readByToUser, updatedAt); - /// Create a copy of LastMessageClass - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) @override @pragma('vm:prefer-inline') _$$LastMessageClassImplCopyWith<_$LastMessageClassImpl> get copyWith => @@ -734,11 +696,8 @@ abstract class _LastMessageClass implements LastMessageClass { @override @JsonKey(name: "updated_at") DateTime get updatedAt; - - /// Create a copy of LastMessageClass - /// with the given fields replaced by the non-null parameter values. @override - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) _$$LastMessageClassImplCopyWith<_$LastMessageClassImpl> get copyWith => throw _privateConstructorUsedError; } @@ -754,12 +713,8 @@ mixin _$Users { @JsonKey(name: "to_chat_user") ChatUser get toChatUser => throw _privateConstructorUsedError; - /// Serializes this Users to a JSON map. Map toJson() => throw _privateConstructorUsedError; - - /// Create a copy of Users - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) $UsersCopyWith get copyWith => throw _privateConstructorUsedError; } @@ -786,8 +741,6 @@ class _$UsersCopyWithImpl<$Res, $Val extends Users> // ignore: unused_field final $Res Function($Val) _then; - /// Create a copy of Users - /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -806,8 +759,6 @@ class _$UsersCopyWithImpl<$Res, $Val extends Users> ) as $Val); } - /// Create a copy of Users - /// with the given fields replaced by the non-null parameter values. @override @pragma('vm:prefer-inline') $ChatUserCopyWith<$Res> get fromChatUser { @@ -816,8 +767,6 @@ class _$UsersCopyWithImpl<$Res, $Val extends Users> }); } - /// Create a copy of Users - /// with the given fields replaced by the non-null parameter values. @override @pragma('vm:prefer-inline') $ChatUserCopyWith<$Res> get toChatUser { @@ -852,8 +801,6 @@ class __$$UsersImplCopyWithImpl<$Res> _$UsersImpl _value, $Res Function(_$UsersImpl) _then) : super(_value, _then); - /// Create a copy of Users - /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -906,13 +853,11 @@ class _$UsersImpl implements _Users { other.toChatUser == toChatUser)); } - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) @override int get hashCode => Object.hash(runtimeType, fromChatUser, toChatUser); - /// Create a copy of Users - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) @override @pragma('vm:prefer-inline') _$$UsersImplCopyWith<_$UsersImpl> get copyWith => @@ -940,11 +885,8 @@ abstract class _Users implements Users { @override @JsonKey(name: "to_chat_user") ChatUser get toChatUser; - - /// Create a copy of Users - /// with the given fields replaced by the non-null parameter values. @override - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) _$$UsersImplCopyWith<_$UsersImpl> get copyWith => throw _privateConstructorUsedError; } @@ -964,12 +906,8 @@ mixin _$ChatUser { @JsonKey(name: "profile_photo_url") String get profilePhotoUrl => throw _privateConstructorUsedError; - /// Serializes this ChatUser to a JSON map. Map toJson() => throw _privateConstructorUsedError; - - /// Create a copy of ChatUser - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) $ChatUserCopyWith get copyWith => throw _privateConstructorUsedError; } @@ -996,8 +934,6 @@ class _$ChatUserCopyWithImpl<$Res, $Val extends ChatUser> // ignore: unused_field final $Res Function($Val) _then; - /// Create a copy of ChatUser - /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -1050,8 +986,6 @@ class __$$ChatUserImplCopyWithImpl<$Res> _$ChatUserImpl _value, $Res Function(_$ChatUserImpl) _then) : super(_value, _then); - /// Create a copy of ChatUser - /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -1124,14 +1058,12 @@ class _$ChatUserImpl implements _ChatUser { other.profilePhotoUrl == profilePhotoUrl)); } - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) @override int get hashCode => Object.hash(runtimeType, id, name, profilePhotoPath, profilePhotoUrl); - /// Create a copy of ChatUser - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) @override @pragma('vm:prefer-inline') _$$ChatUserImplCopyWith<_$ChatUserImpl> get copyWith => @@ -1169,11 +1101,8 @@ abstract class _ChatUser implements ChatUser { @override @JsonKey(name: "profile_photo_url") String get profilePhotoUrl; - - /// Create a copy of ChatUser - /// with the given fields replaced by the non-null parameter values. @override - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) _$$ChatUserImplCopyWith<_$ChatUserImpl> get copyWith => throw _privateConstructorUsedError; } diff --git a/lib/features/chat/models/chat_room_settings_model.freezed.dart b/lib/features/chat/models/chat_room_settings_model.freezed.dart index 9d12eefa..4f217556 100644 --- a/lib/features/chat/models/chat_room_settings_model.freezed.dart +++ b/lib/features/chat/models/chat_room_settings_model.freezed.dart @@ -30,12 +30,8 @@ mixin _$ChatRoomSettingsModel { @JsonKey(name: 'updated_at') String get updatedAt => throw _privateConstructorUsedError; - /// Serializes this ChatRoomSettingsModel to a JSON map. Map toJson() => throw _privateConstructorUsedError; - - /// Create a copy of ChatRoomSettingsModel - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) $ChatRoomSettingsModelCopyWith get copyWith => throw _privateConstructorUsedError; } @@ -65,8 +61,6 @@ class _$ChatRoomSettingsModelCopyWithImpl<$Res, // ignore: unused_field final $Res Function($Val) _then; - /// Create a copy of ChatRoomSettingsModel - /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -127,8 +121,6 @@ class __$$ChatRoomSettingsModelImplCopyWithImpl<$Res> $Res Function(_$ChatRoomSettingsModelImpl) _then) : super(_value, _then); - /// Create a copy of ChatRoomSettingsModel - /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -210,14 +202,12 @@ class _$ChatRoomSettingsModelImpl implements _ChatRoomSettingsModel { other.updatedAt == updatedAt)); } - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) @override int get hashCode => Object.hash(runtimeType, id, roomName, state, accessLevel, updatedAt); - /// Create a copy of ChatRoomSettingsModel - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) @override @pragma('vm:prefer-inline') _$$ChatRoomSettingsModelImplCopyWith<_$ChatRoomSettingsModelImpl> @@ -257,11 +247,8 @@ abstract class _ChatRoomSettingsModel implements ChatRoomSettingsModel { @override @JsonKey(name: 'updated_at') String get updatedAt; - - /// Create a copy of ChatRoomSettingsModel - /// with the given fields replaced by the non-null parameter values. @override - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) _$$ChatRoomSettingsModelImplCopyWith<_$ChatRoomSettingsModelImpl> get copyWith => throw _privateConstructorUsedError; } diff --git a/lib/features/chat/models/chat_user_model.freezed.dart b/lib/features/chat/models/chat_user_model.freezed.dart index 94718168..095c09e2 100644 --- a/lib/features/chat/models/chat_user_model.freezed.dart +++ b/lib/features/chat/models/chat_user_model.freezed.dart @@ -27,12 +27,8 @@ mixin _$ChatUserModel { @JsonKey(name: 'profile_photo_url') String? get profilePhotoUrl => throw _privateConstructorUsedError; - /// Serializes this ChatUserModel to a JSON map. Map toJson() => throw _privateConstructorUsedError; - - /// Create a copy of ChatUserModel - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) $ChatUserModelCopyWith get copyWith => throw _privateConstructorUsedError; } @@ -60,8 +56,6 @@ class _$ChatUserModelCopyWithImpl<$Res, $Val extends ChatUserModel> // ignore: unused_field final $Res Function($Val) _then; - /// Create a copy of ChatUserModel - /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -114,8 +108,6 @@ class __$$ChatUserModelImplCopyWithImpl<$Res> _$ChatUserModelImpl _value, $Res Function(_$ChatUserModelImpl) _then) : super(_value, _then); - /// Create a copy of ChatUserModel - /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -186,14 +178,12 @@ class _$ChatUserModelImpl implements _ChatUserModel { other.profilePhotoUrl == profilePhotoUrl)); } - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) @override int get hashCode => Object.hash(runtimeType, id, name, profilePhotoPath, profilePhotoUrl); - /// Create a copy of ChatUserModel - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) @override @pragma('vm:prefer-inline') _$$ChatUserModelImplCopyWith<_$ChatUserModelImpl> get copyWith => @@ -228,11 +218,8 @@ abstract class _ChatUserModel implements ChatUserModel { @override @JsonKey(name: 'profile_photo_url') String? get profilePhotoUrl; - - /// Create a copy of ChatUserModel - /// with the given fields replaced by the non-null parameter values. @override - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) _$$ChatUserModelImplCopyWith<_$ChatUserModelImpl> get copyWith => throw _privateConstructorUsedError; } diff --git a/lib/features/chat/models/websocket_info_model.freezed.dart b/lib/features/chat/models/websocket_info_model.freezed.dart index 9cddabee..cd383a2b 100644 --- a/lib/features/chat/models/websocket_info_model.freezed.dart +++ b/lib/features/chat/models/websocket_info_model.freezed.dart @@ -27,12 +27,8 @@ mixin _$WebsocketInfoModel { @JsonKey(name: 'user_id') int get userId => throw _privateConstructorUsedError; - /// Serializes this WebsocketInfoModel to a JSON map. Map toJson() => throw _privateConstructorUsedError; - - /// Create a copy of WebsocketInfoModel - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) $WebsocketInfoModelCopyWith get copyWith => throw _privateConstructorUsedError; } @@ -61,8 +57,6 @@ class _$WebsocketInfoModelCopyWithImpl<$Res, $Val extends WebsocketInfoModel> // ignore: unused_field final $Res Function($Val) _then; - /// Create a copy of WebsocketInfoModel - /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -121,8 +115,6 @@ class __$$WebsocketInfoModelImplCopyWithImpl<$Res> $Res Function(_$WebsocketInfoModelImpl) _then) : super(_value, _then); - /// Create a copy of WebsocketInfoModel - /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -199,14 +191,12 @@ class _$WebsocketInfoModelImpl implements _WebsocketInfoModel { (identical(other.userId, userId) || other.userId == userId)); } - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) @override int get hashCode => Object.hash(runtimeType, key, host, port, cluster, userId); - /// Create a copy of WebsocketInfoModel - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) @override @pragma('vm:prefer-inline') _$$WebsocketInfoModelImplCopyWith<_$WebsocketInfoModelImpl> get copyWith => @@ -244,11 +234,8 @@ abstract class _WebsocketInfoModel implements WebsocketInfoModel { @override @JsonKey(name: 'user_id') int get userId; - - /// Create a copy of WebsocketInfoModel - /// with the given fields replaced by the non-null parameter values. @override - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) _$$WebsocketInfoModelImplCopyWith<_$WebsocketInfoModelImpl> get copyWith => throw _privateConstructorUsedError; } diff --git a/lib/features/chat/presentation/bloc/chat_room_cubit/chat_room_cubit.dart b/lib/features/chat/presentation/bloc/chat_room_cubit/chat_room_cubit.dart index 4a558925..9140a6bd 100644 --- a/lib/features/chat/presentation/bloc/chat_room_cubit/chat_room_cubit.dart +++ b/lib/features/chat/presentation/bloc/chat_room_cubit/chat_room_cubit.dart @@ -1,6 +1,7 @@ import 'dart:convert'; import 'dart:io'; +import 'package:audioplayers/audioplayers.dart'; import 'package:dart_pusher_channels/dart_pusher_channels.dart'; import 'package:easy_debounce/easy_debounce.dart'; import 'package:eatvio_app/core/constants/constants.dart'; @@ -65,7 +66,7 @@ class ChatRoomCubit extends Cubit { final chatMessages = await chatRepository.getChatMessages(chatId, currentPage); lastPage = chatMessages.meta.lastPage; - await subscribeToChatChannel(initCubit: initializationCubit, chatId: chatId); + await _subscribeToChatChannel(initCubit: initializationCubit, chatId: chatId); emit(ChatRoomState.loaded( chatRoom: chatRoom, @@ -79,7 +80,7 @@ class ChatRoomCubit extends Cubit { } } - Future subscribeToChatChannel({ + Future _subscribeToChatChannel({ required InitializationCubit initCubit, required String chatId, }) async { @@ -98,7 +99,7 @@ class ChatRoomCubit extends Cubit { privateChatChannel.subscribe(); privateChatChannel.bind('App\\Events\\ChatMessageUpdated').listen((event) { - print(jsonDecode(event.data)); + AudioPlayer().play((AssetSource('audio/recive_message.wav'))); List messagesList = [ ChatMessageModel.fromJson(jsonDecode(event.data)['message']), ...(state as ChatRoomStateLoaded).chatMessages, @@ -147,6 +148,7 @@ class ChatRoomCubit extends Cubit { data: data, files: files, ); + AudioPlayer().play((AssetSource('audio/send_message.wav'))); } @override diff --git a/lib/features/chat/presentation/bloc/chat_room_cubit/chat_room_state.freezed.dart b/lib/features/chat/presentation/bloc/chat_room_cubit/chat_room_state.freezed.dart index 4695b4ad..43bf9df9 100644 --- a/lib/features/chat/presentation/bloc/chat_room_cubit/chat_room_state.freezed.dart +++ b/lib/features/chat/presentation/bloc/chat_room_cubit/chat_room_state.freezed.dart @@ -90,9 +90,6 @@ class _$ChatRoomStateCopyWithImpl<$Res, $Val extends ChatRoomState> final $Val _value; // ignore: unused_field final $Res Function($Val) _then; - - /// Create a copy of ChatRoomState - /// with the given fields replaced by the non-null parameter values. } /// @nodoc @@ -109,9 +106,6 @@ class __$$ChatRoomStateImplCopyWithImpl<$Res> __$$ChatRoomStateImplCopyWithImpl( _$ChatRoomStateImpl _value, $Res Function(_$ChatRoomStateImpl) _then) : super(_value, _then); - - /// Create a copy of ChatRoomState - /// with the given fields replaced by the non-null parameter values. } /// @nodoc @@ -232,9 +226,6 @@ class __$$ChatRoomStateLoadingImplCopyWithImpl<$Res> __$$ChatRoomStateLoadingImplCopyWithImpl(_$ChatRoomStateLoadingImpl _value, $Res Function(_$ChatRoomStateLoadingImpl) _then) : super(_value, _then); - - /// Create a copy of ChatRoomState - /// with the given fields replaced by the non-null parameter values. } /// @nodoc @@ -365,8 +356,6 @@ class __$$ChatRoomStateLoadedImplCopyWithImpl<$Res> $Res Function(_$ChatRoomStateLoadedImpl) _then) : super(_value, _then); - /// Create a copy of ChatRoomState - /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -395,8 +384,6 @@ class __$$ChatRoomStateLoadedImplCopyWithImpl<$Res> )); } - /// Create a copy of ChatRoomState - /// with the given fields replaced by the non-null parameter values. @override @pragma('vm:prefer-inline') $ChatRoomModelCopyWith<$Res> get chatRoom { @@ -455,9 +442,7 @@ class _$ChatRoomStateLoadedImpl implements ChatRoomStateLoaded { int get hashCode => Object.hash(runtimeType, chatRoom, const DeepCollectionEquality().hash(_chatMessages), isTyping, isLoading); - /// Create a copy of ChatRoomState - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) @override @pragma('vm:prefer-inline') _$$ChatRoomStateLoadedImplCopyWith<_$ChatRoomStateLoadedImpl> get copyWith => @@ -556,10 +541,7 @@ abstract class ChatRoomStateLoaded implements ChatRoomState { List get chatMessages; bool get isTyping; bool get isLoading; - - /// Create a copy of ChatRoomState - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) _$$ChatRoomStateLoadedImplCopyWith<_$ChatRoomStateLoadedImpl> get copyWith => throw _privateConstructorUsedError; } @@ -581,8 +563,6 @@ class __$$ChatRoomStateErrorImplCopyWithImpl<$Res> $Res Function(_$ChatRoomStateErrorImpl) _then) : super(_value, _then); - /// Create a copy of ChatRoomState - /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -622,9 +602,7 @@ class _$ChatRoomStateErrorImpl implements ChatRoomStateError { @override int get hashCode => Object.hash(runtimeType, errorMessage); - /// Create a copy of ChatRoomState - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) @override @pragma('vm:prefer-inline') _$$ChatRoomStateErrorImplCopyWith<_$ChatRoomStateErrorImpl> get copyWith => @@ -717,10 +695,7 @@ abstract class ChatRoomStateError implements ChatRoomState { _$ChatRoomStateErrorImpl; String get errorMessage; - - /// Create a copy of ChatRoomState - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) _$$ChatRoomStateErrorImplCopyWith<_$ChatRoomStateErrorImpl> get copyWith => throw _privateConstructorUsedError; } diff --git a/lib/features/chat/presentation/bloc/chat_select_cubit/chat_select_state.freezed.dart b/lib/features/chat/presentation/bloc/chat_select_cubit/chat_select_state.freezed.dart index 99fa9054..9a05918d 100644 --- a/lib/features/chat/presentation/bloc/chat_select_cubit/chat_select_state.freezed.dart +++ b/lib/features/chat/presentation/bloc/chat_select_cubit/chat_select_state.freezed.dart @@ -84,9 +84,6 @@ class _$ChatSelectStateCopyWithImpl<$Res, $Val extends ChatSelectState> final $Val _value; // ignore: unused_field final $Res Function($Val) _then; - - /// Create a copy of ChatSelectState - /// with the given fields replaced by the non-null parameter values. } /// @nodoc @@ -103,9 +100,6 @@ class __$$ChatSelectStateImplCopyWithImpl<$Res> __$$ChatSelectStateImplCopyWithImpl( _$ChatSelectStateImpl _value, $Res Function(_$ChatSelectStateImpl) _then) : super(_value, _then); - - /// Create a copy of ChatSelectState - /// with the given fields replaced by the non-null parameter values. } /// @nodoc @@ -222,9 +216,6 @@ class __$$ChatSelectStateLoadingImplCopyWithImpl<$Res> _$ChatSelectStateLoadingImpl _value, $Res Function(_$ChatSelectStateLoadingImpl) _then) : super(_value, _then); - - /// Create a copy of ChatSelectState - /// with the given fields replaced by the non-null parameter values. } /// @nodoc @@ -343,8 +334,6 @@ class __$$ChatSelectStateErrorImplCopyWithImpl<$Res> $Res Function(_$ChatSelectStateErrorImpl) _then) : super(_value, _then); - /// Create a copy of ChatSelectState - /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -384,9 +373,7 @@ class _$ChatSelectStateErrorImpl implements ChatSelectStateError { @override int get hashCode => Object.hash(runtimeType, errorMessage); - /// Create a copy of ChatSelectState - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) @override @pragma('vm:prefer-inline') _$$ChatSelectStateErrorImplCopyWith<_$ChatSelectStateErrorImpl> @@ -474,10 +461,7 @@ abstract class ChatSelectStateError implements ChatSelectState { _$ChatSelectStateErrorImpl; String get errorMessage; - - /// Create a copy of ChatSelectState - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) _$$ChatSelectStateErrorImplCopyWith<_$ChatSelectStateErrorImpl> get copyWith => throw _privateConstructorUsedError; } @@ -500,8 +484,6 @@ class __$$ChatSelectStateLoadedImplCopyWithImpl<$Res> $Res Function(_$ChatSelectStateLoadedImpl) _then) : super(_value, _then); - /// Create a copy of ChatSelectState - /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -548,9 +530,7 @@ class _$ChatSelectStateLoadedImpl implements ChatSelectStateLoaded { int get hashCode => Object.hash(runtimeType, const DeepCollectionEquality().hash(_chatRooms)); - /// Create a copy of ChatSelectState - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) @override @pragma('vm:prefer-inline') _$$ChatSelectStateLoadedImplCopyWith<_$ChatSelectStateLoadedImpl> @@ -637,10 +617,7 @@ abstract class ChatSelectStateLoaded implements ChatSelectState { {required final List chatRooms}) = _$ChatSelectStateLoadedImpl; List get chatRooms; - - /// Create a copy of ChatSelectState - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) _$$ChatSelectStateLoadedImplCopyWith<_$ChatSelectStateLoadedImpl> get copyWith => throw _privateConstructorUsedError; } diff --git a/lib/features/chat/presentation/pages/chat_screen.dart b/lib/features/chat/presentation/pages/chat_screen.dart index eed575cb..fac8c5eb 100644 --- a/lib/features/chat/presentation/pages/chat_screen.dart +++ b/lib/features/chat/presentation/pages/chat_screen.dart @@ -1,5 +1,4 @@ import 'dart:io'; - import 'package:eatvio_app/core/app_export.dart'; import 'package:eatvio_app/features/chat/presentation/bloc/chat_room_cubit/chat_room_cubit.dart'; import 'package:eatvio_app/features/chat/presentation/bloc/chat_room_cubit/chat_room_state.dart'; @@ -60,23 +59,29 @@ class _ChatScreenState extends State { centerTitle: false, title: Row( children: [ - Container( - width: 40, - height: 40, - alignment: Alignment.center, - decoration: BoxDecoration( - color: Color(0xFFEBF4FF), - shape: BoxShape.circle, + if (state.chatRoom.users['to_chat_user']!.profilePhotoUrl != null) + CircleAvatar( + radius: 20, + foregroundImage: NetworkImage(state.chatRoom.users['to_chat_user']!.profilePhotoUrl!), ), - child: Text( - state.chatRoom.users['to_chat_user']!.name.split(' ').first[0] + state.chatRoom.users['to_chat_user']!.name.split(' ')[1][0], - style: TextStyle( - color: Color(0xFF7F9CF5), - fontWeight: FontWeight.w400, - fontSize: 20, + if (state.chatRoom.users['to_chat_user']!.profilePhotoUrl == null) + Container( + width: 40, + height: 40, + alignment: Alignment.center, + decoration: BoxDecoration( + color: Color(0xFFEBF4FF), + shape: BoxShape.circle, + ), + child: Text( + state.chatRoom.users['to_chat_user']!.name.split(' ').first[0] + state.chatRoom.users['to_chat_user']!.name.split(' ')[1][0], + style: TextStyle( + color: Color(0xFF7F9CF5), + fontWeight: FontWeight.w400, + fontSize: 20, + ), ), ), - ), SizedBox(width: 16), Column( crossAxisAlignment: CrossAxisAlignment.start, @@ -214,7 +219,7 @@ class _ChatScreenState extends State { ), SizedBox(width: 8), SizedBox( - width: mediaQueryData.size.width - 96, + width: MediaQuery.of(context).size.width - 96, child: TextFormField( controller: textEditingController, maxLines: 5, diff --git a/lib/features/chat/presentation/pages/chat_select_screen.dart b/lib/features/chat/presentation/pages/chat_select_screen.dart index bdb3d9ce..74925e29 100644 --- a/lib/features/chat/presentation/pages/chat_select_screen.dart +++ b/lib/features/chat/presentation/pages/chat_select_screen.dart @@ -39,6 +39,7 @@ class _ChatSelectScreenState extends State { title: Padding( padding: const EdgeInsets.only(top: 8), child: ChatSearchBarWidget( + onSuffixIconTap: () => context.read().getChatRooms(), onChanged: (query) { if (query.length > 2) { EasyDebounce.debounce( diff --git a/lib/features/chat/presentation/widgets/chat_bubble_widget.dart b/lib/features/chat/presentation/widgets/chat_bubble_widget.dart index f65fb3bc..eeba8f1e 100644 --- a/lib/features/chat/presentation/widgets/chat_bubble_widget.dart +++ b/lib/features/chat/presentation/widgets/chat_bubble_widget.dart @@ -1,8 +1,7 @@ import 'package:cached_network_image/cached_network_image.dart'; import 'package:dismissible_page/dismissible_page.dart'; -import 'package:eatvio_app/core/constants/constants.dart'; +import 'package:eatvio_app/core/app_export.dart'; import 'package:eatvio_app/features/chat/presentation/pages/photo_view_screen.dart'; -import 'package:eatvio_app/theme/app_decoration.dart'; import 'package:flutter/material.dart'; import 'package:url_launcher/url_launcher.dart'; @@ -29,12 +28,17 @@ class ChatBubbleWidget extends StatelessWidget { child: DecoratedBox( decoration: BoxDecoration( color: isCurrentUser ? Color(0xFF7F9CF5) : Colors.white, - borderRadius: BorderRadiusStyle.circleBorder17, + borderRadius: mediaData.length > 0 + ? BorderRadius.circular(24) + : BorderRadius.horizontal( + left: isCurrentUser ? Radius.circular(32) : Radius.circular(16), + right: isCurrentUser ? Radius.circular(16) : Radius.circular(24), + ), ), child: Padding( - padding: const EdgeInsets.all(12), + padding: mediaData.length > 0 ? EdgeInsets.all(8) : EdgeInsets.only(top: 8, bottom: 8, left: isCurrentUser ? 16 : 8, right: isCurrentUser ? 8 : 16), child: Column( - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: isCurrentUser ? CrossAxisAlignment.end : CrossAxisAlignment.start, children: [ if (mediaData.isNotEmpty) CustomScrollView( @@ -86,7 +90,7 @@ class ChatBubbleWidget extends StatelessWidget { tag: baseUrl + '/storage/' + '${mediaData[index]}', transitionOnUserGestures: true, child: ClipRRect( - borderRadius: BorderRadiusStyle.roundedBorder8, + borderRadius: BorderRadius.circular(16), child: CachedNetworkImage( imageUrl: baseUrl + '/storage/' + '${mediaData[index]}', ), @@ -103,10 +107,17 @@ class ChatBubbleWidget extends StatelessWidget { if (text.isNotEmpty) Text( text, - style: TextStyle( - color: isCurrentUser ? Colors.white : Color(0xFF323F4B), - ), + style: TextStyle(color: isCurrentUser ? Colors.white : Color(0xFF323F4B), height: 1), ), + SizedBox(height: 4), + Text( + DateTime.parse(sendTime).format('hh:mm'), + style: TextStyle( + color: isCurrentUser ? Colors.white.withOpacity(0.4) : Color(0xFF323F4B).withOpacity(0.4), + height: 1, + fontSize: 10, + ), + ), ], ), ), diff --git a/lib/features/chat/presentation/widgets/chat_entry_widget.dart b/lib/features/chat/presentation/widgets/chat_entry_widget.dart index 0054e8f2..b496047d 100644 --- a/lib/features/chat/presentation/widgets/chat_entry_widget.dart +++ b/lib/features/chat/presentation/widgets/chat_entry_widget.dart @@ -95,6 +95,7 @@ class _ChatEntryWidgetState extends State { } buildAvatarByUsername(String username) { + username = username.trim(); return Container( width: 48, height: 48, diff --git a/lib/features/chat/presentation/widgets/chat_search_bar_widget.dart b/lib/features/chat/presentation/widgets/chat_search_bar_widget.dart index d2baebb1..4889fdfd 100644 --- a/lib/features/chat/presentation/widgets/chat_search_bar_widget.dart +++ b/lib/features/chat/presentation/widgets/chat_search_bar_widget.dart @@ -25,6 +25,7 @@ class ChatSearchBarWidget extends StatelessWidget { this.filled = true, this.validator, this.onChanged, + required this.onSuffixIconTap, }) : super(key: key); final Alignment? alignment; @@ -69,6 +70,8 @@ class ChatSearchBarWidget extends StatelessWidget { final Function(String)? onChanged; + final Function() onSuffixIconTap; + @override Widget build(BuildContext context) { return searchViewWidget(context); @@ -111,7 +114,10 @@ class ChatSearchBarWidget extends StatelessWidget { ), suffixIcon: suffix ?? IconButton( - onPressed: () => controller!.clear(), + onPressed: () { + controller!.clear(); + onSuffixIconTap(); + }, icon: Icon( Icons.clear, color: Colors.grey.shade600, diff --git a/lib/features/diary/models/diary_model.freezed.dart b/lib/features/diary/models/diary_model.freezed.dart index ceabd5db..a02a4621 100644 --- a/lib/features/diary/models/diary_model.freezed.dart +++ b/lib/features/diary/models/diary_model.freezed.dart @@ -29,12 +29,8 @@ mixin _$DiaryModel { DateTime? get wakeup => throw _privateConstructorUsedError; DateTime? get retire => throw _privateConstructorUsedError; - /// Serializes this DiaryModel to a JSON map. Map toJson() => throw _privateConstructorUsedError; - - /// Create a copy of DiaryModel - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) $DiaryModelCopyWith get copyWith => throw _privateConstructorUsedError; } @@ -68,8 +64,6 @@ class _$DiaryModelCopyWithImpl<$Res, $Val extends DiaryModel> // ignore: unused_field final $Res Function($Val) _then; - /// Create a copy of DiaryModel - /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -118,8 +112,6 @@ class _$DiaryModelCopyWithImpl<$Res, $Val extends DiaryModel> ) as $Val); } - /// Create a copy of DiaryModel - /// with the given fields replaced by the non-null parameter values. @override @pragma('vm:prefer-inline') $StateCopyWith<$Res> get state { @@ -159,8 +151,6 @@ class __$$DiaryModelImplCopyWithImpl<$Res> _$DiaryModelImpl _value, $Res Function(_$DiaryModelImpl) _then) : super(_value, _then); - /// Create a copy of DiaryModel - /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -270,7 +260,7 @@ class _$DiaryModelImpl implements _DiaryModel { (identical(other.retire, retire) || other.retire == retire)); } - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) @override int get hashCode => Object.hash( runtimeType, @@ -283,9 +273,7 @@ class _$DiaryModelImpl implements _DiaryModel { wakeup, retire); - /// Create a copy of DiaryModel - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) @override @pragma('vm:prefer-inline') _$$DiaryModelImplCopyWith<_$DiaryModelImpl> get copyWith => @@ -329,11 +317,8 @@ abstract class _DiaryModel implements DiaryModel { DateTime? get wakeup; @override DateTime? get retire; - - /// Create a copy of DiaryModel - /// with the given fields replaced by the non-null parameter values. @override - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) _$$DiaryModelImplCopyWith<_$DiaryModelImpl> get copyWith => throw _privateConstructorUsedError; } diff --git a/lib/features/diary/models/meal.freezed.dart b/lib/features/diary/models/meal.freezed.dart index 2bd6c478..2c249b06 100644 --- a/lib/features/diary/models/meal.freezed.dart +++ b/lib/features/diary/models/meal.freezed.dart @@ -28,12 +28,8 @@ mixin _$Meal { List get portions => throw _privateConstructorUsedError; List get photos => throw _privateConstructorUsedError; - /// Serializes this Meal to a JSON map. Map toJson() => throw _privateConstructorUsedError; - - /// Create a copy of Meal - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) $MealCopyWith get copyWith => throw _privateConstructorUsedError; } @@ -62,8 +58,6 @@ class _$MealCopyWithImpl<$Res, $Val extends Meal> // ignore: unused_field final $Res Function($Val) _then; - /// Create a copy of Meal - /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -132,8 +126,6 @@ class __$$MealImplCopyWithImpl<$Res> __$$MealImplCopyWithImpl(_$MealImpl _value, $Res Function(_$MealImpl) _then) : super(_value, _then); - /// Create a copy of Meal - /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -240,7 +232,7 @@ class _$MealImpl implements _Meal { const DeepCollectionEquality().equals(other._photos, _photos)); } - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) @override int get hashCode => Object.hash( runtimeType, @@ -252,9 +244,7 @@ class _$MealImpl implements _Meal { const DeepCollectionEquality().hash(_portions), const DeepCollectionEquality().hash(_photos)); - /// Create a copy of Meal - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) @override @pragma('vm:prefer-inline') _$$MealImplCopyWith<_$MealImpl> get copyWith => @@ -294,11 +284,8 @@ abstract class _Meal implements Meal { List get portions; @override List get photos; - - /// Create a copy of Meal - /// with the given fields replaced by the non-null parameter values. @override - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) _$$MealImplCopyWith<_$MealImpl> get copyWith => throw _privateConstructorUsedError; } diff --git a/lib/features/diary/models/photo.freezed.dart b/lib/features/diary/models/photo.freezed.dart index 8f5e0152..2d9c70bd 100644 --- a/lib/features/diary/models/photo.freezed.dart +++ b/lib/features/diary/models/photo.freezed.dart @@ -25,12 +25,8 @@ mixin _$Photo { String get originalName => throw _privateConstructorUsedError; String get path => throw _privateConstructorUsedError; - /// Serializes this Photo to a JSON map. Map toJson() => throw _privateConstructorUsedError; - - /// Create a copy of Photo - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) $PhotoCopyWith get copyWith => throw _privateConstructorUsedError; } @@ -55,8 +51,6 @@ class _$PhotoCopyWithImpl<$Res, $Val extends Photo> // ignore: unused_field final $Res Function($Val) _then; - /// Create a copy of Photo - /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -102,8 +96,6 @@ class __$$PhotoImplCopyWithImpl<$Res> _$PhotoImpl _value, $Res Function(_$PhotoImpl) _then) : super(_value, _then); - /// Create a copy of Photo - /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -163,13 +155,11 @@ class _$PhotoImpl implements _Photo { (identical(other.path, path) || other.path == path)); } - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) @override int get hashCode => Object.hash(runtimeType, id, originalName, path); - /// Create a copy of Photo - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) @override @pragma('vm:prefer-inline') _$$PhotoImplCopyWith<_$PhotoImpl> get copyWith => @@ -198,11 +188,8 @@ abstract class _Photo implements Photo { String get originalName; @override String get path; - - /// Create a copy of Photo - /// with the given fields replaced by the non-null parameter values. @override - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) _$$PhotoImplCopyWith<_$PhotoImpl> get copyWith => throw _privateConstructorUsedError; } diff --git a/lib/features/diary/models/portion.freezed.dart b/lib/features/diary/models/portion.freezed.dart index 4bef02d4..77627c29 100644 --- a/lib/features/diary/models/portion.freezed.dart +++ b/lib/features/diary/models/portion.freezed.dart @@ -26,12 +26,8 @@ mixin _$Portion { String get portion => throw _privateConstructorUsedError; bool get from_diet => throw _privateConstructorUsedError; - /// Serializes this Portion to a JSON map. Map toJson() => throw _privateConstructorUsedError; - - /// Create a copy of Portion - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) $PortionCopyWith get copyWith => throw _privateConstructorUsedError; } @@ -58,8 +54,6 @@ class _$PortionCopyWithImpl<$Res, $Val extends Portion> // ignore: unused_field final $Res Function($Val) _then; - /// Create a copy of Portion - /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -117,8 +111,6 @@ class __$$PortionImplCopyWithImpl<$Res> _$PortionImpl _value, $Res Function(_$PortionImpl) _then) : super(_value, _then); - /// Create a copy of Portion - /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -197,14 +189,12 @@ class _$PortionImpl implements _Portion { other.from_diet == from_diet)); } - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) @override int get hashCode => Object.hash(runtimeType, id, product_name, quantity, portion, from_diet); - /// Create a copy of Portion - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) @override @pragma('vm:prefer-inline') _$$PortionImplCopyWith<_$PortionImpl> get copyWith => @@ -238,11 +228,8 @@ abstract class _Portion implements Portion { String get portion; @override bool get from_diet; - - /// Create a copy of Portion - /// with the given fields replaced by the non-null parameter values. @override - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) _$$PortionImplCopyWith<_$PortionImpl> get copyWith => throw _privateConstructorUsedError; } diff --git a/lib/features/diary/models/product.freezed.dart b/lib/features/diary/models/product.freezed.dart index 610656fb..d30ada33 100644 --- a/lib/features/diary/models/product.freezed.dart +++ b/lib/features/diary/models/product.freezed.dart @@ -23,12 +23,8 @@ mixin _$Product { int get id => throw _privateConstructorUsedError; String get name => throw _privateConstructorUsedError; - /// Serializes this Product to a JSON map. Map toJson() => throw _privateConstructorUsedError; - - /// Create a copy of Product - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) $ProductCopyWith get copyWith => throw _privateConstructorUsedError; } @@ -50,8 +46,6 @@ class _$ProductCopyWithImpl<$Res, $Val extends Product> // ignore: unused_field final $Res Function($Val) _then; - /// Create a copy of Product - /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -89,8 +83,6 @@ class __$$ProductImplCopyWithImpl<$Res> _$ProductImpl _value, $Res Function(_$ProductImpl) _then) : super(_value, _then); - /// Create a copy of Product - /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -137,13 +129,11 @@ class _$ProductImpl implements _Product { (identical(other.name, name) || other.name == name)); } - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) @override int get hashCode => Object.hash(runtimeType, id, name); - /// Create a copy of Product - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) @override @pragma('vm:prefer-inline') _$$ProductImplCopyWith<_$ProductImpl> get copyWith => @@ -167,11 +157,8 @@ abstract class _Product implements Product { int get id; @override String get name; - - /// Create a copy of Product - /// with the given fields replaced by the non-null parameter values. @override - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) _$$ProductImplCopyWith<_$ProductImpl> get copyWith => throw _privateConstructorUsedError; } diff --git a/lib/features/diary/models/state.freezed.dart b/lib/features/diary/models/state.freezed.dart index 6b9c50fb..599ec29f 100644 --- a/lib/features/diary/models/state.freezed.dart +++ b/lib/features/diary/models/state.freezed.dart @@ -23,12 +23,8 @@ mixin _$State { bool get has_chosen_diet => throw _privateConstructorUsedError; bool get has_chosen_plan => throw _privateConstructorUsedError; - /// Serializes this State to a JSON map. Map toJson() => throw _privateConstructorUsedError; - - /// Create a copy of State - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) $StateCopyWith get copyWith => throw _privateConstructorUsedError; } @@ -50,8 +46,6 @@ class _$StateCopyWithImpl<$Res, $Val extends State> // ignore: unused_field final $Res Function($Val) _then; - /// Create a copy of State - /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -89,8 +83,6 @@ class __$$StateImplCopyWithImpl<$Res> _$StateImpl _value, $Res Function(_$StateImpl) _then) : super(_value, _then); - /// Create a copy of State - /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -140,14 +132,12 @@ class _$StateImpl implements _State { other.has_chosen_plan == has_chosen_plan)); } - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) @override int get hashCode => Object.hash(runtimeType, has_chosen_diet, has_chosen_plan); - /// Create a copy of State - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) @override @pragma('vm:prefer-inline') _$$StateImplCopyWith<_$StateImpl> get copyWith => @@ -172,11 +162,8 @@ abstract class _State implements State { bool get has_chosen_diet; @override bool get has_chosen_plan; - - /// Create a copy of State - /// with the given fields replaced by the non-null parameter values. @override - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) _$$StateImplCopyWith<_$StateImpl> get copyWith => throw _privateConstructorUsedError; } diff --git a/lib/features/diary/presentation/bloc/diary_state.freezed.dart b/lib/features/diary/presentation/bloc/diary_state.freezed.dart index 98d7019f..5a9bbc12 100644 --- a/lib/features/diary/presentation/bloc/diary_state.freezed.dart +++ b/lib/features/diary/presentation/bloc/diary_state.freezed.dart @@ -174,9 +174,6 @@ class _$DiaryStateCopyWithImpl<$Res, $Val extends DiaryState> final $Val _value; // ignore: unused_field final $Res Function($Val) _then; - - /// Create a copy of DiaryState - /// with the given fields replaced by the non-null parameter values. } /// @nodoc @@ -193,9 +190,6 @@ class __$$DiaryStateImplCopyWithImpl<$Res> __$$DiaryStateImplCopyWithImpl( _$DiaryStateImpl _value, $Res Function(_$DiaryStateImpl) _then) : super(_value, _then); - - /// Create a copy of DiaryState - /// with the given fields replaced by the non-null parameter values. } /// @nodoc @@ -403,8 +397,6 @@ class __$$DiaryStateLoadingImplCopyWithImpl<$Res> $Res Function(_$DiaryStateLoadingImpl) _then) : super(_value, _then); - /// Create a copy of DiaryState - /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -443,9 +435,7 @@ class _$DiaryStateLoadingImpl implements DiaryStateLoading { @override int get hashCode => Object.hash(runtimeType, id); - /// Create a copy of DiaryState - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) @override @pragma('vm:prefer-inline') _$$DiaryStateLoadingImplCopyWith<_$DiaryStateLoadingImpl> get copyWith => @@ -621,10 +611,7 @@ abstract class DiaryStateLoading implements DiaryState { const factory DiaryStateLoading({final int? id}) = _$DiaryStateLoadingImpl; int? get id; - - /// Create a copy of DiaryState - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) _$$DiaryStateLoadingImplCopyWith<_$DiaryStateLoadingImpl> get copyWith => throw _privateConstructorUsedError; } @@ -679,8 +666,6 @@ class __$$DiaryStateLoadedImplCopyWithImpl<$Res> $Res Function(_$DiaryStateLoadedImpl) _then) : super(_value, _then); - /// Create a copy of DiaryState - /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -834,8 +819,6 @@ class __$$DiaryStateLoadedImplCopyWithImpl<$Res> )); } - /// Create a copy of DiaryState - /// with the given fields replaced by the non-null parameter values. @override @pragma('vm:prefer-inline') $DiaryModelCopyWith<$Res> get diary { @@ -844,8 +827,6 @@ class __$$DiaryStateLoadedImplCopyWithImpl<$Res> }); } - /// Create a copy of DiaryState - /// with the given fields replaced by the non-null parameter values. @override @pragma('vm:prefer-inline') $MealCopyWith<$Res> get currentMeal { @@ -854,8 +835,6 @@ class __$$DiaryStateLoadedImplCopyWithImpl<$Res> }); } - /// Create a copy of DiaryState - /// with the given fields replaced by the non-null parameter values. @override @pragma('vm:prefer-inline') $SelectionPopupModelCopyWith<$Res> get portionController { @@ -1121,9 +1100,7 @@ class _$DiaryStateLoadedImpl implements DiaryStateLoaded { const DeepCollectionEquality().hash(_chartDataCounted) ]); - /// Create a copy of DiaryState - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) @override @pragma('vm:prefer-inline') _$$DiaryStateLoadedImplCopyWith<_$DiaryStateLoadedImpl> get copyWith => @@ -1443,10 +1420,7 @@ abstract class DiaryStateLoaded implements DiaryState { bool get isLoading; bool get isAdded; List? get chartDataCounted; - - /// Create a copy of DiaryState - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) _$$DiaryStateLoadedImplCopyWith<_$DiaryStateLoadedImpl> get copyWith => throw _privateConstructorUsedError; } @@ -1468,8 +1442,6 @@ class __$$DiaryStateErrorImplCopyWithImpl<$Res> _$DiaryStateErrorImpl _value, $Res Function(_$DiaryStateErrorImpl) _then) : super(_value, _then); - /// Create a copy of DiaryState - /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -1509,9 +1481,7 @@ class _$DiaryStateErrorImpl implements DiaryStateError { @override int get hashCode => Object.hash(runtimeType, errorMessage); - /// Create a copy of DiaryState - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) @override @pragma('vm:prefer-inline') _$$DiaryStateErrorImplCopyWith<_$DiaryStateErrorImpl> get copyWith => @@ -1688,10 +1658,7 @@ abstract class DiaryStateError implements DiaryState { _$DiaryStateErrorImpl; String get errorMessage; - - /// Create a copy of DiaryState - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) _$$DiaryStateErrorImplCopyWith<_$DiaryStateErrorImpl> get copyWith => throw _privateConstructorUsedError; } diff --git a/lib/features/diary/presentation/pages/diary_screen.dart b/lib/features/diary/presentation/pages/diary_screen.dart index 7556fece..d79b4aab 100644 --- a/lib/features/diary/presentation/pages/diary_screen.dart +++ b/lib/features/diary/presentation/pages/diary_screen.dart @@ -18,7 +18,7 @@ import 'package:flutter/services.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter_form_builder/flutter_form_builder.dart'; import 'package:image_picker/image_picker.dart'; -// import 'package:syncfusion_flutter_charts/charts.dart'; +import 'package:syncfusion_flutter_charts/charts.dart'; class DiaryScreen extends StatelessWidget { final String? diaryID; @@ -136,30 +136,30 @@ class DiaryScreen extends StatelessWidget { Text( "от дневной суточной нормы", ), - // Transform.rotate( - // angle: -1.5708, - // child: ClipRect( - // child: Align( - // alignment: Alignment.centerRight, - // widthFactor: 0.5, - // child: SfCircularChart( - // series: [ - // RadialBarSeries( - // dataSource: state.chartDataCounted, - // xValueMapper: (NutritionData data, _) => data.category, - // yValueMapper: (NutritionData data, _) => data.nutrition, - // pointColorMapper: (NutritionData data, _) => data.color, - // trackColor: Color.fromRGBO(59, 130, 246, 1), - // trackOpacity: 0.1, - // gap: "8%", - // radius: "110%", - // innerRadius: '20%', // Измените значение по вашему усмотрению - // ) - // ], - // ), - // ), - // ), - // ), + Transform.rotate( + angle: -1.5708, + child: ClipRect( + child: Align( + alignment: Alignment.centerRight, + widthFactor: 0.5, + child: SfCircularChart( + series: [ + RadialBarSeries( + dataSource: state.chartDataCounted, + xValueMapper: (NutritionData data, _) => data.category, + yValueMapper: (NutritionData data, _) => data.nutrition, + pointColorMapper: (NutritionData data, _) => data.color, + trackColor: Color.fromRGBO(59, 130, 246, 1), + trackOpacity: 0.1, + gap: "8%", + radius: "110%", + innerRadius: '20%', // Измените значение по вашему усмотрению + ) + ], + ), + ), + ), + ), Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ @@ -201,6 +201,7 @@ class DiaryScreen extends StatelessWidget { width: MediaQuery.of(context).size.width, padding: EdgeInsets.only(left: 4, right: 4), child: FloatingActionButton.extended( + heroTag: 'endDayButton', highlightElevation: 0, elevation: 0, focusElevation: 0, @@ -264,6 +265,7 @@ class DiaryScreen extends StatelessWidget { width: MediaQuery.of(context).size.width, padding: EdgeInsets.only(left: 4, right: 4), child: FloatingActionButton.extended( + heroTag: 'addProduct', highlightElevation: 0, elevation: 0, focusElevation: 0, diff --git a/lib/features/diets/presentation/pages/about_diet_screen.dart b/lib/features/diets/presentation/pages/about_diet_screen.dart index 931b2eaf..42aa3bf4 100644 --- a/lib/features/diets/presentation/pages/about_diet_screen.dart +++ b/lib/features/diets/presentation/pages/about_diet_screen.dart @@ -2,13 +2,11 @@ import 'dart:io'; import 'package:cached_network_image/cached_network_image.dart'; import 'package:eatvio_app/core/app_export.dart'; -import 'package:eatvio_app/core/constants/constants.dart'; import 'package:eatvio_app/features/feed/models/comment_model.dart'; import 'package:eatvio_app/features/feed/models/diets_pagination_model.dart' as Diets; import 'package:eatvio_app/features/feed/presentation/bloc/comments_cubit/comments_cubit.dart'; import 'package:eatvio_app/features/feed/presentation/bloc/comments_cubit/comments_state.dart'; import 'package:eatvio_app/locator_service.dart'; -import 'package:eatvio_app/theme/theme_helper.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:go_router/go_router.dart'; diff --git a/lib/features/feed/models/comment_model.freezed.dart b/lib/features/feed/models/comment_model.freezed.dart index 9dc150e4..3f088135 100644 --- a/lib/features/feed/models/comment_model.freezed.dart +++ b/lib/features/feed/models/comment_model.freezed.dart @@ -27,12 +27,8 @@ mixin _$Comment { @JsonKey(name: "meta") Meta get meta => throw _privateConstructorUsedError; - /// Serializes this Comment to a JSON map. Map toJson() => throw _privateConstructorUsedError; - - /// Create a copy of Comment - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) $CommentCopyWith get copyWith => throw _privateConstructorUsedError; } @@ -60,8 +56,6 @@ class _$CommentCopyWithImpl<$Res, $Val extends Comment> // ignore: unused_field final $Res Function($Val) _then; - /// Create a copy of Comment - /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -85,8 +79,6 @@ class _$CommentCopyWithImpl<$Res, $Val extends Comment> ) as $Val); } - /// Create a copy of Comment - /// with the given fields replaced by the non-null parameter values. @override @pragma('vm:prefer-inline') $LinksCopyWith<$Res> get links { @@ -95,8 +87,6 @@ class _$CommentCopyWithImpl<$Res, $Val extends Comment> }); } - /// Create a copy of Comment - /// with the given fields replaced by the non-null parameter values. @override @pragma('vm:prefer-inline') $MetaCopyWith<$Res> get meta { @@ -132,8 +122,6 @@ class __$$CommentImplCopyWithImpl<$Res> _$CommentImpl _value, $Res Function(_$CommentImpl) _then) : super(_value, _then); - /// Create a copy of Comment - /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -201,14 +189,12 @@ class _$CommentImpl implements _Comment { (identical(other.meta, meta) || other.meta == meta)); } - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) @override int get hashCode => Object.hash( runtimeType, const DeepCollectionEquality().hash(_data), links, meta); - /// Create a copy of Comment - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) @override @pragma('vm:prefer-inline') _$$CommentImplCopyWith<_$CommentImpl> get copyWith => @@ -239,11 +225,8 @@ abstract class _Comment implements Comment { @override @JsonKey(name: "meta") Meta get meta; - - /// Create a copy of Comment - /// with the given fields replaced by the non-null parameter values. @override - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) _$$CommentImplCopyWith<_$CommentImpl> get copyWith => throw _privateConstructorUsedError; } @@ -265,12 +248,8 @@ mixin _$Datum { @JsonKey(name: "children_comments") List get childrenComments => throw _privateConstructorUsedError; - /// Serializes this Datum to a JSON map. Map toJson() => throw _privateConstructorUsedError; - - /// Create a copy of Datum - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) $DatumCopyWith get copyWith => throw _privateConstructorUsedError; } @@ -297,8 +276,6 @@ class _$DatumCopyWithImpl<$Res, $Val extends Datum> // ignore: unused_field final $Res Function($Val) _then; - /// Create a copy of Datum - /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -356,8 +333,6 @@ class __$$DatumImplCopyWithImpl<$Res> _$DatumImpl _value, $Res Function(_$DatumImpl) _then) : super(_value, _then); - /// Create a copy of Datum - /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -449,7 +424,7 @@ class _$DatumImpl implements _Datum { .equals(other._childrenComments, _childrenComments)); } - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) @override int get hashCode => Object.hash( runtimeType, @@ -459,9 +434,7 @@ class _$DatumImpl implements _Datum { body, const DeepCollectionEquality().hash(_childrenComments)); - /// Create a copy of Datum - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) @override @pragma('vm:prefer-inline') _$$DatumImplCopyWith<_$DatumImpl> get copyWith => @@ -502,11 +475,8 @@ abstract class _Datum implements Datum { @override @JsonKey(name: "children_comments") List get childrenComments; - - /// Create a copy of Datum - /// with the given fields replaced by the non-null parameter values. @override - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) _$$DatumImplCopyWith<_$DatumImpl> get copyWith => throw _privateConstructorUsedError; } @@ -526,12 +496,8 @@ mixin _$Links { @JsonKey(name: "next") dynamic get next => throw _privateConstructorUsedError; - /// Serializes this Links to a JSON map. Map toJson() => throw _privateConstructorUsedError; - - /// Create a copy of Links - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) $LinksCopyWith get copyWith => throw _privateConstructorUsedError; } @@ -557,8 +523,6 @@ class _$LinksCopyWithImpl<$Res, $Val extends Links> // ignore: unused_field final $Res Function($Val) _then; - /// Create a copy of Links - /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -610,8 +574,6 @@ class __$$LinksImplCopyWithImpl<$Res> _$LinksImpl _value, $Res Function(_$LinksImpl) _then) : super(_value, _then); - /// Create a copy of Links - /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -682,7 +644,7 @@ class _$LinksImpl implements _Links { const DeepCollectionEquality().equals(other.next, next)); } - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) @override int get hashCode => Object.hash( runtimeType, @@ -691,9 +653,7 @@ class _$LinksImpl implements _Links { const DeepCollectionEquality().hash(prev), const DeepCollectionEquality().hash(next)); - /// Create a copy of Links - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) @override @pragma('vm:prefer-inline') _$$LinksImplCopyWith<_$LinksImpl> get copyWith => @@ -728,11 +688,8 @@ abstract class _Links implements Links { @override @JsonKey(name: "next") dynamic get next; - - /// Create a copy of Links - /// with the given fields replaced by the non-null parameter values. @override - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) _$$LinksImplCopyWith<_$LinksImpl> get copyWith => throw _privateConstructorUsedError; } @@ -760,12 +717,8 @@ mixin _$Meta { @JsonKey(name: "total") int get total => throw _privateConstructorUsedError; - /// Serializes this Meta to a JSON map. Map toJson() => throw _privateConstructorUsedError; - - /// Create a copy of Meta - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) $MetaCopyWith get copyWith => throw _privateConstructorUsedError; } @@ -795,8 +748,6 @@ class _$MetaCopyWithImpl<$Res, $Val extends Meta> // ignore: unused_field final $Res Function($Val) _then; - /// Create a copy of Meta - /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -871,8 +822,6 @@ class __$$MetaImplCopyWithImpl<$Res> __$$MetaImplCopyWithImpl(_$MetaImpl _value, $Res Function(_$MetaImpl) _then) : super(_value, _then); - /// Create a copy of Meta - /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -992,14 +941,12 @@ class _$MetaImpl implements _Meta { (identical(other.total, total) || other.total == total)); } - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) @override int get hashCode => Object.hash(runtimeType, currentPage, from, lastPage, const DeepCollectionEquality().hash(_links), path, perPage, to, total); - /// Create a copy of Meta - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) @override @pragma('vm:prefer-inline') _$$MetaImplCopyWith<_$MetaImpl> get copyWith => @@ -1050,11 +997,8 @@ abstract class _Meta implements Meta { @override @JsonKey(name: "total") int get total; - - /// Create a copy of Meta - /// with the given fields replaced by the non-null parameter values. @override - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) _$$MetaImplCopyWith<_$MetaImpl> get copyWith => throw _privateConstructorUsedError; } @@ -1072,12 +1016,8 @@ mixin _$Link { @JsonKey(name: "active") bool get active => throw _privateConstructorUsedError; - /// Serializes this Link to a JSON map. Map toJson() => throw _privateConstructorUsedError; - - /// Create a copy of Link - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) $LinkCopyWith get copyWith => throw _privateConstructorUsedError; } @@ -1102,8 +1042,6 @@ class _$LinkCopyWithImpl<$Res, $Val extends Link> // ignore: unused_field final $Res Function($Val) _then; - /// Create a copy of Link - /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -1148,8 +1086,6 @@ class __$$LinkImplCopyWithImpl<$Res> __$$LinkImplCopyWithImpl(_$LinkImpl _value, $Res Function(_$LinkImpl) _then) : super(_value, _then); - /// Create a copy of Link - /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -1210,13 +1146,11 @@ class _$LinkImpl implements _Link { (identical(other.active, active) || other.active == active)); } - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) @override int get hashCode => Object.hash(runtimeType, url, label, active); - /// Create a copy of Link - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) @override @pragma('vm:prefer-inline') _$$LinkImplCopyWith<_$LinkImpl> get copyWith => @@ -1247,11 +1181,8 @@ abstract class _Link implements Link { @override @JsonKey(name: "active") bool get active; - - /// Create a copy of Link - /// with the given fields replaced by the non-null parameter values. @override - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) _$$LinkImplCopyWith<_$LinkImpl> get copyWith => throw _privateConstructorUsedError; } diff --git a/lib/features/feed/models/diets_pagination_model.freezed.dart b/lib/features/feed/models/diets_pagination_model.freezed.dart index 5fa7d5dc..2c402671 100644 --- a/lib/features/feed/models/diets_pagination_model.freezed.dart +++ b/lib/features/feed/models/diets_pagination_model.freezed.dart @@ -27,12 +27,8 @@ mixin _$DietsPagination { @JsonKey(name: "meta") Meta get meta => throw _privateConstructorUsedError; - /// Serializes this DietsPagination to a JSON map. Map toJson() => throw _privateConstructorUsedError; - - /// Create a copy of DietsPagination - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) $DietsPaginationCopyWith get copyWith => throw _privateConstructorUsedError; } @@ -62,8 +58,6 @@ class _$DietsPaginationCopyWithImpl<$Res, $Val extends DietsPagination> // ignore: unused_field final $Res Function($Val) _then; - /// Create a copy of DietsPagination - /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -87,8 +81,6 @@ class _$DietsPaginationCopyWithImpl<$Res, $Val extends DietsPagination> ) as $Val); } - /// Create a copy of DietsPagination - /// with the given fields replaced by the non-null parameter values. @override @pragma('vm:prefer-inline') $LinksCopyWith<$Res> get links { @@ -97,8 +89,6 @@ class _$DietsPaginationCopyWithImpl<$Res, $Val extends DietsPagination> }); } - /// Create a copy of DietsPagination - /// with the given fields replaced by the non-null parameter values. @override @pragma('vm:prefer-inline') $MetaCopyWith<$Res> get meta { @@ -135,8 +125,6 @@ class __$$DietsPaginationImplCopyWithImpl<$Res> _$DietsPaginationImpl _value, $Res Function(_$DietsPaginationImpl) _then) : super(_value, _then); - /// Create a copy of DietsPagination - /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -204,14 +192,12 @@ class _$DietsPaginationImpl implements _DietsPagination { (identical(other.meta, meta) || other.meta == meta)); } - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) @override int get hashCode => Object.hash( runtimeType, const DeepCollectionEquality().hash(_data), links, meta); - /// Create a copy of DietsPagination - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) @override @pragma('vm:prefer-inline') _$$DietsPaginationImplCopyWith<_$DietsPaginationImpl> get copyWith => @@ -244,11 +230,8 @@ abstract class _DietsPagination implements DietsPagination { @override @JsonKey(name: "meta") Meta get meta; - - /// Create a copy of DietsPagination - /// with the given fields replaced by the non-null parameter values. @override - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) _$$DietsPaginationImplCopyWith<_$DietsPaginationImpl> get copyWith => throw _privateConstructorUsedError; } @@ -285,12 +268,8 @@ mixin _$Datum { @JsonKey(name: "total_comments") int get totalComments => throw _privateConstructorUsedError; - /// Serializes this Datum to a JSON map. Map toJson() => throw _privateConstructorUsedError; - - /// Create a copy of Datum - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) $DatumCopyWith get copyWith => throw _privateConstructorUsedError; } @@ -328,8 +307,6 @@ class _$DatumCopyWithImpl<$Res, $Val extends Datum> // ignore: unused_field final $Res Function($Val) _then; - /// Create a copy of Datum - /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -398,8 +375,6 @@ class _$DatumCopyWithImpl<$Res, $Val extends Datum> ) as $Val); } - /// Create a copy of Datum - /// with the given fields replaced by the non-null parameter values. @override @pragma('vm:prefer-inline') $TypeCopyWith<$Res> get type { @@ -408,8 +383,6 @@ class _$DatumCopyWithImpl<$Res, $Val extends Datum> }); } - /// Create a copy of Datum - /// with the given fields replaced by the non-null parameter values. @override @pragma('vm:prefer-inline') $AuthorCopyWith<$Res> get author { @@ -455,8 +428,6 @@ class __$$DatumImplCopyWithImpl<$Res> _$DatumImpl _value, $Res Function(_$DatumImpl) _then) : super(_value, _then); - /// Create a copy of Datum - /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -620,7 +591,7 @@ class _$DatumImpl implements _Datum { other.totalComments == totalComments)); } - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) @override int get hashCode => Object.hash( runtimeType, @@ -637,9 +608,7 @@ class _$DatumImpl implements _Datum { totalViews, totalComments); - /// Create a copy of Datum - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) @override @pragma('vm:prefer-inline') _$$DatumImplCopyWith<_$DatumImpl> get copyWith => @@ -708,11 +677,8 @@ abstract class _Datum implements Datum { @override @JsonKey(name: "total_comments") int get totalComments; - - /// Create a copy of Datum - /// with the given fields replaced by the non-null parameter values. @override - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) _$$DatumImplCopyWith<_$DatumImpl> get copyWith => throw _privateConstructorUsedError; } @@ -732,12 +698,8 @@ mixin _$Author { @JsonKey(name: "author_is_me") bool get authorIsMe => throw _privateConstructorUsedError; - /// Serializes this Author to a JSON map. Map toJson() => throw _privateConstructorUsedError; - - /// Create a copy of Author - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) $AuthorCopyWith get copyWith => throw _privateConstructorUsedError; } @@ -763,8 +725,6 @@ class _$AuthorCopyWithImpl<$Res, $Val extends Author> // ignore: unused_field final $Res Function($Val) _then; - /// Create a copy of Author - /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -816,8 +776,6 @@ class __$$AuthorImplCopyWithImpl<$Res> _$AuthorImpl _value, $Res Function(_$AuthorImpl) _then) : super(_value, _then); - /// Create a copy of Author - /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -892,14 +850,12 @@ class _$AuthorImpl implements _Author { other.authorIsMe == authorIsMe)); } - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) @override int get hashCode => Object.hash( runtimeType, authorSlug, authorName, authorProfileIcon, authorIsMe); - /// Create a copy of Author - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) @override @pragma('vm:prefer-inline') _$$AuthorImplCopyWith<_$AuthorImpl> get copyWith => @@ -936,11 +892,8 @@ abstract class _Author implements Author { @override @JsonKey(name: "author_is_me") bool get authorIsMe; - - /// Create a copy of Author - /// with the given fields replaced by the non-null parameter values. @override - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) _$$AuthorImplCopyWith<_$AuthorImpl> get copyWith => throw _privateConstructorUsedError; } @@ -960,12 +913,8 @@ mixin _$DailySchedule { @JsonKey(name: "quantity") int get quantity => throw _privateConstructorUsedError; - /// Serializes this DailySchedule to a JSON map. Map toJson() => throw _privateConstructorUsedError; - - /// Create a copy of DailySchedule - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) $DailyScheduleCopyWith get copyWith => throw _privateConstructorUsedError; } @@ -993,8 +942,6 @@ class _$DailyScheduleCopyWithImpl<$Res, $Val extends DailySchedule> // ignore: unused_field final $Res Function($Val) _then; - /// Create a copy of DailySchedule - /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -1047,8 +994,6 @@ class __$$DailyScheduleImplCopyWithImpl<$Res> _$DailyScheduleImpl _value, $Res Function(_$DailyScheduleImpl) _then) : super(_value, _then); - /// Create a copy of DailySchedule - /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -1120,13 +1065,11 @@ class _$DailyScheduleImpl implements _DailySchedule { other.quantity == quantity)); } - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) @override int get hashCode => Object.hash(runtimeType, name, uniq, portion, quantity); - /// Create a copy of DailySchedule - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) @override @pragma('vm:prefer-inline') _$$DailyScheduleImplCopyWith<_$DailyScheduleImpl> get copyWith => @@ -1163,11 +1106,8 @@ abstract class _DailySchedule implements DailySchedule { @override @JsonKey(name: "quantity") int get quantity; - - /// Create a copy of DailySchedule - /// with the given fields replaced by the non-null parameter values. @override - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) _$$DailyScheduleImplCopyWith<_$DailyScheduleImpl> get copyWith => throw _privateConstructorUsedError; } @@ -1187,12 +1127,8 @@ mixin _$Type { @JsonKey(name: "meat") bool? get meat => throw _privateConstructorUsedError; - /// Serializes this Type to a JSON map. Map toJson() => throw _privateConstructorUsedError; - - /// Create a copy of Type - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) $TypeCopyWith get copyWith => throw _privateConstructorUsedError; } @@ -1218,8 +1154,6 @@ class _$TypeCopyWithImpl<$Res, $Val extends Type> // ignore: unused_field final $Res Function($Val) _then; - /// Create a copy of Type - /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -1270,8 +1204,6 @@ class __$$TypeImplCopyWithImpl<$Res> __$$TypeImplCopyWithImpl(_$TypeImpl _value, $Res Function(_$TypeImpl) _then) : super(_value, _then); - /// Create a copy of Type - /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -1342,13 +1274,11 @@ class _$TypeImpl implements _Type { (identical(other.meat, meat) || other.meat == meat)); } - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) @override int get hashCode => Object.hash(runtimeType, alko, veg, corb, meat); - /// Create a copy of Type - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) @override @pragma('vm:prefer-inline') _$$TypeImplCopyWith<_$TypeImpl> get copyWith => @@ -1383,11 +1313,8 @@ abstract class _Type implements Type { @override @JsonKey(name: "meat") bool? get meat; - - /// Create a copy of Type - /// with the given fields replaced by the non-null parameter values. @override - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) _$$TypeImplCopyWith<_$TypeImpl> get copyWith => throw _privateConstructorUsedError; } @@ -1407,12 +1334,8 @@ mixin _$Links { @JsonKey(name: "next") dynamic get next => throw _privateConstructorUsedError; - /// Serializes this Links to a JSON map. Map toJson() => throw _privateConstructorUsedError; - - /// Create a copy of Links - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) $LinksCopyWith get copyWith => throw _privateConstructorUsedError; } @@ -1438,8 +1361,6 @@ class _$LinksCopyWithImpl<$Res, $Val extends Links> // ignore: unused_field final $Res Function($Val) _then; - /// Create a copy of Links - /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -1491,8 +1412,6 @@ class __$$LinksImplCopyWithImpl<$Res> _$LinksImpl _value, $Res Function(_$LinksImpl) _then) : super(_value, _then); - /// Create a copy of Links - /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -1563,7 +1482,7 @@ class _$LinksImpl implements _Links { const DeepCollectionEquality().equals(other.next, next)); } - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) @override int get hashCode => Object.hash( runtimeType, @@ -1572,9 +1491,7 @@ class _$LinksImpl implements _Links { const DeepCollectionEquality().hash(prev), const DeepCollectionEquality().hash(next)); - /// Create a copy of Links - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) @override @pragma('vm:prefer-inline') _$$LinksImplCopyWith<_$LinksImpl> get copyWith => @@ -1609,11 +1526,8 @@ abstract class _Links implements Links { @override @JsonKey(name: "next") dynamic get next; - - /// Create a copy of Links - /// with the given fields replaced by the non-null parameter values. @override - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) _$$LinksImplCopyWith<_$LinksImpl> get copyWith => throw _privateConstructorUsedError; } @@ -1641,12 +1555,8 @@ mixin _$Meta { @JsonKey(name: "total") int get total => throw _privateConstructorUsedError; - /// Serializes this Meta to a JSON map. Map toJson() => throw _privateConstructorUsedError; - - /// Create a copy of Meta - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) $MetaCopyWith get copyWith => throw _privateConstructorUsedError; } @@ -1676,8 +1586,6 @@ class _$MetaCopyWithImpl<$Res, $Val extends Meta> // ignore: unused_field final $Res Function($Val) _then; - /// Create a copy of Meta - /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -1752,8 +1660,6 @@ class __$$MetaImplCopyWithImpl<$Res> __$$MetaImplCopyWithImpl(_$MetaImpl _value, $Res Function(_$MetaImpl) _then) : super(_value, _then); - /// Create a copy of Meta - /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -1873,14 +1779,12 @@ class _$MetaImpl implements _Meta { (identical(other.total, total) || other.total == total)); } - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) @override int get hashCode => Object.hash(runtimeType, currentPage, from, lastPage, const DeepCollectionEquality().hash(_links), path, perPage, to, total); - /// Create a copy of Meta - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) @override @pragma('vm:prefer-inline') _$$MetaImplCopyWith<_$MetaImpl> get copyWith => @@ -1931,11 +1835,8 @@ abstract class _Meta implements Meta { @override @JsonKey(name: "total") int get total; - - /// Create a copy of Meta - /// with the given fields replaced by the non-null parameter values. @override - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) _$$MetaImplCopyWith<_$MetaImpl> get copyWith => throw _privateConstructorUsedError; } @@ -1953,12 +1854,8 @@ mixin _$Link { @JsonKey(name: "active") bool get active => throw _privateConstructorUsedError; - /// Serializes this Link to a JSON map. Map toJson() => throw _privateConstructorUsedError; - - /// Create a copy of Link - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) $LinkCopyWith get copyWith => throw _privateConstructorUsedError; } @@ -1983,8 +1880,6 @@ class _$LinkCopyWithImpl<$Res, $Val extends Link> // ignore: unused_field final $Res Function($Val) _then; - /// Create a copy of Link - /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -2029,8 +1924,6 @@ class __$$LinkImplCopyWithImpl<$Res> __$$LinkImplCopyWithImpl(_$LinkImpl _value, $Res Function(_$LinkImpl) _then) : super(_value, _then); - /// Create a copy of Link - /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -2091,13 +1984,11 @@ class _$LinkImpl implements _Link { (identical(other.active, active) || other.active == active)); } - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) @override int get hashCode => Object.hash(runtimeType, url, label, active); - /// Create a copy of Link - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) @override @pragma('vm:prefer-inline') _$$LinkImplCopyWith<_$LinkImpl> get copyWith => @@ -2128,11 +2019,8 @@ abstract class _Link implements Link { @override @JsonKey(name: "active") bool get active; - - /// Create a copy of Link - /// with the given fields replaced by the non-null parameter values. @override - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) _$$LinkImplCopyWith<_$LinkImpl> get copyWith => throw _privateConstructorUsedError; } diff --git a/lib/features/feed/models/feed_blog_post_model.freezed.dart b/lib/features/feed/models/feed_blog_post_model.freezed.dart index 89087373..08d5527a 100644 --- a/lib/features/feed/models/feed_blog_post_model.freezed.dart +++ b/lib/features/feed/models/feed_blog_post_model.freezed.dart @@ -41,12 +41,8 @@ mixin _$FeedBlogPostModel { @JsonKey(name: "was_liked_by_me") bool get wasLikedByMe => throw _privateConstructorUsedError; - /// Serializes this FeedBlogPostModel to a JSON map. Map toJson() => throw _privateConstructorUsedError; - - /// Create a copy of FeedBlogPostModel - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) $FeedBlogPostModelCopyWith get copyWith => throw _privateConstructorUsedError; } @@ -85,8 +81,6 @@ class _$FeedBlogPostModelCopyWithImpl<$Res, $Val extends FeedBlogPostModel> // ignore: unused_field final $Res Function($Val) _then; - /// Create a copy of FeedBlogPostModel - /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -160,8 +154,6 @@ class _$FeedBlogPostModelCopyWithImpl<$Res, $Val extends FeedBlogPostModel> ) as $Val); } - /// Create a copy of FeedBlogPostModel - /// with the given fields replaced by the non-null parameter values. @override @pragma('vm:prefer-inline') $AuthorCopyWith<$Res> get author { @@ -206,8 +198,6 @@ class __$$FeedBlogPostModelImplCopyWithImpl<$Res> $Res Function(_$FeedBlogPostModelImpl) _then) : super(_value, _then); - /// Create a copy of FeedBlogPostModel - /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -370,7 +360,7 @@ class _$FeedBlogPostModelImpl implements _FeedBlogPostModel { other.wasLikedByMe == wasLikedByMe)); } - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) @override int get hashCode => Object.hash( runtimeType, @@ -388,9 +378,7 @@ class _$FeedBlogPostModelImpl implements _FeedBlogPostModel { totalComments, wasLikedByMe); - /// Create a copy of FeedBlogPostModel - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) @override @pragma('vm:prefer-inline') _$$FeedBlogPostModelImplCopyWith<_$FeedBlogPostModelImpl> get copyWith => @@ -458,11 +446,8 @@ abstract class _FeedBlogPostModel implements FeedBlogPostModel { @override @JsonKey(name: "was_liked_by_me") bool get wasLikedByMe; - - /// Create a copy of FeedBlogPostModel - /// with the given fields replaced by the non-null parameter values. @override - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) _$$FeedBlogPostModelImplCopyWith<_$FeedBlogPostModelImpl> get copyWith => throw _privateConstructorUsedError; } diff --git a/lib/features/feed/models/feed_blog_post_settings_model.freezed.dart b/lib/features/feed/models/feed_blog_post_settings_model.freezed.dart index 9bddceae..c680d82e 100644 --- a/lib/features/feed/models/feed_blog_post_settings_model.freezed.dart +++ b/lib/features/feed/models/feed_blog_post_settings_model.freezed.dart @@ -26,12 +26,8 @@ mixin _$FeedBlogPostSettingsModel { throw _privateConstructorUsedError; Meta get meta => throw _privateConstructorUsedError; - /// Serializes this FeedBlogPostSettingsModel to a JSON map. Map toJson() => throw _privateConstructorUsedError; - - /// Create a copy of FeedBlogPostSettingsModel - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) $FeedBlogPostSettingsModelCopyWith get copyWith => throw _privateConstructorUsedError; } @@ -60,8 +56,6 @@ class _$FeedBlogPostSettingsModelCopyWithImpl<$Res, // ignore: unused_field final $Res Function($Val) _then; - /// Create a copy of FeedBlogPostSettingsModel - /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -80,8 +74,6 @@ class _$FeedBlogPostSettingsModelCopyWithImpl<$Res, ) as $Val); } - /// Create a copy of FeedBlogPostSettingsModel - /// with the given fields replaced by the non-null parameter values. @override @pragma('vm:prefer-inline') $MetaCopyWith<$Res> get meta { @@ -118,8 +110,6 @@ class __$$FeedBlogPostSettingsModelImplCopyWithImpl<$Res> $Res Function(_$FeedBlogPostSettingsModelImpl) _then) : super(_value, _then); - /// Create a copy of FeedBlogPostSettingsModel - /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -179,14 +169,12 @@ class _$FeedBlogPostSettingsModelImpl implements _FeedBlogPostSettingsModel { (identical(other.meta, meta) || other.meta == meta)); } - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) @override int get hashCode => Object.hash(runtimeType, const DeepCollectionEquality().hash(_feedBlogPostList), meta); - /// Create a copy of FeedBlogPostSettingsModel - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) @override @pragma('vm:prefer-inline') _$$FeedBlogPostSettingsModelImplCopyWith<_$FeedBlogPostSettingsModelImpl> @@ -215,11 +203,8 @@ abstract class _FeedBlogPostSettingsModel implements FeedBlogPostSettingsModel { List get feedBlogPostList; @override Meta get meta; - - /// Create a copy of FeedBlogPostSettingsModel - /// with the given fields replaced by the non-null parameter values. @override - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) _$$FeedBlogPostSettingsModelImplCopyWith<_$FeedBlogPostSettingsModelImpl> get copyWith => throw _privateConstructorUsedError; } diff --git a/lib/features/feed/models/recipes_model.freezed.dart b/lib/features/feed/models/recipes_model.freezed.dart index 9dd4f54e..26cd55e3 100644 --- a/lib/features/feed/models/recipes_model.freezed.dart +++ b/lib/features/feed/models/recipes_model.freezed.dart @@ -45,12 +45,8 @@ mixin _$Recipes { int get viewsCount => throw _privateConstructorUsedError; Author get author => throw _privateConstructorUsedError; - /// Serializes this Recipes to a JSON map. Map toJson() => throw _privateConstructorUsedError; - - /// Create a copy of Recipes - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) $RecipesCopyWith get copyWith => throw _privateConstructorUsedError; } @@ -91,8 +87,6 @@ class _$RecipesCopyWithImpl<$Res, $Val extends Recipes> // ignore: unused_field final $Res Function($Val) _then; - /// Create a copy of Recipes - /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -186,8 +180,6 @@ class _$RecipesCopyWithImpl<$Res, $Val extends Recipes> ) as $Val); } - /// Create a copy of Recipes - /// with the given fields replaced by the non-null parameter values. @override @pragma('vm:prefer-inline') $AuthorCopyWith<$Res> get author { @@ -235,8 +227,6 @@ class __$$RecipesImplCopyWithImpl<$Res> _$RecipesImpl _value, $Res Function(_$RecipesImpl) _then) : super(_value, _then); - /// Create a copy of Recipes - /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -450,7 +440,7 @@ class _$RecipesImpl implements _Recipes { (identical(other.author, author) || other.author == author)); } - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) @override int get hashCode => Object.hash( runtimeType, @@ -472,9 +462,7 @@ class _$RecipesImpl implements _Recipes { viewsCount, author); - /// Create a copy of Recipes - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) @override @pragma('vm:prefer-inline') _$$RecipesImplCopyWith<_$RecipesImpl> get copyWith => @@ -551,11 +539,8 @@ abstract class _Recipes implements Recipes { int get viewsCount; @override Author get author; - - /// Create a copy of Recipes - /// with the given fields replaced by the non-null parameter values. @override - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) _$$RecipesImplCopyWith<_$RecipesImpl> get copyWith => throw _privateConstructorUsedError; } @@ -570,12 +555,8 @@ mixin _$Ingredient { String? get unit => throw _privateConstructorUsedError; String get portion => throw _privateConstructorUsedError; - /// Serializes this Ingredient to a JSON map. Map toJson() => throw _privateConstructorUsedError; - - /// Create a copy of Ingredient - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) $IngredientCopyWith get copyWith => throw _privateConstructorUsedError; } @@ -599,8 +580,6 @@ class _$IngredientCopyWithImpl<$Res, $Val extends Ingredient> // ignore: unused_field final $Res Function($Val) _then; - /// Create a copy of Ingredient - /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -644,8 +623,6 @@ class __$$IngredientImplCopyWithImpl<$Res> _$IngredientImpl _value, $Res Function(_$IngredientImpl) _then) : super(_value, _then); - /// Create a copy of Ingredient - /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -701,13 +678,11 @@ class _$IngredientImpl implements _Ingredient { (identical(other.portion, portion) || other.portion == portion)); } - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) @override int get hashCode => Object.hash(runtimeType, name, unit, portion); - /// Create a copy of Ingredient - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) @override @pragma('vm:prefer-inline') _$$IngredientImplCopyWith<_$IngredientImpl> get copyWith => @@ -736,11 +711,8 @@ abstract class _Ingredient implements Ingredient { String? get unit; @override String get portion; - - /// Create a copy of Ingredient - /// with the given fields replaced by the non-null parameter values. @override - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) _$$IngredientImplCopyWith<_$IngredientImpl> get copyWith => throw _privateConstructorUsedError; } @@ -754,12 +726,8 @@ mixin _$Step { String get image => throw _privateConstructorUsedError; String get description => throw _privateConstructorUsedError; - /// Serializes this Step to a JSON map. Map toJson() => throw _privateConstructorUsedError; - - /// Create a copy of Step - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) $StepCopyWith get copyWith => throw _privateConstructorUsedError; } @@ -781,8 +749,6 @@ class _$StepCopyWithImpl<$Res, $Val extends Step> // ignore: unused_field final $Res Function($Val) _then; - /// Create a copy of Step - /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -819,8 +785,6 @@ class __$$StepImplCopyWithImpl<$Res> __$$StepImplCopyWithImpl(_$StepImpl _value, $Res Function(_$StepImpl) _then) : super(_value, _then); - /// Create a copy of Step - /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -868,13 +832,11 @@ class _$StepImpl implements _Step { other.description == description)); } - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) @override int get hashCode => Object.hash(runtimeType, image, description); - /// Create a copy of Step - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) @override @pragma('vm:prefer-inline') _$$StepImplCopyWith<_$StepImpl> get copyWith => @@ -899,11 +861,8 @@ abstract class _Step implements Step { String get image; @override String get description; - - /// Create a copy of Step - /// with the given fields replaced by the non-null parameter values. @override - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) _$$StepImplCopyWith<_$StepImpl> get copyWith => throw _privateConstructorUsedError; } diff --git a/lib/features/feed/models/recipes_pagination_model.freezed.dart b/lib/features/feed/models/recipes_pagination_model.freezed.dart index ca8e9f92..2f0d43fb 100644 --- a/lib/features/feed/models/recipes_pagination_model.freezed.dart +++ b/lib/features/feed/models/recipes_pagination_model.freezed.dart @@ -23,12 +23,8 @@ mixin _$RecipesPagination { @JsonKey(name: 'data') List get recipesList => throw _privateConstructorUsedError; - /// Serializes this RecipesPagination to a JSON map. Map toJson() => throw _privateConstructorUsedError; - - /// Create a copy of RecipesPagination - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) $RecipesPaginationCopyWith get copyWith => throw _privateConstructorUsedError; } @@ -52,8 +48,6 @@ class _$RecipesPaginationCopyWithImpl<$Res, $Val extends RecipesPagination> // ignore: unused_field final $Res Function($Val) _then; - /// Create a copy of RecipesPagination - /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -87,8 +81,6 @@ class __$$RecipesPaginationImplCopyWithImpl<$Res> $Res Function(_$RecipesPaginationImpl) _then) : super(_value, _then); - /// Create a copy of RecipesPagination - /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -136,14 +128,12 @@ class _$RecipesPaginationImpl implements _RecipesPagination { .equals(other._recipesList, _recipesList)); } - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) @override int get hashCode => Object.hash( runtimeType, const DeepCollectionEquality().hash(_recipesList)); - /// Create a copy of RecipesPagination - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) @override @pragma('vm:prefer-inline') _$$RecipesPaginationImplCopyWith<_$RecipesPaginationImpl> get copyWith => @@ -169,11 +159,8 @@ abstract class _RecipesPagination implements RecipesPagination { @override @JsonKey(name: 'data') List get recipesList; - - /// Create a copy of RecipesPagination - /// with the given fields replaced by the non-null parameter values. @override - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) _$$RecipesPaginationImplCopyWith<_$RecipesPaginationImpl> get copyWith => throw _privateConstructorUsedError; } diff --git a/lib/features/feed/presentation/bloc/comments_cubit/comments_state.freezed.dart b/lib/features/feed/presentation/bloc/comments_cubit/comments_state.freezed.dart index 297a668c..da3d0345 100644 --- a/lib/features/feed/presentation/bloc/comments_cubit/comments_state.freezed.dart +++ b/lib/features/feed/presentation/bloc/comments_cubit/comments_state.freezed.dart @@ -84,9 +84,6 @@ class _$CommentsStateCopyWithImpl<$Res, $Val extends CommentsState> final $Val _value; // ignore: unused_field final $Res Function($Val) _then; - - /// Create a copy of CommentsState - /// with the given fields replaced by the non-null parameter values. } /// @nodoc @@ -103,9 +100,6 @@ class __$$CommentsStateImplCopyWithImpl<$Res> __$$CommentsStateImplCopyWithImpl( _$CommentsStateImpl _value, $Res Function(_$CommentsStateImpl) _then) : super(_value, _then); - - /// Create a copy of CommentsState - /// with the given fields replaced by the non-null parameter values. } /// @nodoc @@ -220,9 +214,6 @@ class __$$CommentsStateLoadingImplCopyWithImpl<$Res> __$$CommentsStateLoadingImplCopyWithImpl(_$CommentsStateLoadingImpl _value, $Res Function(_$CommentsStateLoadingImpl) _then) : super(_value, _then); - - /// Create a copy of CommentsState - /// with the given fields replaced by the non-null parameter values. } /// @nodoc @@ -343,8 +334,6 @@ class __$$CommentsStateLoadedImplCopyWithImpl<$Res> $Res Function(_$CommentsStateLoadedImpl) _then) : super(_value, _then); - /// Create a copy of CommentsState - /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -358,8 +347,6 @@ class __$$CommentsStateLoadedImplCopyWithImpl<$Res> )); } - /// Create a copy of CommentsState - /// with the given fields replaced by the non-null parameter values. @override @pragma('vm:prefer-inline') $CommentCopyWith<$Res> get comment { @@ -393,9 +380,7 @@ class _$CommentsStateLoadedImpl implements CommentsStateLoaded { @override int get hashCode => Object.hash(runtimeType, comment); - /// Create a copy of CommentsState - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) @override @pragma('vm:prefer-inline') _$$CommentsStateLoadedImplCopyWith<_$CommentsStateLoadedImpl> get copyWith => @@ -482,10 +467,7 @@ abstract class CommentsStateLoaded implements CommentsState { _$CommentsStateLoadedImpl; Comment get comment; - - /// Create a copy of CommentsState - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) _$$CommentsStateLoadedImplCopyWith<_$CommentsStateLoadedImpl> get copyWith => throw _privateConstructorUsedError; } @@ -507,8 +489,6 @@ class __$$CommentsStateErrorImplCopyWithImpl<$Res> $Res Function(_$CommentsStateErrorImpl) _then) : super(_value, _then); - /// Create a copy of CommentsState - /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -548,9 +528,7 @@ class _$CommentsStateErrorImpl implements CommentsStateError { @override int get hashCode => Object.hash(runtimeType, errorMessage); - /// Create a copy of CommentsState - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) @override @pragma('vm:prefer-inline') _$$CommentsStateErrorImplCopyWith<_$CommentsStateErrorImpl> get copyWith => @@ -637,10 +615,7 @@ abstract class CommentsStateError implements CommentsState { _$CommentsStateErrorImpl; String get errorMessage; - - /// Create a copy of CommentsState - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) _$$CommentsStateErrorImplCopyWith<_$CommentsStateErrorImpl> get copyWith => throw _privateConstructorUsedError; } diff --git a/lib/features/feed/presentation/bloc/diets_cubit/diets_state.freezed.dart b/lib/features/feed/presentation/bloc/diets_cubit/diets_state.freezed.dart index dd30f73d..adff30f5 100644 --- a/lib/features/feed/presentation/bloc/diets_cubit/diets_state.freezed.dart +++ b/lib/features/feed/presentation/bloc/diets_cubit/diets_state.freezed.dart @@ -84,9 +84,6 @@ class _$DietsStateCopyWithImpl<$Res, $Val extends DietsState> final $Val _value; // ignore: unused_field final $Res Function($Val) _then; - - /// Create a copy of DietsState - /// with the given fields replaced by the non-null parameter values. } /// @nodoc @@ -103,9 +100,6 @@ class __$$DietsStateImplCopyWithImpl<$Res> __$$DietsStateImplCopyWithImpl( _$DietsStateImpl _value, $Res Function(_$DietsStateImpl) _then) : super(_value, _then); - - /// Create a copy of DietsState - /// with the given fields replaced by the non-null parameter values. } /// @nodoc @@ -220,9 +214,6 @@ class __$$DietsStateLoadingImplCopyWithImpl<$Res> __$$DietsStateLoadingImplCopyWithImpl(_$DietsStateLoadingImpl _value, $Res Function(_$DietsStateLoadingImpl) _then) : super(_value, _then); - - /// Create a copy of DietsState - /// with the given fields replaced by the non-null parameter values. } /// @nodoc @@ -342,8 +333,6 @@ class __$$DietsStateLoadedImplCopyWithImpl<$Res> $Res Function(_$DietsStateLoadedImpl) _then) : super(_value, _then); - /// Create a copy of DietsState - /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -357,8 +346,6 @@ class __$$DietsStateLoadedImplCopyWithImpl<$Res> )); } - /// Create a copy of DietsState - /// with the given fields replaced by the non-null parameter values. @override @pragma('vm:prefer-inline') $DietsPaginationCopyWith<$Res> get diets { @@ -392,9 +379,7 @@ class _$DietsStateLoadedImpl implements DietsStateLoaded { @override int get hashCode => Object.hash(runtimeType, diets); - /// Create a copy of DietsState - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) @override @pragma('vm:prefer-inline') _$$DietsStateLoadedImplCopyWith<_$DietsStateLoadedImpl> get copyWith => @@ -481,10 +466,7 @@ abstract class DietsStateLoaded implements DietsState { _$DietsStateLoadedImpl; DietsPagination get diets; - - /// Create a copy of DietsState - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) _$$DietsStateLoadedImplCopyWith<_$DietsStateLoadedImpl> get copyWith => throw _privateConstructorUsedError; } @@ -506,8 +488,6 @@ class __$$DietsStateErrorImplCopyWithImpl<$Res> _$DietsStateErrorImpl _value, $Res Function(_$DietsStateErrorImpl) _then) : super(_value, _then); - /// Create a copy of DietsState - /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -547,9 +527,7 @@ class _$DietsStateErrorImpl implements DietsStateError { @override int get hashCode => Object.hash(runtimeType, errorMessage); - /// Create a copy of DietsState - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) @override @pragma('vm:prefer-inline') _$$DietsStateErrorImplCopyWith<_$DietsStateErrorImpl> get copyWith => @@ -636,10 +614,7 @@ abstract class DietsStateError implements DietsState { _$DietsStateErrorImpl; String get errorMessage; - - /// Create a copy of DietsState - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) _$$DietsStateErrorImplCopyWith<_$DietsStateErrorImpl> get copyWith => throw _privateConstructorUsedError; } diff --git a/lib/features/feed/presentation/bloc/feed_cubit/feed_state.freezed.dart b/lib/features/feed/presentation/bloc/feed_cubit/feed_state.freezed.dart index 70cb30d4..779dcdb5 100644 --- a/lib/features/feed/presentation/bloc/feed_cubit/feed_state.freezed.dart +++ b/lib/features/feed/presentation/bloc/feed_cubit/feed_state.freezed.dart @@ -87,9 +87,6 @@ class _$FeedStateCopyWithImpl<$Res, $Val extends FeedState> final $Val _value; // ignore: unused_field final $Res Function($Val) _then; - - /// Create a copy of FeedState - /// with the given fields replaced by the non-null parameter values. } /// @nodoc @@ -106,9 +103,6 @@ class __$$FeedStateImplCopyWithImpl<$Res> __$$FeedStateImplCopyWithImpl( _$FeedStateImpl _value, $Res Function(_$FeedStateImpl) _then) : super(_value, _then); - - /// Create a copy of FeedState - /// with the given fields replaced by the non-null parameter values. } /// @nodoc @@ -227,9 +221,6 @@ class __$$FeedStateLoadingImplCopyWithImpl<$Res> __$$FeedStateLoadingImplCopyWithImpl(_$FeedStateLoadingImpl _value, $Res Function(_$FeedStateLoadingImpl) _then) : super(_value, _then); - - /// Create a copy of FeedState - /// with the given fields replaced by the non-null parameter values. } /// @nodoc @@ -351,8 +342,6 @@ class __$$FeedStateLoadedImplCopyWithImpl<$Res> _$FeedStateLoadedImpl _value, $Res Function(_$FeedStateLoadedImpl) _then) : super(_value, _then); - /// Create a copy of FeedState - /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -412,9 +401,7 @@ class _$FeedStateLoadedImpl implements FeedStateLoaded { int get hashCode => Object.hash(runtimeType, const DeepCollectionEquality().hash(_feedBlogPostList), isLoading); - /// Create a copy of FeedState - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) @override @pragma('vm:prefer-inline') _$$FeedStateLoadedImplCopyWith<_$FeedStateLoadedImpl> get copyWith => @@ -507,10 +494,7 @@ abstract class FeedStateLoaded implements FeedState { List get feedBlogPostList; bool get isLoading; - - /// Create a copy of FeedState - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) _$$FeedStateLoadedImplCopyWith<_$FeedStateLoadedImpl> get copyWith => throw _privateConstructorUsedError; } @@ -532,8 +516,6 @@ class __$$FeedStateErrorImplCopyWithImpl<$Res> _$FeedStateErrorImpl _value, $Res Function(_$FeedStateErrorImpl) _then) : super(_value, _then); - /// Create a copy of FeedState - /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -573,9 +555,7 @@ class _$FeedStateErrorImpl implements FeedStateError { @override int get hashCode => Object.hash(runtimeType, errorMessage); - /// Create a copy of FeedState - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) @override @pragma('vm:prefer-inline') _$$FeedStateErrorImplCopyWith<_$FeedStateErrorImpl> get copyWith => @@ -666,10 +646,7 @@ abstract class FeedStateError implements FeedState { _$FeedStateErrorImpl; String get errorMessage; - - /// Create a copy of FeedState - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) _$$FeedStateErrorImplCopyWith<_$FeedStateErrorImpl> get copyWith => throw _privateConstructorUsedError; } diff --git a/lib/features/feed/presentation/bloc/recipes_cubit/recipes_state.freezed.dart b/lib/features/feed/presentation/bloc/recipes_cubit/recipes_state.freezed.dart index 056ef8be..e8aa88e0 100644 --- a/lib/features/feed/presentation/bloc/recipes_cubit/recipes_state.freezed.dart +++ b/lib/features/feed/presentation/bloc/recipes_cubit/recipes_state.freezed.dart @@ -84,9 +84,6 @@ class _$RecipesStateCopyWithImpl<$Res, $Val extends RecipesState> final $Val _value; // ignore: unused_field final $Res Function($Val) _then; - - /// Create a copy of RecipesState - /// with the given fields replaced by the non-null parameter values. } /// @nodoc @@ -103,9 +100,6 @@ class __$$RecipesStateImplCopyWithImpl<$Res> __$$RecipesStateImplCopyWithImpl( _$RecipesStateImpl _value, $Res Function(_$RecipesStateImpl) _then) : super(_value, _then); - - /// Create a copy of RecipesState - /// with the given fields replaced by the non-null parameter values. } /// @nodoc @@ -220,9 +214,6 @@ class __$$RecipesStateLoadingImplCopyWithImpl<$Res> __$$RecipesStateLoadingImplCopyWithImpl(_$RecipesStateLoadingImpl _value, $Res Function(_$RecipesStateLoadingImpl) _then) : super(_value, _then); - - /// Create a copy of RecipesState - /// with the given fields replaced by the non-null parameter values. } /// @nodoc @@ -341,8 +332,6 @@ class __$$RecipesStateLoadedImplCopyWithImpl<$Res> $Res Function(_$RecipesStateLoadedImpl) _then) : super(_value, _then); - /// Create a copy of RecipesState - /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -389,9 +378,7 @@ class _$RecipesStateLoadedImpl implements RecipesStateLoaded { int get hashCode => Object.hash( runtimeType, const DeepCollectionEquality().hash(_recipesList)); - /// Create a copy of RecipesState - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) @override @pragma('vm:prefer-inline') _$$RecipesStateLoadedImplCopyWith<_$RecipesStateLoadedImpl> get copyWith => @@ -478,10 +465,7 @@ abstract class RecipesStateLoaded implements RecipesState { _$RecipesStateLoadedImpl; List get recipesList; - - /// Create a copy of RecipesState - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) _$$RecipesStateLoadedImplCopyWith<_$RecipesStateLoadedImpl> get copyWith => throw _privateConstructorUsedError; } @@ -503,8 +487,6 @@ class __$$RecipesStateErrorImplCopyWithImpl<$Res> $Res Function(_$RecipesStateErrorImpl) _then) : super(_value, _then); - /// Create a copy of RecipesState - /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -544,9 +526,7 @@ class _$RecipesStateErrorImpl implements RecipesStateError { @override int get hashCode => Object.hash(runtimeType, errorMessage); - /// Create a copy of RecipesState - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) @override @pragma('vm:prefer-inline') _$$RecipesStateErrorImplCopyWith<_$RecipesStateErrorImpl> get copyWith => @@ -633,10 +613,7 @@ abstract class RecipesStateError implements RecipesState { _$RecipesStateErrorImpl; String get errorMessage; - - /// Create a copy of RecipesState - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) _$$RecipesStateErrorImplCopyWith<_$RecipesStateErrorImpl> get copyWith => throw _privateConstructorUsedError; } diff --git a/lib/features/feed/services/feed_service.g.dart b/lib/features/feed/services/feed_service.g.dart index ab608334..6ae8ffef 100644 --- a/lib/features/feed/services/feed_service.g.dart +++ b/lib/features/feed/services/feed_service.g.dart @@ -390,7 +390,9 @@ class _FeedService implements FeedService { } RequestOptions _setStreamType(RequestOptions requestOptions) { - if (T != dynamic && !(requestOptions.responseType == ResponseType.bytes || requestOptions.responseType == ResponseType.stream)) { + if (T != dynamic && + !(requestOptions.responseType == ResponseType.bytes || + requestOptions.responseType == ResponseType.stream)) { if (T == String) { requestOptions.responseType = ResponseType.plain; } else { diff --git a/lib/features/menu/presentation/pages/menu_screen.dart b/lib/features/menu/presentation/pages/menu_screen.dart new file mode 100644 index 00000000..010bf6d3 --- /dev/null +++ b/lib/features/menu/presentation/pages/menu_screen.dart @@ -0,0 +1,119 @@ +import 'package:dio/dio.dart'; +import 'package:eatvio_app/core/constants/constants.dart'; +import 'package:eatvio_app/core/token_storage.dart'; +import 'package:eatvio_app/core/utils/image_constant.dart'; +import 'package:eatvio_app/locator_service.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_svg/flutter_svg.dart'; +import 'package:go_router/go_router.dart'; + +class MenuScreen extends StatelessWidget { + const MenuScreen({super.key}); + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + title: Text('Меню'), + ), + body: SingleChildScrollView( + child: Column( + children: [ + _tile( + title: 'Настройки профиля', + leading: ImageConstant.icnProfileSettings, + onTap: () => GoRouter.of(context).push('/my-settings-screen'), + ), + _divider(context), + _tile( + leading: ImageConstant.icnRecipes, + title: 'Мои рецепты', + onTap: () => GoRouter.of(context).push('/recipe-select-screen'), + ), + _divider(context), + _tile( + leading: 'assets/icons/diets.svg', + title: 'Мои диеты', + onTap: () => GoRouter.of(context).push('/diet-select-screen'), + ), + _divider(context), + _tile( + leading: ImageConstant.icnPlans, + title: 'Мои планы', + onTap: () => GoRouter.of(context).push('/plan-select-screen'), + ), + _divider(context), + _tile( + leading: 'assets/icons/calendar.svg', + title: 'Календарь', + onTap: () => GoRouter.of(context).push('/calendar-screen'), + ), + _divider(context), + _tile( + leading: ImageConstant.icnGlossary, + title: 'Глоссарий', + onTap: () => GoRouter.of(context).push('/glossary-screen'), + ), + _divider(context), + _tile( + leading: ImageConstant.icnSupport, + title: 'Поддержка', + onTap: () {}, + ), + _divider(context), + _tile( + leading: ImageConstant.icnExit, + title: 'Выход', + onTap: _onTapLogout(context), + ), + ], + ), + ), + ); + } + + _tile({ + required String title, + required String leading, + required Function() onTap, + }) { + return ListTile( + onTap: onTap, + leading: SvgPicture.asset( + leading, + height: 24, + width: 24, + ), + title: Text(title), + trailing: Icon( + Icons.arrow_forward_ios_rounded, + size: 12, + color: Colors.black38, + ), + ); + } + + _divider(BuildContext context) { + return Container( + height: 0.4, + width: MediaQuery.of(context).size.width - 32, + decoration: BoxDecoration( + color: Colors.black26, + borderRadius: BorderRadius.circular(16), + ), + ); + } + + _onTapLogout(BuildContext context) { + return () async { + final response = await sl().post( + baseUrl + '/api/profile/logout', + ); + + if (response.statusCode == 204) { + await TokenStorage.removeTokenInStorage(); + GoRouter.of(context).go('/auth-screen'); + } + }; + } +} diff --git a/lib/features/notifications/presentation/pages/notifications_screen.dart b/lib/features/notifications/presentation/pages/notifications_screen.dart new file mode 100644 index 00000000..10947cbf --- /dev/null +++ b/lib/features/notifications/presentation/pages/notifications_screen.dart @@ -0,0 +1,27 @@ +import 'package:eatvio_app/core/app_export.dart'; +import 'package:eatvio_app/features/bottom_navigation_bar/presentation/bloc/notifications_cubit/notifications_cubit.dart'; +import 'package:eatvio_app/features/bottom_navigation_bar/presentation/bloc/notifications_cubit/notifications_state.dart'; +import 'package:flutter/material.dart'; + +class NotificationsScreen extends StatelessWidget { + const NotificationsScreen({super.key}); + + @override + Widget build(BuildContext context) { + return BlocBuilder( + builder: (BuildContext context, NotificationsState state) { + return Scaffold( + appBar: AppBar( + title: Text('Уведомления'), + ), + body: SingleChildScrollView( + padding: EdgeInsets.all(16), + child: Text( + state is NotificationsStateLoaded ? state.notifications.toString() : 'Уведомлений нет', + ), + ), + ); + }, + ); + } +} diff --git a/lib/features/profile/models/profile_model.dart b/lib/features/profile/models/profile_model.dart index 8ecf3b4f..6c72a1fa 100644 --- a/lib/features/profile/models/profile_model.dart +++ b/lib/features/profile/models/profile_model.dart @@ -1,24 +1,38 @@ import 'package:freezed_annotation/freezed_annotation.dart'; - part 'profile_model.freezed.dart'; part 'profile_model.g.dart'; @freezed -class Profile with _$Profile { - const factory Profile({ +class ProfileModel with _$ProfileModel { + const factory ProfileModel({ @JsonKey(name: "user") required User user, - @JsonKey(name: "chartPoints") required List chartPoints, + @JsonKey(name: "chartPoints") required List chartPoints, @JsonKey(name: "userDetails") required UserDetails userDetails, - @JsonKey(name: "circumferences") required List circumferences, + @JsonKey(name: "circumferences") required List circumferences, @JsonKey(name: "finishedPlans") required List finishedPlans, @JsonKey(name: "rejectedPlans") required List rejectedPlans, @JsonKey(name: "startedPlan") required List startedPlan, @JsonKey(name: "paidPlan") required List paidPlan, @JsonKey(name: "requestedPlan") required List requestedPlan, @JsonKey(name: "initedPlan") required List initedPlan, - }) = _Profile; + }) = _ProfileModel; - factory Profile.fromJson(Map json) => _$ProfileFromJson(json); + factory ProfileModel.fromJson(Map json) => _$ProfileModelFromJson(json); +} + +@freezed +class Circumference with _$Circumference { + const factory Circumference({ + @JsonKey(name: "id") required int id, + @JsonKey(name: "user_id") required int userId, + @JsonKey(name: "chest_circumference") required int chestCircumference, + @JsonKey(name: "waist_circumference") required int waistCircumference, + @JsonKey(name: "hip_circumference") required int hipCircumference, + @JsonKey(name: "created_at") required DateTime createdAt, + @JsonKey(name: "updated_at") required DateTime updatedAt, + }) = _Circumference; + + factory Circumference.fromJson(Map json) => _$CircumferenceFromJson(json); } @freezed @@ -41,7 +55,7 @@ class User with _$User { @JsonKey(name: "detailz") required UserDetails detailz, }) = _User; - factory User.fromJson(Map json) => _$UserFromJson(json); + factory User.fromJson(Map json) => _$UserFromJson(json); } @freezed @@ -78,5 +92,19 @@ class UserDetails with _$UserDetails { @JsonKey(name: "activity_coefficient") required double activityCoefficient, }) = _UserDetails; - factory UserDetails.fromJson(Map json) => _$UserDetailsFromJson(json); + factory UserDetails.fromJson(Map json) => _$UserDetailsFromJson(json); +} + +@freezed +class ChartPoint with _$ChartPoint { + const factory ChartPoint({ + @JsonKey(name: "id") required int id, + @JsonKey(name: "user_id") required int userId, + @JsonKey(name: "weight") required int weight, + @JsonKey(name: "bmi") required String bmi, + @JsonKey(name: "created_at") required DateTime createdAt, + @JsonKey(name: "updated_at") required DateTime updatedAt, + }) = _ChartPoint; + + factory ChartPoint.fromJson(Map json) => _$ChartPointFromJson(json); } diff --git a/lib/features/profile/models/profile_model.freezed.dart b/lib/features/profile/models/profile_model.freezed.dart index 5319ba7c..0e5607b4 100644 --- a/lib/features/profile/models/profile_model.freezed.dart +++ b/lib/features/profile/models/profile_model.freezed.dart @@ -14,20 +14,20 @@ T _$identity(T value) => value; final _privateConstructorUsedError = UnsupportedError( 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models'); -Profile _$ProfileFromJson(Map json) { - return _Profile.fromJson(json); +ProfileModel _$ProfileModelFromJson(Map json) { + return _ProfileModel.fromJson(json); } /// @nodoc -mixin _$Profile { +mixin _$ProfileModel { @JsonKey(name: "user") User get user => throw _privateConstructorUsedError; @JsonKey(name: "chartPoints") - List get chartPoints => throw _privateConstructorUsedError; + List get chartPoints => throw _privateConstructorUsedError; @JsonKey(name: "userDetails") UserDetails get userDetails => throw _privateConstructorUsedError; @JsonKey(name: "circumferences") - List get circumferences => throw _privateConstructorUsedError; + List get circumferences => throw _privateConstructorUsedError; @JsonKey(name: "finishedPlans") List get finishedPlans => throw _privateConstructorUsedError; @JsonKey(name: "rejectedPlans") @@ -41,25 +41,23 @@ mixin _$Profile { @JsonKey(name: "initedPlan") List get initedPlan => throw _privateConstructorUsedError; - /// Serializes this Profile to a JSON map. Map toJson() => throw _privateConstructorUsedError; - - /// Create a copy of Profile - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - $ProfileCopyWith get copyWith => throw _privateConstructorUsedError; + @JsonKey(ignore: true) + $ProfileModelCopyWith get copyWith => + throw _privateConstructorUsedError; } /// @nodoc -abstract class $ProfileCopyWith<$Res> { - factory $ProfileCopyWith(Profile value, $Res Function(Profile) then) = - _$ProfileCopyWithImpl<$Res, Profile>; +abstract class $ProfileModelCopyWith<$Res> { + factory $ProfileModelCopyWith( + ProfileModel value, $Res Function(ProfileModel) then) = + _$ProfileModelCopyWithImpl<$Res, ProfileModel>; @useResult $Res call( {@JsonKey(name: "user") User user, - @JsonKey(name: "chartPoints") List chartPoints, + @JsonKey(name: "chartPoints") List chartPoints, @JsonKey(name: "userDetails") UserDetails userDetails, - @JsonKey(name: "circumferences") List circumferences, + @JsonKey(name: "circumferences") List circumferences, @JsonKey(name: "finishedPlans") List finishedPlans, @JsonKey(name: "rejectedPlans") List rejectedPlans, @JsonKey(name: "startedPlan") List startedPlan, @@ -72,17 +70,15 @@ abstract class $ProfileCopyWith<$Res> { } /// @nodoc -class _$ProfileCopyWithImpl<$Res, $Val extends Profile> - implements $ProfileCopyWith<$Res> { - _$ProfileCopyWithImpl(this._value, this._then); +class _$ProfileModelCopyWithImpl<$Res, $Val extends ProfileModel> + implements $ProfileModelCopyWith<$Res> { + _$ProfileModelCopyWithImpl(this._value, this._then); // ignore: unused_field final $Val _value; // ignore: unused_field final $Res Function($Val) _then; - /// Create a copy of Profile - /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -105,7 +101,7 @@ class _$ProfileCopyWithImpl<$Res, $Val extends Profile> chartPoints: null == chartPoints ? _value.chartPoints : chartPoints // ignore: cast_nullable_to_non_nullable - as List, + as List, userDetails: null == userDetails ? _value.userDetails : userDetails // ignore: cast_nullable_to_non_nullable @@ -113,7 +109,7 @@ class _$ProfileCopyWithImpl<$Res, $Val extends Profile> circumferences: null == circumferences ? _value.circumferences : circumferences // ignore: cast_nullable_to_non_nullable - as List, + as List, finishedPlans: null == finishedPlans ? _value.finishedPlans : finishedPlans // ignore: cast_nullable_to_non_nullable @@ -141,8 +137,6 @@ class _$ProfileCopyWithImpl<$Res, $Val extends Profile> ) as $Val); } - /// Create a copy of Profile - /// with the given fields replaced by the non-null parameter values. @override @pragma('vm:prefer-inline') $UserCopyWith<$Res> get user { @@ -151,8 +145,6 @@ class _$ProfileCopyWithImpl<$Res, $Val extends Profile> }); } - /// Create a copy of Profile - /// with the given fields replaced by the non-null parameter values. @override @pragma('vm:prefer-inline') $UserDetailsCopyWith<$Res> get userDetails { @@ -163,17 +155,18 @@ class _$ProfileCopyWithImpl<$Res, $Val extends Profile> } /// @nodoc -abstract class _$$ProfileImplCopyWith<$Res> implements $ProfileCopyWith<$Res> { - factory _$$ProfileImplCopyWith( - _$ProfileImpl value, $Res Function(_$ProfileImpl) then) = - __$$ProfileImplCopyWithImpl<$Res>; +abstract class _$$ProfileModelImplCopyWith<$Res> + implements $ProfileModelCopyWith<$Res> { + factory _$$ProfileModelImplCopyWith( + _$ProfileModelImpl value, $Res Function(_$ProfileModelImpl) then) = + __$$ProfileModelImplCopyWithImpl<$Res>; @override @useResult $Res call( {@JsonKey(name: "user") User user, - @JsonKey(name: "chartPoints") List chartPoints, + @JsonKey(name: "chartPoints") List chartPoints, @JsonKey(name: "userDetails") UserDetails userDetails, - @JsonKey(name: "circumferences") List circumferences, + @JsonKey(name: "circumferences") List circumferences, @JsonKey(name: "finishedPlans") List finishedPlans, @JsonKey(name: "rejectedPlans") List rejectedPlans, @JsonKey(name: "startedPlan") List startedPlan, @@ -188,15 +181,13 @@ abstract class _$$ProfileImplCopyWith<$Res> implements $ProfileCopyWith<$Res> { } /// @nodoc -class __$$ProfileImplCopyWithImpl<$Res> - extends _$ProfileCopyWithImpl<$Res, _$ProfileImpl> - implements _$$ProfileImplCopyWith<$Res> { - __$$ProfileImplCopyWithImpl( - _$ProfileImpl _value, $Res Function(_$ProfileImpl) _then) +class __$$ProfileModelImplCopyWithImpl<$Res> + extends _$ProfileModelCopyWithImpl<$Res, _$ProfileModelImpl> + implements _$$ProfileModelImplCopyWith<$Res> { + __$$ProfileModelImplCopyWithImpl( + _$ProfileModelImpl _value, $Res Function(_$ProfileModelImpl) _then) : super(_value, _then); - /// Create a copy of Profile - /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -211,7 +202,7 @@ class __$$ProfileImplCopyWithImpl<$Res> Object? requestedPlan = null, Object? initedPlan = null, }) { - return _then(_$ProfileImpl( + return _then(_$ProfileModelImpl( user: null == user ? _value.user : user // ignore: cast_nullable_to_non_nullable @@ -219,7 +210,7 @@ class __$$ProfileImplCopyWithImpl<$Res> chartPoints: null == chartPoints ? _value._chartPoints : chartPoints // ignore: cast_nullable_to_non_nullable - as List, + as List, userDetails: null == userDetails ? _value.userDetails : userDetails // ignore: cast_nullable_to_non_nullable @@ -227,7 +218,7 @@ class __$$ProfileImplCopyWithImpl<$Res> circumferences: null == circumferences ? _value._circumferences : circumferences // ignore: cast_nullable_to_non_nullable - as List, + as List, finishedPlans: null == finishedPlans ? _value._finishedPlans : finishedPlans // ignore: cast_nullable_to_non_nullable @@ -258,13 +249,13 @@ class __$$ProfileImplCopyWithImpl<$Res> /// @nodoc @JsonSerializable() -class _$ProfileImpl implements _Profile { - const _$ProfileImpl( +class _$ProfileModelImpl implements _ProfileModel { + const _$ProfileModelImpl( {@JsonKey(name: "user") required this.user, - @JsonKey(name: "chartPoints") required final List chartPoints, + @JsonKey(name: "chartPoints") required final List chartPoints, @JsonKey(name: "userDetails") required this.userDetails, @JsonKey(name: "circumferences") - required final List circumferences, + required final List circumferences, @JsonKey(name: "finishedPlans") required final List finishedPlans, @JsonKey(name: "rejectedPlans") @@ -283,16 +274,16 @@ class _$ProfileImpl implements _Profile { _requestedPlan = requestedPlan, _initedPlan = initedPlan; - factory _$ProfileImpl.fromJson(Map json) => - _$$ProfileImplFromJson(json); + factory _$ProfileModelImpl.fromJson(Map json) => + _$$ProfileModelImplFromJson(json); @override @JsonKey(name: "user") final User user; - final List _chartPoints; + final List _chartPoints; @override @JsonKey(name: "chartPoints") - List get chartPoints { + List get chartPoints { if (_chartPoints is EqualUnmodifiableListView) return _chartPoints; // ignore: implicit_dynamic_type return EqualUnmodifiableListView(_chartPoints); @@ -301,10 +292,10 @@ class _$ProfileImpl implements _Profile { @override @JsonKey(name: "userDetails") final UserDetails userDetails; - final List _circumferences; + final List _circumferences; @override @JsonKey(name: "circumferences") - List get circumferences { + List get circumferences { if (_circumferences is EqualUnmodifiableListView) return _circumferences; // ignore: implicit_dynamic_type return EqualUnmodifiableListView(_circumferences); @@ -366,14 +357,14 @@ class _$ProfileImpl implements _Profile { @override String toString() { - return 'Profile(user: $user, chartPoints: $chartPoints, userDetails: $userDetails, circumferences: $circumferences, finishedPlans: $finishedPlans, rejectedPlans: $rejectedPlans, startedPlan: $startedPlan, paidPlan: $paidPlan, requestedPlan: $requestedPlan, initedPlan: $initedPlan)'; + return 'ProfileModel(user: $user, chartPoints: $chartPoints, userDetails: $userDetails, circumferences: $circumferences, finishedPlans: $finishedPlans, rejectedPlans: $rejectedPlans, startedPlan: $startedPlan, paidPlan: $paidPlan, requestedPlan: $requestedPlan, initedPlan: $initedPlan)'; } @override bool operator ==(Object other) { return identical(this, other) || (other.runtimeType == runtimeType && - other is _$ProfileImpl && + other is _$ProfileModelImpl && (identical(other.user, user) || other.user == user) && const DeepCollectionEquality() .equals(other._chartPoints, _chartPoints) && @@ -394,7 +385,7 @@ class _$ProfileImpl implements _Profile { .equals(other._initedPlan, _initedPlan)); } - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) @override int get hashCode => Object.hash( runtimeType, @@ -409,29 +400,27 @@ class _$ProfileImpl implements _Profile { const DeepCollectionEquality().hash(_requestedPlan), const DeepCollectionEquality().hash(_initedPlan)); - /// Create a copy of Profile - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) @override @pragma('vm:prefer-inline') - _$$ProfileImplCopyWith<_$ProfileImpl> get copyWith => - __$$ProfileImplCopyWithImpl<_$ProfileImpl>(this, _$identity); + _$$ProfileModelImplCopyWith<_$ProfileModelImpl> get copyWith => + __$$ProfileModelImplCopyWithImpl<_$ProfileModelImpl>(this, _$identity); @override Map toJson() { - return _$$ProfileImplToJson( + return _$$ProfileModelImplToJson( this, ); } } -abstract class _Profile implements Profile { - const factory _Profile( +abstract class _ProfileModel implements ProfileModel { + const factory _ProfileModel( {@JsonKey(name: "user") required final User user, - @JsonKey(name: "chartPoints") required final List chartPoints, + @JsonKey(name: "chartPoints") required final List chartPoints, @JsonKey(name: "userDetails") required final UserDetails userDetails, @JsonKey(name: "circumferences") - required final List circumferences, + required final List circumferences, @JsonKey(name: "finishedPlans") required final List finishedPlans, @JsonKey(name: "rejectedPlans") @@ -441,22 +430,23 @@ abstract class _Profile implements Profile { @JsonKey(name: "requestedPlan") required final List requestedPlan, @JsonKey(name: "initedPlan") - required final List initedPlan}) = _$ProfileImpl; + required final List initedPlan}) = _$ProfileModelImpl; - factory _Profile.fromJson(Map json) = _$ProfileImpl.fromJson; + factory _ProfileModel.fromJson(Map json) = + _$ProfileModelImpl.fromJson; @override @JsonKey(name: "user") User get user; @override @JsonKey(name: "chartPoints") - List get chartPoints; + List get chartPoints; @override @JsonKey(name: "userDetails") UserDetails get userDetails; @override @JsonKey(name: "circumferences") - List get circumferences; + List get circumferences; @override @JsonKey(name: "finishedPlans") List get finishedPlans; @@ -475,12 +465,299 @@ abstract class _Profile implements Profile { @override @JsonKey(name: "initedPlan") List get initedPlan; - - /// Create a copy of Profile - /// with the given fields replaced by the non-null parameter values. @override - @JsonKey(includeFromJson: false, includeToJson: false) - _$$ProfileImplCopyWith<_$ProfileImpl> get copyWith => + @JsonKey(ignore: true) + _$$ProfileModelImplCopyWith<_$ProfileModelImpl> get copyWith => + throw _privateConstructorUsedError; +} + +Circumference _$CircumferenceFromJson(Map json) { + return _Circumference.fromJson(json); +} + +/// @nodoc +mixin _$Circumference { + @JsonKey(name: "id") + int get id => throw _privateConstructorUsedError; + @JsonKey(name: "user_id") + int get userId => throw _privateConstructorUsedError; + @JsonKey(name: "chest_circumference") + int get chestCircumference => throw _privateConstructorUsedError; + @JsonKey(name: "waist_circumference") + int get waistCircumference => throw _privateConstructorUsedError; + @JsonKey(name: "hip_circumference") + int get hipCircumference => throw _privateConstructorUsedError; + @JsonKey(name: "created_at") + DateTime get createdAt => throw _privateConstructorUsedError; + @JsonKey(name: "updated_at") + DateTime get updatedAt => throw _privateConstructorUsedError; + + Map toJson() => throw _privateConstructorUsedError; + @JsonKey(ignore: true) + $CircumferenceCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $CircumferenceCopyWith<$Res> { + factory $CircumferenceCopyWith( + Circumference value, $Res Function(Circumference) then) = + _$CircumferenceCopyWithImpl<$Res, Circumference>; + @useResult + $Res call( + {@JsonKey(name: "id") int id, + @JsonKey(name: "user_id") int userId, + @JsonKey(name: "chest_circumference") int chestCircumference, + @JsonKey(name: "waist_circumference") int waistCircumference, + @JsonKey(name: "hip_circumference") int hipCircumference, + @JsonKey(name: "created_at") DateTime createdAt, + @JsonKey(name: "updated_at") DateTime updatedAt}); +} + +/// @nodoc +class _$CircumferenceCopyWithImpl<$Res, $Val extends Circumference> + implements $CircumferenceCopyWith<$Res> { + _$CircumferenceCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? id = null, + Object? userId = null, + Object? chestCircumference = null, + Object? waistCircumference = null, + Object? hipCircumference = null, + Object? createdAt = null, + Object? updatedAt = null, + }) { + return _then(_value.copyWith( + id: null == id + ? _value.id + : id // ignore: cast_nullable_to_non_nullable + as int, + userId: null == userId + ? _value.userId + : userId // ignore: cast_nullable_to_non_nullable + as int, + chestCircumference: null == chestCircumference + ? _value.chestCircumference + : chestCircumference // ignore: cast_nullable_to_non_nullable + as int, + waistCircumference: null == waistCircumference + ? _value.waistCircumference + : waistCircumference // ignore: cast_nullable_to_non_nullable + as int, + hipCircumference: null == hipCircumference + ? _value.hipCircumference + : hipCircumference // ignore: cast_nullable_to_non_nullable + as int, + createdAt: null == createdAt + ? _value.createdAt + : createdAt // ignore: cast_nullable_to_non_nullable + as DateTime, + updatedAt: null == updatedAt + ? _value.updatedAt + : updatedAt // ignore: cast_nullable_to_non_nullable + as DateTime, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$CircumferenceImplCopyWith<$Res> + implements $CircumferenceCopyWith<$Res> { + factory _$$CircumferenceImplCopyWith( + _$CircumferenceImpl value, $Res Function(_$CircumferenceImpl) then) = + __$$CircumferenceImplCopyWithImpl<$Res>; + @override + @useResult + $Res call( + {@JsonKey(name: "id") int id, + @JsonKey(name: "user_id") int userId, + @JsonKey(name: "chest_circumference") int chestCircumference, + @JsonKey(name: "waist_circumference") int waistCircumference, + @JsonKey(name: "hip_circumference") int hipCircumference, + @JsonKey(name: "created_at") DateTime createdAt, + @JsonKey(name: "updated_at") DateTime updatedAt}); +} + +/// @nodoc +class __$$CircumferenceImplCopyWithImpl<$Res> + extends _$CircumferenceCopyWithImpl<$Res, _$CircumferenceImpl> + implements _$$CircumferenceImplCopyWith<$Res> { + __$$CircumferenceImplCopyWithImpl( + _$CircumferenceImpl _value, $Res Function(_$CircumferenceImpl) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? id = null, + Object? userId = null, + Object? chestCircumference = null, + Object? waistCircumference = null, + Object? hipCircumference = null, + Object? createdAt = null, + Object? updatedAt = null, + }) { + return _then(_$CircumferenceImpl( + id: null == id + ? _value.id + : id // ignore: cast_nullable_to_non_nullable + as int, + userId: null == userId + ? _value.userId + : userId // ignore: cast_nullable_to_non_nullable + as int, + chestCircumference: null == chestCircumference + ? _value.chestCircumference + : chestCircumference // ignore: cast_nullable_to_non_nullable + as int, + waistCircumference: null == waistCircumference + ? _value.waistCircumference + : waistCircumference // ignore: cast_nullable_to_non_nullable + as int, + hipCircumference: null == hipCircumference + ? _value.hipCircumference + : hipCircumference // ignore: cast_nullable_to_non_nullable + as int, + createdAt: null == createdAt + ? _value.createdAt + : createdAt // ignore: cast_nullable_to_non_nullable + as DateTime, + updatedAt: null == updatedAt + ? _value.updatedAt + : updatedAt // ignore: cast_nullable_to_non_nullable + as DateTime, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$CircumferenceImpl implements _Circumference { + const _$CircumferenceImpl( + {@JsonKey(name: "id") required this.id, + @JsonKey(name: "user_id") required this.userId, + @JsonKey(name: "chest_circumference") required this.chestCircumference, + @JsonKey(name: "waist_circumference") required this.waistCircumference, + @JsonKey(name: "hip_circumference") required this.hipCircumference, + @JsonKey(name: "created_at") required this.createdAt, + @JsonKey(name: "updated_at") required this.updatedAt}); + + factory _$CircumferenceImpl.fromJson(Map json) => + _$$CircumferenceImplFromJson(json); + + @override + @JsonKey(name: "id") + final int id; + @override + @JsonKey(name: "user_id") + final int userId; + @override + @JsonKey(name: "chest_circumference") + final int chestCircumference; + @override + @JsonKey(name: "waist_circumference") + final int waistCircumference; + @override + @JsonKey(name: "hip_circumference") + final int hipCircumference; + @override + @JsonKey(name: "created_at") + final DateTime createdAt; + @override + @JsonKey(name: "updated_at") + final DateTime updatedAt; + + @override + String toString() { + return 'Circumference(id: $id, userId: $userId, chestCircumference: $chestCircumference, waistCircumference: $waistCircumference, hipCircumference: $hipCircumference, createdAt: $createdAt, updatedAt: $updatedAt)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$CircumferenceImpl && + (identical(other.id, id) || other.id == id) && + (identical(other.userId, userId) || other.userId == userId) && + (identical(other.chestCircumference, chestCircumference) || + other.chestCircumference == chestCircumference) && + (identical(other.waistCircumference, waistCircumference) || + other.waistCircumference == waistCircumference) && + (identical(other.hipCircumference, hipCircumference) || + other.hipCircumference == hipCircumference) && + (identical(other.createdAt, createdAt) || + other.createdAt == createdAt) && + (identical(other.updatedAt, updatedAt) || + other.updatedAt == updatedAt)); + } + + @JsonKey(ignore: true) + @override + int get hashCode => Object.hash(runtimeType, id, userId, chestCircumference, + waistCircumference, hipCircumference, createdAt, updatedAt); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$CircumferenceImplCopyWith<_$CircumferenceImpl> get copyWith => + __$$CircumferenceImplCopyWithImpl<_$CircumferenceImpl>(this, _$identity); + + @override + Map toJson() { + return _$$CircumferenceImplToJson( + this, + ); + } +} + +abstract class _Circumference implements Circumference { + const factory _Circumference( + {@JsonKey(name: "id") required final int id, + @JsonKey(name: "user_id") required final int userId, + @JsonKey(name: "chest_circumference") + required final int chestCircumference, + @JsonKey(name: "waist_circumference") + required final int waistCircumference, + @JsonKey(name: "hip_circumference") required final int hipCircumference, + @JsonKey(name: "created_at") required final DateTime createdAt, + @JsonKey(name: "updated_at") + required final DateTime updatedAt}) = _$CircumferenceImpl; + + factory _Circumference.fromJson(Map json) = + _$CircumferenceImpl.fromJson; + + @override + @JsonKey(name: "id") + int get id; + @override + @JsonKey(name: "user_id") + int get userId; + @override + @JsonKey(name: "chest_circumference") + int get chestCircumference; + @override + @JsonKey(name: "waist_circumference") + int get waistCircumference; + @override + @JsonKey(name: "hip_circumference") + int get hipCircumference; + @override + @JsonKey(name: "created_at") + DateTime get createdAt; + @override + @JsonKey(name: "updated_at") + DateTime get updatedAt; + @override + @JsonKey(ignore: true) + _$$CircumferenceImplCopyWith<_$CircumferenceImpl> get copyWith => throw _privateConstructorUsedError; } @@ -521,12 +798,8 @@ mixin _$User { @JsonKey(name: "detailz") UserDetails get detailz => throw _privateConstructorUsedError; - /// Serializes this User to a JSON map. Map toJson() => throw _privateConstructorUsedError; - - /// Create a copy of User - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) $UserCopyWith get copyWith => throw _privateConstructorUsedError; } @@ -565,8 +838,6 @@ class _$UserCopyWithImpl<$Res, $Val extends User> // ignore: unused_field final $Res Function($Val) _then; - /// Create a copy of User - /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -650,8 +921,6 @@ class _$UserCopyWithImpl<$Res, $Val extends User> ) as $Val); } - /// Create a copy of User - /// with the given fields replaced by the non-null parameter values. @override @pragma('vm:prefer-inline') $UserDetailsCopyWith<$Res> get detailz { @@ -696,8 +965,6 @@ class __$$UserImplCopyWithImpl<$Res> __$$UserImplCopyWithImpl(_$UserImpl _value, $Res Function(_$UserImpl) _then) : super(_value, _then); - /// Create a copy of User - /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -889,7 +1156,7 @@ class _$UserImpl implements _User { (identical(other.detailz, detailz) || other.detailz == detailz)); } - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) @override int get hashCode => Object.hash( runtimeType, @@ -909,9 +1176,7 @@ class _$UserImpl implements _User { profilePhotoUrl, detailz); - /// Create a copy of User - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) @override @pragma('vm:prefer-inline') _$$UserImplCopyWith<_$UserImpl> get copyWith => @@ -994,11 +1259,8 @@ abstract class _User implements User { @override @JsonKey(name: "detailz") UserDetails get detailz; - - /// Create a copy of User - /// with the given fields replaced by the non-null parameter values. @override - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) _$$UserImplCopyWith<_$UserImpl> get copyWith => throw _privateConstructorUsedError; } @@ -1068,12 +1330,8 @@ mixin _$UserDetails { @JsonKey(name: "activity_coefficient") double get activityCoefficient => throw _privateConstructorUsedError; - /// Serializes this UserDetails to a JSON map. Map toJson() => throw _privateConstructorUsedError; - - /// Create a copy of UserDetails - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) $UserDetailsCopyWith get copyWith => throw _privateConstructorUsedError; } @@ -1126,8 +1384,6 @@ class _$UserDetailsCopyWithImpl<$Res, $Val extends UserDetails> // ignore: unused_field final $Res Function($Val) _then; - /// Create a copy of UserDetails - /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -1330,8 +1586,6 @@ class __$$UserDetailsImplCopyWithImpl<$Res> _$UserDetailsImpl _value, $Res Function(_$UserDetailsImpl) _then) : super(_value, _then); - /// Create a copy of UserDetails - /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -1673,7 +1927,7 @@ class _$UserDetailsImpl implements _UserDetails { other.activityCoefficient == activityCoefficient)); } - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) @override int get hashCode => Object.hashAll([ runtimeType, @@ -1708,9 +1962,7 @@ class _$UserDetailsImpl implements _UserDetails { activityCoefficient ]); - /// Create a copy of UserDetails - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) @override @pragma('vm:prefer-inline') _$$UserDetailsImplCopyWith<_$UserDetailsImpl> get copyWith => @@ -1852,11 +2104,270 @@ abstract class _UserDetails implements UserDetails { @override @JsonKey(name: "activity_coefficient") double get activityCoefficient; - - /// Create a copy of UserDetails - /// with the given fields replaced by the non-null parameter values. @override - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) _$$UserDetailsImplCopyWith<_$UserDetailsImpl> get copyWith => throw _privateConstructorUsedError; } + +ChartPoint _$ChartPointFromJson(Map json) { + return _ChartPoint.fromJson(json); +} + +/// @nodoc +mixin _$ChartPoint { + @JsonKey(name: "id") + int get id => throw _privateConstructorUsedError; + @JsonKey(name: "user_id") + int get userId => throw _privateConstructorUsedError; + @JsonKey(name: "weight") + int get weight => throw _privateConstructorUsedError; + @JsonKey(name: "bmi") + String get bmi => throw _privateConstructorUsedError; + @JsonKey(name: "created_at") + DateTime get createdAt => throw _privateConstructorUsedError; + @JsonKey(name: "updated_at") + DateTime get updatedAt => throw _privateConstructorUsedError; + + Map toJson() => throw _privateConstructorUsedError; + @JsonKey(ignore: true) + $ChartPointCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $ChartPointCopyWith<$Res> { + factory $ChartPointCopyWith( + ChartPoint value, $Res Function(ChartPoint) then) = + _$ChartPointCopyWithImpl<$Res, ChartPoint>; + @useResult + $Res call( + {@JsonKey(name: "id") int id, + @JsonKey(name: "user_id") int userId, + @JsonKey(name: "weight") int weight, + @JsonKey(name: "bmi") String bmi, + @JsonKey(name: "created_at") DateTime createdAt, + @JsonKey(name: "updated_at") DateTime updatedAt}); +} + +/// @nodoc +class _$ChartPointCopyWithImpl<$Res, $Val extends ChartPoint> + implements $ChartPointCopyWith<$Res> { + _$ChartPointCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? id = null, + Object? userId = null, + Object? weight = null, + Object? bmi = null, + Object? createdAt = null, + Object? updatedAt = null, + }) { + return _then(_value.copyWith( + id: null == id + ? _value.id + : id // ignore: cast_nullable_to_non_nullable + as int, + userId: null == userId + ? _value.userId + : userId // ignore: cast_nullable_to_non_nullable + as int, + weight: null == weight + ? _value.weight + : weight // ignore: cast_nullable_to_non_nullable + as int, + bmi: null == bmi + ? _value.bmi + : bmi // ignore: cast_nullable_to_non_nullable + as String, + createdAt: null == createdAt + ? _value.createdAt + : createdAt // ignore: cast_nullable_to_non_nullable + as DateTime, + updatedAt: null == updatedAt + ? _value.updatedAt + : updatedAt // ignore: cast_nullable_to_non_nullable + as DateTime, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$ChartPointImplCopyWith<$Res> + implements $ChartPointCopyWith<$Res> { + factory _$$ChartPointImplCopyWith( + _$ChartPointImpl value, $Res Function(_$ChartPointImpl) then) = + __$$ChartPointImplCopyWithImpl<$Res>; + @override + @useResult + $Res call( + {@JsonKey(name: "id") int id, + @JsonKey(name: "user_id") int userId, + @JsonKey(name: "weight") int weight, + @JsonKey(name: "bmi") String bmi, + @JsonKey(name: "created_at") DateTime createdAt, + @JsonKey(name: "updated_at") DateTime updatedAt}); +} + +/// @nodoc +class __$$ChartPointImplCopyWithImpl<$Res> + extends _$ChartPointCopyWithImpl<$Res, _$ChartPointImpl> + implements _$$ChartPointImplCopyWith<$Res> { + __$$ChartPointImplCopyWithImpl( + _$ChartPointImpl _value, $Res Function(_$ChartPointImpl) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? id = null, + Object? userId = null, + Object? weight = null, + Object? bmi = null, + Object? createdAt = null, + Object? updatedAt = null, + }) { + return _then(_$ChartPointImpl( + id: null == id + ? _value.id + : id // ignore: cast_nullable_to_non_nullable + as int, + userId: null == userId + ? _value.userId + : userId // ignore: cast_nullable_to_non_nullable + as int, + weight: null == weight + ? _value.weight + : weight // ignore: cast_nullable_to_non_nullable + as int, + bmi: null == bmi + ? _value.bmi + : bmi // ignore: cast_nullable_to_non_nullable + as String, + createdAt: null == createdAt + ? _value.createdAt + : createdAt // ignore: cast_nullable_to_non_nullable + as DateTime, + updatedAt: null == updatedAt + ? _value.updatedAt + : updatedAt // ignore: cast_nullable_to_non_nullable + as DateTime, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$ChartPointImpl implements _ChartPoint { + const _$ChartPointImpl( + {@JsonKey(name: "id") required this.id, + @JsonKey(name: "user_id") required this.userId, + @JsonKey(name: "weight") required this.weight, + @JsonKey(name: "bmi") required this.bmi, + @JsonKey(name: "created_at") required this.createdAt, + @JsonKey(name: "updated_at") required this.updatedAt}); + + factory _$ChartPointImpl.fromJson(Map json) => + _$$ChartPointImplFromJson(json); + + @override + @JsonKey(name: "id") + final int id; + @override + @JsonKey(name: "user_id") + final int userId; + @override + @JsonKey(name: "weight") + final int weight; + @override + @JsonKey(name: "bmi") + final String bmi; + @override + @JsonKey(name: "created_at") + final DateTime createdAt; + @override + @JsonKey(name: "updated_at") + final DateTime updatedAt; + + @override + String toString() { + return 'ChartPoint(id: $id, userId: $userId, weight: $weight, bmi: $bmi, createdAt: $createdAt, updatedAt: $updatedAt)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$ChartPointImpl && + (identical(other.id, id) || other.id == id) && + (identical(other.userId, userId) || other.userId == userId) && + (identical(other.weight, weight) || other.weight == weight) && + (identical(other.bmi, bmi) || other.bmi == bmi) && + (identical(other.createdAt, createdAt) || + other.createdAt == createdAt) && + (identical(other.updatedAt, updatedAt) || + other.updatedAt == updatedAt)); + } + + @JsonKey(ignore: true) + @override + int get hashCode => + Object.hash(runtimeType, id, userId, weight, bmi, createdAt, updatedAt); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$ChartPointImplCopyWith<_$ChartPointImpl> get copyWith => + __$$ChartPointImplCopyWithImpl<_$ChartPointImpl>(this, _$identity); + + @override + Map toJson() { + return _$$ChartPointImplToJson( + this, + ); + } +} + +abstract class _ChartPoint implements ChartPoint { + const factory _ChartPoint( + {@JsonKey(name: "id") required final int id, + @JsonKey(name: "user_id") required final int userId, + @JsonKey(name: "weight") required final int weight, + @JsonKey(name: "bmi") required final String bmi, + @JsonKey(name: "created_at") required final DateTime createdAt, + @JsonKey(name: "updated_at") required final DateTime updatedAt}) = + _$ChartPointImpl; + + factory _ChartPoint.fromJson(Map json) = + _$ChartPointImpl.fromJson; + + @override + @JsonKey(name: "id") + int get id; + @override + @JsonKey(name: "user_id") + int get userId; + @override + @JsonKey(name: "weight") + int get weight; + @override + @JsonKey(name: "bmi") + String get bmi; + @override + @JsonKey(name: "created_at") + DateTime get createdAt; + @override + @JsonKey(name: "updated_at") + DateTime get updatedAt; + @override + @JsonKey(ignore: true) + _$$ChartPointImplCopyWith<_$ChartPointImpl> get copyWith => + throw _privateConstructorUsedError; +} diff --git a/lib/features/profile/models/profile_model.g.dart b/lib/features/profile/models/profile_model.g.dart index e7943fdf..af1c1c4d 100644 --- a/lib/features/profile/models/profile_model.g.dart +++ b/lib/features/profile/models/profile_model.g.dart @@ -6,13 +6,17 @@ part of 'profile_model.dart'; // JsonSerializableGenerator // ************************************************************************** -_$ProfileImpl _$$ProfileImplFromJson(Map json) => - _$ProfileImpl( +_$ProfileModelImpl _$$ProfileModelImplFromJson(Map json) => + _$ProfileModelImpl( user: User.fromJson(json['user'] as Map), - chartPoints: json['chartPoints'] as List, + chartPoints: (json['chartPoints'] as List) + .map((e) => ChartPoint.fromJson(e as Map)) + .toList(), userDetails: UserDetails.fromJson(json['userDetails'] as Map), - circumferences: json['circumferences'] as List, + circumferences: (json['circumferences'] as List) + .map((e) => Circumference.fromJson(e as Map)) + .toList(), finishedPlans: json['finishedPlans'] as List, rejectedPlans: json['rejectedPlans'] as List, startedPlan: json['startedPlan'] as List, @@ -21,7 +25,7 @@ _$ProfileImpl _$$ProfileImplFromJson(Map json) => initedPlan: json['initedPlan'] as List, ); -Map _$$ProfileImplToJson(_$ProfileImpl instance) => +Map _$$ProfileModelImplToJson(_$ProfileModelImpl instance) => { 'user': instance.user, 'chartPoints': instance.chartPoints, @@ -35,6 +39,28 @@ Map _$$ProfileImplToJson(_$ProfileImpl instance) => 'initedPlan': instance.initedPlan, }; +_$CircumferenceImpl _$$CircumferenceImplFromJson(Map json) => + _$CircumferenceImpl( + id: (json['id'] as num).toInt(), + userId: (json['user_id'] as num).toInt(), + chestCircumference: (json['chest_circumference'] as num).toInt(), + waistCircumference: (json['waist_circumference'] as num).toInt(), + hipCircumference: (json['hip_circumference'] as num).toInt(), + createdAt: DateTime.parse(json['created_at'] as String), + updatedAt: DateTime.parse(json['updated_at'] as String), + ); + +Map _$$CircumferenceImplToJson(_$CircumferenceImpl instance) => + { + 'id': instance.id, + 'user_id': instance.userId, + 'chest_circumference': instance.chestCircumference, + 'waist_circumference': instance.waistCircumference, + 'hip_circumference': instance.hipCircumference, + 'created_at': instance.createdAt.toIso8601String(), + 'updated_at': instance.updatedAt.toIso8601String(), + }; + _$UserImpl _$$UserImplFromJson(Map json) => _$UserImpl( id: (json['id'] as num).toInt(), name: json['name'] as String, @@ -137,3 +163,23 @@ Map _$$UserDetailsImplToJson(_$UserDetailsImpl instance) => 'is_bedtime_fillable': instance.isBedtimeFillable, 'activity_coefficient': instance.activityCoefficient, }; + +_$ChartPointImpl _$$ChartPointImplFromJson(Map json) => + _$ChartPointImpl( + id: (json['id'] as num).toInt(), + userId: (json['user_id'] as num).toInt(), + weight: (json['weight'] as num).toInt(), + bmi: json['bmi'] as String, + createdAt: DateTime.parse(json['created_at'] as String), + updatedAt: DateTime.parse(json['updated_at'] as String), + ); + +Map _$$ChartPointImplToJson(_$ChartPointImpl instance) => + { + 'id': instance.id, + 'user_id': instance.userId, + 'weight': instance.weight, + 'bmi': instance.bmi, + 'created_at': instance.createdAt.toIso8601String(), + 'updated_at': instance.updatedAt.toIso8601String(), + }; diff --git a/lib/features/profile/presentation/bloc/profile_cubit/profile_cubit.dart b/lib/features/profile/presentation/bloc/profile_cubit/profile_cubit.dart index 452c1895..0a08e8de 100644 --- a/lib/features/profile/presentation/bloc/profile_cubit/profile_cubit.dart +++ b/lib/features/profile/presentation/bloc/profile_cubit/profile_cubit.dart @@ -5,11 +5,56 @@ import 'package:eatvio_app/features/profile/repositories/profile_repository.dart class ProfileCubit extends Cubit { final ProfileRepository profileRepository; - ProfileCubit({required this.profileRepository}) : super(const ProfileState.loading()); + ProfileCubit({ + required this.profileRepository, + }) : super(const ProfileState.loading()); getProfileBySlug(String slug) async { try { - emit(ProfileState.loaded(profile: await profileRepository.getProfileBySlug(slug))); + emit(ProfileState.loaded( + profile: await profileRepository.getProfileBySlug(slug), + )); + } catch (e) { + emit(ProfileState.error(errorMessage: e.toString())); + print(e); + } + } + + getMyProfile() async { + try { + emit(ProfileState.loaded( + profile: await profileRepository.getMyProfile(), + )); + } catch (e) { + emit(ProfileState.error(errorMessage: e.toString())); + print(e); + } + } + + addCircumference({ + required int chestCircumference, + required int waistCircumference, + required int hipCircumference, + }) async { + try { + await profileRepository.addCircumference( + chestCircumference: chestCircumference, + waistCircumference: waistCircumference, + hipCircumference: hipCircumference, + ); + } catch (e) { + emit(ProfileState.error(errorMessage: e.toString())); + print(e); + } + } + + addWeight({ + required int weight, + }) async { + try { + await profileRepository.addWeight( + weight: weight, + ); } catch (e) { emit(ProfileState.error(errorMessage: e.toString())); print(e); diff --git a/lib/features/profile/presentation/bloc/profile_cubit/profile_state.dart b/lib/features/profile/presentation/bloc/profile_cubit/profile_state.dart index 1b6ee5ad..1f06bfe4 100644 --- a/lib/features/profile/presentation/bloc/profile_cubit/profile_state.dart +++ b/lib/features/profile/presentation/bloc/profile_cubit/profile_state.dart @@ -10,7 +10,7 @@ abstract class ProfileState with _$ProfileState { const factory ProfileState.loading() = ProfileStateLoading; const factory ProfileState.loaded({ - required Profile profile, + required ProfileModel profile, }) = ProfileStateLoaded; const factory ProfileState.error({ diff --git a/lib/features/profile/presentation/bloc/profile_cubit/profile_state.freezed.dart b/lib/features/profile/presentation/bloc/profile_cubit/profile_state.freezed.dart index c06a0c0d..2658d2e2 100644 --- a/lib/features/profile/presentation/bloc/profile_cubit/profile_state.freezed.dart +++ b/lib/features/profile/presentation/bloc/profile_cubit/profile_state.freezed.dart @@ -20,7 +20,7 @@ mixin _$ProfileState { TResult when( TResult Function() $default, { required TResult Function() loading, - required TResult Function(Profile profile) loaded, + required TResult Function(ProfileModel profile) loaded, required TResult Function(String errorMessage) error, }) => throw _privateConstructorUsedError; @@ -28,7 +28,7 @@ mixin _$ProfileState { TResult? whenOrNull( TResult? Function()? $default, { TResult? Function()? loading, - TResult? Function(Profile profile)? loaded, + TResult? Function(ProfileModel profile)? loaded, TResult? Function(String errorMessage)? error, }) => throw _privateConstructorUsedError; @@ -36,7 +36,7 @@ mixin _$ProfileState { TResult maybeWhen( TResult Function()? $default, { TResult Function()? loading, - TResult Function(Profile profile)? loaded, + TResult Function(ProfileModel profile)? loaded, TResult Function(String errorMessage)? error, required TResult orElse(), }) => @@ -84,9 +84,6 @@ class _$ProfileStateCopyWithImpl<$Res, $Val extends ProfileState> final $Val _value; // ignore: unused_field final $Res Function($Val) _then; - - /// Create a copy of ProfileState - /// with the given fields replaced by the non-null parameter values. } /// @nodoc @@ -103,9 +100,6 @@ class __$$ProfileStateImplCopyWithImpl<$Res> __$$ProfileStateImplCopyWithImpl( _$ProfileStateImpl _value, $Res Function(_$ProfileStateImpl) _then) : super(_value, _then); - - /// Create a copy of ProfileState - /// with the given fields replaced by the non-null parameter values. } /// @nodoc @@ -132,7 +126,7 @@ class _$ProfileStateImpl implements _ProfileState { TResult when( TResult Function() $default, { required TResult Function() loading, - required TResult Function(Profile profile) loaded, + required TResult Function(ProfileModel profile) loaded, required TResult Function(String errorMessage) error, }) { return $default(); @@ -143,7 +137,7 @@ class _$ProfileStateImpl implements _ProfileState { TResult? whenOrNull( TResult? Function()? $default, { TResult? Function()? loading, - TResult? Function(Profile profile)? loaded, + TResult? Function(ProfileModel profile)? loaded, TResult? Function(String errorMessage)? error, }) { return $default?.call(); @@ -154,7 +148,7 @@ class _$ProfileStateImpl implements _ProfileState { TResult maybeWhen( TResult Function()? $default, { TResult Function()? loading, - TResult Function(Profile profile)? loaded, + TResult Function(ProfileModel profile)? loaded, TResult Function(String errorMessage)? error, required TResult orElse(), }) { @@ -220,9 +214,6 @@ class __$$ProfileStateLoadingImplCopyWithImpl<$Res> __$$ProfileStateLoadingImplCopyWithImpl(_$ProfileStateLoadingImpl _value, $Res Function(_$ProfileStateLoadingImpl) _then) : super(_value, _then); - - /// Create a copy of ProfileState - /// with the given fields replaced by the non-null parameter values. } /// @nodoc @@ -250,7 +241,7 @@ class _$ProfileStateLoadingImpl implements ProfileStateLoading { TResult when( TResult Function() $default, { required TResult Function() loading, - required TResult Function(Profile profile) loaded, + required TResult Function(ProfileModel profile) loaded, required TResult Function(String errorMessage) error, }) { return loading(); @@ -261,7 +252,7 @@ class _$ProfileStateLoadingImpl implements ProfileStateLoading { TResult? whenOrNull( TResult? Function()? $default, { TResult? Function()? loading, - TResult? Function(Profile profile)? loaded, + TResult? Function(ProfileModel profile)? loaded, TResult? Function(String errorMessage)? error, }) { return loading?.call(); @@ -272,7 +263,7 @@ class _$ProfileStateLoadingImpl implements ProfileStateLoading { TResult maybeWhen( TResult Function()? $default, { TResult Function()? loading, - TResult Function(Profile profile)? loaded, + TResult Function(ProfileModel profile)? loaded, TResult Function(String errorMessage)? error, required TResult orElse(), }) { @@ -330,9 +321,9 @@ abstract class _$$ProfileStateLoadedImplCopyWith<$Res> { $Res Function(_$ProfileStateLoadedImpl) then) = __$$ProfileStateLoadedImplCopyWithImpl<$Res>; @useResult - $Res call({Profile profile}); + $Res call({ProfileModel profile}); - $ProfileCopyWith<$Res> get profile; + $ProfileModelCopyWith<$Res> get profile; } /// @nodoc @@ -343,8 +334,6 @@ class __$$ProfileStateLoadedImplCopyWithImpl<$Res> $Res Function(_$ProfileStateLoadedImpl) _then) : super(_value, _then); - /// Create a copy of ProfileState - /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -354,16 +343,14 @@ class __$$ProfileStateLoadedImplCopyWithImpl<$Res> profile: null == profile ? _value.profile : profile // ignore: cast_nullable_to_non_nullable - as Profile, + as ProfileModel, )); } - /// Create a copy of ProfileState - /// with the given fields replaced by the non-null parameter values. @override @pragma('vm:prefer-inline') - $ProfileCopyWith<$Res> get profile { - return $ProfileCopyWith<$Res>(_value.profile, (value) { + $ProfileModelCopyWith<$Res> get profile { + return $ProfileModelCopyWith<$Res>(_value.profile, (value) { return _then(_value.copyWith(profile: value)); }); } @@ -375,7 +362,7 @@ class _$ProfileStateLoadedImpl implements ProfileStateLoaded { const _$ProfileStateLoadedImpl({required this.profile}); @override - final Profile profile; + final ProfileModel profile; @override String toString() { @@ -393,9 +380,7 @@ class _$ProfileStateLoadedImpl implements ProfileStateLoaded { @override int get hashCode => Object.hash(runtimeType, profile); - /// Create a copy of ProfileState - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) @override @pragma('vm:prefer-inline') _$$ProfileStateLoadedImplCopyWith<_$ProfileStateLoadedImpl> get copyWith => @@ -407,7 +392,7 @@ class _$ProfileStateLoadedImpl implements ProfileStateLoaded { TResult when( TResult Function() $default, { required TResult Function() loading, - required TResult Function(Profile profile) loaded, + required TResult Function(ProfileModel profile) loaded, required TResult Function(String errorMessage) error, }) { return loaded(profile); @@ -418,7 +403,7 @@ class _$ProfileStateLoadedImpl implements ProfileStateLoaded { TResult? whenOrNull( TResult? Function()? $default, { TResult? Function()? loading, - TResult? Function(Profile profile)? loaded, + TResult? Function(ProfileModel profile)? loaded, TResult? Function(String errorMessage)? error, }) { return loaded?.call(profile); @@ -429,7 +414,7 @@ class _$ProfileStateLoadedImpl implements ProfileStateLoaded { TResult maybeWhen( TResult Function()? $default, { TResult Function()? loading, - TResult Function(Profile profile)? loaded, + TResult Function(ProfileModel profile)? loaded, TResult Function(String errorMessage)? error, required TResult orElse(), }) { @@ -478,14 +463,11 @@ class _$ProfileStateLoadedImpl implements ProfileStateLoaded { } abstract class ProfileStateLoaded implements ProfileState { - const factory ProfileStateLoaded({required final Profile profile}) = + const factory ProfileStateLoaded({required final ProfileModel profile}) = _$ProfileStateLoadedImpl; - Profile get profile; - - /// Create a copy of ProfileState - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) + ProfileModel get profile; + @JsonKey(ignore: true) _$$ProfileStateLoadedImplCopyWith<_$ProfileStateLoadedImpl> get copyWith => throw _privateConstructorUsedError; } @@ -507,8 +489,6 @@ class __$$ProfileStateErrorImplCopyWithImpl<$Res> $Res Function(_$ProfileStateErrorImpl) _then) : super(_value, _then); - /// Create a copy of ProfileState - /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -548,9 +528,7 @@ class _$ProfileStateErrorImpl implements ProfileStateError { @override int get hashCode => Object.hash(runtimeType, errorMessage); - /// Create a copy of ProfileState - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) @override @pragma('vm:prefer-inline') _$$ProfileStateErrorImplCopyWith<_$ProfileStateErrorImpl> get copyWith => @@ -562,7 +540,7 @@ class _$ProfileStateErrorImpl implements ProfileStateError { TResult when( TResult Function() $default, { required TResult Function() loading, - required TResult Function(Profile profile) loaded, + required TResult Function(ProfileModel profile) loaded, required TResult Function(String errorMessage) error, }) { return error(errorMessage); @@ -573,7 +551,7 @@ class _$ProfileStateErrorImpl implements ProfileStateError { TResult? whenOrNull( TResult? Function()? $default, { TResult? Function()? loading, - TResult? Function(Profile profile)? loaded, + TResult? Function(ProfileModel profile)? loaded, TResult? Function(String errorMessage)? error, }) { return error?.call(errorMessage); @@ -584,7 +562,7 @@ class _$ProfileStateErrorImpl implements ProfileStateError { TResult maybeWhen( TResult Function()? $default, { TResult Function()? loading, - TResult Function(Profile profile)? loaded, + TResult Function(ProfileModel profile)? loaded, TResult Function(String errorMessage)? error, required TResult orElse(), }) { @@ -637,10 +615,7 @@ abstract class ProfileStateError implements ProfileState { _$ProfileStateErrorImpl; String get errorMessage; - - /// Create a copy of ProfileState - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) _$$ProfileStateErrorImplCopyWith<_$ProfileStateErrorImpl> get copyWith => throw _privateConstructorUsedError; } diff --git a/lib/features/profile/presentation/pages/profile_screen.dart b/lib/features/profile/presentation/pages/profile_screen.dart index d4cec48f..e9e37c56 100644 --- a/lib/features/profile/presentation/pages/profile_screen.dart +++ b/lib/features/profile/presentation/pages/profile_screen.dart @@ -1,46 +1,59 @@ import 'package:eatvio_app/core/app_export.dart'; import 'package:eatvio_app/features/feed/models/diets_pagination_model.dart'; +import 'package:eatvio_app/features/profile/models/profile_model.dart'; import 'package:eatvio_app/features/profile/presentation/bloc/profile_cubit/profile_cubit.dart'; import 'package:eatvio_app/features/profile/presentation/bloc/profile_cubit/profile_state.dart'; +import 'package:eatvio_app/features/profile/presentation/widgets/circumference_chart_widget.dart'; +import 'package:eatvio_app/features/profile/presentation/widgets/imt_chart_widget.dart'; +import 'package:eatvio_app/features/profile/presentation/widgets/weight_chart_widget.dart'; import 'package:eatvio_app/locator_service.dart'; import 'package:flutter/material.dart'; -class ProfileScreen extends StatelessWidget { - final Author author; +class ProfileScreen extends StatefulWidget { + final Author? author; - const ProfileScreen({super.key, required this.author}); + const ProfileScreen({super.key, this.author}); + + @override + State createState() => _ProfileScreenState(); +} + +class _ProfileScreenState extends State { + List chartData = []; + List chartPoints = []; @override Widget build(BuildContext context) { return BlocProvider( - create: (BuildContext context) => sl()..getProfileBySlug(author.authorSlug), + create: (BuildContext context) { + if (widget.author == null) + return sl()..getMyProfile(); + else + return sl()..getProfileBySlug(widget.author!.authorSlug); + }, child: BlocBuilder( builder: (BuildContext context, ProfileState state) { if (state is ProfileStateLoaded) { + chartData = state.profile.circumferences; + chartPoints = state.profile.chartPoints; return Scaffold( appBar: AppBar( - centerTitle: true, - title: Text( - state.profile.user.name, - style: TextStyle( - color: Colors.black, - fontSize: 24, - fontWeight: FontWeight.w400, - height: 1, - ), - ), + toolbarHeight: 0, ), body: SingleChildScrollView( - padding: EdgeInsets.all(16), child: Column( + crossAxisAlignment: CrossAxisAlignment.start, children: [ - Center( + Padding( + padding: const EdgeInsets.only(left: 16, bottom: 32), child: CircleAvatar( - maxRadius: 128, - minRadius: 128, + radius: 32, backgroundImage: NetworkImage(state.profile.user.profilePhotoUrl), ), ), + CircumferenceChartWidget(chartData: chartData), + WeightChartWidget(chartPoints: chartPoints), + ImtChartWidget(chartPoints: chartPoints), ], ), ), diff --git a/lib/features/profile/presentation/widgets/circumference_chart_widget.dart b/lib/features/profile/presentation/widgets/circumference_chart_widget.dart new file mode 100644 index 00000000..a4a6af7a --- /dev/null +++ b/lib/features/profile/presentation/widgets/circumference_chart_widget.dart @@ -0,0 +1,107 @@ +import 'package:eatvio_app/features/profile/models/profile_model.dart'; +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_charts/charts.dart'; +import 'package:intl/intl.dart'; + +class CircumferenceChartWidget extends StatelessWidget { + final List chartData; + + const CircumferenceChartWidget({ + super.key, + required this.chartData, + }); + + @override + Widget build(BuildContext context) { + return SfCartesianChart( + margin: EdgeInsets.zero, + enableAxisAnimation: true, + enableSideBySideSeriesPlacement: true, + legend: const Legend( + isVisible: true, + opacity: 0.7, + position: LegendPosition.bottom, + ), + plotAreaBorderWidth: 0, + trackballBehavior: TrackballBehavior( + enable: true, + activationMode: ActivationMode.singleTap, + ), + primaryXAxis: DateTimeAxis( + dateFormat: DateFormat.MMMd('ru'), + axisLine: AxisLine( + width: 1, + ), + ), + primaryYAxis: NumericAxis( + labelFormat: '{value} см', + axisLine: AxisLine( + width: 1, + ), + majorTickLines: MajorTickLines(size: 0), + ), + series: _getSplineSeries(), + tooltipBehavior: TooltipBehavior(enable: true), + ); + } + + List> _getSplineSeries() { + final Color seriesColor1 = Colors.red; + final Color seriesColor2 = Colors.blue; + final Color seriesColor3 = Colors.green; + + return >[ + SplineSeries( + markerSettings: MarkerSettings( + isVisible: true, + color: seriesColor1, + height: 12, + width: 12, + ), + dataLabelSettings: DataLabelSettings( + labelAlignment: ChartDataLabelAlignment.top, + isVisible: true, + ), + dataSource: chartData, + color: seriesColor1, + name: 'Грудь', + xValueMapper: (Circumference value, int index) => value.createdAt, + yValueMapper: (Circumference value, int index) => value.chestCircumference, + ), + SplineSeries( + markerSettings: MarkerSettings( + isVisible: true, + color: seriesColor2, + height: 12, + width: 12, + ), + dataLabelSettings: DataLabelSettings( + labelAlignment: ChartDataLabelAlignment.top, + isVisible: true, + ), + dataSource: chartData, + color: seriesColor2, + name: 'Талия', + xValueMapper: (Circumference value, int index) => value.createdAt, + yValueMapper: (Circumference value, int index) => value.waistCircumference, + ), + SplineSeries( + markerSettings: MarkerSettings( + isVisible: true, + color: seriesColor3, + height: 12, + width: 12, + ), + dataLabelSettings: DataLabelSettings( + labelAlignment: ChartDataLabelAlignment.top, + isVisible: true, + ), + dataSource: chartData, + color: seriesColor3, + name: 'Бёдра', + xValueMapper: (Circumference value, int index) => value.createdAt, + yValueMapper: (Circumference value, int index) => value.hipCircumference, + ), + ]; + } +} diff --git a/lib/features/profile/presentation/widgets/imt_chart_widget.dart b/lib/features/profile/presentation/widgets/imt_chart_widget.dart new file mode 100644 index 00000000..275a5810 --- /dev/null +++ b/lib/features/profile/presentation/widgets/imt_chart_widget.dart @@ -0,0 +1,69 @@ +import 'package:eatvio_app/features/profile/models/profile_model.dart' as ProfileModel; +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_charts/charts.dart'; +import 'package:intl/intl.dart'; + +class ImtChartWidget extends StatelessWidget { + final List chartPoints; + + const ImtChartWidget({ + super.key, + required this.chartPoints, + }); + + @override + Widget build(BuildContext context) { + return SfCartesianChart( + margin: EdgeInsets.zero, + enableAxisAnimation: true, + enableSideBySideSeriesPlacement: true, + legend: const Legend( + isVisible: true, + opacity: 0.7, + position: LegendPosition.bottom, + ), + plotAreaBorderWidth: 0, + trackballBehavior: TrackballBehavior( + enable: true, + activationMode: ActivationMode.singleTap, + ), + primaryXAxis: DateTimeAxis( + dateFormat: DateFormat.MMMd('ru'), + axisLine: AxisLine( + width: 1, + ), + ), + primaryYAxis: NumericAxis( + labelFormat: '{value} кг', + axisLine: AxisLine( + width: 1, + ), + majorTickLines: MajorTickLines(size: 0), + ), + series: _getSplineSeries(), + tooltipBehavior: TooltipBehavior(enable: true), + ); + } + + List> _getSplineSeries() { + return >[ + SplineSeries( + markerSettings: MarkerSettings( + isVisible: true, + color: Colors.blue, + height: 12, + width: 12, + ), + dataLabelSettings: DataLabelSettings( + labelAlignment: ChartDataLabelAlignment.top, + isVisible: true, + ), + dataSource: chartPoints, + color: Colors.blue, + name: 'ИМТ', + xValueMapper: (ProfileModel.ChartPoint value, int index) => value.createdAt, + yValueMapper: (ProfileModel.ChartPoint value, int index) => double.parse(value.bmi), + ), + ]; + } +} diff --git a/lib/features/profile/presentation/widgets/weight_chart_widget.dart b/lib/features/profile/presentation/widgets/weight_chart_widget.dart new file mode 100644 index 00000000..eabad3ec --- /dev/null +++ b/lib/features/profile/presentation/widgets/weight_chart_widget.dart @@ -0,0 +1,69 @@ +import 'package:eatvio_app/features/profile/models/profile_model.dart' as ProfileModel; +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_charts/charts.dart'; +import 'package:intl/intl.dart'; + +class WeightChartWidget extends StatelessWidget { + final List chartPoints; + + const WeightChartWidget({ + super.key, + required this.chartPoints, + }); + + @override + Widget build(BuildContext context) { + return SfCartesianChart( + margin: EdgeInsets.zero, + enableAxisAnimation: true, + enableSideBySideSeriesPlacement: true, + legend: const Legend( + isVisible: true, + opacity: 0.7, + position: LegendPosition.bottom, + ), + plotAreaBorderWidth: 0, + trackballBehavior: TrackballBehavior( + enable: true, + activationMode: ActivationMode.singleTap, + ), + primaryXAxis: DateTimeAxis( + dateFormat: DateFormat.MMMd('ru'), + axisLine: AxisLine( + width: 1, + ), + ), + primaryYAxis: NumericAxis( + labelFormat: '{value} кг', + axisLine: AxisLine( + width: 1, + ), + majorTickLines: MajorTickLines(size: 0), + ), + series: _getSplineSeries(), + tooltipBehavior: TooltipBehavior(enable: true), + ); + } + + List> _getSplineSeries() { + return >[ + SplineSeries( + markerSettings: MarkerSettings( + isVisible: true, + color: Colors.blue, + height: 12, + width: 12, + ), + dataLabelSettings: DataLabelSettings( + labelAlignment: ChartDataLabelAlignment.top, + isVisible: true, + ), + dataSource: chartPoints, + color: Colors.blue, + name: 'Вес', + xValueMapper: (ProfileModel.ChartPoint value, int index) => value.createdAt, + yValueMapper: (ProfileModel.ChartPoint value, int index) => value.weight, + ), + ]; + } +} diff --git a/lib/features/profile/repositories/profile_repository.dart b/lib/features/profile/repositories/profile_repository.dart index af15d704..e859c8d6 100644 --- a/lib/features/profile/repositories/profile_repository.dart +++ b/lib/features/profile/repositories/profile_repository.dart @@ -6,11 +6,51 @@ class ProfileRepository { ProfileRepository({required this.profileService}); - Future getProfileBySlug(String slug) async { + Future getProfileBySlug(String slug) async { try { return await profileService.getProfileBySlug(slug: slug); } catch (e) { rethrow; } } + + Future getMyProfile() async { + try { + return await profileService.getMyProfile(); + } catch (e) { + rethrow; + } + } + + Future addCircumference({ + required int chestCircumference, + required int waistCircumference, + required int hipCircumference, + }) async { + try { + return (await profileService.addCircumference( + chestCircumference: chestCircumference, + waistCircumference: waistCircumference, + hipCircumference: hipCircumference, + )) + .values + .first; + } catch (e) { + rethrow; + } + } + + Future addWeight({ + required int weight, + }) async { + try { + return (await profileService.addWeight( + weight: weight, + )) + .values + .first; + } catch (e) { + rethrow; + } + } } diff --git a/lib/features/profile/services/profile_service.dart b/lib/features/profile/services/profile_service.dart index e9863ca2..9966a82d 100644 --- a/lib/features/profile/services/profile_service.dart +++ b/lib/features/profile/services/profile_service.dart @@ -9,7 +9,22 @@ abstract class ProfileService { factory ProfileService(Dio dio, {String baseUrl}) = _ProfileService; @GET('/api/profile/show/{slug}') - Future getProfileBySlug({ + Future getProfileBySlug({ @Path() required String slug, }); + + @GET('/api/profile/index') + Future getMyProfile(); + + @POST('/api/profile/addCircumference') + Future> addCircumference({ + @Part(name: 'chest_circumference') required int chestCircumference, + @Part(name: 'waist_circumference') required int waistCircumference, + @Part(name: 'hip_circumference') required int hipCircumference, + }); + + @POST('/api/profile/addWeight') + Future> addWeight({ + @Part() required int weight, + }); } diff --git a/lib/features/profile/services/profile_service.g.dart b/lib/features/profile/services/profile_service.g.dart index 79ebdb24..96b65b4d 100644 --- a/lib/features/profile/services/profile_service.g.dart +++ b/lib/features/profile/services/profile_service.g.dart @@ -22,12 +22,12 @@ class _ProfileService implements ProfileService { final ParseErrorLogger? errorLogger; @override - Future getProfileBySlug({required String slug}) async { + Future getProfileBySlug({required String slug}) async { final _extra = {}; final queryParameters = {}; final _headers = {}; const Map? _data = null; - final _options = _setStreamType(Options( + final _options = _setStreamType(Options( method: 'GET', headers: _headers, extra: _extra, @@ -44,9 +44,130 @@ class _ProfileService implements ProfileService { baseUrl, ))); final _result = await _dio.fetch>(_options); - late Profile _value; + late ProfileModel _value; try { - _value = Profile.fromJson(_result.data!); + _value = ProfileModel.fromJson(_result.data!); + } on Object catch (e, s) { + errorLogger?.logError(e, s, _options); + rethrow; + } + return _value; + } + + @override + Future getMyProfile() async { + final _extra = {}; + final queryParameters = {}; + final _headers = {}; + const Map? _data = null; + final _options = _setStreamType(Options( + method: 'GET', + headers: _headers, + extra: _extra, + ) + .compose( + _dio.options, + '/api/profile/index', + queryParameters: queryParameters, + data: _data, + ) + .copyWith( + baseUrl: _combineBaseUrls( + _dio.options.baseUrl, + baseUrl, + ))); + final _result = await _dio.fetch>(_options); + late ProfileModel _value; + try { + _value = ProfileModel.fromJson(_result.data!); + } on Object catch (e, s) { + errorLogger?.logError(e, s, _options); + rethrow; + } + return _value; + } + + @override + Future> addCircumference({ + required int chestCircumference, + required int waistCircumference, + required int hipCircumference, + }) async { + final _extra = {}; + final queryParameters = {}; + final _headers = {}; + final _data = FormData(); + _data.fields.add(MapEntry( + 'chest_circumference', + chestCircumference.toString(), + )); + _data.fields.add(MapEntry( + 'waist_circumference', + waistCircumference.toString(), + )); + _data.fields.add(MapEntry( + 'hip_circumference', + hipCircumference.toString(), + )); + final _options = _setStreamType>(Options( + method: 'POST', + headers: _headers, + extra: _extra, + ) + .compose( + _dio.options, + '/api/profile/addCircumference', + queryParameters: queryParameters, + data: _data, + ) + .copyWith( + baseUrl: _combineBaseUrls( + _dio.options.baseUrl, + baseUrl, + ))); + final _result = await _dio.fetch>(_options); + late Map _value; + try { + _value = _result.data!.map((k, dynamic v) => + MapEntry(k, Circumference.fromJson(v as Map))); + } on Object catch (e, s) { + errorLogger?.logError(e, s, _options); + rethrow; + } + return _value; + } + + @override + Future> addWeight({required int weight}) async { + final _extra = {}; + final queryParameters = {}; + final _headers = {}; + final _data = FormData(); + _data.fields.add(MapEntry( + 'weight', + weight.toString(), + )); + final _options = _setStreamType>(Options( + method: 'POST', + headers: _headers, + extra: _extra, + ) + .compose( + _dio.options, + '/api/profile/addWeight', + queryParameters: queryParameters, + data: _data, + ) + .copyWith( + baseUrl: _combineBaseUrls( + _dio.options.baseUrl, + baseUrl, + ))); + final _result = await _dio.fetch>(_options); + late Map _value; + try { + _value = _result.data!.map((k, dynamic v) => + MapEntry(k, ChartPoint.fromJson(v as Map))); } on Object catch (e, s) { errorLogger?.logError(e, s, _options); rethrow; diff --git a/lib/features/recipes/models/ingredient.freezed.dart b/lib/features/recipes/models/ingredient.freezed.dart index 2bf96fb3..63f3facb 100644 --- a/lib/features/recipes/models/ingredient.freezed.dart +++ b/lib/features/recipes/models/ingredient.freezed.dart @@ -24,12 +24,8 @@ mixin _$Ingredient { String get unit => throw _privateConstructorUsedError; String get portion => throw _privateConstructorUsedError; - /// Serializes this Ingredient to a JSON map. Map toJson() => throw _privateConstructorUsedError; - - /// Create a copy of Ingredient - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) $IngredientCopyWith get copyWith => throw _privateConstructorUsedError; } @@ -53,8 +49,6 @@ class _$IngredientCopyWithImpl<$Res, $Val extends Ingredient> // ignore: unused_field final $Res Function($Val) _then; - /// Create a copy of Ingredient - /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -98,8 +92,6 @@ class __$$IngredientImplCopyWithImpl<$Res> _$IngredientImpl _value, $Res Function(_$IngredientImpl) _then) : super(_value, _then); - /// Create a copy of Ingredient - /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -155,13 +147,11 @@ class _$IngredientImpl implements _Ingredient { (identical(other.portion, portion) || other.portion == portion)); } - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) @override int get hashCode => Object.hash(runtimeType, name, unit, portion); - /// Create a copy of Ingredient - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) @override @pragma('vm:prefer-inline') _$$IngredientImplCopyWith<_$IngredientImpl> get copyWith => @@ -190,11 +180,8 @@ abstract class _Ingredient implements Ingredient { String get unit; @override String get portion; - - /// Create a copy of Ingredient - /// with the given fields replaced by the non-null parameter values. @override - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) _$$IngredientImplCopyWith<_$IngredientImpl> get copyWith => throw _privateConstructorUsedError; } diff --git a/lib/features/recipes/models/recipe_model.freezed.dart b/lib/features/recipes/models/recipe_model.freezed.dart index 691ac1f3..fb93e70a 100644 --- a/lib/features/recipes/models/recipe_model.freezed.dart +++ b/lib/features/recipes/models/recipe_model.freezed.dart @@ -30,12 +30,8 @@ mixin _$RecipeModel { String? get image => throw _privateConstructorUsedError; int? get cooking_time => throw _privateConstructorUsedError; - /// Serializes this RecipeModel to a JSON map. Map toJson() => throw _privateConstructorUsedError; - - /// Create a copy of RecipeModel - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) $RecipeModelCopyWith get copyWith => throw _privateConstructorUsedError; } @@ -68,8 +64,6 @@ class _$RecipeModelCopyWithImpl<$Res, $Val extends RecipeModel> // ignore: unused_field final $Res Function($Val) _then; - /// Create a copy of RecipeModel - /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -152,8 +146,6 @@ class __$$RecipeModelImplCopyWithImpl<$Res> _$RecipeModelImpl _value, $Res Function(_$RecipeModelImpl) _then) : super(_value, _then); - /// Create a copy of RecipeModel - /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -287,7 +279,7 @@ class _$RecipeModelImpl implements _RecipeModel { other.cooking_time == cooking_time)); } - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) @override int get hashCode => Object.hash( runtimeType, @@ -301,9 +293,7 @@ class _$RecipeModelImpl implements _RecipeModel { image, cooking_time); - /// Create a copy of RecipeModel - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) @override @pragma('vm:prefer-inline') _$$RecipeModelImplCopyWith<_$RecipeModelImpl> get copyWith => @@ -350,11 +340,8 @@ abstract class _RecipeModel implements RecipeModel { String? get image; @override int? get cooking_time; - - /// Create a copy of RecipeModel - /// with the given fields replaced by the non-null parameter values. @override - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) _$$RecipeModelImplCopyWith<_$RecipeModelImpl> get copyWith => throw _privateConstructorUsedError; } diff --git a/lib/features/recipes/models/step.freezed.dart b/lib/features/recipes/models/step.freezed.dart index 040dd5aa..c2014f4f 100644 --- a/lib/features/recipes/models/step.freezed.dart +++ b/lib/features/recipes/models/step.freezed.dart @@ -23,12 +23,8 @@ mixin _$Step { String? get image => throw _privateConstructorUsedError; String? get description => throw _privateConstructorUsedError; - /// Serializes this Step to a JSON map. Map toJson() => throw _privateConstructorUsedError; - - /// Create a copy of Step - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) $StepCopyWith get copyWith => throw _privateConstructorUsedError; } @@ -50,8 +46,6 @@ class _$StepCopyWithImpl<$Res, $Val extends Step> // ignore: unused_field final $Res Function($Val) _then; - /// Create a copy of Step - /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -88,8 +82,6 @@ class __$$StepImplCopyWithImpl<$Res> __$$StepImplCopyWithImpl(_$StepImpl _value, $Res Function(_$StepImpl) _then) : super(_value, _then); - /// Create a copy of Step - /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -137,13 +129,11 @@ class _$StepImpl implements _Step { other.description == description)); } - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) @override int get hashCode => Object.hash(runtimeType, image, description); - /// Create a copy of Step - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) @override @pragma('vm:prefer-inline') _$$StepImplCopyWith<_$StepImpl> get copyWith => @@ -167,11 +157,8 @@ abstract class _Step implements Step { String? get image; @override String? get description; - - /// Create a copy of Step - /// with the given fields replaced by the non-null parameter values. @override - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) _$$StepImplCopyWith<_$StepImpl> get copyWith => throw _privateConstructorUsedError; } diff --git a/lib/features/recipes/presentation/bloc/recipe_create_state.freezed.dart b/lib/features/recipes/presentation/bloc/recipe_create_state.freezed.dart index e15a1a52..9acea107 100644 --- a/lib/features/recipes/presentation/bloc/recipe_create_state.freezed.dart +++ b/lib/features/recipes/presentation/bloc/recipe_create_state.freezed.dart @@ -147,9 +147,6 @@ class _$RecipeCreateStateCopyWithImpl<$Res, $Val extends RecipeCreateState> final $Val _value; // ignore: unused_field final $Res Function($Val) _then; - - /// Create a copy of RecipeCreateState - /// with the given fields replaced by the non-null parameter values. } /// @nodoc @@ -166,9 +163,6 @@ class __$$RecipeCreateStateImplCopyWithImpl<$Res> __$$RecipeCreateStateImplCopyWithImpl(_$RecipeCreateStateImpl _value, $Res Function(_$RecipeCreateStateImpl) _then) : super(_value, _then); - - /// Create a copy of RecipeCreateState - /// with the given fields replaced by the non-null parameter values. } /// @nodoc @@ -349,9 +343,6 @@ class __$$RecipeCreateStateLoadingImplCopyWithImpl<$Res> _$RecipeCreateStateLoadingImpl _value, $Res Function(_$RecipeCreateStateLoadingImpl) _then) : super(_value, _then); - - /// Create a copy of RecipeCreateState - /// with the given fields replaced by the non-null parameter values. } /// @nodoc @@ -560,8 +551,6 @@ class __$$RecipeCreateStateLoadedImplCopyWithImpl<$Res> $Res Function(_$RecipeCreateStateLoadedImpl) _then) : super(_value, _then); - /// Create a copy of RecipeCreateState - /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -670,8 +659,6 @@ class __$$RecipeCreateStateLoadedImplCopyWithImpl<$Res> )); } - /// Create a copy of RecipeCreateState - /// with the given fields replaced by the non-null parameter values. @override @pragma('vm:prefer-inline') $RecipeModelCopyWith<$Res>? get recipe { @@ -684,8 +671,6 @@ class __$$RecipeCreateStateLoadedImplCopyWithImpl<$Res> }); } - /// Create a copy of RecipeCreateState - /// with the given fields replaced by the non-null parameter values. @override @pragma('vm:prefer-inline') $SelectionPopupModelCopyWith<$Res> get selectedType { @@ -694,8 +679,6 @@ class __$$RecipeCreateStateLoadedImplCopyWithImpl<$Res> }); } - /// Create a copy of RecipeCreateState - /// with the given fields replaced by the non-null parameter values. @override @pragma('vm:prefer-inline') $SelectionPopupModelCopyWith<$Res> get selectedCookingTime { @@ -705,8 +688,6 @@ class __$$RecipeCreateStateLoadedImplCopyWithImpl<$Res> }); } - /// Create a copy of RecipeCreateState - /// with the given fields replaced by the non-null parameter values. @override @pragma('vm:prefer-inline') $SelectionPopupModelCopyWith<$Res> get selectedStatus { @@ -906,9 +887,7 @@ class _$RecipeCreateStateLoadedImpl implements RecipeCreateStateLoaded { selectedStatus ]); - /// Create a copy of RecipeCreateState - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) @override @pragma('vm:prefer-inline') _$$RecipeCreateStateLoadedImplCopyWith<_$RecipeCreateStateLoadedImpl> @@ -1157,10 +1136,7 @@ abstract class RecipeCreateStateLoaded implements RecipeCreateState { SelectionPopupModel get selectedType; SelectionPopupModel get selectedCookingTime; SelectionPopupModel get selectedStatus; - - /// Create a copy of RecipeCreateState - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) _$$RecipeCreateStateLoadedImplCopyWith<_$RecipeCreateStateLoadedImpl> get copyWith => throw _privateConstructorUsedError; } @@ -1184,8 +1160,6 @@ class __$$RecipeCreateStateErrorImplCopyWithImpl<$Res> $Res Function(_$RecipeCreateStateErrorImpl) _then) : super(_value, _then); - /// Create a copy of RecipeCreateState - /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -1225,9 +1199,7 @@ class _$RecipeCreateStateErrorImpl implements RecipeCreateStateError { @override int get hashCode => Object.hash(runtimeType, errorMessage); - /// Create a copy of RecipeCreateState - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) @override @pragma('vm:prefer-inline') _$$RecipeCreateStateErrorImplCopyWith<_$RecipeCreateStateErrorImpl> @@ -1377,10 +1349,7 @@ abstract class RecipeCreateStateError implements RecipeCreateState { _$RecipeCreateStateErrorImpl; String get errorMessage; - - /// Create a copy of RecipeCreateState - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) _$$RecipeCreateStateErrorImplCopyWith<_$RecipeCreateStateErrorImpl> get copyWith => throw _privateConstructorUsedError; } diff --git a/lib/features/registration/models/location_model.freezed.dart b/lib/features/registration/models/location_model.freezed.dart index 95f81d60..f640ca2e 100644 --- a/lib/features/registration/models/location_model.freezed.dart +++ b/lib/features/registration/models/location_model.freezed.dart @@ -24,12 +24,8 @@ mixin _$LocationModel { @JsonKey(name: 'response_body') String get responseBody => throw _privateConstructorUsedError; - /// Serializes this LocationModel to a JSON map. Map toJson() => throw _privateConstructorUsedError; - - /// Create a copy of LocationModel - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) $LocationModelCopyWith get copyWith => throw _privateConstructorUsedError; } @@ -55,8 +51,6 @@ class _$LocationModelCopyWithImpl<$Res, $Val extends LocationModel> // ignore: unused_field final $Res Function($Val) _then; - /// Create a copy of LocationModel - /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -97,8 +91,6 @@ class __$$LocationModelImplCopyWithImpl<$Res> _$LocationModelImpl _value, $Res Function(_$LocationModelImpl) _then) : super(_value, _then); - /// Create a copy of LocationModel - /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -157,14 +149,12 @@ class _$LocationModelImpl implements _LocationModel { other.responseBody == responseBody)); } - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) @override int get hashCode => Object.hash(runtimeType, const DeepCollectionEquality().hash(_locations), responseBody); - /// Create a copy of LocationModel - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) @override @pragma('vm:prefer-inline') _$$LocationModelImplCopyWith<_$LocationModelImpl> get copyWith => @@ -192,11 +182,8 @@ abstract class _LocationModel implements LocationModel { @override @JsonKey(name: 'response_body') String get responseBody; - - /// Create a copy of LocationModel - /// with the given fields replaced by the non-null parameter values. @override - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) _$$LocationModelImplCopyWith<_$LocationModelImpl> get copyWith => throw _privateConstructorUsedError; } diff --git a/lib/features/registration/presentation/bloc/registration_cubit/registration_state.freezed.dart b/lib/features/registration/presentation/bloc/registration_cubit/registration_state.freezed.dart index ae0a9706..dcb49236 100644 --- a/lib/features/registration/presentation/bloc/registration_cubit/registration_state.freezed.dart +++ b/lib/features/registration/presentation/bloc/registration_cubit/registration_state.freezed.dart @@ -18,9 +18,7 @@ final _privateConstructorUsedError = UnsupportedError( mixin _$RegistrationState { UserRegistrationSheet get sheet => throw _privateConstructorUsedError; - /// Create a copy of RegistrationState - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) $RegistrationStateCopyWith get copyWith => throw _privateConstructorUsedError; } @@ -46,8 +44,6 @@ class _$RegistrationStateCopyWithImpl<$Res, $Val extends RegistrationState> // ignore: unused_field final $Res Function($Val) _then; - /// Create a copy of RegistrationState - /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -61,8 +57,6 @@ class _$RegistrationStateCopyWithImpl<$Res, $Val extends RegistrationState> ) as $Val); } - /// Create a copy of RegistrationState - /// with the given fields replaced by the non-null parameter values. @override @pragma('vm:prefer-inline') $UserRegistrationSheetCopyWith<$Res> get sheet { @@ -94,8 +88,6 @@ class __$$RegistrationStateImplCopyWithImpl<$Res> $Res Function(_$RegistrationStateImpl) _then) : super(_value, _then); - /// Create a copy of RegistrationState - /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -134,9 +126,7 @@ class _$RegistrationStateImpl implements _RegistrationState { @override int get hashCode => Object.hash(runtimeType, sheet); - /// Create a copy of RegistrationState - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) @override @pragma('vm:prefer-inline') _$$RegistrationStateImplCopyWith<_$RegistrationStateImpl> get copyWith => @@ -150,11 +140,8 @@ abstract class _RegistrationState implements RegistrationState { @override UserRegistrationSheet get sheet; - - /// Create a copy of RegistrationState - /// with the given fields replaced by the non-null parameter values. @override - @JsonKey(includeFromJson: false, includeToJson: false) + @JsonKey(ignore: true) _$$RegistrationStateImplCopyWith<_$RegistrationStateImpl> get copyWith => throw _privateConstructorUsedError; } diff --git a/lib/locator_service.dart b/lib/locator_service.dart index f0a28808..a73d21f1 100644 --- a/lib/locator_service.dart +++ b/lib/locator_service.dart @@ -3,6 +3,7 @@ import 'package:eatvio_app/core/constants/constants.dart'; import 'package:eatvio_app/core/initialization_cubit/initialization_cubit.dart'; import 'package:eatvio_app/features/bottom_navigation_bar/presentation/bloc/new_messages_cubit/new_messages_cubit.dart'; import 'package:eatvio_app/features/bottom_navigation_bar/presentation/bloc/notifications_cubit/notifications_cubit.dart'; +import 'package:eatvio_app/features/bottom_navigation_bar/presentation/bloc/profile_avatar_cubit/profile_avatar_cubit.dart'; import 'package:eatvio_app/features/calendar/presentation/bloc/calendar_cubit.dart'; import 'package:eatvio_app/features/calendar/repositories/calendar_repository.dart'; import 'package:eatvio_app/features/calendar/services/calendar_service.dart'; @@ -45,6 +46,7 @@ Future init() async { sl.registerFactory(() => DiaryBloc(diaryRepository: sl())); sl.registerFactory(() => CalendarCubit(calendarRepository: sl())); sl.registerFactory(() => ProfileCubit(profileRepository: sl())); + sl.registerFactory(() => ProfileAvatarCubit(profileRepository: sl())); sl.registerFactory(() => RecipeCreateCubit(recipeRepository: sl())); sl.registerFactory(() => DietsCubit(feedRepository: sl())); sl.registerFactory(() => CommentsCubit(feedRepository: sl())); diff --git a/lib/main.dart b/lib/main.dart index 34f37ccf..a0867795 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -3,6 +3,7 @@ import 'package:eatvio_app/core/initialization_cubit/initialization_cubit.dart'; import 'package:eatvio_app/core/initialization_cubit/initialization_state.dart'; import 'package:eatvio_app/features/bottom_navigation_bar/presentation/bloc/new_messages_cubit/new_messages_cubit.dart'; import 'package:eatvio_app/features/bottom_navigation_bar/presentation/bloc/notifications_cubit/notifications_cubit.dart'; +import 'package:eatvio_app/features/bottom_navigation_bar/presentation/bloc/profile_avatar_cubit/profile_avatar_cubit.dart'; import 'package:eatvio_app/features/calendar/presentation/bloc/calendar_cubit.dart'; import 'package:eatvio_app/features/chat/presentation/bloc/chat_select_cubit/chat_select_cubit.dart'; import 'package:eatvio_app/features/diary/presentation/bloc/diary_bloc.dart'; @@ -17,11 +18,8 @@ import 'package:eatvio_app/presentation/profile/my_profile_screen/models/my_prof import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_localizations/flutter_localizations.dart'; -import 'package:hive_flutter/hive_flutter.dart'; import 'package:intl/date_symbol_data_local.dart'; import 'package:keyboard_dismisser/keyboard_dismisser.dart'; -import 'package:path_provider/path_provider.dart'; - import 'core/app_export.dart'; var globalMessengerKey = GlobalKey(); @@ -29,15 +27,11 @@ var globalMessengerKey = GlobalKey(); void main() async { WidgetsFlutterBinding.ensureInitialized(); await di.init(); - final appDocumentDir = await getApplicationDocumentsDirectory(); - final path = appDocumentDir.path; - await Hive.initFlutter(path); SystemChrome.setPreferredOrientations([ DeviceOrientation.landscapeLeft, DeviceOrientation.landscapeRight, DeviceOrientation.portraitUp, ]); - await PrefUtils().init(); initializeDateFormatting().then((_) => runApp(MyApp())); } @@ -49,7 +43,7 @@ class MyApp extends StatelessWidget { BlocProvider(create: (context) => sl()), BlocProvider(create: (context) => sl()), BlocProvider(create: (context) => sl()), - BlocProvider(create: (context) => ThemeBloc(ThemeState(themeType: PrefUtils().getThemeData()))), + BlocProvider(create: (context) => sl()..getMyProfile()), BlocProvider(create: (context) => sl()..loadFeedBlogPostList()), BlocProvider(create: (context) => sl()..loadRecipesList()), BlocProvider(create: (context) => sl()..loadDiets()), @@ -61,31 +55,27 @@ class MyApp extends StatelessWidget { ], child: BlocListener( listener: (BuildContext context, InitializationState state) {}, - child: BlocBuilder( - builder: (context, state) { - return KeyboardDismisser( - gestures: [ - GestureType.onTap, - GestureType.onPanUpdateDownDirection, - ], - child: MaterialApp.router( - theme: theme, - routerConfig: AppRouter.appRouter, - debugShowCheckedModeBanner: false, - localizationsDelegates: [ - AppLocalizationDelegate(), - GlobalMaterialLocalizations.delegate, - GlobalWidgetsLocalizations.delegate, - GlobalCupertinoLocalizations.delegate, - ], - supportedLocales: [ - Locale( - 'ru', - ), - ], + child: KeyboardDismisser( + gestures: [ + GestureType.onTap, + GestureType.onPanUpdateDownDirection, + ], + child: MaterialApp.router( + theme: theme, + routerConfig: AppRouter.appRouter, + debugShowCheckedModeBanner: false, + localizationsDelegates: [ + AppLocalizationDelegate(), + GlobalMaterialLocalizations.delegate, + GlobalWidgetsLocalizations.delegate, + GlobalCupertinoLocalizations.delegate, + ], + supportedLocales: [ + Locale( + 'ru', ), - ); - }, + ], + ), ), ), ); diff --git a/lib/presentation/auth/auth_screen/auth_screen.dart b/lib/presentation/auth/auth_screen/auth_screen.dart index bd662937..502eff15 100644 --- a/lib/presentation/auth/auth_screen/auth_screen.dart +++ b/lib/presentation/auth/auth_screen/auth_screen.dart @@ -6,7 +6,6 @@ import 'package:eatvio_app/widgets/app_bar/appbar_title_image.dart'; import 'package:eatvio_app/widgets/custom_text_form_field.dart'; import 'package:flutter/material.dart'; import 'package:go_router/go_router.dart'; -import 'package:hive/hive.dart'; import 'package:http/http.dart' as http; import 'package:url_launcher/url_launcher.dart'; import 'package:validators/validators.dart'; @@ -126,7 +125,7 @@ class _AuthScreenState extends State { height: 48, width: MediaQuery.of(context).size.width - 32, child: FloatingActionButton.extended( - heroTag: 'nextButtonRegistration', + heroTag: 'authButton', highlightElevation: 0, elevation: 0, focusElevation: 0, @@ -167,9 +166,7 @@ class _AuthScreenState extends State { print(response.statusCode); if (response.statusCode == 200) { var res = await jsonDecode(response.body); - final box = await Hive.openBox('token'); final token = res['token']; - box.put('token', token); await TokenStorage.saveTokenInStorage(token); GoRouter.of(context).go('/my-profile-screen'); } else { diff --git a/lib/presentation/diets/diet_create_screen/bloc/diet_create_bloc.dart b/lib/presentation/diets/diet_create_screen/bloc/diet_create_bloc.dart index 65ea65b9..db2f02a9 100644 --- a/lib/presentation/diets/diet_create_screen/bloc/diet_create_bloc.dart +++ b/lib/presentation/diets/diet_create_screen/bloc/diet_create_bloc.dart @@ -2,11 +2,11 @@ import 'dart:async'; import 'dart:convert'; import 'package:eatvio_app/app_router.dart'; +import 'package:eatvio_app/core/token_storage.dart'; import 'package:eatvio_app/presentation/diets/diet_create_screen/models/diet_create_model.dart'; import 'package:equatable/equatable.dart'; import 'package:flutter/material.dart'; import 'package:go_router/go_router.dart'; -import 'package:hive/hive.dart'; import 'package:http/http.dart' as http; import '/core/app_export.dart'; @@ -25,9 +25,7 @@ class DietCreateBloc extends Bloc { DietCreateInitialEvent event, Emitter emit, ) async { - final box = await Hive.openBox('token'); - final token = box.get('token'); - if (token == null) { + if (!await TokenStorage.haveTokenInStorage()) { AppRouter.navigatorKey.currentContext?.goNamed('authScreen'); } if (state is DietCreateLoadedState) { diff --git a/lib/presentation/diets/diet_edit_screen/bloc/diet_edit_bloc.dart b/lib/presentation/diets/diet_edit_screen/bloc/diet_edit_bloc.dart index 81e034a1..5f92e25b 100644 --- a/lib/presentation/diets/diet_edit_screen/bloc/diet_edit_bloc.dart +++ b/lib/presentation/diets/diet_edit_screen/bloc/diet_edit_bloc.dart @@ -2,11 +2,11 @@ import 'dart:async'; import 'dart:convert'; import 'package:eatvio_app/app_router.dart'; +import 'package:eatvio_app/core/token_storage.dart'; import 'package:eatvio_app/presentation/diets/diet_edit_screen/models/diet_edit_model.dart'; import 'package:equatable/equatable.dart'; import 'package:flutter/material.dart'; import 'package:go_router/go_router.dart'; -import 'package:hive/hive.dart'; import 'package:http/http.dart' as http; import '/core/app_export.dart'; @@ -26,16 +26,14 @@ class DietEditBloc extends Bloc { Emitter emit, ) async { try { - final box = await Hive.openBox('token'); - final token = box.get('token'); - if (token == null) { + if (!await TokenStorage.haveTokenInStorage()) { AppRouter.navigatorKey.currentContext?.goNamed('authScreen'); } final String? dietID = state.dietModelObj?.dietID; final response = await http.get( Uri.parse(baseUrl + '/api/diets/show/$dietID'), headers: { - 'Authorization': 'Bearer $token', + 'Authorization': 'Bearer ${await TokenStorage.getTokenFromStorage()}', }, ); if (response.statusCode == 200) { diff --git a/lib/presentation/diets/diet_select_screen/bloc/diet_select_bloc.dart b/lib/presentation/diets/diet_select_screen/bloc/diet_select_bloc.dart index 56dabcf2..6910f250 100644 --- a/lib/presentation/diets/diet_select_screen/bloc/diet_select_bloc.dart +++ b/lib/presentation/diets/diet_select_screen/bloc/diet_select_bloc.dart @@ -3,11 +3,11 @@ import 'dart:async'; import 'dart:convert'; import 'package:eatvio_app/app_router.dart'; +import 'package:eatvio_app/core/token_storage.dart'; import 'package:eatvio_app/presentation/diets/diet_select_screen/models/diet_select_model.dart'; import 'package:equatable/equatable.dart'; import 'package:flutter/material.dart'; import 'package:go_router/go_router.dart'; -import 'package:hive/hive.dart'; import 'package:http/http.dart' as http; import 'package:image_picker/image_picker.dart'; @@ -27,15 +27,13 @@ class DietSelectBloc extends Bloc { Emitter emit, ) async { try { - final box = await Hive.openBox('token'); - final token = box.get('token'); - if (token == null) { + if (!await TokenStorage.haveTokenInStorage()) { AppRouter.navigatorKey.currentContext?.goNamed('authScreen'); } final response = await http.get( Uri.parse(baseUrl + '/api/diets/index'), headers: { - 'Authorization': 'Bearer $token', + 'Authorization': 'Bearer ${await TokenStorage.getTokenFromStorage()}', }, ); print('Got response'); diff --git a/lib/presentation/diets/diet_show_screen/bloc/diet_show_bloc.dart b/lib/presentation/diets/diet_show_screen/bloc/diet_show_bloc.dart index 3d0551a2..b680d054 100644 --- a/lib/presentation/diets/diet_show_screen/bloc/diet_show_bloc.dart +++ b/lib/presentation/diets/diet_show_screen/bloc/diet_show_bloc.dart @@ -2,11 +2,11 @@ import 'dart:async'; import 'dart:convert'; import 'package:eatvio_app/app_router.dart'; +import 'package:eatvio_app/core/token_storage.dart'; import 'package:eatvio_app/presentation/diets/diet_show_screen/models/diet_show_model.dart'; import 'package:equatable/equatable.dart'; import 'package:flutter/material.dart'; import 'package:go_router/go_router.dart'; -import 'package:hive/hive.dart'; import 'package:http/http.dart' as http; import '/core/app_export.dart'; @@ -26,16 +26,14 @@ class DietBloc extends Bloc { Emitter emit, ) async { try { - final box = await Hive.openBox('token'); - final token = box.get('token'); - if (token == null) { + if (!await TokenStorage.haveTokenInStorage()) { AppRouter.navigatorKey.currentContext?.goNamed('authScreen'); } final String? dietID = state.dietModelObj?.dietID; final response = await http.get( Uri.parse(baseUrl + '/api/diets/show/$dietID'), headers: { - 'Authorization': 'Bearer $token', + 'Authorization': 'Bearer ${await TokenStorage.getTokenFromStorage()}', }, ); if (response.statusCode == 200) { @@ -62,16 +60,14 @@ class DietBloc extends Bloc { } FutureOr _deleteEntry(DeleteEntry event, Emitter emit) async { - final box = await Hive.openBox('token'); - final token = box.get('token'); - if (token == null) { + if (!await TokenStorage.haveTokenInStorage()) { AppRouter.navigatorKey.currentContext?.goNamed('authScreen'); } final int id = event.id; final response = await http.post( Uri.parse(baseUrl + '/api/diets/delete/$id'), headers: { - 'Authorization': 'Bearer $token', + 'Authorization': 'Bearer ${await TokenStorage.getTokenFromStorage()}', }, ); if (response.statusCode == 200) { diff --git a/lib/presentation/feed/blog_post_create_screen/bloc/blog_post_create_bloc.dart b/lib/presentation/feed/blog_post_create_screen/bloc/blog_post_create_bloc.dart index 798b771c..0cfd4cc4 100644 --- a/lib/presentation/feed/blog_post_create_screen/bloc/blog_post_create_bloc.dart +++ b/lib/presentation/feed/blog_post_create_screen/bloc/blog_post_create_bloc.dart @@ -2,12 +2,12 @@ import 'dart:async'; import 'package:dio/dio.dart'; import 'package:eatvio_app/app_router.dart'; +import 'package:eatvio_app/core/token_storage.dart'; import 'package:eatvio_app/locator_service.dart'; import 'package:eatvio_app/presentation/feed/blog_post_create_screen/models/blog_post_create_model.dart'; import 'package:equatable/equatable.dart'; import 'package:flutter/material.dart'; import 'package:go_router/go_router.dart'; -import 'package:hive/hive.dart'; import 'package:image_picker/image_picker.dart'; import '/core/app_export.dart'; @@ -27,9 +27,7 @@ class BlogPostCreateBloc extends Bloc BlogPostCreateInitialEvent event, Emitter emit, ) async { - final box = await Hive.openBox('token'); - final token = box.get('token'); - if (token == null) { + if (!await TokenStorage.haveTokenInStorage()) { AppRouter.navigatorKey.currentContext?.goNamed('authScreen'); } if (state is BlogPostCreateLoadedState) { @@ -46,7 +44,7 @@ class BlogPostCreateBloc extends Bloc } else { emit( BlogPostCreateLoadedState( - token: token, + token: await TokenStorage.getTokenFromStorage(), title: TextEditingController(), description: TextEditingController(), youtubeURL: TextEditingController(), diff --git a/lib/presentation/feed/blog_post_edit_screen/bloc/blog_post_edit_bloc.dart b/lib/presentation/feed/blog_post_edit_screen/bloc/blog_post_edit_bloc.dart index c9c6bf9c..813a66d0 100644 --- a/lib/presentation/feed/blog_post_edit_screen/bloc/blog_post_edit_bloc.dart +++ b/lib/presentation/feed/blog_post_edit_screen/bloc/blog_post_edit_bloc.dart @@ -2,11 +2,11 @@ import 'dart:async'; import 'dart:convert'; import 'package:eatvio_app/app_router.dart'; +import 'package:eatvio_app/core/token_storage.dart'; import 'package:eatvio_app/presentation/feed/blog_post_edit_screen/models/blog_post_edit_model.dart'; import 'package:equatable/equatable.dart'; import 'package:flutter/material.dart'; import 'package:go_router/go_router.dart'; -import 'package:hive/hive.dart'; import 'package:http/http.dart' as http; import '/core/app_export.dart'; @@ -26,16 +26,14 @@ class BlogPostEditBloc extends Bloc { Emitter emit, ) async { try { - final box = await Hive.openBox('token'); - final token = box.get('token'); - if (token == null) { + if (!await TokenStorage.haveTokenInStorage()) { AppRouter.navigatorKey.currentContext?.goNamed('authScreen'); } final String? blog_postID = state.blog_postModelObj?.blog_postID; final response = await http.get( Uri.parse(baseUrl + '/api/blogPosts/show/$blog_postID'), headers: { - 'Authorization': 'Bearer $token', + 'Authorization': 'Bearer ${await TokenStorage.getTokenFromStorage()}', }, ); if (response.statusCode == 200) { diff --git a/lib/presentation/glossary/glossary_screen/bloc/glossary_screen_bloc.dart b/lib/presentation/glossary/glossary_screen/bloc/glossary_screen_bloc.dart index 3bae9e80..c45d5569 100644 --- a/lib/presentation/glossary/glossary_screen/bloc/glossary_screen_bloc.dart +++ b/lib/presentation/glossary/glossary_screen/bloc/glossary_screen_bloc.dart @@ -2,11 +2,11 @@ import 'dart:async'; import 'dart:convert'; import 'package:eatvio_app/app_router.dart'; +import 'package:eatvio_app/core/token_storage.dart'; import 'package:eatvio_app/presentation/glossary/glossary_screen/models/glossary_screen_model.dart'; import 'package:equatable/equatable.dart'; import 'package:flutter/material.dart'; import 'package:go_router/go_router.dart'; -import 'package:hive/hive.dart'; import 'package:http/http.dart' as http; import '/core/app_export.dart'; @@ -26,15 +26,13 @@ class GlossaryBloc extends Bloc { Emitter emit, ) async { try { - final box = await Hive.openBox('token'); - final token = box.get('token'); - if (token == null) { + if (!await TokenStorage.haveTokenInStorage()) { AppRouter.navigatorKey.currentContext?.goNamed('authScreen'); } final responseProductGroups = await http.get( Uri.parse(baseUrl + '/api/glossaries/group/index'), headers: { - 'Authorization': 'Bearer $token', + 'Authorization': 'Bearer ${await TokenStorage.getTokenFromStorage()}', }, ); if (responseProductGroups.statusCode == 200) { @@ -54,12 +52,12 @@ class GlossaryBloc extends Bloc { List productGroupsModel = _fillProductGroups(dataProductGroups); emit( GlossaryLoadedState( - token: token, + token: await TokenStorage.getTokenFromStorage(), productGroups: productGroupsModel, productList: [], ), ); - await _getProductListById(token, emit, productGroupsModel[0].id); + await _getProductListById(await TokenStorage.getTokenFromStorage(), emit, productGroupsModel[0].id); } } else { // Один или несколько ключевых полей отсутствуют, обрабатываем ошибку diff --git a/lib/presentation/plans/plan_create_screen/bloc/plan_create_bloc.dart b/lib/presentation/plans/plan_create_screen/bloc/plan_create_bloc.dart index 3cab0f65..871c2dc1 100644 --- a/lib/presentation/plans/plan_create_screen/bloc/plan_create_bloc.dart +++ b/lib/presentation/plans/plan_create_screen/bloc/plan_create_bloc.dart @@ -2,11 +2,11 @@ import 'dart:async'; import 'dart:convert'; import 'package:eatvio_app/app_router.dart'; +import 'package:eatvio_app/core/token_storage.dart'; import 'package:eatvio_app/presentation/plans/plan_create_screen/models/plan_create_model.dart'; import 'package:equatable/equatable.dart'; import 'package:flutter/material.dart'; import 'package:go_router/go_router.dart'; -import 'package:hive/hive.dart'; import 'package:http/http.dart' as http; import '/core/app_export.dart'; @@ -25,9 +25,7 @@ class PlanCreateBloc extends Bloc { PlanCreateInitialEvent event, Emitter emit, ) async { - final box = await Hive.openBox('token'); - final token = box.get('token'); - if (token == null) { + if (!await TokenStorage.haveTokenInStorage()) { AppRouter.navigatorKey.currentContext?.goNamed('authScreen'); } if (state is PlanCreateLoadedState) { diff --git a/lib/presentation/plans/plan_edit_screen/bloc/plan_edit_bloc.dart b/lib/presentation/plans/plan_edit_screen/bloc/plan_edit_bloc.dart index 5987b6bd..656e671c 100644 --- a/lib/presentation/plans/plan_edit_screen/bloc/plan_edit_bloc.dart +++ b/lib/presentation/plans/plan_edit_screen/bloc/plan_edit_bloc.dart @@ -2,11 +2,11 @@ import 'dart:async'; import 'dart:convert'; import 'package:eatvio_app/app_router.dart'; +import 'package:eatvio_app/core/token_storage.dart'; import 'package:eatvio_app/presentation/plans/plan_edit_screen/models/plan_edit_model.dart'; import 'package:equatable/equatable.dart'; import 'package:flutter/material.dart'; import 'package:go_router/go_router.dart'; -import 'package:hive/hive.dart'; import 'package:http/http.dart' as http; import '/core/app_export.dart'; @@ -26,16 +26,14 @@ class PlanEditBloc extends Bloc { Emitter emit, ) async { try { - final box = await Hive.openBox('token'); - final token = box.get('token'); - if (token == null) { + if (!await TokenStorage.haveTokenInStorage()) { AppRouter.navigatorKey.currentContext?.goNamed('authScreen'); } final String? planID = state.planModelObj?.planID; final response = await http.get( Uri.parse(baseUrl + '/api/plans/show/$planID'), headers: { - 'Authorization': 'Bearer $token', + 'Authorization': 'Bearer ${await TokenStorage.getTokenFromStorage()}', }, ); if (response.statusCode == 200) { diff --git a/lib/presentation/plans/plan_select_screen/bloc/plan_select_bloc.dart b/lib/presentation/plans/plan_select_screen/bloc/plan_select_bloc.dart index dcf60700..fa32b77f 100644 --- a/lib/presentation/plans/plan_select_screen/bloc/plan_select_bloc.dart +++ b/lib/presentation/plans/plan_select_screen/bloc/plan_select_bloc.dart @@ -3,11 +3,11 @@ import 'dart:async'; import 'dart:convert'; import 'package:eatvio_app/app_router.dart'; +import 'package:eatvio_app/core/token_storage.dart'; import 'package:eatvio_app/presentation/plans/plan_select_screen/models/plan_select_model.dart'; import 'package:equatable/equatable.dart'; import 'package:flutter/material.dart'; import 'package:go_router/go_router.dart'; -import 'package:hive/hive.dart'; import 'package:http/http.dart' as http; import 'package:image_picker/image_picker.dart'; @@ -27,9 +27,7 @@ class PlanSelectBloc extends Bloc { Emitter emit, ) async { try { - final box = await Hive.openBox('token'); - final token = box.get('token'); - if (token == null) { + if (!await TokenStorage.haveTokenInStorage()) { AppRouter.navigatorKey.currentContext?.goNamed('authScreen'); } final response = await http.get( diff --git a/lib/presentation/plans/plan_show_screen/bloc/plan_show_bloc.dart b/lib/presentation/plans/plan_show_screen/bloc/plan_show_bloc.dart index ad9a7a43..f09463a9 100644 --- a/lib/presentation/plans/plan_show_screen/bloc/plan_show_bloc.dart +++ b/lib/presentation/plans/plan_show_screen/bloc/plan_show_bloc.dart @@ -2,11 +2,11 @@ import 'dart:async'; import 'dart:convert'; import 'package:eatvio_app/app_router.dart'; +import 'package:eatvio_app/core/token_storage.dart'; import 'package:eatvio_app/presentation/plans/plan_show_screen/models/plan_show_model.dart'; import 'package:equatable/equatable.dart'; import 'package:flutter/material.dart'; import 'package:go_router/go_router.dart'; -import 'package:hive/hive.dart'; import 'package:http/http.dart' as http; import '/core/app_export.dart'; @@ -26,16 +26,14 @@ class PlanBloc extends Bloc { Emitter emit, ) async { try { - final box = await Hive.openBox('token'); - final token = box.get('token'); - if (token == null) { + if (!await TokenStorage.haveTokenInStorage()) { AppRouter.navigatorKey.currentContext?.goNamed('authScreen'); } final String? planID = state.planModelObj?.planID; final response = await http.get( Uri.parse(baseUrl + '/api/plans/show/$planID'), headers: { - 'Authorization': 'Bearer $token', + 'Authorization': 'Bearer ${await TokenStorage.getTokenFromStorage()}', }, ); if (response.statusCode == 200) { @@ -62,16 +60,14 @@ class PlanBloc extends Bloc { } FutureOr _deleteEntry(DeleteEntry event, Emitter emit) async { - final box = await Hive.openBox('token'); - final token = box.get('token'); - if (token == null) { + if (!await TokenStorage.haveTokenInStorage()) { AppRouter.navigatorKey.currentContext?.goNamed('authScreen'); } final int id = event.id; final response = await http.post( Uri.parse(baseUrl + '/api/plans/delete/$id'), headers: { - 'Authorization': 'Bearer $token', + 'Authorization': 'Bearer ${await TokenStorage.getTokenFromStorage()}', }, ); if (response.statusCode == 200) { diff --git a/lib/presentation/profile/my_profile_screen/bloc/my_profile_bloc.dart b/lib/presentation/profile/my_profile_screen/bloc/my_profile_bloc.dart index 8b01f618..4678416e 100644 --- a/lib/presentation/profile/my_profile_screen/bloc/my_profile_bloc.dart +++ b/lib/presentation/profile/my_profile_screen/bloc/my_profile_bloc.dart @@ -3,11 +3,11 @@ import 'dart:async'; import 'dart:convert'; import 'package:eatvio_app/app_router.dart'; +import 'package:eatvio_app/core/token_storage.dart'; import 'package:eatvio_app/presentation/profile/my_profile_screen/models/my_profile_model.dart'; import 'package:equatable/equatable.dart'; import 'package:flutter/material.dart'; import 'package:go_router/go_router.dart'; -import 'package:hive/hive.dart'; import 'package:http/http.dart' as http; import 'package:image_picker/image_picker.dart'; @@ -28,9 +28,7 @@ class MyProfileBloc extends Bloc { Emitter emit, ) async { try { - final box = await Hive.openBox('token'); - final token = box.get('token'); - if (token == null) { + if (!await TokenStorage.haveTokenInStorage()) { AppRouter.navigatorKey.currentContext?.goNamed('authScreen'); } //final token = @@ -38,7 +36,7 @@ class MyProfileBloc extends Bloc { final response = await http.get( Uri.parse(baseUrl + '/api/profile/index'), headers: { - 'Authorization': 'Bearer $token', + 'Authorization': 'Bearer ${await TokenStorage.getTokenFromStorage()}', }, ); if (response.statusCode == 200) { @@ -48,10 +46,6 @@ class MyProfileBloc extends Bloc { data.containsKey('userDetails') && data.containsKey('chartPoints') && data.containsKey('circumferences')) { - final avatarBox = await Hive.openBox('avatar'); - final avatar = data['user']['profile_photo_path']; - print(avatar); - avatarBox.put('avatar', avatar); if (state is MyProfileLoadedState) { var currentState = state as MyProfileLoadedState; var plans = [] @@ -69,7 +63,7 @@ class MyProfileBloc extends Bloc { user: data['user'], userDetails: data['userDetails'], plans: plans, - token: token, + token: await TokenStorage.getTokenFromStorage(), chestCircumferenceController: TextEditingController(), waistCircumferenceController: TextEditingController(), hipCircumferenceController: TextEditingController(), @@ -172,7 +166,7 @@ class MyProfileBloc extends Bloc { user: data['user'], userDetails: data['userDetails'], plans: plans, - token: token, + token: await TokenStorage.getTokenFromStorage(), chestCircumferenceController: TextEditingController(), waistCircumferenceController: TextEditingController(), hipCircumferenceController: TextEditingController(), diff --git a/lib/presentation/profile/my_profile_screen/my_profile_screen.dart b/lib/presentation/profile/my_profile_screen/my_profile_screen.dart index 306099e8..d10b70ab 100644 --- a/lib/presentation/profile/my_profile_screen/my_profile_screen.dart +++ b/lib/presentation/profile/my_profile_screen/my_profile_screen.dart @@ -1,24 +1,23 @@ import 'dart:convert'; +import 'dart:math'; import 'package:cached_network_image/cached_network_image.dart'; import 'package:carousel_slider_plus/carousel_slider_plus.dart'; import 'package:eatvio_app/core/app_export.dart'; import 'package:eatvio_app/widgets/app_bar/appbar_subtitle.dart'; import 'package:eatvio_app/widgets/custom_text_form_field.dart'; +import 'package:fl_chart/fl_chart.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:go_router/go_router.dart'; import 'package:http/http.dart' as http; import 'package:image_picker/image_picker.dart'; +import 'package:intl/intl.dart'; + import 'bloc/my_profile_bloc.dart'; import 'models/my_profile_model.dart'; class MyProfileScreen extends StatelessWidget { - int valuteToInt(String value) { - // Преобразование строки в целое число - return int.tryParse(value) ?? 0; // Возвращает 0, если преобразование не удалось - } - static Widget builder(BuildContext context) { return BlocProvider( create: (context) => MyProfileBloc( @@ -193,7 +192,7 @@ class MyProfileScreen extends StatelessWidget { _buildCarousel(BuildContext contex, MyProfileLoadedState state) { return CarouselSlider( - options: CarouselOptions(height: 370), + options: CarouselOptions(height: 340), items: [1, 2, 3].map((chartType) { return Builder( builder: (BuildContext context) { @@ -210,11 +209,11 @@ class MyProfileScreen extends StatelessWidget { ), ), SizedBox(height: 50.v), - // _buildChart( - // context, - // state.chartPoints?.values.map((e) => e['weight']).toList().map((i) => i.toDouble()).toList() ?? [0.0, 0.0, 0.0, 0.0], - // state.chartDates, - // ), + _buildChart( + context, + state.chartPoints?.values.map((e) => e['weight']).toList().map((i) => i.toDouble()).toList() ?? [0.0, 0.0, 0.0, 0.0], + state.chartDates, + ), ], ), ); @@ -228,14 +227,14 @@ class MyProfileScreen extends StatelessWidget { ), ), SizedBox(height: 50.v), - // _buildChart( - // context, - // _bodyMassIndex( - // state.chartPoints?.values.map((e) => e['weight']).toList().map((i) => i.toDouble()).toList() ?? [0.0, 0.0, 0.0, 0.0], - // state.userDetails?['height'].toInt() ?? 160, - // ), - // state.chartDates, - // ), + _buildChart( + context, + _bodyMassIndex( + state.chartPoints?.values.map((e) => e['weight']).toList().map((i) => i.toDouble()).toList() ?? [0.0, 0.0, 0.0, 0.0], + state.userDetails?['height'].toInt() ?? 160, + ), + state.chartDates, + ), ], ); case 3: //График обхватов @@ -250,7 +249,7 @@ class MyProfileScreen extends StatelessWidget { ), ), SizedBox(height: 30.v), - // _buildCircumferenceChart(context, state.circumferences, state.chartDates), + _buildCircumferenceChart(context, state.circumferences, state.chartDates), _buildChartLegend(), ], ), @@ -296,34 +295,354 @@ class MyProfileScreen extends StatelessWidget { ); } - // Widget _buildChart(BuildContext context, List chartPoints, List? dates) { - // // Проверяем, что у нас есть 4 элемента в обоих списках - // if (chartPoints.length != 4 || (dates != null && dates.length != 4)) { - // return Center(child: Text('Должно быть ровно 4 точки и 4 даты.')); - // } + _buildChart(BuildContext context, List chartPoints, List? dates) { + List spots = []; + for (int i = 0; i < 4; i++) { + spots.add( + FlSpot((i * 10 / 10) + 1, chartPoints[i]), + ); + } - // // Преобразуем данные в список точек для графика - // List chartData = List.generate(4, (index) { - // return ChartData(dates![index], chartPoints[index]); - // }); + Widget bottomTitleWidgets(double value, TitleMeta meta, double chartWidth, List? dates) { + if (value % 1 != 0) { + return Container(); + } + final style = TextStyle( + color: Colors.blue, + fontWeight: FontWeight.bold, + fontSize: min(13, 13 * chartWidth / 300), + ); + int index = value.toInt(); + if (index >= 0 && index < dates!.length) { + // Проверка на допустимый индекс в массиве dates + String formattedDate = DateFormat('dd.MM').format(DateTime.parse(dates[index])); + return SideTitleWidget( + axisSide: meta.axisSide, + space: 16, + child: Text(formattedDate, style: style), + ); + } else { + return Container(); + } + } - // return Container( - // height: 300, // Задайте нужную высоту для графика - // child: SfCartesianChart( - // title: ChartTitle(text: 'График значений'), - // primaryXAxis: CategoryAxis(), - // series: >[ - // // Изменяем на CartesianSeries - // LineSeries( - // dataSource: chartData, - // xValueMapper: (ChartData data, _) => data.date, - // yValueMapper: (ChartData data, _) => data.value, - // dataLabelSettings: DataLabelSettings(isVisible: true), - // ), - // ], - // ), - // ); - // } + Widget leftTitleWidgets(double value, TitleMeta meta, double chartWidth) { + final style = TextStyle( + color: Colors.blue, + fontWeight: FontWeight.bold, + fontSize: min(18, 18 * chartWidth / 300), + ); + return SideTitleWidget( + axisSide: meta.axisSide, + space: 16, + child: Text(meta.formattedValue, style: style), + ); + } + + return Padding( + padding: const EdgeInsets.only( + left: 12, + right: 20, + ), + child: AspectRatio( + aspectRatio: 1, + child: LayoutBuilder( + builder: (context, constraints) { + return LineChart( + LineChartData( + lineTouchData: LineTouchData( + touchTooltipData: LineTouchTooltipData( + maxContentWidth: 100, + // tooltipBgColor: Colors.black, + getTooltipItems: mapSpots(), + ), + handleBuiltInTouches: true, + getTouchLineStart: (data, index) => 0, + ), + lineBarsData: [ + LineChartBarData( + color: Colors.pink, + spots: spots, + isCurved: true, + isStrokeCapRound: true, + barWidth: 3, + belowBarData: BarAreaData( + show: false, + ), + dotData: const FlDotData(show: false), + ), + ], + minY: chartPoints.reduce((value, element) => value < element ? value : element), + maxY: chartPoints.reduce((value, element) => value > element ? value : element), + minX: 1, + maxX: 4, + titlesData: FlTitlesData( + leftTitles: AxisTitles( + sideTitles: SideTitles( + showTitles: true, + getTitlesWidget: (value, meta) => leftTitleWidgets(value, meta, constraints.maxWidth), + reservedSize: 56, + ), + drawBelowEverything: true, + ), + rightTitles: const AxisTitles( + sideTitles: SideTitles(showTitles: false), + ), + bottomTitles: AxisTitles( + sideTitles: SideTitles( + showTitles: true, + getTitlesWidget: (value, meta) => bottomTitleWidgets(value, meta, constraints.maxWidth, dates), + reservedSize: 36, + interval: 1, + ), + drawBelowEverything: true, + ), + topTitles: const AxisTitles( + sideTitles: SideTitles(showTitles: false), + ), + ), + gridData: FlGridData( + show: true, + drawHorizontalLine: true, + drawVerticalLine: true, + horizontalInterval: 1.5, + verticalInterval: 5, + checkToShowHorizontalLine: valuteToInt(), + getDrawingHorizontalLine: (_) => FlLine( + color: Colors.blue.withOpacity(1), + dashArray: [8, 2], + strokeWidth: 0.8, + ), + getDrawingVerticalLine: (_) => FlLine( + color: Colors.blue.withOpacity(1), + dashArray: [8, 2], + strokeWidth: 0.8, + ), + checkToShowVerticalLine: valuteToInt(), + ), + borderData: FlBorderData(show: false), + ), + ); + }, + ), + ), + ); + } + + valuteToInt() { + return (value) { + return value.toInt() == 0; + }; + } + + List Function(List) mapSpots() { + return (touchedSpots) { + return touchedSpots.map((LineBarSpot touchedSpot) { + final textStyle = TextStyle( + color: touchedSpot.bar.gradient?.colors[0] ?? touchedSpot.bar.color, + fontWeight: FontWeight.bold, + fontSize: 14, + ); + return LineTooltipItem( + '${touchedSpot.x}, ${touchedSpot.y.toStringAsFixed(2)}', + textStyle, + ); + }).toList(); + }; + } + + _buildCircumferenceChart(BuildContext context, chartPoints, List? dates) { +// Определение осей графика + final chestCircumferences = chartPoints.values.map((e) => e['chest_circumference']).toList(); + List spotsChest = []; + for (int i = 0; i < 4; i++) { + chestCircumferences[i] = chestCircumferences[i] * 10 / 10; + spotsChest.add( + FlSpot((i * 10 / 10) + 1, chestCircumferences[i] * 10 / 10), + ); + } + final waistCircumferences = chartPoints.values.map((e) => e['waist_circumference']).toList(); + List spotsWaist = []; + for (int i = 0; i < 4; i++) { + waistCircumferences[i] = waistCircumferences[i] * 10 / 10; + spotsWaist.add( + FlSpot((i * 10 / 10) + 1, waistCircumferences[i] * 10 / 10), + ); + } + final hipCircumferences = chartPoints.values.map((e) => e['hip_circumference']).toList(); + List spotsHip = []; + for (int i = 0; i < 4; i++) { + hipCircumferences[i] = hipCircumferences[i] * 10 / 10; + spotsHip.add( + FlSpot((i * 10 / 10) + 1, hipCircumferences[i]), + ); + } + + final allCircumferences = [...chestCircumferences, ...hipCircumferences, ...waistCircumferences]; + + Widget bottomTitleWidgets(double value, TitleMeta meta, double chartWidth, List? dates) { + if (value % 1 != 0) { + return Container(); + } + final style = TextStyle( + color: Colors.blue, + fontWeight: FontWeight.bold, + fontSize: min(13, 13 * chartWidth / 300), + ); + int index = value.toInt(); + if (index >= 0 && index < dates!.length) { + // Проверка на допустимый индекс в массиве dates + String formattedDate = DateFormat('dd.MM').format(DateTime.parse(dates[index])); + return SideTitleWidget( + axisSide: meta.axisSide, + space: 16, + child: Text(formattedDate, style: style), + ); + } else { + return Container(); + } + } + + Widget leftTitleWidgets(double value, TitleMeta meta, double chartWidth) { + final style = TextStyle( + color: Colors.blue, + fontWeight: FontWeight.bold, + fontSize: min(18, 18 * chartWidth / 300), + ); + return SideTitleWidget( + axisSide: meta.axisSide, + space: 16, + child: Text(meta.formattedValue, style: style), + ); + } + + return Padding( + padding: const EdgeInsets.only( + left: 12, + right: 20, + ), + child: AspectRatio( + aspectRatio: 1, + child: LayoutBuilder( + builder: (context, constraints) { + return LineChart( + LineChartData( + lineTouchData: LineTouchData( + touchTooltipData: LineTouchTooltipData( + maxContentWidth: 100, + // tooltipBgColor: Colors.black, + getTooltipItems: mapTouchedSpots(), + ), + handleBuiltInTouches: true, + getTouchLineStart: (data, index) => 0, + ), + lineBarsData: [ + LineChartBarData( + color: Colors.pink, + spots: spotsChest, + isCurved: true, + isStrokeCapRound: true, + barWidth: 3, + belowBarData: BarAreaData( + show: false, + ), + dotData: const FlDotData(show: false), + ), + LineChartBarData( + color: Colors.green, + spots: spotsWaist, + isCurved: true, + isStrokeCapRound: true, + barWidth: 3, + belowBarData: BarAreaData( + show: false, + ), + dotData: const FlDotData(show: false), + ), + LineChartBarData( + color: Colors.purple, + spots: spotsHip, + isCurved: true, + isStrokeCapRound: true, + barWidth: 3, + belowBarData: BarAreaData( + show: false, + ), + dotData: const FlDotData(show: false), + ), + ], + minY: allCircumferences.reduce((value, element) => value < element ? value : element), + maxY: allCircumferences.reduce((value, element) => value > element ? value : element), + minX: 1, + maxX: 4, + titlesData: FlTitlesData( + leftTitles: AxisTitles( + sideTitles: SideTitles( + showTitles: true, + getTitlesWidget: (value, meta) => leftTitleWidgets(value, meta, constraints.maxWidth), + reservedSize: 56, + ), + drawBelowEverything: true, + ), + rightTitles: const AxisTitles( + sideTitles: SideTitles(showTitles: false), + ), + bottomTitles: AxisTitles( + sideTitles: SideTitles( + showTitles: true, + getTitlesWidget: (value, meta) => bottomTitleWidgets(value, meta, constraints.maxWidth, dates), + reservedSize: 36, + interval: 1, + ), + drawBelowEverything: true, + ), + topTitles: const AxisTitles( + sideTitles: SideTitles(showTitles: false), + ), + ), + gridData: FlGridData( + show: true, + drawHorizontalLine: true, + drawVerticalLine: true, + horizontalInterval: 1.5, + verticalInterval: 5, + checkToShowHorizontalLine: valuteToInt(), + getDrawingHorizontalLine: (_) => FlLine( + color: Colors.blue.withOpacity(1), + dashArray: [8, 2], + strokeWidth: 0.8, + ), + getDrawingVerticalLine: (_) => FlLine( + color: Colors.blue.withOpacity(1), + dashArray: [8, 2], + strokeWidth: 0.8, + ), + checkToShowVerticalLine: valuteToInt(), + ), + borderData: FlBorderData(show: false), + ), + ); + }, + ), + ), + ); + } + + List Function(List) mapTouchedSpots() { + return (touchedSpots) { + return touchedSpots.map((LineBarSpot touchedSpot) { + final textStyle = TextStyle( + color: touchedSpot.bar.gradient?.colors[0] ?? touchedSpot.bar.color, + fontWeight: FontWeight.bold, + fontSize: 14, + ); + return LineTooltipItem( + '${touchedSpot.x}, ${touchedSpot.y.toStringAsFixed(2)}', + textStyle, + ); + }).toList(); + }; + } /// Section Widget _buildPlans(BuildContext context, List? plans, List? imagePaths, List? states) { @@ -643,16 +962,3 @@ class MyProfileScreen extends StatelessWidget { }; } } - -class ChartData { - final String date; - final double value; - - ChartData(this.date, this.value); - - valuteToInt() { - return (value) { - return value.toInt() == 0; - }; - } -} diff --git a/lib/presentation/recipe/recipe_edit_screen/bloc/recipe_edit_bloc.dart b/lib/presentation/recipe/recipe_edit_screen/bloc/recipe_edit_bloc.dart index 560c75ee..fa817935 100644 --- a/lib/presentation/recipe/recipe_edit_screen/bloc/recipe_edit_bloc.dart +++ b/lib/presentation/recipe/recipe_edit_screen/bloc/recipe_edit_bloc.dart @@ -2,11 +2,11 @@ import 'dart:async'; import 'dart:convert'; import 'package:eatvio_app/app_router.dart'; +import 'package:eatvio_app/core/token_storage.dart'; import 'package:eatvio_app/presentation/recipe/recipe_edit_screen/models/recipe_edit_model.dart'; import 'package:equatable/equatable.dart'; import 'package:flutter/material.dart'; import 'package:go_router/go_router.dart'; -import 'package:hive/hive.dart'; import 'package:http/http.dart' as http; import '/core/app_export.dart'; @@ -29,16 +29,14 @@ class RecipeEditBloc extends Bloc { Emitter emit, ) async { try { - final box = await Hive.openBox('token'); - final token = box.get('token'); - if (token == null) { + if (!await TokenStorage.haveTokenInStorage()) { AppRouter.navigatorKey.currentContext?.goNamed('authScreen'); } final String? recipeID = state.recipeModelObj?.recipeID; final response = await http.get( Uri.parse(baseUrl + '/api/recipes/show/$recipeID'), headers: { - 'Authorization': 'Bearer $token', + 'Authorization': 'Bearer ${await TokenStorage.getTokenFromStorage()}', }, ); if (response.statusCode == 200) { @@ -79,7 +77,7 @@ class RecipeEditBloc extends Bloc { emit( RecipeEditLoadedState( - token: token, + token: await TokenStorage.getTokenFromStorage(), recipe: data, title: TextEditingController(text: data['title']), description: TextEditingController(text: data['description']), @@ -191,17 +189,14 @@ class RecipeEditBloc extends Bloc { } _fetchTags(int id) async { - final box = await Hive.openBox('token'); - final token = box.get('token'); - - if (token == null) { + if (!await TokenStorage.haveTokenInStorage()) { AppRouter.navigatorKey.currentContext?.goNamed('authScreen'); } final response = await http.get( Uri.parse(baseUrl + '/api/recipes/getTags/$id'), headers: { - 'Authorization': 'Bearer $token', + 'Authorization': 'Bearer ${await TokenStorage.getTokenFromStorage()}', }, ); final data = jsonDecode(response.body); @@ -210,9 +205,7 @@ class RecipeEditBloc extends Bloc { FutureOr _reloadScreen(RecipeEditEvent? event, Emitter emit) async { print('Reloading..'); - final box = await Hive.openBox('token'); - final token = box.get('token'); - if (token == null) { + if (!await TokenStorage.haveTokenInStorage()) { AppRouter.navigatorKey.currentContext?.goNamed('authScreen'); } if (state is RecipeEditLoadedState) { diff --git a/lib/presentation/recipe/recipe_select_screen/bloc/recipe_select_bloc.dart b/lib/presentation/recipe/recipe_select_screen/bloc/recipe_select_bloc.dart index 399e20f8..21f14634 100644 --- a/lib/presentation/recipe/recipe_select_screen/bloc/recipe_select_bloc.dart +++ b/lib/presentation/recipe/recipe_select_screen/bloc/recipe_select_bloc.dart @@ -2,12 +2,12 @@ import 'dart:async'; import 'package:dio/dio.dart'; import 'package:eatvio_app/app_router.dart'; +import 'package:eatvio_app/core/token_storage.dart'; import 'package:eatvio_app/locator_service.dart'; import 'package:eatvio_app/presentation/recipe/recipe_select_screen/models/recipe_select_model.dart'; import 'package:equatable/equatable.dart'; import 'package:flutter/material.dart'; import 'package:go_router/go_router.dart'; -import 'package:hive/hive.dart'; import 'package:image_picker/image_picker.dart'; import '/core/app_export.dart'; @@ -26,9 +26,7 @@ class RecipeSelectBloc extends Bloc { Emitter emit, ) async { try { - final box = await Hive.openBox('token'); - final token = box.get('token'); - if (token == null) { + if (!await TokenStorage.haveTokenInStorage()) { AppRouter.navigatorKey.currentContext?.goNamed('authScreen'); } final response = await sl().get(baseUrl + '/api/recipes/index'); diff --git a/lib/presentation/recipe/recipe_show_screen/bloc/recipe_show_bloc.dart b/lib/presentation/recipe/recipe_show_screen/bloc/recipe_show_bloc.dart index ac2d9a9a..2ae1d76d 100644 --- a/lib/presentation/recipe/recipe_show_screen/bloc/recipe_show_bloc.dart +++ b/lib/presentation/recipe/recipe_show_screen/bloc/recipe_show_bloc.dart @@ -2,12 +2,12 @@ import 'dart:async'; import 'dart:convert'; import 'package:eatvio_app/app_router.dart'; +import 'package:eatvio_app/core/token_storage.dart'; import 'package:eatvio_app/presentation/feed/blog_post_screen/models/comment_model.dart'; import 'package:eatvio_app/presentation/recipe/recipe_show_screen/models/recipe_show_model.dart'; import 'package:equatable/equatable.dart'; import 'package:flutter/material.dart'; import 'package:go_router/go_router.dart'; -import 'package:hive/hive.dart'; import 'package:http/http.dart' as http; import 'package:intl/intl.dart'; @@ -29,16 +29,14 @@ class RecipeBloc extends Bloc { Emitter emit, ) async { try { - final box = await Hive.openBox('token'); - final token = box.get('token'); - if (token == null) { + if (!await TokenStorage.haveTokenInStorage()) { AppRouter.navigatorKey.currentContext?.goNamed('authScreen'); } final String? recipeID = state.recipeModelObj?.recipeID; final response = await http.get( Uri.parse(baseUrl + '/api/recipes/show/$recipeID'), headers: { - 'Authorization': 'Bearer $token', + 'Authorization': 'Bearer ${await TokenStorage.getTokenFromStorage()}', }, ); if (response.statusCode == 200) { @@ -60,7 +58,7 @@ class RecipeBloc extends Bloc { } else { emit( RecipeLoadedState( - token: token, + token: await TokenStorage.getTokenFromStorage(), recipe: data, steps: data['steps'], author: await _fetchAuthor(data['id']), @@ -85,16 +83,14 @@ class RecipeBloc extends Bloc { } FutureOr _deleteEntry(DeleteEntry event, Emitter emit) async { - final box = await Hive.openBox('token'); - final token = box.get('token'); - if (token == null) { + if (!await TokenStorage.haveTokenInStorage()) { AppRouter.navigatorKey.currentContext?.goNamed('authScreen'); } final int id = event.id; final response = await http.post( Uri.parse(baseUrl + '/api/recipes/delete/$id'), headers: { - 'Authorization': 'Bearer $token', + 'Authorization': 'Bearer ${await TokenStorage.getTokenFromStorage()}', }, ); if (response.statusCode == 200) { @@ -122,17 +118,14 @@ class RecipeBloc extends Bloc { } _fetchAuthor(int id) async { - final box = await Hive.openBox('token'); - final token = box.get('token'); - - if (token == null) { + if (!await TokenStorage.haveTokenInStorage()) { AppRouter.navigatorKey.currentContext?.goNamed('authScreen'); } final response = await http.get( Uri.parse(baseUrl + '/api/recipes/getAuthor/$id'), headers: { - 'Authorization': 'Bearer $token', + 'Authorization': 'Bearer ${await TokenStorage.getTokenFromStorage()}', }, ); final data = jsonDecode(response.body); @@ -140,15 +133,13 @@ class RecipeBloc extends Bloc { } Future _fetchComments(int id) async { - final box = await Hive.openBox('token'); - final token = box.get('token'); - if (token == null) { + if (!await TokenStorage.haveTokenInStorage()) { AppRouter.navigatorKey.currentContext?.goNamed('authScreen'); } final response = await http.get( Uri.parse(baseUrl + '/api/recipes/getComments/$id'), headers: { - 'Authorization': 'Bearer $token', + 'Authorization': 'Bearer ${await TokenStorage.getTokenFromStorage()}', }, ); final data = jsonDecode(response.body); @@ -156,17 +147,14 @@ class RecipeBloc extends Bloc { } _fetchTags(int id) async { - final box = await Hive.openBox('token'); - final token = box.get('token'); - - if (token == null) { + if (!await TokenStorage.haveTokenInStorage()) { AppRouter.navigatorKey.currentContext?.goNamed('authScreen'); } final response = await http.get( Uri.parse(baseUrl + '/api/recipes/getTags/$id'), headers: { - 'Authorization': 'Bearer $token', + 'Authorization': 'Bearer ${await TokenStorage.getTokenFromStorage()}', }, ); final data = jsonDecode(response.body); diff --git a/lib/presentation/users/subscribers_screen/bloc/subscribers_bloc.dart b/lib/presentation/users/subscribers_screen/bloc/subscribers_bloc.dart index a48d6198..f29ace07 100644 --- a/lib/presentation/users/subscribers_screen/bloc/subscribers_bloc.dart +++ b/lib/presentation/users/subscribers_screen/bloc/subscribers_bloc.dart @@ -3,11 +3,11 @@ import 'dart:async'; import 'dart:convert'; import 'package:eatvio_app/app_router.dart'; +import 'package:eatvio_app/core/token_storage.dart'; import 'package:eatvio_app/presentation/users/subscribers_screen/models/subscribers_model.dart'; import 'package:equatable/equatable.dart'; import 'package:flutter/material.dart'; import 'package:go_router/go_router.dart'; -import 'package:hive/hive.dart'; import 'package:http/http.dart' as http; import '/core/app_export.dart'; @@ -26,15 +26,13 @@ class SubscribersBloc extends Bloc { Emitter emit, ) async { try { - final box = await Hive.openBox('token'); - final token = box.get('token'); - if (token == null) { + if (!await TokenStorage.haveTokenInStorage()) { AppRouter.navigatorKey.currentContext?.goNamed('authScreen'); } final response = await http.get( Uri.parse(baseUrl + '/api/profile/subscribers'), headers: { - 'Authorization': 'Bearer $token', + 'Authorization': 'Bearer ${await TokenStorage.getTokenFromStorage()}', }, ); print('Got response'); diff --git a/lib/theme/bloc/theme_bloc.dart b/lib/theme/bloc/theme_bloc.dart deleted file mode 100644 index ae2863bd..00000000 --- a/lib/theme/bloc/theme_bloc.dart +++ /dev/null @@ -1,20 +0,0 @@ -import 'package:equatable/equatable.dart'; -import 'package:flutter/material.dart'; - -import '../../core/app_export.dart'; - -part 'theme_event.dart'; -part 'theme_state.dart'; - -class ThemeBloc extends Bloc { - ThemeBloc(ThemeState initialState) : super(initialState) { - on(_changeTheme); - } - - _changeTheme( - ThemeChangeEvent event, - Emitter emit, - ) async { - emit(state.copyWith(themeType: event.themeType)); - } -} diff --git a/lib/theme/bloc/theme_event.dart b/lib/theme/bloc/theme_event.dart deleted file mode 100644 index 700cbdec..00000000 --- a/lib/theme/bloc/theme_event.dart +++ /dev/null @@ -1,15 +0,0 @@ -part of 'theme_bloc.dart'; - -@immutable -abstract class ThemeEvent extends Equatable {} - -class ThemeChangeEvent extends ThemeEvent { - ThemeChangeEvent({required this.themeType}) : super() { - PrefUtils().setThemeData(themeType); - } - - final String themeType; - - @override - List get props => []; -} diff --git a/lib/theme/bloc/theme_state.dart b/lib/theme/bloc/theme_state.dart deleted file mode 100644 index 191bcfe4..00000000 --- a/lib/theme/bloc/theme_state.dart +++ /dev/null @@ -1,15 +0,0 @@ -part of 'theme_bloc.dart'; - -@immutable -class ThemeState extends Equatable { - ThemeState({required this.themeType}); - - final String themeType; - - @override - List get props => [themeType]; - - ThemeState copyWith({String? themeType}) { - return ThemeState(themeType: themeType ?? this.themeType); - } -} diff --git a/lib/theme/theme_helper.dart b/lib/theme/theme_helper.dart index b33d056b..20fa5474 100644 --- a/lib/theme/theme_helper.dart +++ b/lib/theme/theme_helper.dart @@ -7,7 +7,7 @@ import '../../core/app_export.dart'; /// Helper class for managing themes and colors. class ThemeHelper { // The current app theme - var _appTheme = PrefUtils().getThemeData(); + var _appTheme = 'primary'; // A map of custom color themes supported by the app Map _supportedCustomColor = { diff --git a/lib/widgets/custom_expandable_list.dart b/lib/widgets/custom_expandable_list.dart index 5678f3e4..2489c0d7 100644 --- a/lib/widgets/custom_expandable_list.dart +++ b/lib/widgets/custom_expandable_list.dart @@ -1,6 +1,7 @@ import 'dart:convert'; import 'package:eatvio_app/core/app_export.dart'; +import 'package:eatvio_app/core/token_storage.dart'; import 'package:eatvio_app/presentation/profile/my_profile_screen/bloc/my_profile_bloc.dart'; import 'package:eatvio_app/widgets/custom_hyper_switch.dart'; import 'package:eatvio_app/widgets/custom_hypo_switch.dart'; @@ -8,7 +9,6 @@ import 'package:eatvio_app/widgets/next_step_button.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:go_router/go_router.dart'; -import 'package:hive/hive.dart'; import 'package:http/http.dart' as http; import 'package:intl/intl.dart'; @@ -384,8 +384,7 @@ class _ExpandableListState extends State { } Future _getTokenFromBox() async { - final box = await Hive.openBox('token'); - return box.get('token'); + return await TokenStorage.getTokenFromStorage(); } String _buildApiUrl() { diff --git a/lib/widgets/custom_navigation_menu.dart b/lib/widgets/custom_navigation_menu.dart deleted file mode 100644 index eece5f8f..00000000 --- a/lib/widgets/custom_navigation_menu.dart +++ /dev/null @@ -1,79 +0,0 @@ -import 'package:eatvio_app/core/app_export.dart'; -import 'package:eatvio_app/widgets/custom_navigation_menu_item.dart'; -import 'package:flutter/material.dart'; -import 'package:go_router/go_router.dart'; -import 'package:hive/hive.dart'; -import 'package:http/http.dart' as http; - -class CustomNavigationMenu extends StatelessWidget { - @override - Widget build(BuildContext context) { - return Container( - color: Colors.white, - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - MenuItem( - icon: ImageConstant.icnProfileSettings, - text: 'Настройки профиля', - onTap: () => GoRouter.of(context).push('/my-settings-screen'), - ), - MenuItem( - icon: ImageConstant.icnRecipes, - text: 'Мои рецепты', - onTap: () => GoRouter.of(context).push('/recipe-select-screen'), - ), - MenuItem( - icon: ImageConstant.icnVeggies, - text: 'Мои диеты', - onTap: () => GoRouter.of(context).push('/diet-select-screen'), - ), - MenuItem( - icon: ImageConstant.icnPlans, - text: 'Мои планы', - onTap: () => GoRouter.of(context).push('/plan-select-screen'), - ), - MenuItem( - icon: ImageConstant.icnPlans, - text: 'Календарь', - onTap: () => GoRouter.of(context).push('/calendar-screen'), - ), - MenuItem( - icon: ImageConstant.icnGlossary, - text: 'Глоссарий', - onTap: () => GoRouter.of(context).push('/glossary-screen'), - ), - MenuItem( - icon: ImageConstant.icnSupport, - text: 'Поддержка', - onTap: () {}, - ), - MenuItem( - icon: ImageConstant.icnExit, - text: 'Выход', - onTap: _onTapLogout(context), - ), - ], - ), - ); - } -} - -_onTapLogout(BuildContext context) { - return () async { - final box = await Hive.openBox('token'); - final token = box.get('token'); - final response = await http.post( - Uri.parse(baseUrl + '/api/profile/logout'), - headers: { - 'Authorization': 'Bearer $token', - }, - ); - - if (response.statusCode == 204) { - print(response.statusCode); - box.delete('token'); // Удаляем токен из Hive - GoRouter.of(context).go('/auth-screen'); - } - }; -} diff --git a/pubspec.yaml b/pubspec.yaml index 08cdef1d..514eb4a2 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -13,17 +13,14 @@ dependencies: flutter_localizations: sdk: flutter + flutter_secure_storage: ^9.2.2 flutter_bloc: ^8.1.6 - shared_preferences: ^2.3.2 - hive: ^2.2.3 - hive_flutter: ^1.1.0 cached_network_image: ^3.4.1 flutter_svg: ^2.0.10 equatable: ^2.0.5 freezed_annotation: ^2.4.4 json_annotation: ^4.9.0 validators: ^3.0.0 - isar_flutter_libs: ^3.1.0 path_provider: ^2.1.4 fl_chart: ^0.68.0 flutter_spinkit: ^5.2.1 @@ -45,12 +42,13 @@ dependencies: badges: ^3.1.2 google_fonts: ^6.2.1 location: ^6.0.2 - # syncfusion_flutter_charts: ^26.2.9 + syncfusion_flutter_charts: ^26.2.11 table_calendar: ^3.1.2 flutter_keyboard_visibility: ^6.0.0 share_plus: ^10.0.0 flutter_html: 3.0.0-beta.2 file_picker: ^8.1.1 + audioplayers: ^5.2.1 dev_dependencies: build_runner: ^2.4.11 @@ -66,3 +64,5 @@ flutter: assets: - assets/ - assets/images/ + - assets/audio/ + - assets/icons/