diff --git a/.gitea/workflows/test.yml b/.gitea/workflows/test.yml index 0fd6fdd1..3ab485dc 100644 --- a/.gitea/workflows/test.yml +++ b/.gitea/workflows/test.yml @@ -3,7 +3,7 @@ name: Eatvio App Android Test on: [ pull_request ] env: - flutter_version: "3.22.0" + flutter_version: "3.24.2" java_version: "17.x" flutter_channel: "stable" diff --git a/android/app/build.gradle b/android/app/build.gradle index 7652369e..bc059244 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -26,7 +26,7 @@ if (flutterVersionName == null) { android { namespace = "com.eatvioapp.app" compileSdk = flutter.compileSdkVersion - ndkVersion = flutter.ndkVersion + ndkVersion = "25.1.8937393" compileOptions { sourceCompatibility = JavaVersion.VERSION_1_8 diff --git a/assets/icons/chat.svg b/assets/icons/chat.svg new file mode 100644 index 00000000..01f615fe --- /dev/null +++ b/assets/icons/chat.svg @@ -0,0 +1,18 @@ + + + + + + + + + + + + diff --git a/assets/icons/comment.svg b/assets/icons/comment.svg new file mode 100644 index 00000000..60b1e584 --- /dev/null +++ b/assets/icons/comment.svg @@ -0,0 +1,18 @@ + + + + + + + + + + + + diff --git a/assets/icons/copy.svg b/assets/icons/copy.svg new file mode 100644 index 00000000..4ddffa65 --- /dev/null +++ b/assets/icons/copy.svg @@ -0,0 +1,19 @@ + + + + + + + + + + + + + diff --git a/assets/icons/diary.svg b/assets/icons/diary.svg new file mode 100644 index 00000000..3ddc00d2 --- /dev/null +++ b/assets/icons/diary.svg @@ -0,0 +1,18 @@ + + + + + + + + + + + + diff --git a/assets/icons/exit.svg b/assets/icons/exit.svg new file mode 100644 index 00000000..11e622be --- /dev/null +++ b/assets/icons/exit.svg @@ -0,0 +1,18 @@ + + + + + + + + + + + + diff --git a/assets/icons/favorite_blog_posts.svg b/assets/icons/favorite_blog_posts.svg new file mode 100644 index 00000000..b4c30bc7 --- /dev/null +++ b/assets/icons/favorite_blog_posts.svg @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + diff --git a/assets/icons/favorite_recipes.svg b/assets/icons/favorite_recipes.svg new file mode 100644 index 00000000..028fb5b3 --- /dev/null +++ b/assets/icons/favorite_recipes.svg @@ -0,0 +1,18 @@ + + + + + + + + + + + + diff --git a/assets/icons/feed.svg b/assets/icons/feed.svg new file mode 100644 index 00000000..3cefd68a --- /dev/null +++ b/assets/icons/feed.svg @@ -0,0 +1,19 @@ + + + + + + + + + + + + + diff --git a/assets/icons/filter.svg b/assets/icons/filter.svg new file mode 100644 index 00000000..7f5491ff --- /dev/null +++ b/assets/icons/filter.svg @@ -0,0 +1,67 @@ + + + + + + + + + + + + diff --git a/assets/icons/finance.svg b/assets/icons/finance.svg new file mode 100644 index 00000000..3bb33357 --- /dev/null +++ b/assets/icons/finance.svg @@ -0,0 +1,18 @@ + + + + + + + + + + + + diff --git a/assets/icons/glosasry.svg b/assets/icons/glosasry.svg new file mode 100644 index 00000000..1cb5ba2c --- /dev/null +++ b/assets/icons/glosasry.svg @@ -0,0 +1,18 @@ + + + + + + + + + + + + diff --git a/assets/icons/like.svg b/assets/icons/like.svg new file mode 100644 index 00000000..11397221 --- /dev/null +++ b/assets/icons/like.svg @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + diff --git a/assets/icons/like_filled.svg b/assets/icons/like_filled.svg new file mode 100644 index 00000000..e39670c3 --- /dev/null +++ b/assets/icons/like_filled.svg @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + diff --git a/assets/icons/meat.svg b/assets/icons/meat.svg new file mode 100644 index 00000000..5205a78c --- /dev/null +++ b/assets/icons/meat.svg @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + diff --git a/assets/icons/my_blog_posts.svg b/assets/icons/my_blog_posts.svg new file mode 100644 index 00000000..4dd28718 --- /dev/null +++ b/assets/icons/my_blog_posts.svg @@ -0,0 +1,18 @@ + + + + + + + + + + + + diff --git a/assets/icons/my_diets.svg b/assets/icons/my_diets.svg new file mode 100644 index 00000000..7714b3fa --- /dev/null +++ b/assets/icons/my_diets.svg @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + diff --git a/assets/icons/my_plans.svg b/assets/icons/my_plans.svg new file mode 100644 index 00000000..5e100f69 --- /dev/null +++ b/assets/icons/my_plans.svg @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/icons/my_rating.svg b/assets/icons/my_rating.svg new file mode 100644 index 00000000..8b5e069f --- /dev/null +++ b/assets/icons/my_rating.svg @@ -0,0 +1,18 @@ + + + + + + + + + + + + diff --git a/assets/icons/my_recipes.svg b/assets/icons/my_recipes.svg new file mode 100644 index 00000000..246014c5 --- /dev/null +++ b/assets/icons/my_recipes.svg @@ -0,0 +1,18 @@ + + + + + + + + + + + + diff --git a/assets/icons/notifications.svg b/assets/icons/notifications.svg new file mode 100644 index 00000000..fe550083 --- /dev/null +++ b/assets/icons/notifications.svg @@ -0,0 +1,18 @@ + + + + + + + + + + + + diff --git a/assets/icons/paste.svg b/assets/icons/paste.svg new file mode 100644 index 00000000..a6fe95bf --- /dev/null +++ b/assets/icons/paste.svg @@ -0,0 +1,18 @@ + + + + + + + + + + + + diff --git a/assets/icons/profile_settings.svg b/assets/icons/profile_settings.svg new file mode 100644 index 00000000..b3852d07 --- /dev/null +++ b/assets/icons/profile_settings.svg @@ -0,0 +1,18 @@ + + + + + + + + + + + + diff --git a/assets/icons/send.svg b/assets/icons/send.svg new file mode 100644 index 00000000..d4b7b65e --- /dev/null +++ b/assets/icons/send.svg @@ -0,0 +1,18 @@ + + + + + + + + + + + + diff --git a/assets/icons/share.svg b/assets/icons/share.svg new file mode 100644 index 00000000..711847c2 --- /dev/null +++ b/assets/icons/share.svg @@ -0,0 +1,18 @@ + + + + + + + + + + + + diff --git a/assets/icons/subscribers.svg b/assets/icons/subscribers.svg new file mode 100644 index 00000000..4006d4b4 --- /dev/null +++ b/assets/icons/subscribers.svg @@ -0,0 +1,18 @@ + + + + + + + + + + + + diff --git a/assets/icons/time.svg b/assets/icons/time.svg new file mode 100644 index 00000000..5037d404 --- /dev/null +++ b/assets/icons/time.svg @@ -0,0 +1,18 @@ + + + + + + + + + + + + diff --git a/assets/icons/views.svg b/assets/icons/views.svg new file mode 100644 index 00000000..60ff0928 --- /dev/null +++ b/assets/icons/views.svg @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + diff --git a/assets/icons/Консультации.svg b/assets/icons/Консультации.svg new file mode 100644 index 00000000..0bb87eaa --- /dev/null +++ b/assets/icons/Консультации.svg @@ -0,0 +1,18 @@ + + + + + + + + + + + + diff --git a/assets/icons/Шаги.svg b/assets/icons/Шаги.svg new file mode 100644 index 00000000..14563821 --- /dev/null +++ b/assets/icons/Шаги.svg @@ -0,0 +1,18 @@ + + + + + + + + + + + + diff --git a/assets/icons/калорийность.svg b/assets/icons/калорийность.svg new file mode 100644 index 00000000..329d1bda --- /dev/null +++ b/assets/icons/калорийность.svg @@ -0,0 +1,18 @@ + + + + + + + + + + + + diff --git a/assets/icons/легкая.svg b/assets/icons/легкая.svg new file mode 100644 index 00000000..1f752bc3 --- /dev/null +++ b/assets/icons/легкая.svg @@ -0,0 +1,18 @@ + + + + + + + + + + + + diff --git a/assets/icons/овощи.svg b/assets/icons/овощи.svg new file mode 100644 index 00000000..3d0d4eba --- /dev/null +++ b/assets/icons/овощи.svg @@ -0,0 +1,18 @@ + + + + + + + + + + + + diff --git a/assets/icons/поддержание формы.svg b/assets/icons/поддержание формы.svg new file mode 100644 index 00000000..eb3aca15 --- /dev/null +++ b/assets/icons/поддержание формы.svg @@ -0,0 +1,18 @@ + + + + + + + + + + + + diff --git a/assets/icons/поддержка.svg b/assets/icons/поддержка.svg new file mode 100644 index 00000000..84b48d66 --- /dev/null +++ b/assets/icons/поддержка.svg @@ -0,0 +1,18 @@ + + + + + + + + + + + + diff --git a/assets/icons/похудения.svg b/assets/icons/похудения.svg new file mode 100644 index 00000000..680582a8 --- /dev/null +++ b/assets/icons/похудения.svg @@ -0,0 +1,18 @@ + + + + + + + + + + + + diff --git a/assets/icons/углеводная.svg b/assets/icons/углеводная.svg new file mode 100644 index 00000000..3926c874 --- /dev/null +++ b/assets/icons/углеводная.svg @@ -0,0 +1,18 @@ + + + + + + + + + + + + diff --git a/assets/icons/улучшение самочувствия.svg b/assets/icons/улучшение самочувствия.svg new file mode 100644 index 00000000..0a66c836 --- /dev/null +++ b/assets/icons/улучшение самочувствия.svg @@ -0,0 +1,18 @@ + + + + + + + + + + + + diff --git a/assets/icons/формирование пище.svg b/assets/icons/формирование пище.svg new file mode 100644 index 00000000..a50c9209 --- /dev/null +++ b/assets/icons/формирование пище.svg @@ -0,0 +1,18 @@ + + + + + + + + + + + + diff --git a/assets/icons/хорошее.svg b/assets/icons/хорошее.svg new file mode 100644 index 00000000..430bea61 --- /dev/null +++ b/assets/icons/хорошее.svg @@ -0,0 +1,18 @@ + + + + + + + + + + + + diff --git a/assets/icons/хорошеее.svg b/assets/icons/хорошеее.svg new file mode 100644 index 00000000..8f45b384 --- /dev/null +++ b/assets/icons/хорошеее.svg @@ -0,0 +1,18 @@ + + + + + + + + + + + + diff --git a/assets/icons/этапы шаги.svg b/assets/icons/этапы шаги.svg new file mode 100644 index 00000000..8bb51a1c --- /dev/null +++ b/assets/icons/этапы шаги.svg @@ -0,0 +1,18 @@ + + + + + + + + + + + + diff --git a/assets/rive_animations/loading.riv b/assets/rive_animations/loading.riv new file mode 100644 index 00000000..d328f26d Binary files /dev/null and b/assets/rive_animations/loading.riv differ diff --git a/flutter_01.log b/flutter_01.log deleted file mode 100644 index f7f3c20d..00000000 --- a/flutter_01.log +++ /dev/null @@ -1,97 +0,0 @@ -Flutter crash report. -Please report a bug at https://github.com/flutter/flutter/issues. - -## command - -flutter analyze - -## exception - -PathNotFoundException: PathNotFoundException: Cannot open file, path = '/home/alex/snap/flutter/common/flutter/version' (OS Error: No such file or directory, errno = 2) - -``` -#0 _File.throwIfError (dart:io/file_impl.dart:675:7) -#1 _File.openSync (dart:io/file_impl.dart:490:5) -#2 _File.readAsBytesSync (dart:io/file_impl.dart:574:18) -#3 _File.readAsStringSync (dart:io/file_impl.dart:624:18) -#4 ForwardingFile.readAsStringSync (package:file/src/forwarding/forwarding_file.dart:99:16) -#5 ErrorHandlingFile.readAsStringSync. (package:flutter_tools/src/base/error_handling_io.dart:217:22) -#6 _runSync (package:flutter_tools/src/base/error_handling_io.dart:587:14) -#7 ErrorHandlingFile.readAsStringSync (package:flutter_tools/src/base/error_handling_io.dart:216:12) -#8 _DefaultPub.get (package:flutter_tools/src/dart/pub.dart:302:58) -#9 FlutterCommand.verifyThenRunCommand (package:flutter_tools/src/runner/flutter_command.dart:1724:17) - -#10 FlutterCommand.run. (package:flutter_tools/src/runner/flutter_command.dart:1394:27) - -#11 AppContext.run. (package:flutter_tools/src/base/context.dart:153:19) - -#12 CommandRunner.runCommand (package:args/command_runner.dart:212:13) - -#13 FlutterCommandRunner.runCommand. (package:flutter_tools/src/runner/flutter_command_runner.dart:372:9) - -#14 AppContext.run. (package:flutter_tools/src/base/context.dart:153:19) - -#15 FlutterCommandRunner.runCommand (package:flutter_tools/src/runner/flutter_command_runner.dart:308:5) - -#16 run.. (package:flutter_tools/runner.dart:130:9) - -#17 AppContext.run. (package:flutter_tools/src/base/context.dart:153:19) - -#18 main (package:flutter_tools/executable.dart:93:3) - -``` - -## flutter doctor - -``` -[!] Flutter (Channel [user-branch], 0.0.0-unknown, on Ubuntu 24.04 LTS 6.8.0-38-generic, locale ru_RU.UTF-8) - ! Flutter version 0.0.0-unknown on channel [user-branch] at /home/alex/snap/flutter/common/flutter - Currently on an unknown channel. Run `flutter channel` to switch to an official channel. - If that doesn't fix the issue, reinstall Flutter by following instructions at https://flutter.dev/docs/get-started/install. - Cannot resolve current version, possibly due to local changes. - Reinstall Flutter by following instructions at https://flutter.dev/docs/get-started/install. - ! Upstream repository unknown source is not a standard remote. - Set environment variable "FLUTTER_GIT_URL" to unknown source to dismiss this error. - • Framework revision (), 1970-01-01 03:00:00.000 - • Engine revision edd8546116 - • Dart version 3.4.3 - • DevTools version 2.34.3 - • If those were intentional, you can disregard the above warnings; however it is recommended to use "git" directly to perform update checks and upgrades. - -[✓] Android toolchain - develop for Android devices (Android SDK version 35.0.0) - • Android SDK at /home/alex/Android/Sdk - • Platform android-35, build-tools 35.0.0 - • Java binary at: /snap/android-studio/161/jbr/bin/java - • Java version OpenJDK Runtime Environment (build 17.0.10+0-17.0.10b1087.21-11609105) - • All Android licenses accepted. - -[✓] Chrome - develop for the web - • Chrome at google-chrome - -[✓] Linux toolchain - develop for Linux desktop - • clang version 10.0.0-4ubuntu1 - • cmake version 3.16.3 - • ninja version 1.10.0 - • pkg-config version 0.29.1 - -[✓] Android Studio (version 2024.1) - • Android Studio at /snap/android-studio/161 - • Flutter plugin version 80.0.2 - • Dart plugin can be installed from: - 🔨 https://plugins.jetbrains.com/plugin/6351-dart - • Java version OpenJDK Runtime Environment (build 17.0.10+0-17.0.10b1087.21-11609105) - -[✓] VS Code (version 1.91.1) - • VS Code at /usr/share/code - • Flutter extension version 3.92.0 - -[✓] Connected device (3 available) - • sdk gphone64 x86 64 (mobile) • emulator-5554 • android-x64 • Android 15 (API 35) (emulator) - • Linux (desktop) • linux • linux-x64 • Ubuntu 24.04 LTS 6.8.0-38-generic - • Chrome (web) • chrome • web-javascript • Google Chrome 126.0.6478.126 - -[✓] Network resources - • All expected network resources are available. - -! Doctor found issues in 1 category. -``` diff --git a/lib/app_router.dart b/lib/app_router.dart index f872ddc9..e54fe2da 100644 --- a/lib/app_router.dart +++ b/lib/app_router.dart @@ -15,19 +15,28 @@ 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/plans/models/plan_pagination_model.dart'; +import 'package:eatvio_app/features/plans/presentation/pages/about_plan_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'; import 'package:eatvio_app/features/recipes/presentation/pages/recipe_edit_screen.dart'; import 'package:eatvio_app/features/registration/presentation/pages/registration_screen.dart'; -import 'package:eatvio_app/presentation/auth/auth_screen/auth_screen.dart'; -import 'package:eatvio_app/presentation/diets/diet_create_screen/diet_create_screen.dart'; -import 'package:eatvio_app/presentation/diets/diet_select_screen/diet_select_screen.dart'; -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_settings_screen.dart'; -import 'package:eatvio_app/presentation/recipe/recipe_select_screen/recipe_select_screen.dart'; +import 'package:eatvio_app/features/settings/entities/settings_entity.dart'; +import 'package:eatvio_app/features/settings/presentation/pages/change_password_screen.dart'; +import 'package:eatvio_app/features/settings/presentation/pages/general_info_screen.dart'; +import 'package:eatvio_app/features/settings/presentation/pages/other_info_screen.dart'; +import 'package:eatvio_app/features/settings/presentation/pages/physical_activity_screen.dart'; +import 'package:eatvio_app/features/settings/presentation/pages/physical_form_screen.dart'; +import 'package:eatvio_app/features/settings/presentation/pages/pressure_screen.dart'; +import 'package:eatvio_app/features/settings/presentation/pages/settings_screen.dart'; +import 'package:eatvio_app/old/auth/auth_screen/auth_screen.dart'; +import 'package:eatvio_app/old/diets/diet_create_screen/diet_create_screen.dart'; +import 'package:eatvio_app/old/diets/diet_select_screen/diet_select_screen.dart'; +import 'package:eatvio_app/old/glossary/glossary_screen/glossary_screen.dart'; +import 'package:eatvio_app/old/plans/plan_select_screen/plan_select_screen.dart'; +import 'package:eatvio_app/old/profile/my_profile_screen/my_settings_screen.dart'; +import 'package:eatvio_app/old/recipe/recipe_select_screen/recipe_select_screen.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:go_router/go_router.dart'; @@ -103,6 +112,13 @@ class AppRouter { ), ], ), + GoRoute( + path: '/about-plan-screen', + name: 'aboutPlanScreen', + builder: (context, state) => AboutPlanScreen( + planModel: state.extra as PlanModel, + ), + ), GoRoute( path: '/about-recipes-screen', name: 'aboutRecipesScreen', @@ -133,7 +149,7 @@ class AppRouter { path: '/about-diet-screen', name: 'aboutDietScreen', builder: (context, state) => AboutDietScreen( - datum: state.extra as Datum, + diet: state.extra as Diet, ), ), GoRoute( @@ -146,19 +162,60 @@ class AppRouter { name: 'blogPostScreen', builder: (context, state) => BlogPostScreen(blogPost: state.extra as FeedBlogPostModel), ), - GoRoute( - path: '/blog-post-edit-screen', - name: 'blogPostEditScreen', - builder: (context, state) => BlogPostEditScreen.builder( - context, - state.extra, - ), - ), GoRoute( path: '/chat-screen', name: 'chatScreen', builder: (context, state) => ChatScreen(chatId: state.extra as String), ), + GoRoute( + path: '/settings-screen', + name: 'settingsScreen', + builder: (context, state) => SettingsScreen(), + routes: [ + GoRoute( + path: 'general-info-screen', + name: 'generalInfoScreen', + builder: (context, state) => GeneralInfoScreen( + settingsEntity: state.extra as SettingsEntity, + ), + ), + GoRoute( + path: 'other-info-screen', + name: 'otherInfoScreen', + builder: (context, state) => OtherInfoScreen( + settingsEntity: state.extra as SettingsEntity, + ), + ), + GoRoute( + path: 'physical-activity-screen', + name: 'physicalActivityScreen', + builder: (context, state) => PhysicalActivityScreen( + settingsEntity: state.extra as SettingsEntity, + ), + ), + GoRoute( + path: 'physical-form-screen', + name: 'physicalFormScreen', + builder: (context, state) => PhysicalFormScreen( + settingsEntity: state.extra as SettingsEntity, + ), + ), + GoRoute( + path: 'pressure-screen', + name: 'pressureScreen', + builder: (context, state) => PressureScreen( + settingsEntity: state.extra as SettingsEntity, + ), + ), + GoRoute( + path: 'change-password-screen', + name: 'changePasswordScreen', + builder: (context, state) => ChangePasswordScreen( + settingsEntity: state.extra as SettingsEntity, + ), + ), + ], + ), GoRoute( path: '/my-settings-screen', name: 'mySettingsScreen', diff --git a/lib/core/app_export.dart b/lib/core/app_export.dart deleted file mode 100644 index 88b3fe01..00000000 --- a/lib/core/app_export.dart +++ /dev/null @@ -1,14 +0,0 @@ -export 'package:eatvio_app/core/constants/constants.dart'; -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/size_utils.dart'; -export 'package:eatvio_app/data/models/selectionPopupModel/selection_popup_model.dart'; -export 'package:eatvio_app/localization/app_localization.dart'; -export 'package:eatvio_app/theme/app_decoration.dart'; -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/custom_button_style.dart'; diff --git a/lib/core/constants/constants.dart b/lib/core/const.dart similarity index 100% rename from lib/core/constants/constants.dart rename to lib/core/const.dart diff --git a/lib/core/errors/exceptions.dart b/lib/core/errors/exceptions.dart deleted file mode 100644 index 7cbb3f19..00000000 --- a/lib/core/errors/exceptions.dart +++ /dev/null @@ -1,25 +0,0 @@ -import 'package:eatvio_app/main.dart'; -import 'package:flutter/material.dart'; - -class ServerException implements Exception {} - -class CacheException implements Exception {} - -class NetworkException implements Exception {} - -///can be used for throwing [NoInternetException] -class NoInternetException implements Exception { - late String _message; - - NoInternetException([String message = 'NoInternetException Occurred']) { - if (globalMessengerKey.currentState != null) { - globalMessengerKey.currentState!.showSnackBar(SnackBar(content: Text(message))); - } - this._message = message; - } - - @override - String toString() { - return _message; - } -} diff --git a/lib/core/errors/failures.dart b/lib/core/errors/failures.dart deleted file mode 100644 index a96b786a..00000000 --- a/lib/core/errors/failures.dart +++ /dev/null @@ -1,8 +0,0 @@ -abstract class Failure {} - -// General failures -class ServerFailure extends Failure {} - -class CacheFailure extends Failure {} - -class NetworkFailure extends Failure {} diff --git a/lib/core/initialization_cubit/initialization_cubit.dart b/lib/core/initialization_cubit/initialization_cubit.dart index 518abeba..da7588cd 100644 --- a/lib/core/initialization_cubit/initialization_cubit.dart +++ b/lib/core/initialization_cubit/initialization_cubit.dart @@ -1,11 +1,12 @@ import 'package:dart_pusher_channels/dart_pusher_channels.dart'; -import 'package:eatvio_app/core/app_export.dart'; +import 'package:eatvio_app/core/const.dart'; import 'package:eatvio_app/core/initialization_cubit/initialization_state.dart'; import 'package:eatvio_app/core/token_storage.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/chat/repositories/chat_repository.dart'; import 'package:eatvio_app/locator_service.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; class InitializationCubit extends Cubit { final ChatRepository chatRepository; diff --git a/lib/core/initialization_cubit/initialization_state.freezed.dart b/lib/core/initialization_cubit/initialization_state.freezed.dart index 3364e440..b0535c68 100644 --- a/lib/core/initialization_cubit/initialization_state.freezed.dart +++ b/lib/core/initialization_cubit/initialization_state.freezed.dart @@ -84,6 +84,9 @@ 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 @@ -100,6 +103,9 @@ 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 @@ -218,6 +224,9 @@ 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 @@ -339,6 +348,8 @@ 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({ @@ -377,7 +388,9 @@ class _$InitializationStateSuccessImpl implements InitializationStateSuccess { @override int get hashCode => Object.hash(runtimeType, client); - @JsonKey(ignore: true) + /// Create a copy of InitializationState + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$InitializationStateSuccessImplCopyWith<_$InitializationStateSuccessImpl> @@ -465,7 +478,10 @@ abstract class InitializationStateSuccess implements InitializationState { _$InitializationStateSuccessImpl; PusherChannelsClient get client; - @JsonKey(ignore: true) + + /// Create a copy of InitializationState + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) _$$InitializationStateSuccessImplCopyWith<_$InitializationStateSuccessImpl> get copyWith => throw _privateConstructorUsedError; } @@ -490,6 +506,8 @@ 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({ @@ -529,7 +547,9 @@ class _$InitializationStateErrorImpl implements InitializationStateError { @override int get hashCode => Object.hash(runtimeType, errorMessage); - @JsonKey(ignore: true) + /// Create a copy of InitializationState + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$InitializationStateErrorImplCopyWith<_$InitializationStateErrorImpl> @@ -616,7 +636,10 @@ abstract class InitializationStateError implements InitializationState { _$InitializationStateErrorImpl; String get errorMessage; - @JsonKey(ignore: true) + + /// Create a copy of InitializationState + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) _$$InitializationStateErrorImplCopyWith<_$InitializationStateErrorImpl> get copyWith => throw _privateConstructorUsedError; } diff --git a/lib/core/models/pagination_model.dart b/lib/core/models/pagination_model.dart new file mode 100644 index 00000000..d54863b6 --- /dev/null +++ b/lib/core/models/pagination_model.dart @@ -0,0 +1,43 @@ +import 'package:freezed_annotation/freezed_annotation.dart'; + +part 'pagination_model.freezed.dart'; +part 'pagination_model.g.dart'; + +@freezed +class Links with _$Links { + const factory Links({ + @JsonKey(name: "first") required String first, + @JsonKey(name: "last") required String last, + @JsonKey(name: "prev") required dynamic prev, + @JsonKey(name: "next") required dynamic next, + }) = _Links; + + factory Links.fromJson(Map json) => _$LinksFromJson(json); +} + +@freezed +class Meta with _$Meta { + const factory Meta({ + @JsonKey(name: "current_page") required int currentPage, + @JsonKey(name: "from") required dynamic from, + @JsonKey(name: "last_page") required int lastPage, + @JsonKey(name: "links") required List links, + @JsonKey(name: "path") String? path, + @JsonKey(name: "per_page") required int perPage, + @JsonKey(name: "to") required dynamic to, + @JsonKey(name: "total") required int total, + }) = _Meta; + + factory Meta.fromJson(Map json) => _$MetaFromJson(json); +} + +@freezed +class Link with _$Link { + const factory Link({ + @JsonKey(name: "url") String? url, + @JsonKey(name: "label") String? label, + @JsonKey(name: "active") bool? active, + }) = _Link; + + factory Link.fromJson(Map json) => _$LinkFromJson(json); +} diff --git a/lib/core/models/pagination_model.freezed.dart b/lib/core/models/pagination_model.freezed.dart new file mode 100644 index 00000000..35f2c080 --- /dev/null +++ b/lib/core/models/pagination_model.freezed.dart @@ -0,0 +1,768 @@ +// 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 'pagination_model.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'); + +Links _$LinksFromJson(Map json) { + return _Links.fromJson(json); +} + +/// @nodoc +mixin _$Links { + @JsonKey(name: "first") + String get first => throw _privateConstructorUsedError; + @JsonKey(name: "last") + String get last => throw _privateConstructorUsedError; + @JsonKey(name: "prev") + dynamic get prev => throw _privateConstructorUsedError; + @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) + $LinksCopyWith get copyWith => throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $LinksCopyWith<$Res> { + factory $LinksCopyWith(Links value, $Res Function(Links) then) = + _$LinksCopyWithImpl<$Res, Links>; + @useResult + $Res call( + {@JsonKey(name: "first") String first, + @JsonKey(name: "last") String last, + @JsonKey(name: "prev") dynamic prev, + @JsonKey(name: "next") dynamic next}); +} + +/// @nodoc +class _$LinksCopyWithImpl<$Res, $Val extends Links> + implements $LinksCopyWith<$Res> { + _$LinksCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // 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({ + Object? first = null, + Object? last = null, + Object? prev = freezed, + Object? next = freezed, + }) { + return _then(_value.copyWith( + first: null == first + ? _value.first + : first // ignore: cast_nullable_to_non_nullable + as String, + last: null == last + ? _value.last + : last // ignore: cast_nullable_to_non_nullable + as String, + prev: freezed == prev + ? _value.prev + : prev // ignore: cast_nullable_to_non_nullable + as dynamic, + next: freezed == next + ? _value.next + : next // ignore: cast_nullable_to_non_nullable + as dynamic, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$LinksImplCopyWith<$Res> implements $LinksCopyWith<$Res> { + factory _$$LinksImplCopyWith( + _$LinksImpl value, $Res Function(_$LinksImpl) then) = + __$$LinksImplCopyWithImpl<$Res>; + @override + @useResult + $Res call( + {@JsonKey(name: "first") String first, + @JsonKey(name: "last") String last, + @JsonKey(name: "prev") dynamic prev, + @JsonKey(name: "next") dynamic next}); +} + +/// @nodoc +class __$$LinksImplCopyWithImpl<$Res> + extends _$LinksCopyWithImpl<$Res, _$LinksImpl> + implements _$$LinksImplCopyWith<$Res> { + __$$LinksImplCopyWithImpl( + _$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({ + Object? first = null, + Object? last = null, + Object? prev = freezed, + Object? next = freezed, + }) { + return _then(_$LinksImpl( + first: null == first + ? _value.first + : first // ignore: cast_nullable_to_non_nullable + as String, + last: null == last + ? _value.last + : last // ignore: cast_nullable_to_non_nullable + as String, + prev: freezed == prev + ? _value.prev + : prev // ignore: cast_nullable_to_non_nullable + as dynamic, + next: freezed == next + ? _value.next + : next // ignore: cast_nullable_to_non_nullable + as dynamic, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$LinksImpl implements _Links { + const _$LinksImpl( + {@JsonKey(name: "first") required this.first, + @JsonKey(name: "last") required this.last, + @JsonKey(name: "prev") required this.prev, + @JsonKey(name: "next") required this.next}); + + factory _$LinksImpl.fromJson(Map json) => + _$$LinksImplFromJson(json); + + @override + @JsonKey(name: "first") + final String first; + @override + @JsonKey(name: "last") + final String last; + @override + @JsonKey(name: "prev") + final dynamic prev; + @override + @JsonKey(name: "next") + final dynamic next; + + @override + String toString() { + return 'Links(first: $first, last: $last, prev: $prev, next: $next)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$LinksImpl && + (identical(other.first, first) || other.first == first) && + (identical(other.last, last) || other.last == last) && + const DeepCollectionEquality().equals(other.prev, prev) && + const DeepCollectionEquality().equals(other.next, next)); + } + + @JsonKey(includeFromJson: false, includeToJson: false) + @override + int get hashCode => Object.hash( + runtimeType, + first, + last, + 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) + @override + @pragma('vm:prefer-inline') + _$$LinksImplCopyWith<_$LinksImpl> get copyWith => + __$$LinksImplCopyWithImpl<_$LinksImpl>(this, _$identity); + + @override + Map toJson() { + return _$$LinksImplToJson( + this, + ); + } +} + +abstract class _Links implements Links { + const factory _Links( + {@JsonKey(name: "first") required final String first, + @JsonKey(name: "last") required final String last, + @JsonKey(name: "prev") required final dynamic prev, + @JsonKey(name: "next") required final dynamic next}) = _$LinksImpl; + + factory _Links.fromJson(Map json) = _$LinksImpl.fromJson; + + @override + @JsonKey(name: "first") + String get first; + @override + @JsonKey(name: "last") + String get last; + @override + @JsonKey(name: "prev") + dynamic get prev; + @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) + _$$LinksImplCopyWith<_$LinksImpl> get copyWith => + throw _privateConstructorUsedError; +} + +Meta _$MetaFromJson(Map json) { + return _Meta.fromJson(json); +} + +/// @nodoc +mixin _$Meta { + @JsonKey(name: "current_page") + int get currentPage => throw _privateConstructorUsedError; + @JsonKey(name: "from") + dynamic get from => throw _privateConstructorUsedError; + @JsonKey(name: "last_page") + int get lastPage => throw _privateConstructorUsedError; + @JsonKey(name: "links") + List get links => throw _privateConstructorUsedError; + @JsonKey(name: "path") + String? get path => throw _privateConstructorUsedError; + @JsonKey(name: "per_page") + int get perPage => throw _privateConstructorUsedError; + @JsonKey(name: "to") + dynamic get to => throw _privateConstructorUsedError; + @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) + $MetaCopyWith get copyWith => throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $MetaCopyWith<$Res> { + factory $MetaCopyWith(Meta value, $Res Function(Meta) then) = + _$MetaCopyWithImpl<$Res, Meta>; + @useResult + $Res call( + {@JsonKey(name: "current_page") int currentPage, + @JsonKey(name: "from") dynamic from, + @JsonKey(name: "last_page") int lastPage, + @JsonKey(name: "links") List links, + @JsonKey(name: "path") String? path, + @JsonKey(name: "per_page") int perPage, + @JsonKey(name: "to") dynamic to, + @JsonKey(name: "total") int total}); +} + +/// @nodoc +class _$MetaCopyWithImpl<$Res, $Val extends Meta> + implements $MetaCopyWith<$Res> { + _$MetaCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // 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({ + Object? currentPage = null, + Object? from = freezed, + Object? lastPage = null, + Object? links = null, + Object? path = freezed, + Object? perPage = null, + Object? to = freezed, + Object? total = null, + }) { + return _then(_value.copyWith( + currentPage: null == currentPage + ? _value.currentPage + : currentPage // ignore: cast_nullable_to_non_nullable + as int, + from: freezed == from + ? _value.from + : from // ignore: cast_nullable_to_non_nullable + as dynamic, + lastPage: null == lastPage + ? _value.lastPage + : lastPage // ignore: cast_nullable_to_non_nullable + as int, + links: null == links + ? _value.links + : links // ignore: cast_nullable_to_non_nullable + as List, + path: freezed == path + ? _value.path + : path // ignore: cast_nullable_to_non_nullable + as String?, + perPage: null == perPage + ? _value.perPage + : perPage // ignore: cast_nullable_to_non_nullable + as int, + to: freezed == to + ? _value.to + : to // ignore: cast_nullable_to_non_nullable + as dynamic, + total: null == total + ? _value.total + : total // ignore: cast_nullable_to_non_nullable + as int, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$MetaImplCopyWith<$Res> implements $MetaCopyWith<$Res> { + factory _$$MetaImplCopyWith( + _$MetaImpl value, $Res Function(_$MetaImpl) then) = + __$$MetaImplCopyWithImpl<$Res>; + @override + @useResult + $Res call( + {@JsonKey(name: "current_page") int currentPage, + @JsonKey(name: "from") dynamic from, + @JsonKey(name: "last_page") int lastPage, + @JsonKey(name: "links") List links, + @JsonKey(name: "path") String? path, + @JsonKey(name: "per_page") int perPage, + @JsonKey(name: "to") dynamic to, + @JsonKey(name: "total") int total}); +} + +/// @nodoc +class __$$MetaImplCopyWithImpl<$Res> + extends _$MetaCopyWithImpl<$Res, _$MetaImpl> + implements _$$MetaImplCopyWith<$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({ + Object? currentPage = null, + Object? from = freezed, + Object? lastPage = null, + Object? links = null, + Object? path = freezed, + Object? perPage = null, + Object? to = freezed, + Object? total = null, + }) { + return _then(_$MetaImpl( + currentPage: null == currentPage + ? _value.currentPage + : currentPage // ignore: cast_nullable_to_non_nullable + as int, + from: freezed == from + ? _value.from + : from // ignore: cast_nullable_to_non_nullable + as dynamic, + lastPage: null == lastPage + ? _value.lastPage + : lastPage // ignore: cast_nullable_to_non_nullable + as int, + links: null == links + ? _value._links + : links // ignore: cast_nullable_to_non_nullable + as List, + path: freezed == path + ? _value.path + : path // ignore: cast_nullable_to_non_nullable + as String?, + perPage: null == perPage + ? _value.perPage + : perPage // ignore: cast_nullable_to_non_nullable + as int, + to: freezed == to + ? _value.to + : to // ignore: cast_nullable_to_non_nullable + as dynamic, + total: null == total + ? _value.total + : total // ignore: cast_nullable_to_non_nullable + as int, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$MetaImpl implements _Meta { + const _$MetaImpl( + {@JsonKey(name: "current_page") required this.currentPage, + @JsonKey(name: "from") required this.from, + @JsonKey(name: "last_page") required this.lastPage, + @JsonKey(name: "links") required final List links, + @JsonKey(name: "path") this.path, + @JsonKey(name: "per_page") required this.perPage, + @JsonKey(name: "to") required this.to, + @JsonKey(name: "total") required this.total}) + : _links = links; + + factory _$MetaImpl.fromJson(Map json) => + _$$MetaImplFromJson(json); + + @override + @JsonKey(name: "current_page") + final int currentPage; + @override + @JsonKey(name: "from") + final dynamic from; + @override + @JsonKey(name: "last_page") + final int lastPage; + final List _links; + @override + @JsonKey(name: "links") + List get links { + if (_links is EqualUnmodifiableListView) return _links; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(_links); + } + + @override + @JsonKey(name: "path") + final String? path; + @override + @JsonKey(name: "per_page") + final int perPage; + @override + @JsonKey(name: "to") + final dynamic to; + @override + @JsonKey(name: "total") + final int total; + + @override + String toString() { + return 'Meta(currentPage: $currentPage, from: $from, lastPage: $lastPage, links: $links, path: $path, perPage: $perPage, to: $to, total: $total)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$MetaImpl && + (identical(other.currentPage, currentPage) || + other.currentPage == currentPage) && + const DeepCollectionEquality().equals(other.from, from) && + (identical(other.lastPage, lastPage) || + other.lastPage == lastPage) && + const DeepCollectionEquality().equals(other._links, _links) && + (identical(other.path, path) || other.path == path) && + (identical(other.perPage, perPage) || other.perPage == perPage) && + const DeepCollectionEquality().equals(other.to, to) && + (identical(other.total, total) || other.total == total)); + } + + @JsonKey(includeFromJson: false, includeToJson: false) + @override + int get hashCode => Object.hash( + runtimeType, + currentPage, + const DeepCollectionEquality().hash(from), + lastPage, + const DeepCollectionEquality().hash(_links), + path, + perPage, + const DeepCollectionEquality().hash(to), + total); + + /// Create a copy of Meta + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$MetaImplCopyWith<_$MetaImpl> get copyWith => + __$$MetaImplCopyWithImpl<_$MetaImpl>(this, _$identity); + + @override + Map toJson() { + return _$$MetaImplToJson( + this, + ); + } +} + +abstract class _Meta implements Meta { + const factory _Meta( + {@JsonKey(name: "current_page") required final int currentPage, + @JsonKey(name: "from") required final dynamic from, + @JsonKey(name: "last_page") required final int lastPage, + @JsonKey(name: "links") required final List links, + @JsonKey(name: "path") final String? path, + @JsonKey(name: "per_page") required final int perPage, + @JsonKey(name: "to") required final dynamic to, + @JsonKey(name: "total") required final int total}) = _$MetaImpl; + + factory _Meta.fromJson(Map json) = _$MetaImpl.fromJson; + + @override + @JsonKey(name: "current_page") + int get currentPage; + @override + @JsonKey(name: "from") + dynamic get from; + @override + @JsonKey(name: "last_page") + int get lastPage; + @override + @JsonKey(name: "links") + List get links; + @override + @JsonKey(name: "path") + String? get path; + @override + @JsonKey(name: "per_page") + int get perPage; + @override + @JsonKey(name: "to") + dynamic get to; + @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) + _$$MetaImplCopyWith<_$MetaImpl> get copyWith => + throw _privateConstructorUsedError; +} + +Link _$LinkFromJson(Map json) { + return _Link.fromJson(json); +} + +/// @nodoc +mixin _$Link { + @JsonKey(name: "url") + String? get url => throw _privateConstructorUsedError; + @JsonKey(name: "label") + String? get label => throw _privateConstructorUsedError; + @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) + $LinkCopyWith get copyWith => throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $LinkCopyWith<$Res> { + factory $LinkCopyWith(Link value, $Res Function(Link) then) = + _$LinkCopyWithImpl<$Res, Link>; + @useResult + $Res call( + {@JsonKey(name: "url") String? url, + @JsonKey(name: "label") String? label, + @JsonKey(name: "active") bool? active}); +} + +/// @nodoc +class _$LinkCopyWithImpl<$Res, $Val extends Link> + implements $LinkCopyWith<$Res> { + _$LinkCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // 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({ + Object? url = freezed, + Object? label = freezed, + Object? active = freezed, + }) { + return _then(_value.copyWith( + url: freezed == url + ? _value.url + : url // ignore: cast_nullable_to_non_nullable + as String?, + label: freezed == label + ? _value.label + : label // ignore: cast_nullable_to_non_nullable + as String?, + active: freezed == active + ? _value.active + : active // ignore: cast_nullable_to_non_nullable + as bool?, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$LinkImplCopyWith<$Res> implements $LinkCopyWith<$Res> { + factory _$$LinkImplCopyWith( + _$LinkImpl value, $Res Function(_$LinkImpl) then) = + __$$LinkImplCopyWithImpl<$Res>; + @override + @useResult + $Res call( + {@JsonKey(name: "url") String? url, + @JsonKey(name: "label") String? label, + @JsonKey(name: "active") bool? active}); +} + +/// @nodoc +class __$$LinkImplCopyWithImpl<$Res> + extends _$LinkCopyWithImpl<$Res, _$LinkImpl> + implements _$$LinkImplCopyWith<$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({ + Object? url = freezed, + Object? label = freezed, + Object? active = freezed, + }) { + return _then(_$LinkImpl( + url: freezed == url + ? _value.url + : url // ignore: cast_nullable_to_non_nullable + as String?, + label: freezed == label + ? _value.label + : label // ignore: cast_nullable_to_non_nullable + as String?, + active: freezed == active + ? _value.active + : active // ignore: cast_nullable_to_non_nullable + as bool?, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$LinkImpl implements _Link { + const _$LinkImpl( + {@JsonKey(name: "url") this.url, + @JsonKey(name: "label") this.label, + @JsonKey(name: "active") this.active}); + + factory _$LinkImpl.fromJson(Map json) => + _$$LinkImplFromJson(json); + + @override + @JsonKey(name: "url") + final String? url; + @override + @JsonKey(name: "label") + final String? label; + @override + @JsonKey(name: "active") + final bool? active; + + @override + String toString() { + return 'Link(url: $url, label: $label, active: $active)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$LinkImpl && + (identical(other.url, url) || other.url == url) && + (identical(other.label, label) || other.label == label) && + (identical(other.active, active) || other.active == active)); + } + + @JsonKey(includeFromJson: false, includeToJson: false) + @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) + @override + @pragma('vm:prefer-inline') + _$$LinkImplCopyWith<_$LinkImpl> get copyWith => + __$$LinkImplCopyWithImpl<_$LinkImpl>(this, _$identity); + + @override + Map toJson() { + return _$$LinkImplToJson( + this, + ); + } +} + +abstract class _Link implements Link { + const factory _Link( + {@JsonKey(name: "url") final String? url, + @JsonKey(name: "label") final String? label, + @JsonKey(name: "active") final bool? active}) = _$LinkImpl; + + factory _Link.fromJson(Map json) = _$LinkImpl.fromJson; + + @override + @JsonKey(name: "url") + String? get url; + @override + @JsonKey(name: "label") + String? get label; + @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) + _$$LinkImplCopyWith<_$LinkImpl> get copyWith => + throw _privateConstructorUsedError; +} diff --git a/lib/core/models/pagination_model.g.dart b/lib/core/models/pagination_model.g.dart new file mode 100644 index 00000000..610d19b2 --- /dev/null +++ b/lib/core/models/pagination_model.g.dart @@ -0,0 +1,60 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'pagination_model.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +_$LinksImpl _$$LinksImplFromJson(Map json) => _$LinksImpl( + first: json['first'] as String, + last: json['last'] as String, + prev: json['prev'], + next: json['next'], + ); + +Map _$$LinksImplToJson(_$LinksImpl instance) => + { + 'first': instance.first, + 'last': instance.last, + 'prev': instance.prev, + 'next': instance.next, + }; + +_$MetaImpl _$$MetaImplFromJson(Map json) => _$MetaImpl( + currentPage: (json['current_page'] as num).toInt(), + from: json['from'], + lastPage: (json['last_page'] as num).toInt(), + links: (json['links'] as List) + .map((e) => Link.fromJson(e as Map)) + .toList(), + path: json['path'] as String?, + perPage: (json['per_page'] as num).toInt(), + to: json['to'], + total: (json['total'] as num).toInt(), + ); + +Map _$$MetaImplToJson(_$MetaImpl instance) => + { + 'current_page': instance.currentPage, + 'from': instance.from, + 'last_page': instance.lastPage, + 'links': instance.links, + 'path': instance.path, + 'per_page': instance.perPage, + 'to': instance.to, + 'total': instance.total, + }; + +_$LinkImpl _$$LinkImplFromJson(Map json) => _$LinkImpl( + url: json['url'] as String?, + label: json['label'] as String?, + active: json['active'] as bool?, + ); + +Map _$$LinkImplToJson(_$LinkImpl instance) => + { + 'url': instance.url, + 'label': instance.label, + 'active': instance.active, + }; diff --git a/lib/core/utils/date_time_utils.dart b/lib/core/utils/date_time_utils.dart index efa7b572..574799cd 100644 --- a/lib/core/utils/date_time_utils.dart +++ b/lib/core/utils/date_time_utils.dart @@ -4,7 +4,6 @@ import 'package:intl/intl.dart'; const String dateTimeFormatPattern = 'dd/MM/yyyy'; extension DateTimeExtension on DateTime { - /// Return a string representing [date] formatted according to our locale String format([ String pattern = dateTimeFormatPattern, String? locale, diff --git a/lib/core/utils/logger.dart b/lib/core/utils/logger.dart deleted file mode 100644 index dab50c2a..00000000 --- a/lib/core/utils/logger.dart +++ /dev/null @@ -1,15 +0,0 @@ -class Logger { - static LogMode _logMode = LogMode.debug; - - static void init(LogMode mode) { - Logger._logMode = mode; - } - - static void log(dynamic data, {StackTrace? stackTrace}) { - if (_logMode == LogMode.debug) { - print("Error: $data$stackTrace"); - } - } -} - -enum LogMode { debug, live } diff --git a/lib/core/utils/progress_dialog_utils.dart b/lib/core/utils/progress_dialog_utils.dart deleted file mode 100644 index ced3347c..00000000 --- a/lib/core/utils/progress_dialog_utils.dart +++ /dev/null @@ -1,33 +0,0 @@ -import 'package:eatvio_app/app_router.dart'; -import 'package:flutter/material.dart'; - -class ProgressDialogUtils { - static bool isProgressVisible = false; - - ///common method for showing progress dialog - static void showProgressDialog({BuildContext? context, isCancellable = false}) async { - if (!isProgressVisible && AppRouter.navigatorKey.currentState?.overlay?.context != null) { - showDialog( - barrierDismissible: isCancellable, - context: AppRouter.navigatorKey.currentState!.overlay!.context, - builder: (BuildContext context) { - return Center( - child: CircularProgressIndicator.adaptive( - strokeWidth: 4, - valueColor: AlwaysStoppedAnimation( - Colors.white, - ), - ), - ); - }, - ); - isProgressVisible = true; - } - } - - ///common method for hiding progress dialog - static void hideProgressDialog() { - if (isProgressVisible) Navigator.pop(AppRouter.navigatorKey.currentState!.overlay!.context); - isProgressVisible = false; - } -} diff --git a/lib/core/utils/size_utils.dart b/lib/core/utils/size_utils.dart deleted file mode 100644 index 04f09c8a..00000000 --- a/lib/core/utils/size_utils.dart +++ /dev/null @@ -1,52 +0,0 @@ -import 'package:flutter/material.dart'; - -// This functions are responsible to make UI responsive across all the mobile devices. - -MediaQueryData mediaQueryData = MediaQueryData.fromView( - WidgetsBinding.instance.platformDispatcher.views.single, -); - -// These are the Viewport values of your Figma Design. -// These are used in the code as a reference to create your UI Responsively. -const num FIGMA_DESIGN_WIDTH = 375; -const num FIGMA_DESIGN_HEIGHT = 812; -const num FIGMA_DESIGN_STATUS_BAR = 0; - -///This extension is used to set padding/margin (for the top and bottom side) & height of the screen or widget according to the Viewport height. -extension ResponsiveExtension on num { - ///This method is used to get device viewport width. - get _width { - return mediaQueryData.size.width; - } - - ///This method is used to get device viewport height. - get _height { - num statusBar = mediaQueryData.viewPadding.top; - num bottomBar = mediaQueryData.viewPadding.bottom; - num screenHeight = mediaQueryData.size.height - statusBar - bottomBar; - return screenHeight; - } - - ///This method is used to set padding/margin (for the left and Right side) & width of the screen or widget according to the Viewport width. - double get h => ((this * _width) / FIGMA_DESIGN_WIDTH); - - ///This method is used to set padding/margin (for the top and bottom side) & height of the screen or widget according to the Viewport height. - double get v => (this * _height) / (FIGMA_DESIGN_HEIGHT - FIGMA_DESIGN_STATUS_BAR); - - ///This method is used to set smallest px in image height and width - double get adaptSize { - var height = v; - var width = h; - return height < width ? height.toDoubleValue() : width.toDoubleValue(); - } - - ///This method is used to set text font size according to Viewport - double get fSize => adaptSize; -} - -extension FormatExtension on double { - /// Return a [double] value with formatted according to provided fractionDigits - double toDoubleValue({int fractionDigits = 2}) { - return double.parse(this.toStringAsFixed(fractionDigits)); - } -} diff --git a/lib/data/models/selectionPopupModel/selection_popup_model.freezed.dart b/lib/data/models/selectionPopupModel/selection_popup_model.freezed.dart index 917785c7..97ab368c 100644 --- a/lib/data/models/selectionPopupModel/selection_popup_model.freezed.dart +++ b/lib/data/models/selectionPopupModel/selection_popup_model.freezed.dart @@ -21,7 +21,9 @@ mixin _$SelectionPopupModel { dynamic get value => throw _privateConstructorUsedError; bool get isSelected => throw _privateConstructorUsedError; - @JsonKey(ignore: true) + /// Create a copy of SelectionPopupModel + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) $SelectionPopupModelCopyWith get copyWith => throw _privateConstructorUsedError; } @@ -45,6 +47,8 @@ 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({ @@ -93,6 +97,8 @@ 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({ @@ -159,7 +165,9 @@ class _$SelectionPopupModelImpl implements _SelectionPopupModel { int get hashCode => Object.hash(runtimeType, id, title, const DeepCollectionEquality().hash(value), isSelected); - @JsonKey(ignore: true) + /// Create a copy of SelectionPopupModel + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$SelectionPopupModelImplCopyWith<_$SelectionPopupModelImpl> get copyWith => @@ -182,8 +190,11 @@ 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(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) _$$SelectionPopupModelImplCopyWith<_$SelectionPopupModelImpl> get copyWith => throw _privateConstructorUsedError; } diff --git a/lib/features/blog_post/presentation/pages/blog_post_screen.dart b/lib/features/blog_post/presentation/pages/blog_post_screen.dart index 27d8901a..7c27ab09 100644 --- a/lib/features/blog_post/presentation/pages/blog_post_screen.dart +++ b/lib/features/blog_post/presentation/pages/blog_post_screen.dart @@ -1,16 +1,19 @@ import 'dart:io'; - import 'package:cached_network_image/cached_network_image.dart'; -import 'package:eatvio_app/core/app_export.dart'; -import 'package:eatvio_app/features/feed/models/comment_model.dart'; +import 'package:eatvio_app/core/const.dart'; +import 'package:eatvio_app/core/utils/date_time_utils.dart'; import 'package:eatvio_app/features/feed/models/feed_blog_post_model.dart'; 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/features/feed/presentation/bloc/feed_cubit/feed_cubit.dart'; +import 'package:eatvio_app/features/feed/presentation/widgets/comments_widget.dart'; import 'package:eatvio_app/locator_service.dart'; -import 'package:flutter/cupertino.dart'; +import 'package:eatvio_app/theme/theme_helper.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:flutter_html/flutter_html.dart'; import 'package:go_router/go_router.dart'; +import 'package:rive/rive.dart'; import 'package:share_plus/share_plus.dart'; class BlogPostScreen extends StatefulWidget { @@ -31,7 +34,6 @@ class _BlogPostScreenState extends State { @override void initState() { - commentsCubit.getBlogPostComments(widget.blogPost.id); isLiked = widget.blogPost.wasLikedByMe; totalLikes = widget.blogPost.totalLikes; super.initState(); @@ -40,8 +42,20 @@ class _BlogPostScreenState extends State { @override Widget build(BuildContext context) { return BlocProvider( - create: (BuildContext context) => commentsCubit, - child: BlocBuilder( + create: (BuildContext context) => commentsCubit + ..getComments( + widget.blogPost.id.toString(), + CommentSourceType.blogPost, + true, + ), + child: BlocConsumer( + listener: (BuildContext context, CommentsState state) { + if (state is CommentsStateLoaded) { + setState(() { + replyId = state.replyId; + }); + } + }, builder: (BuildContext context, CommentsState state) { return Scaffold( resizeToAvoidBottomInset: true, @@ -61,6 +75,7 @@ class _BlogPostScreenState extends State { if (replyId != null) GestureDetector( onTap: () { + context.read().setReplyId(null); setState(() { replyId = null; textEditingController.clear(); @@ -83,7 +98,7 @@ class _BlogPostScreenState extends State { ), if (replyId != null) SizedBox(width: 8), SizedBox( - width: mediaQueryData.size.width - (replyId == null ? 64 : 104), + width: MediaQuery.of(context).size.width - (replyId == null ? 64 : 104), child: TextFormField( onChanged: (_) { setState(() {}); @@ -137,11 +152,13 @@ class _BlogPostScreenState extends State { GestureDetector( onTap: () { if (textEditingController.text.length > 2) { - commentsCubit.sendBlogPostComment( - id: widget.blogPost.id, + commentsCubit.sendComment( + id: widget.blogPost.id.toString(), commentText: textEditingController.text, parentCommentId: replyId, + commentSourceType: CommentSourceType.blogPost, ); + context.read().setReplyId(null); setState(() { textEditingController.clear(); replyId = null; @@ -215,22 +232,18 @@ class _BlogPostScreenState extends State { ), ), ), - if (widget.blogPost.description.isNotEmpty) SizedBox(height: 12), - Padding( - padding: const EdgeInsets.symmetric(horizontal: 16), - child: Align( - alignment: Alignment.centerLeft, - child: Text( - widget.blogPost.description, - style: TextStyle( - color: Colors.black, - fontSize: 14, - fontWeight: FontWeight.w400, - height: 1, - ), + if (widget.blogPost.description.isNotEmpty) + Padding( + padding: const EdgeInsets.symmetric(horizontal: 8), + child: Html( + data: widget.blogPost.description, + style: { + "*": Style( + color: Colors.black87, + ), + }, ), ), - ), SizedBox(height: 8), CachedNetworkImage( imageUrl: baseUrl + '/storage/' + (widget.blogPost.image), @@ -308,9 +321,21 @@ class _BlogPostScreenState extends State { if (state is CommentsStateLoading) Padding( padding: const EdgeInsets.all(32), - child: CupertinoActivityIndicator(), + child: SizedBox( + height: 32, + width: 32, + child: RiveAnimation.asset( + 'assets/rive_animations/loading.riv', + ), + ), + ), + if (state is CommentsStateLoaded) + CommentsWidget( + id: widget.blogPost.id.toString(), + commentSourceType: CommentSourceType.blogPost, + comment: state.comment, + replyId: replyId, ), - if (state is CommentsStateLoaded) _buildComments(state.comment), ], ), ), @@ -320,102 +345,6 @@ class _BlogPostScreenState extends State { ); } - _buildComments(Comment comment) { - return Column( - children: [ - for (int i = 0; i < comment.data.length; i++) ...[ - _comment(comment.data[i]), - if (comment.data[i].childrenComments.isNotEmpty) - for (int j = 0; j < comment.data[i].childrenComments.length; j++) - Padding( - padding: EdgeInsets.only(left: 40), - child: _comment( - comment.data[i].childrenComments[j], - 12, - ), - ), - SizedBox(height: 8), - ], - ], - ); - } - - _comment(Datum datum, [double radius = 16]) { - return Container( - width: MediaQuery.of(context).size.width, - decoration: BoxDecoration( - color: replyId == datum.id ? appTheme.blueA400.withOpacity(0.1) : Colors.white, - borderRadius: BorderRadius.circular(16), - ), - child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 16), - child: Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - CircleAvatar( - foregroundImage: NetworkImage(datum.authorProfileIcon), - radius: radius, - ), - SizedBox(width: 8), - Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisAlignment: MainAxisAlignment.start, - children: [ - Text( - datum.authorName, - style: TextStyle( - height: 1, - color: Colors.grey.shade600, - fontWeight: FontWeight.w500, - ), - ), - SizedBox(width: 4), - Text( - datum.body, - style: TextStyle( - height: 1, - color: Colors.black, - ), - ), - SizedBox(height: 4), - Row( - children: [ - Text( - widget.blogPost.createdAt.format('dd MMMM', 'ru'), - style: TextStyle( - color: Colors.grey.shade600, - fontSize: 12, - fontWeight: FontWeight.w400, - height: 1, - ), - ), - SizedBox(width: 16), - GestureDetector( - onTap: () { - setState(() { - replyId = datum.id; - }); - }, - child: Text( - 'Ответить', - style: TextStyle( - height: 1, - fontSize: 12, - color: Colors.grey.shade800, - fontWeight: FontWeight.w500, - ), - ), - ), - ], - ), - ], - ), - ], - ), - ), - ); - } - _iconButton({required IconData icon, String? text, Function()? onTap, Color? iconColor, Color? backgroundColor, Color? textColor}) { return InkWell( onTap: onTap ?? () {}, 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 d8fc116e..baf87e0f 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 @@ -1,15 +1,15 @@ import 'dart:async'; import 'dart:io'; - -import 'package:eatvio_app/core/app_export.dart'; +import 'package:eatvio_app/old/feed/blog_post_create_screen/bloc/blog_post_create_bloc.dart'; +import 'package:eatvio_app/old/feed/blog_post_create_screen/models/blog_post_create_model.dart'; +import 'package:eatvio_app/theme/app_decoration.dart'; +import 'package:eatvio_app/theme/theme_helper.dart'; import 'package:eatvio_app/widgets/custom_text_form_field.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_keyboard_visibility/flutter_keyboard_visibility.dart'; import 'package:image_picker/image_picker.dart'; -import '../../../../presentation/feed/blog_post_create_screen/bloc/blog_post_create_bloc.dart'; -import '../../../../presentation/feed/blog_post_create_screen/models/blog_post_create_model.dart'; - class BlogPostCreateScreen extends StatefulWidget { const BlogPostCreateScreen({Key? key}) : super(key: key); @@ -122,9 +122,10 @@ class _BlogPostCreateScreenState extends State { SizedBox(height: 16), if (state.image == null) Text('Ссылка на видео'), if (state.image == null) SizedBox(height: 8), - if (state.image == null) CustomTextFormField( - controller: state.youtubeURL, - ), + if (state.image == null) + CustomTextFormField( + controller: state.youtubeURL, + ), SizedBox(height: 80), ], ), diff --git a/lib/features/bottom_navigation_bar/presentation/bloc/new_messages_cubit/new_messages_cubit.dart b/lib/features/bottom_navigation_bar/presentation/bloc/new_messages_cubit/new_messages_cubit.dart index 8b2a0f5a..6f31b94b 100644 --- a/lib/features/bottom_navigation_bar/presentation/bloc/new_messages_cubit/new_messages_cubit.dart +++ b/lib/features/bottom_navigation_bar/presentation/bloc/new_messages_cubit/new_messages_cubit.dart @@ -1,5 +1,5 @@ -import 'package:eatvio_app/core/app_export.dart'; import 'package:eatvio_app/features/bottom_navigation_bar/presentation/bloc/new_messages_cubit/new_messages_state.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; class NewMessagesCubit extends Cubit { int _messagesCount = 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 02a1c4bd..7c5d7ffd 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,6 +84,9 @@ 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 @@ -100,6 +103,9 @@ 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 @@ -215,6 +221,9 @@ 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 @@ -335,6 +344,8 @@ 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({ @@ -374,7 +385,9 @@ class _$NewMessagesStateLoadedImpl implements NewMessagesStateLoaded { @override int get hashCode => Object.hash(runtimeType, messagesCount); - @JsonKey(ignore: true) + /// Create a copy of NewMessagesState + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$NewMessagesStateLoadedImplCopyWith<_$NewMessagesStateLoadedImpl> @@ -461,7 +474,10 @@ abstract class NewMessagesStateLoaded implements NewMessagesState { _$NewMessagesStateLoadedImpl; int get messagesCount; - @JsonKey(ignore: true) + + /// Create a copy of NewMessagesState + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) _$$NewMessagesStateLoadedImplCopyWith<_$NewMessagesStateLoadedImpl> get copyWith => throw _privateConstructorUsedError; } @@ -484,6 +500,8 @@ 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({ @@ -523,7 +541,9 @@ class _$NewMessagesStateErrorImpl implements NewMessagesStateError { @override int get hashCode => Object.hash(runtimeType, errorMessage); - @JsonKey(ignore: true) + /// Create a copy of NewMessagesState + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$NewMessagesStateErrorImplCopyWith<_$NewMessagesStateErrorImpl> @@ -610,7 +630,10 @@ abstract class NewMessagesStateError implements NewMessagesState { _$NewMessagesStateErrorImpl; String get errorMessage; - @JsonKey(ignore: true) + + /// Create a copy of NewMessagesState + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) _$$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 8a22b6d5..d862efa7 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 @@ -1,5 +1,5 @@ -import 'package:eatvio_app/core/app_export.dart'; import 'package:eatvio_app/features/bottom_navigation_bar/presentation/bloc/notifications_cubit/notifications_state.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; class NotificationsCubit extends Cubit { int _notificationsCount = 0; 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 4ba18f06..d634b318 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 @@ -88,6 +88,9 @@ 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 @@ -104,6 +107,9 @@ 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 @@ -225,6 +231,9 @@ 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 @@ -350,6 +359,8 @@ 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({ @@ -408,7 +419,9 @@ class _$NotificationsStateLoadedImpl implements NotificationsStateLoaded { int get hashCode => Object.hash(runtimeType, const DeepCollectionEquality().hash(_notifications), notificationsCount); - @JsonKey(ignore: true) + /// Create a copy of NotificationsState + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$NotificationsStateLoadedImplCopyWith<_$NotificationsStateLoadedImpl> @@ -501,7 +514,10 @@ abstract class NotificationsStateLoaded implements NotificationsState { List get notifications; int get notificationsCount; - @JsonKey(ignore: true) + + /// Create a copy of NotificationsState + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) _$$NotificationsStateLoadedImplCopyWith<_$NotificationsStateLoadedImpl> get copyWith => throw _privateConstructorUsedError; } @@ -526,6 +542,8 @@ 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({ @@ -565,7 +583,9 @@ class _$NotificationsStateErrorImpl implements NotificationsStateError { @override int get hashCode => Object.hash(runtimeType, errorMessage); - @JsonKey(ignore: true) + /// Create a copy of NotificationsState + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$NotificationsStateErrorImplCopyWith<_$NotificationsStateErrorImpl> @@ -656,7 +676,10 @@ abstract class NotificationsStateError implements NotificationsState { _$NotificationsStateErrorImpl; String get errorMessage; - @JsonKey(ignore: true) + + /// Create a copy of NotificationsState + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) _$$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 index e2bfd48b..c6d83825 100644 --- 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 @@ -19,4 +19,4 @@ class ProfileAvatarCubit extends Cubit { print(e); } } -} \ No newline at end of file +} 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 index 5d8de7ff..b629d579 100644 --- 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 @@ -84,6 +84,9 @@ class _$ProfileAvatarStateCopyWithImpl<$Res, $Val extends ProfileAvatarState> final $Val _value; // ignore: unused_field final $Res Function($Val) _then; + + /// Create a copy of ProfileAvatarState + /// with the given fields replaced by the non-null parameter values. } /// @nodoc @@ -100,6 +103,9 @@ class __$$ProfileAvatarStateImplCopyWithImpl<$Res> __$$ProfileAvatarStateImplCopyWithImpl(_$ProfileAvatarStateImpl _value, $Res Function(_$ProfileAvatarStateImpl) _then) : super(_value, _then); + + /// Create a copy of ProfileAvatarState + /// with the given fields replaced by the non-null parameter values. } /// @nodoc @@ -217,6 +223,9 @@ class __$$ProfileAvatarStateLoadingImplCopyWithImpl<$Res> _$ProfileAvatarStateLoadingImpl _value, $Res Function(_$ProfileAvatarStateLoadingImpl) _then) : super(_value, _then); + + /// Create a copy of ProfileAvatarState + /// with the given fields replaced by the non-null parameter values. } /// @nodoc @@ -340,6 +349,8 @@ class __$$ProfileAvatarStateLoadedImplCopyWithImpl<$Res> $Res Function(_$ProfileAvatarStateLoadedImpl) _then) : super(_value, _then); + /// Create a copy of ProfileAvatarState + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -353,6 +364,8 @@ class __$$ProfileAvatarStateLoadedImplCopyWithImpl<$Res> )); } + /// Create a copy of ProfileAvatarState + /// with the given fields replaced by the non-null parameter values. @override @pragma('vm:prefer-inline') $ProfileModelCopyWith<$Res> get profile { @@ -386,7 +399,9 @@ class _$ProfileAvatarStateLoadedImpl implements ProfileAvatarStateLoaded { @override int get hashCode => Object.hash(runtimeType, profile); - @JsonKey(ignore: true) + /// Create a copy of ProfileAvatarState + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$ProfileAvatarStateLoadedImplCopyWith<_$ProfileAvatarStateLoadedImpl> @@ -473,7 +488,10 @@ abstract class ProfileAvatarStateLoaded implements ProfileAvatarState { {required final ProfileModel profile}) = _$ProfileAvatarStateLoadedImpl; ProfileModel get profile; - @JsonKey(ignore: true) + + /// Create a copy of ProfileAvatarState + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) _$$ProfileAvatarStateLoadedImplCopyWith<_$ProfileAvatarStateLoadedImpl> get copyWith => throw _privateConstructorUsedError; } @@ -498,6 +516,8 @@ class __$$ProfileAvatarStateErrorImplCopyWithImpl<$Res> $Res Function(_$ProfileAvatarStateErrorImpl) _then) : super(_value, _then); + /// Create a copy of ProfileAvatarState + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -537,7 +557,9 @@ class _$ProfileAvatarStateErrorImpl implements ProfileAvatarStateError { @override int get hashCode => Object.hash(runtimeType, errorMessage); - @JsonKey(ignore: true) + /// Create a copy of ProfileAvatarState + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$ProfileAvatarStateErrorImplCopyWith<_$ProfileAvatarStateErrorImpl> @@ -624,7 +646,10 @@ abstract class ProfileAvatarStateError implements ProfileAvatarState { _$ProfileAvatarStateErrorImpl; String get errorMessage; - @JsonKey(ignore: true) + + /// Create a copy of ProfileAvatarState + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) _$$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 356d3cc7..ce8a8bca 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 @@ -1,12 +1,16 @@ import 'package:badges/badges.dart' as badges; -import 'package:eatvio_app/core/app_export.dart'; +import 'package:eatvio_app/core/utils/image_constant.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/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/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:eatvio_app/generated/l10n.dart'; +import 'package:eatvio_app/locator_service.dart'; +import 'package:eatvio_app/theme/theme_helper.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:go_router/go_router.dart'; @@ -55,6 +59,7 @@ class _BottomNavigationBarWidgetState extends State { @override Widget build(BuildContext context) { + final s = S.of(context); return Scaffold( body: widget.child, bottomNavigationBar: SizedBox( @@ -69,9 +74,22 @@ class _BottomNavigationBarWidgetState extends State { items: [ BottomNavigationBarItem( label: '', - icon: SvgPicture.asset( - ImageConstant.imgLogo, - height: 32, + icon: BlocProvider( + create: (context) => sl()..getMyProfile(), + child: BlocBuilder( + builder: (BuildContext context, ProfileAvatarState state) { + if (state is ProfileAvatarStateLoaded) { + return CircleAvatar( + backgroundImage: NetworkImage(state.profile.profilePhotoUrl), + radius: 16, + ); + } + return CircleAvatar( + radius: 16, + backgroundColor: Colors.black12, + ); + }, + ), ), ), BottomNavigationBarItem( @@ -99,7 +117,7 @@ class _BottomNavigationBarWidgetState extends State { ), ), BottomNavigationBarItem( - label: "diary".tr, + label: s.diary, icon: Padding( padding: const EdgeInsets.only(bottom: 2), child: SvgPicture.asset( @@ -123,7 +141,7 @@ class _BottomNavigationBarWidgetState extends State { ), ), BottomNavigationBarItem( - label: "chat".tr, + label: s.chat, icon: BlocBuilder( builder: (BuildContext context, NewMessagesState state) { return badges.Badge( @@ -188,19 +206,9 @@ class _BottomNavigationBarWidgetState extends State { ), 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, - ); - }, + icon: SvgPicture.asset( + ImageConstant.imgLogo, + height: 32, ), ), ], diff --git a/lib/features/calendar/models/calendar_entry_model.dart b/lib/features/calendar/models/calendar_entry_model.dart index 0973f979..32a6d1bd 100644 --- a/lib/features/calendar/models/calendar_entry_model.dart +++ b/lib/features/calendar/models/calendar_entry_model.dart @@ -16,7 +16,6 @@ class CalendarEntryModel { date = date; status = status; id = id; - is_current_day_included_in_the_chosen_diet_progression = - is_current_day_included_in_the_chosen_diet_progression; + is_current_day_included_in_the_chosen_diet_progression = is_current_day_included_in_the_chosen_diet_progression; } } diff --git a/lib/features/calendar/models/calendar_model.dart b/lib/features/calendar/models/calendar_model.dart index 4d74a87a..29e822e2 100644 --- a/lib/features/calendar/models/calendar_model.dart +++ b/lib/features/calendar/models/calendar_model.dart @@ -1,6 +1,7 @@ import 'package:freezed_annotation/freezed_annotation.dart'; part 'calendar_model.freezed.dart'; + part 'calendar_model.g.dart'; @freezed diff --git a/lib/features/calendar/models/calendar_model.freezed.dart b/lib/features/calendar/models/calendar_model.freezed.dart index 5e47f848..d10fc8f2 100644 --- a/lib/features/calendar/models/calendar_model.freezed.dart +++ b/lib/features/calendar/models/calendar_model.freezed.dart @@ -25,8 +25,12 @@ mixin _$CalendarModel { throw _privateConstructorUsedError; Object? get diary => throw _privateConstructorUsedError; + /// Serializes this CalendarModel to a JSON map. Map toJson() => throw _privateConstructorUsedError; - @JsonKey(ignore: true) + + /// Create a copy of CalendarModel + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) $CalendarModelCopyWith get copyWith => throw _privateConstructorUsedError; } @@ -53,6 +57,8 @@ 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({ @@ -97,6 +103,8 @@ 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({ @@ -157,7 +165,7 @@ class _$CalendarModelImpl implements _CalendarModel { const DeepCollectionEquality().equals(other.diary, diary)); } - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) @override int get hashCode => Object.hash( runtimeType, @@ -165,7 +173,9 @@ class _$CalendarModelImpl implements _CalendarModel { is_current_day_included_in_the_chosen_diet_progression, const DeepCollectionEquality().hash(diary)); - @JsonKey(ignore: true) + /// Create a copy of CalendarModel + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$CalendarModelImplCopyWith<_$CalendarModelImpl> get copyWith => @@ -195,8 +205,11 @@ 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(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) _$$CalendarModelImplCopyWith<_$CalendarModelImpl> get copyWith => throw _privateConstructorUsedError; } diff --git a/lib/features/calendar/presentation/bloc/calendar_cubit.dart b/lib/features/calendar/presentation/bloc/calendar_cubit.dart index cfbc5b07..01a16da9 100644 --- a/lib/features/calendar/presentation/bloc/calendar_cubit.dart +++ b/lib/features/calendar/presentation/bloc/calendar_cubit.dart @@ -1,6 +1,6 @@ -import 'package:eatvio_app/core/app_export.dart'; import 'package:eatvio_app/features/calendar/presentation/bloc/calendar_state.dart'; import 'package:eatvio_app/features/calendar/repositories/calendar_repository.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; class CalendarCubit extends Cubit { final CalendarRepository calendarRepository; diff --git a/lib/features/calendar/presentation/bloc/calendar_state.freezed.dart b/lib/features/calendar/presentation/bloc/calendar_state.freezed.dart index c71d5226..0e7bdbcd 100644 --- a/lib/features/calendar/presentation/bloc/calendar_state.freezed.dart +++ b/lib/features/calendar/presentation/bloc/calendar_state.freezed.dart @@ -84,6 +84,9 @@ 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 @@ -100,6 +103,9 @@ 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 @@ -214,6 +220,9 @@ 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 @@ -332,6 +341,8 @@ 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({ @@ -379,7 +390,9 @@ class _$CalendarStateLoadedImpl implements CalendarStateLoaded { int get hashCode => Object.hash( runtimeType, const DeepCollectionEquality().hash(_calendarList)); - @JsonKey(ignore: true) + /// Create a copy of CalendarState + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$CalendarStateLoadedImplCopyWith<_$CalendarStateLoadedImpl> get copyWith => @@ -467,7 +480,10 @@ abstract class CalendarStateLoaded implements CalendarState { _$CalendarStateLoadedImpl; List get calendarList; - @JsonKey(ignore: true) + + /// Create a copy of CalendarState + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) _$$CalendarStateLoadedImplCopyWith<_$CalendarStateLoadedImpl> get copyWith => throw _privateConstructorUsedError; } @@ -489,6 +505,8 @@ 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({ @@ -528,7 +546,9 @@ class _$CalendarStateErrorImpl implements CalendarStateError { @override int get hashCode => Object.hash(runtimeType, errorMessage); - @JsonKey(ignore: true) + /// Create a copy of CalendarState + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$CalendarStateErrorImplCopyWith<_$CalendarStateErrorImpl> get copyWith => @@ -615,7 +635,10 @@ abstract class CalendarStateError implements CalendarState { _$CalendarStateErrorImpl; String get errorMessage; - @JsonKey(ignore: true) + + /// Create a copy of CalendarState + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) _$$CalendarStateErrorImplCopyWith<_$CalendarStateErrorImpl> get copyWith => throw _privateConstructorUsedError; } diff --git a/lib/features/calendar/presentation/pages/calendar_screen.dart b/lib/features/calendar/presentation/pages/calendar_screen.dart index bcd365c2..be3f22ed 100644 --- a/lib/features/calendar/presentation/pages/calendar_screen.dart +++ b/lib/features/calendar/presentation/pages/calendar_screen.dart @@ -1,47 +1,58 @@ -// ignore_for_file: unused_local_variable - import 'package:eatvio_app/features/calendar/presentation/bloc/calendar_cubit.dart'; import 'package:eatvio_app/features/calendar/presentation/bloc/calendar_state.dart'; -import 'package:eatvio_app/core/app_export.dart'; +import 'package:eatvio_app/locator_service.dart'; +import 'package:eatvio_app/theme/app_decoration.dart'; +import 'package:eatvio_app/theme/custom_text_style.dart'; +import 'package:eatvio_app/theme/theme_helper.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:flutter_form_builder/flutter_form_builder.dart'; import 'package:go_router/go_router.dart'; import 'package:intl/intl.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter/cupertino.dart'; -import 'package:flutter_form_builder/flutter_form_builder.dart'; +import 'package:rive/rive.dart'; -// ignore: must_be_immutable class CalendarScreen extends StatelessWidget { CalendarScreen({Key? key}) : super(key: key); + Widget build(BuildContext context) { - return BlocBuilder( - builder: (context, state) { - if (state is CalendarStateLoaded) { - return _buildCalendar(context, state); - } else if (state is CalendarStateLoading) { - return Scaffold( - body: Center( - child: CupertinoActivityIndicator(), - ), - ); - } else if (state is CalendarStateError) { - return Scaffold( - body: Padding( - padding: const EdgeInsets.all(16), - child: Center( - child: Text(state.errorMessage), + return BlocProvider( + create: (context) => sl()..loadCalendarList(), + child: BlocBuilder( + builder: (context, state) { + if (state is CalendarStateLoaded) { + return _buildCalendar(context, state); + } else if (state is CalendarStateLoading) { + return Scaffold( + body: Center( + child: SizedBox( + height: 32, + width: 32, + child: RiveAnimation.asset( + 'assets/rive_animations/loading.riv', + ), + ), ), - ), - ); - } else - return Scaffold( - body: Padding( - padding: const EdgeInsets.all(16), - child: Center( - child: Text("Неопределенная ошибка"), + ); + } else if (state is CalendarStateError) { + return Scaffold( + body: Padding( + padding: const EdgeInsets.all(16), + child: Center( + child: Text(state.errorMessage), + ), ), - ), - ); - }, + ); + } else + return Scaffold( + body: Padding( + padding: const EdgeInsets.all(16), + child: Center( + child: Text("Неопределенная ошибка"), + ), + ), + ); + }, + ), ); } @@ -62,12 +73,12 @@ class CalendarScreen extends StatelessWidget { Expanded( child: SingleChildScrollView( child: Padding( - padding: EdgeInsets.only(bottom: 5.v), + padding: EdgeInsets.only(bottom: 8), child: Column( children: [ - SizedBox(height: 20.v), + SizedBox(height: 24), _buildCalendarBody(context, state), - SizedBox(height: 20.v), + SizedBox(height: 24), ], ), ), @@ -88,7 +99,7 @@ class CalendarScreen extends StatelessWidget { physics: NeverScrollableScrollPhysics(), separatorBuilder: (context, index) { return SizedBox( - height: 2.v, + height: 4, ); }, itemCount: state.calendarList.length, @@ -102,8 +113,7 @@ class CalendarScreen extends StatelessWidget { padding: EdgeInsets.all(8), decoration: BoxDecoration( borderRadius: BorderRadiusStyle.circleBorder8, - color: state.calendarList[index] - .is_current_day_included_in_the_chosen_diet_progression + color: state.calendarList[index].is_current_day_included_in_the_chosen_diet_progression ? Color.fromRGBO(59, 130, 246, .2) : Color.fromRGBO(126, 136, 151, .1), ), @@ -119,37 +129,29 @@ class CalendarScreen extends StatelessWidget { formatDate(state.calendarList[index].date), style: theme.textTheme.titleMedium, ), - SizedBox(height: 2.v), - if (state.calendarList[index] - .is_current_day_included_in_the_chosen_diet_progression) + SizedBox(height: 4), + if (state.calendarList[index].is_current_day_included_in_the_chosen_diet_progression) Container( - padding: EdgeInsets.all( - 4.0), // Отступы внутри контейнера + padding: EdgeInsets.all(4.0), // Отступы внутри контейнера decoration: BoxDecoration( color: Color.fromRGBO(13, 110, 253, 1), - borderRadius: BorderRadius.circular( - 24.0), // Закругленные углы + borderRadius: BorderRadius.circular(24.0), // Закругленные углы ), child: Text( 'Посмотреть диету на день', - style: CustomTextStyles - .titleSmallBold, // Предполагается, что текст белый + style: CustomTextStyles.titleSmallBold, // Предполагается, что текст белый ), ), - if (!state.calendarList[index] - .is_current_day_included_in_the_chosen_diet_progression) + if (!state.calendarList[index].is_current_day_included_in_the_chosen_diet_progression) Container( - padding: EdgeInsets.all( - 4.0), // Отступы внутри контейнера + padding: EdgeInsets.all(4.0), // Отступы внутри контейнера decoration: BoxDecoration( color: Color.fromRGBO(108, 117, 125, 1), - borderRadius: BorderRadius.circular( - 24.0), // Закругленные углы + borderRadius: BorderRadius.circular(24.0), // Закругленные углы ), child: Text( 'Cкоро', - style: CustomTextStyles - .titleSmallBold, // Предполагается, что текст белый + style: CustomTextStyles.titleSmallBold, // Предполагается, что текст белый ), ), ], @@ -186,53 +188,42 @@ class CalendarScreen extends StatelessWidget { formatDate(state.calendarList[index].date), style: theme.textTheme.titleMedium, ), - SizedBox(height: 2.v), + SizedBox(height: 4), Row(children: [ Container( - padding: EdgeInsets.all( - 4.0), // Отступы внутри контейнера + padding: EdgeInsets.all(4.0), // Отступы внутри контейнера decoration: BoxDecoration( - color: diary['state'] == 'finished' - ? Color.fromRGBO(1, 154, 62, 1) - : Color.fromRGBO(154, 74, 1, 1), - borderRadius: BorderRadius.circular( - 24.0), // Закругленные углы + color: diary['state'] == 'finished' ? Color.fromRGBO(1, 154, 62, 1) : Color.fromRGBO(154, 74, 1, 1), + borderRadius: BorderRadius.circular(24.0), // Закругленные углы ), child: Text( _getStateText(diary['state'] ?? ''), - style: CustomTextStyles - .titleSmallBold, // Предполагается, что текст белый + style: CustomTextStyles.titleSmallBold, // Предполагается, что текст белый ), ), SizedBox(width: 4), if (diary['state'] == 'started') Container( - padding: EdgeInsets.all( - 4.0), // Отступы внутри контейнера + padding: EdgeInsets.all(4.0), // Отступы внутри контейнера decoration: BoxDecoration( color: Color.fromRGBO(13, 110, 253, 1), - borderRadius: BorderRadius.circular( - 24.0), // Закругленные углы + borderRadius: BorderRadius.circular(24.0), // Закругленные углы ), child: Text( 'Заполнить отчет', - style: CustomTextStyles - .titleSmallBold, // Предполагается, что текст белый + style: CustomTextStyles.titleSmallBold, // Предполагается, что текст белый ), ), if (diary['state'] == 'finished') Container( - padding: EdgeInsets.all( - 4.0), // Отступы внутри контейнера + padding: EdgeInsets.all(4.0), // Отступы внутри контейнера decoration: BoxDecoration( color: Color.fromRGBO(13, 110, 253, 1), - borderRadius: BorderRadius.circular( - 24.0), // Закругленные углы + borderRadius: BorderRadius.circular(24.0), // Закругленные углы ), child: Text( 'Изменить отчет', - style: CustomTextStyles - .titleSmallBold, // Предполагается, что текст белый + style: CustomTextStyles.titleSmallBold, // Предполагается, что текст белый ), ), ]), diff --git a/lib/features/chat/models/chat_message_model.freezed.dart b/lib/features/chat/models/chat_message_model.freezed.dart index 76a91cbc..8f921425 100644 --- a/lib/features/chat/models/chat_message_model.freezed.dart +++ b/lib/features/chat/models/chat_message_model.freezed.dart @@ -29,8 +29,12 @@ mixin _$ChatMessageModel { @JsonKey(name: 'updated_at') String get updatedAt => throw _privateConstructorUsedError; + /// Serializes this ChatMessageModel to a JSON map. Map toJson() => throw _privateConstructorUsedError; - @JsonKey(ignore: true) + + /// Create a copy of ChatMessageModel + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) $ChatMessageModelCopyWith get copyWith => throw _privateConstructorUsedError; } @@ -59,6 +63,8 @@ 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({ @@ -117,6 +123,8 @@ 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({ @@ -207,12 +215,14 @@ class _$ChatMessageModelImpl implements _ChatMessageModel { other.updatedAt == updatedAt)); } - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) @override int get hashCode => Object.hash(runtimeType, id, data, const DeepCollectionEquality().hash(_mediaData), authorId, updatedAt); - @JsonKey(ignore: true) + /// Create a copy of ChatMessageModel + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$ChatMessageModelImplCopyWith<_$ChatMessageModelImpl> get copyWith => @@ -252,8 +262,11 @@ 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(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) _$$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 a970241c..852b33e4 100644 --- a/lib/features/chat/models/chat_messages_model.freezed.dart +++ b/lib/features/chat/models/chat_messages_model.freezed.dart @@ -24,8 +24,12 @@ mixin _$ChatMessagesModel { List get messagesList => throw _privateConstructorUsedError; ChatMetaModel get meta => throw _privateConstructorUsedError; + /// Serializes this ChatMessagesModel to a JSON map. Map toJson() => throw _privateConstructorUsedError; - @JsonKey(ignore: true) + + /// Create a copy of ChatMessagesModel + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) $ChatMessagesModelCopyWith get copyWith => throw _privateConstructorUsedError; } @@ -53,6 +57,8 @@ 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({ @@ -71,6 +77,8 @@ 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 { @@ -104,6 +112,8 @@ 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({ @@ -162,12 +172,14 @@ class _$ChatMessagesModelImpl implements _ChatMessagesModel { (identical(other.meta, meta) || other.meta == meta)); } - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) @override int get hashCode => Object.hash( runtimeType, const DeepCollectionEquality().hash(_messagesList), meta); - @JsonKey(ignore: true) + /// Create a copy of ChatMessagesModel + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$ChatMessagesModelImplCopyWith<_$ChatMessagesModelImpl> get copyWith => @@ -196,8 +208,11 @@ 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(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) _$$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 11ecb9e2..e8e4e96b 100644 --- a/lib/features/chat/models/chat_meta_model.freezed.dart +++ b/lib/features/chat/models/chat_meta_model.freezed.dart @@ -23,8 +23,12 @@ mixin _$ChatMetaModel { @JsonKey(name: "last_page") int get lastPage => throw _privateConstructorUsedError; + /// Serializes this ChatMetaModel to a JSON map. Map toJson() => throw _privateConstructorUsedError; - @JsonKey(ignore: true) + + /// Create a copy of ChatMetaModel + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) $ChatMetaModelCopyWith get copyWith => throw _privateConstructorUsedError; } @@ -48,6 +52,8 @@ 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({ @@ -81,6 +87,8 @@ 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({ @@ -122,11 +130,13 @@ class _$ChatMetaModelImpl implements _ChatMetaModel { other.lastPage == lastPage)); } - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) @override int get hashCode => Object.hash(runtimeType, lastPage); - @JsonKey(ignore: true) + /// Create a copy of ChatMetaModel + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$ChatMetaModelImplCopyWith<_$ChatMetaModelImpl> get copyWith => @@ -151,8 +161,11 @@ 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(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) _$$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 5a0b6e62..6afb3a94 100644 --- a/lib/features/chat/models/chat_room_model.freezed.dart +++ b/lib/features/chat/models/chat_room_model.freezed.dart @@ -26,8 +26,12 @@ mixin _$ChatRoomModel { throw _privateConstructorUsedError; Map get users => throw _privateConstructorUsedError; + /// Serializes this ChatRoomModel to a JSON map. Map toJson() => throw _privateConstructorUsedError; - @JsonKey(ignore: true) + + /// Create a copy of ChatRoomModel + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) $ChatRoomModelCopyWith get copyWith => throw _privateConstructorUsedError; } @@ -57,6 +61,8 @@ 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({ @@ -80,6 +86,8 @@ 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 { @@ -116,6 +124,8 @@ 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({ @@ -181,12 +191,14 @@ class _$ChatRoomModelImpl implements _ChatRoomModel { const DeepCollectionEquality().equals(other._users, _users)); } - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) @override int get hashCode => Object.hash(runtimeType, id, chatRoomSettings, const DeepCollectionEquality().hash(_users)); - @JsonKey(ignore: true) + /// Create a copy of ChatRoomModel + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$ChatRoomModelImplCopyWith<_$ChatRoomModelImpl> get copyWith => @@ -217,8 +229,11 @@ 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(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) _$$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 8d41bd4b..4b006cf0 100644 --- a/lib/features/chat/models/chat_room_preview_model.freezed.dart +++ b/lib/features/chat/models/chat_room_preview_model.freezed.dart @@ -23,8 +23,12 @@ mixin _$ChatRoomPreviewModel { @JsonKey(name: "chatRooms") List get chatRooms => throw _privateConstructorUsedError; + /// Serializes this ChatRoomPreviewModel to a JSON map. Map toJson() => throw _privateConstructorUsedError; - @JsonKey(ignore: true) + + /// Create a copy of ChatRoomPreviewModel + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) $ChatRoomPreviewModelCopyWith get copyWith => throw _privateConstructorUsedError; } @@ -49,6 +53,8 @@ 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({ @@ -82,6 +88,8 @@ 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({ @@ -129,12 +137,14 @@ class _$ChatRoomPreviewModelImpl implements _ChatRoomPreviewModel { .equals(other._chatRooms, _chatRooms)); } - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) @override int get hashCode => Object.hash(runtimeType, const DeepCollectionEquality().hash(_chatRooms)); - @JsonKey(ignore: true) + /// Create a copy of ChatRoomPreviewModel + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$ChatRoomPreviewModelImplCopyWith<_$ChatRoomPreviewModelImpl> @@ -161,8 +171,11 @@ 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(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) _$$ChatRoomPreviewModelImplCopyWith<_$ChatRoomPreviewModelImpl> get copyWith => throw _privateConstructorUsedError; } @@ -182,8 +195,12 @@ mixin _$ChatRoom { @JsonKey(name: "users") Users get users => throw _privateConstructorUsedError; + /// Serializes this ChatRoom to a JSON map. Map toJson() => throw _privateConstructorUsedError; - @JsonKey(ignore: true) + + /// Create a copy of ChatRoom + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) $ChatRoomCopyWith get copyWith => throw _privateConstructorUsedError; } @@ -212,6 +229,8 @@ 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({ @@ -240,6 +259,8 @@ 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 { @@ -275,6 +296,8 @@ 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({ @@ -347,12 +370,14 @@ class _$ChatRoomImpl implements _ChatRoom { (identical(other.users, users) || other.users == users)); } - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) @override int get hashCode => Object.hash(runtimeType, id, roomName, const DeepCollectionEquality().hash(lastMessage), users); - @JsonKey(ignore: true) + /// Create a copy of ChatRoom + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$ChatRoomImplCopyWith<_$ChatRoomImpl> get copyWith => @@ -388,8 +413,11 @@ 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(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) _$$ChatRoomImplCopyWith<_$ChatRoomImpl> get copyWith => throw _privateConstructorUsedError; } @@ -415,8 +443,12 @@ mixin _$LastMessageClass { @JsonKey(name: "updated_at") DateTime get updatedAt => throw _privateConstructorUsedError; + /// Serializes this LastMessageClass to a JSON map. Map toJson() => throw _privateConstructorUsedError; - @JsonKey(ignore: true) + + /// Create a copy of LastMessageClass + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) $LastMessageClassCopyWith get copyWith => throw _privateConstructorUsedError; } @@ -448,6 +480,8 @@ 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({ @@ -519,6 +553,8 @@ 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({ @@ -633,7 +669,7 @@ class _$LastMessageClassImpl implements _LastMessageClass { other.updatedAt == updatedAt)); } - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) @override int get hashCode => Object.hash( runtimeType, @@ -645,7 +681,9 @@ class _$LastMessageClassImpl implements _LastMessageClass { readByToUser, updatedAt); - @JsonKey(ignore: true) + /// Create a copy of LastMessageClass + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$LastMessageClassImplCopyWith<_$LastMessageClassImpl> get copyWith => @@ -696,8 +734,11 @@ 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(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) _$$LastMessageClassImplCopyWith<_$LastMessageClassImpl> get copyWith => throw _privateConstructorUsedError; } @@ -713,8 +754,12 @@ mixin _$Users { @JsonKey(name: "to_chat_user") ChatUser get toChatUser => throw _privateConstructorUsedError; + /// Serializes this Users to a JSON map. Map toJson() => throw _privateConstructorUsedError; - @JsonKey(ignore: true) + + /// Create a copy of Users + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) $UsersCopyWith get copyWith => throw _privateConstructorUsedError; } @@ -741,6 +786,8 @@ 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({ @@ -759,6 +806,8 @@ 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 { @@ -767,6 +816,8 @@ 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 { @@ -801,6 +852,8 @@ 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({ @@ -853,11 +906,13 @@ class _$UsersImpl implements _Users { other.toChatUser == toChatUser)); } - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) @override int get hashCode => Object.hash(runtimeType, fromChatUser, toChatUser); - @JsonKey(ignore: true) + /// Create a copy of Users + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$UsersImplCopyWith<_$UsersImpl> get copyWith => @@ -885,8 +940,11 @@ 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(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) _$$UsersImplCopyWith<_$UsersImpl> get copyWith => throw _privateConstructorUsedError; } @@ -906,8 +964,12 @@ mixin _$ChatUser { @JsonKey(name: "profile_photo_url") String get profilePhotoUrl => throw _privateConstructorUsedError; + /// Serializes this ChatUser to a JSON map. Map toJson() => throw _privateConstructorUsedError; - @JsonKey(ignore: true) + + /// Create a copy of ChatUser + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) $ChatUserCopyWith get copyWith => throw _privateConstructorUsedError; } @@ -934,6 +996,8 @@ 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({ @@ -986,6 +1050,8 @@ 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({ @@ -1058,12 +1124,14 @@ class _$ChatUserImpl implements _ChatUser { other.profilePhotoUrl == profilePhotoUrl)); } - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) @override int get hashCode => Object.hash(runtimeType, id, name, profilePhotoPath, profilePhotoUrl); - @JsonKey(ignore: true) + /// Create a copy of ChatUser + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$ChatUserImplCopyWith<_$ChatUserImpl> get copyWith => @@ -1101,8 +1169,11 @@ 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(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) _$$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 4f217556..9d12eefa 100644 --- a/lib/features/chat/models/chat_room_settings_model.freezed.dart +++ b/lib/features/chat/models/chat_room_settings_model.freezed.dart @@ -30,8 +30,12 @@ mixin _$ChatRoomSettingsModel { @JsonKey(name: 'updated_at') String get updatedAt => throw _privateConstructorUsedError; + /// Serializes this ChatRoomSettingsModel to a JSON map. Map toJson() => throw _privateConstructorUsedError; - @JsonKey(ignore: true) + + /// Create a copy of ChatRoomSettingsModel + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) $ChatRoomSettingsModelCopyWith get copyWith => throw _privateConstructorUsedError; } @@ -61,6 +65,8 @@ 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({ @@ -121,6 +127,8 @@ 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({ @@ -202,12 +210,14 @@ class _$ChatRoomSettingsModelImpl implements _ChatRoomSettingsModel { other.updatedAt == updatedAt)); } - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) @override int get hashCode => Object.hash(runtimeType, id, roomName, state, accessLevel, updatedAt); - @JsonKey(ignore: true) + /// Create a copy of ChatRoomSettingsModel + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$ChatRoomSettingsModelImplCopyWith<_$ChatRoomSettingsModelImpl> @@ -247,8 +257,11 @@ 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(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) _$$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 095c09e2..94718168 100644 --- a/lib/features/chat/models/chat_user_model.freezed.dart +++ b/lib/features/chat/models/chat_user_model.freezed.dart @@ -27,8 +27,12 @@ mixin _$ChatUserModel { @JsonKey(name: 'profile_photo_url') String? get profilePhotoUrl => throw _privateConstructorUsedError; + /// Serializes this ChatUserModel to a JSON map. Map toJson() => throw _privateConstructorUsedError; - @JsonKey(ignore: true) + + /// Create a copy of ChatUserModel + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) $ChatUserModelCopyWith get copyWith => throw _privateConstructorUsedError; } @@ -56,6 +60,8 @@ 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({ @@ -108,6 +114,8 @@ 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({ @@ -178,12 +186,14 @@ class _$ChatUserModelImpl implements _ChatUserModel { other.profilePhotoUrl == profilePhotoUrl)); } - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) @override int get hashCode => Object.hash(runtimeType, id, name, profilePhotoPath, profilePhotoUrl); - @JsonKey(ignore: true) + /// Create a copy of ChatUserModel + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$ChatUserModelImplCopyWith<_$ChatUserModelImpl> get copyWith => @@ -218,8 +228,11 @@ 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(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) _$$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 cd383a2b..9cddabee 100644 --- a/lib/features/chat/models/websocket_info_model.freezed.dart +++ b/lib/features/chat/models/websocket_info_model.freezed.dart @@ -27,8 +27,12 @@ mixin _$WebsocketInfoModel { @JsonKey(name: 'user_id') int get userId => throw _privateConstructorUsedError; + /// Serializes this WebsocketInfoModel to a JSON map. Map toJson() => throw _privateConstructorUsedError; - @JsonKey(ignore: true) + + /// Create a copy of WebsocketInfoModel + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) $WebsocketInfoModelCopyWith get copyWith => throw _privateConstructorUsedError; } @@ -57,6 +61,8 @@ 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({ @@ -115,6 +121,8 @@ 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({ @@ -191,12 +199,14 @@ class _$WebsocketInfoModelImpl implements _WebsocketInfoModel { (identical(other.userId, userId) || other.userId == userId)); } - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) @override int get hashCode => Object.hash(runtimeType, key, host, port, cluster, userId); - @JsonKey(ignore: true) + /// Create a copy of WebsocketInfoModel + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$WebsocketInfoModelImplCopyWith<_$WebsocketInfoModelImpl> get copyWith => @@ -234,8 +244,11 @@ 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(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) _$$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 9140a6bd..413ff885 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 @@ -4,7 +4,7 @@ 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'; +import 'package:eatvio_app/core/const.dart'; import 'package:eatvio_app/core/initialization_cubit/initialization_cubit.dart'; import 'package:eatvio_app/core/initialization_cubit/initialization_state.dart'; import 'package:eatvio_app/core/token_storage.dart'; 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 43bf9df9..4695b4ad 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,6 +90,9 @@ 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 @@ -106,6 +109,9 @@ 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 @@ -226,6 +232,9 @@ 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 @@ -356,6 +365,8 @@ 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({ @@ -384,6 +395,8 @@ 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 { @@ -442,7 +455,9 @@ class _$ChatRoomStateLoadedImpl implements ChatRoomStateLoaded { int get hashCode => Object.hash(runtimeType, chatRoom, const DeepCollectionEquality().hash(_chatMessages), isTyping, isLoading); - @JsonKey(ignore: true) + /// Create a copy of ChatRoomState + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$ChatRoomStateLoadedImplCopyWith<_$ChatRoomStateLoadedImpl> get copyWith => @@ -541,7 +556,10 @@ abstract class ChatRoomStateLoaded implements ChatRoomState { List get chatMessages; bool get isTyping; bool get isLoading; - @JsonKey(ignore: true) + + /// Create a copy of ChatRoomState + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) _$$ChatRoomStateLoadedImplCopyWith<_$ChatRoomStateLoadedImpl> get copyWith => throw _privateConstructorUsedError; } @@ -563,6 +581,8 @@ 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({ @@ -602,7 +622,9 @@ class _$ChatRoomStateErrorImpl implements ChatRoomStateError { @override int get hashCode => Object.hash(runtimeType, errorMessage); - @JsonKey(ignore: true) + /// Create a copy of ChatRoomState + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$ChatRoomStateErrorImplCopyWith<_$ChatRoomStateErrorImpl> get copyWith => @@ -695,7 +717,10 @@ abstract class ChatRoomStateError implements ChatRoomState { _$ChatRoomStateErrorImpl; String get errorMessage; - @JsonKey(ignore: true) + + /// Create a copy of ChatRoomState + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) _$$ChatRoomStateErrorImplCopyWith<_$ChatRoomStateErrorImpl> get copyWith => throw _privateConstructorUsedError; } diff --git a/lib/features/chat/presentation/bloc/chat_select_cubit/chat_select_cubit.dart b/lib/features/chat/presentation/bloc/chat_select_cubit/chat_select_cubit.dart index fc92f22d..d3edddc8 100644 --- a/lib/features/chat/presentation/bloc/chat_select_cubit/chat_select_cubit.dart +++ b/lib/features/chat/presentation/bloc/chat_select_cubit/chat_select_cubit.dart @@ -1,6 +1,6 @@ -import 'package:eatvio_app/core/app_export.dart'; import 'package:eatvio_app/features/chat/presentation/bloc/chat_select_cubit/chat_select_state.dart'; import 'package:eatvio_app/features/chat/repositories/chat_repository.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; class ChatSelectCubit extends Cubit { final ChatRepository chatRepository; 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 9a05918d..99fa9054 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,6 +84,9 @@ 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 @@ -100,6 +103,9 @@ 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 @@ -216,6 +222,9 @@ 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 @@ -334,6 +343,8 @@ 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({ @@ -373,7 +384,9 @@ class _$ChatSelectStateErrorImpl implements ChatSelectStateError { @override int get hashCode => Object.hash(runtimeType, errorMessage); - @JsonKey(ignore: true) + /// Create a copy of ChatSelectState + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$ChatSelectStateErrorImplCopyWith<_$ChatSelectStateErrorImpl> @@ -461,7 +474,10 @@ abstract class ChatSelectStateError implements ChatSelectState { _$ChatSelectStateErrorImpl; String get errorMessage; - @JsonKey(ignore: true) + + /// Create a copy of ChatSelectState + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) _$$ChatSelectStateErrorImplCopyWith<_$ChatSelectStateErrorImpl> get copyWith => throw _privateConstructorUsedError; } @@ -484,6 +500,8 @@ 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({ @@ -530,7 +548,9 @@ class _$ChatSelectStateLoadedImpl implements ChatSelectStateLoaded { int get hashCode => Object.hash(runtimeType, const DeepCollectionEquality().hash(_chatRooms)); - @JsonKey(ignore: true) + /// Create a copy of ChatSelectState + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$ChatSelectStateLoadedImplCopyWith<_$ChatSelectStateLoadedImpl> @@ -617,7 +637,10 @@ abstract class ChatSelectStateLoaded implements ChatSelectState { {required final List chatRooms}) = _$ChatSelectStateLoadedImpl; List get chatRooms; - @JsonKey(ignore: true) + + /// Create a copy of ChatSelectState + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) _$$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 fac8c5eb..2e96d007 100644 --- a/lib/features/chat/presentation/pages/chat_screen.dart +++ b/lib/features/chat/presentation/pages/chat_screen.dart @@ -1,13 +1,16 @@ 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'; import 'package:eatvio_app/features/chat/presentation/widgets/chat_bubble_widget.dart'; import 'package:eatvio_app/locator_service.dart'; +import 'package:eatvio_app/theme/custom_text_style.dart'; +import 'package:eatvio_app/theme/theme_helper.dart'; import 'package:file_picker/file_picker.dart'; -import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; -import 'package:lazy_load_scrollview/lazy_load_scrollview.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:intl/intl.dart'; +import 'package:rive/rive.dart'; class ChatScreen extends StatefulWidget { final String chatId; @@ -25,6 +28,24 @@ class _ChatScreenState extends State { final scrollController = ScrollController(); final TextEditingController textEditingController = TextEditingController(); + @override + void initState() { + scrollController.addListener(_onScroll); + super.initState(); + } + + _onScroll() { + if (scrollController.offset >= scrollController.position.maxScrollExtent && !scrollController.position.outOfRange) { + context.read().loadNextPage(widget.chatId); + } + } + + @override + void dispose() { + scrollController.dispose(); + super.dispose(); + } + Widget build(BuildContext context) { return BlocProvider( create: (BuildContext context) => sl()..initChat(widget.chatId), @@ -42,7 +63,13 @@ class _ChatScreenState extends State { } else { return Scaffold( body: Center( - child: CupertinoActivityIndicator(), + child: SizedBox( + height: 32, + width: 32, + child: RiveAnimation.asset( + 'assets/rive_animations/loading.riv', + ), + ), ), ); } @@ -116,40 +143,52 @@ class _ChatScreenState extends State { child: Container( color: Color(0xFFF0F2F5), width: double.maxFinite, - child: LazyLoadScrollView( - onEndOfPage: () => context.read().loadNextPage(widget.chatId), - isLoading: state.isLoading, - scrollOffset: MediaQuery.of(context).size.height.toInt(), - child: CustomScrollView( - physics: BouncingScrollPhysics(), - controller: scrollController, - reverse: true, - slivers: [ - SliverPadding( - padding: EdgeInsets.symmetric(vertical: 16), - sliver: SliverList( - delegate: SliverChildBuilderDelegate( - (context, index) { - if (index < state.chatMessages.length) { - return ChatBubbleWidget( - sendTime: state.chatMessages[index].updatedAt, - text: state.chatMessages[index].data.trim(), - isCurrentUser: state.chatRoom.users['to_chat_user']!.id != state.chatMessages[index].authorId, - mediaData: state.chatMessages[index].mediaData ?? [], - ); - } else { - return Padding( - padding: const EdgeInsets.all(8), - child: Center(child: CupertinoActivityIndicator()), - ); - } - }, - childCount: state.chatMessages.length + (state.isLoading ? 1 : 0), - ), + child: CustomScrollView( + physics: BouncingScrollPhysics(), + controller: scrollController, + reverse: true, + slivers: [ + SliverPadding( + padding: EdgeInsets.symmetric(vertical: 16), + sliver: SliverList( + delegate: SliverChildBuilderDelegate( + (context, index) { + if (index < state.chatMessages.length) { + return Column( + children: [ + if ((index + 1 != state.chatMessages.length && + DateTime.parse(state.chatMessages[index].updatedAt).day != + DateTime.parse(state.chatMessages[index + 1].updatedAt).day) || + index + 1 == state.chatMessages.length) + _messageDate(state.chatMessages[index].updatedAt), + ChatBubbleWidget( + sendTime: state.chatMessages[index].updatedAt, + text: state.chatMessages[index].data.trim(), + isCurrentUser: state.chatRoom.users['to_chat_user']!.id != state.chatMessages[index].authorId, + mediaData: state.chatMessages[index].mediaData ?? [], + ), + ], + ); + } else { + return Padding( + padding: const EdgeInsets.all(8), + child: Center( + child: SizedBox( + height: 32, + width: 32, + child: RiveAnimation.asset( + 'assets/rive_animations/loading.riv', + ), + ), + ), + ); + } + }, + childCount: state.chatMessages.length + (state.isLoading ? 1 : 0), ), ), - ], - ), + ), + ], ), ), ), @@ -298,4 +337,20 @@ class _ChatScreenState extends State { ), ); } + + _messageDate(String date) { + return Padding( + padding: const EdgeInsets.symmetric(vertical: 8), + child: Text( + DateFormat.MMMMd('RU').format( + DateTime.parse(date), + ), + style: const TextStyle( + height: 1, + color: Color(0xFF8393A1), + fontWeight: FontWeight.w500, + ), + ), + ); + } } diff --git a/lib/features/chat/presentation/pages/chat_select_screen.dart b/lib/features/chat/presentation/pages/chat_select_screen.dart index 74925e29..b4660cf2 100644 --- a/lib/features/chat/presentation/pages/chat_select_screen.dart +++ b/lib/features/chat/presentation/pages/chat_select_screen.dart @@ -1,11 +1,12 @@ import 'package:easy_debounce/easy_debounce.dart'; -import 'package:eatvio_app/core/app_export.dart'; import 'package:eatvio_app/features/chat/presentation/bloc/chat_select_cubit/chat_select_cubit.dart'; import 'package:eatvio_app/features/chat/presentation/bloc/chat_select_cubit/chat_select_state.dart'; import 'package:eatvio_app/features/chat/presentation/widgets/chat_entry_widget.dart'; import 'package:eatvio_app/features/chat/presentation/widgets/chat_search_bar_widget.dart'; -import 'package:flutter/cupertino.dart'; +import 'package:eatvio_app/locator_service.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:rive/rive.dart'; class ChatSelectScreen extends StatefulWidget { const ChatSelectScreen({Key? key}) : super(key: key); @@ -15,58 +16,62 @@ class ChatSelectScreen extends StatefulWidget { } class _ChatSelectScreenState extends State { + final ChatSelectCubit chatSelectCubit = sl(); final searchController = TextEditingController(); Widget build(BuildContext context) { - return BlocBuilder( - builder: (context, state) { - return Scaffold( - appBar: AppBar( - backgroundColor: Colors.white, - toolbarHeight: 0, - ), - body: NestedScrollView( - headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) { - return [ - SliverPadding( - padding: const EdgeInsets.only(top: 8), - sliver: SliverAppBar( - automaticallyImplyLeading: false, - stretchTriggerOffset: 1, - scrolledUnderElevation: 0, - floating: true, - snap: true, - title: Padding( - padding: const EdgeInsets.only(top: 8), - child: ChatSearchBarWidget( - onSuffixIconTap: () => context.read().getChatRooms(), - onChanged: (query) { - if (query.length > 2) { - EasyDebounce.debounce( - 'searchChatRoom', - Duration(milliseconds: 300), - () => context.read().getChatRooms(query: query), - ); - } else { - context.read().getChatRooms(); - } - }, - controller: searchController, - fillColor: Color(0xFFF0F2F5), - hintText: "Поиск", - hintStyle: TextStyle( - color: Color(0xFF7B8794), + return BlocProvider( + create: (context) => chatSelectCubit..getChatRooms(), + child: BlocBuilder( + builder: (context, state) { + return Scaffold( + appBar: AppBar( + backgroundColor: Colors.white, + toolbarHeight: 0, + ), + body: NestedScrollView( + headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) { + return [ + SliverPadding( + padding: const EdgeInsets.only(top: 8), + sliver: SliverAppBar( + automaticallyImplyLeading: false, + stretchTriggerOffset: 1, + scrolledUnderElevation: 0, + floating: true, + snap: true, + title: Padding( + padding: const EdgeInsets.only(top: 8), + child: ChatSearchBarWidget( + onSuffixIconTap: () => context.read().getChatRooms(), + onChanged: (query) { + if (query.length > 2) { + EasyDebounce.debounce( + 'searchChatRoom', + Duration(milliseconds: 300), + () => context.read().getChatRooms(query: query), + ); + } else { + context.read().getChatRooms(); + } + }, + controller: searchController, + fillColor: Color(0xFFF0F2F5), + hintText: "Поиск", + hintStyle: TextStyle( + color: Color(0xFF7B8794), + ), ), ), ), ), - ), - ]; - }, - body: stateBuilder(state), - ), - ); - }, + ]; + }, + body: stateBuilder(state), + ), + ); + }, + ), ); } @@ -74,7 +79,13 @@ class _ChatSelectScreenState extends State { if (state is ChatSelectStateLoading) { return Scaffold( body: Center( - child: CupertinoActivityIndicator(), + child: SizedBox( + height: 32, + width: 32, + child: RiveAnimation.asset( + 'assets/rive_animations/loading.riv', + ), + ), ), ); } else if (state is ChatSelectStateLoaded) { @@ -87,7 +98,13 @@ class _ChatSelectScreenState extends State { } else { return Scaffold( body: Center( - child: CupertinoActivityIndicator(), + child: SizedBox( + height: 32, + width: 32, + child: RiveAnimation.asset( + 'assets/rive_animations/loading.riv', + ), + ), ), ); } diff --git a/lib/features/chat/presentation/pages/photo_view_screen.dart b/lib/features/chat/presentation/pages/photo_view_screen.dart index a070103d..4bc71ee9 100644 --- a/lib/features/chat/presentation/pages/photo_view_screen.dart +++ b/lib/features/chat/presentation/pages/photo_view_screen.dart @@ -1,6 +1,7 @@ import 'package:cached_network_image/cached_network_image.dart'; import 'package:dismissible_page/dismissible_page.dart'; -import 'package:eatvio_app/core/app_export.dart'; +import 'package:eatvio_app/core/const.dart'; +import 'package:eatvio_app/theme/app_decoration.dart'; import 'package:flutter/material.dart'; import 'package:go_router/go_router.dart'; import 'package:photo_view/photo_view.dart'; diff --git a/lib/features/chat/presentation/widgets/chat_bubble_widget.dart b/lib/features/chat/presentation/widgets/chat_bubble_widget.dart index eeba8f1e..79e3269a 100644 --- a/lib/features/chat/presentation/widgets/chat_bubble_widget.dart +++ b/lib/features/chat/presentation/widgets/chat_bubble_widget.dart @@ -1,6 +1,7 @@ import 'package:cached_network_image/cached_network_image.dart'; import 'package:dismissible_page/dismissible_page.dart'; -import 'package:eatvio_app/core/app_export.dart'; +import 'package:eatvio_app/core/const.dart'; +import 'package:eatvio_app/core/utils/date_time_utils.dart'; import 'package:eatvio_app/features/chat/presentation/pages/photo_view_screen.dart'; import 'package:flutter/material.dart'; import 'package:url_launcher/url_launcher.dart'; @@ -51,7 +52,7 @@ class ChatBubbleWidget extends StatelessWidget { !mediaData[index].toString().contains('.jpg') && !mediaData[index].toString().contains('.jpeg')) { return ListTile( - contentPadding: EdgeInsets.zero, + contentPadding: EdgeInsets.all(4), horizontalTitleGap: 8, onTap: () async { if (!await launchUrl(Uri.parse(baseUrl + '/storage/' + mediaData[index].toString()))) { @@ -60,17 +61,17 @@ class ChatBubbleWidget extends StatelessWidget { }, leading: Icon( Icons.file_copy_outlined, - color: Color(0xFF2F80ED), + color: Colors.white, ), trailing: Icon( Icons.download_outlined, - color: Color(0xFF2F80ED), + color: Colors.white, ), title: Text( mediaData[index].toString().replaceAll('chat_files/', ''), maxLines: 2, style: TextStyle( - color: Color(0xFF323F4B), + color: Colors.white, fontSize: 12, overflow: TextOverflow.ellipsis, ), @@ -110,12 +111,15 @@ class ChatBubbleWidget extends StatelessWidget { 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, + Padding( + padding: mediaData.length > 0 ? const EdgeInsets.only(right: 8, top: 4, left: 8) : EdgeInsets.zero, + child: 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 b496047d..e8150dc1 100644 --- a/lib/features/chat/presentation/widgets/chat_entry_widget.dart +++ b/lib/features/chat/presentation/widgets/chat_entry_widget.dart @@ -1,5 +1,7 @@ -import 'package:eatvio_app/core/app_export.dart'; +import 'package:eatvio_app/core/utils/date_time_utils.dart'; import 'package:eatvio_app/features/chat/models/chat_room_preview_model.dart'; +import 'package:eatvio_app/theme/custom_text_style.dart'; +import 'package:eatvio_app/theme/theme_helper.dart'; import 'package:flutter/material.dart'; import 'package:go_router/go_router.dart'; 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 4889fdfd..3480c923 100644 --- a/lib/features/chat/presentation/widgets/chat_search_bar_widget.dart +++ b/lib/features/chat/presentation/widgets/chat_search_bar_widget.dart @@ -1,4 +1,5 @@ -import 'package:eatvio_app/core/app_export.dart'; +import 'package:eatvio_app/theme/custom_text_style.dart'; +import 'package:eatvio_app/theme/theme_helper.dart'; import 'package:flutter/material.dart'; class ChatSearchBarWidget extends StatelessWidget { @@ -78,7 +79,7 @@ class ChatSearchBarWidget extends StatelessWidget { } searchViewWidget(BuildContext context) => SizedBox( - width: width ?? double.maxFinite, + width: width ?? MediaQuery.of(context).size.width, child: TextFormField( controller: controller, focusNode: focusNode, @@ -123,10 +124,6 @@ class ChatSearchBarWidget extends StatelessWidget { color: Colors.grey.shade600, ), ), - suffixIconConstraints: suffixConstraints ?? - BoxConstraints( - maxHeight: 40.v, - ), isDense: true, contentPadding: EdgeInsets.all(16), fillColor: fillColor ?? appTheme.gray100, diff --git a/lib/features/chat/repositories/chat_repository.dart b/lib/features/chat/repositories/chat_repository.dart index 0f0be7de..f83fa563 100644 --- a/lib/features/chat/repositories/chat_repository.dart +++ b/lib/features/chat/repositories/chat_repository.dart @@ -1,11 +1,12 @@ import 'dart:io'; + import 'package:dio/dio.dart'; -import 'package:eatvio_app/features/chat/models/chat_room_preview_model.dart'; -import 'package:http_parser/http_parser.dart'; import 'package:eatvio_app/features/chat/models/chat_messages_model.dart'; import 'package:eatvio_app/features/chat/models/chat_room_model.dart'; +import 'package:eatvio_app/features/chat/models/chat_room_preview_model.dart'; import 'package:eatvio_app/features/chat/models/websocket_info_model.dart'; import 'package:eatvio_app/features/chat/services/chat_service.dart'; +import 'package:http_parser/http_parser.dart'; class ChatRepository { final ChatService chatService; diff --git a/lib/features/diary/models/diary_model.dart b/lib/features/diary/models/diary_model.dart index d9abc3a9..8c152997 100644 --- a/lib/features/diary/models/diary_model.dart +++ b/lib/features/diary/models/diary_model.dart @@ -4,6 +4,7 @@ import 'package:freezed_annotation/freezed_annotation.dart'; import './meal.dart'; part 'diary_model.freezed.dart'; + part 'diary_model.g.dart'; @freezed diff --git a/lib/features/diary/models/diary_model.freezed.dart b/lib/features/diary/models/diary_model.freezed.dart index a02a4621..ceabd5db 100644 --- a/lib/features/diary/models/diary_model.freezed.dart +++ b/lib/features/diary/models/diary_model.freezed.dart @@ -29,8 +29,12 @@ mixin _$DiaryModel { DateTime? get wakeup => throw _privateConstructorUsedError; DateTime? get retire => throw _privateConstructorUsedError; + /// Serializes this DiaryModel to a JSON map. Map toJson() => throw _privateConstructorUsedError; - @JsonKey(ignore: true) + + /// Create a copy of DiaryModel + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) $DiaryModelCopyWith get copyWith => throw _privateConstructorUsedError; } @@ -64,6 +68,8 @@ 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({ @@ -112,6 +118,8 @@ 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 { @@ -151,6 +159,8 @@ 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({ @@ -260,7 +270,7 @@ class _$DiaryModelImpl implements _DiaryModel { (identical(other.retire, retire) || other.retire == retire)); } - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) @override int get hashCode => Object.hash( runtimeType, @@ -273,7 +283,9 @@ class _$DiaryModelImpl implements _DiaryModel { wakeup, retire); - @JsonKey(ignore: true) + /// Create a copy of DiaryModel + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$DiaryModelImplCopyWith<_$DiaryModelImpl> get copyWith => @@ -317,8 +329,11 @@ 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(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) _$$DiaryModelImplCopyWith<_$DiaryModelImpl> get copyWith => throw _privateConstructorUsedError; } diff --git a/lib/features/diary/models/meal.dart b/lib/features/diary/models/meal.dart index 415242c6..b5e12d83 100644 --- a/lib/features/diary/models/meal.dart +++ b/lib/features/diary/models/meal.dart @@ -4,6 +4,7 @@ import './photo.dart'; import './portion.dart'; part 'meal.freezed.dart'; + part 'meal.g.dart'; @freezed diff --git a/lib/features/diary/models/meal.freezed.dart b/lib/features/diary/models/meal.freezed.dart index 2c249b06..2bd6c478 100644 --- a/lib/features/diary/models/meal.freezed.dart +++ b/lib/features/diary/models/meal.freezed.dart @@ -28,8 +28,12 @@ mixin _$Meal { List get portions => throw _privateConstructorUsedError; List get photos => throw _privateConstructorUsedError; + /// Serializes this Meal to a JSON map. Map toJson() => throw _privateConstructorUsedError; - @JsonKey(ignore: true) + + /// Create a copy of Meal + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) $MealCopyWith get copyWith => throw _privateConstructorUsedError; } @@ -58,6 +62,8 @@ 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({ @@ -126,6 +132,8 @@ 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({ @@ -232,7 +240,7 @@ class _$MealImpl implements _Meal { const DeepCollectionEquality().equals(other._photos, _photos)); } - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) @override int get hashCode => Object.hash( runtimeType, @@ -244,7 +252,9 @@ class _$MealImpl implements _Meal { const DeepCollectionEquality().hash(_portions), const DeepCollectionEquality().hash(_photos)); - @JsonKey(ignore: true) + /// Create a copy of Meal + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$MealImplCopyWith<_$MealImpl> get copyWith => @@ -284,8 +294,11 @@ 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(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) _$$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 2d9c70bd..8f5e0152 100644 --- a/lib/features/diary/models/photo.freezed.dart +++ b/lib/features/diary/models/photo.freezed.dart @@ -25,8 +25,12 @@ mixin _$Photo { String get originalName => throw _privateConstructorUsedError; String get path => throw _privateConstructorUsedError; + /// Serializes this Photo to a JSON map. Map toJson() => throw _privateConstructorUsedError; - @JsonKey(ignore: true) + + /// Create a copy of Photo + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) $PhotoCopyWith get copyWith => throw _privateConstructorUsedError; } @@ -51,6 +55,8 @@ 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({ @@ -96,6 +102,8 @@ 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({ @@ -155,11 +163,13 @@ class _$PhotoImpl implements _Photo { (identical(other.path, path) || other.path == path)); } - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) @override int get hashCode => Object.hash(runtimeType, id, originalName, path); - @JsonKey(ignore: true) + /// Create a copy of Photo + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$PhotoImplCopyWith<_$PhotoImpl> get copyWith => @@ -188,8 +198,11 @@ 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(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) _$$PhotoImplCopyWith<_$PhotoImpl> get copyWith => throw _privateConstructorUsedError; } diff --git a/lib/features/diary/models/portion.dart b/lib/features/diary/models/portion.dart index 59ad837d..f829dcf9 100644 --- a/lib/features/diary/models/portion.dart +++ b/lib/features/diary/models/portion.dart @@ -1,6 +1,7 @@ import 'package:freezed_annotation/freezed_annotation.dart'; part 'portion.freezed.dart'; + part 'portion.g.dart'; @freezed diff --git a/lib/features/diary/models/portion.freezed.dart b/lib/features/diary/models/portion.freezed.dart index 77627c29..4bef02d4 100644 --- a/lib/features/diary/models/portion.freezed.dart +++ b/lib/features/diary/models/portion.freezed.dart @@ -26,8 +26,12 @@ mixin _$Portion { String get portion => throw _privateConstructorUsedError; bool get from_diet => throw _privateConstructorUsedError; + /// Serializes this Portion to a JSON map. Map toJson() => throw _privateConstructorUsedError; - @JsonKey(ignore: true) + + /// Create a copy of Portion + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) $PortionCopyWith get copyWith => throw _privateConstructorUsedError; } @@ -54,6 +58,8 @@ 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({ @@ -111,6 +117,8 @@ 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({ @@ -189,12 +197,14 @@ class _$PortionImpl implements _Portion { other.from_diet == from_diet)); } - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) @override int get hashCode => Object.hash(runtimeType, id, product_name, quantity, portion, from_diet); - @JsonKey(ignore: true) + /// Create a copy of Portion + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$PortionImplCopyWith<_$PortionImpl> get copyWith => @@ -228,8 +238,11 @@ 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(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) _$$PortionImplCopyWith<_$PortionImpl> get copyWith => throw _privateConstructorUsedError; } diff --git a/lib/features/diary/models/product.dart b/lib/features/diary/models/product.dart index 050b97de..48b1de0e 100644 --- a/lib/features/diary/models/product.dart +++ b/lib/features/diary/models/product.dart @@ -1,6 +1,7 @@ import 'package:freezed_annotation/freezed_annotation.dart'; part 'product.freezed.dart'; + part 'product.g.dart'; @freezed diff --git a/lib/features/diary/models/product.freezed.dart b/lib/features/diary/models/product.freezed.dart index d30ada33..610656fb 100644 --- a/lib/features/diary/models/product.freezed.dart +++ b/lib/features/diary/models/product.freezed.dart @@ -23,8 +23,12 @@ mixin _$Product { int get id => throw _privateConstructorUsedError; String get name => throw _privateConstructorUsedError; + /// Serializes this Product to a JSON map. Map toJson() => throw _privateConstructorUsedError; - @JsonKey(ignore: true) + + /// Create a copy of Product + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) $ProductCopyWith get copyWith => throw _privateConstructorUsedError; } @@ -46,6 +50,8 @@ 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({ @@ -83,6 +89,8 @@ 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({ @@ -129,11 +137,13 @@ class _$ProductImpl implements _Product { (identical(other.name, name) || other.name == name)); } - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) @override int get hashCode => Object.hash(runtimeType, id, name); - @JsonKey(ignore: true) + /// Create a copy of Product + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$ProductImplCopyWith<_$ProductImpl> get copyWith => @@ -157,8 +167,11 @@ 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(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) _$$ProductImplCopyWith<_$ProductImpl> get copyWith => throw _privateConstructorUsedError; } diff --git a/lib/features/diary/models/state.dart b/lib/features/diary/models/state.dart index 874592ed..b1da05c4 100644 --- a/lib/features/diary/models/state.dart +++ b/lib/features/diary/models/state.dart @@ -1,6 +1,7 @@ import 'package:freezed_annotation/freezed_annotation.dart'; part 'state.freezed.dart'; + part 'state.g.dart'; @freezed diff --git a/lib/features/diary/models/state.freezed.dart b/lib/features/diary/models/state.freezed.dart index 599ec29f..6b9c50fb 100644 --- a/lib/features/diary/models/state.freezed.dart +++ b/lib/features/diary/models/state.freezed.dart @@ -23,8 +23,12 @@ 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; - @JsonKey(ignore: true) + + /// Create a copy of State + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) $StateCopyWith get copyWith => throw _privateConstructorUsedError; } @@ -46,6 +50,8 @@ 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({ @@ -83,6 +89,8 @@ 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({ @@ -132,12 +140,14 @@ class _$StateImpl implements _State { other.has_chosen_plan == has_chosen_plan)); } - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) @override int get hashCode => Object.hash(runtimeType, has_chosen_diet, has_chosen_plan); - @JsonKey(ignore: true) + /// Create a copy of State + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$StateImplCopyWith<_$StateImpl> get copyWith => @@ -162,8 +172,11 @@ 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(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) _$$StateImplCopyWith<_$StateImpl> get copyWith => throw _privateConstructorUsedError; } diff --git a/lib/features/diary/presentation/bloc/diary_bloc.dart b/lib/features/diary/presentation/bloc/diary_bloc.dart index 747f9ee8..cee99a34 100644 --- a/lib/features/diary/presentation/bloc/diary_bloc.dart +++ b/lib/features/diary/presentation/bloc/diary_bloc.dart @@ -1,5 +1,6 @@ import 'dart:async'; +import 'package:eatvio_app/data/models/selectionPopupModel/selection_popup_model.dart'; import 'package:eatvio_app/features/diary/models/diary_model.dart'; import 'package:eatvio_app/features/diary/models/meal.dart'; import 'package:eatvio_app/features/diary/models/product.dart'; @@ -7,11 +8,10 @@ import 'package:eatvio_app/features/diary/presentation/bloc/diary_state.dart'; import 'package:eatvio_app/features/diary/repositories/diary_repository.dart'; import 'package:equatable/equatable.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:image_picker/image_picker.dart'; import 'package:intl/intl.dart'; -import '/core/app_export.dart'; - part 'diary_event.dart'; /// A bloc that manages the state of a Diary according to the event that is dispatched to it. diff --git a/lib/features/diary/presentation/bloc/diary_event.dart b/lib/features/diary/presentation/bloc/diary_event.dart index cfc1bedf..33c168d7 100644 --- a/lib/features/diary/presentation/bloc/diary_event.dart +++ b/lib/features/diary/presentation/bloc/diary_event.dart @@ -182,6 +182,7 @@ class RefreshEvent extends DiaryEvent { class ConfirmPortion extends DiaryEvent { ConfirmPortion(this.id); + int id; @override diff --git a/lib/features/diary/presentation/bloc/diary_state.freezed.dart b/lib/features/diary/presentation/bloc/diary_state.freezed.dart index 5a9bbc12..98d7019f 100644 --- a/lib/features/diary/presentation/bloc/diary_state.freezed.dart +++ b/lib/features/diary/presentation/bloc/diary_state.freezed.dart @@ -174,6 +174,9 @@ 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 @@ -190,6 +193,9 @@ 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 @@ -397,6 +403,8 @@ 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({ @@ -435,7 +443,9 @@ class _$DiaryStateLoadingImpl implements DiaryStateLoading { @override int get hashCode => Object.hash(runtimeType, id); - @JsonKey(ignore: true) + /// Create a copy of DiaryState + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$DiaryStateLoadingImplCopyWith<_$DiaryStateLoadingImpl> get copyWith => @@ -611,7 +621,10 @@ abstract class DiaryStateLoading implements DiaryState { const factory DiaryStateLoading({final int? id}) = _$DiaryStateLoadingImpl; int? get id; - @JsonKey(ignore: true) + + /// Create a copy of DiaryState + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) _$$DiaryStateLoadingImplCopyWith<_$DiaryStateLoadingImpl> get copyWith => throw _privateConstructorUsedError; } @@ -666,6 +679,8 @@ 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({ @@ -819,6 +834,8 @@ 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 { @@ -827,6 +844,8 @@ 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 { @@ -835,6 +854,8 @@ 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 { @@ -1100,7 +1121,9 @@ class _$DiaryStateLoadedImpl implements DiaryStateLoaded { const DeepCollectionEquality().hash(_chartDataCounted) ]); - @JsonKey(ignore: true) + /// Create a copy of DiaryState + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$DiaryStateLoadedImplCopyWith<_$DiaryStateLoadedImpl> get copyWith => @@ -1420,7 +1443,10 @@ abstract class DiaryStateLoaded implements DiaryState { bool get isLoading; bool get isAdded; List? get chartDataCounted; - @JsonKey(ignore: true) + + /// Create a copy of DiaryState + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) _$$DiaryStateLoadedImplCopyWith<_$DiaryStateLoadedImpl> get copyWith => throw _privateConstructorUsedError; } @@ -1442,6 +1468,8 @@ 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({ @@ -1481,7 +1509,9 @@ class _$DiaryStateErrorImpl implements DiaryStateError { @override int get hashCode => Object.hash(runtimeType, errorMessage); - @JsonKey(ignore: true) + /// Create a copy of DiaryState + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$DiaryStateErrorImplCopyWith<_$DiaryStateErrorImpl> get copyWith => @@ -1658,7 +1688,10 @@ abstract class DiaryStateError implements DiaryState { _$DiaryStateErrorImpl; String get errorMessage; - @JsonKey(ignore: true) + + /// Create a copy of DiaryState + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) _$$DiaryStateErrorImplCopyWith<_$DiaryStateErrorImpl> get copyWith => throw _privateConstructorUsedError; } diff --git a/lib/features/diary/presentation/pages/diary_recommendations_scree.dart b/lib/features/diary/presentation/pages/diary_recommendations_scree.dart index 6c9f3a12..53b20dee 100644 --- a/lib/features/diary/presentation/pages/diary_recommendations_scree.dart +++ b/lib/features/diary/presentation/pages/diary_recommendations_scree.dart @@ -3,11 +3,10 @@ import 'package:eatvio_app/features/diary/models/portion.dart'; import 'package:eatvio_app/features/diary/presentation/bloc/diary_bloc.dart'; import 'package:eatvio_app/features/diary/presentation/bloc/diary_state.dart'; -import 'package:eatvio_app/core/app_export.dart'; - import 'package:flutter/material.dart'; -import 'package:flutter/cupertino.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_form_builder/flutter_form_builder.dart'; +import 'package:rive/rive.dart'; // ignore: must_be_immutable class DiaryRecommendationsScreen extends StatelessWidget { @@ -29,7 +28,13 @@ class DiaryRecommendationsScreen extends StatelessWidget { } else if (state is DiaryStateLoading) { return Scaffold( body: Center( - child: CupertinoActivityIndicator(), + child: SizedBox( + height: 32, + width: 32, + child: RiveAnimation.asset( + 'assets/rive_animations/loading.riv', + ), + ), ), ); } else if (state is DiaryStateError) { @@ -74,7 +79,7 @@ class DiaryRecommendationsScreen extends StatelessWidget { Expanded( child: SingleChildScrollView( child: Padding( - padding: EdgeInsets.only(bottom: 5.v), + padding: EdgeInsets.only(bottom: 9), child: Column( children: [ Scaffold( diff --git a/lib/features/diary/presentation/pages/diary_screen.dart b/lib/features/diary/presentation/pages/diary_screen.dart index d79b4aab..aaa06ad8 100644 --- a/lib/features/diary/presentation/pages/diary_screen.dart +++ b/lib/features/diary/presentation/pages/diary_screen.dart @@ -1,6 +1,6 @@ -// ignore_for_file: unused_local_variable - import 'package:carousel_slider_plus/carousel_slider_plus.dart'; +import 'package:eatvio_app/core/const.dart'; +import 'package:eatvio_app/data/models/selectionPopupModel/selection_popup_model.dart'; import 'package:eatvio_app/features/diary/models/diary_model.dart'; import 'package:eatvio_app/features/diary/models/meal.dart'; import 'package:eatvio_app/features/diary/models/photo.dart'; @@ -8,16 +8,19 @@ import 'package:eatvio_app/features/diary/models/portion.dart'; import 'package:eatvio_app/features/diary/models/product.dart'; import 'package:eatvio_app/features/diary/presentation/bloc/diary_bloc.dart'; import 'package:eatvio_app/features/diary/presentation/bloc/diary_state.dart'; -import 'package:eatvio_app/core/app_export.dart'; -import 'package:eatvio_app/widgets/custom_edit_text_form_field.dart'; -import 'package:eatvio_app/widgets/custom_edit_drop_down.dart'; +import 'package:eatvio_app/locator_service.dart'; +import 'package:eatvio_app/theme/app_decoration.dart'; +import 'package:eatvio_app/theme/custom_text_style.dart'; +import 'package:eatvio_app/theme/theme_helper.dart'; +import 'package:eatvio_app/widgets/custom_drop_down.dart'; import 'package:eatvio_app/widgets/custom_scale_element.dart'; - +import 'package:eatvio_app/widgets/custom_text_form_field.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; -import 'package:flutter/cupertino.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_form_builder/flutter_form_builder.dart'; import 'package:image_picker/image_picker.dart'; +import 'package:rive/rive.dart' as rive; import 'package:syncfusion_flutter_charts/charts.dart'; class DiaryScreen extends StatelessWidget { @@ -32,35 +35,44 @@ class DiaryScreen extends StatelessWidget { if (diaryID != "0") { context.read().add(LoadDiaryById(diaryID)); } - return BlocBuilder( - builder: (context, state) { - if (state is DiaryStateLoaded) { - return _buildDiary(context, state); - } else if (state is DiaryStateLoading) { - return Scaffold( - body: Center( - child: CupertinoActivityIndicator(), - ), - ); - } else if (state is DiaryStateError) { - return Scaffold( - body: Padding( - padding: const EdgeInsets.all(16), - child: Center( - child: Text(state.errorMessage), + return BlocProvider( + create: (context) => sl()..add(LoadDiary()), + child: BlocBuilder( + builder: (context, state) { + if (state is DiaryStateLoaded) { + return _buildDiary(context, state); + } else if (state is DiaryStateLoading) { + return Scaffold( + body: Center( + child: SizedBox( + height: 32, + width: 32, + child: rive.RiveAnimation.asset( + 'assets/rive_animations/loading.riv', + ), + ), ), - ), - ); - } else - return Scaffold( - body: Padding( - padding: const EdgeInsets.all(16), - child: Center( - child: Text("Неопределенная ошибка"), + ); + } else if (state is DiaryStateError) { + return Scaffold( + body: Padding( + padding: const EdgeInsets.all(16), + child: Center( + child: Text(state.errorMessage), + ), ), - ), - ); - }, + ); + } else + return Scaffold( + body: Padding( + padding: const EdgeInsets.all(16), + child: Center( + child: Text("Неопределенная ошибка"), + ), + ), + ); + }, + ), ); } @@ -85,19 +97,19 @@ class DiaryScreen extends StatelessWidget { Expanded( child: SingleChildScrollView( child: Padding( - padding: EdgeInsets.only(bottom: 5.v), + padding: EdgeInsets.only(bottom: 8), child: Column( children: [ _buildHeaderRow(context, state), - SizedBox(height: 8.v), + SizedBox(height: 8), _buildWakupRetire(context, state), - SizedBox(height: 8.v), + SizedBox(height: 8), _buildMeal(context, state), - SizedBox(height: 8.v), + SizedBox(height: 8), _buildMood(context, state), - SizedBox(height: 8.v), + SizedBox(height: 8), _buildNutritionChart(context, state), - SizedBox(height: 8.v), + SizedBox(height: 8), // _buildComment(context, state), // SizedBox(height: 8.v), _buildEndDay(context), @@ -119,8 +131,8 @@ class DiaryScreen extends StatelessWidget { _buildNutritionChart(BuildContext context, DiaryStateLoaded state) { return Container( padding: EdgeInsets.symmetric( - horizontal: 24.h, - vertical: 12.v, + horizontal: 24, + vertical: 12, ), decoration: BoxDecoration( color: Colors.white, @@ -177,13 +189,13 @@ class DiaryScreen extends StatelessWidget { children: [ Text( '${state.chartData['dailyNutritionIntake']['carbohydrates'].toStringAsFixed(1)} из ${state.chartData['dailyNutritionRecommendation']['carbohydrates'].toStringAsFixed(1)} грамм'), - SizedBox(height: 8.v), + SizedBox(height: 8), Text( '${state.chartData['dailyNutritionIntake']['fats'].toStringAsFixed(1)} из ${state.chartData['dailyNutritionRecommendation']['fats'].toStringAsFixed(1)} грамм'), - SizedBox(height: 8.v), + SizedBox(height: 8), Text( '${state.chartData['dailyNutritionIntake']['proteins'].toStringAsFixed(1)} из ${state.chartData['dailyNutritionRecommendation']['proteins'].toStringAsFixed(1)} грамм'), - SizedBox(height: 8.v), + SizedBox(height: 8), Text( '${state.chartData['dailyNutritionIntake']['energy'].toStringAsFixed(1)} из ${state.chartData['dailyNutritionRecommendation']['energy'].toStringAsFixed(1)} Ккал'), ], @@ -229,8 +241,8 @@ class DiaryScreen extends StatelessWidget { final day = state.diary.id; return Container( padding: EdgeInsets.symmetric( - horizontal: 24.h, - vertical: 12.v, + horizontal: 24, + vertical: 12, ), decoration: BoxDecoration( color: Colors.white, @@ -240,7 +252,7 @@ class DiaryScreen extends StatelessWidget { mainAxisAlignment: MainAxisAlignment.center, children: [ Padding( - padding: EdgeInsets.only(top: 1.v), + padding: EdgeInsets.only(top: 4), child: Column( children: [ Align( @@ -296,10 +308,10 @@ class DiaryScreen extends StatelessWidget { children: [ if (!isLoading) Container( - margin: EdgeInsets.symmetric(horizontal: 10.h), + margin: EdgeInsets.symmetric(horizontal: 12), padding: EdgeInsets.symmetric( - horizontal: 40.h, - vertical: 80.v, + horizontal: 32, + vertical: 64, ), decoration: AppDecoration.fillGray.copyWith( borderRadius: BorderRadiusStyle.roundedBorder5, @@ -310,8 +322,8 @@ class DiaryScreen extends StatelessWidget { children: [ Padding( padding: EdgeInsets.only( - left: 7.h, - top: 5.v, + left: 8, + top: 8, ), child: Text( "Добавить фото", @@ -328,16 +340,22 @@ class DiaryScreen extends StatelessWidget { ), if (isLoading) Container( - margin: EdgeInsets.symmetric(horizontal: 10.h), + margin: EdgeInsets.symmetric(horizontal: 12), padding: EdgeInsets.symmetric( - horizontal: 40.h, - vertical: 80.v, + horizontal: 32, + vertical: 64, ), decoration: AppDecoration.fillGray.copyWith( borderRadius: BorderRadiusStyle.roundedBorder5, ), child: Center( - child: CircularProgressIndicator(color: appTheme.blueGray300), // Замените на свой прелоадер при необходимости + child: SizedBox( + height: 32, + width: 32, + child: rive.RiveAnimation.asset( + 'assets/rive_animations/loading.riv', + ), + ), ), ), ], @@ -364,11 +382,10 @@ class DiaryScreen extends StatelessWidget { _buildMeal(BuildContext context, DiaryStateLoaded state) { final digitsOnly = FilteringTextInputFormatter.digitsOnly; List _options = state.autocompleteList.map((Product item) => item.name).toList(); - FocusNode focusNodeName = FocusNode(); return Container( padding: EdgeInsets.symmetric( - horizontal: 24.h, - vertical: 12.v, + horizontal: 24, + vertical: 12, ), decoration: BoxDecoration( color: Colors.white, @@ -378,7 +395,7 @@ class DiaryScreen extends StatelessWidget { mainAxisSize: MainAxisSize.min, children: [ Padding( - padding: EdgeInsets.symmetric(horizontal: 10.h), + padding: EdgeInsets.symmetric(horizontal: 12), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ @@ -389,7 +406,7 @@ class DiaryScreen extends StatelessWidget { Expanded( // Adding Expanded widget child: Padding( - padding: EdgeInsets.symmetric(horizontal: 10.h), + padding: EdgeInsets.symmetric(horizontal: 12), child: ConstrainedBox( constraints: BoxConstraints( maxWidth: MediaQuery.of(context).size.width - 260, @@ -409,9 +426,9 @@ class DiaryScreen extends StatelessWidget { ], ), ), - SizedBox(height: 20.v), + SizedBox(height: 24), Padding( - padding: EdgeInsets.symmetric(horizontal: 10.h), + padding: EdgeInsets.symmetric(horizontal: 12), child: BlocSelector( selector: (state) { if (state is DiaryStateLoaded) @@ -423,18 +440,18 @@ class DiaryScreen extends StatelessWidget { return CustomDropDown( items: state.mealList, contentPadding: EdgeInsets.symmetric( - horizontal: 10.h, - vertical: 9.v, + horizontal: 12, + vertical: 12, ), - defaultValue: state.mealList[0], + // defaultValue: state.mealList[0], onChanged: changeMeal(context, state), ); }, ), ), - SizedBox(height: 20.v), + SizedBox(height: 24), Padding( - padding: EdgeInsets.symmetric(horizontal: 10.h), + padding: EdgeInsets.symmetric(horizontal: 12), child: RawAutocomplete( optionsBuilder: buildOptions(_options), fieldViewBuilder: ( @@ -483,25 +500,25 @@ class DiaryScreen extends StatelessWidget { }, ), ), - SizedBox(height: 20.v), + SizedBox(height: 24), if (state.moderationExpanded) Padding( - padding: EdgeInsets.symmetric(horizontal: 10.h), + padding: EdgeInsets.symmetric(horizontal: 12), child: GestureDetector( onTap: () => openCaloriesDialog(context, state), child: Text("Отправить на модерацию"), ), ), - SizedBox(height: 20.v), + SizedBox(height: 24), Padding( - padding: EdgeInsets.symmetric(horizontal: 10.h), + padding: EdgeInsets.symmetric(horizontal: 12), child: SingleChildScrollView( scrollDirection: Axis.horizontal, child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ CustomTextFormField( - width: 150.h, + width: 128, hintText: "Кол-во", textInputAction: TextInputAction.done, // focusNode: focusNodeQuantity, @@ -510,7 +527,7 @@ class DiaryScreen extends StatelessWidget { inputFormatters: [digitsOnly], ), Padding( - padding: EdgeInsets.only(left: 30.h), + padding: EdgeInsets.only(left: 32), child: BlocSelector( selector: (state) { if (state is DiaryStateLoaded) { @@ -521,7 +538,7 @@ class DiaryScreen extends StatelessWidget { builder: (context, diary) { return CustomDropDown( items: state.portionList, - defaultValue: state.portionController, + // defaultValue: state.portionController, onChanged: changePortion(context, state), ); }, @@ -531,21 +548,21 @@ class DiaryScreen extends StatelessWidget { ), ), ), - SizedBox(height: 24.v), + SizedBox(height: 24), _buildAddProduct(context, state), - SizedBox(height: 24.v), + SizedBox(height: 24), if (!state.diary.state.has_chosen_diet) ...state.portions.map((portion) => _buildProduct(context, portion)).toList(), if (state.diary.state.has_chosen_diet) ...state.portions.map((portion) => _buildProductDiet(context, portion)).toList(), - SizedBox(height: 24.v), + SizedBox(height: 24), _buildCarousel(context, state), - SizedBox(height: 24.v), + SizedBox(height: 24), _buildAddPhoto(context, state), - SizedBox(height: 24.v), + SizedBox(height: 24), Text( "Ваша сытость после приёма пищи", style: CustomTextStyles.bodyMediumBlack900, ), - SizedBox(height: 15.v), + SizedBox(height: 16), BlocBuilder( builder: (context, state) { if (state is DiaryStateLoaded) { @@ -610,25 +627,25 @@ class DiaryScreen extends StatelessWidget { hintText: "Название", controller: state.product_nameController, ), - SizedBox(height: 10.v), + SizedBox(height: 12), CustomTextFormField( hintText: "Энергетическая ценность на 100", keyboardType: TextInputType.number, controller: state.caloriesController, ), - SizedBox(height: 10.v), + SizedBox(height: 12), CustomTextFormField( hintText: "Белки на 100г", keyboardType: TextInputType.number, controller: state.proteinsController, ), - SizedBox(height: 10.v), + SizedBox(height: 12), CustomTextFormField( hintText: "Жиры на 100г", keyboardType: TextInputType.number, controller: state.fatsController, ), - SizedBox(height: 10.v), + SizedBox(height: 12), CustomTextFormField( hintText: "Углеводы на 100г", keyboardType: TextInputType.number, @@ -744,10 +761,10 @@ class DiaryScreen extends StatelessWidget { _buildProduct(BuildContext context, Portion portion) { return Container( - margin: EdgeInsets.symmetric(horizontal: 10.h), + margin: EdgeInsets.symmetric(horizontal: 12), padding: EdgeInsets.symmetric( - horizontal: 8.h, - vertical: 6.v, + horizontal: 8, + vertical: 8, ), decoration: AppDecoration.fillGray.copyWith( borderRadius: BorderRadiusStyle.roundedBorder5, @@ -758,8 +775,8 @@ class DiaryScreen extends StatelessWidget { children: [ Padding( padding: EdgeInsets.only( - left: 7.h, - top: 5.v, + left: 8, + top: 8, ), child: Text( portion.product_name.length > 8 ? portion.product_name.substring(0, 8) : portion.product_name, @@ -768,12 +785,12 @@ class DiaryScreen extends StatelessWidget { ), Padding( padding: EdgeInsets.only( - left: 20.h, - top: 3.v, - bottom: 3.v, + left: 24, + top: 4, + bottom: 4, ), child: Text( - portion.quantity.toString() + ' ' + portion.portion.toString().tr, + portion.quantity.toString() + ' ' + portion.portion.toString(), ), ), Spacer(), @@ -795,12 +812,12 @@ class DiaryScreen extends StatelessWidget { _buildProductDiet(BuildContext context, Portion portion) { return Container( margin: EdgeInsets.symmetric( - horizontal: 10.h, - vertical: 4.h, + horizontal: 12, + vertical: 4, ), padding: EdgeInsets.symmetric( - horizontal: 8.h, - vertical: 6.v, + horizontal: 8, + vertical: 8, ), decoration: AppDecoration.fillGray.copyWith( borderRadius: BorderRadiusStyle.roundedBorder5, @@ -815,8 +832,8 @@ class DiaryScreen extends StatelessWidget { ), Padding( padding: EdgeInsets.only( - left: 7.h, - top: 5.v, + left: 8, + top: 8, ), child: Text( portion.product_name.length > 18 ? portion.product_name.substring(0, 18) : portion.product_name, @@ -826,12 +843,12 @@ class DiaryScreen extends StatelessWidget { Spacer(), Padding( padding: EdgeInsets.only( - left: 20.h, - top: 3.v, - bottom: 3.v, + left: 24, + top: 4, + bottom: 4, ), child: Text( - portion.quantity.toString() + ' ' + portion.portion.toString().tr, + portion.quantity.toString() + ' ' + portion.portion.toString(), ), ), ], @@ -843,7 +860,7 @@ class DiaryScreen extends StatelessWidget { return Stack( children: [ Container( - margin: EdgeInsets.symmetric(horizontal: 10.h, vertical: 10.h), + margin: EdgeInsets.symmetric(horizontal: 12, vertical: 12), decoration: AppDecoration.fillGray.copyWith( borderRadius: BorderRadiusStyle.roundedBorder5, ), @@ -857,7 +874,7 @@ class DiaryScreen extends StatelessWidget { left: 0, right: 0, child: Container( - height: 50.h, // Высота затемненной области + height: 64, // Высота затемненной области decoration: BoxDecoration( gradient: LinearGradient( colors: [ @@ -939,8 +956,8 @@ class DiaryScreen extends StatelessWidget { _buildWakupRetire(BuildContext context, DiaryStateLoaded state) { return Container( padding: EdgeInsets.symmetric( - horizontal: 24.h, - vertical: 12.v, + horizontal: 24, + vertical: 12, ), decoration: BoxDecoration( color: Colors.white, @@ -966,7 +983,7 @@ class DiaryScreen extends StatelessWidget { padding: const EdgeInsets.only(left: 16.0), child: Column( children: [ - SizedBox(height: 20.v), + SizedBox(height: 24), GestureDetector( onTap: () => _selectWakeupTime(context, state), child: AbsorbPointer( @@ -977,7 +994,7 @@ class DiaryScreen extends StatelessWidget { ), ), ), - SizedBox(height: 20.v), + SizedBox(height: 24), GestureDetector( onTap: () => _selectRetireTime(context, state), child: AbsorbPointer( @@ -988,7 +1005,7 @@ class DiaryScreen extends StatelessWidget { ), ), ), - SizedBox(height: 20.v), + SizedBox(height: 24), ], ), ), @@ -1045,8 +1062,8 @@ class DiaryScreen extends StatelessWidget { _buildMood(BuildContext context, DiaryStateLoaded state) { return Container( padding: EdgeInsets.symmetric( - horizontal: 24.h, - vertical: 12.v, + horizontal: 24, + vertical: 12, ), decoration: BoxDecoration( color: Colors.white, diff --git a/lib/features/diets/presentation/pages/about_diet_screen.dart b/lib/features/diets/presentation/pages/about_diet_screen.dart index 42aa3bf4..7dd66a37 100644 --- a/lib/features/diets/presentation/pages/about_diet_screen.dart +++ b/lib/features/diets/presentation/pages/about_diet_screen.dart @@ -1,22 +1,25 @@ import 'dart:io'; import 'package:cached_network_image/cached_network_image.dart'; -import 'package:eatvio_app/core/app_export.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/core/const.dart'; +import 'package:eatvio_app/features/feed/models/diets_pagination_model.dart'; 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/features/feed/presentation/widgets/comments_widget.dart'; import 'package:eatvio_app/locator_service.dart'; -import 'package:flutter/cupertino.dart'; +import 'package:eatvio_app/theme/theme_helper.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:flutter_html/flutter_html.dart'; import 'package:go_router/go_router.dart'; +import 'package:rive/rive.dart'; class AboutDietScreen extends StatefulWidget { - final Diets.Datum datum; + final Diet diet; late final List selectedIndexes; - AboutDietScreen({super.key, required this.datum}) { - selectedIndexes = List.generate(datum.dailySchedule.length, (_) => 0); + AboutDietScreen({super.key, required this.diet}) { + selectedIndexes = List.generate(diet.dailySchedule.length, (_) => 0); } @override @@ -28,17 +31,23 @@ class _AboutDietScreenState extends State { int? replyId; final textEditingController = TextEditingController(); - @override - void initState() { - super.initState(); - commentsCubit.getDietsComments(widget.datum.id); - } - @override Widget build(BuildContext context) { return BlocProvider( - create: (BuildContext context) => commentsCubit, - child: BlocBuilder( + create: (BuildContext context) => commentsCubit + ..getComments( + widget.diet.id.toString(), + CommentSourceType.diet, + true, + ), + child: BlocConsumer( + listener: (BuildContext context, CommentsState state) { + if (state is CommentsStateLoaded) { + setState(() { + replyId = state.replyId; + }); + } + }, builder: (BuildContext context, CommentsState state) { return Scaffold( resizeToAvoidBottomInset: true, @@ -80,6 +89,7 @@ class _AboutDietScreenState extends State { if (replyId != null) GestureDetector( onTap: () { + context.read().setReplyId(null); setState(() { replyId = null; textEditingController.clear(); @@ -156,11 +166,13 @@ class _AboutDietScreenState extends State { GestureDetector( onTap: () { if (textEditingController.text.length > 2) { - commentsCubit.sendDietsComment( - id: widget.datum.id, + commentsCubit.sendComment( + id: widget.diet.id.toString(), commentText: textEditingController.text, parentCommentId: replyId, + commentSourceType: CommentSourceType.diet, ); + context.read().setReplyId(null); setState(() { textEditingController.clear(); replyId = null; @@ -187,30 +199,11 @@ class _AboutDietScreenState extends State { ], ), ), - // floatingActionButtonLocation: FloatingActionButtonLocation.centerFloat, - // floatingActionButton: SizedBox( - // width: MediaQuery.of(context).size.width - 32, - // child: FloatingActionButton.extended( - // heroTag: 'nextButtonRegistration', - // highlightElevation: 0, - // elevation: 0, - // focusElevation: 0, - // shape: RoundedRectangleBorder( - // borderRadius: BorderRadius.circular(16), - // ), - // backgroundColor: appTheme.greenA700, - // onPressed: () {}, - // label: Text( - // 'Начать диету', - // style: theme.textTheme.titleSmall, - // ), - // ), - // ), appBar: AppBar( actions: [ InkWell( borderRadius: BorderRadius.circular(16), - onTap: () => GoRouter.of(context).pushNamed('profileScreen', extra: widget.datum.author), + onTap: () => GoRouter.of(context).pushNamed('profileScreen', extra: widget.diet.author), child: Ink( padding: const EdgeInsets.symmetric(horizontal: 16), child: Column( @@ -219,11 +212,11 @@ class _AboutDietScreenState extends State { CircleAvatar( maxRadius: 16, minRadius: 16, - backgroundImage: NetworkImage(widget.datum.author.authorProfileIcon), + backgroundImage: NetworkImage(widget.diet.author.authorProfileIcon), ), SizedBox(height: 4), Text( - widget.datum.author.authorName, + widget.diet.author.authorName, style: TextStyle( color: Colors.black, fontSize: 14, @@ -245,7 +238,7 @@ class _AboutDietScreenState extends State { Padding( padding: const EdgeInsets.symmetric(horizontal: 16), child: Text( - widget.datum.name, + widget.diet.name, style: TextStyle( color: Colors.black, fontSize: 24, @@ -262,7 +255,7 @@ class _AboutDietScreenState extends State { Icon(Icons.timer_outlined), SizedBox(width: 4), Text( - widget.datum.duration.toString() + ' дней', + widget.diet.duration.toString() + ' дней', style: TextStyle( color: Colors.black, fontSize: 12, @@ -273,22 +266,21 @@ class _AboutDietScreenState extends State { ], ), ), - SizedBox(height: 12), - Padding( - padding: const EdgeInsets.symmetric(horizontal: 16), - child: Text( - widget.datum.details, - style: TextStyle( - color: Colors.black, - fontSize: 14, - fontWeight: FontWeight.w400, - height: 1.2, + if (widget.diet.details.isNotEmpty) + Padding( + padding: const EdgeInsets.symmetric(horizontal: 8), + child: Html( + data: widget.diet.details, + style: { + "*": Style( + color: Colors.black87, + ), + }, ), ), - ), SizedBox(height: 12), CachedNetworkImage( - imageUrl: baseUrl + '/storage/' + widget.datum.image, + imageUrl: baseUrl + '/storage/' + widget.diet.image, ), SizedBox(height: 12), ListView.separated( @@ -296,7 +288,7 @@ class _AboutDietScreenState extends State { physics: NeverScrollableScrollPhysics(), shrinkWrap: true, itemBuilder: (context, index) { - return _dayOfPlan(widget.datum.dailySchedule[index], index); + return _dayOfPlan(widget.diet.dailySchedule[index], index); }, separatorBuilder: (context, index) => Padding( padding: const EdgeInsets.symmetric(vertical: 16), @@ -308,14 +300,25 @@ class _AboutDietScreenState extends State { ), ), ), - itemCount: widget.datum.dailySchedule.length, + itemCount: widget.diet.dailySchedule.length, ), SizedBox(height: 32), + Padding( + padding: const EdgeInsets.symmetric(horizontal: 16), + child: Container( + height: 0.4, + decoration: BoxDecoration( + color: Colors.grey, + borderRadius: BorderRadius.circular(16), + ), + ), + ), + SizedBox(height: 8), Container( padding: EdgeInsets.symmetric(horizontal: 16), alignment: Alignment.centerLeft, child: Text( - widget.datum.totalComments.toString() + ' КОММЕНТАРИЕВ', + widget.diet.totalComments.toString() + ' КОММЕНТАРИЕВ', style: TextStyle( fontSize: 12, color: appTheme.gray500, @@ -327,9 +330,21 @@ class _AboutDietScreenState extends State { if (state is CommentsStateLoading) Padding( padding: const EdgeInsets.all(32), - child: CupertinoActivityIndicator(), + child: SizedBox( + height: 32, + width: 32, + child: RiveAnimation.asset( + 'assets/rive_animations/loading.riv', + ), + ), + ), + if (state is CommentsStateLoaded) + CommentsWidget( + id: widget.diet.id.toString(), + commentSourceType: CommentSourceType.diet, + comment: state.comment, + replyId: replyId, ), - if (state is CommentsStateLoaded) _buildComments(state.comment), ], ), ), @@ -339,7 +354,7 @@ class _AboutDietScreenState extends State { ); } - _dayOfPlan(List> day, int dayNumber) { + _dayOfPlan(List> day, int dayNumber) { _choiceChipWidget(int index) { return ChoiceChip( selectedColor: appTheme.blueA400, @@ -410,7 +425,7 @@ class _AboutDietScreenState extends State { ); } - _daily(Diets.DailySchedule daily) { + _daily(DailySchedule daily) { return Row( children: [ Text( @@ -435,101 +450,4 @@ class _AboutDietScreenState extends State { ], ); } - - _buildComments(Comment comment) { - return Column( - children: [ - for (int i = 0; i < comment.data.length; i++) ...[ - _comment(comment.data[i]), - if (comment.data[i].childrenComments.isNotEmpty) - for (int j = 0; j < comment.data[i].childrenComments.length; j++) - Padding( - padding: EdgeInsets.only(left: 40), - child: _comment( - comment.data[i].childrenComments[j], - 12, - ), - ), - SizedBox(height: 8), - ], - ], - ); - } - - _comment(Datum datum, [double radius = 16]) { - return Container( - width: MediaQuery.of(context).size.width, - decoration: BoxDecoration( - color: replyId == datum.id ? appTheme.blueA400.withOpacity(0.1) : Colors.white, - borderRadius: BorderRadius.circular(16), - ), - child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 16), - child: Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - CircleAvatar( - foregroundImage: NetworkImage(datum.authorProfileIcon), - radius: radius, - ), - SizedBox(width: 8), - Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisAlignment: MainAxisAlignment.start, - children: [ - Text( - datum.authorName, - style: TextStyle( - height: 1, - color: Colors.grey.shade600, - fontWeight: FontWeight.w500, - ), - ), - SizedBox(width: 4), - Text( - datum.body, - style: TextStyle( - height: 1, - color: Colors.black, - ), - ), - SizedBox(height: 4), - Row( - children: [ - Text( - '99 августа', - // datum.createdAt.format('dd MMMM', 'ru'), - style: TextStyle( - color: Colors.grey.shade600, - fontSize: 12, - fontWeight: FontWeight.w400, - height: 1, - ), - ), - SizedBox(width: 16), - GestureDetector( - onTap: () { - setState(() { - replyId = datum.id; - }); - }, - child: Text( - 'Ответить', - style: TextStyle( - height: 1, - fontSize: 12, - color: Colors.grey.shade800, - fontWeight: FontWeight.w500, - ), - ), - ), - ], - ), - ], - ), - ], - ), - ), - ); - } } diff --git a/lib/features/feed/models/comment_model.dart b/lib/features/feed/models/comment_model.dart index 4c8aa268..1fbcb145 100644 --- a/lib/features/feed/models/comment_model.dart +++ b/lib/features/feed/models/comment_model.dart @@ -1,67 +1,30 @@ +import 'package:eatvio_app/core/models/pagination_model.dart'; import 'package:freezed_annotation/freezed_annotation.dart'; part 'comment_model.freezed.dart'; part 'comment_model.g.dart'; @freezed -class Comment with _$Comment { - const factory Comment({ - @JsonKey(name: "data") required List data, +class CommentModel with _$CommentModel { + const factory CommentModel({ + @JsonKey(name: "data") required List data, @JsonKey(name: "links") required Links links, @JsonKey(name: "meta") required Meta meta, - }) = _Comment; + }) = _CommentModel; - factory Comment.fromJson(Map json) => _$CommentFromJson(json); + factory CommentModel.fromJson(Map json) => _$CommentModelFromJson(json); } @freezed -class Datum with _$Datum { - const factory Datum({ +class Comment with _$Comment { + const factory Comment({ @JsonKey(name: "id") required int id, @JsonKey(name: "author_name") required String authorName, @JsonKey(name: "author_profile_icon") required String authorProfileIcon, @JsonKey(name: "body") required String body, - @JsonKey(name: "children_comments") required List childrenComments, - }) = _Datum; + @JsonKey(name: "children_comments") required List childrenComments, + @JsonKey(name: "created_at") required DateTime createdAt, + }) = _Comment; - factory Datum.fromJson(Map json) => _$DatumFromJson(json); -} - -@freezed -class Links with _$Links { - const factory Links({ - @JsonKey(name: "first") required String first, - @JsonKey(name: "last") required String last, - @JsonKey(name: "prev") required dynamic prev, - @JsonKey(name: "next") required dynamic next, - }) = _Links; - - factory Links.fromJson(Map json) => _$LinksFromJson(json); -} - -@freezed -class Meta with _$Meta { - const factory Meta({ - @JsonKey(name: "current_page") required int currentPage, - @JsonKey(name: "from") required int from, - @JsonKey(name: "last_page") required int lastPage, - @JsonKey(name: "links") required List links, - @JsonKey(name: "path") required String path, - @JsonKey(name: "per_page") required int perPage, - @JsonKey(name: "to") required int to, - @JsonKey(name: "total") required int total, - }) = _Meta; - - factory Meta.fromJson(Map json) => _$MetaFromJson(json); -} - -@freezed -class Link with _$Link { - const factory Link({ - @JsonKey(name: "url") required String? url, - @JsonKey(name: "label") required String label, - @JsonKey(name: "active") required bool active, - }) = _Link; - - factory Link.fromJson(Map json) => _$LinkFromJson(json); + factory Comment.fromJson(Map json) => _$CommentFromJson(json); } diff --git a/lib/features/feed/models/comment_model.freezed.dart b/lib/features/feed/models/comment_model.freezed.dart index 3f088135..4e520131 100644 --- a/lib/features/feed/models/comment_model.freezed.dart +++ b/lib/features/feed/models/comment_model.freezed.dart @@ -14,31 +14,37 @@ 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'); -Comment _$CommentFromJson(Map json) { - return _Comment.fromJson(json); +CommentModel _$CommentModelFromJson(Map json) { + return _CommentModel.fromJson(json); } /// @nodoc -mixin _$Comment { +mixin _$CommentModel { @JsonKey(name: "data") - List get data => throw _privateConstructorUsedError; + List get data => throw _privateConstructorUsedError; @JsonKey(name: "links") Links get links => throw _privateConstructorUsedError; @JsonKey(name: "meta") Meta get meta => throw _privateConstructorUsedError; + /// Serializes this CommentModel to a JSON map. Map toJson() => throw _privateConstructorUsedError; - @JsonKey(ignore: true) - $CommentCopyWith get copyWith => throw _privateConstructorUsedError; + + /// Create a copy of CommentModel + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $CommentModelCopyWith get copyWith => + throw _privateConstructorUsedError; } /// @nodoc -abstract class $CommentCopyWith<$Res> { - factory $CommentCopyWith(Comment value, $Res Function(Comment) then) = - _$CommentCopyWithImpl<$Res, Comment>; +abstract class $CommentModelCopyWith<$Res> { + factory $CommentModelCopyWith( + CommentModel value, $Res Function(CommentModel) then) = + _$CommentModelCopyWithImpl<$Res, CommentModel>; @useResult $Res call( - {@JsonKey(name: "data") List data, + {@JsonKey(name: "data") List data, @JsonKey(name: "links") Links links, @JsonKey(name: "meta") Meta meta}); @@ -47,15 +53,17 @@ abstract class $CommentCopyWith<$Res> { } /// @nodoc -class _$CommentCopyWithImpl<$Res, $Val extends Comment> - implements $CommentCopyWith<$Res> { - _$CommentCopyWithImpl(this._value, this._then); +class _$CommentModelCopyWithImpl<$Res, $Val extends CommentModel> + implements $CommentModelCopyWith<$Res> { + _$CommentModelCopyWithImpl(this._value, this._then); // ignore: unused_field final $Val _value; // ignore: unused_field final $Res Function($Val) _then; + /// Create a copy of CommentModel + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -67,7 +75,7 @@ class _$CommentCopyWithImpl<$Res, $Val extends Comment> data: null == data ? _value.data : data // ignore: cast_nullable_to_non_nullable - as List, + as List, links: null == links ? _value.links : links // ignore: cast_nullable_to_non_nullable @@ -79,6 +87,8 @@ class _$CommentCopyWithImpl<$Res, $Val extends Comment> ) as $Val); } + /// Create a copy of CommentModel + /// with the given fields replaced by the non-null parameter values. @override @pragma('vm:prefer-inline') $LinksCopyWith<$Res> get links { @@ -87,6 +97,8 @@ class _$CommentCopyWithImpl<$Res, $Val extends Comment> }); } + /// Create a copy of CommentModel + /// with the given fields replaced by the non-null parameter values. @override @pragma('vm:prefer-inline') $MetaCopyWith<$Res> get meta { @@ -97,14 +109,15 @@ class _$CommentCopyWithImpl<$Res, $Val extends Comment> } /// @nodoc -abstract class _$$CommentImplCopyWith<$Res> implements $CommentCopyWith<$Res> { - factory _$$CommentImplCopyWith( - _$CommentImpl value, $Res Function(_$CommentImpl) then) = - __$$CommentImplCopyWithImpl<$Res>; +abstract class _$$CommentModelImplCopyWith<$Res> + implements $CommentModelCopyWith<$Res> { + factory _$$CommentModelImplCopyWith( + _$CommentModelImpl value, $Res Function(_$CommentModelImpl) then) = + __$$CommentModelImplCopyWithImpl<$Res>; @override @useResult $Res call( - {@JsonKey(name: "data") List data, + {@JsonKey(name: "data") List data, @JsonKey(name: "links") Links links, @JsonKey(name: "meta") Meta meta}); @@ -115,13 +128,15 @@ abstract class _$$CommentImplCopyWith<$Res> implements $CommentCopyWith<$Res> { } /// @nodoc -class __$$CommentImplCopyWithImpl<$Res> - extends _$CommentCopyWithImpl<$Res, _$CommentImpl> - implements _$$CommentImplCopyWith<$Res> { - __$$CommentImplCopyWithImpl( - _$CommentImpl _value, $Res Function(_$CommentImpl) _then) +class __$$CommentModelImplCopyWithImpl<$Res> + extends _$CommentModelCopyWithImpl<$Res, _$CommentModelImpl> + implements _$$CommentModelImplCopyWith<$Res> { + __$$CommentModelImplCopyWithImpl( + _$CommentModelImpl _value, $Res Function(_$CommentModelImpl) _then) : super(_value, _then); + /// Create a copy of CommentModel + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -129,11 +144,11 @@ class __$$CommentImplCopyWithImpl<$Res> Object? links = null, Object? meta = null, }) { - return _then(_$CommentImpl( + return _then(_$CommentModelImpl( data: null == data ? _value._data : data // ignore: cast_nullable_to_non_nullable - as List, + as List, links: null == links ? _value.links : links // ignore: cast_nullable_to_non_nullable @@ -148,20 +163,20 @@ class __$$CommentImplCopyWithImpl<$Res> /// @nodoc @JsonSerializable() -class _$CommentImpl implements _Comment { - const _$CommentImpl( - {@JsonKey(name: "data") required final List data, +class _$CommentModelImpl implements _CommentModel { + const _$CommentModelImpl( + {@JsonKey(name: "data") required final List data, @JsonKey(name: "links") required this.links, @JsonKey(name: "meta") required this.meta}) : _data = data; - factory _$CommentImpl.fromJson(Map json) => - _$$CommentImplFromJson(json); + factory _$CommentModelImpl.fromJson(Map json) => + _$$CommentModelImplFromJson(json); - final List _data; + final List _data; @override @JsonKey(name: "data") - List get data { + List get data { if (_data is EqualUnmodifiableListView) return _data; // ignore: implicit_dynamic_type return EqualUnmodifiableListView(_data); @@ -176,67 +191,73 @@ class _$CommentImpl implements _Comment { @override String toString() { - return 'Comment(data: $data, links: $links, meta: $meta)'; + return 'CommentModel(data: $data, links: $links, meta: $meta)'; } @override bool operator ==(Object other) { return identical(this, other) || (other.runtimeType == runtimeType && - other is _$CommentImpl && + other is _$CommentModelImpl && const DeepCollectionEquality().equals(other._data, _data) && (identical(other.links, links) || other.links == links) && (identical(other.meta, meta) || other.meta == meta)); } - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) @override int get hashCode => Object.hash( runtimeType, const DeepCollectionEquality().hash(_data), links, meta); - @JsonKey(ignore: true) + /// Create a copy of CommentModel + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') - _$$CommentImplCopyWith<_$CommentImpl> get copyWith => - __$$CommentImplCopyWithImpl<_$CommentImpl>(this, _$identity); + _$$CommentModelImplCopyWith<_$CommentModelImpl> get copyWith => + __$$CommentModelImplCopyWithImpl<_$CommentModelImpl>(this, _$identity); @override Map toJson() { - return _$$CommentImplToJson( + return _$$CommentModelImplToJson( this, ); } } -abstract class _Comment implements Comment { - const factory _Comment( - {@JsonKey(name: "data") required final List data, +abstract class _CommentModel implements CommentModel { + const factory _CommentModel( + {@JsonKey(name: "data") required final List data, @JsonKey(name: "links") required final Links links, - @JsonKey(name: "meta") required final Meta meta}) = _$CommentImpl; + @JsonKey(name: "meta") required final Meta meta}) = _$CommentModelImpl; - factory _Comment.fromJson(Map json) = _$CommentImpl.fromJson; + factory _CommentModel.fromJson(Map json) = + _$CommentModelImpl.fromJson; @override @JsonKey(name: "data") - List get data; + List get data; @override @JsonKey(name: "links") Links get links; @override @JsonKey(name: "meta") Meta get meta; + + /// Create a copy of CommentModel + /// with the given fields replaced by the non-null parameter values. @override - @JsonKey(ignore: true) - _$$CommentImplCopyWith<_$CommentImpl> get copyWith => + @JsonKey(includeFromJson: false, includeToJson: false) + _$$CommentModelImplCopyWith<_$CommentModelImpl> get copyWith => throw _privateConstructorUsedError; } -Datum _$DatumFromJson(Map json) { - return _Datum.fromJson(json); +Comment _$CommentFromJson(Map json) { + return _Comment.fromJson(json); } /// @nodoc -mixin _$Datum { +mixin _$Comment { @JsonKey(name: "id") int get id => throw _privateConstructorUsedError; @JsonKey(name: "author_name") @@ -246,36 +267,45 @@ mixin _$Datum { @JsonKey(name: "body") String get body => throw _privateConstructorUsedError; @JsonKey(name: "children_comments") - List get childrenComments => throw _privateConstructorUsedError; + List get childrenComments => throw _privateConstructorUsedError; + @JsonKey(name: "created_at") + DateTime get createdAt => throw _privateConstructorUsedError; + /// Serializes this Comment to a JSON map. Map toJson() => throw _privateConstructorUsedError; - @JsonKey(ignore: true) - $DatumCopyWith get copyWith => throw _privateConstructorUsedError; + + /// Create a copy of Comment + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $CommentCopyWith get copyWith => throw _privateConstructorUsedError; } /// @nodoc -abstract class $DatumCopyWith<$Res> { - factory $DatumCopyWith(Datum value, $Res Function(Datum) then) = - _$DatumCopyWithImpl<$Res, Datum>; +abstract class $CommentCopyWith<$Res> { + factory $CommentCopyWith(Comment value, $Res Function(Comment) then) = + _$CommentCopyWithImpl<$Res, Comment>; @useResult $Res call( {@JsonKey(name: "id") int id, @JsonKey(name: "author_name") String authorName, @JsonKey(name: "author_profile_icon") String authorProfileIcon, @JsonKey(name: "body") String body, - @JsonKey(name: "children_comments") List childrenComments}); + @JsonKey(name: "children_comments") List childrenComments, + @JsonKey(name: "created_at") DateTime createdAt}); } /// @nodoc -class _$DatumCopyWithImpl<$Res, $Val extends Datum> - implements $DatumCopyWith<$Res> { - _$DatumCopyWithImpl(this._value, this._then); +class _$CommentCopyWithImpl<$Res, $Val extends Comment> + implements $CommentCopyWith<$Res> { + _$CommentCopyWithImpl(this._value, this._then); // ignore: unused_field final $Val _value; // 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({ @@ -284,6 +314,7 @@ class _$DatumCopyWithImpl<$Res, $Val extends Datum> Object? authorProfileIcon = null, Object? body = null, Object? childrenComments = null, + Object? createdAt = null, }) { return _then(_value.copyWith( id: null == id @@ -305,16 +336,20 @@ class _$DatumCopyWithImpl<$Res, $Val extends Datum> childrenComments: null == childrenComments ? _value.childrenComments : childrenComments // ignore: cast_nullable_to_non_nullable - as List, + as List, + createdAt: null == createdAt + ? _value.createdAt + : createdAt // ignore: cast_nullable_to_non_nullable + as DateTime, ) as $Val); } } /// @nodoc -abstract class _$$DatumImplCopyWith<$Res> implements $DatumCopyWith<$Res> { - factory _$$DatumImplCopyWith( - _$DatumImpl value, $Res Function(_$DatumImpl) then) = - __$$DatumImplCopyWithImpl<$Res>; +abstract class _$$CommentImplCopyWith<$Res> implements $CommentCopyWith<$Res> { + factory _$$CommentImplCopyWith( + _$CommentImpl value, $Res Function(_$CommentImpl) then) = + __$$CommentImplCopyWithImpl<$Res>; @override @useResult $Res call( @@ -322,17 +357,20 @@ abstract class _$$DatumImplCopyWith<$Res> implements $DatumCopyWith<$Res> { @JsonKey(name: "author_name") String authorName, @JsonKey(name: "author_profile_icon") String authorProfileIcon, @JsonKey(name: "body") String body, - @JsonKey(name: "children_comments") List childrenComments}); + @JsonKey(name: "children_comments") List childrenComments, + @JsonKey(name: "created_at") DateTime createdAt}); } /// @nodoc -class __$$DatumImplCopyWithImpl<$Res> - extends _$DatumCopyWithImpl<$Res, _$DatumImpl> - implements _$$DatumImplCopyWith<$Res> { - __$$DatumImplCopyWithImpl( - _$DatumImpl _value, $Res Function(_$DatumImpl) _then) +class __$$CommentImplCopyWithImpl<$Res> + extends _$CommentCopyWithImpl<$Res, _$CommentImpl> + implements _$$CommentImplCopyWith<$Res> { + __$$CommentImplCopyWithImpl( + _$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({ @@ -341,8 +379,9 @@ class __$$DatumImplCopyWithImpl<$Res> Object? authorProfileIcon = null, Object? body = null, Object? childrenComments = null, + Object? createdAt = null, }) { - return _then(_$DatumImpl( + return _then(_$CommentImpl( id: null == id ? _value.id : id // ignore: cast_nullable_to_non_nullable @@ -362,25 +401,30 @@ class __$$DatumImplCopyWithImpl<$Res> childrenComments: null == childrenComments ? _value._childrenComments : childrenComments // ignore: cast_nullable_to_non_nullable - as List, + as List, + createdAt: null == createdAt + ? _value.createdAt + : createdAt // ignore: cast_nullable_to_non_nullable + as DateTime, )); } } /// @nodoc @JsonSerializable() -class _$DatumImpl implements _Datum { - const _$DatumImpl( +class _$CommentImpl implements _Comment { + const _$CommentImpl( {@JsonKey(name: "id") required this.id, @JsonKey(name: "author_name") required this.authorName, @JsonKey(name: "author_profile_icon") required this.authorProfileIcon, @JsonKey(name: "body") required this.body, @JsonKey(name: "children_comments") - required final List childrenComments}) + required final List childrenComments, + @JsonKey(name: "created_at") required this.createdAt}) : _childrenComments = childrenComments; - factory _$DatumImpl.fromJson(Map json) => - _$$DatumImplFromJson(json); + factory _$CommentImpl.fromJson(Map json) => + _$$CommentImplFromJson(json); @override @JsonKey(name: "id") @@ -394,26 +438,30 @@ class _$DatumImpl implements _Datum { @override @JsonKey(name: "body") final String body; - final List _childrenComments; + final List _childrenComments; @override @JsonKey(name: "children_comments") - List get childrenComments { + List get childrenComments { if (_childrenComments is EqualUnmodifiableListView) return _childrenComments; // ignore: implicit_dynamic_type return EqualUnmodifiableListView(_childrenComments); } + @override + @JsonKey(name: "created_at") + final DateTime createdAt; + @override String toString() { - return 'Datum(id: $id, authorName: $authorName, authorProfileIcon: $authorProfileIcon, body: $body, childrenComments: $childrenComments)'; + return 'Comment(id: $id, authorName: $authorName, authorProfileIcon: $authorProfileIcon, body: $body, childrenComments: $childrenComments, createdAt: $createdAt)'; } @override bool operator ==(Object other) { return identical(this, other) || (other.runtimeType == runtimeType && - other is _$DatumImpl && + other is _$CommentImpl && (identical(other.id, id) || other.id == id) && (identical(other.authorName, authorName) || other.authorName == authorName) && @@ -421,10 +469,12 @@ class _$DatumImpl implements _Datum { other.authorProfileIcon == authorProfileIcon) && (identical(other.body, body) || other.body == body) && const DeepCollectionEquality() - .equals(other._childrenComments, _childrenComments)); + .equals(other._childrenComments, _childrenComments) && + (identical(other.createdAt, createdAt) || + other.createdAt == createdAt)); } - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) @override int get hashCode => Object.hash( runtimeType, @@ -432,33 +482,38 @@ class _$DatumImpl implements _Datum { authorName, authorProfileIcon, body, - const DeepCollectionEquality().hash(_childrenComments)); + const DeepCollectionEquality().hash(_childrenComments), + createdAt); - @JsonKey(ignore: true) + /// Create a copy of Comment + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') - _$$DatumImplCopyWith<_$DatumImpl> get copyWith => - __$$DatumImplCopyWithImpl<_$DatumImpl>(this, _$identity); + _$$CommentImplCopyWith<_$CommentImpl> get copyWith => + __$$CommentImplCopyWithImpl<_$CommentImpl>(this, _$identity); @override Map toJson() { - return _$$DatumImplToJson( + return _$$CommentImplToJson( this, ); } } -abstract class _Datum implements Datum { - const factory _Datum( - {@JsonKey(name: "id") required final int id, - @JsonKey(name: "author_name") required final String authorName, - @JsonKey(name: "author_profile_icon") - required final String authorProfileIcon, - @JsonKey(name: "body") required final String body, - @JsonKey(name: "children_comments") - required final List childrenComments}) = _$DatumImpl; +abstract class _Comment implements Comment { + const factory _Comment( + {@JsonKey(name: "id") required final int id, + @JsonKey(name: "author_name") required final String authorName, + @JsonKey(name: "author_profile_icon") + required final String authorProfileIcon, + @JsonKey(name: "body") required final String body, + @JsonKey(name: "children_comments") + required final List childrenComments, + @JsonKey(name: "created_at") required final DateTime createdAt}) = + _$CommentImpl; - factory _Datum.fromJson(Map json) = _$DatumImpl.fromJson; + factory _Comment.fromJson(Map json) = _$CommentImpl.fromJson; @override @JsonKey(name: "id") @@ -474,715 +529,15 @@ abstract class _Datum implements Datum { String get body; @override @JsonKey(name: "children_comments") - List get childrenComments; + List get childrenComments; @override - @JsonKey(ignore: true) - _$$DatumImplCopyWith<_$DatumImpl> get copyWith => - throw _privateConstructorUsedError; -} - -Links _$LinksFromJson(Map json) { - return _Links.fromJson(json); -} - -/// @nodoc -mixin _$Links { - @JsonKey(name: "first") - String get first => throw _privateConstructorUsedError; - @JsonKey(name: "last") - String get last => throw _privateConstructorUsedError; - @JsonKey(name: "prev") - dynamic get prev => throw _privateConstructorUsedError; - @JsonKey(name: "next") - dynamic get next => throw _privateConstructorUsedError; - - Map toJson() => throw _privateConstructorUsedError; - @JsonKey(ignore: true) - $LinksCopyWith get copyWith => throw _privateConstructorUsedError; -} - -/// @nodoc -abstract class $LinksCopyWith<$Res> { - factory $LinksCopyWith(Links value, $Res Function(Links) then) = - _$LinksCopyWithImpl<$Res, Links>; - @useResult - $Res call( - {@JsonKey(name: "first") String first, - @JsonKey(name: "last") String last, - @JsonKey(name: "prev") dynamic prev, - @JsonKey(name: "next") dynamic next}); -} - -/// @nodoc -class _$LinksCopyWithImpl<$Res, $Val extends Links> - implements $LinksCopyWith<$Res> { - _$LinksCopyWithImpl(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? first = null, - Object? last = null, - Object? prev = freezed, - Object? next = freezed, - }) { - return _then(_value.copyWith( - first: null == first - ? _value.first - : first // ignore: cast_nullable_to_non_nullable - as String, - last: null == last - ? _value.last - : last // ignore: cast_nullable_to_non_nullable - as String, - prev: freezed == prev - ? _value.prev - : prev // ignore: cast_nullable_to_non_nullable - as dynamic, - next: freezed == next - ? _value.next - : next // ignore: cast_nullable_to_non_nullable - as dynamic, - ) as $Val); - } -} - -/// @nodoc -abstract class _$$LinksImplCopyWith<$Res> implements $LinksCopyWith<$Res> { - factory _$$LinksImplCopyWith( - _$LinksImpl value, $Res Function(_$LinksImpl) then) = - __$$LinksImplCopyWithImpl<$Res>; - @override - @useResult - $Res call( - {@JsonKey(name: "first") String first, - @JsonKey(name: "last") String last, - @JsonKey(name: "prev") dynamic prev, - @JsonKey(name: "next") dynamic next}); -} - -/// @nodoc -class __$$LinksImplCopyWithImpl<$Res> - extends _$LinksCopyWithImpl<$Res, _$LinksImpl> - implements _$$LinksImplCopyWith<$Res> { - __$$LinksImplCopyWithImpl( - _$LinksImpl _value, $Res Function(_$LinksImpl) _then) - : super(_value, _then); - - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? first = null, - Object? last = null, - Object? prev = freezed, - Object? next = freezed, - }) { - return _then(_$LinksImpl( - first: null == first - ? _value.first - : first // ignore: cast_nullable_to_non_nullable - as String, - last: null == last - ? _value.last - : last // ignore: cast_nullable_to_non_nullable - as String, - prev: freezed == prev - ? _value.prev - : prev // ignore: cast_nullable_to_non_nullable - as dynamic, - next: freezed == next - ? _value.next - : next // ignore: cast_nullable_to_non_nullable - as dynamic, - )); - } -} - -/// @nodoc -@JsonSerializable() -class _$LinksImpl implements _Links { - const _$LinksImpl( - {@JsonKey(name: "first") required this.first, - @JsonKey(name: "last") required this.last, - @JsonKey(name: "prev") required this.prev, - @JsonKey(name: "next") required this.next}); - - factory _$LinksImpl.fromJson(Map json) => - _$$LinksImplFromJson(json); - - @override - @JsonKey(name: "first") - final String first; - @override - @JsonKey(name: "last") - final String last; - @override - @JsonKey(name: "prev") - final dynamic prev; - @override - @JsonKey(name: "next") - final dynamic next; - - @override - String toString() { - return 'Links(first: $first, last: $last, prev: $prev, next: $next)'; - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _$LinksImpl && - (identical(other.first, first) || other.first == first) && - (identical(other.last, last) || other.last == last) && - const DeepCollectionEquality().equals(other.prev, prev) && - const DeepCollectionEquality().equals(other.next, next)); - } - - @JsonKey(ignore: true) - @override - int get hashCode => Object.hash( - runtimeType, - first, - last, - const DeepCollectionEquality().hash(prev), - const DeepCollectionEquality().hash(next)); - - @JsonKey(ignore: true) - @override - @pragma('vm:prefer-inline') - _$$LinksImplCopyWith<_$LinksImpl> get copyWith => - __$$LinksImplCopyWithImpl<_$LinksImpl>(this, _$identity); - - @override - Map toJson() { - return _$$LinksImplToJson( - this, - ); - } -} - -abstract class _Links implements Links { - const factory _Links( - {@JsonKey(name: "first") required final String first, - @JsonKey(name: "last") required final String last, - @JsonKey(name: "prev") required final dynamic prev, - @JsonKey(name: "next") required final dynamic next}) = _$LinksImpl; - - factory _Links.fromJson(Map json) = _$LinksImpl.fromJson; - - @override - @JsonKey(name: "first") - String get first; - @override - @JsonKey(name: "last") - String get last; - @override - @JsonKey(name: "prev") - dynamic get prev; - @override - @JsonKey(name: "next") - dynamic get next; - @override - @JsonKey(ignore: true) - _$$LinksImplCopyWith<_$LinksImpl> get copyWith => - throw _privateConstructorUsedError; -} - -Meta _$MetaFromJson(Map json) { - return _Meta.fromJson(json); -} - -/// @nodoc -mixin _$Meta { - @JsonKey(name: "current_page") - int get currentPage => throw _privateConstructorUsedError; - @JsonKey(name: "from") - int get from => throw _privateConstructorUsedError; - @JsonKey(name: "last_page") - int get lastPage => throw _privateConstructorUsedError; - @JsonKey(name: "links") - List get links => throw _privateConstructorUsedError; - @JsonKey(name: "path") - String get path => throw _privateConstructorUsedError; - @JsonKey(name: "per_page") - int get perPage => throw _privateConstructorUsedError; - @JsonKey(name: "to") - int get to => throw _privateConstructorUsedError; - @JsonKey(name: "total") - int get total => throw _privateConstructorUsedError; - - Map toJson() => throw _privateConstructorUsedError; - @JsonKey(ignore: true) - $MetaCopyWith get copyWith => throw _privateConstructorUsedError; -} - -/// @nodoc -abstract class $MetaCopyWith<$Res> { - factory $MetaCopyWith(Meta value, $Res Function(Meta) then) = - _$MetaCopyWithImpl<$Res, Meta>; - @useResult - $Res call( - {@JsonKey(name: "current_page") int currentPage, - @JsonKey(name: "from") int from, - @JsonKey(name: "last_page") int lastPage, - @JsonKey(name: "links") List links, - @JsonKey(name: "path") String path, - @JsonKey(name: "per_page") int perPage, - @JsonKey(name: "to") int to, - @JsonKey(name: "total") int total}); -} - -/// @nodoc -class _$MetaCopyWithImpl<$Res, $Val extends Meta> - implements $MetaCopyWith<$Res> { - _$MetaCopyWithImpl(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? currentPage = null, - Object? from = null, - Object? lastPage = null, - Object? links = null, - Object? path = null, - Object? perPage = null, - Object? to = null, - Object? total = null, - }) { - return _then(_value.copyWith( - currentPage: null == currentPage - ? _value.currentPage - : currentPage // ignore: cast_nullable_to_non_nullable - as int, - from: null == from - ? _value.from - : from // ignore: cast_nullable_to_non_nullable - as int, - lastPage: null == lastPage - ? _value.lastPage - : lastPage // ignore: cast_nullable_to_non_nullable - as int, - links: null == links - ? _value.links - : links // ignore: cast_nullable_to_non_nullable - as List, - path: null == path - ? _value.path - : path // ignore: cast_nullable_to_non_nullable - as String, - perPage: null == perPage - ? _value.perPage - : perPage // ignore: cast_nullable_to_non_nullable - as int, - to: null == to - ? _value.to - : to // ignore: cast_nullable_to_non_nullable - as int, - total: null == total - ? _value.total - : total // ignore: cast_nullable_to_non_nullable - as int, - ) as $Val); - } -} - -/// @nodoc -abstract class _$$MetaImplCopyWith<$Res> implements $MetaCopyWith<$Res> { - factory _$$MetaImplCopyWith( - _$MetaImpl value, $Res Function(_$MetaImpl) then) = - __$$MetaImplCopyWithImpl<$Res>; - @override - @useResult - $Res call( - {@JsonKey(name: "current_page") int currentPage, - @JsonKey(name: "from") int from, - @JsonKey(name: "last_page") int lastPage, - @JsonKey(name: "links") List links, - @JsonKey(name: "path") String path, - @JsonKey(name: "per_page") int perPage, - @JsonKey(name: "to") int to, - @JsonKey(name: "total") int total}); -} - -/// @nodoc -class __$$MetaImplCopyWithImpl<$Res> - extends _$MetaCopyWithImpl<$Res, _$MetaImpl> - implements _$$MetaImplCopyWith<$Res> { - __$$MetaImplCopyWithImpl(_$MetaImpl _value, $Res Function(_$MetaImpl) _then) - : super(_value, _then); - - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? currentPage = null, - Object? from = null, - Object? lastPage = null, - Object? links = null, - Object? path = null, - Object? perPage = null, - Object? to = null, - Object? total = null, - }) { - return _then(_$MetaImpl( - currentPage: null == currentPage - ? _value.currentPage - : currentPage // ignore: cast_nullable_to_non_nullable - as int, - from: null == from - ? _value.from - : from // ignore: cast_nullable_to_non_nullable - as int, - lastPage: null == lastPage - ? _value.lastPage - : lastPage // ignore: cast_nullable_to_non_nullable - as int, - links: null == links - ? _value._links - : links // ignore: cast_nullable_to_non_nullable - as List, - path: null == path - ? _value.path - : path // ignore: cast_nullable_to_non_nullable - as String, - perPage: null == perPage - ? _value.perPage - : perPage // ignore: cast_nullable_to_non_nullable - as int, - to: null == to - ? _value.to - : to // ignore: cast_nullable_to_non_nullable - as int, - total: null == total - ? _value.total - : total // ignore: cast_nullable_to_non_nullable - as int, - )); - } -} - -/// @nodoc -@JsonSerializable() -class _$MetaImpl implements _Meta { - const _$MetaImpl( - {@JsonKey(name: "current_page") required this.currentPage, - @JsonKey(name: "from") required this.from, - @JsonKey(name: "last_page") required this.lastPage, - @JsonKey(name: "links") required final List links, - @JsonKey(name: "path") required this.path, - @JsonKey(name: "per_page") required this.perPage, - @JsonKey(name: "to") required this.to, - @JsonKey(name: "total") required this.total}) - : _links = links; - - factory _$MetaImpl.fromJson(Map json) => - _$$MetaImplFromJson(json); - - @override - @JsonKey(name: "current_page") - final int currentPage; - @override - @JsonKey(name: "from") - final int from; - @override - @JsonKey(name: "last_page") - final int lastPage; - final List _links; - @override - @JsonKey(name: "links") - List get links { - if (_links is EqualUnmodifiableListView) return _links; - // ignore: implicit_dynamic_type - return EqualUnmodifiableListView(_links); - } - - @override - @JsonKey(name: "path") - final String path; - @override - @JsonKey(name: "per_page") - final int perPage; - @override - @JsonKey(name: "to") - final int to; - @override - @JsonKey(name: "total") - final int total; - - @override - String toString() { - return 'Meta(currentPage: $currentPage, from: $from, lastPage: $lastPage, links: $links, path: $path, perPage: $perPage, to: $to, total: $total)'; - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _$MetaImpl && - (identical(other.currentPage, currentPage) || - other.currentPage == currentPage) && - (identical(other.from, from) || other.from == from) && - (identical(other.lastPage, lastPage) || - other.lastPage == lastPage) && - const DeepCollectionEquality().equals(other._links, _links) && - (identical(other.path, path) || other.path == path) && - (identical(other.perPage, perPage) || other.perPage == perPage) && - (identical(other.to, to) || other.to == to) && - (identical(other.total, total) || other.total == total)); - } - - @JsonKey(ignore: true) - @override - int get hashCode => Object.hash(runtimeType, currentPage, from, lastPage, - const DeepCollectionEquality().hash(_links), path, perPage, to, total); - - @JsonKey(ignore: true) - @override - @pragma('vm:prefer-inline') - _$$MetaImplCopyWith<_$MetaImpl> get copyWith => - __$$MetaImplCopyWithImpl<_$MetaImpl>(this, _$identity); - - @override - Map toJson() { - return _$$MetaImplToJson( - this, - ); - } -} - -abstract class _Meta implements Meta { - const factory _Meta( - {@JsonKey(name: "current_page") required final int currentPage, - @JsonKey(name: "from") required final int from, - @JsonKey(name: "last_page") required final int lastPage, - @JsonKey(name: "links") required final List links, - @JsonKey(name: "path") required final String path, - @JsonKey(name: "per_page") required final int perPage, - @JsonKey(name: "to") required final int to, - @JsonKey(name: "total") required final int total}) = _$MetaImpl; - - factory _Meta.fromJson(Map json) = _$MetaImpl.fromJson; - - @override - @JsonKey(name: "current_page") - int get currentPage; - @override - @JsonKey(name: "from") - int get from; - @override - @JsonKey(name: "last_page") - int get lastPage; - @override - @JsonKey(name: "links") - List get links; - @override - @JsonKey(name: "path") - String get path; - @override - @JsonKey(name: "per_page") - int get perPage; - @override - @JsonKey(name: "to") - int get to; - @override - @JsonKey(name: "total") - int get total; - @override - @JsonKey(ignore: true) - _$$MetaImplCopyWith<_$MetaImpl> get copyWith => - throw _privateConstructorUsedError; -} - -Link _$LinkFromJson(Map json) { - return _Link.fromJson(json); -} - -/// @nodoc -mixin _$Link { - @JsonKey(name: "url") - String? get url => throw _privateConstructorUsedError; - @JsonKey(name: "label") - String get label => throw _privateConstructorUsedError; - @JsonKey(name: "active") - bool get active => throw _privateConstructorUsedError; - - Map toJson() => throw _privateConstructorUsedError; - @JsonKey(ignore: true) - $LinkCopyWith get copyWith => throw _privateConstructorUsedError; -} - -/// @nodoc -abstract class $LinkCopyWith<$Res> { - factory $LinkCopyWith(Link value, $Res Function(Link) then) = - _$LinkCopyWithImpl<$Res, Link>; - @useResult - $Res call( - {@JsonKey(name: "url") String? url, - @JsonKey(name: "label") String label, - @JsonKey(name: "active") bool active}); -} - -/// @nodoc -class _$LinkCopyWithImpl<$Res, $Val extends Link> - implements $LinkCopyWith<$Res> { - _$LinkCopyWithImpl(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? url = freezed, - Object? label = null, - Object? active = null, - }) { - return _then(_value.copyWith( - url: freezed == url - ? _value.url - : url // ignore: cast_nullable_to_non_nullable - as String?, - label: null == label - ? _value.label - : label // ignore: cast_nullable_to_non_nullable - as String, - active: null == active - ? _value.active - : active // ignore: cast_nullable_to_non_nullable - as bool, - ) as $Val); - } -} - -/// @nodoc -abstract class _$$LinkImplCopyWith<$Res> implements $LinkCopyWith<$Res> { - factory _$$LinkImplCopyWith( - _$LinkImpl value, $Res Function(_$LinkImpl) then) = - __$$LinkImplCopyWithImpl<$Res>; - @override - @useResult - $Res call( - {@JsonKey(name: "url") String? url, - @JsonKey(name: "label") String label, - @JsonKey(name: "active") bool active}); -} - -/// @nodoc -class __$$LinkImplCopyWithImpl<$Res> - extends _$LinkCopyWithImpl<$Res, _$LinkImpl> - implements _$$LinkImplCopyWith<$Res> { - __$$LinkImplCopyWithImpl(_$LinkImpl _value, $Res Function(_$LinkImpl) _then) - : super(_value, _then); - - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? url = freezed, - Object? label = null, - Object? active = null, - }) { - return _then(_$LinkImpl( - url: freezed == url - ? _value.url - : url // ignore: cast_nullable_to_non_nullable - as String?, - label: null == label - ? _value.label - : label // ignore: cast_nullable_to_non_nullable - as String, - active: null == active - ? _value.active - : active // ignore: cast_nullable_to_non_nullable - as bool, - )); - } -} - -/// @nodoc -@JsonSerializable() -class _$LinkImpl implements _Link { - const _$LinkImpl( - {@JsonKey(name: "url") required this.url, - @JsonKey(name: "label") required this.label, - @JsonKey(name: "active") required this.active}); - - factory _$LinkImpl.fromJson(Map json) => - _$$LinkImplFromJson(json); - - @override - @JsonKey(name: "url") - final String? url; - @override - @JsonKey(name: "label") - final String label; - @override - @JsonKey(name: "active") - final bool active; - - @override - String toString() { - return 'Link(url: $url, label: $label, active: $active)'; - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _$LinkImpl && - (identical(other.url, url) || other.url == url) && - (identical(other.label, label) || other.label == label) && - (identical(other.active, active) || other.active == active)); - } - - @JsonKey(ignore: true) - @override - int get hashCode => Object.hash(runtimeType, url, label, active); - - @JsonKey(ignore: true) - @override - @pragma('vm:prefer-inline') - _$$LinkImplCopyWith<_$LinkImpl> get copyWith => - __$$LinkImplCopyWithImpl<_$LinkImpl>(this, _$identity); - - @override - Map toJson() { - return _$$LinkImplToJson( - this, - ); - } -} - -abstract class _Link implements Link { - const factory _Link( - {@JsonKey(name: "url") required final String? url, - @JsonKey(name: "label") required final String label, - @JsonKey(name: "active") required final bool active}) = _$LinkImpl; - - factory _Link.fromJson(Map json) = _$LinkImpl.fromJson; - - @override - @JsonKey(name: "url") - String? get url; - @override - @JsonKey(name: "label") - String get label; - @override - @JsonKey(name: "active") - bool get active; - @override - @JsonKey(ignore: true) - _$$LinkImplCopyWith<_$LinkImpl> get copyWith => + @JsonKey(name: "created_at") + DateTime get createdAt; + + /// Create a copy of Comment + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + _$$CommentImplCopyWith<_$CommentImpl> get copyWith => throw _privateConstructorUsedError; } diff --git a/lib/features/feed/models/comment_model.g.dart b/lib/features/feed/models/comment_model.g.dart index ef471dc6..1410cfcc 100644 --- a/lib/features/feed/models/comment_model.g.dart +++ b/lib/features/feed/models/comment_model.g.dart @@ -6,90 +6,40 @@ part of 'comment_model.dart'; // JsonSerializableGenerator // ************************************************************************** -_$CommentImpl _$$CommentImplFromJson(Map json) => - _$CommentImpl( +_$CommentModelImpl _$$CommentModelImplFromJson(Map json) => + _$CommentModelImpl( data: (json['data'] as List) - .map((e) => Datum.fromJson(e as Map)) + .map((e) => Comment.fromJson(e as Map)) .toList(), links: Links.fromJson(json['links'] as Map), meta: Meta.fromJson(json['meta'] as Map), ); -Map _$$CommentImplToJson(_$CommentImpl instance) => +Map _$$CommentModelImplToJson(_$CommentModelImpl instance) => { 'data': instance.data, 'links': instance.links, 'meta': instance.meta, }; -_$DatumImpl _$$DatumImplFromJson(Map json) => _$DatumImpl( +_$CommentImpl _$$CommentImplFromJson(Map json) => + _$CommentImpl( id: (json['id'] as num).toInt(), authorName: json['author_name'] as String, authorProfileIcon: json['author_profile_icon'] as String, body: json['body'] as String, childrenComments: (json['children_comments'] as List) - .map((e) => Datum.fromJson(e as Map)) + .map((e) => Comment.fromJson(e as Map)) .toList(), + createdAt: DateTime.parse(json['created_at'] as String), ); -Map _$$DatumImplToJson(_$DatumImpl instance) => +Map _$$CommentImplToJson(_$CommentImpl instance) => { 'id': instance.id, 'author_name': instance.authorName, 'author_profile_icon': instance.authorProfileIcon, 'body': instance.body, 'children_comments': instance.childrenComments, - }; - -_$LinksImpl _$$LinksImplFromJson(Map json) => _$LinksImpl( - first: json['first'] as String, - last: json['last'] as String, - prev: json['prev'], - next: json['next'], - ); - -Map _$$LinksImplToJson(_$LinksImpl instance) => - { - 'first': instance.first, - 'last': instance.last, - 'prev': instance.prev, - 'next': instance.next, - }; - -_$MetaImpl _$$MetaImplFromJson(Map json) => _$MetaImpl( - currentPage: (json['current_page'] as num).toInt(), - from: (json['from'] as num).toInt(), - lastPage: (json['last_page'] as num).toInt(), - links: (json['links'] as List) - .map((e) => Link.fromJson(e as Map)) - .toList(), - path: json['path'] as String, - perPage: (json['per_page'] as num).toInt(), - to: (json['to'] as num).toInt(), - total: (json['total'] as num).toInt(), - ); - -Map _$$MetaImplToJson(_$MetaImpl instance) => - { - 'current_page': instance.currentPage, - 'from': instance.from, - 'last_page': instance.lastPage, - 'links': instance.links, - 'path': instance.path, - 'per_page': instance.perPage, - 'to': instance.to, - 'total': instance.total, - }; - -_$LinkImpl _$$LinkImplFromJson(Map json) => _$LinkImpl( - url: json['url'] as String?, - label: json['label'] as String, - active: json['active'] as bool, - ); - -Map _$$LinkImplToJson(_$LinkImpl instance) => - { - 'url': instance.url, - 'label': instance.label, - 'active': instance.active, + 'created_at': instance.createdAt.toIso8601String(), }; diff --git a/lib/features/feed/models/diets_pagination_model.dart b/lib/features/feed/models/diets_pagination_model.dart index 10fb6afb..dd7f4491 100644 --- a/lib/features/feed/models/diets_pagination_model.dart +++ b/lib/features/feed/models/diets_pagination_model.dart @@ -1,12 +1,14 @@ +import 'package:eatvio_app/core/models/pagination_model.dart'; import 'package:freezed_annotation/freezed_annotation.dart'; part 'diets_pagination_model.freezed.dart'; + part 'diets_pagination_model.g.dart'; @freezed class DietsPagination with _$DietsPagination { const factory DietsPagination({ - @JsonKey(name: "data") required List data, + @JsonKey(name: "data") required List data, @JsonKey(name: "links") required Links links, @JsonKey(name: "meta") required Meta meta, }) = _DietsPagination; @@ -15,23 +17,23 @@ class DietsPagination with _$DietsPagination { } @freezed -class Datum with _$Datum { - const factory Datum({ +class Diet with _$Diet { + const factory Diet({ @JsonKey(name: "id") required int id, @JsonKey(name: "name") required String name, @JsonKey(name: "image") required String image, @JsonKey(name: "duration") required int duration, @JsonKey(name: "state") required String state, - @JsonKey(name: "type") required Type type, + @JsonKey(name: "type") required DietType type, @JsonKey(name: "details") required String details, @JsonKey(name: "daily_schedule") required List>> dailySchedule, @JsonKey(name: "author") required Author author, @JsonKey(name: "total_likes") required int totalLikes, @JsonKey(name: "total_views") required int totalViews, @JsonKey(name: "total_comments") required int totalComments, - }) = _Datum; + }) = _Diet; - factory Datum.fromJson(Map json) => _$DatumFromJson(json); + factory Diet.fromJson(Map json) => _$DietFromJson(json); } @freezed @@ -70,54 +72,15 @@ enum Portion { final portionValues = EnumValues({"grams": Portion.GRAMS, "milliliters": Portion.MILLILITERS, "pcs": Portion.PCS}); @freezed -class Type with _$Type { - const factory Type({ +class DietType with _$DietType { + const factory DietType({ @JsonKey(name: "alko") bool? alko, @JsonKey(name: "veg") bool? veg, @JsonKey(name: "corb") bool? corb, @JsonKey(name: "meat") bool? meat, - }) = _Type; + }) = _DietType; - factory Type.fromJson(Map json) => _$TypeFromJson(json); -} - -@freezed -class Links with _$Links { - const factory Links({ - @JsonKey(name: "first") required String first, - @JsonKey(name: "last") required String last, - @JsonKey(name: "prev") required dynamic prev, - @JsonKey(name: "next") required dynamic next, - }) = _Links; - - factory Links.fromJson(Map json) => _$LinksFromJson(json); -} - -@freezed -class Meta with _$Meta { - const factory Meta({ - @JsonKey(name: "current_page") required int currentPage, - @JsonKey(name: "from") required int from, - @JsonKey(name: "last_page") required int lastPage, - @JsonKey(name: "links") required List links, - @JsonKey(name: "path") required String path, - @JsonKey(name: "per_page") required int perPage, - @JsonKey(name: "to") required int to, - @JsonKey(name: "total") required int total, - }) = _Meta; - - factory Meta.fromJson(Map json) => _$MetaFromJson(json); -} - -@freezed -class Link with _$Link { - const factory Link({ - @JsonKey(name: "url") required String? url, - @JsonKey(name: "label") required String label, - @JsonKey(name: "active") required bool active, - }) = _Link; - - factory Link.fromJson(Map json) => _$LinkFromJson(json); + factory DietType.fromJson(Map json) => _$DietTypeFromJson(json); } class EnumValues { diff --git a/lib/features/feed/models/diets_pagination_model.freezed.dart b/lib/features/feed/models/diets_pagination_model.freezed.dart index 2c402671..15b651f3 100644 --- a/lib/features/feed/models/diets_pagination_model.freezed.dart +++ b/lib/features/feed/models/diets_pagination_model.freezed.dart @@ -21,14 +21,18 @@ DietsPagination _$DietsPaginationFromJson(Map json) { /// @nodoc mixin _$DietsPagination { @JsonKey(name: "data") - List get data => throw _privateConstructorUsedError; + List get data => throw _privateConstructorUsedError; @JsonKey(name: "links") Links get links => throw _privateConstructorUsedError; @JsonKey(name: "meta") Meta get meta => throw _privateConstructorUsedError; + /// Serializes this DietsPagination to a JSON map. Map toJson() => throw _privateConstructorUsedError; - @JsonKey(ignore: true) + + /// Create a copy of DietsPagination + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) $DietsPaginationCopyWith get copyWith => throw _privateConstructorUsedError; } @@ -40,7 +44,7 @@ abstract class $DietsPaginationCopyWith<$Res> { _$DietsPaginationCopyWithImpl<$Res, DietsPagination>; @useResult $Res call( - {@JsonKey(name: "data") List data, + {@JsonKey(name: "data") List data, @JsonKey(name: "links") Links links, @JsonKey(name: "meta") Meta meta}); @@ -58,6 +62,8 @@ 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({ @@ -69,7 +75,7 @@ class _$DietsPaginationCopyWithImpl<$Res, $Val extends DietsPagination> data: null == data ? _value.data : data // ignore: cast_nullable_to_non_nullable - as List, + as List, links: null == links ? _value.links : links // ignore: cast_nullable_to_non_nullable @@ -81,6 +87,8 @@ 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 { @@ -89,6 +97,8 @@ 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 { @@ -107,7 +117,7 @@ abstract class _$$DietsPaginationImplCopyWith<$Res> @override @useResult $Res call( - {@JsonKey(name: "data") List data, + {@JsonKey(name: "data") List data, @JsonKey(name: "links") Links links, @JsonKey(name: "meta") Meta meta}); @@ -125,6 +135,8 @@ 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({ @@ -136,7 +148,7 @@ class __$$DietsPaginationImplCopyWithImpl<$Res> data: null == data ? _value._data : data // ignore: cast_nullable_to_non_nullable - as List, + as List, links: null == links ? _value.links : links // ignore: cast_nullable_to_non_nullable @@ -153,7 +165,7 @@ class __$$DietsPaginationImplCopyWithImpl<$Res> @JsonSerializable() class _$DietsPaginationImpl implements _DietsPagination { const _$DietsPaginationImpl( - {@JsonKey(name: "data") required final List data, + {@JsonKey(name: "data") required final List data, @JsonKey(name: "links") required this.links, @JsonKey(name: "meta") required this.meta}) : _data = data; @@ -161,10 +173,10 @@ class _$DietsPaginationImpl implements _DietsPagination { factory _$DietsPaginationImpl.fromJson(Map json) => _$$DietsPaginationImplFromJson(json); - final List _data; + final List _data; @override @JsonKey(name: "data") - List get data { + List get data { if (_data is EqualUnmodifiableListView) return _data; // ignore: implicit_dynamic_type return EqualUnmodifiableListView(_data); @@ -192,12 +204,14 @@ class _$DietsPaginationImpl implements _DietsPagination { (identical(other.meta, meta) || other.meta == meta)); } - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) @override int get hashCode => Object.hash( runtimeType, const DeepCollectionEquality().hash(_data), links, meta); - @JsonKey(ignore: true) + /// Create a copy of DietsPagination + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$DietsPaginationImplCopyWith<_$DietsPaginationImpl> get copyWith => @@ -214,7 +228,7 @@ class _$DietsPaginationImpl implements _DietsPagination { abstract class _DietsPagination implements DietsPagination { const factory _DietsPagination( - {@JsonKey(name: "data") required final List data, + {@JsonKey(name: "data") required final List data, @JsonKey(name: "links") required final Links links, @JsonKey(name: "meta") required final Meta meta}) = _$DietsPaginationImpl; @@ -223,25 +237,28 @@ abstract class _DietsPagination implements DietsPagination { @override @JsonKey(name: "data") - List get data; + List get data; @override @JsonKey(name: "links") Links get links; @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(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) _$$DietsPaginationImplCopyWith<_$DietsPaginationImpl> get copyWith => throw _privateConstructorUsedError; } -Datum _$DatumFromJson(Map json) { - return _Datum.fromJson(json); +Diet _$DietFromJson(Map json) { + return _Diet.fromJson(json); } /// @nodoc -mixin _$Datum { +mixin _$Diet { @JsonKey(name: "id") int get id => throw _privateConstructorUsedError; @JsonKey(name: "name") @@ -253,7 +270,7 @@ mixin _$Datum { @JsonKey(name: "state") String get state => throw _privateConstructorUsedError; @JsonKey(name: "type") - Type get type => throw _privateConstructorUsedError; + DietType get type => throw _privateConstructorUsedError; @JsonKey(name: "details") String get details => throw _privateConstructorUsedError; @JsonKey(name: "daily_schedule") @@ -268,15 +285,19 @@ mixin _$Datum { @JsonKey(name: "total_comments") int get totalComments => throw _privateConstructorUsedError; + /// Serializes this Diet to a JSON map. Map toJson() => throw _privateConstructorUsedError; - @JsonKey(ignore: true) - $DatumCopyWith get copyWith => throw _privateConstructorUsedError; + + /// Create a copy of Diet + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $DietCopyWith get copyWith => throw _privateConstructorUsedError; } /// @nodoc -abstract class $DatumCopyWith<$Res> { - factory $DatumCopyWith(Datum value, $Res Function(Datum) then) = - _$DatumCopyWithImpl<$Res, Datum>; +abstract class $DietCopyWith<$Res> { + factory $DietCopyWith(Diet value, $Res Function(Diet) then) = + _$DietCopyWithImpl<$Res, Diet>; @useResult $Res call( {@JsonKey(name: "id") int id, @@ -284,7 +305,7 @@ abstract class $DatumCopyWith<$Res> { @JsonKey(name: "image") String image, @JsonKey(name: "duration") int duration, @JsonKey(name: "state") String state, - @JsonKey(name: "type") Type type, + @JsonKey(name: "type") DietType type, @JsonKey(name: "details") String details, @JsonKey(name: "daily_schedule") List>> dailySchedule, @@ -293,20 +314,22 @@ abstract class $DatumCopyWith<$Res> { @JsonKey(name: "total_views") int totalViews, @JsonKey(name: "total_comments") int totalComments}); - $TypeCopyWith<$Res> get type; + $DietTypeCopyWith<$Res> get type; $AuthorCopyWith<$Res> get author; } /// @nodoc -class _$DatumCopyWithImpl<$Res, $Val extends Datum> - implements $DatumCopyWith<$Res> { - _$DatumCopyWithImpl(this._value, this._then); +class _$DietCopyWithImpl<$Res, $Val extends Diet> + implements $DietCopyWith<$Res> { + _$DietCopyWithImpl(this._value, this._then); // ignore: unused_field final $Val _value; // ignore: unused_field final $Res Function($Val) _then; + /// Create a copy of Diet + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -347,7 +370,7 @@ class _$DatumCopyWithImpl<$Res, $Val extends Datum> type: null == type ? _value.type : type // ignore: cast_nullable_to_non_nullable - as Type, + as DietType, details: null == details ? _value.details : details // ignore: cast_nullable_to_non_nullable @@ -375,14 +398,18 @@ class _$DatumCopyWithImpl<$Res, $Val extends Datum> ) as $Val); } + /// Create a copy of Diet + /// with the given fields replaced by the non-null parameter values. @override @pragma('vm:prefer-inline') - $TypeCopyWith<$Res> get type { - return $TypeCopyWith<$Res>(_value.type, (value) { + $DietTypeCopyWith<$Res> get type { + return $DietTypeCopyWith<$Res>(_value.type, (value) { return _then(_value.copyWith(type: value) as $Val); }); } + /// Create a copy of Diet + /// with the given fields replaced by the non-null parameter values. @override @pragma('vm:prefer-inline') $AuthorCopyWith<$Res> get author { @@ -393,10 +420,10 @@ class _$DatumCopyWithImpl<$Res, $Val extends Datum> } /// @nodoc -abstract class _$$DatumImplCopyWith<$Res> implements $DatumCopyWith<$Res> { - factory _$$DatumImplCopyWith( - _$DatumImpl value, $Res Function(_$DatumImpl) then) = - __$$DatumImplCopyWithImpl<$Res>; +abstract class _$$DietImplCopyWith<$Res> implements $DietCopyWith<$Res> { + factory _$$DietImplCopyWith( + _$DietImpl value, $Res Function(_$DietImpl) then) = + __$$DietImplCopyWithImpl<$Res>; @override @useResult $Res call( @@ -405,7 +432,7 @@ abstract class _$$DatumImplCopyWith<$Res> implements $DatumCopyWith<$Res> { @JsonKey(name: "image") String image, @JsonKey(name: "duration") int duration, @JsonKey(name: "state") String state, - @JsonKey(name: "type") Type type, + @JsonKey(name: "type") DietType type, @JsonKey(name: "details") String details, @JsonKey(name: "daily_schedule") List>> dailySchedule, @@ -415,19 +442,20 @@ abstract class _$$DatumImplCopyWith<$Res> implements $DatumCopyWith<$Res> { @JsonKey(name: "total_comments") int totalComments}); @override - $TypeCopyWith<$Res> get type; + $DietTypeCopyWith<$Res> get type; @override $AuthorCopyWith<$Res> get author; } /// @nodoc -class __$$DatumImplCopyWithImpl<$Res> - extends _$DatumCopyWithImpl<$Res, _$DatumImpl> - implements _$$DatumImplCopyWith<$Res> { - __$$DatumImplCopyWithImpl( - _$DatumImpl _value, $Res Function(_$DatumImpl) _then) +class __$$DietImplCopyWithImpl<$Res> + extends _$DietCopyWithImpl<$Res, _$DietImpl> + implements _$$DietImplCopyWith<$Res> { + __$$DietImplCopyWithImpl(_$DietImpl _value, $Res Function(_$DietImpl) _then) : super(_value, _then); + /// Create a copy of Diet + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -444,7 +472,7 @@ class __$$DatumImplCopyWithImpl<$Res> Object? totalViews = null, Object? totalComments = null, }) { - return _then(_$DatumImpl( + return _then(_$DietImpl( id: null == id ? _value.id : id // ignore: cast_nullable_to_non_nullable @@ -468,7 +496,7 @@ class __$$DatumImplCopyWithImpl<$Res> type: null == type ? _value.type : type // ignore: cast_nullable_to_non_nullable - as Type, + as DietType, details: null == details ? _value.details : details // ignore: cast_nullable_to_non_nullable @@ -499,8 +527,8 @@ class __$$DatumImplCopyWithImpl<$Res> /// @nodoc @JsonSerializable() -class _$DatumImpl implements _Datum { - const _$DatumImpl( +class _$DietImpl implements _Diet { + const _$DietImpl( {@JsonKey(name: "id") required this.id, @JsonKey(name: "name") required this.name, @JsonKey(name: "image") required this.image, @@ -516,8 +544,8 @@ class _$DatumImpl implements _Datum { @JsonKey(name: "total_comments") required this.totalComments}) : _dailySchedule = dailySchedule; - factory _$DatumImpl.fromJson(Map json) => - _$$DatumImplFromJson(json); + factory _$DietImpl.fromJson(Map json) => + _$$DietImplFromJson(json); @override @JsonKey(name: "id") @@ -536,7 +564,7 @@ class _$DatumImpl implements _Datum { final String state; @override @JsonKey(name: "type") - final Type type; + final DietType type; @override @JsonKey(name: "details") final String details; @@ -564,14 +592,14 @@ class _$DatumImpl implements _Datum { @override String toString() { - return 'Datum(id: $id, name: $name, image: $image, duration: $duration, state: $state, type: $type, details: $details, dailySchedule: $dailySchedule, author: $author, totalLikes: $totalLikes, totalViews: $totalViews, totalComments: $totalComments)'; + return 'Diet(id: $id, name: $name, image: $image, duration: $duration, state: $state, type: $type, details: $details, dailySchedule: $dailySchedule, author: $author, totalLikes: $totalLikes, totalViews: $totalViews, totalComments: $totalComments)'; } @override bool operator ==(Object other) { return identical(this, other) || (other.runtimeType == runtimeType && - other is _$DatumImpl && + other is _$DietImpl && (identical(other.id, id) || other.id == id) && (identical(other.name, name) || other.name == name) && (identical(other.image, image) || other.image == image) && @@ -591,7 +619,7 @@ class _$DatumImpl implements _Datum { other.totalComments == totalComments)); } - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) @override int get hashCode => Object.hash( runtimeType, @@ -608,28 +636,30 @@ class _$DatumImpl implements _Datum { totalViews, totalComments); - @JsonKey(ignore: true) + /// Create a copy of Diet + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') - _$$DatumImplCopyWith<_$DatumImpl> get copyWith => - __$$DatumImplCopyWithImpl<_$DatumImpl>(this, _$identity); + _$$DietImplCopyWith<_$DietImpl> get copyWith => + __$$DietImplCopyWithImpl<_$DietImpl>(this, _$identity); @override Map toJson() { - return _$$DatumImplToJson( + return _$$DietImplToJson( this, ); } } -abstract class _Datum implements Datum { - const factory _Datum( +abstract class _Diet implements Diet { + const factory _Diet( {@JsonKey(name: "id") required final int id, @JsonKey(name: "name") required final String name, @JsonKey(name: "image") required final String image, @JsonKey(name: "duration") required final int duration, @JsonKey(name: "state") required final String state, - @JsonKey(name: "type") required final Type type, + @JsonKey(name: "type") required final DietType type, @JsonKey(name: "details") required final String details, @JsonKey(name: "daily_schedule") required final List>> dailySchedule, @@ -637,9 +667,9 @@ abstract class _Datum implements Datum { @JsonKey(name: "total_likes") required final int totalLikes, @JsonKey(name: "total_views") required final int totalViews, @JsonKey(name: "total_comments") required final int totalComments}) = - _$DatumImpl; + _$DietImpl; - factory _Datum.fromJson(Map json) = _$DatumImpl.fromJson; + factory _Diet.fromJson(Map json) = _$DietImpl.fromJson; @override @JsonKey(name: "id") @@ -658,7 +688,7 @@ abstract class _Datum implements Datum { String get state; @override @JsonKey(name: "type") - Type get type; + DietType get type; @override @JsonKey(name: "details") String get details; @@ -677,9 +707,12 @@ abstract class _Datum implements Datum { @override @JsonKey(name: "total_comments") int get totalComments; + + /// Create a copy of Diet + /// with the given fields replaced by the non-null parameter values. @override - @JsonKey(ignore: true) - _$$DatumImplCopyWith<_$DatumImpl> get copyWith => + @JsonKey(includeFromJson: false, includeToJson: false) + _$$DietImplCopyWith<_$DietImpl> get copyWith => throw _privateConstructorUsedError; } @@ -698,8 +731,12 @@ mixin _$Author { @JsonKey(name: "author_is_me") bool get authorIsMe => throw _privateConstructorUsedError; + /// Serializes this Author to a JSON map. Map toJson() => throw _privateConstructorUsedError; - @JsonKey(ignore: true) + + /// Create a copy of Author + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) $AuthorCopyWith get copyWith => throw _privateConstructorUsedError; } @@ -725,6 +762,8 @@ 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({ @@ -776,6 +815,8 @@ 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({ @@ -850,12 +891,14 @@ class _$AuthorImpl implements _Author { other.authorIsMe == authorIsMe)); } - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) @override int get hashCode => Object.hash( runtimeType, authorSlug, authorName, authorProfileIcon, authorIsMe); - @JsonKey(ignore: true) + /// Create a copy of Author + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$AuthorImplCopyWith<_$AuthorImpl> get copyWith => @@ -892,8 +935,11 @@ 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(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) _$$AuthorImplCopyWith<_$AuthorImpl> get copyWith => throw _privateConstructorUsedError; } @@ -913,8 +959,12 @@ mixin _$DailySchedule { @JsonKey(name: "quantity") int get quantity => throw _privateConstructorUsedError; + /// Serializes this DailySchedule to a JSON map. Map toJson() => throw _privateConstructorUsedError; - @JsonKey(ignore: true) + + /// Create a copy of DailySchedule + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) $DailyScheduleCopyWith get copyWith => throw _privateConstructorUsedError; } @@ -942,6 +992,8 @@ 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({ @@ -994,6 +1046,8 @@ 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({ @@ -1065,11 +1119,13 @@ class _$DailyScheduleImpl implements _DailySchedule { other.quantity == quantity)); } - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) @override int get hashCode => Object.hash(runtimeType, name, uniq, portion, quantity); - @JsonKey(ignore: true) + /// Create a copy of DailySchedule + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$DailyScheduleImplCopyWith<_$DailyScheduleImpl> get copyWith => @@ -1106,18 +1162,21 @@ 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(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) _$$DailyScheduleImplCopyWith<_$DailyScheduleImpl> get copyWith => throw _privateConstructorUsedError; } -Type _$TypeFromJson(Map json) { - return _Type.fromJson(json); +DietType _$DietTypeFromJson(Map json) { + return _DietType.fromJson(json); } /// @nodoc -mixin _$Type { +mixin _$DietType { @JsonKey(name: "alko") bool? get alko => throw _privateConstructorUsedError; @JsonKey(name: "veg") @@ -1127,15 +1186,20 @@ mixin _$Type { @JsonKey(name: "meat") bool? get meat => throw _privateConstructorUsedError; + /// Serializes this DietType to a JSON map. Map toJson() => throw _privateConstructorUsedError; - @JsonKey(ignore: true) - $TypeCopyWith get copyWith => throw _privateConstructorUsedError; + + /// Create a copy of DietType + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $DietTypeCopyWith get copyWith => + throw _privateConstructorUsedError; } /// @nodoc -abstract class $TypeCopyWith<$Res> { - factory $TypeCopyWith(Type value, $Res Function(Type) then) = - _$TypeCopyWithImpl<$Res, Type>; +abstract class $DietTypeCopyWith<$Res> { + factory $DietTypeCopyWith(DietType value, $Res Function(DietType) then) = + _$DietTypeCopyWithImpl<$Res, DietType>; @useResult $Res call( {@JsonKey(name: "alko") bool? alko, @@ -1145,15 +1209,17 @@ abstract class $TypeCopyWith<$Res> { } /// @nodoc -class _$TypeCopyWithImpl<$Res, $Val extends Type> - implements $TypeCopyWith<$Res> { - _$TypeCopyWithImpl(this._value, this._then); +class _$DietTypeCopyWithImpl<$Res, $Val extends DietType> + implements $DietTypeCopyWith<$Res> { + _$DietTypeCopyWithImpl(this._value, this._then); // ignore: unused_field final $Val _value; // ignore: unused_field final $Res Function($Val) _then; + /// Create a copy of DietType + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -1184,10 +1250,11 @@ class _$TypeCopyWithImpl<$Res, $Val extends Type> } /// @nodoc -abstract class _$$TypeImplCopyWith<$Res> implements $TypeCopyWith<$Res> { - factory _$$TypeImplCopyWith( - _$TypeImpl value, $Res Function(_$TypeImpl) then) = - __$$TypeImplCopyWithImpl<$Res>; +abstract class _$$DietTypeImplCopyWith<$Res> + implements $DietTypeCopyWith<$Res> { + factory _$$DietTypeImplCopyWith( + _$DietTypeImpl value, $Res Function(_$DietTypeImpl) then) = + __$$DietTypeImplCopyWithImpl<$Res>; @override @useResult $Res call( @@ -1198,12 +1265,15 @@ abstract class _$$TypeImplCopyWith<$Res> implements $TypeCopyWith<$Res> { } /// @nodoc -class __$$TypeImplCopyWithImpl<$Res> - extends _$TypeCopyWithImpl<$Res, _$TypeImpl> - implements _$$TypeImplCopyWith<$Res> { - __$$TypeImplCopyWithImpl(_$TypeImpl _value, $Res Function(_$TypeImpl) _then) +class __$$DietTypeImplCopyWithImpl<$Res> + extends _$DietTypeCopyWithImpl<$Res, _$DietTypeImpl> + implements _$$DietTypeImplCopyWith<$Res> { + __$$DietTypeImplCopyWithImpl( + _$DietTypeImpl _value, $Res Function(_$DietTypeImpl) _then) : super(_value, _then); + /// Create a copy of DietType + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -1212,7 +1282,7 @@ class __$$TypeImplCopyWithImpl<$Res> Object? corb = freezed, Object? meat = freezed, }) { - return _then(_$TypeImpl( + return _then(_$DietTypeImpl( alko: freezed == alko ? _value.alko : alko // ignore: cast_nullable_to_non_nullable @@ -1235,15 +1305,15 @@ class __$$TypeImplCopyWithImpl<$Res> /// @nodoc @JsonSerializable() -class _$TypeImpl implements _Type { - const _$TypeImpl( +class _$DietTypeImpl implements _DietType { + const _$DietTypeImpl( {@JsonKey(name: "alko") this.alko, @JsonKey(name: "veg") this.veg, @JsonKey(name: "corb") this.corb, @JsonKey(name: "meat") this.meat}); - factory _$TypeImpl.fromJson(Map json) => - _$$TypeImplFromJson(json); + factory _$DietTypeImpl.fromJson(Map json) => + _$$DietTypeImplFromJson(json); @override @JsonKey(name: "alko") @@ -1260,46 +1330,49 @@ class _$TypeImpl implements _Type { @override String toString() { - return 'Type(alko: $alko, veg: $veg, corb: $corb, meat: $meat)'; + return 'DietType(alko: $alko, veg: $veg, corb: $corb, meat: $meat)'; } @override bool operator ==(Object other) { return identical(this, other) || (other.runtimeType == runtimeType && - other is _$TypeImpl && + other is _$DietTypeImpl && (identical(other.alko, alko) || other.alko == alko) && (identical(other.veg, veg) || other.veg == veg) && (identical(other.corb, corb) || other.corb == corb) && (identical(other.meat, meat) || other.meat == meat)); } - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) @override int get hashCode => Object.hash(runtimeType, alko, veg, corb, meat); - @JsonKey(ignore: true) + /// Create a copy of DietType + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') - _$$TypeImplCopyWith<_$TypeImpl> get copyWith => - __$$TypeImplCopyWithImpl<_$TypeImpl>(this, _$identity); + _$$DietTypeImplCopyWith<_$DietTypeImpl> get copyWith => + __$$DietTypeImplCopyWithImpl<_$DietTypeImpl>(this, _$identity); @override Map toJson() { - return _$$TypeImplToJson( + return _$$DietTypeImplToJson( this, ); } } -abstract class _Type implements Type { - const factory _Type( +abstract class _DietType implements DietType { + const factory _DietType( {@JsonKey(name: "alko") final bool? alko, @JsonKey(name: "veg") final bool? veg, @JsonKey(name: "corb") final bool? corb, - @JsonKey(name: "meat") final bool? meat}) = _$TypeImpl; + @JsonKey(name: "meat") final bool? meat}) = _$DietTypeImpl; - factory _Type.fromJson(Map json) = _$TypeImpl.fromJson; + factory _DietType.fromJson(Map json) = + _$DietTypeImpl.fromJson; @override @JsonKey(name: "alko") @@ -1313,714 +1386,11 @@ abstract class _Type implements Type { @override @JsonKey(name: "meat") bool? get meat; + + /// Create a copy of DietType + /// with the given fields replaced by the non-null parameter values. @override - @JsonKey(ignore: true) - _$$TypeImplCopyWith<_$TypeImpl> get copyWith => - throw _privateConstructorUsedError; -} - -Links _$LinksFromJson(Map json) { - return _Links.fromJson(json); -} - -/// @nodoc -mixin _$Links { - @JsonKey(name: "first") - String get first => throw _privateConstructorUsedError; - @JsonKey(name: "last") - String get last => throw _privateConstructorUsedError; - @JsonKey(name: "prev") - dynamic get prev => throw _privateConstructorUsedError; - @JsonKey(name: "next") - dynamic get next => throw _privateConstructorUsedError; - - Map toJson() => throw _privateConstructorUsedError; - @JsonKey(ignore: true) - $LinksCopyWith get copyWith => throw _privateConstructorUsedError; -} - -/// @nodoc -abstract class $LinksCopyWith<$Res> { - factory $LinksCopyWith(Links value, $Res Function(Links) then) = - _$LinksCopyWithImpl<$Res, Links>; - @useResult - $Res call( - {@JsonKey(name: "first") String first, - @JsonKey(name: "last") String last, - @JsonKey(name: "prev") dynamic prev, - @JsonKey(name: "next") dynamic next}); -} - -/// @nodoc -class _$LinksCopyWithImpl<$Res, $Val extends Links> - implements $LinksCopyWith<$Res> { - _$LinksCopyWithImpl(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? first = null, - Object? last = null, - Object? prev = freezed, - Object? next = freezed, - }) { - return _then(_value.copyWith( - first: null == first - ? _value.first - : first // ignore: cast_nullable_to_non_nullable - as String, - last: null == last - ? _value.last - : last // ignore: cast_nullable_to_non_nullable - as String, - prev: freezed == prev - ? _value.prev - : prev // ignore: cast_nullable_to_non_nullable - as dynamic, - next: freezed == next - ? _value.next - : next // ignore: cast_nullable_to_non_nullable - as dynamic, - ) as $Val); - } -} - -/// @nodoc -abstract class _$$LinksImplCopyWith<$Res> implements $LinksCopyWith<$Res> { - factory _$$LinksImplCopyWith( - _$LinksImpl value, $Res Function(_$LinksImpl) then) = - __$$LinksImplCopyWithImpl<$Res>; - @override - @useResult - $Res call( - {@JsonKey(name: "first") String first, - @JsonKey(name: "last") String last, - @JsonKey(name: "prev") dynamic prev, - @JsonKey(name: "next") dynamic next}); -} - -/// @nodoc -class __$$LinksImplCopyWithImpl<$Res> - extends _$LinksCopyWithImpl<$Res, _$LinksImpl> - implements _$$LinksImplCopyWith<$Res> { - __$$LinksImplCopyWithImpl( - _$LinksImpl _value, $Res Function(_$LinksImpl) _then) - : super(_value, _then); - - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? first = null, - Object? last = null, - Object? prev = freezed, - Object? next = freezed, - }) { - return _then(_$LinksImpl( - first: null == first - ? _value.first - : first // ignore: cast_nullable_to_non_nullable - as String, - last: null == last - ? _value.last - : last // ignore: cast_nullable_to_non_nullable - as String, - prev: freezed == prev - ? _value.prev - : prev // ignore: cast_nullable_to_non_nullable - as dynamic, - next: freezed == next - ? _value.next - : next // ignore: cast_nullable_to_non_nullable - as dynamic, - )); - } -} - -/// @nodoc -@JsonSerializable() -class _$LinksImpl implements _Links { - const _$LinksImpl( - {@JsonKey(name: "first") required this.first, - @JsonKey(name: "last") required this.last, - @JsonKey(name: "prev") required this.prev, - @JsonKey(name: "next") required this.next}); - - factory _$LinksImpl.fromJson(Map json) => - _$$LinksImplFromJson(json); - - @override - @JsonKey(name: "first") - final String first; - @override - @JsonKey(name: "last") - final String last; - @override - @JsonKey(name: "prev") - final dynamic prev; - @override - @JsonKey(name: "next") - final dynamic next; - - @override - String toString() { - return 'Links(first: $first, last: $last, prev: $prev, next: $next)'; - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _$LinksImpl && - (identical(other.first, first) || other.first == first) && - (identical(other.last, last) || other.last == last) && - const DeepCollectionEquality().equals(other.prev, prev) && - const DeepCollectionEquality().equals(other.next, next)); - } - - @JsonKey(ignore: true) - @override - int get hashCode => Object.hash( - runtimeType, - first, - last, - const DeepCollectionEquality().hash(prev), - const DeepCollectionEquality().hash(next)); - - @JsonKey(ignore: true) - @override - @pragma('vm:prefer-inline') - _$$LinksImplCopyWith<_$LinksImpl> get copyWith => - __$$LinksImplCopyWithImpl<_$LinksImpl>(this, _$identity); - - @override - Map toJson() { - return _$$LinksImplToJson( - this, - ); - } -} - -abstract class _Links implements Links { - const factory _Links( - {@JsonKey(name: "first") required final String first, - @JsonKey(name: "last") required final String last, - @JsonKey(name: "prev") required final dynamic prev, - @JsonKey(name: "next") required final dynamic next}) = _$LinksImpl; - - factory _Links.fromJson(Map json) = _$LinksImpl.fromJson; - - @override - @JsonKey(name: "first") - String get first; - @override - @JsonKey(name: "last") - String get last; - @override - @JsonKey(name: "prev") - dynamic get prev; - @override - @JsonKey(name: "next") - dynamic get next; - @override - @JsonKey(ignore: true) - _$$LinksImplCopyWith<_$LinksImpl> get copyWith => - throw _privateConstructorUsedError; -} - -Meta _$MetaFromJson(Map json) { - return _Meta.fromJson(json); -} - -/// @nodoc -mixin _$Meta { - @JsonKey(name: "current_page") - int get currentPage => throw _privateConstructorUsedError; - @JsonKey(name: "from") - int get from => throw _privateConstructorUsedError; - @JsonKey(name: "last_page") - int get lastPage => throw _privateConstructorUsedError; - @JsonKey(name: "links") - List get links => throw _privateConstructorUsedError; - @JsonKey(name: "path") - String get path => throw _privateConstructorUsedError; - @JsonKey(name: "per_page") - int get perPage => throw _privateConstructorUsedError; - @JsonKey(name: "to") - int get to => throw _privateConstructorUsedError; - @JsonKey(name: "total") - int get total => throw _privateConstructorUsedError; - - Map toJson() => throw _privateConstructorUsedError; - @JsonKey(ignore: true) - $MetaCopyWith get copyWith => throw _privateConstructorUsedError; -} - -/// @nodoc -abstract class $MetaCopyWith<$Res> { - factory $MetaCopyWith(Meta value, $Res Function(Meta) then) = - _$MetaCopyWithImpl<$Res, Meta>; - @useResult - $Res call( - {@JsonKey(name: "current_page") int currentPage, - @JsonKey(name: "from") int from, - @JsonKey(name: "last_page") int lastPage, - @JsonKey(name: "links") List links, - @JsonKey(name: "path") String path, - @JsonKey(name: "per_page") int perPage, - @JsonKey(name: "to") int to, - @JsonKey(name: "total") int total}); -} - -/// @nodoc -class _$MetaCopyWithImpl<$Res, $Val extends Meta> - implements $MetaCopyWith<$Res> { - _$MetaCopyWithImpl(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? currentPage = null, - Object? from = null, - Object? lastPage = null, - Object? links = null, - Object? path = null, - Object? perPage = null, - Object? to = null, - Object? total = null, - }) { - return _then(_value.copyWith( - currentPage: null == currentPage - ? _value.currentPage - : currentPage // ignore: cast_nullable_to_non_nullable - as int, - from: null == from - ? _value.from - : from // ignore: cast_nullable_to_non_nullable - as int, - lastPage: null == lastPage - ? _value.lastPage - : lastPage // ignore: cast_nullable_to_non_nullable - as int, - links: null == links - ? _value.links - : links // ignore: cast_nullable_to_non_nullable - as List, - path: null == path - ? _value.path - : path // ignore: cast_nullable_to_non_nullable - as String, - perPage: null == perPage - ? _value.perPage - : perPage // ignore: cast_nullable_to_non_nullable - as int, - to: null == to - ? _value.to - : to // ignore: cast_nullable_to_non_nullable - as int, - total: null == total - ? _value.total - : total // ignore: cast_nullable_to_non_nullable - as int, - ) as $Val); - } -} - -/// @nodoc -abstract class _$$MetaImplCopyWith<$Res> implements $MetaCopyWith<$Res> { - factory _$$MetaImplCopyWith( - _$MetaImpl value, $Res Function(_$MetaImpl) then) = - __$$MetaImplCopyWithImpl<$Res>; - @override - @useResult - $Res call( - {@JsonKey(name: "current_page") int currentPage, - @JsonKey(name: "from") int from, - @JsonKey(name: "last_page") int lastPage, - @JsonKey(name: "links") List links, - @JsonKey(name: "path") String path, - @JsonKey(name: "per_page") int perPage, - @JsonKey(name: "to") int to, - @JsonKey(name: "total") int total}); -} - -/// @nodoc -class __$$MetaImplCopyWithImpl<$Res> - extends _$MetaCopyWithImpl<$Res, _$MetaImpl> - implements _$$MetaImplCopyWith<$Res> { - __$$MetaImplCopyWithImpl(_$MetaImpl _value, $Res Function(_$MetaImpl) _then) - : super(_value, _then); - - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? currentPage = null, - Object? from = null, - Object? lastPage = null, - Object? links = null, - Object? path = null, - Object? perPage = null, - Object? to = null, - Object? total = null, - }) { - return _then(_$MetaImpl( - currentPage: null == currentPage - ? _value.currentPage - : currentPage // ignore: cast_nullable_to_non_nullable - as int, - from: null == from - ? _value.from - : from // ignore: cast_nullable_to_non_nullable - as int, - lastPage: null == lastPage - ? _value.lastPage - : lastPage // ignore: cast_nullable_to_non_nullable - as int, - links: null == links - ? _value._links - : links // ignore: cast_nullable_to_non_nullable - as List, - path: null == path - ? _value.path - : path // ignore: cast_nullable_to_non_nullable - as String, - perPage: null == perPage - ? _value.perPage - : perPage // ignore: cast_nullable_to_non_nullable - as int, - to: null == to - ? _value.to - : to // ignore: cast_nullable_to_non_nullable - as int, - total: null == total - ? _value.total - : total // ignore: cast_nullable_to_non_nullable - as int, - )); - } -} - -/// @nodoc -@JsonSerializable() -class _$MetaImpl implements _Meta { - const _$MetaImpl( - {@JsonKey(name: "current_page") required this.currentPage, - @JsonKey(name: "from") required this.from, - @JsonKey(name: "last_page") required this.lastPage, - @JsonKey(name: "links") required final List links, - @JsonKey(name: "path") required this.path, - @JsonKey(name: "per_page") required this.perPage, - @JsonKey(name: "to") required this.to, - @JsonKey(name: "total") required this.total}) - : _links = links; - - factory _$MetaImpl.fromJson(Map json) => - _$$MetaImplFromJson(json); - - @override - @JsonKey(name: "current_page") - final int currentPage; - @override - @JsonKey(name: "from") - final int from; - @override - @JsonKey(name: "last_page") - final int lastPage; - final List _links; - @override - @JsonKey(name: "links") - List get links { - if (_links is EqualUnmodifiableListView) return _links; - // ignore: implicit_dynamic_type - return EqualUnmodifiableListView(_links); - } - - @override - @JsonKey(name: "path") - final String path; - @override - @JsonKey(name: "per_page") - final int perPage; - @override - @JsonKey(name: "to") - final int to; - @override - @JsonKey(name: "total") - final int total; - - @override - String toString() { - return 'Meta(currentPage: $currentPage, from: $from, lastPage: $lastPage, links: $links, path: $path, perPage: $perPage, to: $to, total: $total)'; - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _$MetaImpl && - (identical(other.currentPage, currentPage) || - other.currentPage == currentPage) && - (identical(other.from, from) || other.from == from) && - (identical(other.lastPage, lastPage) || - other.lastPage == lastPage) && - const DeepCollectionEquality().equals(other._links, _links) && - (identical(other.path, path) || other.path == path) && - (identical(other.perPage, perPage) || other.perPage == perPage) && - (identical(other.to, to) || other.to == to) && - (identical(other.total, total) || other.total == total)); - } - - @JsonKey(ignore: true) - @override - int get hashCode => Object.hash(runtimeType, currentPage, from, lastPage, - const DeepCollectionEquality().hash(_links), path, perPage, to, total); - - @JsonKey(ignore: true) - @override - @pragma('vm:prefer-inline') - _$$MetaImplCopyWith<_$MetaImpl> get copyWith => - __$$MetaImplCopyWithImpl<_$MetaImpl>(this, _$identity); - - @override - Map toJson() { - return _$$MetaImplToJson( - this, - ); - } -} - -abstract class _Meta implements Meta { - const factory _Meta( - {@JsonKey(name: "current_page") required final int currentPage, - @JsonKey(name: "from") required final int from, - @JsonKey(name: "last_page") required final int lastPage, - @JsonKey(name: "links") required final List links, - @JsonKey(name: "path") required final String path, - @JsonKey(name: "per_page") required final int perPage, - @JsonKey(name: "to") required final int to, - @JsonKey(name: "total") required final int total}) = _$MetaImpl; - - factory _Meta.fromJson(Map json) = _$MetaImpl.fromJson; - - @override - @JsonKey(name: "current_page") - int get currentPage; - @override - @JsonKey(name: "from") - int get from; - @override - @JsonKey(name: "last_page") - int get lastPage; - @override - @JsonKey(name: "links") - List get links; - @override - @JsonKey(name: "path") - String get path; - @override - @JsonKey(name: "per_page") - int get perPage; - @override - @JsonKey(name: "to") - int get to; - @override - @JsonKey(name: "total") - int get total; - @override - @JsonKey(ignore: true) - _$$MetaImplCopyWith<_$MetaImpl> get copyWith => - throw _privateConstructorUsedError; -} - -Link _$LinkFromJson(Map json) { - return _Link.fromJson(json); -} - -/// @nodoc -mixin _$Link { - @JsonKey(name: "url") - String? get url => throw _privateConstructorUsedError; - @JsonKey(name: "label") - String get label => throw _privateConstructorUsedError; - @JsonKey(name: "active") - bool get active => throw _privateConstructorUsedError; - - Map toJson() => throw _privateConstructorUsedError; - @JsonKey(ignore: true) - $LinkCopyWith get copyWith => throw _privateConstructorUsedError; -} - -/// @nodoc -abstract class $LinkCopyWith<$Res> { - factory $LinkCopyWith(Link value, $Res Function(Link) then) = - _$LinkCopyWithImpl<$Res, Link>; - @useResult - $Res call( - {@JsonKey(name: "url") String? url, - @JsonKey(name: "label") String label, - @JsonKey(name: "active") bool active}); -} - -/// @nodoc -class _$LinkCopyWithImpl<$Res, $Val extends Link> - implements $LinkCopyWith<$Res> { - _$LinkCopyWithImpl(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? url = freezed, - Object? label = null, - Object? active = null, - }) { - return _then(_value.copyWith( - url: freezed == url - ? _value.url - : url // ignore: cast_nullable_to_non_nullable - as String?, - label: null == label - ? _value.label - : label // ignore: cast_nullable_to_non_nullable - as String, - active: null == active - ? _value.active - : active // ignore: cast_nullable_to_non_nullable - as bool, - ) as $Val); - } -} - -/// @nodoc -abstract class _$$LinkImplCopyWith<$Res> implements $LinkCopyWith<$Res> { - factory _$$LinkImplCopyWith( - _$LinkImpl value, $Res Function(_$LinkImpl) then) = - __$$LinkImplCopyWithImpl<$Res>; - @override - @useResult - $Res call( - {@JsonKey(name: "url") String? url, - @JsonKey(name: "label") String label, - @JsonKey(name: "active") bool active}); -} - -/// @nodoc -class __$$LinkImplCopyWithImpl<$Res> - extends _$LinkCopyWithImpl<$Res, _$LinkImpl> - implements _$$LinkImplCopyWith<$Res> { - __$$LinkImplCopyWithImpl(_$LinkImpl _value, $Res Function(_$LinkImpl) _then) - : super(_value, _then); - - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? url = freezed, - Object? label = null, - Object? active = null, - }) { - return _then(_$LinkImpl( - url: freezed == url - ? _value.url - : url // ignore: cast_nullable_to_non_nullable - as String?, - label: null == label - ? _value.label - : label // ignore: cast_nullable_to_non_nullable - as String, - active: null == active - ? _value.active - : active // ignore: cast_nullable_to_non_nullable - as bool, - )); - } -} - -/// @nodoc -@JsonSerializable() -class _$LinkImpl implements _Link { - const _$LinkImpl( - {@JsonKey(name: "url") required this.url, - @JsonKey(name: "label") required this.label, - @JsonKey(name: "active") required this.active}); - - factory _$LinkImpl.fromJson(Map json) => - _$$LinkImplFromJson(json); - - @override - @JsonKey(name: "url") - final String? url; - @override - @JsonKey(name: "label") - final String label; - @override - @JsonKey(name: "active") - final bool active; - - @override - String toString() { - return 'Link(url: $url, label: $label, active: $active)'; - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _$LinkImpl && - (identical(other.url, url) || other.url == url) && - (identical(other.label, label) || other.label == label) && - (identical(other.active, active) || other.active == active)); - } - - @JsonKey(ignore: true) - @override - int get hashCode => Object.hash(runtimeType, url, label, active); - - @JsonKey(ignore: true) - @override - @pragma('vm:prefer-inline') - _$$LinkImplCopyWith<_$LinkImpl> get copyWith => - __$$LinkImplCopyWithImpl<_$LinkImpl>(this, _$identity); - - @override - Map toJson() { - return _$$LinkImplToJson( - this, - ); - } -} - -abstract class _Link implements Link { - const factory _Link( - {@JsonKey(name: "url") required final String? url, - @JsonKey(name: "label") required final String label, - @JsonKey(name: "active") required final bool active}) = _$LinkImpl; - - factory _Link.fromJson(Map json) = _$LinkImpl.fromJson; - - @override - @JsonKey(name: "url") - String? get url; - @override - @JsonKey(name: "label") - String get label; - @override - @JsonKey(name: "active") - bool get active; - @override - @JsonKey(ignore: true) - _$$LinkImplCopyWith<_$LinkImpl> get copyWith => + @JsonKey(includeFromJson: false, includeToJson: false) + _$$DietTypeImplCopyWith<_$DietTypeImpl> get copyWith => throw _privateConstructorUsedError; } diff --git a/lib/features/feed/models/diets_pagination_model.g.dart b/lib/features/feed/models/diets_pagination_model.g.dart index 0a745095..7fcab8cd 100644 --- a/lib/features/feed/models/diets_pagination_model.g.dart +++ b/lib/features/feed/models/diets_pagination_model.g.dart @@ -10,7 +10,7 @@ _$DietsPaginationImpl _$$DietsPaginationImplFromJson( Map json) => _$DietsPaginationImpl( data: (json['data'] as List) - .map((e) => Datum.fromJson(e as Map)) + .map((e) => Diet.fromJson(e as Map)) .toList(), links: Links.fromJson(json['links'] as Map), meta: Meta.fromJson(json['meta'] as Map), @@ -24,13 +24,13 @@ Map _$$DietsPaginationImplToJson( 'meta': instance.meta, }; -_$DatumImpl _$$DatumImplFromJson(Map json) => _$DatumImpl( +_$DietImpl _$$DietImplFromJson(Map json) => _$DietImpl( id: (json['id'] as num).toInt(), name: json['name'] as String, image: json['image'] as String, duration: (json['duration'] as num).toInt(), state: json['state'] as String, - type: Type.fromJson(json['type'] as Map), + type: DietType.fromJson(json['type'] as Map), details: json['details'] as String, dailySchedule: (json['daily_schedule'] as List) .map((e) => (e as List) @@ -45,7 +45,7 @@ _$DatumImpl _$$DatumImplFromJson(Map json) => _$DatumImpl( totalComments: (json['total_comments'] as num).toInt(), ); -Map _$$DatumImplToJson(_$DatumImpl instance) => +Map _$$DietImplToJson(_$DietImpl instance) => { 'id': instance.id, 'name': instance.name, @@ -98,70 +98,18 @@ const _$PortionEnumMap = { Portion.PCS: 'pcs', }; -_$TypeImpl _$$TypeImplFromJson(Map json) => _$TypeImpl( +_$DietTypeImpl _$$DietTypeImplFromJson(Map json) => + _$DietTypeImpl( alko: json['alko'] as bool?, veg: json['veg'] as bool?, corb: json['corb'] as bool?, meat: json['meat'] as bool?, ); -Map _$$TypeImplToJson(_$TypeImpl instance) => +Map _$$DietTypeImplToJson(_$DietTypeImpl instance) => { 'alko': instance.alko, 'veg': instance.veg, 'corb': instance.corb, 'meat': instance.meat, }; - -_$LinksImpl _$$LinksImplFromJson(Map json) => _$LinksImpl( - first: json['first'] as String, - last: json['last'] as String, - prev: json['prev'], - next: json['next'], - ); - -Map _$$LinksImplToJson(_$LinksImpl instance) => - { - 'first': instance.first, - 'last': instance.last, - 'prev': instance.prev, - 'next': instance.next, - }; - -_$MetaImpl _$$MetaImplFromJson(Map json) => _$MetaImpl( - currentPage: (json['current_page'] as num).toInt(), - from: (json['from'] as num).toInt(), - lastPage: (json['last_page'] as num).toInt(), - links: (json['links'] as List) - .map((e) => Link.fromJson(e as Map)) - .toList(), - path: json['path'] as String, - perPage: (json['per_page'] as num).toInt(), - to: (json['to'] as num).toInt(), - total: (json['total'] as num).toInt(), - ); - -Map _$$MetaImplToJson(_$MetaImpl instance) => - { - 'current_page': instance.currentPage, - 'from': instance.from, - 'last_page': instance.lastPage, - 'links': instance.links, - 'path': instance.path, - 'per_page': instance.perPage, - 'to': instance.to, - 'total': instance.total, - }; - -_$LinkImpl _$$LinkImplFromJson(Map json) => _$LinkImpl( - url: json['url'] as String?, - label: json['label'] as String, - active: json['active'] as bool, - ); - -Map _$$LinkImplToJson(_$LinkImpl instance) => - { - 'url': instance.url, - 'label': instance.label, - 'active': instance.active, - }; 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 08d5527a..89087373 100644 --- a/lib/features/feed/models/feed_blog_post_model.freezed.dart +++ b/lib/features/feed/models/feed_blog_post_model.freezed.dart @@ -41,8 +41,12 @@ mixin _$FeedBlogPostModel { @JsonKey(name: "was_liked_by_me") bool get wasLikedByMe => throw _privateConstructorUsedError; + /// Serializes this FeedBlogPostModel to a JSON map. Map toJson() => throw _privateConstructorUsedError; - @JsonKey(ignore: true) + + /// Create a copy of FeedBlogPostModel + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) $FeedBlogPostModelCopyWith get copyWith => throw _privateConstructorUsedError; } @@ -81,6 +85,8 @@ 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({ @@ -154,6 +160,8 @@ 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 { @@ -198,6 +206,8 @@ 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({ @@ -360,7 +370,7 @@ class _$FeedBlogPostModelImpl implements _FeedBlogPostModel { other.wasLikedByMe == wasLikedByMe)); } - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) @override int get hashCode => Object.hash( runtimeType, @@ -378,7 +388,9 @@ class _$FeedBlogPostModelImpl implements _FeedBlogPostModel { totalComments, wasLikedByMe); - @JsonKey(ignore: true) + /// Create a copy of FeedBlogPostModel + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$FeedBlogPostModelImplCopyWith<_$FeedBlogPostModelImpl> get copyWith => @@ -446,8 +458,11 @@ 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(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) _$$FeedBlogPostModelImplCopyWith<_$FeedBlogPostModelImpl> get copyWith => throw _privateConstructorUsedError; } diff --git a/lib/features/feed/models/feed_blog_post_settings_model.dart b/lib/features/feed/models/feed_blog_post_settings_model.dart index 66e0ecf3..064facfa 100644 --- a/lib/features/feed/models/feed_blog_post_settings_model.dart +++ b/lib/features/feed/models/feed_blog_post_settings_model.dart @@ -1,8 +1,9 @@ -import 'package:eatvio_app/features/feed/models/diets_pagination_model.dart'; +import 'package:eatvio_app/core/models/pagination_model.dart'; import 'package:eatvio_app/features/feed/models/feed_blog_post_model.dart'; import 'package:freezed_annotation/freezed_annotation.dart'; part 'feed_blog_post_settings_model.freezed.dart'; + part 'feed_blog_post_settings_model.g.dart'; @freezed 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 c680d82e..9bddceae 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,8 +26,12 @@ mixin _$FeedBlogPostSettingsModel { throw _privateConstructorUsedError; Meta get meta => throw _privateConstructorUsedError; + /// Serializes this FeedBlogPostSettingsModel to a JSON map. Map toJson() => throw _privateConstructorUsedError; - @JsonKey(ignore: true) + + /// Create a copy of FeedBlogPostSettingsModel + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) $FeedBlogPostSettingsModelCopyWith get copyWith => throw _privateConstructorUsedError; } @@ -56,6 +60,8 @@ 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({ @@ -74,6 +80,8 @@ 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 { @@ -110,6 +118,8 @@ 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({ @@ -169,12 +179,14 @@ class _$FeedBlogPostSettingsModelImpl implements _FeedBlogPostSettingsModel { (identical(other.meta, meta) || other.meta == meta)); } - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) @override int get hashCode => Object.hash(runtimeType, const DeepCollectionEquality().hash(_feedBlogPostList), meta); - @JsonKey(ignore: true) + /// Create a copy of FeedBlogPostSettingsModel + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$FeedBlogPostSettingsModelImplCopyWith<_$FeedBlogPostSettingsModelImpl> @@ -203,8 +215,11 @@ 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(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) _$$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 26cd55e3..9dd4f54e 100644 --- a/lib/features/feed/models/recipes_model.freezed.dart +++ b/lib/features/feed/models/recipes_model.freezed.dart @@ -45,8 +45,12 @@ mixin _$Recipes { int get viewsCount => throw _privateConstructorUsedError; Author get author => throw _privateConstructorUsedError; + /// Serializes this Recipes to a JSON map. Map toJson() => throw _privateConstructorUsedError; - @JsonKey(ignore: true) + + /// Create a copy of Recipes + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) $RecipesCopyWith get copyWith => throw _privateConstructorUsedError; } @@ -87,6 +91,8 @@ 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({ @@ -180,6 +186,8 @@ 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 { @@ -227,6 +235,8 @@ 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({ @@ -440,7 +450,7 @@ class _$RecipesImpl implements _Recipes { (identical(other.author, author) || other.author == author)); } - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) @override int get hashCode => Object.hash( runtimeType, @@ -462,7 +472,9 @@ class _$RecipesImpl implements _Recipes { viewsCount, author); - @JsonKey(ignore: true) + /// Create a copy of Recipes + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$RecipesImplCopyWith<_$RecipesImpl> get copyWith => @@ -539,8 +551,11 @@ 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(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) _$$RecipesImplCopyWith<_$RecipesImpl> get copyWith => throw _privateConstructorUsedError; } @@ -555,8 +570,12 @@ mixin _$Ingredient { String? get unit => throw _privateConstructorUsedError; String get portion => throw _privateConstructorUsedError; + /// Serializes this Ingredient to a JSON map. Map toJson() => throw _privateConstructorUsedError; - @JsonKey(ignore: true) + + /// Create a copy of Ingredient + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) $IngredientCopyWith get copyWith => throw _privateConstructorUsedError; } @@ -580,6 +599,8 @@ 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({ @@ -623,6 +644,8 @@ 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({ @@ -678,11 +701,13 @@ class _$IngredientImpl implements _Ingredient { (identical(other.portion, portion) || other.portion == portion)); } - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) @override int get hashCode => Object.hash(runtimeType, name, unit, portion); - @JsonKey(ignore: true) + /// Create a copy of Ingredient + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$IngredientImplCopyWith<_$IngredientImpl> get copyWith => @@ -711,8 +736,11 @@ 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(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) _$$IngredientImplCopyWith<_$IngredientImpl> get copyWith => throw _privateConstructorUsedError; } @@ -726,8 +754,12 @@ mixin _$Step { String get image => throw _privateConstructorUsedError; String get description => throw _privateConstructorUsedError; + /// Serializes this Step to a JSON map. Map toJson() => throw _privateConstructorUsedError; - @JsonKey(ignore: true) + + /// Create a copy of Step + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) $StepCopyWith get copyWith => throw _privateConstructorUsedError; } @@ -749,6 +781,8 @@ 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({ @@ -785,6 +819,8 @@ 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({ @@ -832,11 +868,13 @@ class _$StepImpl implements _Step { other.description == description)); } - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) @override int get hashCode => Object.hash(runtimeType, image, description); - @JsonKey(ignore: true) + /// Create a copy of Step + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$StepImplCopyWith<_$StepImpl> get copyWith => @@ -861,8 +899,11 @@ 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(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) _$$StepImplCopyWith<_$StepImpl> get copyWith => throw _privateConstructorUsedError; } diff --git a/lib/features/feed/models/recipes_pagination_model.dart b/lib/features/feed/models/recipes_pagination_model.dart index 0d2abdca..25384082 100644 --- a/lib/features/feed/models/recipes_pagination_model.dart +++ b/lib/features/feed/models/recipes_pagination_model.dart @@ -2,6 +2,7 @@ import 'package:eatvio_app/features/feed/models/recipes_model.dart'; import 'package:freezed_annotation/freezed_annotation.dart'; part 'recipes_pagination_model.freezed.dart'; + part 'recipes_pagination_model.g.dart'; @freezed diff --git a/lib/features/feed/models/recipes_pagination_model.freezed.dart b/lib/features/feed/models/recipes_pagination_model.freezed.dart index 2f0d43fb..ca8e9f92 100644 --- a/lib/features/feed/models/recipes_pagination_model.freezed.dart +++ b/lib/features/feed/models/recipes_pagination_model.freezed.dart @@ -23,8 +23,12 @@ mixin _$RecipesPagination { @JsonKey(name: 'data') List get recipesList => throw _privateConstructorUsedError; + /// Serializes this RecipesPagination to a JSON map. Map toJson() => throw _privateConstructorUsedError; - @JsonKey(ignore: true) + + /// Create a copy of RecipesPagination + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) $RecipesPaginationCopyWith get copyWith => throw _privateConstructorUsedError; } @@ -48,6 +52,8 @@ 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({ @@ -81,6 +87,8 @@ 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({ @@ -128,12 +136,14 @@ class _$RecipesPaginationImpl implements _RecipesPagination { .equals(other._recipesList, _recipesList)); } - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) @override int get hashCode => Object.hash( runtimeType, const DeepCollectionEquality().hash(_recipesList)); - @JsonKey(ignore: true) + /// Create a copy of RecipesPagination + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$RecipesPaginationImplCopyWith<_$RecipesPaginationImpl> get copyWith => @@ -159,8 +169,11 @@ 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(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) _$$RecipesPaginationImplCopyWith<_$RecipesPaginationImpl> get copyWith => throw _privateConstructorUsedError; } diff --git a/lib/features/feed/presentation/bloc/comments_cubit/comments_cubit.dart b/lib/features/feed/presentation/bloc/comments_cubit/comments_cubit.dart index 3dc735fa..dbfdaeb0 100644 --- a/lib/features/feed/presentation/bloc/comments_cubit/comments_cubit.dart +++ b/lib/features/feed/presentation/bloc/comments_cubit/comments_cubit.dart @@ -1,6 +1,7 @@ -import 'package:eatvio_app/core/app_export.dart'; import 'package:eatvio_app/features/feed/presentation/bloc/comments_cubit/comments_state.dart'; +import 'package:eatvio_app/features/feed/presentation/widgets/comments_widget.dart'; import 'package:eatvio_app/features/feed/repositories/feed_repository.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; class CommentsCubit extends Cubit { final FeedRepository feedRepository; @@ -9,79 +10,60 @@ class CommentsCubit extends Cubit { required this.feedRepository, }) : super(CommentsState()); - getBlogPostComments(int id) async { - emit(CommentsState.loading()); + setReplyId(int? replyId) { + emit((state as CommentsStateLoaded).copyWith(replyId: replyId)); + } + + getComments(String id, CommentSourceType commentSourceType, [bool isFirstFetch = false]) async { + if (isFirstFetch) emit(CommentsState.loading()); try { - emit(CommentsState.loaded(comment: await feedRepository.getBlogPostComments(id))); + switch (commentSourceType) { + case CommentSourceType.blogPost: + emit(CommentsState.loaded(comment: await feedRepository.getBlogPostComments(id: id))); + break; + case CommentSourceType.diet: + emit(CommentsState.loaded(comment: await feedRepository.getDietsComments(id: id))); + break; + case CommentSourceType.recipe: + emit(CommentsState.loaded(comment: await feedRepository.getRecipesComments(id: id))); + break; + } } catch (e) { emit(CommentsState.error(errorMessage: e.toString())); } } - getRecipesComments(String id) async { - emit(CommentsState.loading()); - try { - emit(CommentsState.loaded(comment: await feedRepository.getRecipesComments(id))); - } catch (e) { - emit(CommentsState.error(errorMessage: e.toString())); - } - } - - getDietsComments(int id) async { - emit(CommentsState.loading()); - try { - emit(CommentsState.loaded(comment: await feedRepository.getDietsComments(id))); - } catch (e) { - emit(CommentsState.error(errorMessage: e.toString())); - } - } - - sendBlogPostComment({ - required int id, - required String commentText, - int? parentCommentId, - }) async { - try { - await feedRepository.sendBlogPostComment( - id: id, - commentText: commentText, - parentCommentId: parentCommentId, - ); - emit(CommentsState.loaded(comment: await feedRepository.getBlogPostComments(id))); - } catch (e) { - emit(CommentsState.error(errorMessage: e.toString())); - } - } - - sendRecipesComment({ + sendComment({ required String id, required String commentText, + required CommentSourceType commentSourceType, int? parentCommentId, }) async { try { - await feedRepository.sendRecipesComment( - id: id, - commentText: commentText, - parentCommentId: parentCommentId, - ); - emit(CommentsState.loaded(comment: await feedRepository.getRecipesComments(id))); - } catch (e) { - emit(CommentsState.error(errorMessage: e.toString())); - } - } - - sendDietsComment({ - required int id, - required String commentText, - int? parentCommentId, - }) async { - try { - await feedRepository.sendDietsComment( - id: id, - commentText: commentText, - parentCommentId: parentCommentId, - ); - emit(CommentsState.loaded(comment: await feedRepository.getDietsComments(id))); + switch (commentSourceType) { + case CommentSourceType.blogPost: + await feedRepository.sendBlogPostComment( + id: id, + commentText: commentText, + parentCommentId: parentCommentId, + ); + break; + case CommentSourceType.diet: + await feedRepository.sendDietsComment( + id: id, + commentText: commentText, + parentCommentId: parentCommentId, + ); + break; + case CommentSourceType.recipe: + await feedRepository.sendRecipesComment( + id: id, + commentText: commentText, + parentCommentId: parentCommentId, + ); + break; + } + getComments(id, commentSourceType); } catch (e) { emit(CommentsState.error(errorMessage: e.toString())); } diff --git a/lib/features/feed/presentation/bloc/comments_cubit/comments_state.dart b/lib/features/feed/presentation/bloc/comments_cubit/comments_state.dart index 2f910856..0f9c49ea 100644 --- a/lib/features/feed/presentation/bloc/comments_cubit/comments_state.dart +++ b/lib/features/feed/presentation/bloc/comments_cubit/comments_state.dart @@ -10,7 +10,8 @@ abstract class CommentsState with _$CommentsState { const factory CommentsState.loading() = CommentsStateLoading; const factory CommentsState.loaded({ - required Comment comment, + required CommentModel comment, + int? replyId, }) = CommentsStateLoaded; const factory CommentsState.error({ 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 da3d0345..c3b582ce 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 @@ -20,7 +20,7 @@ mixin _$CommentsState { TResult when( TResult Function() $default, { required TResult Function() loading, - required TResult Function(Comment comment) loaded, + required TResult Function(CommentModel comment, int? replyId) loaded, required TResult Function(String errorMessage) error, }) => throw _privateConstructorUsedError; @@ -28,7 +28,7 @@ mixin _$CommentsState { TResult? whenOrNull( TResult? Function()? $default, { TResult? Function()? loading, - TResult? Function(Comment comment)? loaded, + TResult? Function(CommentModel comment, int? replyId)? loaded, TResult? Function(String errorMessage)? error, }) => throw _privateConstructorUsedError; @@ -36,7 +36,7 @@ mixin _$CommentsState { TResult maybeWhen( TResult Function()? $default, { TResult Function()? loading, - TResult Function(Comment comment)? loaded, + TResult Function(CommentModel comment, int? replyId)? loaded, TResult Function(String errorMessage)? error, required TResult orElse(), }) => @@ -84,6 +84,9 @@ 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 @@ -100,6 +103,9 @@ 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 @@ -126,7 +132,7 @@ class _$CommentsStateImpl implements _CommentsState { TResult when( TResult Function() $default, { required TResult Function() loading, - required TResult Function(Comment comment) loaded, + required TResult Function(CommentModel comment, int? replyId) loaded, required TResult Function(String errorMessage) error, }) { return $default(); @@ -137,7 +143,7 @@ class _$CommentsStateImpl implements _CommentsState { TResult? whenOrNull( TResult? Function()? $default, { TResult? Function()? loading, - TResult? Function(Comment comment)? loaded, + TResult? Function(CommentModel comment, int? replyId)? loaded, TResult? Function(String errorMessage)? error, }) { return $default?.call(); @@ -148,7 +154,7 @@ class _$CommentsStateImpl implements _CommentsState { TResult maybeWhen( TResult Function()? $default, { TResult Function()? loading, - TResult Function(Comment comment)? loaded, + TResult Function(CommentModel comment, int? replyId)? loaded, TResult Function(String errorMessage)? error, required TResult orElse(), }) { @@ -214,6 +220,9 @@ 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 @@ -241,7 +250,7 @@ class _$CommentsStateLoadingImpl implements CommentsStateLoading { TResult when( TResult Function() $default, { required TResult Function() loading, - required TResult Function(Comment comment) loaded, + required TResult Function(CommentModel comment, int? replyId) loaded, required TResult Function(String errorMessage) error, }) { return loading(); @@ -252,7 +261,7 @@ class _$CommentsStateLoadingImpl implements CommentsStateLoading { TResult? whenOrNull( TResult? Function()? $default, { TResult? Function()? loading, - TResult? Function(Comment comment)? loaded, + TResult? Function(CommentModel comment, int? replyId)? loaded, TResult? Function(String errorMessage)? error, }) { return loading?.call(); @@ -263,7 +272,7 @@ class _$CommentsStateLoadingImpl implements CommentsStateLoading { TResult maybeWhen( TResult Function()? $default, { TResult Function()? loading, - TResult Function(Comment comment)? loaded, + TResult Function(CommentModel comment, int? replyId)? loaded, TResult Function(String errorMessage)? error, required TResult orElse(), }) { @@ -321,9 +330,9 @@ abstract class _$$CommentsStateLoadedImplCopyWith<$Res> { $Res Function(_$CommentsStateLoadedImpl) then) = __$$CommentsStateLoadedImplCopyWithImpl<$Res>; @useResult - $Res call({Comment comment}); + $Res call({CommentModel comment, int? replyId}); - $CommentCopyWith<$Res> get comment; + $CommentModelCopyWith<$Res> get comment; } /// @nodoc @@ -334,23 +343,32 @@ 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({ Object? comment = null, + Object? replyId = freezed, }) { return _then(_$CommentsStateLoadedImpl( comment: null == comment ? _value.comment : comment // ignore: cast_nullable_to_non_nullable - as Comment, + as CommentModel, + replyId: freezed == replyId + ? _value.replyId + : replyId // ignore: cast_nullable_to_non_nullable + as int?, )); } + /// 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 { - return $CommentCopyWith<$Res>(_value.comment, (value) { + $CommentModelCopyWith<$Res> get comment { + return $CommentModelCopyWith<$Res>(_value.comment, (value) { return _then(_value.copyWith(comment: value)); }); } @@ -359,14 +377,16 @@ class __$$CommentsStateLoadedImplCopyWithImpl<$Res> /// @nodoc class _$CommentsStateLoadedImpl implements CommentsStateLoaded { - const _$CommentsStateLoadedImpl({required this.comment}); + const _$CommentsStateLoadedImpl({required this.comment, this.replyId}); @override - final Comment comment; + final CommentModel comment; + @override + final int? replyId; @override String toString() { - return 'CommentsState.loaded(comment: $comment)'; + return 'CommentsState.loaded(comment: $comment, replyId: $replyId)'; } @override @@ -374,13 +394,16 @@ class _$CommentsStateLoadedImpl implements CommentsStateLoaded { return identical(this, other) || (other.runtimeType == runtimeType && other is _$CommentsStateLoadedImpl && - (identical(other.comment, comment) || other.comment == comment)); + (identical(other.comment, comment) || other.comment == comment) && + (identical(other.replyId, replyId) || other.replyId == replyId)); } @override - int get hashCode => Object.hash(runtimeType, comment); + int get hashCode => Object.hash(runtimeType, comment, replyId); - @JsonKey(ignore: true) + /// Create a copy of CommentsState + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$CommentsStateLoadedImplCopyWith<_$CommentsStateLoadedImpl> get copyWith => @@ -392,10 +415,10 @@ class _$CommentsStateLoadedImpl implements CommentsStateLoaded { TResult when( TResult Function() $default, { required TResult Function() loading, - required TResult Function(Comment comment) loaded, + required TResult Function(CommentModel comment, int? replyId) loaded, required TResult Function(String errorMessage) error, }) { - return loaded(comment); + return loaded(comment, replyId); } @override @@ -403,10 +426,10 @@ class _$CommentsStateLoadedImpl implements CommentsStateLoaded { TResult? whenOrNull( TResult? Function()? $default, { TResult? Function()? loading, - TResult? Function(Comment comment)? loaded, + TResult? Function(CommentModel comment, int? replyId)? loaded, TResult? Function(String errorMessage)? error, }) { - return loaded?.call(comment); + return loaded?.call(comment, replyId); } @override @@ -414,12 +437,12 @@ class _$CommentsStateLoadedImpl implements CommentsStateLoaded { TResult maybeWhen( TResult Function()? $default, { TResult Function()? loading, - TResult Function(Comment comment)? loaded, + TResult Function(CommentModel comment, int? replyId)? loaded, TResult Function(String errorMessage)? error, required TResult orElse(), }) { if (loaded != null) { - return loaded(comment); + return loaded(comment, replyId); } return orElse(); } @@ -463,11 +486,16 @@ class _$CommentsStateLoadedImpl implements CommentsStateLoaded { } abstract class CommentsStateLoaded implements CommentsState { - const factory CommentsStateLoaded({required final Comment comment}) = - _$CommentsStateLoadedImpl; + const factory CommentsStateLoaded( + {required final CommentModel comment, + final int? replyId}) = _$CommentsStateLoadedImpl; - Comment get comment; - @JsonKey(ignore: true) + CommentModel get comment; + int? get replyId; + + /// Create a copy of CommentsState + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) _$$CommentsStateLoadedImplCopyWith<_$CommentsStateLoadedImpl> get copyWith => throw _privateConstructorUsedError; } @@ -489,6 +517,8 @@ 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({ @@ -528,7 +558,9 @@ class _$CommentsStateErrorImpl implements CommentsStateError { @override int get hashCode => Object.hash(runtimeType, errorMessage); - @JsonKey(ignore: true) + /// Create a copy of CommentsState + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$CommentsStateErrorImplCopyWith<_$CommentsStateErrorImpl> get copyWith => @@ -540,7 +572,7 @@ class _$CommentsStateErrorImpl implements CommentsStateError { TResult when( TResult Function() $default, { required TResult Function() loading, - required TResult Function(Comment comment) loaded, + required TResult Function(CommentModel comment, int? replyId) loaded, required TResult Function(String errorMessage) error, }) { return error(errorMessage); @@ -551,7 +583,7 @@ class _$CommentsStateErrorImpl implements CommentsStateError { TResult? whenOrNull( TResult? Function()? $default, { TResult? Function()? loading, - TResult? Function(Comment comment)? loaded, + TResult? Function(CommentModel comment, int? replyId)? loaded, TResult? Function(String errorMessage)? error, }) { return error?.call(errorMessage); @@ -562,7 +594,7 @@ class _$CommentsStateErrorImpl implements CommentsStateError { TResult maybeWhen( TResult Function()? $default, { TResult Function()? loading, - TResult Function(Comment comment)? loaded, + TResult Function(CommentModel comment, int? replyId)? loaded, TResult Function(String errorMessage)? error, required TResult orElse(), }) { @@ -615,7 +647,10 @@ abstract class CommentsStateError implements CommentsState { _$CommentsStateErrorImpl; String get errorMessage; - @JsonKey(ignore: true) + + /// Create a copy of CommentsState + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) _$$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 adff30f5..dd30f73d 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,6 +84,9 @@ 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 @@ -100,6 +103,9 @@ 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 @@ -214,6 +220,9 @@ 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 @@ -333,6 +342,8 @@ 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({ @@ -346,6 +357,8 @@ 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 { @@ -379,7 +392,9 @@ class _$DietsStateLoadedImpl implements DietsStateLoaded { @override int get hashCode => Object.hash(runtimeType, diets); - @JsonKey(ignore: true) + /// Create a copy of DietsState + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$DietsStateLoadedImplCopyWith<_$DietsStateLoadedImpl> get copyWith => @@ -466,7 +481,10 @@ abstract class DietsStateLoaded implements DietsState { _$DietsStateLoadedImpl; DietsPagination get diets; - @JsonKey(ignore: true) + + /// Create a copy of DietsState + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) _$$DietsStateLoadedImplCopyWith<_$DietsStateLoadedImpl> get copyWith => throw _privateConstructorUsedError; } @@ -488,6 +506,8 @@ 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({ @@ -527,7 +547,9 @@ class _$DietsStateErrorImpl implements DietsStateError { @override int get hashCode => Object.hash(runtimeType, errorMessage); - @JsonKey(ignore: true) + /// Create a copy of DietsState + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$DietsStateErrorImplCopyWith<_$DietsStateErrorImpl> get copyWith => @@ -614,7 +636,10 @@ abstract class DietsStateError implements DietsState { _$DietsStateErrorImpl; String get errorMessage; - @JsonKey(ignore: true) + + /// Create a copy of DietsState + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) _$$DietsStateErrorImplCopyWith<_$DietsStateErrorImpl> get copyWith => throw _privateConstructorUsedError; } diff --git a/lib/features/feed/presentation/bloc/feed_cubit/feed_cubit.dart b/lib/features/feed/presentation/bloc/feed_cubit/feed_cubit.dart index 0de3af57..83df5eb0 100644 --- a/lib/features/feed/presentation/bloc/feed_cubit/feed_cubit.dart +++ b/lib/features/feed/presentation/bloc/feed_cubit/feed_cubit.dart @@ -1,18 +1,23 @@ -import 'package:eatvio_app/core/app_export.dart'; import 'package:eatvio_app/features/feed/presentation/bloc/feed_cubit/feed_state.dart'; import 'package:eatvio_app/features/feed/repositories/feed_repository.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; class FeedCubit extends Cubit { final FeedRepository feedRepository; - int _currentPage = 1; - final int _lastPage = 7; + int currentPage = 1; + late int lastPage; bool isLoading = false; + String? _query; FeedCubit({required this.feedRepository}) : super(const FeedState.loading()); - loadFeedBlogPostList() async { + loadFeedBlogPostList({ + String? query, + }) async { try { - final feedBlogPosts = await feedRepository.getFeedBlogPosts(); + _query = query; + final feedBlogPosts = await feedRepository.getFeedBlogPosts(query: query); + lastPage = feedBlogPosts.meta.lastPage; emit( FeedState.loaded( feedBlogPostList: feedBlogPosts.feedBlogPostList, @@ -25,30 +30,36 @@ class FeedCubit extends Cubit { } loadNextPage() async { - print('start'); - try { - if (_lastPage < _currentPage) { - _currentPage++; - final feedBlogPosts = await feedRepository.getFeedBlogPosts(page: _currentPage); - emit( - FeedState.loaded( - feedBlogPostList: [ - ...(state as FeedStateLoaded).feedBlogPostList, - ...feedBlogPosts.feedBlogPostList, - ], - isLoading: false, - ), - ); + if (currentPage < lastPage && !isLoading) { + isLoading = true; + + emit((state as FeedStateLoaded).copyWith(isLoading: isLoading)); + + try { + if (currentPage < lastPage) { + currentPage++; + final feedBlogPosts = await feedRepository.getFeedBlogPosts( + page: currentPage, + query: _query, + ); + isLoading = false; + emit( + FeedState.loaded( + feedBlogPostList: [ + ...(state as FeedStateLoaded).feedBlogPostList, + ...feedBlogPosts.feedBlogPostList, + ], + isLoading: isLoading, + ), + ); + } + } catch (e) { + emit(FeedState.error(errorMessage: e.toString())); } - } catch (e) { - print('error bro'); - print(e.toString()); - } finally { - print('end'); } } - likePost(int id) async => await feedRepository.likeBlogPost(id); + likePost(int id) async => await feedRepository.likeBlogPost(id: id); - unlikedPost(int id) async => await feedRepository.unlikedBlogPost(id); + unlikedPost(int id) async => await feedRepository.unlikedBlogPost(id: id); } 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 779dcdb5..70cb30d4 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,6 +87,9 @@ 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 @@ -103,6 +106,9 @@ 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 @@ -221,6 +227,9 @@ 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 @@ -342,6 +351,8 @@ 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({ @@ -401,7 +412,9 @@ class _$FeedStateLoadedImpl implements FeedStateLoaded { int get hashCode => Object.hash(runtimeType, const DeepCollectionEquality().hash(_feedBlogPostList), isLoading); - @JsonKey(ignore: true) + /// Create a copy of FeedState + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$FeedStateLoadedImplCopyWith<_$FeedStateLoadedImpl> get copyWith => @@ -494,7 +507,10 @@ abstract class FeedStateLoaded implements FeedState { List get feedBlogPostList; bool get isLoading; - @JsonKey(ignore: true) + + /// Create a copy of FeedState + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) _$$FeedStateLoadedImplCopyWith<_$FeedStateLoadedImpl> get copyWith => throw _privateConstructorUsedError; } @@ -516,6 +532,8 @@ 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({ @@ -555,7 +573,9 @@ class _$FeedStateErrorImpl implements FeedStateError { @override int get hashCode => Object.hash(runtimeType, errorMessage); - @JsonKey(ignore: true) + /// Create a copy of FeedState + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$FeedStateErrorImplCopyWith<_$FeedStateErrorImpl> get copyWith => @@ -646,7 +666,10 @@ abstract class FeedStateError implements FeedState { _$FeedStateErrorImpl; String get errorMessage; - @JsonKey(ignore: true) + + /// Create a copy of FeedState + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) _$$FeedStateErrorImplCopyWith<_$FeedStateErrorImpl> get copyWith => throw _privateConstructorUsedError; } diff --git a/lib/features/feed/presentation/bloc/recipes_cubit/recipes_cubit.dart b/lib/features/feed/presentation/bloc/recipes_cubit/recipes_cubit.dart index 8cd8a522..621880fe 100644 --- a/lib/features/feed/presentation/bloc/recipes_cubit/recipes_cubit.dart +++ b/lib/features/feed/presentation/bloc/recipes_cubit/recipes_cubit.dart @@ -1,18 +1,79 @@ import 'package:eatvio_app/features/feed/presentation/bloc/recipes_cubit/recipes_state.dart'; import 'package:eatvio_app/features/feed/repositories/feed_repository.dart'; +import 'package:eatvio_app/features/recipes/models/recipe_tag_model.dart'; +import 'package:eatvio_app/features/recipes/reporitories/recipe_repository.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; class RecipesCubit extends Cubit { final FeedRepository feedRepository; + final RecipeRepository recipeRepository; + Set _selectedTags = {}; + int currentPage = 1; + late int lastPage; + bool isLoading = false; + String? _query; - RecipesCubit({required this.feedRepository}) : super(const RecipesState.loading()); - - loadRecipesList() async { + loadRecipesList({ + String? query, + }) async { try { - final recipesList = await feedRepository.getRecipes(); - emit(RecipesState.loaded(recipesList: recipesList)); + _query = query; + final recipesList = await feedRepository.getRecipes( + tags: _selectedTags.toList(), + query: query, + ); + final recipesTags = (await recipeRepository.getRecipesTags()); + emit(RecipesState.loaded( + recipesList: recipesList, + recipesTags: recipesTags, + selectedTags: _selectedTags, + selectedTagsCounter: _selectedTags.length, + isLoading: isLoading, + )); } catch (e) { emit(RecipesState.error(errorMessage: e.toString())); } } + + RecipesCubit({ + required this.feedRepository, + required this.recipeRepository, + }) : super(const RecipesState.loading()); + + loadNextPage() async { + if (currentPage < lastPage && !isLoading) { + isLoading = true; + + emit((state as RecipesStateLoaded).copyWith(isLoading: isLoading)); + + try { + if (currentPage < lastPage) { + currentPage++; + final recipesList = await feedRepository.getRecipes( + page: currentPage, + tags: _selectedTags.toList(), + query: _query, + ); + isLoading = false; + emit((state as RecipesStateLoaded).copyWith( + recipesList: [ + ...(state as RecipesStateLoaded).recipesList, + ...recipesList, + ], + isLoading: isLoading, + )); + } + } catch (e) { + emit(RecipesState.error(errorMessage: e.toString())); + } + } + } + + updateTags(RecipeTag tag) { + _selectedTags.contains(tag.id) ? _selectedTags.remove(tag.id) : _selectedTags.add(tag.id); + emit((state as RecipesStateLoaded).copyWith( + selectedTags: _selectedTags, + selectedTagsCounter: _selectedTags.length, + )); + } } diff --git a/lib/features/feed/presentation/bloc/recipes_cubit/recipes_state.dart b/lib/features/feed/presentation/bloc/recipes_cubit/recipes_state.dart index ecdf17c2..dc6dcb66 100644 --- a/lib/features/feed/presentation/bloc/recipes_cubit/recipes_state.dart +++ b/lib/features/feed/presentation/bloc/recipes_cubit/recipes_state.dart @@ -1,4 +1,5 @@ import 'package:eatvio_app/features/feed/models/recipes_model.dart'; +import 'package:eatvio_app/features/recipes/models/recipe_tag_model.dart'; import 'package:freezed_annotation/freezed_annotation.dart'; part 'recipes_state.freezed.dart'; @@ -11,6 +12,10 @@ abstract class RecipesState with _$RecipesState { const factory RecipesState.loaded({ required List recipesList, + required List recipesTags, + required Set selectedTags, + required int selectedTagsCounter, + required bool isLoading, }) = RecipesStateLoaded; const factory RecipesState.error({ 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 e8aa88e0..34100adb 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 @@ -20,7 +20,13 @@ mixin _$RecipesState { TResult when( TResult Function() $default, { required TResult Function() loading, - required TResult Function(List recipesList) loaded, + required TResult Function( + List recipesList, + List recipesTags, + Set selectedTags, + int selectedTagsCounter, + bool isLoading) + loaded, required TResult Function(String errorMessage) error, }) => throw _privateConstructorUsedError; @@ -28,7 +34,9 @@ mixin _$RecipesState { TResult? whenOrNull( TResult? Function()? $default, { TResult? Function()? loading, - TResult? Function(List recipesList)? loaded, + TResult? Function(List recipesList, List recipesTags, + Set selectedTags, int selectedTagsCounter, bool isLoading)? + loaded, TResult? Function(String errorMessage)? error, }) => throw _privateConstructorUsedError; @@ -36,7 +44,9 @@ mixin _$RecipesState { TResult maybeWhen( TResult Function()? $default, { TResult Function()? loading, - TResult Function(List recipesList)? loaded, + TResult Function(List recipesList, List recipesTags, + Set selectedTags, int selectedTagsCounter, bool isLoading)? + loaded, TResult Function(String errorMessage)? error, required TResult orElse(), }) => @@ -84,6 +94,9 @@ 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 @@ -100,6 +113,9 @@ 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 @@ -126,7 +142,13 @@ class _$RecipesStateImpl implements _RecipesState { TResult when( TResult Function() $default, { required TResult Function() loading, - required TResult Function(List recipesList) loaded, + required TResult Function( + List recipesList, + List recipesTags, + Set selectedTags, + int selectedTagsCounter, + bool isLoading) + loaded, required TResult Function(String errorMessage) error, }) { return $default(); @@ -137,7 +159,9 @@ class _$RecipesStateImpl implements _RecipesState { TResult? whenOrNull( TResult? Function()? $default, { TResult? Function()? loading, - TResult? Function(List recipesList)? loaded, + TResult? Function(List recipesList, List recipesTags, + Set selectedTags, int selectedTagsCounter, bool isLoading)? + loaded, TResult? Function(String errorMessage)? error, }) { return $default?.call(); @@ -148,7 +172,9 @@ class _$RecipesStateImpl implements _RecipesState { TResult maybeWhen( TResult Function()? $default, { TResult Function()? loading, - TResult Function(List recipesList)? loaded, + TResult Function(List recipesList, List recipesTags, + Set selectedTags, int selectedTagsCounter, bool isLoading)? + loaded, TResult Function(String errorMessage)? error, required TResult orElse(), }) { @@ -214,6 +240,9 @@ 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 @@ -241,7 +270,13 @@ class _$RecipesStateLoadingImpl implements RecipesStateLoading { TResult when( TResult Function() $default, { required TResult Function() loading, - required TResult Function(List recipesList) loaded, + required TResult Function( + List recipesList, + List recipesTags, + Set selectedTags, + int selectedTagsCounter, + bool isLoading) + loaded, required TResult Function(String errorMessage) error, }) { return loading(); @@ -252,7 +287,9 @@ class _$RecipesStateLoadingImpl implements RecipesStateLoading { TResult? whenOrNull( TResult? Function()? $default, { TResult? Function()? loading, - TResult? Function(List recipesList)? loaded, + TResult? Function(List recipesList, List recipesTags, + Set selectedTags, int selectedTagsCounter, bool isLoading)? + loaded, TResult? Function(String errorMessage)? error, }) { return loading?.call(); @@ -263,7 +300,9 @@ class _$RecipesStateLoadingImpl implements RecipesStateLoading { TResult maybeWhen( TResult Function()? $default, { TResult Function()? loading, - TResult Function(List recipesList)? loaded, + TResult Function(List recipesList, List recipesTags, + Set selectedTags, int selectedTagsCounter, bool isLoading)? + loaded, TResult Function(String errorMessage)? error, required TResult orElse(), }) { @@ -321,7 +360,12 @@ abstract class _$$RecipesStateLoadedImplCopyWith<$Res> { $Res Function(_$RecipesStateLoadedImpl) then) = __$$RecipesStateLoadedImplCopyWithImpl<$Res>; @useResult - $Res call({List recipesList}); + $Res call( + {List recipesList, + List recipesTags, + Set selectedTags, + int selectedTagsCounter, + bool isLoading}); } /// @nodoc @@ -332,16 +376,38 @@ 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({ Object? recipesList = null, + Object? recipesTags = null, + Object? selectedTags = null, + Object? selectedTagsCounter = null, + Object? isLoading = null, }) { return _then(_$RecipesStateLoadedImpl( recipesList: null == recipesList ? _value._recipesList : recipesList // ignore: cast_nullable_to_non_nullable as List, + recipesTags: null == recipesTags + ? _value._recipesTags + : recipesTags // ignore: cast_nullable_to_non_nullable + as List, + selectedTags: null == selectedTags + ? _value._selectedTags + : selectedTags // ignore: cast_nullable_to_non_nullable + as Set, + selectedTagsCounter: null == selectedTagsCounter + ? _value.selectedTagsCounter + : selectedTagsCounter // ignore: cast_nullable_to_non_nullable + as int, + isLoading: null == isLoading + ? _value.isLoading + : isLoading // ignore: cast_nullable_to_non_nullable + as bool, )); } } @@ -349,8 +415,15 @@ class __$$RecipesStateLoadedImplCopyWithImpl<$Res> /// @nodoc class _$RecipesStateLoadedImpl implements RecipesStateLoaded { - const _$RecipesStateLoadedImpl({required final List recipesList}) - : _recipesList = recipesList; + const _$RecipesStateLoadedImpl( + {required final List recipesList, + required final List recipesTags, + required final Set selectedTags, + required this.selectedTagsCounter, + required this.isLoading}) + : _recipesList = recipesList, + _recipesTags = recipesTags, + _selectedTags = selectedTags; final List _recipesList; @override @@ -360,9 +433,30 @@ class _$RecipesStateLoadedImpl implements RecipesStateLoaded { return EqualUnmodifiableListView(_recipesList); } + final List _recipesTags; + @override + List get recipesTags { + if (_recipesTags is EqualUnmodifiableListView) return _recipesTags; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(_recipesTags); + } + + final Set _selectedTags; + @override + Set get selectedTags { + if (_selectedTags is EqualUnmodifiableSetView) return _selectedTags; + // ignore: implicit_dynamic_type + return EqualUnmodifiableSetView(_selectedTags); + } + + @override + final int selectedTagsCounter; + @override + final bool isLoading; + @override String toString() { - return 'RecipesState.loaded(recipesList: $recipesList)'; + return 'RecipesState.loaded(recipesList: $recipesList, recipesTags: $recipesTags, selectedTags: $selectedTags, selectedTagsCounter: $selectedTagsCounter, isLoading: $isLoading)'; } @override @@ -371,14 +465,29 @@ class _$RecipesStateLoadedImpl implements RecipesStateLoaded { (other.runtimeType == runtimeType && other is _$RecipesStateLoadedImpl && const DeepCollectionEquality() - .equals(other._recipesList, _recipesList)); + .equals(other._recipesList, _recipesList) && + const DeepCollectionEquality() + .equals(other._recipesTags, _recipesTags) && + const DeepCollectionEquality() + .equals(other._selectedTags, _selectedTags) && + (identical(other.selectedTagsCounter, selectedTagsCounter) || + other.selectedTagsCounter == selectedTagsCounter) && + (identical(other.isLoading, isLoading) || + other.isLoading == isLoading)); } @override int get hashCode => Object.hash( - runtimeType, const DeepCollectionEquality().hash(_recipesList)); + runtimeType, + const DeepCollectionEquality().hash(_recipesList), + const DeepCollectionEquality().hash(_recipesTags), + const DeepCollectionEquality().hash(_selectedTags), + selectedTagsCounter, + isLoading); - @JsonKey(ignore: true) + /// Create a copy of RecipesState + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$RecipesStateLoadedImplCopyWith<_$RecipesStateLoadedImpl> get copyWith => @@ -390,10 +499,17 @@ class _$RecipesStateLoadedImpl implements RecipesStateLoaded { TResult when( TResult Function() $default, { required TResult Function() loading, - required TResult Function(List recipesList) loaded, + required TResult Function( + List recipesList, + List recipesTags, + Set selectedTags, + int selectedTagsCounter, + bool isLoading) + loaded, required TResult Function(String errorMessage) error, }) { - return loaded(recipesList); + return loaded( + recipesList, recipesTags, selectedTags, selectedTagsCounter, isLoading); } @override @@ -401,10 +517,13 @@ class _$RecipesStateLoadedImpl implements RecipesStateLoaded { TResult? whenOrNull( TResult? Function()? $default, { TResult? Function()? loading, - TResult? Function(List recipesList)? loaded, + TResult? Function(List recipesList, List recipesTags, + Set selectedTags, int selectedTagsCounter, bool isLoading)? + loaded, TResult? Function(String errorMessage)? error, }) { - return loaded?.call(recipesList); + return loaded?.call( + recipesList, recipesTags, selectedTags, selectedTagsCounter, isLoading); } @override @@ -412,12 +531,15 @@ class _$RecipesStateLoadedImpl implements RecipesStateLoaded { TResult maybeWhen( TResult Function()? $default, { TResult Function()? loading, - TResult Function(List recipesList)? loaded, + TResult Function(List recipesList, List recipesTags, + Set selectedTags, int selectedTagsCounter, bool isLoading)? + loaded, TResult Function(String errorMessage)? error, required TResult orElse(), }) { if (loaded != null) { - return loaded(recipesList); + return loaded(recipesList, recipesTags, selectedTags, selectedTagsCounter, + isLoading); } return orElse(); } @@ -461,11 +583,22 @@ class _$RecipesStateLoadedImpl implements RecipesStateLoaded { } abstract class RecipesStateLoaded implements RecipesState { - const factory RecipesStateLoaded({required final List recipesList}) = - _$RecipesStateLoadedImpl; + const factory RecipesStateLoaded( + {required final List recipesList, + required final List recipesTags, + required final Set selectedTags, + required final int selectedTagsCounter, + required final bool isLoading}) = _$RecipesStateLoadedImpl; List get recipesList; - @JsonKey(ignore: true) + List get recipesTags; + Set get selectedTags; + int get selectedTagsCounter; + bool get isLoading; + + /// Create a copy of RecipesState + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) _$$RecipesStateLoadedImplCopyWith<_$RecipesStateLoadedImpl> get copyWith => throw _privateConstructorUsedError; } @@ -487,6 +620,8 @@ 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({ @@ -526,7 +661,9 @@ class _$RecipesStateErrorImpl implements RecipesStateError { @override int get hashCode => Object.hash(runtimeType, errorMessage); - @JsonKey(ignore: true) + /// Create a copy of RecipesState + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$RecipesStateErrorImplCopyWith<_$RecipesStateErrorImpl> get copyWith => @@ -538,7 +675,13 @@ class _$RecipesStateErrorImpl implements RecipesStateError { TResult when( TResult Function() $default, { required TResult Function() loading, - required TResult Function(List recipesList) loaded, + required TResult Function( + List recipesList, + List recipesTags, + Set selectedTags, + int selectedTagsCounter, + bool isLoading) + loaded, required TResult Function(String errorMessage) error, }) { return error(errorMessage); @@ -549,7 +692,9 @@ class _$RecipesStateErrorImpl implements RecipesStateError { TResult? whenOrNull( TResult? Function()? $default, { TResult? Function()? loading, - TResult? Function(List recipesList)? loaded, + TResult? Function(List recipesList, List recipesTags, + Set selectedTags, int selectedTagsCounter, bool isLoading)? + loaded, TResult? Function(String errorMessage)? error, }) { return error?.call(errorMessage); @@ -560,7 +705,9 @@ class _$RecipesStateErrorImpl implements RecipesStateError { TResult maybeWhen( TResult Function()? $default, { TResult Function()? loading, - TResult Function(List recipesList)? loaded, + TResult Function(List recipesList, List recipesTags, + Set selectedTags, int selectedTagsCounter, bool isLoading)? + loaded, TResult Function(String errorMessage)? error, required TResult orElse(), }) { @@ -613,7 +760,10 @@ abstract class RecipesStateError implements RecipesState { _$RecipesStateErrorImpl; String get errorMessage; - @JsonKey(ignore: true) + + /// Create a copy of RecipesState + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) _$$RecipesStateErrorImplCopyWith<_$RecipesStateErrorImpl> get copyWith => throw _privateConstructorUsedError; } diff --git a/lib/features/feed/presentation/pages/feed_screen.dart b/lib/features/feed/presentation/pages/feed_screen.dart index 662c06ec..ab1c9768 100644 --- a/lib/features/feed/presentation/pages/feed_screen.dart +++ b/lib/features/feed/presentation/pages/feed_screen.dart @@ -1,3 +1,4 @@ +import 'package:easy_debounce/easy_debounce.dart'; import 'package:eatvio_app/features/feed/presentation/bloc/diets_cubit/diets_cubit.dart'; import 'package:eatvio_app/features/feed/presentation/bloc/diets_cubit/diets_state.dart'; import 'package:eatvio_app/features/feed/presentation/bloc/feed_cubit/feed_cubit.dart'; @@ -6,12 +7,19 @@ import 'package:eatvio_app/features/feed/presentation/bloc/recipes_cubit/recipes import 'package:eatvio_app/features/feed/presentation/bloc/recipes_cubit/recipes_state.dart'; import 'package:eatvio_app/features/feed/presentation/widgets/blog_post_widget.dart'; import 'package:eatvio_app/features/feed/presentation/widgets/diets_widget.dart'; +import 'package:eatvio_app/features/feed/presentation/widgets/plan_widget.dart'; import 'package:eatvio_app/features/feed/presentation/widgets/recipes_widget.dart'; +import 'package:eatvio_app/features/feed/presentation/widgets/tags_modal_widget.dart'; +import 'package:eatvio_app/features/plans/presentation/bloc/plans_cubit/plans_cubit.dart'; +import 'package:eatvio_app/features/plans/presentation/bloc/plans_cubit/plans_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:flutter_bloc/flutter_bloc.dart'; import 'package:go_router/go_router.dart'; +import 'package:rive/rive.dart'; + +final bucket = PageStorageBucket(); class FeedScreen extends StatefulWidget { const FeedScreen({super.key}); @@ -21,19 +29,84 @@ class FeedScreen extends StatefulWidget { } class _FeedScreenState extends State { - final List chipsLabelList = ['Все', 'Рецепты', 'Диеты', 'Планы питания', 'Консультанты']; + final FeedCubit feedCubit = sl()..loadFeedBlogPostList(); + final RecipesCubit recipesCubit = sl()..loadRecipesList(); + final DietsCubit dietsCubit = sl()..loadDiets(); + final PlansCubit plansCubit = sl()..loadPlans(); + final searchController = TextEditingController(); + final List chipsLabelList = ['Все', 'Рецепты', 'Диеты', 'Планы питания', 'Консультанты']; int _selectedChipIndex = 0; + final blogPostsScrollController = ScrollController(); + final recipesScrollController = ScrollController(); + final dietsScrollController = ScrollController(); + final plansScrollController = ScrollController(); + + @override + void initState() { + blogPostsScrollController.addListener(_onScrollBlogPosts); + recipesScrollController.addListener(_onScrollRecipes); + dietsScrollController.addListener(_onScrollDiets); + plansScrollController.addListener(_onScrollPlans); + super.initState(); + } + + _onScrollBlogPosts() { + if (blogPostsScrollController.offset >= blogPostsScrollController.position.maxScrollExtent && !blogPostsScrollController.position.outOfRange) { + feedCubit.loadNextPage(); + } + } + + _onScrollRecipes() {} + + _onScrollDiets() {} + + _onScrollPlans() {} + + @override + void dispose() { + blogPostsScrollController.dispose(); + recipesScrollController.dispose(); + dietsScrollController.dispose(); + plansScrollController.dispose(); + super.dispose(); + } @override Widget build(BuildContext context) { return Scaffold( + floatingActionButton: _selectedChipIndex == 1 + ? FloatingActionButton.small( + heroTag: 'recipesTagsFilter', + backgroundColor: appTheme.blueA400, + shape: CircleBorder(), + child: Icon( + Icons.filter_list_rounded, + color: Colors.white, + ), + onPressed: () async { + await showModalBottomSheet( + useRootNavigator: true, + context: context, + builder: (context) => TagsModalWidget( + recipesCubit: recipesCubit, + ), + ); + recipesCubit.loadRecipesList(); + }, + ) + : null, appBar: AppBar( backgroundColor: Colors.white, toolbarHeight: 0, ), backgroundColor: Colors.grey.shade200, body: NestedScrollView( + controller: _selectedChipIndex == 0 + ? blogPostsScrollController + : _selectedChipIndex == 1 + ? recipesScrollController + : dietsScrollController, headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) { return [ SliverAppBar( @@ -66,6 +139,8 @@ class _FeedScreenState extends State { return _buildAllRecipes(); else if (_selectedChipIndex == 2) return _buildDiets(); + else if (_selectedChipIndex == 3) + return _buildPlans(); else return Center(child: Text(chipsLabelList[_selectedChipIndex])); }, @@ -74,125 +149,214 @@ class _FeedScreenState extends State { ); } - _buildDiets() { - return RefreshIndicator( - onRefresh: () => context.read().loadDiets(), - child: BlocBuilder( - builder: (BuildContext context, DietsState state) { - if (state is DietsStateLoaded) { - return ListView.separated( - padding: EdgeInsets.symmetric(vertical: 8), - shrinkWrap: true, - physics: BouncingScrollPhysics(), - itemBuilder: (context, index) { - return DietsWidget(datum: state.diets.data[index]); - }, - separatorBuilder: (context, index) { - return SizedBox(height: 8); - }, - itemCount: state.diets.data.length, - ); - } else if (state is DietsStateError) { - return Scaffold( - backgroundColor: Colors.grey.shade200, - body: Padding( - padding: const EdgeInsets.all(16), - child: Center( - child: Text(state.errorMessage), - ), - ), - ); - } else { - return Scaffold( - backgroundColor: Colors.grey.shade200, - body: Center( - child: CupertinoActivityIndicator(), - ), - ); - } - }, - ), - ); - } - _buildAllBlogPosts() { - return RefreshIndicator( - onRefresh: () => context.read().loadFeedBlogPostList(), - child: BlocBuilder( - builder: (BuildContext context, FeedState state) { - if (state is FeedStateLoaded) { - return ListView.separated( - padding: EdgeInsets.symmetric(vertical: 8), - shrinkWrap: true, - physics: BouncingScrollPhysics(), - itemBuilder: (context, index) { - return BlogPostWidget(feedBlogPostModel: state.feedBlogPostList[index]); - }, - separatorBuilder: (context, index) { - return SizedBox(height: 8); - }, - itemCount: state.feedBlogPostList.length, - ); - } else if (state is FeedStateError) { - return Scaffold( - backgroundColor: Colors.grey.shade200, - body: Padding( - padding: const EdgeInsets.all(16), - child: Center( - child: Text(state.errorMessage), + return BlocProvider( + create: (context) => feedCubit, + child: RefreshIndicator( + onRefresh: () => feedCubit.loadFeedBlogPostList(), + child: BlocBuilder( + builder: (BuildContext context, FeedState state) { + if (state is FeedStateLoaded) { + return ListView.separated( + padding: EdgeInsets.symmetric(vertical: 8), + shrinkWrap: true, + physics: BouncingScrollPhysics(), + itemBuilder: (context, index) { + if (index == state.feedBlogPostList.length) { + return Container( + alignment: Alignment.center, + child: SizedBox( + height: 32, + width: 32, + child: RiveAnimation.asset( + 'assets/rive_animations/loading.riv', + ), + ), + ); + } + return BlogPostWidget(feedBlogPostModel: state.feedBlogPostList[index]); + }, + separatorBuilder: (context, index) { + return SizedBox(height: 8); + }, + itemCount: state.isLoading ? state.feedBlogPostList.length + 1 : state.feedBlogPostList.length, + ); + } else if (state is FeedStateError) { + return Scaffold( + backgroundColor: Colors.grey.shade200, + body: Padding( + padding: const EdgeInsets.all(16), + child: Center( + child: Text(state.errorMessage), + ), ), - ), - ); - } else { - return Scaffold( - backgroundColor: Colors.grey.shade200, - body: Center( - child: CupertinoActivityIndicator(), - ), - ); - } - }, + ); + } else { + return Scaffold( + backgroundColor: Colors.grey.shade200, + body: Center( + child: SizedBox( + height: 32, + width: 32, + child: RiveAnimation.asset( + 'assets/rive_animations/loading.riv', + ), + ), + ), + ); + } + }, + ), ), ); } _buildAllRecipes() { - return RefreshIndicator( - onRefresh: () => context.read().loadRecipesList(), - child: BlocBuilder( - builder: (BuildContext context, RecipesState state) { - if (state is RecipesStateLoaded) { - return ListView.separated( - padding: EdgeInsets.symmetric(vertical: 8), - shrinkWrap: true, - physics: BouncingScrollPhysics(), - itemBuilder: (context, index) { - return RecipesWidget(recipes: state.recipesList[index]); - }, - separatorBuilder: (context, index) { - return SizedBox(height: 8); - }, - itemCount: state.recipesList.length, - ); - } else if (state is RecipesStateError) { - return Scaffold( - backgroundColor: Colors.grey.shade200, - body: Padding( - padding: const EdgeInsets.all(16), - child: Center( - child: Text(state.errorMessage), + return BlocProvider( + create: (context) => recipesCubit, + child: RefreshIndicator( + onRefresh: () => recipesCubit.loadRecipesList(), + child: BlocBuilder( + builder: (BuildContext context, RecipesState state) { + if (state is RecipesStateLoaded) { + return ListView.separated( + padding: EdgeInsets.symmetric(vertical: 8), + shrinkWrap: true, + physics: BouncingScrollPhysics(), + itemBuilder: (context, index) { + return RecipesWidget(recipes: state.recipesList[index]); + }, + separatorBuilder: (context, index) { + return SizedBox(height: 8); + }, + itemCount: state.recipesList.length, + ); + } else if (state is RecipesStateError) { + return Scaffold( + backgroundColor: Colors.grey.shade200, + body: Padding( + padding: const EdgeInsets.all(16), + child: Center( + child: Text(state.errorMessage), + ), ), - ), - ); - } else { - return Scaffold( - backgroundColor: Colors.grey.shade200, - body: Center( - child: CupertinoActivityIndicator(), - ), - ); - } - }, + ); + } else { + return Scaffold( + backgroundColor: Colors.grey.shade200, + body: Center( + child: SizedBox( + height: 32, + width: 32, + child: RiveAnimation.asset( + 'assets/rive_animations/loading.riv', + ), + ), + ), + ); + } + }, + ), + ), + ); + } + + _buildDiets() { + return BlocProvider( + create: (context) => dietsCubit, + child: RefreshIndicator( + onRefresh: () => dietsCubit.loadDiets(), + child: BlocBuilder( + builder: (BuildContext context, DietsState state) { + if (state is DietsStateLoaded) { + return ListView.separated( + padding: EdgeInsets.symmetric(vertical: 8), + shrinkWrap: true, + physics: BouncingScrollPhysics(), + itemBuilder: (context, index) { + return DietsWidget(diet: state.diets.data[index]); + }, + separatorBuilder: (context, index) { + return SizedBox(height: 8); + }, + itemCount: state.diets.data.length, + ); + } else if (state is DietsStateError) { + return Scaffold( + backgroundColor: Colors.grey.shade200, + body: Padding( + padding: const EdgeInsets.all(16), + child: Center( + child: Text(state.errorMessage), + ), + ), + ); + } else { + return Scaffold( + backgroundColor: Colors.grey.shade200, + body: Center( + child: SizedBox( + height: 32, + width: 32, + child: RiveAnimation.asset( + 'assets/rive_animations/loading.riv', + ), + ), + ), + ); + } + }, + ), + ), + ); + } + + _buildPlans() { + return BlocProvider( + create: (context) => plansCubit, + child: RefreshIndicator( + onRefresh: () => plansCubit.loadPlans(), + child: BlocBuilder( + builder: (BuildContext context, PlansState state) { + if (state is PlansStateLoaded) { + return ListView.separated( + padding: EdgeInsets.symmetric(vertical: 8), + shrinkWrap: true, + physics: BouncingScrollPhysics(), + itemBuilder: (context, index) { + return PlanWidget(planModel: state.plansModel.data[index]); + }, + separatorBuilder: (context, index) { + return SizedBox(height: 8); + }, + itemCount: state.plansModel.data.length, + ); + } else if (state is PlansStateError) { + return Scaffold( + backgroundColor: Colors.grey.shade200, + body: Padding( + padding: const EdgeInsets.all(16), + child: Center( + child: Text(state.errorMessage), + ), + ), + ); + } else { + return Scaffold( + backgroundColor: Colors.grey.shade200, + body: Center( + child: SizedBox( + height: 32, + width: 32, + child: RiveAnimation.asset( + 'assets/rive_animations/loading.riv', + ), + ), + ), + ); + } + }, + ), ), ); } @@ -247,9 +411,43 @@ class _FeedScreenState extends State { height: 40, width: MediaQuery.of(context).size.width - 84, child: TextFormField( + controller: searchController, style: TextStyle( fontSize: 12, ), + onChanged: (query) { + if (query.length > 2) { + EasyDebounce.debounce( + 'searchFeed', + Duration(milliseconds: 500), + () { + switch (_selectedChipIndex) { + case 0: + feedCubit.loadFeedBlogPostList(query: query); + break; + case 1: + recipesCubit.loadRecipesList(query: query); + break; + } + }, + ); + } else { + EasyDebounce.debounce( + 'searchFeed', + Duration(milliseconds: 500), + () { + switch (_selectedChipIndex) { + case 0: + feedCubit.loadFeedBlogPostList(); + break; + case 1: + recipesCubit.loadRecipesList(); + break; + } + }, + ); + } + }, decoration: InputDecoration( hintText: 'Поиск', hintStyle: TextStyle( @@ -304,6 +502,8 @@ class _FeedScreenState extends State { onSelected: (bool selected) { setState(() { _selectedChipIndex = index; + searchController.clear(); + FocusScope.of(context).requestFocus(new FocusNode()); }); }, ); diff --git a/lib/features/feed/presentation/widgets/blog_post_widget.dart b/lib/features/feed/presentation/widgets/blog_post_widget.dart index 290560a6..781024cb 100644 --- a/lib/features/feed/presentation/widgets/blog_post_widget.dart +++ b/lib/features/feed/presentation/widgets/blog_post_widget.dart @@ -1,11 +1,15 @@ import 'package:cached_network_image/cached_network_image.dart'; import 'package:dismissible_page/dismissible_page.dart'; -import 'package:eatvio_app/core/app_export.dart'; +import 'package:eatvio_app/core/const.dart'; +import 'package:eatvio_app/core/utils/date_time_utils.dart'; import 'package:eatvio_app/features/chat/presentation/pages/photo_view_screen.dart'; import 'package:eatvio_app/features/feed/models/feed_blog_post_model.dart'; import 'package:eatvio_app/features/feed/presentation/bloc/feed_cubit/feed_cubit.dart'; +import 'package:eatvio_app/theme/theme_helper.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_html/flutter_html.dart'; +import 'package:flutter_svg/flutter_svg.dart'; import 'package:go_router/go_router.dart'; import 'package:share_plus/share_plus.dart'; @@ -62,8 +66,24 @@ class _BlogPostWidgetState extends State { Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Text(widget.feedBlogPostModel.author.authorName), - Text(calculateDifference(widget.feedBlogPostModel.createdAt)), + Text( + widget.feedBlogPostModel.author.authorName, + style: TextStyle( + height: 1, + color: Colors.black87, + fontWeight: FontWeight.w500, + ), + ), + const SizedBox(height: 4), + Text( + calculateDifference( + widget.feedBlogPostModel.createdAt, + ), + style: TextStyle( + height: 1, + color: Colors.black45, + ), + ), ], ), ], @@ -81,18 +101,32 @@ class _BlogPostWidgetState extends State { ), ), if (widget.feedBlogPostModel.title.isNotEmpty && widget.feedBlogPostModel.description.isNotEmpty) SizedBox(height: 8), - Padding( - padding: const EdgeInsets.symmetric(horizontal: 12), - child: Html( - data: widget.feedBlogPostModel.description, + if (widget.feedBlogPostModel.description.isNotEmpty) + Padding( + padding: const EdgeInsets.symmetric(horizontal: 4), + child: Html( + data: widget.feedBlogPostModel.description.length > 200 + ? widget.feedBlogPostModel.description.substring(0, 200) + : widget.feedBlogPostModel.description, + style: { + "*": Style( + color: Colors.black87, + ), + }, + ), + ), + if (widget.feedBlogPostModel.description.length > 200) + Padding( + padding: const EdgeInsets.symmetric(horizontal: 16), + child: Text( + 'Читать полностью...', + style: TextStyle( + height: 1, + color: appTheme.blueA400, + decoration: TextDecoration.underline, + ), + ), ), - // child: Text( - // widget.feedBlogPostModel.description, - // style: TextStyle( - // color: Colors.black87, - // ), - // ), - ), if (widget.feedBlogPostModel.title.isNotEmpty || widget.feedBlogPostModel.description.isNotEmpty) SizedBox(height: 8), GestureDetector( onTap: () { @@ -107,6 +141,8 @@ class _BlogPostWidgetState extends State { child: Hero( tag: baseUrl + '/storage/' + widget.feedBlogPostModel.image, child: CachedNetworkImage( + fit: BoxFit.fitWidth, + width: MediaQuery.of(context).size.width, imageUrl: baseUrl + '/storage/' + widget.feedBlogPostModel.image, errorWidget: (context, str, object) => SizedBox.shrink(), ), @@ -118,7 +154,7 @@ class _BlogPostWidgetState extends State { child: Row( children: [ _iconButton( - icon: Icons.favorite_border_rounded, + icon: isLiked ? Icons.favorite_rounded : Icons.favorite_border_rounded, text: totalLikes.toString(), iconColor: isLiked ? Colors.red.withOpacity(0.8) : null, backgroundColor: isLiked ? Colors.red.withOpacity(0.1) : null, @@ -136,7 +172,15 @@ class _BlogPostWidgetState extends State { ), SizedBox(width: 8), _iconButton( - icon: Icons.mode_comment_outlined, + svgIcon: SvgPicture.asset( + 'assets/icons/comment.svg', + height: 20, + width: 20, + colorFilter: ColorFilter.mode( + appTheme.gray600, + BlendMode.srcIn, + ), + ), text: widget.feedBlogPostModel.totalComments.toString(), onTap: () => GoRouter.of(context).pushNamed( 'blogPostScreen', @@ -145,7 +189,12 @@ class _BlogPostWidgetState extends State { ), SizedBox(width: 8), _iconButton( - icon: Icons.reply_rounded, + svgIcon: SvgPicture.asset( + height: 20, + width: 20, + 'assets/icons/share.svg', + colorFilter: ColorFilter.mode(appTheme.gray600, BlendMode.srcIn), + ), onTap: () => Share.shareUri( Uri.parse( baseUrl + '/ru/blog_post/' + widget.feedBlogPostModel.id.toString(), @@ -177,7 +226,7 @@ class _BlogPostWidgetState extends State { ); } - _iconButton({required IconData icon, String? text, Function()? onTap, Color? iconColor, Color? backgroundColor, Color? textColor}) { + _iconButton({IconData? icon, SvgPicture? svgIcon, String? text, Function()? onTap, Color? iconColor, Color? backgroundColor, Color? textColor}) { return InkWell( onTap: onTap ?? () {}, borderRadius: BorderRadius.circular(16), @@ -191,11 +240,13 @@ class _BlogPostWidgetState extends State { child: Row( mainAxisSize: MainAxisSize.min, children: [ - Icon( - icon, - size: 20, - color: iconColor ?? appTheme.gray600, - ), + if (svgIcon != null) svgIcon, + if (icon != null) + Icon( + icon, + size: 20, + color: iconColor ?? appTheme.gray600, + ), if (text != null) SizedBox(width: 8), if (text != null) Text( diff --git a/lib/features/feed/presentation/widgets/comments_widget.dart b/lib/features/feed/presentation/widgets/comments_widget.dart new file mode 100644 index 00000000..695c5459 --- /dev/null +++ b/lib/features/feed/presentation/widgets/comments_widget.dart @@ -0,0 +1,121 @@ +import 'package:eatvio_app/core/utils/date_time_utils.dart'; +import 'package:eatvio_app/features/feed/models/comment_model.dart'; +import 'package:eatvio_app/features/feed/presentation/bloc/comments_cubit/comments_cubit.dart'; +import 'package:eatvio_app/theme/theme_helper.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; + +enum CommentSourceType { blogPost, recipe, diet } + +class CommentsWidget extends StatefulWidget { + final String id; + final CommentSourceType commentSourceType; + final CommentModel comment; + final int? replyId; + + const CommentsWidget({ + super.key, + required this.id, + required this.commentSourceType, + required this.comment, + this.replyId, + }); + + @override + State createState() => _CommentsWidgetState(); +} + +class _CommentsWidgetState extends State { + @override + Widget build(BuildContext context) { + return Column( + children: [ + for (int i = 0; i < widget.comment.data.length; i++) ...[ + _comment(widget.comment.data[i]), + if (widget.comment.data[i].childrenComments.isNotEmpty) SizedBox(height: 8), + for (int j = 0; j < widget.comment.data[i].childrenComments.length; j++) + Padding( + padding: EdgeInsets.only(left: 40), + child: _comment(widget.comment.data[i].childrenComments[j], 12, true), + ), + SizedBox(height: 8), + ], + ], + ); + } + + _comment(Comment comment, [double radius = 16, bool isChild = false]) { + return Container( + width: MediaQuery.of(context).size.width, + decoration: BoxDecoration( + color: widget.replyId == comment.id ? appTheme.blueA400.withOpacity(0.1) : Colors.white, + borderRadius: BorderRadius.circular(16), + ), + child: Padding( + padding: const EdgeInsets.symmetric(horizontal: 16), + child: Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + CircleAvatar( + foregroundImage: NetworkImage(comment.authorProfileIcon), + radius: radius, + ), + SizedBox(width: 8), + Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Text( + comment.authorName, + style: TextStyle( + height: 1, + color: Colors.grey.shade600, + fontWeight: FontWeight.w500, + ), + ), + SizedBox(width: 4), + Text( + comment.body, + style: TextStyle( + height: 1, + color: Colors.black, + ), + ), + SizedBox(height: 4), + Row( + children: [ + Text( + comment.createdAt.format('dd MMMM', 'ru'), + style: TextStyle( + color: Colors.grey.shade600, + fontSize: 12, + fontWeight: FontWeight.w400, + height: 1, + ), + ), + SizedBox(width: 16), + if (!isChild) + GestureDetector( + onTap: () { + context.read().setReplyId(comment.id); + }, + child: Text( + 'Ответить', + style: TextStyle( + height: 1, + fontSize: 12, + color: Colors.grey.shade800, + fontWeight: FontWeight.w500, + ), + ), + ), + ], + ), + ], + ), + ], + ), + ), + ); + } +} diff --git a/lib/features/feed/presentation/widgets/diets_widget.dart b/lib/features/feed/presentation/widgets/diets_widget.dart index 38f589cf..ce8a9e15 100644 --- a/lib/features/feed/presentation/widgets/diets_widget.dart +++ b/lib/features/feed/presentation/widgets/diets_widget.dart @@ -1,13 +1,15 @@ import 'package:cached_network_image/cached_network_image.dart'; -import 'package:eatvio_app/core/app_export.dart'; +import 'package:eatvio_app/core/const.dart'; import 'package:eatvio_app/features/feed/models/diets_pagination_model.dart'; +import 'package:eatvio_app/theme/theme_helper.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_html/flutter_html.dart'; import 'package:go_router/go_router.dart'; class DietsWidget extends StatefulWidget { - final Datum datum; + final Diet diet; - const DietsWidget({super.key, required this.datum}); + const DietsWidget({super.key, required this.diet}); @override State createState() => _DietsWidgetState(); @@ -18,7 +20,7 @@ class _DietsWidgetState extends State { Widget build(BuildContext context) { return InkWell( borderRadius: BorderRadius.circular(12), - onTap: () => GoRouter.of(context).pushNamed('aboutDietScreen', extra: widget.datum), + onTap: () => GoRouter.of(context).pushNamed('aboutDietScreen', extra: widget.diet), child: Ink( decoration: BoxDecoration( borderRadius: BorderRadius.circular(12), @@ -33,7 +35,9 @@ class _DietsWidgetState extends State { ClipRRect( borderRadius: BorderRadius.vertical(top: Radius.circular(12)), child: CachedNetworkImage( - imageUrl: baseUrl + '/storage/' + widget.datum.image, + imageUrl: baseUrl + '/storage/' + widget.diet.image, + fit: BoxFit.fitWidth, + width: MediaQuery.of(context).size.width, ), ), Positioned( @@ -44,9 +48,9 @@ class _DietsWidgetState extends State { children: [ _iconButton(Icons.fastfood, '139.9 ккал'), SizedBox(width: 8), - _iconButton(Icons.timer_rounded, widget.datum.state), + _iconButton(Icons.timer_rounded, widget.diet.state), SizedBox(width: 8), - _iconButton(Icons.fast_forward_rounded, widget.datum.duration.toString()), + _iconButton(Icons.fast_forward_rounded, widget.diet.duration.toString()), ], ), ), @@ -68,7 +72,7 @@ class _DietsWidgetState extends State { ), SizedBox(width: 4), Text( - widget.datum.totalLikes.toString(), + widget.diet.totalLikes.toString(), style: TextStyle( fontSize: 12, color: Colors.black, @@ -97,7 +101,7 @@ class _DietsWidgetState extends State { ), SizedBox(width: 4), Text( - widget.datum.totalViews.toString(), + widget.diet.totalViews.toString(), style: TextStyle( fontSize: 12, color: Colors.black, @@ -114,23 +118,37 @@ class _DietsWidgetState extends State { Padding( padding: const EdgeInsets.symmetric(horizontal: 12), child: Text( - widget.datum.name, + widget.diet.name, style: TextStyle( fontWeight: FontWeight.w600, color: Colors.black87, ), ), ), - SizedBox(height: 8), - Padding( - padding: const EdgeInsets.symmetric(horizontal: 12), - child: Text( - widget.datum.details, - style: TextStyle( - color: Colors.black87, + if (widget.diet.details.isNotEmpty) + Padding( + padding: const EdgeInsets.symmetric(horizontal: 4), + child: Html( + data: widget.diet.details.length > 200 ? widget.diet.details.substring(0, 200) : widget.diet.details, + style: { + "*": Style( + color: Colors.black87, + ), + }, + ), + ), + if (widget.diet.details.length > 200) + Padding( + padding: const EdgeInsets.symmetric(horizontal: 16), + child: Text( + 'Читать полностью...', + style: TextStyle( + height: 1, + color: appTheme.blueA400, + decoration: TextDecoration.underline, + ), ), ), - ), SizedBox(height: 12), ], ), diff --git a/lib/features/feed/presentation/widgets/plan_widget.dart b/lib/features/feed/presentation/widgets/plan_widget.dart new file mode 100644 index 00000000..0364dbb0 --- /dev/null +++ b/lib/features/feed/presentation/widgets/plan_widget.dart @@ -0,0 +1,173 @@ +import 'package:cached_network_image/cached_network_image.dart'; +import 'package:eatvio_app/core/const.dart'; +import 'package:eatvio_app/features/plans/models/plan_pagination_model.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_html/flutter_html.dart'; +import 'package:go_router/go_router.dart'; + +class PlanWidget extends StatelessWidget { + final PlanModel planModel; + + const PlanWidget({ + super.key, + required this.planModel, + }); + + @override + Widget build(BuildContext context) { + return InkWell( + borderRadius: BorderRadius.circular(12), + onTap: () => GoRouter.of(context).pushNamed( + 'aboutPlanScreen', + extra: planModel, + ), + child: Ink( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(12), + color: Colors.white, + ), + child: Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Stack( + children: [ + ClipRRect( + borderRadius: BorderRadius.vertical(top: Radius.circular(12)), + child: CachedNetworkImage( + imageUrl: baseUrl + '/storage/' + planModel.image, + fit: BoxFit.fitWidth, + width: MediaQuery.of(context).size.width, + ), + ), + Positioned( + left: 8, + bottom: 8, + child: Wrap( + runSpacing: 8, + children: [ + _iconButton(Icons.timelapse_rounded, '${planModel.duration} дней'), + SizedBox(width: 8), + ], + ), + ), + Positioned( + left: 8, + top: 8, + child: Container( + padding: EdgeInsets.symmetric(horizontal: 8, vertical: 4), + decoration: BoxDecoration( + color: Colors.white.withOpacity(0.8), + borderRadius: BorderRadius.circular(16), + ), + child: Row( + children: [ + Icon( + Icons.favorite_rounded, + size: 16, + color: Colors.black, + ), + SizedBox(width: 4), + Text( + '0', + style: TextStyle( + fontSize: 12, + color: Colors.black, + fontWeight: FontWeight.w400, + ), + ), + ], + ), + ), + ), + Positioned( + right: 8, + top: 8, + child: Container( + padding: EdgeInsets.symmetric(horizontal: 8, vertical: 4), + decoration: BoxDecoration( + color: Colors.white.withOpacity(0.8), + borderRadius: BorderRadius.circular(16), + ), + child: Row( + children: [ + Icon( + Icons.visibility_rounded, + size: 16, + color: Colors.black, + ), + SizedBox(width: 4), + Text( + '0', + style: TextStyle( + fontSize: 12, + color: Colors.black, + fontWeight: FontWeight.w400, + ), + ), + ], + ), + ), + ), + ], + ), + SizedBox(height: 12), + Padding( + padding: const EdgeInsets.symmetric(horizontal: 12), + child: Text( + planModel.name, + style: TextStyle( + fontWeight: FontWeight.w600, + color: Colors.black87, + ), + ), + ), + Padding( + padding: const EdgeInsets.symmetric(horizontal: 4), + child: Html( + data: planModel.details, + style: { + "*": Style( + color: Colors.black87, + ), + }, + ), + ), + SizedBox(height: 12), + ], + ), + ), + ); + } + + _iconButton(IconData icon, [String? text]) { + return Container( + padding: EdgeInsets.symmetric(horizontal: 12, vertical: 4), + decoration: BoxDecoration( + color: Colors.white.withOpacity(0.8), + borderRadius: BorderRadius.circular(16), + ), + height: 32, + child: Row( + mainAxisSize: MainAxisSize.min, + children: [ + Icon( + icon, + size: 16, + color: Colors.black, + ), + if (text != null) SizedBox(width: 8), + if (text != null) + Text( + text, + style: TextStyle( + fontSize: 12, + color: Colors.black, + fontWeight: FontWeight.w500, + ), + ), + ], + ), + ); + } +} diff --git a/lib/features/feed/presentation/widgets/recipes_widget.dart b/lib/features/feed/presentation/widgets/recipes_widget.dart index c341c5a4..348ac841 100644 --- a/lib/features/feed/presentation/widgets/recipes_widget.dart +++ b/lib/features/feed/presentation/widgets/recipes_widget.dart @@ -1,7 +1,9 @@ import 'package:cached_network_image/cached_network_image.dart'; -import 'package:eatvio_app/core/app_export.dart'; +import 'package:eatvio_app/core/const.dart'; import 'package:eatvio_app/features/feed/models/recipes_model.dart'; +import 'package:eatvio_app/theme/theme_helper.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_html/flutter_html.dart'; import 'package:go_router/go_router.dart'; class RecipesWidget extends StatefulWidget { @@ -34,6 +36,8 @@ class _RecipesWidgetState extends State { borderRadius: BorderRadius.vertical(top: Radius.circular(12)), child: CachedNetworkImage( imageUrl: baseUrl + '/storage/' + widget.recipes.image, + fit: BoxFit.fitWidth, + width: MediaQuery.of(context).size.width, ), ), Positioned( @@ -121,16 +125,30 @@ class _RecipesWidgetState extends State { ), ), ), - SizedBox(height: 8), - Padding( - padding: const EdgeInsets.symmetric(horizontal: 12), - child: Text( - widget.recipes.description, - style: TextStyle( - color: Colors.black87, + if (widget.recipes.description.isNotEmpty) + Padding( + padding: const EdgeInsets.symmetric(horizontal: 4), + child: Html( + data: widget.recipes.description.length > 200 ? widget.recipes.description.substring(0, 200) : widget.recipes.description, + style: { + "*": Style( + color: Colors.black87, + ), + }, + ), + ), + if (widget.recipes.description.length > 200) + Padding( + padding: const EdgeInsets.symmetric(horizontal: 16), + child: Text( + 'Читать полностью...', + style: TextStyle( + height: 1, + color: appTheme.blueA400, + decoration: TextDecoration.underline, + ), ), ), - ), SizedBox(height: 12), ], ), diff --git a/lib/features/feed/presentation/widgets/tags_modal_widget.dart b/lib/features/feed/presentation/widgets/tags_modal_widget.dart new file mode 100644 index 00000000..21618511 --- /dev/null +++ b/lib/features/feed/presentation/widgets/tags_modal_widget.dart @@ -0,0 +1,75 @@ +import 'package:eatvio_app/features/feed/presentation/bloc/recipes_cubit/recipes_cubit.dart'; +import 'package:eatvio_app/features/feed/presentation/bloc/recipes_cubit/recipes_state.dart'; +import 'package:eatvio_app/features/recipes/models/recipe_tag_model.dart'; +import 'package:eatvio_app/theme/theme_helper.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; + +class TagsModalWidget extends StatefulWidget { + final RecipesCubit recipesCubit; + + const TagsModalWidget({ + super.key, + required this.recipesCubit, + }); + + @override + State createState() => _TagsModalWidgetState(); +} + +class _TagsModalWidgetState extends State { + @override + Widget build(BuildContext context) { + return BlocBuilder( + bloc: widget.recipesCubit, + builder: (BuildContext context, RecipesState state) { + if (state is RecipesStateLoaded) { + return Container( + padding: EdgeInsets.all(16), + width: MediaQuery.of(context).size.width, + child: Wrap( + spacing: 8, + runSpacing: -8, + children: [ + for (int i = 0; i < state.recipesTags.length; i++) + _tagChip( + tag: state.recipesTags[i], + isSelected: state.selectedTags.contains(state.recipesTags[i].id), + ), + ], + ), + ); + } else { + return Container(); + } + }, + ); + } + + _tagChip({ + required RecipeTag tag, + required bool isSelected, + }) { + return ChoiceChip( + selectedColor: appTheme.blueA400, + pressElevation: 0, + showCheckmark: false, + side: BorderSide.none, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(16), + ), + padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4), + labelStyle: TextStyle( + color: isSelected ? Colors.white : appTheme.gray600, + fontWeight: FontWeight.w500, + fontSize: 12, + ), + selected: isSelected, + backgroundColor: appTheme.gray100, + onSelected: (bool selected) => widget.recipesCubit.updateTags(tag), + label: Text( + '${tag.name} ${tag.recipesCount}', + ), + ); + } +} diff --git a/lib/features/feed/repositories/feed_repository.dart b/lib/features/feed/repositories/feed_repository.dart index 78cc2106..459923fc 100644 --- a/lib/features/feed/repositories/feed_repository.dart +++ b/lib/features/feed/repositories/feed_repository.dart @@ -7,33 +7,58 @@ import 'package:eatvio_app/features/feed/services/feed_service.dart'; class FeedRepository { final FeedService feedService; - FeedRepository({required this.feedService}); + FeedRepository({ + required this.feedService, + }); - Future getFeedBlogPosts({int page = 1}) async { + Future getFeedBlogPosts({ + String? query, + int page = 1, + }) async { try { - return (await feedService.getBlocPostList(page: page)); + return (await feedService.getBlogPostList( + page: page, + query: query, + )); } catch (e) { rethrow; } } - Future> getRecipes() async { + Future> getRecipes({ + String? query, + List? tags, + int page = 1, + }) async { try { - return (await feedService.getRecipes()).recipesList; + return (await feedService.getRecipes( + query: query, + tags: tags, + page: page, + )) + .recipesList; } catch (e) { rethrow; } } - Future getDiets() async { + Future getDiets({ + int page = 1, + String? query, + }) async { try { - return (await feedService.getDiets()); + return (await feedService.getDiets( + page: page, + query: query, + )); } catch (e) { rethrow; } } - Future getBlogPostComments(int id) async { + Future getBlogPostComments({ + required String id, + }) async { try { return (await feedService.getBlogPostComments(id: id)); } catch (e) { @@ -42,7 +67,7 @@ class FeedRepository { } Future sendBlogPostComment({ - required int id, + required String id, required String commentText, int? parentCommentId, }) async { @@ -57,7 +82,9 @@ class FeedRepository { } } - Future getDietsComments(int id) async { + Future getDietsComments({ + required String id, + }) async { try { return (await feedService.getDietsComments(id: id)); } catch (e) { @@ -66,7 +93,7 @@ class FeedRepository { } Future sendDietsComment({ - required int id, + required String id, required String commentText, int? parentCommentId, }) async { @@ -81,7 +108,9 @@ class FeedRepository { } } - Future getRecipesComments(String id) async { + Future getRecipesComments({ + required String id, + }) async { try { return (await feedService.getRecipesComments(id: id)); } catch (e) { @@ -105,7 +134,9 @@ class FeedRepository { } } - Future likeBlogPost(int id) async { + Future likeBlogPost({ + required int id, + }) async { try { await feedService.likeBlogPost(id: id); } catch (e) { @@ -113,7 +144,9 @@ class FeedRepository { } } - Future unlikedBlogPost(int id) async { + Future unlikedBlogPost({ + required int id, + }) async { try { await feedService.unlikedBlogPost(id: id); } catch (e) { diff --git a/lib/features/feed/services/feed_service.dart b/lib/features/feed/services/feed_service.dart index 44f5e33f..9d0cd1bd 100644 --- a/lib/features/feed/services/feed_service.dart +++ b/lib/features/feed/services/feed_service.dart @@ -11,43 +11,51 @@ part 'feed_service.g.dart'; abstract class FeedService { factory FeedService(Dio dio, {String baseUrl}) = _FeedService; - @GET('/api/blogPosts/index?page={page}') - Future getBlocPostList({ + @GET('/api/blogPosts/index') + Future getBlogPostList({ @Path() required int page, + @Query('query_search') String? query, }); @GET('/api/recipes/index') - Future getRecipes(); + Future getRecipes({ + @Path() required int page, + @Query('filters[tags][tags.id][\$in][]') required List? tags, + @Query('filters[title][\$contains]') required String? query, + }); @GET('/api/diets/index') - Future getDiets(); + Future getDiets({ + @Path() required int page, + @Query('query_search') String? query, + }); @GET('/api/blogPosts/{id}/comments/show') - Future getBlogPostComments({ - @Path() required int id, + Future getBlogPostComments({ + @Path() required String id, }); @POST('/api/blogPosts/{id}/comment/create') Future sendBlogPostComment({ - @Path() required int id, + @Path() required String id, @Part() required String body, @Part() int? parentCommentId, }); @GET('/api/diets/{id}/comments/show') - Future getDietsComments({ - @Path() required int id, + Future getDietsComments({ + @Path() required String id, }); @POST('/api/diets/{id}/comment/create') Future sendDietsComment({ - @Path() required int id, + @Path() required String id, @Part() required String body, @Part() int? parentCommentId, }); @GET('/api/recipes/{id}/comments/show') - Future getRecipesComments({ + Future getRecipesComments({ @Path() required String id, }); diff --git a/lib/features/feed/services/feed_service.g.dart b/lib/features/feed/services/feed_service.g.dart index 6ae8ffef..d074b0a2 100644 --- a/lib/features/feed/services/feed_service.g.dart +++ b/lib/features/feed/services/feed_service.g.dart @@ -22,9 +22,13 @@ class _FeedService implements FeedService { final ParseErrorLogger? errorLogger; @override - Future getBlocPostList({required int page}) async { + Future getBlogPostList({ + required int page, + String? query, + }) async { final _extra = {}; - final queryParameters = {}; + final queryParameters = {r'query_search': query}; + queryParameters.removeWhere((k, v) => v == null); final _headers = {}; const Map? _data = null; final _options = _setStreamType(Options( @@ -34,7 +38,7 @@ class _FeedService implements FeedService { ) .compose( _dio.options, - '/api/blogPosts/index?page=${page}', + '/api/blogPosts/index', queryParameters: queryParameters, data: _data, ) @@ -55,9 +59,17 @@ class _FeedService implements FeedService { } @override - Future getRecipes() async { + Future getRecipes({ + required int page, + List? tags, + String? query, + }) async { final _extra = {}; - final queryParameters = {}; + final queryParameters = { + r'filters[tags][tags.id][$in][]': tags, + r'filters[title][$contains]': query, + }; + queryParameters.removeWhere((k, v) => v == null); final _headers = {}; const Map? _data = null; final _options = _setStreamType(Options( @@ -88,9 +100,13 @@ class _FeedService implements FeedService { } @override - Future getDiets() async { + Future getDiets({ + required int page, + String? query, + }) async { final _extra = {}; - final queryParameters = {}; + final queryParameters = {r'query_search': query}; + queryParameters.removeWhere((k, v) => v == null); final _headers = {}; const Map? _data = null; final _options = _setStreamType(Options( @@ -121,12 +137,12 @@ class _FeedService implements FeedService { } @override - Future getBlogPostComments({required int id}) async { + Future getBlogPostComments({required String id}) 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, @@ -143,9 +159,9 @@ class _FeedService implements FeedService { baseUrl, ))); final _result = await _dio.fetch>(_options); - late Comment _value; + late CommentModel _value; try { - _value = Comment.fromJson(_result.data!); + _value = CommentModel.fromJson(_result.data!); } on Object catch (e, s) { errorLogger?.logError(e, s, _options); rethrow; @@ -155,7 +171,7 @@ class _FeedService implements FeedService { @override Future sendBlogPostComment({ - required int id, + required String id, required String body, int? parentCommentId, }) async { @@ -194,12 +210,12 @@ class _FeedService implements FeedService { } @override - Future getDietsComments({required int id}) async { + Future getDietsComments({required String id}) 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, @@ -216,9 +232,9 @@ class _FeedService implements FeedService { baseUrl, ))); final _result = await _dio.fetch>(_options); - late Comment _value; + late CommentModel _value; try { - _value = Comment.fromJson(_result.data!); + _value = CommentModel.fromJson(_result.data!); } on Object catch (e, s) { errorLogger?.logError(e, s, _options); rethrow; @@ -228,7 +244,7 @@ class _FeedService implements FeedService { @override Future sendDietsComment({ - required int id, + required String id, required String body, int? parentCommentId, }) async { @@ -267,12 +283,12 @@ class _FeedService implements FeedService { } @override - Future getRecipesComments({required String id}) async { + Future getRecipesComments({required String id}) 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, @@ -289,9 +305,9 @@ class _FeedService implements FeedService { baseUrl, ))); final _result = await _dio.fetch>(_options); - late Comment _value; + late CommentModel _value; try { - _value = Comment.fromJson(_result.data!); + _value = CommentModel.fromJson(_result.data!); } on Object catch (e, s) { errorLogger?.logError(e, s, _options); rethrow; diff --git a/lib/features/menu/presentation/pages/menu_screen.dart b/lib/features/menu/presentation/pages/menu_screen.dart index 010bf6d3..1ed46aec 100644 --- a/lib/features/menu/presentation/pages/menu_screen.dart +++ b/lib/features/menu/presentation/pages/menu_screen.dart @@ -1,8 +1,9 @@ import 'package:dio/dio.dart'; -import 'package:eatvio_app/core/constants/constants.dart'; +import 'package:eatvio_app/core/const.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:eatvio_app/theme/theme_helper.dart'; import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:go_router/go_router.dart'; @@ -14,6 +15,7 @@ class MenuScreen extends StatelessWidget { Widget build(BuildContext context) { return Scaffold( appBar: AppBar( + centerTitle: false, title: Text('Меню'), ), body: SingleChildScrollView( @@ -22,7 +24,7 @@ class MenuScreen extends StatelessWidget { _tile( title: 'Настройки профиля', leading: ImageConstant.icnProfileSettings, - onTap: () => GoRouter.of(context).push('/my-settings-screen'), + onTap: () => GoRouter.of(context).push('/settings-screen'), ), _divider(context), _tile( @@ -83,6 +85,7 @@ class MenuScreen extends StatelessWidget { leading, height: 24, width: 24, + colorFilter: ColorFilter.mode(appTheme.blueA400, BlendMode.srcIn), ), title: Text(title), trailing: Icon( diff --git a/lib/features/notifications/presentation/pages/notifications_screen.dart b/lib/features/notifications/presentation/pages/notifications_screen.dart index 10947cbf..69058bf0 100644 --- a/lib/features/notifications/presentation/pages/notifications_screen.dart +++ b/lib/features/notifications/presentation/pages/notifications_screen.dart @@ -1,7 +1,7 @@ -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'; +import 'package:flutter_bloc/flutter_bloc.dart'; class NotificationsScreen extends StatelessWidget { const NotificationsScreen({super.key}); diff --git a/lib/features/plans/models/plan_pagination_model.dart b/lib/features/plans/models/plan_pagination_model.dart new file mode 100644 index 00000000..637961e3 --- /dev/null +++ b/lib/features/plans/models/plan_pagination_model.dart @@ -0,0 +1,65 @@ +import 'package:eatvio_app/core/models/pagination_model.dart'; +import 'package:eatvio_app/features/feed/models/diets_pagination_model.dart'; +import 'package:freezed_annotation/freezed_annotation.dart'; + +part 'plan_pagination_model.freezed.dart'; + +part 'plan_pagination_model.g.dart'; + +@freezed +class PlanPaginationModel with _$PlanPaginationModel { + const factory PlanPaginationModel({ + @JsonKey(name: "data") required List data, + @JsonKey(name: "links") required Links links, + @JsonKey(name: "meta") required Meta meta, + }) = _PlanPaginationModel; + + factory PlanPaginationModel.fromJson(Map json) => _$PlanPaginationModelFromJson(json); +} + +@freezed +class PlanModel with _$PlanModel { + const factory PlanModel({ + @JsonKey(name: "id") required int id, + @JsonKey(name: "name") required String name, + @JsonKey(name: "image") required String image, + @JsonKey(name: "duration") required int duration, + @JsonKey(name: "state") required String state, + @JsonKey(name: "type") required PlanType type, + @JsonKey(name: "details") required String details, + @JsonKey(name: "packets_count") required int packetsCount, + @JsonKey(name: "packet1_options") dynamic packet1Options, + @JsonKey(name: "packet2_options") dynamic packet2Options, + @JsonKey(name: "packet3_options") dynamic packet3Options, + @JsonKey(name: "author") required Author author, + @JsonKey(name: "total_likes") required int totalLikes, + @JsonKey(name: "total_views") required int totalViews, + @JsonKey(name: "total_comments") required int totalComments, + }) = _PlanModel; + + factory PlanModel.fromJson(Map json) => _$PlanModelFromJson(json); +} + +@freezed +class PacketOptions with _$PacketOptions { + const factory PacketOptions({ + @JsonKey(name: "items") required List items, + @JsonKey(name: "price") required dynamic price, + @JsonKey(name: "short") required String short, + @JsonKey(name: "description") required String description, + }) = _PacketOptions; + + factory PacketOptions.fromJson(Map json) => _$PacketOptionsFromJson(json); +} + +@freezed +class PlanType with _$PlanType { + const factory PlanType({ + @JsonKey(name: "fit") required bool fit, + @JsonKey(name: "slim") required bool slim, + @JsonKey(name: "behavior") required bool behavior, + @JsonKey(name: "wellness") required bool wellness, + }) = _PlanType; + + factory PlanType.fromJson(Map json) => _$PlanTypeFromJson(json); +} diff --git a/lib/features/plans/models/plan_pagination_model.freezed.dart b/lib/features/plans/models/plan_pagination_model.freezed.dart new file mode 100644 index 00000000..caa2ef10 --- /dev/null +++ b/lib/features/plans/models/plan_pagination_model.freezed.dart @@ -0,0 +1,1251 @@ +// 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 'plan_pagination_model.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'); + +PlanPaginationModel _$PlanPaginationModelFromJson(Map json) { + return _PlanPaginationModel.fromJson(json); +} + +/// @nodoc +mixin _$PlanPaginationModel { + @JsonKey(name: "data") + List get data => throw _privateConstructorUsedError; + @JsonKey(name: "links") + Links get links => throw _privateConstructorUsedError; + @JsonKey(name: "meta") + Meta get meta => throw _privateConstructorUsedError; + + /// Serializes this PlanPaginationModel to a JSON map. + Map toJson() => throw _privateConstructorUsedError; + + /// Create a copy of PlanPaginationModel + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $PlanPaginationModelCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $PlanPaginationModelCopyWith<$Res> { + factory $PlanPaginationModelCopyWith( + PlanPaginationModel value, $Res Function(PlanPaginationModel) then) = + _$PlanPaginationModelCopyWithImpl<$Res, PlanPaginationModel>; + @useResult + $Res call( + {@JsonKey(name: "data") List data, + @JsonKey(name: "links") Links links, + @JsonKey(name: "meta") Meta meta}); + + $LinksCopyWith<$Res> get links; + $MetaCopyWith<$Res> get meta; +} + +/// @nodoc +class _$PlanPaginationModelCopyWithImpl<$Res, $Val extends PlanPaginationModel> + implements $PlanPaginationModelCopyWith<$Res> { + _$PlanPaginationModelCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of PlanPaginationModel + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? data = null, + Object? links = null, + Object? meta = null, + }) { + return _then(_value.copyWith( + data: null == data + ? _value.data + : data // ignore: cast_nullable_to_non_nullable + as List, + links: null == links + ? _value.links + : links // ignore: cast_nullable_to_non_nullable + as Links, + meta: null == meta + ? _value.meta + : meta // ignore: cast_nullable_to_non_nullable + as Meta, + ) as $Val); + } + + /// Create a copy of PlanPaginationModel + /// with the given fields replaced by the non-null parameter values. + @override + @pragma('vm:prefer-inline') + $LinksCopyWith<$Res> get links { + return $LinksCopyWith<$Res>(_value.links, (value) { + return _then(_value.copyWith(links: value) as $Val); + }); + } + + /// Create a copy of PlanPaginationModel + /// with the given fields replaced by the non-null parameter values. + @override + @pragma('vm:prefer-inline') + $MetaCopyWith<$Res> get meta { + return $MetaCopyWith<$Res>(_value.meta, (value) { + return _then(_value.copyWith(meta: value) as $Val); + }); + } +} + +/// @nodoc +abstract class _$$PlanPaginationModelImplCopyWith<$Res> + implements $PlanPaginationModelCopyWith<$Res> { + factory _$$PlanPaginationModelImplCopyWith(_$PlanPaginationModelImpl value, + $Res Function(_$PlanPaginationModelImpl) then) = + __$$PlanPaginationModelImplCopyWithImpl<$Res>; + @override + @useResult + $Res call( + {@JsonKey(name: "data") List data, + @JsonKey(name: "links") Links links, + @JsonKey(name: "meta") Meta meta}); + + @override + $LinksCopyWith<$Res> get links; + @override + $MetaCopyWith<$Res> get meta; +} + +/// @nodoc +class __$$PlanPaginationModelImplCopyWithImpl<$Res> + extends _$PlanPaginationModelCopyWithImpl<$Res, _$PlanPaginationModelImpl> + implements _$$PlanPaginationModelImplCopyWith<$Res> { + __$$PlanPaginationModelImplCopyWithImpl(_$PlanPaginationModelImpl _value, + $Res Function(_$PlanPaginationModelImpl) _then) + : super(_value, _then); + + /// Create a copy of PlanPaginationModel + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? data = null, + Object? links = null, + Object? meta = null, + }) { + return _then(_$PlanPaginationModelImpl( + data: null == data + ? _value._data + : data // ignore: cast_nullable_to_non_nullable + as List, + links: null == links + ? _value.links + : links // ignore: cast_nullable_to_non_nullable + as Links, + meta: null == meta + ? _value.meta + : meta // ignore: cast_nullable_to_non_nullable + as Meta, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$PlanPaginationModelImpl implements _PlanPaginationModel { + const _$PlanPaginationModelImpl( + {@JsonKey(name: "data") required final List data, + @JsonKey(name: "links") required this.links, + @JsonKey(name: "meta") required this.meta}) + : _data = data; + + factory _$PlanPaginationModelImpl.fromJson(Map json) => + _$$PlanPaginationModelImplFromJson(json); + + final List _data; + @override + @JsonKey(name: "data") + List get data { + if (_data is EqualUnmodifiableListView) return _data; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(_data); + } + + @override + @JsonKey(name: "links") + final Links links; + @override + @JsonKey(name: "meta") + final Meta meta; + + @override + String toString() { + return 'PlanPaginationModel(data: $data, links: $links, meta: $meta)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$PlanPaginationModelImpl && + const DeepCollectionEquality().equals(other._data, _data) && + (identical(other.links, links) || other.links == links) && + (identical(other.meta, meta) || other.meta == meta)); + } + + @JsonKey(includeFromJson: false, includeToJson: false) + @override + int get hashCode => Object.hash( + runtimeType, const DeepCollectionEquality().hash(_data), links, meta); + + /// Create a copy of PlanPaginationModel + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$PlanPaginationModelImplCopyWith<_$PlanPaginationModelImpl> get copyWith => + __$$PlanPaginationModelImplCopyWithImpl<_$PlanPaginationModelImpl>( + this, _$identity); + + @override + Map toJson() { + return _$$PlanPaginationModelImplToJson( + this, + ); + } +} + +abstract class _PlanPaginationModel implements PlanPaginationModel { + const factory _PlanPaginationModel( + {@JsonKey(name: "data") required final List data, + @JsonKey(name: "links") required final Links links, + @JsonKey(name: "meta") required final Meta meta}) = + _$PlanPaginationModelImpl; + + factory _PlanPaginationModel.fromJson(Map json) = + _$PlanPaginationModelImpl.fromJson; + + @override + @JsonKey(name: "data") + List get data; + @override + @JsonKey(name: "links") + Links get links; + @override + @JsonKey(name: "meta") + Meta get meta; + + /// Create a copy of PlanPaginationModel + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + _$$PlanPaginationModelImplCopyWith<_$PlanPaginationModelImpl> get copyWith => + throw _privateConstructorUsedError; +} + +PlanModel _$PlanModelFromJson(Map json) { + return _PlanModel.fromJson(json); +} + +/// @nodoc +mixin _$PlanModel { + @JsonKey(name: "id") + int get id => throw _privateConstructorUsedError; + @JsonKey(name: "name") + String get name => throw _privateConstructorUsedError; + @JsonKey(name: "image") + String get image => throw _privateConstructorUsedError; + @JsonKey(name: "duration") + int get duration => throw _privateConstructorUsedError; + @JsonKey(name: "state") + String get state => throw _privateConstructorUsedError; + @JsonKey(name: "type") + PlanType get type => throw _privateConstructorUsedError; + @JsonKey(name: "details") + String get details => throw _privateConstructorUsedError; + @JsonKey(name: "packets_count") + int get packetsCount => throw _privateConstructorUsedError; + @JsonKey(name: "packet1_options") + dynamic get packet1Options => throw _privateConstructorUsedError; + @JsonKey(name: "packet2_options") + dynamic get packet2Options => throw _privateConstructorUsedError; + @JsonKey(name: "packet3_options") + dynamic get packet3Options => throw _privateConstructorUsedError; + @JsonKey(name: "author") + Author get author => throw _privateConstructorUsedError; + @JsonKey(name: "total_likes") + int get totalLikes => throw _privateConstructorUsedError; + @JsonKey(name: "total_views") + int get totalViews => throw _privateConstructorUsedError; + @JsonKey(name: "total_comments") + int get totalComments => throw _privateConstructorUsedError; + + /// Serializes this PlanModel to a JSON map. + Map toJson() => throw _privateConstructorUsedError; + + /// Create a copy of PlanModel + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $PlanModelCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $PlanModelCopyWith<$Res> { + factory $PlanModelCopyWith(PlanModel value, $Res Function(PlanModel) then) = + _$PlanModelCopyWithImpl<$Res, PlanModel>; + @useResult + $Res call( + {@JsonKey(name: "id") int id, + @JsonKey(name: "name") String name, + @JsonKey(name: "image") String image, + @JsonKey(name: "duration") int duration, + @JsonKey(name: "state") String state, + @JsonKey(name: "type") PlanType type, + @JsonKey(name: "details") String details, + @JsonKey(name: "packets_count") int packetsCount, + @JsonKey(name: "packet1_options") dynamic packet1Options, + @JsonKey(name: "packet2_options") dynamic packet2Options, + @JsonKey(name: "packet3_options") dynamic packet3Options, + @JsonKey(name: "author") Author author, + @JsonKey(name: "total_likes") int totalLikes, + @JsonKey(name: "total_views") int totalViews, + @JsonKey(name: "total_comments") int totalComments}); + + $PlanTypeCopyWith<$Res> get type; + $AuthorCopyWith<$Res> get author; +} + +/// @nodoc +class _$PlanModelCopyWithImpl<$Res, $Val extends PlanModel> + implements $PlanModelCopyWith<$Res> { + _$PlanModelCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of PlanModel + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? id = null, + Object? name = null, + Object? image = null, + Object? duration = null, + Object? state = null, + Object? type = null, + Object? details = null, + Object? packetsCount = null, + Object? packet1Options = freezed, + Object? packet2Options = freezed, + Object? packet3Options = freezed, + Object? author = null, + Object? totalLikes = null, + Object? totalViews = null, + Object? totalComments = null, + }) { + return _then(_value.copyWith( + id: null == id + ? _value.id + : id // ignore: cast_nullable_to_non_nullable + as int, + name: null == name + ? _value.name + : name // ignore: cast_nullable_to_non_nullable + as String, + image: null == image + ? _value.image + : image // ignore: cast_nullable_to_non_nullable + as String, + duration: null == duration + ? _value.duration + : duration // ignore: cast_nullable_to_non_nullable + as int, + state: null == state + ? _value.state + : state // ignore: cast_nullable_to_non_nullable + as String, + type: null == type + ? _value.type + : type // ignore: cast_nullable_to_non_nullable + as PlanType, + details: null == details + ? _value.details + : details // ignore: cast_nullable_to_non_nullable + as String, + packetsCount: null == packetsCount + ? _value.packetsCount + : packetsCount // ignore: cast_nullable_to_non_nullable + as int, + packet1Options: freezed == packet1Options + ? _value.packet1Options + : packet1Options // ignore: cast_nullable_to_non_nullable + as dynamic, + packet2Options: freezed == packet2Options + ? _value.packet2Options + : packet2Options // ignore: cast_nullable_to_non_nullable + as dynamic, + packet3Options: freezed == packet3Options + ? _value.packet3Options + : packet3Options // ignore: cast_nullable_to_non_nullable + as dynamic, + author: null == author + ? _value.author + : author // ignore: cast_nullable_to_non_nullable + as Author, + totalLikes: null == totalLikes + ? _value.totalLikes + : totalLikes // ignore: cast_nullable_to_non_nullable + as int, + totalViews: null == totalViews + ? _value.totalViews + : totalViews // ignore: cast_nullable_to_non_nullable + as int, + totalComments: null == totalComments + ? _value.totalComments + : totalComments // ignore: cast_nullable_to_non_nullable + as int, + ) as $Val); + } + + /// Create a copy of PlanModel + /// with the given fields replaced by the non-null parameter values. + @override + @pragma('vm:prefer-inline') + $PlanTypeCopyWith<$Res> get type { + return $PlanTypeCopyWith<$Res>(_value.type, (value) { + return _then(_value.copyWith(type: value) as $Val); + }); + } + + /// Create a copy of PlanModel + /// with the given fields replaced by the non-null parameter values. + @override + @pragma('vm:prefer-inline') + $AuthorCopyWith<$Res> get author { + return $AuthorCopyWith<$Res>(_value.author, (value) { + return _then(_value.copyWith(author: value) as $Val); + }); + } +} + +/// @nodoc +abstract class _$$PlanModelImplCopyWith<$Res> + implements $PlanModelCopyWith<$Res> { + factory _$$PlanModelImplCopyWith( + _$PlanModelImpl value, $Res Function(_$PlanModelImpl) then) = + __$$PlanModelImplCopyWithImpl<$Res>; + @override + @useResult + $Res call( + {@JsonKey(name: "id") int id, + @JsonKey(name: "name") String name, + @JsonKey(name: "image") String image, + @JsonKey(name: "duration") int duration, + @JsonKey(name: "state") String state, + @JsonKey(name: "type") PlanType type, + @JsonKey(name: "details") String details, + @JsonKey(name: "packets_count") int packetsCount, + @JsonKey(name: "packet1_options") dynamic packet1Options, + @JsonKey(name: "packet2_options") dynamic packet2Options, + @JsonKey(name: "packet3_options") dynamic packet3Options, + @JsonKey(name: "author") Author author, + @JsonKey(name: "total_likes") int totalLikes, + @JsonKey(name: "total_views") int totalViews, + @JsonKey(name: "total_comments") int totalComments}); + + @override + $PlanTypeCopyWith<$Res> get type; + @override + $AuthorCopyWith<$Res> get author; +} + +/// @nodoc +class __$$PlanModelImplCopyWithImpl<$Res> + extends _$PlanModelCopyWithImpl<$Res, _$PlanModelImpl> + implements _$$PlanModelImplCopyWith<$Res> { + __$$PlanModelImplCopyWithImpl( + _$PlanModelImpl _value, $Res Function(_$PlanModelImpl) _then) + : super(_value, _then); + + /// Create a copy of PlanModel + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? id = null, + Object? name = null, + Object? image = null, + Object? duration = null, + Object? state = null, + Object? type = null, + Object? details = null, + Object? packetsCount = null, + Object? packet1Options = freezed, + Object? packet2Options = freezed, + Object? packet3Options = freezed, + Object? author = null, + Object? totalLikes = null, + Object? totalViews = null, + Object? totalComments = null, + }) { + return _then(_$PlanModelImpl( + id: null == id + ? _value.id + : id // ignore: cast_nullable_to_non_nullable + as int, + name: null == name + ? _value.name + : name // ignore: cast_nullable_to_non_nullable + as String, + image: null == image + ? _value.image + : image // ignore: cast_nullable_to_non_nullable + as String, + duration: null == duration + ? _value.duration + : duration // ignore: cast_nullable_to_non_nullable + as int, + state: null == state + ? _value.state + : state // ignore: cast_nullable_to_non_nullable + as String, + type: null == type + ? _value.type + : type // ignore: cast_nullable_to_non_nullable + as PlanType, + details: null == details + ? _value.details + : details // ignore: cast_nullable_to_non_nullable + as String, + packetsCount: null == packetsCount + ? _value.packetsCount + : packetsCount // ignore: cast_nullable_to_non_nullable + as int, + packet1Options: freezed == packet1Options + ? _value.packet1Options + : packet1Options // ignore: cast_nullable_to_non_nullable + as dynamic, + packet2Options: freezed == packet2Options + ? _value.packet2Options + : packet2Options // ignore: cast_nullable_to_non_nullable + as dynamic, + packet3Options: freezed == packet3Options + ? _value.packet3Options + : packet3Options // ignore: cast_nullable_to_non_nullable + as dynamic, + author: null == author + ? _value.author + : author // ignore: cast_nullable_to_non_nullable + as Author, + totalLikes: null == totalLikes + ? _value.totalLikes + : totalLikes // ignore: cast_nullable_to_non_nullable + as int, + totalViews: null == totalViews + ? _value.totalViews + : totalViews // ignore: cast_nullable_to_non_nullable + as int, + totalComments: null == totalComments + ? _value.totalComments + : totalComments // ignore: cast_nullable_to_non_nullable + as int, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$PlanModelImpl implements _PlanModel { + const _$PlanModelImpl( + {@JsonKey(name: "id") required this.id, + @JsonKey(name: "name") required this.name, + @JsonKey(name: "image") required this.image, + @JsonKey(name: "duration") required this.duration, + @JsonKey(name: "state") required this.state, + @JsonKey(name: "type") required this.type, + @JsonKey(name: "details") required this.details, + @JsonKey(name: "packets_count") required this.packetsCount, + @JsonKey(name: "packet1_options") this.packet1Options, + @JsonKey(name: "packet2_options") this.packet2Options, + @JsonKey(name: "packet3_options") this.packet3Options, + @JsonKey(name: "author") required this.author, + @JsonKey(name: "total_likes") required this.totalLikes, + @JsonKey(name: "total_views") required this.totalViews, + @JsonKey(name: "total_comments") required this.totalComments}); + + factory _$PlanModelImpl.fromJson(Map json) => + _$$PlanModelImplFromJson(json); + + @override + @JsonKey(name: "id") + final int id; + @override + @JsonKey(name: "name") + final String name; + @override + @JsonKey(name: "image") + final String image; + @override + @JsonKey(name: "duration") + final int duration; + @override + @JsonKey(name: "state") + final String state; + @override + @JsonKey(name: "type") + final PlanType type; + @override + @JsonKey(name: "details") + final String details; + @override + @JsonKey(name: "packets_count") + final int packetsCount; + @override + @JsonKey(name: "packet1_options") + final dynamic packet1Options; + @override + @JsonKey(name: "packet2_options") + final dynamic packet2Options; + @override + @JsonKey(name: "packet3_options") + final dynamic packet3Options; + @override + @JsonKey(name: "author") + final Author author; + @override + @JsonKey(name: "total_likes") + final int totalLikes; + @override + @JsonKey(name: "total_views") + final int totalViews; + @override + @JsonKey(name: "total_comments") + final int totalComments; + + @override + String toString() { + return 'PlanModel(id: $id, name: $name, image: $image, duration: $duration, state: $state, type: $type, details: $details, packetsCount: $packetsCount, packet1Options: $packet1Options, packet2Options: $packet2Options, packet3Options: $packet3Options, author: $author, totalLikes: $totalLikes, totalViews: $totalViews, totalComments: $totalComments)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$PlanModelImpl && + (identical(other.id, id) || other.id == id) && + (identical(other.name, name) || other.name == name) && + (identical(other.image, image) || other.image == image) && + (identical(other.duration, duration) || + other.duration == duration) && + (identical(other.state, state) || other.state == state) && + (identical(other.type, type) || other.type == type) && + (identical(other.details, details) || other.details == details) && + (identical(other.packetsCount, packetsCount) || + other.packetsCount == packetsCount) && + const DeepCollectionEquality() + .equals(other.packet1Options, packet1Options) && + const DeepCollectionEquality() + .equals(other.packet2Options, packet2Options) && + const DeepCollectionEquality() + .equals(other.packet3Options, packet3Options) && + (identical(other.author, author) || other.author == author) && + (identical(other.totalLikes, totalLikes) || + other.totalLikes == totalLikes) && + (identical(other.totalViews, totalViews) || + other.totalViews == totalViews) && + (identical(other.totalComments, totalComments) || + other.totalComments == totalComments)); + } + + @JsonKey(includeFromJson: false, includeToJson: false) + @override + int get hashCode => Object.hash( + runtimeType, + id, + name, + image, + duration, + state, + type, + details, + packetsCount, + const DeepCollectionEquality().hash(packet1Options), + const DeepCollectionEquality().hash(packet2Options), + const DeepCollectionEquality().hash(packet3Options), + author, + totalLikes, + totalViews, + totalComments); + + /// Create a copy of PlanModel + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$PlanModelImplCopyWith<_$PlanModelImpl> get copyWith => + __$$PlanModelImplCopyWithImpl<_$PlanModelImpl>(this, _$identity); + + @override + Map toJson() { + return _$$PlanModelImplToJson( + this, + ); + } +} + +abstract class _PlanModel implements PlanModel { + const factory _PlanModel( + {@JsonKey(name: "id") required final int id, + @JsonKey(name: "name") required final String name, + @JsonKey(name: "image") required final String image, + @JsonKey(name: "duration") required final int duration, + @JsonKey(name: "state") required final String state, + @JsonKey(name: "type") required final PlanType type, + @JsonKey(name: "details") required final String details, + @JsonKey(name: "packets_count") required final int packetsCount, + @JsonKey(name: "packet1_options") final dynamic packet1Options, + @JsonKey(name: "packet2_options") final dynamic packet2Options, + @JsonKey(name: "packet3_options") final dynamic packet3Options, + @JsonKey(name: "author") required final Author author, + @JsonKey(name: "total_likes") required final int totalLikes, + @JsonKey(name: "total_views") required final int totalViews, + @JsonKey(name: "total_comments") required final int totalComments}) = + _$PlanModelImpl; + + factory _PlanModel.fromJson(Map json) = + _$PlanModelImpl.fromJson; + + @override + @JsonKey(name: "id") + int get id; + @override + @JsonKey(name: "name") + String get name; + @override + @JsonKey(name: "image") + String get image; + @override + @JsonKey(name: "duration") + int get duration; + @override + @JsonKey(name: "state") + String get state; + @override + @JsonKey(name: "type") + PlanType get type; + @override + @JsonKey(name: "details") + String get details; + @override + @JsonKey(name: "packets_count") + int get packetsCount; + @override + @JsonKey(name: "packet1_options") + dynamic get packet1Options; + @override + @JsonKey(name: "packet2_options") + dynamic get packet2Options; + @override + @JsonKey(name: "packet3_options") + dynamic get packet3Options; + @override + @JsonKey(name: "author") + Author get author; + @override + @JsonKey(name: "total_likes") + int get totalLikes; + @override + @JsonKey(name: "total_views") + int get totalViews; + @override + @JsonKey(name: "total_comments") + int get totalComments; + + /// Create a copy of PlanModel + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + _$$PlanModelImplCopyWith<_$PlanModelImpl> get copyWith => + throw _privateConstructorUsedError; +} + +PacketOptions _$PacketOptionsFromJson(Map json) { + return _PacketOptions.fromJson(json); +} + +/// @nodoc +mixin _$PacketOptions { + @JsonKey(name: "items") + List get items => throw _privateConstructorUsedError; + @JsonKey(name: "price") + dynamic get price => throw _privateConstructorUsedError; + @JsonKey(name: "short") + String get short => throw _privateConstructorUsedError; + @JsonKey(name: "description") + String get description => throw _privateConstructorUsedError; + + /// Serializes this PacketOptions to a JSON map. + Map toJson() => throw _privateConstructorUsedError; + + /// Create a copy of PacketOptions + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $PacketOptionsCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $PacketOptionsCopyWith<$Res> { + factory $PacketOptionsCopyWith( + PacketOptions value, $Res Function(PacketOptions) then) = + _$PacketOptionsCopyWithImpl<$Res, PacketOptions>; + @useResult + $Res call( + {@JsonKey(name: "items") List items, + @JsonKey(name: "price") dynamic price, + @JsonKey(name: "short") String short, + @JsonKey(name: "description") String description}); +} + +/// @nodoc +class _$PacketOptionsCopyWithImpl<$Res, $Val extends PacketOptions> + implements $PacketOptionsCopyWith<$Res> { + _$PacketOptionsCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of PacketOptions + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? items = null, + Object? price = freezed, + Object? short = null, + Object? description = null, + }) { + return _then(_value.copyWith( + items: null == items + ? _value.items + : items // ignore: cast_nullable_to_non_nullable + as List, + price: freezed == price + ? _value.price + : price // ignore: cast_nullable_to_non_nullable + as dynamic, + short: null == short + ? _value.short + : short // ignore: cast_nullable_to_non_nullable + as String, + description: null == description + ? _value.description + : description // ignore: cast_nullable_to_non_nullable + as String, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$PacketOptionsImplCopyWith<$Res> + implements $PacketOptionsCopyWith<$Res> { + factory _$$PacketOptionsImplCopyWith( + _$PacketOptionsImpl value, $Res Function(_$PacketOptionsImpl) then) = + __$$PacketOptionsImplCopyWithImpl<$Res>; + @override + @useResult + $Res call( + {@JsonKey(name: "items") List items, + @JsonKey(name: "price") dynamic price, + @JsonKey(name: "short") String short, + @JsonKey(name: "description") String description}); +} + +/// @nodoc +class __$$PacketOptionsImplCopyWithImpl<$Res> + extends _$PacketOptionsCopyWithImpl<$Res, _$PacketOptionsImpl> + implements _$$PacketOptionsImplCopyWith<$Res> { + __$$PacketOptionsImplCopyWithImpl( + _$PacketOptionsImpl _value, $Res Function(_$PacketOptionsImpl) _then) + : super(_value, _then); + + /// Create a copy of PacketOptions + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? items = null, + Object? price = freezed, + Object? short = null, + Object? description = null, + }) { + return _then(_$PacketOptionsImpl( + items: null == items + ? _value._items + : items // ignore: cast_nullable_to_non_nullable + as List, + price: freezed == price + ? _value.price + : price // ignore: cast_nullable_to_non_nullable + as dynamic, + short: null == short + ? _value.short + : short // ignore: cast_nullable_to_non_nullable + as String, + description: null == description + ? _value.description + : description // ignore: cast_nullable_to_non_nullable + as String, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$PacketOptionsImpl implements _PacketOptions { + const _$PacketOptionsImpl( + {@JsonKey(name: "items") required final List items, + @JsonKey(name: "price") required this.price, + @JsonKey(name: "short") required this.short, + @JsonKey(name: "description") required this.description}) + : _items = items; + + factory _$PacketOptionsImpl.fromJson(Map json) => + _$$PacketOptionsImplFromJson(json); + + final List _items; + @override + @JsonKey(name: "items") + List get items { + if (_items is EqualUnmodifiableListView) return _items; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(_items); + } + + @override + @JsonKey(name: "price") + final dynamic price; + @override + @JsonKey(name: "short") + final String short; + @override + @JsonKey(name: "description") + final String description; + + @override + String toString() { + return 'PacketOptions(items: $items, price: $price, short: $short, description: $description)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$PacketOptionsImpl && + const DeepCollectionEquality().equals(other._items, _items) && + const DeepCollectionEquality().equals(other.price, price) && + (identical(other.short, short) || other.short == short) && + (identical(other.description, description) || + other.description == description)); + } + + @JsonKey(includeFromJson: false, includeToJson: false) + @override + int get hashCode => Object.hash( + runtimeType, + const DeepCollectionEquality().hash(_items), + const DeepCollectionEquality().hash(price), + short, + description); + + /// Create a copy of PacketOptions + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$PacketOptionsImplCopyWith<_$PacketOptionsImpl> get copyWith => + __$$PacketOptionsImplCopyWithImpl<_$PacketOptionsImpl>(this, _$identity); + + @override + Map toJson() { + return _$$PacketOptionsImplToJson( + this, + ); + } +} + +abstract class _PacketOptions implements PacketOptions { + const factory _PacketOptions( + {@JsonKey(name: "items") required final List items, + @JsonKey(name: "price") required final dynamic price, + @JsonKey(name: "short") required final String short, + @JsonKey(name: "description") required final String description}) = + _$PacketOptionsImpl; + + factory _PacketOptions.fromJson(Map json) = + _$PacketOptionsImpl.fromJson; + + @override + @JsonKey(name: "items") + List get items; + @override + @JsonKey(name: "price") + dynamic get price; + @override + @JsonKey(name: "short") + String get short; + @override + @JsonKey(name: "description") + String get description; + + /// Create a copy of PacketOptions + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + _$$PacketOptionsImplCopyWith<_$PacketOptionsImpl> get copyWith => + throw _privateConstructorUsedError; +} + +PlanType _$PlanTypeFromJson(Map json) { + return _PlanType.fromJson(json); +} + +/// @nodoc +mixin _$PlanType { + @JsonKey(name: "fit") + bool get fit => throw _privateConstructorUsedError; + @JsonKey(name: "slim") + bool get slim => throw _privateConstructorUsedError; + @JsonKey(name: "behavior") + bool get behavior => throw _privateConstructorUsedError; + @JsonKey(name: "wellness") + bool get wellness => throw _privateConstructorUsedError; + + /// Serializes this PlanType to a JSON map. + Map toJson() => throw _privateConstructorUsedError; + + /// Create a copy of PlanType + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $PlanTypeCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $PlanTypeCopyWith<$Res> { + factory $PlanTypeCopyWith(PlanType value, $Res Function(PlanType) then) = + _$PlanTypeCopyWithImpl<$Res, PlanType>; + @useResult + $Res call( + {@JsonKey(name: "fit") bool fit, + @JsonKey(name: "slim") bool slim, + @JsonKey(name: "behavior") bool behavior, + @JsonKey(name: "wellness") bool wellness}); +} + +/// @nodoc +class _$PlanTypeCopyWithImpl<$Res, $Val extends PlanType> + implements $PlanTypeCopyWith<$Res> { + _$PlanTypeCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of PlanType + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? fit = null, + Object? slim = null, + Object? behavior = null, + Object? wellness = null, + }) { + return _then(_value.copyWith( + fit: null == fit + ? _value.fit + : fit // ignore: cast_nullable_to_non_nullable + as bool, + slim: null == slim + ? _value.slim + : slim // ignore: cast_nullable_to_non_nullable + as bool, + behavior: null == behavior + ? _value.behavior + : behavior // ignore: cast_nullable_to_non_nullable + as bool, + wellness: null == wellness + ? _value.wellness + : wellness // ignore: cast_nullable_to_non_nullable + as bool, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$PlanTypeImplCopyWith<$Res> + implements $PlanTypeCopyWith<$Res> { + factory _$$PlanTypeImplCopyWith( + _$PlanTypeImpl value, $Res Function(_$PlanTypeImpl) then) = + __$$PlanTypeImplCopyWithImpl<$Res>; + @override + @useResult + $Res call( + {@JsonKey(name: "fit") bool fit, + @JsonKey(name: "slim") bool slim, + @JsonKey(name: "behavior") bool behavior, + @JsonKey(name: "wellness") bool wellness}); +} + +/// @nodoc +class __$$PlanTypeImplCopyWithImpl<$Res> + extends _$PlanTypeCopyWithImpl<$Res, _$PlanTypeImpl> + implements _$$PlanTypeImplCopyWith<$Res> { + __$$PlanTypeImplCopyWithImpl( + _$PlanTypeImpl _value, $Res Function(_$PlanTypeImpl) _then) + : super(_value, _then); + + /// Create a copy of PlanType + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? fit = null, + Object? slim = null, + Object? behavior = null, + Object? wellness = null, + }) { + return _then(_$PlanTypeImpl( + fit: null == fit + ? _value.fit + : fit // ignore: cast_nullable_to_non_nullable + as bool, + slim: null == slim + ? _value.slim + : slim // ignore: cast_nullable_to_non_nullable + as bool, + behavior: null == behavior + ? _value.behavior + : behavior // ignore: cast_nullable_to_non_nullable + as bool, + wellness: null == wellness + ? _value.wellness + : wellness // ignore: cast_nullable_to_non_nullable + as bool, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$PlanTypeImpl implements _PlanType { + const _$PlanTypeImpl( + {@JsonKey(name: "fit") required this.fit, + @JsonKey(name: "slim") required this.slim, + @JsonKey(name: "behavior") required this.behavior, + @JsonKey(name: "wellness") required this.wellness}); + + factory _$PlanTypeImpl.fromJson(Map json) => + _$$PlanTypeImplFromJson(json); + + @override + @JsonKey(name: "fit") + final bool fit; + @override + @JsonKey(name: "slim") + final bool slim; + @override + @JsonKey(name: "behavior") + final bool behavior; + @override + @JsonKey(name: "wellness") + final bool wellness; + + @override + String toString() { + return 'PlanType(fit: $fit, slim: $slim, behavior: $behavior, wellness: $wellness)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$PlanTypeImpl && + (identical(other.fit, fit) || other.fit == fit) && + (identical(other.slim, slim) || other.slim == slim) && + (identical(other.behavior, behavior) || + other.behavior == behavior) && + (identical(other.wellness, wellness) || + other.wellness == wellness)); + } + + @JsonKey(includeFromJson: false, includeToJson: false) + @override + int get hashCode => Object.hash(runtimeType, fit, slim, behavior, wellness); + + /// Create a copy of PlanType + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$PlanTypeImplCopyWith<_$PlanTypeImpl> get copyWith => + __$$PlanTypeImplCopyWithImpl<_$PlanTypeImpl>(this, _$identity); + + @override + Map toJson() { + return _$$PlanTypeImplToJson( + this, + ); + } +} + +abstract class _PlanType implements PlanType { + const factory _PlanType( + {@JsonKey(name: "fit") required final bool fit, + @JsonKey(name: "slim") required final bool slim, + @JsonKey(name: "behavior") required final bool behavior, + @JsonKey(name: "wellness") required final bool wellness}) = + _$PlanTypeImpl; + + factory _PlanType.fromJson(Map json) = + _$PlanTypeImpl.fromJson; + + @override + @JsonKey(name: "fit") + bool get fit; + @override + @JsonKey(name: "slim") + bool get slim; + @override + @JsonKey(name: "behavior") + bool get behavior; + @override + @JsonKey(name: "wellness") + bool get wellness; + + /// Create a copy of PlanType + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + _$$PlanTypeImplCopyWith<_$PlanTypeImpl> get copyWith => + throw _privateConstructorUsedError; +} diff --git a/lib/features/plans/models/plan_pagination_model.g.dart b/lib/features/plans/models/plan_pagination_model.g.dart new file mode 100644 index 00000000..8f203fa8 --- /dev/null +++ b/lib/features/plans/models/plan_pagination_model.g.dart @@ -0,0 +1,95 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'plan_pagination_model.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +_$PlanPaginationModelImpl _$$PlanPaginationModelImplFromJson( + Map json) => + _$PlanPaginationModelImpl( + data: (json['data'] as List) + .map((e) => PlanModel.fromJson(e as Map)) + .toList(), + links: Links.fromJson(json['links'] as Map), + meta: Meta.fromJson(json['meta'] as Map), + ); + +Map _$$PlanPaginationModelImplToJson( + _$PlanPaginationModelImpl instance) => + { + 'data': instance.data, + 'links': instance.links, + 'meta': instance.meta, + }; + +_$PlanModelImpl _$$PlanModelImplFromJson(Map json) => + _$PlanModelImpl( + id: (json['id'] as num).toInt(), + name: json['name'] as String, + image: json['image'] as String, + duration: (json['duration'] as num).toInt(), + state: json['state'] as String, + type: PlanType.fromJson(json['type'] as Map), + details: json['details'] as String, + packetsCount: (json['packets_count'] as num).toInt(), + packet1Options: json['packet1_options'], + packet2Options: json['packet2_options'], + packet3Options: json['packet3_options'], + author: Author.fromJson(json['author'] as Map), + totalLikes: (json['total_likes'] as num).toInt(), + totalViews: (json['total_views'] as num).toInt(), + totalComments: (json['total_comments'] as num).toInt(), + ); + +Map _$$PlanModelImplToJson(_$PlanModelImpl instance) => + { + 'id': instance.id, + 'name': instance.name, + 'image': instance.image, + 'duration': instance.duration, + 'state': instance.state, + 'type': instance.type, + 'details': instance.details, + 'packets_count': instance.packetsCount, + 'packet1_options': instance.packet1Options, + 'packet2_options': instance.packet2Options, + 'packet3_options': instance.packet3Options, + 'author': instance.author, + 'total_likes': instance.totalLikes, + 'total_views': instance.totalViews, + 'total_comments': instance.totalComments, + }; + +_$PacketOptionsImpl _$$PacketOptionsImplFromJson(Map json) => + _$PacketOptionsImpl( + items: (json['items'] as List).map((e) => e as String).toList(), + price: json['price'], + short: json['short'] as String, + description: json['description'] as String, + ); + +Map _$$PacketOptionsImplToJson(_$PacketOptionsImpl instance) => + { + 'items': instance.items, + 'price': instance.price, + 'short': instance.short, + 'description': instance.description, + }; + +_$PlanTypeImpl _$$PlanTypeImplFromJson(Map json) => + _$PlanTypeImpl( + fit: json['fit'] as bool, + slim: json['slim'] as bool, + behavior: json['behavior'] as bool, + wellness: json['wellness'] as bool, + ); + +Map _$$PlanTypeImplToJson(_$PlanTypeImpl instance) => + { + 'fit': instance.fit, + 'slim': instance.slim, + 'behavior': instance.behavior, + 'wellness': instance.wellness, + }; diff --git a/lib/features/plans/presentation/bloc/plans_cubit/plans_cubit.dart b/lib/features/plans/presentation/bloc/plans_cubit/plans_cubit.dart new file mode 100644 index 00000000..2190654a --- /dev/null +++ b/lib/features/plans/presentation/bloc/plans_cubit/plans_cubit.dart @@ -0,0 +1,19 @@ +import 'package:eatvio_app/features/plans/presentation/bloc/plans_cubit/plans_state.dart'; +import 'package:eatvio_app/features/plans/repositories/plans_repository.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; + +class PlansCubit extends Cubit { + final PlansRepository plansRepository; + + PlansCubit({ + required this.plansRepository, + }) : super(PlansState.loading()); + + loadPlans() async { + try { + emit(PlansState.loaded(plansModel: await plansRepository.getPlans())); + } catch (e) { + emit(PlansState.error(errorMessage: e.toString())); + } + } +} diff --git a/lib/features/plans/presentation/bloc/plans_cubit/plans_state.dart b/lib/features/plans/presentation/bloc/plans_cubit/plans_state.dart new file mode 100644 index 00000000..ca3193cf --- /dev/null +++ b/lib/features/plans/presentation/bloc/plans_cubit/plans_state.dart @@ -0,0 +1,19 @@ +import 'package:eatvio_app/features/plans/models/plan_pagination_model.dart'; +import 'package:freezed_annotation/freezed_annotation.dart'; + +part 'plans_state.freezed.dart'; + +@freezed +abstract class PlansState with _$PlansState { + const factory PlansState() = _PlansState; + + const factory PlansState.loading() = PlansStateLoading; + + const factory PlansState.loaded({ + required PlanPaginationModel plansModel, + }) = PlansStateLoaded; + + const factory PlansState.error({ + required String errorMessage, + }) = PlansStateError; +} diff --git a/lib/features/plans/presentation/bloc/plans_cubit/plans_state.freezed.dart b/lib/features/plans/presentation/bloc/plans_cubit/plans_state.freezed.dart new file mode 100644 index 00000000..1bbe3cac --- /dev/null +++ b/lib/features/plans/presentation/bloc/plans_cubit/plans_state.freezed.dart @@ -0,0 +1,646 @@ +// 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 'plans_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 _$PlansState { + @optionalTypeArgs + TResult when( + TResult Function() $default, { + required TResult Function() loading, + required TResult Function(PlanPaginationModel plansModel) loaded, + required TResult Function(String errorMessage) error, + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult? whenOrNull( + TResult? Function()? $default, { + TResult? Function()? loading, + TResult? Function(PlanPaginationModel plansModel)? loaded, + TResult? Function(String errorMessage)? error, + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult maybeWhen( + TResult Function()? $default, { + TResult Function()? loading, + TResult Function(PlanPaginationModel plansModel)? loaded, + TResult Function(String errorMessage)? error, + required TResult orElse(), + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult map( + TResult Function(_PlansState value) $default, { + required TResult Function(PlansStateLoading value) loading, + required TResult Function(PlansStateLoaded value) loaded, + required TResult Function(PlansStateError value) error, + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult? mapOrNull( + TResult? Function(_PlansState value)? $default, { + TResult? Function(PlansStateLoading value)? loading, + TResult? Function(PlansStateLoaded value)? loaded, + TResult? Function(PlansStateError value)? error, + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult maybeMap( + TResult Function(_PlansState value)? $default, { + TResult Function(PlansStateLoading value)? loading, + TResult Function(PlansStateLoaded value)? loaded, + TResult Function(PlansStateError value)? error, + required TResult orElse(), + }) => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $PlansStateCopyWith<$Res> { + factory $PlansStateCopyWith( + PlansState value, $Res Function(PlansState) then) = + _$PlansStateCopyWithImpl<$Res, PlansState>; +} + +/// @nodoc +class _$PlansStateCopyWithImpl<$Res, $Val extends PlansState> + implements $PlansStateCopyWith<$Res> { + _$PlansStateCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of PlansState + /// with the given fields replaced by the non-null parameter values. +} + +/// @nodoc +abstract class _$$PlansStateImplCopyWith<$Res> { + factory _$$PlansStateImplCopyWith( + _$PlansStateImpl value, $Res Function(_$PlansStateImpl) then) = + __$$PlansStateImplCopyWithImpl<$Res>; +} + +/// @nodoc +class __$$PlansStateImplCopyWithImpl<$Res> + extends _$PlansStateCopyWithImpl<$Res, _$PlansStateImpl> + implements _$$PlansStateImplCopyWith<$Res> { + __$$PlansStateImplCopyWithImpl( + _$PlansStateImpl _value, $Res Function(_$PlansStateImpl) _then) + : super(_value, _then); + + /// Create a copy of PlansState + /// with the given fields replaced by the non-null parameter values. +} + +/// @nodoc + +class _$PlansStateImpl implements _PlansState { + const _$PlansStateImpl(); + + @override + String toString() { + return 'PlansState()'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && other is _$PlansStateImpl); + } + + @override + int get hashCode => runtimeType.hashCode; + + @override + @optionalTypeArgs + TResult when( + TResult Function() $default, { + required TResult Function() loading, + required TResult Function(PlanPaginationModel plansModel) loaded, + required TResult Function(String errorMessage) error, + }) { + return $default(); + } + + @override + @optionalTypeArgs + TResult? whenOrNull( + TResult? Function()? $default, { + TResult? Function()? loading, + TResult? Function(PlanPaginationModel plansModel)? loaded, + TResult? Function(String errorMessage)? error, + }) { + return $default?.call(); + } + + @override + @optionalTypeArgs + TResult maybeWhen( + TResult Function()? $default, { + TResult Function()? loading, + TResult Function(PlanPaginationModel plansModel)? loaded, + TResult Function(String errorMessage)? error, + required TResult orElse(), + }) { + if ($default != null) { + return $default(); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map( + TResult Function(_PlansState value) $default, { + required TResult Function(PlansStateLoading value) loading, + required TResult Function(PlansStateLoaded value) loaded, + required TResult Function(PlansStateError value) error, + }) { + return $default(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull( + TResult? Function(_PlansState value)? $default, { + TResult? Function(PlansStateLoading value)? loading, + TResult? Function(PlansStateLoaded value)? loaded, + TResult? Function(PlansStateError value)? error, + }) { + return $default?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap( + TResult Function(_PlansState value)? $default, { + TResult Function(PlansStateLoading value)? loading, + TResult Function(PlansStateLoaded value)? loaded, + TResult Function(PlansStateError value)? error, + required TResult orElse(), + }) { + if ($default != null) { + return $default(this); + } + return orElse(); + } +} + +abstract class _PlansState implements PlansState { + const factory _PlansState() = _$PlansStateImpl; +} + +/// @nodoc +abstract class _$$PlansStateLoadingImplCopyWith<$Res> { + factory _$$PlansStateLoadingImplCopyWith(_$PlansStateLoadingImpl value, + $Res Function(_$PlansStateLoadingImpl) then) = + __$$PlansStateLoadingImplCopyWithImpl<$Res>; +} + +/// @nodoc +class __$$PlansStateLoadingImplCopyWithImpl<$Res> + extends _$PlansStateCopyWithImpl<$Res, _$PlansStateLoadingImpl> + implements _$$PlansStateLoadingImplCopyWith<$Res> { + __$$PlansStateLoadingImplCopyWithImpl(_$PlansStateLoadingImpl _value, + $Res Function(_$PlansStateLoadingImpl) _then) + : super(_value, _then); + + /// Create a copy of PlansState + /// with the given fields replaced by the non-null parameter values. +} + +/// @nodoc + +class _$PlansStateLoadingImpl implements PlansStateLoading { + const _$PlansStateLoadingImpl(); + + @override + String toString() { + return 'PlansState.loading()'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && other is _$PlansStateLoadingImpl); + } + + @override + int get hashCode => runtimeType.hashCode; + + @override + @optionalTypeArgs + TResult when( + TResult Function() $default, { + required TResult Function() loading, + required TResult Function(PlanPaginationModel plansModel) loaded, + required TResult Function(String errorMessage) error, + }) { + return loading(); + } + + @override + @optionalTypeArgs + TResult? whenOrNull( + TResult? Function()? $default, { + TResult? Function()? loading, + TResult? Function(PlanPaginationModel plansModel)? loaded, + TResult? Function(String errorMessage)? error, + }) { + return loading?.call(); + } + + @override + @optionalTypeArgs + TResult maybeWhen( + TResult Function()? $default, { + TResult Function()? loading, + TResult Function(PlanPaginationModel plansModel)? loaded, + TResult Function(String errorMessage)? error, + required TResult orElse(), + }) { + if (loading != null) { + return loading(); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map( + TResult Function(_PlansState value) $default, { + required TResult Function(PlansStateLoading value) loading, + required TResult Function(PlansStateLoaded value) loaded, + required TResult Function(PlansStateError value) error, + }) { + return loading(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull( + TResult? Function(_PlansState value)? $default, { + TResult? Function(PlansStateLoading value)? loading, + TResult? Function(PlansStateLoaded value)? loaded, + TResult? Function(PlansStateError value)? error, + }) { + return loading?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap( + TResult Function(_PlansState value)? $default, { + TResult Function(PlansStateLoading value)? loading, + TResult Function(PlansStateLoaded value)? loaded, + TResult Function(PlansStateError value)? error, + required TResult orElse(), + }) { + if (loading != null) { + return loading(this); + } + return orElse(); + } +} + +abstract class PlansStateLoading implements PlansState { + const factory PlansStateLoading() = _$PlansStateLoadingImpl; +} + +/// @nodoc +abstract class _$$PlansStateLoadedImplCopyWith<$Res> { + factory _$$PlansStateLoadedImplCopyWith(_$PlansStateLoadedImpl value, + $Res Function(_$PlansStateLoadedImpl) then) = + __$$PlansStateLoadedImplCopyWithImpl<$Res>; + @useResult + $Res call({PlanPaginationModel plansModel}); + + $PlanPaginationModelCopyWith<$Res> get plansModel; +} + +/// @nodoc +class __$$PlansStateLoadedImplCopyWithImpl<$Res> + extends _$PlansStateCopyWithImpl<$Res, _$PlansStateLoadedImpl> + implements _$$PlansStateLoadedImplCopyWith<$Res> { + __$$PlansStateLoadedImplCopyWithImpl(_$PlansStateLoadedImpl _value, + $Res Function(_$PlansStateLoadedImpl) _then) + : super(_value, _then); + + /// Create a copy of PlansState + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? plansModel = null, + }) { + return _then(_$PlansStateLoadedImpl( + plansModel: null == plansModel + ? _value.plansModel + : plansModel // ignore: cast_nullable_to_non_nullable + as PlanPaginationModel, + )); + } + + /// Create a copy of PlansState + /// with the given fields replaced by the non-null parameter values. + @override + @pragma('vm:prefer-inline') + $PlanPaginationModelCopyWith<$Res> get plansModel { + return $PlanPaginationModelCopyWith<$Res>(_value.plansModel, (value) { + return _then(_value.copyWith(plansModel: value)); + }); + } +} + +/// @nodoc + +class _$PlansStateLoadedImpl implements PlansStateLoaded { + const _$PlansStateLoadedImpl({required this.plansModel}); + + @override + final PlanPaginationModel plansModel; + + @override + String toString() { + return 'PlansState.loaded(plansModel: $plansModel)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$PlansStateLoadedImpl && + (identical(other.plansModel, plansModel) || + other.plansModel == plansModel)); + } + + @override + int get hashCode => Object.hash(runtimeType, plansModel); + + /// Create a copy of PlansState + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$PlansStateLoadedImplCopyWith<_$PlansStateLoadedImpl> get copyWith => + __$$PlansStateLoadedImplCopyWithImpl<_$PlansStateLoadedImpl>( + this, _$identity); + + @override + @optionalTypeArgs + TResult when( + TResult Function() $default, { + required TResult Function() loading, + required TResult Function(PlanPaginationModel plansModel) loaded, + required TResult Function(String errorMessage) error, + }) { + return loaded(plansModel); + } + + @override + @optionalTypeArgs + TResult? whenOrNull( + TResult? Function()? $default, { + TResult? Function()? loading, + TResult? Function(PlanPaginationModel plansModel)? loaded, + TResult? Function(String errorMessage)? error, + }) { + return loaded?.call(plansModel); + } + + @override + @optionalTypeArgs + TResult maybeWhen( + TResult Function()? $default, { + TResult Function()? loading, + TResult Function(PlanPaginationModel plansModel)? loaded, + TResult Function(String errorMessage)? error, + required TResult orElse(), + }) { + if (loaded != null) { + return loaded(plansModel); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map( + TResult Function(_PlansState value) $default, { + required TResult Function(PlansStateLoading value) loading, + required TResult Function(PlansStateLoaded value) loaded, + required TResult Function(PlansStateError value) error, + }) { + return loaded(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull( + TResult? Function(_PlansState value)? $default, { + TResult? Function(PlansStateLoading value)? loading, + TResult? Function(PlansStateLoaded value)? loaded, + TResult? Function(PlansStateError value)? error, + }) { + return loaded?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap( + TResult Function(_PlansState value)? $default, { + TResult Function(PlansStateLoading value)? loading, + TResult Function(PlansStateLoaded value)? loaded, + TResult Function(PlansStateError value)? error, + required TResult orElse(), + }) { + if (loaded != null) { + return loaded(this); + } + return orElse(); + } +} + +abstract class PlansStateLoaded implements PlansState { + const factory PlansStateLoaded( + {required final PlanPaginationModel plansModel}) = _$PlansStateLoadedImpl; + + PlanPaginationModel get plansModel; + + /// Create a copy of PlansState + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + _$$PlansStateLoadedImplCopyWith<_$PlansStateLoadedImpl> get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class _$$PlansStateErrorImplCopyWith<$Res> { + factory _$$PlansStateErrorImplCopyWith(_$PlansStateErrorImpl value, + $Res Function(_$PlansStateErrorImpl) then) = + __$$PlansStateErrorImplCopyWithImpl<$Res>; + @useResult + $Res call({String errorMessage}); +} + +/// @nodoc +class __$$PlansStateErrorImplCopyWithImpl<$Res> + extends _$PlansStateCopyWithImpl<$Res, _$PlansStateErrorImpl> + implements _$$PlansStateErrorImplCopyWith<$Res> { + __$$PlansStateErrorImplCopyWithImpl( + _$PlansStateErrorImpl _value, $Res Function(_$PlansStateErrorImpl) _then) + : super(_value, _then); + + /// Create a copy of PlansState + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? errorMessage = null, + }) { + return _then(_$PlansStateErrorImpl( + errorMessage: null == errorMessage + ? _value.errorMessage + : errorMessage // ignore: cast_nullable_to_non_nullable + as String, + )); + } +} + +/// @nodoc + +class _$PlansStateErrorImpl implements PlansStateError { + const _$PlansStateErrorImpl({required this.errorMessage}); + + @override + final String errorMessage; + + @override + String toString() { + return 'PlansState.error(errorMessage: $errorMessage)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$PlansStateErrorImpl && + (identical(other.errorMessage, errorMessage) || + other.errorMessage == errorMessage)); + } + + @override + int get hashCode => Object.hash(runtimeType, errorMessage); + + /// Create a copy of PlansState + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$PlansStateErrorImplCopyWith<_$PlansStateErrorImpl> get copyWith => + __$$PlansStateErrorImplCopyWithImpl<_$PlansStateErrorImpl>( + this, _$identity); + + @override + @optionalTypeArgs + TResult when( + TResult Function() $default, { + required TResult Function() loading, + required TResult Function(PlanPaginationModel plansModel) loaded, + required TResult Function(String errorMessage) error, + }) { + return error(errorMessage); + } + + @override + @optionalTypeArgs + TResult? whenOrNull( + TResult? Function()? $default, { + TResult? Function()? loading, + TResult? Function(PlanPaginationModel plansModel)? loaded, + TResult? Function(String errorMessage)? error, + }) { + return error?.call(errorMessage); + } + + @override + @optionalTypeArgs + TResult maybeWhen( + TResult Function()? $default, { + TResult Function()? loading, + TResult Function(PlanPaginationModel plansModel)? loaded, + TResult Function(String errorMessage)? error, + required TResult orElse(), + }) { + if (error != null) { + return error(errorMessage); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map( + TResult Function(_PlansState value) $default, { + required TResult Function(PlansStateLoading value) loading, + required TResult Function(PlansStateLoaded value) loaded, + required TResult Function(PlansStateError value) error, + }) { + return error(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull( + TResult? Function(_PlansState value)? $default, { + TResult? Function(PlansStateLoading value)? loading, + TResult? Function(PlansStateLoaded value)? loaded, + TResult? Function(PlansStateError value)? error, + }) { + return error?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap( + TResult Function(_PlansState value)? $default, { + TResult Function(PlansStateLoading value)? loading, + TResult Function(PlansStateLoaded value)? loaded, + TResult Function(PlansStateError value)? error, + required TResult orElse(), + }) { + if (error != null) { + return error(this); + } + return orElse(); + } +} + +abstract class PlansStateError implements PlansState { + const factory PlansStateError({required final String errorMessage}) = + _$PlansStateErrorImpl; + + String get errorMessage; + + /// Create a copy of PlansState + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + _$$PlansStateErrorImplCopyWith<_$PlansStateErrorImpl> get copyWith => + throw _privateConstructorUsedError; +} diff --git a/lib/features/plans/presentation/pages/about_plan_screen.dart b/lib/features/plans/presentation/pages/about_plan_screen.dart new file mode 100644 index 00000000..50f81867 --- /dev/null +++ b/lib/features/plans/presentation/pages/about_plan_screen.dart @@ -0,0 +1,20 @@ +import 'package:eatvio_app/features/plans/models/plan_pagination_model.dart'; +import 'package:flutter/material.dart'; + +class AboutPlanScreen extends StatelessWidget { + final PlanModel planModel; + + const AboutPlanScreen({ + super.key, + required this.planModel, + }); + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + title: Text(planModel.name), + ), + ); + } +} diff --git a/lib/features/plans/repositories/plans_repository.dart b/lib/features/plans/repositories/plans_repository.dart new file mode 100644 index 00000000..ee8e7fb7 --- /dev/null +++ b/lib/features/plans/repositories/plans_repository.dart @@ -0,0 +1,16 @@ +import 'package:eatvio_app/features/plans/models/plan_pagination_model.dart'; +import 'package:eatvio_app/features/plans/services/plans_service.dart'; + +class PlansRepository { + final PlansService plansService; + + const PlansRepository({required this.plansService}); + + Future getPlans() async { + try { + return await plansService.getPlans(); + } catch (e) { + rethrow; + } + } +} diff --git a/lib/features/plans/services/plans_service.dart b/lib/features/plans/services/plans_service.dart new file mode 100644 index 00000000..2b842047 --- /dev/null +++ b/lib/features/plans/services/plans_service.dart @@ -0,0 +1,13 @@ +import 'package:dio/dio.dart'; +import 'package:eatvio_app/features/plans/models/plan_pagination_model.dart'; +import 'package:retrofit/retrofit.dart'; + +part 'plans_service.g.dart'; + +@RestApi() +abstract class PlansService { + factory PlansService(Dio dio, {String baseUrl}) = _PlansService; + + @GET('/api/plans/index') + Future getPlans(); +} diff --git a/lib/features/plans/services/plans_service.g.dart b/lib/features/plans/services/plans_service.g.dart new file mode 100644 index 00000000..bce687f0 --- /dev/null +++ b/lib/features/plans/services/plans_service.g.dart @@ -0,0 +1,86 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'plans_service.dart'; + +// ************************************************************************** +// RetrofitGenerator +// ************************************************************************** + +// ignore_for_file: unnecessary_brace_in_string_interps,no_leading_underscores_for_local_identifiers,unused_element + +class _PlansService implements PlansService { + _PlansService( + this._dio, { + this.baseUrl, + this.errorLogger, + }); + + final Dio _dio; + + String? baseUrl; + + final ParseErrorLogger? errorLogger; + + @override + Future getPlans() 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/plans/index', + queryParameters: queryParameters, + data: _data, + ) + .copyWith( + baseUrl: _combineBaseUrls( + _dio.options.baseUrl, + baseUrl, + ))); + final _result = await _dio.fetch>(_options); + late PlanPaginationModel _value; + try { + _value = PlanPaginationModel.fromJson(_result.data!); + } on Object catch (e, s) { + errorLogger?.logError(e, s, _options); + rethrow; + } + return _value; + } + + RequestOptions _setStreamType(RequestOptions requestOptions) { + if (T != dynamic && + !(requestOptions.responseType == ResponseType.bytes || + requestOptions.responseType == ResponseType.stream)) { + if (T == String) { + requestOptions.responseType = ResponseType.plain; + } else { + requestOptions.responseType = ResponseType.json; + } + } + return requestOptions; + } + + String _combineBaseUrls( + String dioBaseUrl, + String? baseUrl, + ) { + if (baseUrl == null || baseUrl.trim().isEmpty) { + return dioBaseUrl; + } + + final url = Uri.parse(baseUrl); + + if (url.isAbsolute) { + return url.toString(); + } + + return Uri.parse(dioBaseUrl).resolveUri(url).toString(); + } +} diff --git a/lib/features/profile/models/circumference_model.dart b/lib/features/profile/models/circumference_model.dart new file mode 100644 index 00000000..62b54d23 --- /dev/null +++ b/lib/features/profile/models/circumference_model.dart @@ -0,0 +1,20 @@ +import 'package:freezed_annotation/freezed_annotation.dart'; + +part 'circumference_model.freezed.dart'; + +part 'circumference_model.g.dart'; + +@freezed +class CircumferenceModel with _$CircumferenceModel { + const factory CircumferenceModel({ + @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, + }) = _CircumferenceModel; + + factory CircumferenceModel.fromJson(Map json) => _$CircumferenceModelFromJson(json); +} diff --git a/lib/features/profile/models/circumference_model.freezed.dart b/lib/features/profile/models/circumference_model.freezed.dart new file mode 100644 index 00000000..870620f3 --- /dev/null +++ b/lib/features/profile/models/circumference_model.freezed.dart @@ -0,0 +1,319 @@ +// 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 'circumference_model.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'); + +CircumferenceModel _$CircumferenceModelFromJson(Map json) { + return _CircumferenceModel.fromJson(json); +} + +/// @nodoc +mixin _$CircumferenceModel { + @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; + + /// Serializes this CircumferenceModel to a JSON map. + Map toJson() => throw _privateConstructorUsedError; + + /// Create a copy of CircumferenceModel + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $CircumferenceModelCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $CircumferenceModelCopyWith<$Res> { + factory $CircumferenceModelCopyWith( + CircumferenceModel value, $Res Function(CircumferenceModel) then) = + _$CircumferenceModelCopyWithImpl<$Res, CircumferenceModel>; + @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 _$CircumferenceModelCopyWithImpl<$Res, $Val extends CircumferenceModel> + implements $CircumferenceModelCopyWith<$Res> { + _$CircumferenceModelCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of CircumferenceModel + /// with the given fields replaced by the non-null parameter values. + @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 _$$CircumferenceModelImplCopyWith<$Res> + implements $CircumferenceModelCopyWith<$Res> { + factory _$$CircumferenceModelImplCopyWith(_$CircumferenceModelImpl value, + $Res Function(_$CircumferenceModelImpl) then) = + __$$CircumferenceModelImplCopyWithImpl<$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 __$$CircumferenceModelImplCopyWithImpl<$Res> + extends _$CircumferenceModelCopyWithImpl<$Res, _$CircumferenceModelImpl> + implements _$$CircumferenceModelImplCopyWith<$Res> { + __$$CircumferenceModelImplCopyWithImpl(_$CircumferenceModelImpl _value, + $Res Function(_$CircumferenceModelImpl) _then) + : super(_value, _then); + + /// Create a copy of CircumferenceModel + /// with the given fields replaced by the non-null parameter values. + @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(_$CircumferenceModelImpl( + 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 _$CircumferenceModelImpl implements _CircumferenceModel { + const _$CircumferenceModelImpl( + {@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 _$CircumferenceModelImpl.fromJson(Map json) => + _$$CircumferenceModelImplFromJson(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 'CircumferenceModel(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 _$CircumferenceModelImpl && + (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(includeFromJson: false, includeToJson: false) + @override + int get hashCode => Object.hash(runtimeType, id, userId, chestCircumference, + waistCircumference, hipCircumference, createdAt, updatedAt); + + /// Create a copy of CircumferenceModel + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$CircumferenceModelImplCopyWith<_$CircumferenceModelImpl> get copyWith => + __$$CircumferenceModelImplCopyWithImpl<_$CircumferenceModelImpl>( + this, _$identity); + + @override + Map toJson() { + return _$$CircumferenceModelImplToJson( + this, + ); + } +} + +abstract class _CircumferenceModel implements CircumferenceModel { + const factory _CircumferenceModel( + {@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}) = _$CircumferenceModelImpl; + + factory _CircumferenceModel.fromJson(Map json) = + _$CircumferenceModelImpl.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; + + /// Create a copy of CircumferenceModel + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + _$$CircumferenceModelImplCopyWith<_$CircumferenceModelImpl> get copyWith => + throw _privateConstructorUsedError; +} diff --git a/lib/features/profile/models/circumference_model.g.dart b/lib/features/profile/models/circumference_model.g.dart new file mode 100644 index 00000000..07a10f71 --- /dev/null +++ b/lib/features/profile/models/circumference_model.g.dart @@ -0,0 +1,31 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'circumference_model.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +_$CircumferenceModelImpl _$$CircumferenceModelImplFromJson( + Map json) => + _$CircumferenceModelImpl( + 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 _$$CircumferenceModelImplToJson( + _$CircumferenceModelImpl 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(), + }; diff --git a/lib/features/profile/models/profile_model.dart b/lib/features/profile/models/profile_model.dart index 6c72a1fa..d209e6d7 100644 --- a/lib/features/profile/models/profile_model.dart +++ b/lib/features/profile/models/profile_model.dart @@ -1,110 +1,57 @@ import 'package:freezed_annotation/freezed_annotation.dart'; + part 'profile_model.freezed.dart'; + part 'profile_model.g.dart'; @freezed class ProfileModel with _$ProfileModel { const factory ProfileModel({ - @JsonKey(name: "user") required User user, - @JsonKey(name: "chartPoints") required List chartPoints, - @JsonKey(name: "userDetails") required UserDetails userDetails, - @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, + @JsonKey(name: "id") required int id, + @JsonKey(name: "name") required String name, + @JsonKey(name: "email") required String email, + @JsonKey(name: "email_verified_at") DateTime? emailVerifiedAt, + @JsonKey(name: "created_at") DateTime? createdAt, + @JsonKey(name: "updated_at") DateTime? updatedAt, + @JsonKey(name: "is_public_profile") required bool isPublicProfile, + @JsonKey(name: "slug") required String slug, + @JsonKey(name: "profile_photo_url") required String profilePhotoUrl, }) = _ProfileModel; 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 -class User with _$User { - const factory User({ - @JsonKey(name: "id") required int id, - @JsonKey(name: "name") required String name, - @JsonKey(name: "email") required String email, - @JsonKey(name: "email_verified_at") required DateTime emailVerifiedAt, - @JsonKey(name: "two_factor_confirmed_at") required dynamic twoFactorConfirmedAt, - @JsonKey(name: "current_team_id") required dynamic currentTeamId, - @JsonKey(name: "profile_photo_path") required String profilePhotoPath, - @JsonKey(name: "created_at") required DateTime createdAt, - @JsonKey(name: "updated_at") required DateTime updatedAt, - @JsonKey(name: "is_consultant") required int isConsultant, - @JsonKey(name: "is_public_profile") required int isPublicProfile, - @JsonKey(name: "slug") required String slug, - @JsonKey(name: "user_settings_id") required dynamic userSettingsId, - @JsonKey(name: "profile_photo_url") required String profilePhotoUrl, - @JsonKey(name: "detailz") required UserDetails detailz, - }) = _User; - - factory User.fromJson(Map json) => _$UserFromJson(json); -} - -@freezed -class UserDetails with _$UserDetails { - const factory UserDetails({ - @JsonKey(name: "id") required int id, - @JsonKey(name: "user_id") required int userId, +class ProfileDetailsModel with _$ProfileDetailsModel { + const factory ProfileDetailsModel({ @JsonKey(name: "first_name") required String firstName, @JsonKey(name: "last_name") required String lastName, - @JsonKey(name: "birthdate") required DateTime birthdate, + @JsonKey(name: "birthdate") required String birthdate, @JsonKey(name: "gender") required String gender, @JsonKey(name: "country") required String country, @JsonKey(name: "city") required String city, @JsonKey(name: "lang") required String lang, - @JsonKey(name: "weight") required int weight, + @JsonKey(name: "weight") required double weight, @JsonKey(name: "height") required int height, @JsonKey(name: "chest_circumference") required int chestCircumference, @JsonKey(name: "waist_circumference") required int waistCircumference, @JsonKey(name: "hip_circumference") required int hipCircumference, @JsonKey(name: "blood_pressure_up") required int bloodPressureUp, @JsonKey(name: "blood_pressure_down") required int bloodPressureDown, - @JsonKey(name: "has_hypo") required int hasHypo, - @JsonKey(name: "has_hyper") required int hasHyper, + @JsonKey(name: "has_hypo") required bool hasHypo, + @JsonKey(name: "has_hyper") required bool hasHyper, @JsonKey(name: "about_alergy") required String aboutAlergy, @JsonKey(name: "about_taking_pils") required String aboutTakingPils, @JsonKey(name: "about_sport_hobbies") required String aboutSportHobbies, @JsonKey(name: "favorite_foods") required String favoriteFoods, @JsonKey(name: "unfavorite_foods") required String unfavoriteFoods, @JsonKey(name: "additional_info") required String additionalInfo, - @JsonKey(name: "created_at") required DateTime createdAt, - @JsonKey(name: "updated_at") required DateTime updatedAt, - @JsonKey(name: "is_mood_fillable") required int isMoodFillable, - @JsonKey(name: "is_bedtime_fillable") required int isBedtimeFillable, + @JsonKey(name: "created_at") DateTime? createdAt, + @JsonKey(name: "updated_at") DateTime? updatedAt, + @JsonKey(name: "is_mood_fillable") required bool isMoodFillable, + @JsonKey(name: "is_bedtime_fillable") required bool isBedtimeFillable, @JsonKey(name: "activity_coefficient") required double activityCoefficient, - }) = _UserDetails; + }) = _ProfileDetailsModel; - 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); + factory ProfileDetailsModel.fromJson(Map json) => _$ProfileDetailsModelFromJson(json); } diff --git a/lib/features/profile/models/profile_model.freezed.dart b/lib/features/profile/models/profile_model.freezed.dart index 0e5607b4..94b860a3 100644 --- a/lib/features/profile/models/profile_model.freezed.dart +++ b/lib/features/profile/models/profile_model.freezed.dart @@ -20,29 +20,31 @@ ProfileModel _$ProfileModelFromJson(Map json) { /// @nodoc mixin _$ProfileModel { - @JsonKey(name: "user") - User get user => throw _privateConstructorUsedError; - @JsonKey(name: "chartPoints") - List get chartPoints => throw _privateConstructorUsedError; - @JsonKey(name: "userDetails") - UserDetails get userDetails => throw _privateConstructorUsedError; - @JsonKey(name: "circumferences") - List get circumferences => throw _privateConstructorUsedError; - @JsonKey(name: "finishedPlans") - List get finishedPlans => throw _privateConstructorUsedError; - @JsonKey(name: "rejectedPlans") - List get rejectedPlans => throw _privateConstructorUsedError; - @JsonKey(name: "startedPlan") - List get startedPlan => throw _privateConstructorUsedError; - @JsonKey(name: "paidPlan") - List get paidPlan => throw _privateConstructorUsedError; - @JsonKey(name: "requestedPlan") - List get requestedPlan => throw _privateConstructorUsedError; - @JsonKey(name: "initedPlan") - List get initedPlan => throw _privateConstructorUsedError; + @JsonKey(name: "id") + int get id => throw _privateConstructorUsedError; + @JsonKey(name: "name") + String get name => throw _privateConstructorUsedError; + @JsonKey(name: "email") + String get email => throw _privateConstructorUsedError; + @JsonKey(name: "email_verified_at") + DateTime? get emailVerifiedAt => throw _privateConstructorUsedError; + @JsonKey(name: "created_at") + DateTime? get createdAt => throw _privateConstructorUsedError; + @JsonKey(name: "updated_at") + DateTime? get updatedAt => throw _privateConstructorUsedError; + @JsonKey(name: "is_public_profile") + bool get isPublicProfile => throw _privateConstructorUsedError; + @JsonKey(name: "slug") + String get slug => throw _privateConstructorUsedError; + @JsonKey(name: "profile_photo_url") + String get profilePhotoUrl => throw _privateConstructorUsedError; + /// Serializes this ProfileModel to a JSON map. Map toJson() => throw _privateConstructorUsedError; - @JsonKey(ignore: true) + + /// Create a copy of ProfileModel + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) $ProfileModelCopyWith get copyWith => throw _privateConstructorUsedError; } @@ -54,19 +56,15 @@ abstract class $ProfileModelCopyWith<$Res> { _$ProfileModelCopyWithImpl<$Res, ProfileModel>; @useResult $Res call( - {@JsonKey(name: "user") User user, - @JsonKey(name: "chartPoints") List chartPoints, - @JsonKey(name: "userDetails") UserDetails userDetails, - @JsonKey(name: "circumferences") List circumferences, - @JsonKey(name: "finishedPlans") List finishedPlans, - @JsonKey(name: "rejectedPlans") List rejectedPlans, - @JsonKey(name: "startedPlan") List startedPlan, - @JsonKey(name: "paidPlan") List paidPlan, - @JsonKey(name: "requestedPlan") List requestedPlan, - @JsonKey(name: "initedPlan") List initedPlan}); - - $UserCopyWith<$Res> get user; - $UserDetailsCopyWith<$Res> get userDetails; + {@JsonKey(name: "id") int id, + @JsonKey(name: "name") String name, + @JsonKey(name: "email") String email, + @JsonKey(name: "email_verified_at") DateTime? emailVerifiedAt, + @JsonKey(name: "created_at") DateTime? createdAt, + @JsonKey(name: "updated_at") DateTime? updatedAt, + @JsonKey(name: "is_public_profile") bool isPublicProfile, + @JsonKey(name: "slug") String slug, + @JsonKey(name: "profile_photo_url") String profilePhotoUrl}); } /// @nodoc @@ -79,79 +77,60 @@ class _$ProfileModelCopyWithImpl<$Res, $Val extends ProfileModel> // ignore: unused_field final $Res Function($Val) _then; + /// Create a copy of ProfileModel + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ - Object? user = null, - Object? chartPoints = null, - Object? userDetails = null, - Object? circumferences = null, - Object? finishedPlans = null, - Object? rejectedPlans = null, - Object? startedPlan = null, - Object? paidPlan = null, - Object? requestedPlan = null, - Object? initedPlan = null, + Object? id = null, + Object? name = null, + Object? email = null, + Object? emailVerifiedAt = freezed, + Object? createdAt = freezed, + Object? updatedAt = freezed, + Object? isPublicProfile = null, + Object? slug = null, + Object? profilePhotoUrl = null, }) { return _then(_value.copyWith( - user: null == user - ? _value.user - : user // ignore: cast_nullable_to_non_nullable - as User, - chartPoints: null == chartPoints - ? _value.chartPoints - : chartPoints // ignore: cast_nullable_to_non_nullable - as List, - userDetails: null == userDetails - ? _value.userDetails - : userDetails // ignore: cast_nullable_to_non_nullable - as UserDetails, - circumferences: null == circumferences - ? _value.circumferences - : circumferences // ignore: cast_nullable_to_non_nullable - as List, - finishedPlans: null == finishedPlans - ? _value.finishedPlans - : finishedPlans // ignore: cast_nullable_to_non_nullable - as List, - rejectedPlans: null == rejectedPlans - ? _value.rejectedPlans - : rejectedPlans // ignore: cast_nullable_to_non_nullable - as List, - startedPlan: null == startedPlan - ? _value.startedPlan - : startedPlan // ignore: cast_nullable_to_non_nullable - as List, - paidPlan: null == paidPlan - ? _value.paidPlan - : paidPlan // ignore: cast_nullable_to_non_nullable - as List, - requestedPlan: null == requestedPlan - ? _value.requestedPlan - : requestedPlan // ignore: cast_nullable_to_non_nullable - as List, - initedPlan: null == initedPlan - ? _value.initedPlan - : initedPlan // ignore: cast_nullable_to_non_nullable - as List, + id: null == id + ? _value.id + : id // ignore: cast_nullable_to_non_nullable + as int, + name: null == name + ? _value.name + : name // ignore: cast_nullable_to_non_nullable + as String, + email: null == email + ? _value.email + : email // ignore: cast_nullable_to_non_nullable + as String, + emailVerifiedAt: freezed == emailVerifiedAt + ? _value.emailVerifiedAt + : emailVerifiedAt // ignore: cast_nullable_to_non_nullable + as DateTime?, + createdAt: freezed == createdAt + ? _value.createdAt + : createdAt // ignore: cast_nullable_to_non_nullable + as DateTime?, + updatedAt: freezed == updatedAt + ? _value.updatedAt + : updatedAt // ignore: cast_nullable_to_non_nullable + as DateTime?, + isPublicProfile: null == isPublicProfile + ? _value.isPublicProfile + : isPublicProfile // ignore: cast_nullable_to_non_nullable + as bool, + slug: null == slug + ? _value.slug + : slug // ignore: cast_nullable_to_non_nullable + as String, + profilePhotoUrl: null == profilePhotoUrl + ? _value.profilePhotoUrl + : profilePhotoUrl // ignore: cast_nullable_to_non_nullable + as String, ) as $Val); } - - @override - @pragma('vm:prefer-inline') - $UserCopyWith<$Res> get user { - return $UserCopyWith<$Res>(_value.user, (value) { - return _then(_value.copyWith(user: value) as $Val); - }); - } - - @override - @pragma('vm:prefer-inline') - $UserDetailsCopyWith<$Res> get userDetails { - return $UserDetailsCopyWith<$Res>(_value.userDetails, (value) { - return _then(_value.copyWith(userDetails: value) as $Val); - }); - } } /// @nodoc @@ -163,21 +142,15 @@ abstract class _$$ProfileModelImplCopyWith<$Res> @override @useResult $Res call( - {@JsonKey(name: "user") User user, - @JsonKey(name: "chartPoints") List chartPoints, - @JsonKey(name: "userDetails") UserDetails userDetails, - @JsonKey(name: "circumferences") List circumferences, - @JsonKey(name: "finishedPlans") List finishedPlans, - @JsonKey(name: "rejectedPlans") List rejectedPlans, - @JsonKey(name: "startedPlan") List startedPlan, - @JsonKey(name: "paidPlan") List paidPlan, - @JsonKey(name: "requestedPlan") List requestedPlan, - @JsonKey(name: "initedPlan") List initedPlan}); - - @override - $UserCopyWith<$Res> get user; - @override - $UserDetailsCopyWith<$Res> get userDetails; + {@JsonKey(name: "id") int id, + @JsonKey(name: "name") String name, + @JsonKey(name: "email") String email, + @JsonKey(name: "email_verified_at") DateTime? emailVerifiedAt, + @JsonKey(name: "created_at") DateTime? createdAt, + @JsonKey(name: "updated_at") DateTime? updatedAt, + @JsonKey(name: "is_public_profile") bool isPublicProfile, + @JsonKey(name: "slug") String slug, + @JsonKey(name: "profile_photo_url") String profilePhotoUrl}); } /// @nodoc @@ -188,61 +161,58 @@ class __$$ProfileModelImplCopyWithImpl<$Res> _$ProfileModelImpl _value, $Res Function(_$ProfileModelImpl) _then) : super(_value, _then); + /// Create a copy of ProfileModel + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ - Object? user = null, - Object? chartPoints = null, - Object? userDetails = null, - Object? circumferences = null, - Object? finishedPlans = null, - Object? rejectedPlans = null, - Object? startedPlan = null, - Object? paidPlan = null, - Object? requestedPlan = null, - Object? initedPlan = null, + Object? id = null, + Object? name = null, + Object? email = null, + Object? emailVerifiedAt = freezed, + Object? createdAt = freezed, + Object? updatedAt = freezed, + Object? isPublicProfile = null, + Object? slug = null, + Object? profilePhotoUrl = null, }) { return _then(_$ProfileModelImpl( - user: null == user - ? _value.user - : user // ignore: cast_nullable_to_non_nullable - as User, - chartPoints: null == chartPoints - ? _value._chartPoints - : chartPoints // ignore: cast_nullable_to_non_nullable - as List, - userDetails: null == userDetails - ? _value.userDetails - : userDetails // ignore: cast_nullable_to_non_nullable - as UserDetails, - circumferences: null == circumferences - ? _value._circumferences - : circumferences // ignore: cast_nullable_to_non_nullable - as List, - finishedPlans: null == finishedPlans - ? _value._finishedPlans - : finishedPlans // ignore: cast_nullable_to_non_nullable - as List, - rejectedPlans: null == rejectedPlans - ? _value._rejectedPlans - : rejectedPlans // ignore: cast_nullable_to_non_nullable - as List, - startedPlan: null == startedPlan - ? _value._startedPlan - : startedPlan // ignore: cast_nullable_to_non_nullable - as List, - paidPlan: null == paidPlan - ? _value._paidPlan - : paidPlan // ignore: cast_nullable_to_non_nullable - as List, - requestedPlan: null == requestedPlan - ? _value._requestedPlan - : requestedPlan // ignore: cast_nullable_to_non_nullable - as List, - initedPlan: null == initedPlan - ? _value._initedPlan - : initedPlan // ignore: cast_nullable_to_non_nullable - as List, + id: null == id + ? _value.id + : id // ignore: cast_nullable_to_non_nullable + as int, + name: null == name + ? _value.name + : name // ignore: cast_nullable_to_non_nullable + as String, + email: null == email + ? _value.email + : email // ignore: cast_nullable_to_non_nullable + as String, + emailVerifiedAt: freezed == emailVerifiedAt + ? _value.emailVerifiedAt + : emailVerifiedAt // ignore: cast_nullable_to_non_nullable + as DateTime?, + createdAt: freezed == createdAt + ? _value.createdAt + : createdAt // ignore: cast_nullable_to_non_nullable + as DateTime?, + updatedAt: freezed == updatedAt + ? _value.updatedAt + : updatedAt // ignore: cast_nullable_to_non_nullable + as DateTime?, + isPublicProfile: null == isPublicProfile + ? _value.isPublicProfile + : isPublicProfile // ignore: cast_nullable_to_non_nullable + as bool, + slug: null == slug + ? _value.slug + : slug // ignore: cast_nullable_to_non_nullable + as String, + profilePhotoUrl: null == profilePhotoUrl + ? _value.profilePhotoUrl + : profilePhotoUrl // ignore: cast_nullable_to_non_nullable + as String, )); } } @@ -251,113 +221,50 @@ class __$$ProfileModelImplCopyWithImpl<$Res> @JsonSerializable() class _$ProfileModelImpl implements _ProfileModel { const _$ProfileModelImpl( - {@JsonKey(name: "user") required this.user, - @JsonKey(name: "chartPoints") required final List chartPoints, - @JsonKey(name: "userDetails") required this.userDetails, - @JsonKey(name: "circumferences") - required final List circumferences, - @JsonKey(name: "finishedPlans") - required final List finishedPlans, - @JsonKey(name: "rejectedPlans") - required final List rejectedPlans, - @JsonKey(name: "startedPlan") required final List startedPlan, - @JsonKey(name: "paidPlan") required final List paidPlan, - @JsonKey(name: "requestedPlan") - required final List requestedPlan, - @JsonKey(name: "initedPlan") required final List initedPlan}) - : _chartPoints = chartPoints, - _circumferences = circumferences, - _finishedPlans = finishedPlans, - _rejectedPlans = rejectedPlans, - _startedPlan = startedPlan, - _paidPlan = paidPlan, - _requestedPlan = requestedPlan, - _initedPlan = initedPlan; + {@JsonKey(name: "id") required this.id, + @JsonKey(name: "name") required this.name, + @JsonKey(name: "email") required this.email, + @JsonKey(name: "email_verified_at") this.emailVerifiedAt, + @JsonKey(name: "created_at") this.createdAt, + @JsonKey(name: "updated_at") this.updatedAt, + @JsonKey(name: "is_public_profile") required this.isPublicProfile, + @JsonKey(name: "slug") required this.slug, + @JsonKey(name: "profile_photo_url") required this.profilePhotoUrl}); factory _$ProfileModelImpl.fromJson(Map json) => _$$ProfileModelImplFromJson(json); @override - @JsonKey(name: "user") - final User user; - final List _chartPoints; + @JsonKey(name: "id") + final int id; @override - @JsonKey(name: "chartPoints") - List get chartPoints { - if (_chartPoints is EqualUnmodifiableListView) return _chartPoints; - // ignore: implicit_dynamic_type - return EqualUnmodifiableListView(_chartPoints); - } - + @JsonKey(name: "name") + final String name; @override - @JsonKey(name: "userDetails") - final UserDetails userDetails; - final List _circumferences; + @JsonKey(name: "email") + final String email; @override - @JsonKey(name: "circumferences") - List get circumferences { - if (_circumferences is EqualUnmodifiableListView) return _circumferences; - // ignore: implicit_dynamic_type - return EqualUnmodifiableListView(_circumferences); - } - - final List _finishedPlans; + @JsonKey(name: "email_verified_at") + final DateTime? emailVerifiedAt; @override - @JsonKey(name: "finishedPlans") - List get finishedPlans { - if (_finishedPlans is EqualUnmodifiableListView) return _finishedPlans; - // ignore: implicit_dynamic_type - return EqualUnmodifiableListView(_finishedPlans); - } - - final List _rejectedPlans; + @JsonKey(name: "created_at") + final DateTime? createdAt; @override - @JsonKey(name: "rejectedPlans") - List get rejectedPlans { - if (_rejectedPlans is EqualUnmodifiableListView) return _rejectedPlans; - // ignore: implicit_dynamic_type - return EqualUnmodifiableListView(_rejectedPlans); - } - - final List _startedPlan; + @JsonKey(name: "updated_at") + final DateTime? updatedAt; @override - @JsonKey(name: "startedPlan") - List get startedPlan { - if (_startedPlan is EqualUnmodifiableListView) return _startedPlan; - // ignore: implicit_dynamic_type - return EqualUnmodifiableListView(_startedPlan); - } - - final List _paidPlan; + @JsonKey(name: "is_public_profile") + final bool isPublicProfile; @override - @JsonKey(name: "paidPlan") - List get paidPlan { - if (_paidPlan is EqualUnmodifiableListView) return _paidPlan; - // ignore: implicit_dynamic_type - return EqualUnmodifiableListView(_paidPlan); - } - - final List _requestedPlan; + @JsonKey(name: "slug") + final String slug; @override - @JsonKey(name: "requestedPlan") - List get requestedPlan { - if (_requestedPlan is EqualUnmodifiableListView) return _requestedPlan; - // ignore: implicit_dynamic_type - return EqualUnmodifiableListView(_requestedPlan); - } - - final List _initedPlan; - @override - @JsonKey(name: "initedPlan") - List get initedPlan { - if (_initedPlan is EqualUnmodifiableListView) return _initedPlan; - // ignore: implicit_dynamic_type - return EqualUnmodifiableListView(_initedPlan); - } + @JsonKey(name: "profile_photo_url") + final String profilePhotoUrl; @override String toString() { - return 'ProfileModel(user: $user, chartPoints: $chartPoints, userDetails: $userDetails, circumferences: $circumferences, finishedPlans: $finishedPlans, rejectedPlans: $rejectedPlans, startedPlan: $startedPlan, paidPlan: $paidPlan, requestedPlan: $requestedPlan, initedPlan: $initedPlan)'; + return 'ProfileModel(id: $id, name: $name, email: $email, emailVerifiedAt: $emailVerifiedAt, createdAt: $createdAt, updatedAt: $updatedAt, isPublicProfile: $isPublicProfile, slug: $slug, profilePhotoUrl: $profilePhotoUrl)'; } @override @@ -365,42 +272,30 @@ class _$ProfileModelImpl implements _ProfileModel { return identical(this, other) || (other.runtimeType == runtimeType && other is _$ProfileModelImpl && - (identical(other.user, user) || other.user == user) && - const DeepCollectionEquality() - .equals(other._chartPoints, _chartPoints) && - (identical(other.userDetails, userDetails) || - other.userDetails == userDetails) && - const DeepCollectionEquality() - .equals(other._circumferences, _circumferences) && - const DeepCollectionEquality() - .equals(other._finishedPlans, _finishedPlans) && - const DeepCollectionEquality() - .equals(other._rejectedPlans, _rejectedPlans) && - const DeepCollectionEquality() - .equals(other._startedPlan, _startedPlan) && - const DeepCollectionEquality().equals(other._paidPlan, _paidPlan) && - const DeepCollectionEquality() - .equals(other._requestedPlan, _requestedPlan) && - const DeepCollectionEquality() - .equals(other._initedPlan, _initedPlan)); + (identical(other.id, id) || other.id == id) && + (identical(other.name, name) || other.name == name) && + (identical(other.email, email) || other.email == email) && + (identical(other.emailVerifiedAt, emailVerifiedAt) || + other.emailVerifiedAt == emailVerifiedAt) && + (identical(other.createdAt, createdAt) || + other.createdAt == createdAt) && + (identical(other.updatedAt, updatedAt) || + other.updatedAt == updatedAt) && + (identical(other.isPublicProfile, isPublicProfile) || + other.isPublicProfile == isPublicProfile) && + (identical(other.slug, slug) || other.slug == slug) && + (identical(other.profilePhotoUrl, profilePhotoUrl) || + other.profilePhotoUrl == profilePhotoUrl)); } - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) @override - int get hashCode => Object.hash( - runtimeType, - user, - const DeepCollectionEquality().hash(_chartPoints), - userDetails, - const DeepCollectionEquality().hash(_circumferences), - const DeepCollectionEquality().hash(_finishedPlans), - const DeepCollectionEquality().hash(_rejectedPlans), - const DeepCollectionEquality().hash(_startedPlan), - const DeepCollectionEquality().hash(_paidPlan), - const DeepCollectionEquality().hash(_requestedPlan), - const DeepCollectionEquality().hash(_initedPlan)); + int get hashCode => Object.hash(runtimeType, id, name, email, emailVerifiedAt, + createdAt, updatedAt, isPublicProfile, slug, profilePhotoUrl); - @JsonKey(ignore: true) + /// Create a copy of ProfileModel + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$ProfileModelImplCopyWith<_$ProfileModelImpl> get copyWith => @@ -416,803 +311,19 @@ class _$ProfileModelImpl implements _ProfileModel { abstract class _ProfileModel implements ProfileModel { const factory _ProfileModel( - {@JsonKey(name: "user") required final User user, - @JsonKey(name: "chartPoints") required final List chartPoints, - @JsonKey(name: "userDetails") required final UserDetails userDetails, - @JsonKey(name: "circumferences") - required final List circumferences, - @JsonKey(name: "finishedPlans") - required final List finishedPlans, - @JsonKey(name: "rejectedPlans") - required final List rejectedPlans, - @JsonKey(name: "startedPlan") required final List startedPlan, - @JsonKey(name: "paidPlan") required final List paidPlan, - @JsonKey(name: "requestedPlan") - required final List requestedPlan, - @JsonKey(name: "initedPlan") - required final List initedPlan}) = _$ProfileModelImpl; - - factory _ProfileModel.fromJson(Map json) = - _$ProfileModelImpl.fromJson; - - @override - @JsonKey(name: "user") - User get user; - @override - @JsonKey(name: "chartPoints") - List get chartPoints; - @override - @JsonKey(name: "userDetails") - UserDetails get userDetails; - @override - @JsonKey(name: "circumferences") - List get circumferences; - @override - @JsonKey(name: "finishedPlans") - List get finishedPlans; - @override - @JsonKey(name: "rejectedPlans") - List get rejectedPlans; - @override - @JsonKey(name: "startedPlan") - List get startedPlan; - @override - @JsonKey(name: "paidPlan") - List get paidPlan; - @override - @JsonKey(name: "requestedPlan") - List get requestedPlan; - @override - @JsonKey(name: "initedPlan") - List get initedPlan; - @override - @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; -} - -User _$UserFromJson(Map json) { - return _User.fromJson(json); -} - -/// @nodoc -mixin _$User { - @JsonKey(name: "id") - int get id => throw _privateConstructorUsedError; - @JsonKey(name: "name") - String get name => throw _privateConstructorUsedError; - @JsonKey(name: "email") - String get email => throw _privateConstructorUsedError; - @JsonKey(name: "email_verified_at") - DateTime get emailVerifiedAt => throw _privateConstructorUsedError; - @JsonKey(name: "two_factor_confirmed_at") - dynamic get twoFactorConfirmedAt => throw _privateConstructorUsedError; - @JsonKey(name: "current_team_id") - dynamic get currentTeamId => throw _privateConstructorUsedError; - @JsonKey(name: "profile_photo_path") - String get profilePhotoPath => throw _privateConstructorUsedError; - @JsonKey(name: "created_at") - DateTime get createdAt => throw _privateConstructorUsedError; - @JsonKey(name: "updated_at") - DateTime get updatedAt => throw _privateConstructorUsedError; - @JsonKey(name: "is_consultant") - int get isConsultant => throw _privateConstructorUsedError; - @JsonKey(name: "is_public_profile") - int get isPublicProfile => throw _privateConstructorUsedError; - @JsonKey(name: "slug") - String get slug => throw _privateConstructorUsedError; - @JsonKey(name: "user_settings_id") - dynamic get userSettingsId => throw _privateConstructorUsedError; - @JsonKey(name: "profile_photo_url") - String get profilePhotoUrl => throw _privateConstructorUsedError; - @JsonKey(name: "detailz") - UserDetails get detailz => throw _privateConstructorUsedError; - - Map toJson() => throw _privateConstructorUsedError; - @JsonKey(ignore: true) - $UserCopyWith get copyWith => throw _privateConstructorUsedError; -} - -/// @nodoc -abstract class $UserCopyWith<$Res> { - factory $UserCopyWith(User value, $Res Function(User) then) = - _$UserCopyWithImpl<$Res, User>; - @useResult - $Res call( - {@JsonKey(name: "id") int id, - @JsonKey(name: "name") String name, - @JsonKey(name: "email") String email, - @JsonKey(name: "email_verified_at") DateTime emailVerifiedAt, - @JsonKey(name: "two_factor_confirmed_at") dynamic twoFactorConfirmedAt, - @JsonKey(name: "current_team_id") dynamic currentTeamId, - @JsonKey(name: "profile_photo_path") String profilePhotoPath, - @JsonKey(name: "created_at") DateTime createdAt, - @JsonKey(name: "updated_at") DateTime updatedAt, - @JsonKey(name: "is_consultant") int isConsultant, - @JsonKey(name: "is_public_profile") int isPublicProfile, - @JsonKey(name: "slug") String slug, - @JsonKey(name: "user_settings_id") dynamic userSettingsId, - @JsonKey(name: "profile_photo_url") String profilePhotoUrl, - @JsonKey(name: "detailz") UserDetails detailz}); - - $UserDetailsCopyWith<$Res> get detailz; -} - -/// @nodoc -class _$UserCopyWithImpl<$Res, $Val extends User> - implements $UserCopyWith<$Res> { - _$UserCopyWithImpl(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? name = null, - Object? email = null, - Object? emailVerifiedAt = null, - Object? twoFactorConfirmedAt = freezed, - Object? currentTeamId = freezed, - Object? profilePhotoPath = null, - Object? createdAt = null, - Object? updatedAt = null, - Object? isConsultant = null, - Object? isPublicProfile = null, - Object? slug = null, - Object? userSettingsId = freezed, - Object? profilePhotoUrl = null, - Object? detailz = null, - }) { - return _then(_value.copyWith( - id: null == id - ? _value.id - : id // ignore: cast_nullable_to_non_nullable - as int, - name: null == name - ? _value.name - : name // ignore: cast_nullable_to_non_nullable - as String, - email: null == email - ? _value.email - : email // ignore: cast_nullable_to_non_nullable - as String, - emailVerifiedAt: null == emailVerifiedAt - ? _value.emailVerifiedAt - : emailVerifiedAt // ignore: cast_nullable_to_non_nullable - as DateTime, - twoFactorConfirmedAt: freezed == twoFactorConfirmedAt - ? _value.twoFactorConfirmedAt - : twoFactorConfirmedAt // ignore: cast_nullable_to_non_nullable - as dynamic, - currentTeamId: freezed == currentTeamId - ? _value.currentTeamId - : currentTeamId // ignore: cast_nullable_to_non_nullable - as dynamic, - profilePhotoPath: null == profilePhotoPath - ? _value.profilePhotoPath - : profilePhotoPath // 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, - isConsultant: null == isConsultant - ? _value.isConsultant - : isConsultant // ignore: cast_nullable_to_non_nullable - as int, - isPublicProfile: null == isPublicProfile - ? _value.isPublicProfile - : isPublicProfile // ignore: cast_nullable_to_non_nullable - as int, - slug: null == slug - ? _value.slug - : slug // ignore: cast_nullable_to_non_nullable - as String, - userSettingsId: freezed == userSettingsId - ? _value.userSettingsId - : userSettingsId // ignore: cast_nullable_to_non_nullable - as dynamic, - profilePhotoUrl: null == profilePhotoUrl - ? _value.profilePhotoUrl - : profilePhotoUrl // ignore: cast_nullable_to_non_nullable - as String, - detailz: null == detailz - ? _value.detailz - : detailz // ignore: cast_nullable_to_non_nullable - as UserDetails, - ) as $Val); - } - - @override - @pragma('vm:prefer-inline') - $UserDetailsCopyWith<$Res> get detailz { - return $UserDetailsCopyWith<$Res>(_value.detailz, (value) { - return _then(_value.copyWith(detailz: value) as $Val); - }); - } -} - -/// @nodoc -abstract class _$$UserImplCopyWith<$Res> implements $UserCopyWith<$Res> { - factory _$$UserImplCopyWith( - _$UserImpl value, $Res Function(_$UserImpl) then) = - __$$UserImplCopyWithImpl<$Res>; - @override - @useResult - $Res call( - {@JsonKey(name: "id") int id, - @JsonKey(name: "name") String name, - @JsonKey(name: "email") String email, - @JsonKey(name: "email_verified_at") DateTime emailVerifiedAt, - @JsonKey(name: "two_factor_confirmed_at") dynamic twoFactorConfirmedAt, - @JsonKey(name: "current_team_id") dynamic currentTeamId, - @JsonKey(name: "profile_photo_path") String profilePhotoPath, - @JsonKey(name: "created_at") DateTime createdAt, - @JsonKey(name: "updated_at") DateTime updatedAt, - @JsonKey(name: "is_consultant") int isConsultant, - @JsonKey(name: "is_public_profile") int isPublicProfile, - @JsonKey(name: "slug") String slug, - @JsonKey(name: "user_settings_id") dynamic userSettingsId, - @JsonKey(name: "profile_photo_url") String profilePhotoUrl, - @JsonKey(name: "detailz") UserDetails detailz}); - - @override - $UserDetailsCopyWith<$Res> get detailz; -} - -/// @nodoc -class __$$UserImplCopyWithImpl<$Res> - extends _$UserCopyWithImpl<$Res, _$UserImpl> - implements _$$UserImplCopyWith<$Res> { - __$$UserImplCopyWithImpl(_$UserImpl _value, $Res Function(_$UserImpl) _then) - : super(_value, _then); - - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? id = null, - Object? name = null, - Object? email = null, - Object? emailVerifiedAt = null, - Object? twoFactorConfirmedAt = freezed, - Object? currentTeamId = freezed, - Object? profilePhotoPath = null, - Object? createdAt = null, - Object? updatedAt = null, - Object? isConsultant = null, - Object? isPublicProfile = null, - Object? slug = null, - Object? userSettingsId = freezed, - Object? profilePhotoUrl = null, - Object? detailz = null, - }) { - return _then(_$UserImpl( - id: null == id - ? _value.id - : id // ignore: cast_nullable_to_non_nullable - as int, - name: null == name - ? _value.name - : name // ignore: cast_nullable_to_non_nullable - as String, - email: null == email - ? _value.email - : email // ignore: cast_nullable_to_non_nullable - as String, - emailVerifiedAt: null == emailVerifiedAt - ? _value.emailVerifiedAt - : emailVerifiedAt // ignore: cast_nullable_to_non_nullable - as DateTime, - twoFactorConfirmedAt: freezed == twoFactorConfirmedAt - ? _value.twoFactorConfirmedAt - : twoFactorConfirmedAt // ignore: cast_nullable_to_non_nullable - as dynamic, - currentTeamId: freezed == currentTeamId - ? _value.currentTeamId - : currentTeamId // ignore: cast_nullable_to_non_nullable - as dynamic, - profilePhotoPath: null == profilePhotoPath - ? _value.profilePhotoPath - : profilePhotoPath // 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, - isConsultant: null == isConsultant - ? _value.isConsultant - : isConsultant // ignore: cast_nullable_to_non_nullable - as int, - isPublicProfile: null == isPublicProfile - ? _value.isPublicProfile - : isPublicProfile // ignore: cast_nullable_to_non_nullable - as int, - slug: null == slug - ? _value.slug - : slug // ignore: cast_nullable_to_non_nullable - as String, - userSettingsId: freezed == userSettingsId - ? _value.userSettingsId - : userSettingsId // ignore: cast_nullable_to_non_nullable - as dynamic, - profilePhotoUrl: null == profilePhotoUrl - ? _value.profilePhotoUrl - : profilePhotoUrl // ignore: cast_nullable_to_non_nullable - as String, - detailz: null == detailz - ? _value.detailz - : detailz // ignore: cast_nullable_to_non_nullable - as UserDetails, - )); - } -} - -/// @nodoc -@JsonSerializable() -class _$UserImpl implements _User { - const _$UserImpl( - {@JsonKey(name: "id") required this.id, - @JsonKey(name: "name") required this.name, - @JsonKey(name: "email") required this.email, - @JsonKey(name: "email_verified_at") required this.emailVerifiedAt, - @JsonKey(name: "two_factor_confirmed_at") - required this.twoFactorConfirmedAt, - @JsonKey(name: "current_team_id") required this.currentTeamId, - @JsonKey(name: "profile_photo_path") required this.profilePhotoPath, - @JsonKey(name: "created_at") required this.createdAt, - @JsonKey(name: "updated_at") required this.updatedAt, - @JsonKey(name: "is_consultant") required this.isConsultant, - @JsonKey(name: "is_public_profile") required this.isPublicProfile, - @JsonKey(name: "slug") required this.slug, - @JsonKey(name: "user_settings_id") required this.userSettingsId, - @JsonKey(name: "profile_photo_url") required this.profilePhotoUrl, - @JsonKey(name: "detailz") required this.detailz}); - - factory _$UserImpl.fromJson(Map json) => - _$$UserImplFromJson(json); - - @override - @JsonKey(name: "id") - final int id; - @override - @JsonKey(name: "name") - final String name; - @override - @JsonKey(name: "email") - final String email; - @override - @JsonKey(name: "email_verified_at") - final DateTime emailVerifiedAt; - @override - @JsonKey(name: "two_factor_confirmed_at") - final dynamic twoFactorConfirmedAt; - @override - @JsonKey(name: "current_team_id") - final dynamic currentTeamId; - @override - @JsonKey(name: "profile_photo_path") - final String profilePhotoPath; - @override - @JsonKey(name: "created_at") - final DateTime createdAt; - @override - @JsonKey(name: "updated_at") - final DateTime updatedAt; - @override - @JsonKey(name: "is_consultant") - final int isConsultant; - @override - @JsonKey(name: "is_public_profile") - final int isPublicProfile; - @override - @JsonKey(name: "slug") - final String slug; - @override - @JsonKey(name: "user_settings_id") - final dynamic userSettingsId; - @override - @JsonKey(name: "profile_photo_url") - final String profilePhotoUrl; - @override - @JsonKey(name: "detailz") - final UserDetails detailz; - - @override - String toString() { - return 'User(id: $id, name: $name, email: $email, emailVerifiedAt: $emailVerifiedAt, twoFactorConfirmedAt: $twoFactorConfirmedAt, currentTeamId: $currentTeamId, profilePhotoPath: $profilePhotoPath, createdAt: $createdAt, updatedAt: $updatedAt, isConsultant: $isConsultant, isPublicProfile: $isPublicProfile, slug: $slug, userSettingsId: $userSettingsId, profilePhotoUrl: $profilePhotoUrl, detailz: $detailz)'; - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _$UserImpl && - (identical(other.id, id) || other.id == id) && - (identical(other.name, name) || other.name == name) && - (identical(other.email, email) || other.email == email) && - (identical(other.emailVerifiedAt, emailVerifiedAt) || - other.emailVerifiedAt == emailVerifiedAt) && - const DeepCollectionEquality() - .equals(other.twoFactorConfirmedAt, twoFactorConfirmedAt) && - const DeepCollectionEquality() - .equals(other.currentTeamId, currentTeamId) && - (identical(other.profilePhotoPath, profilePhotoPath) || - other.profilePhotoPath == profilePhotoPath) && - (identical(other.createdAt, createdAt) || - other.createdAt == createdAt) && - (identical(other.updatedAt, updatedAt) || - other.updatedAt == updatedAt) && - (identical(other.isConsultant, isConsultant) || - other.isConsultant == isConsultant) && - (identical(other.isPublicProfile, isPublicProfile) || - other.isPublicProfile == isPublicProfile) && - (identical(other.slug, slug) || other.slug == slug) && - const DeepCollectionEquality() - .equals(other.userSettingsId, userSettingsId) && - (identical(other.profilePhotoUrl, profilePhotoUrl) || - other.profilePhotoUrl == profilePhotoUrl) && - (identical(other.detailz, detailz) || other.detailz == detailz)); - } - - @JsonKey(ignore: true) - @override - int get hashCode => Object.hash( - runtimeType, - id, - name, - email, - emailVerifiedAt, - const DeepCollectionEquality().hash(twoFactorConfirmedAt), - const DeepCollectionEquality().hash(currentTeamId), - profilePhotoPath, - createdAt, - updatedAt, - isConsultant, - isPublicProfile, - slug, - const DeepCollectionEquality().hash(userSettingsId), - profilePhotoUrl, - detailz); - - @JsonKey(ignore: true) - @override - @pragma('vm:prefer-inline') - _$$UserImplCopyWith<_$UserImpl> get copyWith => - __$$UserImplCopyWithImpl<_$UserImpl>(this, _$identity); - - @override - Map toJson() { - return _$$UserImplToJson( - this, - ); - } -} - -abstract class _User implements User { - const factory _User( {@JsonKey(name: "id") required final int id, @JsonKey(name: "name") required final String name, @JsonKey(name: "email") required final String email, - @JsonKey(name: "email_verified_at") - required final DateTime emailVerifiedAt, - @JsonKey(name: "two_factor_confirmed_at") - required final dynamic twoFactorConfirmedAt, - @JsonKey(name: "current_team_id") required final dynamic currentTeamId, - @JsonKey(name: "profile_photo_path") - required final String profilePhotoPath, - @JsonKey(name: "created_at") required final DateTime createdAt, - @JsonKey(name: "updated_at") required final DateTime updatedAt, - @JsonKey(name: "is_consultant") required final int isConsultant, - @JsonKey(name: "is_public_profile") required final int isPublicProfile, + @JsonKey(name: "email_verified_at") final DateTime? emailVerifiedAt, + @JsonKey(name: "created_at") final DateTime? createdAt, + @JsonKey(name: "updated_at") final DateTime? updatedAt, + @JsonKey(name: "is_public_profile") required final bool isPublicProfile, @JsonKey(name: "slug") required final String slug, - @JsonKey(name: "user_settings_id") required final dynamic userSettingsId, - @JsonKey(name: "profile_photo_url") required final String profilePhotoUrl, - @JsonKey(name: "detailz") - required final UserDetails detailz}) = _$UserImpl; + @JsonKey(name: "profile_photo_url") + required final String profilePhotoUrl}) = _$ProfileModelImpl; - factory _User.fromJson(Map json) = _$UserImpl.fromJson; + factory _ProfileModel.fromJson(Map json) = + _$ProfileModelImpl.fromJson; @override @JsonKey(name: "id") @@ -1225,62 +336,43 @@ abstract class _User implements User { String get email; @override @JsonKey(name: "email_verified_at") - DateTime get emailVerifiedAt; - @override - @JsonKey(name: "two_factor_confirmed_at") - dynamic get twoFactorConfirmedAt; - @override - @JsonKey(name: "current_team_id") - dynamic get currentTeamId; - @override - @JsonKey(name: "profile_photo_path") - String get profilePhotoPath; + DateTime? get emailVerifiedAt; @override @JsonKey(name: "created_at") - DateTime get createdAt; + DateTime? get createdAt; @override @JsonKey(name: "updated_at") - DateTime get updatedAt; - @override - @JsonKey(name: "is_consultant") - int get isConsultant; + DateTime? get updatedAt; @override @JsonKey(name: "is_public_profile") - int get isPublicProfile; + bool get isPublicProfile; @override @JsonKey(name: "slug") String get slug; @override - @JsonKey(name: "user_settings_id") - dynamic get userSettingsId; - @override @JsonKey(name: "profile_photo_url") String get profilePhotoUrl; + + /// Create a copy of ProfileModel + /// with the given fields replaced by the non-null parameter values. @override - @JsonKey(name: "detailz") - UserDetails get detailz; - @override - @JsonKey(ignore: true) - _$$UserImplCopyWith<_$UserImpl> get copyWith => + @JsonKey(includeFromJson: false, includeToJson: false) + _$$ProfileModelImplCopyWith<_$ProfileModelImpl> get copyWith => throw _privateConstructorUsedError; } -UserDetails _$UserDetailsFromJson(Map json) { - return _UserDetails.fromJson(json); +ProfileDetailsModel _$ProfileDetailsModelFromJson(Map json) { + return _ProfileDetailsModel.fromJson(json); } /// @nodoc -mixin _$UserDetails { - @JsonKey(name: "id") - int get id => throw _privateConstructorUsedError; - @JsonKey(name: "user_id") - int get userId => throw _privateConstructorUsedError; +mixin _$ProfileDetailsModel { @JsonKey(name: "first_name") String get firstName => throw _privateConstructorUsedError; @JsonKey(name: "last_name") String get lastName => throw _privateConstructorUsedError; @JsonKey(name: "birthdate") - DateTime get birthdate => throw _privateConstructorUsedError; + String get birthdate => throw _privateConstructorUsedError; @JsonKey(name: "gender") String get gender => throw _privateConstructorUsedError; @JsonKey(name: "country") @@ -1290,7 +382,7 @@ mixin _$UserDetails { @JsonKey(name: "lang") String get lang => throw _privateConstructorUsedError; @JsonKey(name: "weight") - int get weight => throw _privateConstructorUsedError; + double get weight => throw _privateConstructorUsedError; @JsonKey(name: "height") int get height => throw _privateConstructorUsedError; @JsonKey(name: "chest_circumference") @@ -1304,9 +396,9 @@ mixin _$UserDetails { @JsonKey(name: "blood_pressure_down") int get bloodPressureDown => throw _privateConstructorUsedError; @JsonKey(name: "has_hypo") - int get hasHypo => throw _privateConstructorUsedError; + bool get hasHypo => throw _privateConstructorUsedError; @JsonKey(name: "has_hyper") - int get hasHyper => throw _privateConstructorUsedError; + bool get hasHyper => throw _privateConstructorUsedError; @JsonKey(name: "about_alergy") String get aboutAlergy => throw _privateConstructorUsedError; @JsonKey(name: "about_taking_pils") @@ -1320,75 +412,77 @@ mixin _$UserDetails { @JsonKey(name: "additional_info") String get additionalInfo => throw _privateConstructorUsedError; @JsonKey(name: "created_at") - DateTime get createdAt => throw _privateConstructorUsedError; + DateTime? get createdAt => throw _privateConstructorUsedError; @JsonKey(name: "updated_at") - DateTime get updatedAt => throw _privateConstructorUsedError; + DateTime? get updatedAt => throw _privateConstructorUsedError; @JsonKey(name: "is_mood_fillable") - int get isMoodFillable => throw _privateConstructorUsedError; + bool get isMoodFillable => throw _privateConstructorUsedError; @JsonKey(name: "is_bedtime_fillable") - int get isBedtimeFillable => throw _privateConstructorUsedError; + bool get isBedtimeFillable => throw _privateConstructorUsedError; @JsonKey(name: "activity_coefficient") double get activityCoefficient => throw _privateConstructorUsedError; + /// Serializes this ProfileDetailsModel to a JSON map. Map toJson() => throw _privateConstructorUsedError; - @JsonKey(ignore: true) - $UserDetailsCopyWith get copyWith => + + /// Create a copy of ProfileDetailsModel + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $ProfileDetailsModelCopyWith get copyWith => throw _privateConstructorUsedError; } /// @nodoc -abstract class $UserDetailsCopyWith<$Res> { - factory $UserDetailsCopyWith( - UserDetails value, $Res Function(UserDetails) then) = - _$UserDetailsCopyWithImpl<$Res, UserDetails>; +abstract class $ProfileDetailsModelCopyWith<$Res> { + factory $ProfileDetailsModelCopyWith( + ProfileDetailsModel value, $Res Function(ProfileDetailsModel) then) = + _$ProfileDetailsModelCopyWithImpl<$Res, ProfileDetailsModel>; @useResult $Res call( - {@JsonKey(name: "id") int id, - @JsonKey(name: "user_id") int userId, - @JsonKey(name: "first_name") String firstName, + {@JsonKey(name: "first_name") String firstName, @JsonKey(name: "last_name") String lastName, - @JsonKey(name: "birthdate") DateTime birthdate, + @JsonKey(name: "birthdate") String birthdate, @JsonKey(name: "gender") String gender, @JsonKey(name: "country") String country, @JsonKey(name: "city") String city, @JsonKey(name: "lang") String lang, - @JsonKey(name: "weight") int weight, + @JsonKey(name: "weight") double weight, @JsonKey(name: "height") int height, @JsonKey(name: "chest_circumference") int chestCircumference, @JsonKey(name: "waist_circumference") int waistCircumference, @JsonKey(name: "hip_circumference") int hipCircumference, @JsonKey(name: "blood_pressure_up") int bloodPressureUp, @JsonKey(name: "blood_pressure_down") int bloodPressureDown, - @JsonKey(name: "has_hypo") int hasHypo, - @JsonKey(name: "has_hyper") int hasHyper, + @JsonKey(name: "has_hypo") bool hasHypo, + @JsonKey(name: "has_hyper") bool hasHyper, @JsonKey(name: "about_alergy") String aboutAlergy, @JsonKey(name: "about_taking_pils") String aboutTakingPils, @JsonKey(name: "about_sport_hobbies") String aboutSportHobbies, @JsonKey(name: "favorite_foods") String favoriteFoods, @JsonKey(name: "unfavorite_foods") String unfavoriteFoods, @JsonKey(name: "additional_info") String additionalInfo, - @JsonKey(name: "created_at") DateTime createdAt, - @JsonKey(name: "updated_at") DateTime updatedAt, - @JsonKey(name: "is_mood_fillable") int isMoodFillable, - @JsonKey(name: "is_bedtime_fillable") int isBedtimeFillable, + @JsonKey(name: "created_at") DateTime? createdAt, + @JsonKey(name: "updated_at") DateTime? updatedAt, + @JsonKey(name: "is_mood_fillable") bool isMoodFillable, + @JsonKey(name: "is_bedtime_fillable") bool isBedtimeFillable, @JsonKey(name: "activity_coefficient") double activityCoefficient}); } /// @nodoc -class _$UserDetailsCopyWithImpl<$Res, $Val extends UserDetails> - implements $UserDetailsCopyWith<$Res> { - _$UserDetailsCopyWithImpl(this._value, this._then); +class _$ProfileDetailsModelCopyWithImpl<$Res, $Val extends ProfileDetailsModel> + implements $ProfileDetailsModelCopyWith<$Res> { + _$ProfileDetailsModelCopyWithImpl(this._value, this._then); // ignore: unused_field final $Val _value; // ignore: unused_field final $Res Function($Val) _then; + /// Create a copy of ProfileDetailsModel + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ - Object? id = null, - Object? userId = null, Object? firstName = null, Object? lastName = null, Object? birthdate = null, @@ -1411,21 +505,13 @@ class _$UserDetailsCopyWithImpl<$Res, $Val extends UserDetails> Object? favoriteFoods = null, Object? unfavoriteFoods = null, Object? additionalInfo = null, - Object? createdAt = null, - Object? updatedAt = null, + Object? createdAt = freezed, + Object? updatedAt = freezed, Object? isMoodFillable = null, Object? isBedtimeFillable = null, Object? activityCoefficient = 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, firstName: null == firstName ? _value.firstName : firstName // ignore: cast_nullable_to_non_nullable @@ -1437,7 +523,7 @@ class _$UserDetailsCopyWithImpl<$Res, $Val extends UserDetails> birthdate: null == birthdate ? _value.birthdate : birthdate // ignore: cast_nullable_to_non_nullable - as DateTime, + as String, gender: null == gender ? _value.gender : gender // ignore: cast_nullable_to_non_nullable @@ -1457,7 +543,7 @@ class _$UserDetailsCopyWithImpl<$Res, $Val extends UserDetails> weight: null == weight ? _value.weight : weight // ignore: cast_nullable_to_non_nullable - as int, + as double, height: null == height ? _value.height : height // ignore: cast_nullable_to_non_nullable @@ -1485,11 +571,11 @@ class _$UserDetailsCopyWithImpl<$Res, $Val extends UserDetails> hasHypo: null == hasHypo ? _value.hasHypo : hasHypo // ignore: cast_nullable_to_non_nullable - as int, + as bool, hasHyper: null == hasHyper ? _value.hasHyper : hasHyper // ignore: cast_nullable_to_non_nullable - as int, + as bool, aboutAlergy: null == aboutAlergy ? _value.aboutAlergy : aboutAlergy // ignore: cast_nullable_to_non_nullable @@ -1514,22 +600,22 @@ class _$UserDetailsCopyWithImpl<$Res, $Val extends UserDetails> ? _value.additionalInfo : additionalInfo // ignore: cast_nullable_to_non_nullable as String, - createdAt: null == createdAt + createdAt: freezed == createdAt ? _value.createdAt : createdAt // ignore: cast_nullable_to_non_nullable - as DateTime, - updatedAt: null == updatedAt + as DateTime?, + updatedAt: freezed == updatedAt ? _value.updatedAt : updatedAt // ignore: cast_nullable_to_non_nullable - as DateTime, + as DateTime?, isMoodFillable: null == isMoodFillable ? _value.isMoodFillable : isMoodFillable // ignore: cast_nullable_to_non_nullable - as int, + as bool, isBedtimeFillable: null == isBedtimeFillable ? _value.isBedtimeFillable : isBedtimeFillable // ignore: cast_nullable_to_non_nullable - as int, + as bool, activityCoefficient: null == activityCoefficient ? _value.activityCoefficient : activityCoefficient // ignore: cast_nullable_to_non_nullable @@ -1539,58 +625,56 @@ class _$UserDetailsCopyWithImpl<$Res, $Val extends UserDetails> } /// @nodoc -abstract class _$$UserDetailsImplCopyWith<$Res> - implements $UserDetailsCopyWith<$Res> { - factory _$$UserDetailsImplCopyWith( - _$UserDetailsImpl value, $Res Function(_$UserDetailsImpl) then) = - __$$UserDetailsImplCopyWithImpl<$Res>; +abstract class _$$ProfileDetailsModelImplCopyWith<$Res> + implements $ProfileDetailsModelCopyWith<$Res> { + factory _$$ProfileDetailsModelImplCopyWith(_$ProfileDetailsModelImpl value, + $Res Function(_$ProfileDetailsModelImpl) then) = + __$$ProfileDetailsModelImplCopyWithImpl<$Res>; @override @useResult $Res call( - {@JsonKey(name: "id") int id, - @JsonKey(name: "user_id") int userId, - @JsonKey(name: "first_name") String firstName, + {@JsonKey(name: "first_name") String firstName, @JsonKey(name: "last_name") String lastName, - @JsonKey(name: "birthdate") DateTime birthdate, + @JsonKey(name: "birthdate") String birthdate, @JsonKey(name: "gender") String gender, @JsonKey(name: "country") String country, @JsonKey(name: "city") String city, @JsonKey(name: "lang") String lang, - @JsonKey(name: "weight") int weight, + @JsonKey(name: "weight") double weight, @JsonKey(name: "height") int height, @JsonKey(name: "chest_circumference") int chestCircumference, @JsonKey(name: "waist_circumference") int waistCircumference, @JsonKey(name: "hip_circumference") int hipCircumference, @JsonKey(name: "blood_pressure_up") int bloodPressureUp, @JsonKey(name: "blood_pressure_down") int bloodPressureDown, - @JsonKey(name: "has_hypo") int hasHypo, - @JsonKey(name: "has_hyper") int hasHyper, + @JsonKey(name: "has_hypo") bool hasHypo, + @JsonKey(name: "has_hyper") bool hasHyper, @JsonKey(name: "about_alergy") String aboutAlergy, @JsonKey(name: "about_taking_pils") String aboutTakingPils, @JsonKey(name: "about_sport_hobbies") String aboutSportHobbies, @JsonKey(name: "favorite_foods") String favoriteFoods, @JsonKey(name: "unfavorite_foods") String unfavoriteFoods, @JsonKey(name: "additional_info") String additionalInfo, - @JsonKey(name: "created_at") DateTime createdAt, - @JsonKey(name: "updated_at") DateTime updatedAt, - @JsonKey(name: "is_mood_fillable") int isMoodFillable, - @JsonKey(name: "is_bedtime_fillable") int isBedtimeFillable, + @JsonKey(name: "created_at") DateTime? createdAt, + @JsonKey(name: "updated_at") DateTime? updatedAt, + @JsonKey(name: "is_mood_fillable") bool isMoodFillable, + @JsonKey(name: "is_bedtime_fillable") bool isBedtimeFillable, @JsonKey(name: "activity_coefficient") double activityCoefficient}); } /// @nodoc -class __$$UserDetailsImplCopyWithImpl<$Res> - extends _$UserDetailsCopyWithImpl<$Res, _$UserDetailsImpl> - implements _$$UserDetailsImplCopyWith<$Res> { - __$$UserDetailsImplCopyWithImpl( - _$UserDetailsImpl _value, $Res Function(_$UserDetailsImpl) _then) +class __$$ProfileDetailsModelImplCopyWithImpl<$Res> + extends _$ProfileDetailsModelCopyWithImpl<$Res, _$ProfileDetailsModelImpl> + implements _$$ProfileDetailsModelImplCopyWith<$Res> { + __$$ProfileDetailsModelImplCopyWithImpl(_$ProfileDetailsModelImpl _value, + $Res Function(_$ProfileDetailsModelImpl) _then) : super(_value, _then); + /// Create a copy of ProfileDetailsModel + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ - Object? id = null, - Object? userId = null, Object? firstName = null, Object? lastName = null, Object? birthdate = null, @@ -1613,21 +697,13 @@ class __$$UserDetailsImplCopyWithImpl<$Res> Object? favoriteFoods = null, Object? unfavoriteFoods = null, Object? additionalInfo = null, - Object? createdAt = null, - Object? updatedAt = null, + Object? createdAt = freezed, + Object? updatedAt = freezed, Object? isMoodFillable = null, Object? isBedtimeFillable = null, Object? activityCoefficient = null, }) { - return _then(_$UserDetailsImpl( - 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, + return _then(_$ProfileDetailsModelImpl( firstName: null == firstName ? _value.firstName : firstName // ignore: cast_nullable_to_non_nullable @@ -1639,7 +715,7 @@ class __$$UserDetailsImplCopyWithImpl<$Res> birthdate: null == birthdate ? _value.birthdate : birthdate // ignore: cast_nullable_to_non_nullable - as DateTime, + as String, gender: null == gender ? _value.gender : gender // ignore: cast_nullable_to_non_nullable @@ -1659,7 +735,7 @@ class __$$UserDetailsImplCopyWithImpl<$Res> weight: null == weight ? _value.weight : weight // ignore: cast_nullable_to_non_nullable - as int, + as double, height: null == height ? _value.height : height // ignore: cast_nullable_to_non_nullable @@ -1687,11 +763,11 @@ class __$$UserDetailsImplCopyWithImpl<$Res> hasHypo: null == hasHypo ? _value.hasHypo : hasHypo // ignore: cast_nullable_to_non_nullable - as int, + as bool, hasHyper: null == hasHyper ? _value.hasHyper : hasHyper // ignore: cast_nullable_to_non_nullable - as int, + as bool, aboutAlergy: null == aboutAlergy ? _value.aboutAlergy : aboutAlergy // ignore: cast_nullable_to_non_nullable @@ -1716,22 +792,22 @@ class __$$UserDetailsImplCopyWithImpl<$Res> ? _value.additionalInfo : additionalInfo // ignore: cast_nullable_to_non_nullable as String, - createdAt: null == createdAt + createdAt: freezed == createdAt ? _value.createdAt : createdAt // ignore: cast_nullable_to_non_nullable - as DateTime, - updatedAt: null == updatedAt + as DateTime?, + updatedAt: freezed == updatedAt ? _value.updatedAt : updatedAt // ignore: cast_nullable_to_non_nullable - as DateTime, + as DateTime?, isMoodFillable: null == isMoodFillable ? _value.isMoodFillable : isMoodFillable // ignore: cast_nullable_to_non_nullable - as int, + as bool, isBedtimeFillable: null == isBedtimeFillable ? _value.isBedtimeFillable : isBedtimeFillable // ignore: cast_nullable_to_non_nullable - as int, + as bool, activityCoefficient: null == activityCoefficient ? _value.activityCoefficient : activityCoefficient // ignore: cast_nullable_to_non_nullable @@ -1742,11 +818,9 @@ class __$$UserDetailsImplCopyWithImpl<$Res> /// @nodoc @JsonSerializable() -class _$UserDetailsImpl implements _UserDetails { - const _$UserDetailsImpl( - {@JsonKey(name: "id") required this.id, - @JsonKey(name: "user_id") required this.userId, - @JsonKey(name: "first_name") required this.firstName, +class _$ProfileDetailsModelImpl implements _ProfileDetailsModel { + const _$ProfileDetailsModelImpl( + {@JsonKey(name: "first_name") required this.firstName, @JsonKey(name: "last_name") required this.lastName, @JsonKey(name: "birthdate") required this.birthdate, @JsonKey(name: "gender") required this.gender, @@ -1768,22 +842,16 @@ class _$UserDetailsImpl implements _UserDetails { @JsonKey(name: "favorite_foods") required this.favoriteFoods, @JsonKey(name: "unfavorite_foods") required this.unfavoriteFoods, @JsonKey(name: "additional_info") required this.additionalInfo, - @JsonKey(name: "created_at") required this.createdAt, - @JsonKey(name: "updated_at") required this.updatedAt, + @JsonKey(name: "created_at") this.createdAt, + @JsonKey(name: "updated_at") this.updatedAt, @JsonKey(name: "is_mood_fillable") required this.isMoodFillable, @JsonKey(name: "is_bedtime_fillable") required this.isBedtimeFillable, @JsonKey(name: "activity_coefficient") required this.activityCoefficient}); - factory _$UserDetailsImpl.fromJson(Map json) => - _$$UserDetailsImplFromJson(json); + factory _$ProfileDetailsModelImpl.fromJson(Map json) => + _$$ProfileDetailsModelImplFromJson(json); - @override - @JsonKey(name: "id") - final int id; - @override - @JsonKey(name: "user_id") - final int userId; @override @JsonKey(name: "first_name") final String firstName; @@ -1792,7 +860,7 @@ class _$UserDetailsImpl implements _UserDetails { final String lastName; @override @JsonKey(name: "birthdate") - final DateTime birthdate; + final String birthdate; @override @JsonKey(name: "gender") final String gender; @@ -1807,7 +875,7 @@ class _$UserDetailsImpl implements _UserDetails { final String lang; @override @JsonKey(name: "weight") - final int weight; + final double weight; @override @JsonKey(name: "height") final int height; @@ -1828,10 +896,10 @@ class _$UserDetailsImpl implements _UserDetails { final int bloodPressureDown; @override @JsonKey(name: "has_hypo") - final int hasHypo; + final bool hasHypo; @override @JsonKey(name: "has_hyper") - final int hasHyper; + final bool hasHyper; @override @JsonKey(name: "about_alergy") final String aboutAlergy; @@ -1852,32 +920,30 @@ class _$UserDetailsImpl implements _UserDetails { final String additionalInfo; @override @JsonKey(name: "created_at") - final DateTime createdAt; + final DateTime? createdAt; @override @JsonKey(name: "updated_at") - final DateTime updatedAt; + final DateTime? updatedAt; @override @JsonKey(name: "is_mood_fillable") - final int isMoodFillable; + final bool isMoodFillable; @override @JsonKey(name: "is_bedtime_fillable") - final int isBedtimeFillable; + final bool isBedtimeFillable; @override @JsonKey(name: "activity_coefficient") final double activityCoefficient; @override String toString() { - return 'UserDetails(id: $id, userId: $userId, firstName: $firstName, lastName: $lastName, birthdate: $birthdate, gender: $gender, country: $country, city: $city, lang: $lang, weight: $weight, height: $height, chestCircumference: $chestCircumference, waistCircumference: $waistCircumference, hipCircumference: $hipCircumference, bloodPressureUp: $bloodPressureUp, bloodPressureDown: $bloodPressureDown, hasHypo: $hasHypo, hasHyper: $hasHyper, aboutAlergy: $aboutAlergy, aboutTakingPils: $aboutTakingPils, aboutSportHobbies: $aboutSportHobbies, favoriteFoods: $favoriteFoods, unfavoriteFoods: $unfavoriteFoods, additionalInfo: $additionalInfo, createdAt: $createdAt, updatedAt: $updatedAt, isMoodFillable: $isMoodFillable, isBedtimeFillable: $isBedtimeFillable, activityCoefficient: $activityCoefficient)'; + return 'ProfileDetailsModel(firstName: $firstName, lastName: $lastName, birthdate: $birthdate, gender: $gender, country: $country, city: $city, lang: $lang, weight: $weight, height: $height, chestCircumference: $chestCircumference, waistCircumference: $waistCircumference, hipCircumference: $hipCircumference, bloodPressureUp: $bloodPressureUp, bloodPressureDown: $bloodPressureDown, hasHypo: $hasHypo, hasHyper: $hasHyper, aboutAlergy: $aboutAlergy, aboutTakingPils: $aboutTakingPils, aboutSportHobbies: $aboutSportHobbies, favoriteFoods: $favoriteFoods, unfavoriteFoods: $unfavoriteFoods, additionalInfo: $additionalInfo, createdAt: $createdAt, updatedAt: $updatedAt, isMoodFillable: $isMoodFillable, isBedtimeFillable: $isBedtimeFillable, activityCoefficient: $activityCoefficient)'; } @override bool operator ==(Object other) { return identical(this, other) || (other.runtimeType == runtimeType && - other is _$UserDetailsImpl && - (identical(other.id, id) || other.id == id) && - (identical(other.userId, userId) || other.userId == userId) && + other is _$ProfileDetailsModelImpl && (identical(other.firstName, firstName) || other.firstName == firstName) && (identical(other.lastName, lastName) || @@ -1927,12 +993,10 @@ class _$UserDetailsImpl implements _UserDetails { other.activityCoefficient == activityCoefficient)); } - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) @override int get hashCode => Object.hashAll([ runtimeType, - id, - userId, firstName, lastName, birthdate, @@ -1962,32 +1026,33 @@ class _$UserDetailsImpl implements _UserDetails { activityCoefficient ]); - @JsonKey(ignore: true) + /// Create a copy of ProfileDetailsModel + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') - _$$UserDetailsImplCopyWith<_$UserDetailsImpl> get copyWith => - __$$UserDetailsImplCopyWithImpl<_$UserDetailsImpl>(this, _$identity); + _$$ProfileDetailsModelImplCopyWith<_$ProfileDetailsModelImpl> get copyWith => + __$$ProfileDetailsModelImplCopyWithImpl<_$ProfileDetailsModelImpl>( + this, _$identity); @override Map toJson() { - return _$$UserDetailsImplToJson( + return _$$ProfileDetailsModelImplToJson( this, ); } } -abstract class _UserDetails implements UserDetails { - const factory _UserDetails( - {@JsonKey(name: "id") required final int id, - @JsonKey(name: "user_id") required final int userId, - @JsonKey(name: "first_name") required final String firstName, +abstract class _ProfileDetailsModel implements ProfileDetailsModel { + const factory _ProfileDetailsModel( + {@JsonKey(name: "first_name") required final String firstName, @JsonKey(name: "last_name") required final String lastName, - @JsonKey(name: "birthdate") required final DateTime birthdate, + @JsonKey(name: "birthdate") required final String birthdate, @JsonKey(name: "gender") required final String gender, @JsonKey(name: "country") required final String country, @JsonKey(name: "city") required final String city, @JsonKey(name: "lang") required final String lang, - @JsonKey(name: "weight") required final int weight, + @JsonKey(name: "weight") required final double weight, @JsonKey(name: "height") required final int height, @JsonKey(name: "chest_circumference") required final int chestCircumference, @@ -1997,8 +1062,8 @@ abstract class _UserDetails implements UserDetails { @JsonKey(name: "blood_pressure_up") required final int bloodPressureUp, @JsonKey(name: "blood_pressure_down") required final int bloodPressureDown, - @JsonKey(name: "has_hypo") required final int hasHypo, - @JsonKey(name: "has_hyper") required final int hasHyper, + @JsonKey(name: "has_hypo") required final bool hasHypo, + @JsonKey(name: "has_hyper") required final bool hasHyper, @JsonKey(name: "about_alergy") required final String aboutAlergy, @JsonKey(name: "about_taking_pils") required final String aboutTakingPils, @JsonKey(name: "about_sport_hobbies") @@ -2006,23 +1071,17 @@ abstract class _UserDetails implements UserDetails { @JsonKey(name: "favorite_foods") required final String favoriteFoods, @JsonKey(name: "unfavorite_foods") required final String unfavoriteFoods, @JsonKey(name: "additional_info") required final String additionalInfo, - @JsonKey(name: "created_at") required final DateTime createdAt, - @JsonKey(name: "updated_at") required final DateTime updatedAt, - @JsonKey(name: "is_mood_fillable") required final int isMoodFillable, + @JsonKey(name: "created_at") final DateTime? createdAt, + @JsonKey(name: "updated_at") final DateTime? updatedAt, + @JsonKey(name: "is_mood_fillable") required final bool isMoodFillable, @JsonKey(name: "is_bedtime_fillable") - required final int isBedtimeFillable, + required final bool isBedtimeFillable, @JsonKey(name: "activity_coefficient") - required final double activityCoefficient}) = _$UserDetailsImpl; + required final double activityCoefficient}) = _$ProfileDetailsModelImpl; - factory _UserDetails.fromJson(Map json) = - _$UserDetailsImpl.fromJson; + factory _ProfileDetailsModel.fromJson(Map json) = + _$ProfileDetailsModelImpl.fromJson; - @override - @JsonKey(name: "id") - int get id; - @override - @JsonKey(name: "user_id") - int get userId; @override @JsonKey(name: "first_name") String get firstName; @@ -2031,7 +1090,7 @@ abstract class _UserDetails implements UserDetails { String get lastName; @override @JsonKey(name: "birthdate") - DateTime get birthdate; + String get birthdate; @override @JsonKey(name: "gender") String get gender; @@ -2046,7 +1105,7 @@ abstract class _UserDetails implements UserDetails { String get lang; @override @JsonKey(name: "weight") - int get weight; + double get weight; @override @JsonKey(name: "height") int get height; @@ -2067,10 +1126,10 @@ abstract class _UserDetails implements UserDetails { int get bloodPressureDown; @override @JsonKey(name: "has_hypo") - int get hasHypo; + bool get hasHypo; @override @JsonKey(name: "has_hyper") - int get hasHyper; + bool get hasHyper; @override @JsonKey(name: "about_alergy") String get aboutAlergy; @@ -2091,283 +1150,24 @@ abstract class _UserDetails implements UserDetails { String get additionalInfo; @override @JsonKey(name: "created_at") - DateTime get createdAt; + DateTime? get createdAt; @override @JsonKey(name: "updated_at") - DateTime get updatedAt; + DateTime? get updatedAt; @override @JsonKey(name: "is_mood_fillable") - int get isMoodFillable; + bool get isMoodFillable; @override @JsonKey(name: "is_bedtime_fillable") - int get isBedtimeFillable; + bool get isBedtimeFillable; @override @JsonKey(name: "activity_coefficient") double get activityCoefficient; + + /// Create a copy of ProfileDetailsModel + /// with the given fields replaced by the non-null parameter values. @override - @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 => + @JsonKey(includeFromJson: false, includeToJson: false) + _$$ProfileDetailsModelImplCopyWith<_$ProfileDetailsModelImpl> 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 af1c1c4d..28e10ccf 100644 --- a/lib/features/profile/models/profile_model.g.dart +++ b/lib/features/profile/models/profile_model.g.dart @@ -8,136 +8,78 @@ part of 'profile_model.dart'; _$ProfileModelImpl _$$ProfileModelImplFromJson(Map json) => _$ProfileModelImpl( - user: User.fromJson(json['user'] as Map), - 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) - .map((e) => Circumference.fromJson(e as Map)) - .toList(), - finishedPlans: json['finishedPlans'] as List, - rejectedPlans: json['rejectedPlans'] as List, - startedPlan: json['startedPlan'] as List, - paidPlan: json['paidPlan'] as List, - requestedPlan: json['requestedPlan'] as List, - initedPlan: json['initedPlan'] as List, + id: (json['id'] as num).toInt(), + name: json['name'] as String, + email: json['email'] as String, + emailVerifiedAt: json['email_verified_at'] == null + ? null + : DateTime.parse(json['email_verified_at'] as String), + createdAt: json['created_at'] == null + ? null + : DateTime.parse(json['created_at'] as String), + updatedAt: json['updated_at'] == null + ? null + : DateTime.parse(json['updated_at'] as String), + isPublicProfile: json['is_public_profile'] as bool, + slug: json['slug'] as String, + profilePhotoUrl: json['profile_photo_url'] as String, ); Map _$$ProfileModelImplToJson(_$ProfileModelImpl instance) => - { - 'user': instance.user, - 'chartPoints': instance.chartPoints, - 'userDetails': instance.userDetails, - 'circumferences': instance.circumferences, - 'finishedPlans': instance.finishedPlans, - 'rejectedPlans': instance.rejectedPlans, - 'startedPlan': instance.startedPlan, - 'paidPlan': instance.paidPlan, - 'requestedPlan': instance.requestedPlan, - '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, - email: json['email'] as String, - emailVerifiedAt: DateTime.parse(json['email_verified_at'] as String), - twoFactorConfirmedAt: json['two_factor_confirmed_at'], - currentTeamId: json['current_team_id'], - profilePhotoPath: json['profile_photo_path'] as String, - createdAt: DateTime.parse(json['created_at'] as String), - updatedAt: DateTime.parse(json['updated_at'] as String), - isConsultant: (json['is_consultant'] as num).toInt(), - isPublicProfile: (json['is_public_profile'] as num).toInt(), - slug: json['slug'] as String, - userSettingsId: json['user_settings_id'], - profilePhotoUrl: json['profile_photo_url'] as String, - detailz: UserDetails.fromJson(json['detailz'] as Map), - ); - -Map _$$UserImplToJson(_$UserImpl instance) => { 'id': instance.id, 'name': instance.name, 'email': instance.email, - 'email_verified_at': instance.emailVerifiedAt.toIso8601String(), - 'two_factor_confirmed_at': instance.twoFactorConfirmedAt, - 'current_team_id': instance.currentTeamId, - 'profile_photo_path': instance.profilePhotoPath, - 'created_at': instance.createdAt.toIso8601String(), - 'updated_at': instance.updatedAt.toIso8601String(), - 'is_consultant': instance.isConsultant, + 'email_verified_at': instance.emailVerifiedAt?.toIso8601String(), + 'created_at': instance.createdAt?.toIso8601String(), + 'updated_at': instance.updatedAt?.toIso8601String(), 'is_public_profile': instance.isPublicProfile, 'slug': instance.slug, - 'user_settings_id': instance.userSettingsId, 'profile_photo_url': instance.profilePhotoUrl, - 'detailz': instance.detailz, }; -_$UserDetailsImpl _$$UserDetailsImplFromJson(Map json) => - _$UserDetailsImpl( - id: (json['id'] as num).toInt(), - userId: (json['user_id'] as num).toInt(), +_$ProfileDetailsModelImpl _$$ProfileDetailsModelImplFromJson( + Map json) => + _$ProfileDetailsModelImpl( firstName: json['first_name'] as String, lastName: json['last_name'] as String, - birthdate: DateTime.parse(json['birthdate'] as String), + birthdate: json['birthdate'] as String, gender: json['gender'] as String, country: json['country'] as String, city: json['city'] as String, lang: json['lang'] as String, - weight: (json['weight'] as num).toInt(), + weight: (json['weight'] as num).toDouble(), height: (json['height'] as num).toInt(), chestCircumference: (json['chest_circumference'] as num).toInt(), waistCircumference: (json['waist_circumference'] as num).toInt(), hipCircumference: (json['hip_circumference'] as num).toInt(), bloodPressureUp: (json['blood_pressure_up'] as num).toInt(), bloodPressureDown: (json['blood_pressure_down'] as num).toInt(), - hasHypo: (json['has_hypo'] as num).toInt(), - hasHyper: (json['has_hyper'] as num).toInt(), + hasHypo: json['has_hypo'] as bool, + hasHyper: json['has_hyper'] as bool, aboutAlergy: json['about_alergy'] as String, aboutTakingPils: json['about_taking_pils'] as String, aboutSportHobbies: json['about_sport_hobbies'] as String, favoriteFoods: json['favorite_foods'] as String, unfavoriteFoods: json['unfavorite_foods'] as String, additionalInfo: json['additional_info'] as String, - createdAt: DateTime.parse(json['created_at'] as String), - updatedAt: DateTime.parse(json['updated_at'] as String), - isMoodFillable: (json['is_mood_fillable'] as num).toInt(), - isBedtimeFillable: (json['is_bedtime_fillable'] as num).toInt(), + createdAt: json['created_at'] == null + ? null + : DateTime.parse(json['created_at'] as String), + updatedAt: json['updated_at'] == null + ? null + : DateTime.parse(json['updated_at'] as String), + isMoodFillable: json['is_mood_fillable'] as bool, + isBedtimeFillable: json['is_bedtime_fillable'] as bool, activityCoefficient: (json['activity_coefficient'] as num).toDouble(), ); -Map _$$UserDetailsImplToJson(_$UserDetailsImpl instance) => +Map _$$ProfileDetailsModelImplToJson( + _$ProfileDetailsModelImpl instance) => { - 'id': instance.id, - 'user_id': instance.userId, 'first_name': instance.firstName, 'last_name': instance.lastName, - 'birthdate': instance.birthdate.toIso8601String(), + 'birthdate': instance.birthdate, 'gender': instance.gender, 'country': instance.country, 'city': instance.city, @@ -157,29 +99,9 @@ Map _$$UserDetailsImplToJson(_$UserDetailsImpl instance) => 'favorite_foods': instance.favoriteFoods, 'unfavorite_foods': instance.unfavoriteFoods, 'additional_info': instance.additionalInfo, - 'created_at': instance.createdAt.toIso8601String(), - 'updated_at': instance.updatedAt.toIso8601String(), + 'created_at': instance.createdAt?.toIso8601String(), + 'updated_at': instance.updatedAt?.toIso8601String(), 'is_mood_fillable': instance.isMoodFillable, '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/models/weight_model.dart b/lib/features/profile/models/weight_model.dart new file mode 100644 index 00000000..fc901df5 --- /dev/null +++ b/lib/features/profile/models/weight_model.dart @@ -0,0 +1,19 @@ +import 'package:freezed_annotation/freezed_annotation.dart'; + +part 'weight_model.freezed.dart'; + +part 'weight_model.g.dart'; + +@freezed +class WeightModel with _$WeightModel { + const factory WeightModel({ + @JsonKey(name: "id") required int id, + @JsonKey(name: "user_id") required int userId, + @JsonKey(name: "weight") required int weight, + @JsonKey(name: "created_at") required DateTime createdAt, + @JsonKey(name: "updated_at") required DateTime updatedAt, + @JsonKey(name: "bmi") required double bmi, + }) = _WeightModel; + + factory WeightModel.fromJson(Map json) => _$WeightModelFromJson(json); +} diff --git a/lib/features/profile/models/weight_model.freezed.dart b/lib/features/profile/models/weight_model.freezed.dart new file mode 100644 index 00000000..3ca65637 --- /dev/null +++ b/lib/features/profile/models/weight_model.freezed.dart @@ -0,0 +1,289 @@ +// 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 'weight_model.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'); + +WeightModel _$WeightModelFromJson(Map json) { + return _WeightModel.fromJson(json); +} + +/// @nodoc +mixin _$WeightModel { + @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: "created_at") + DateTime get createdAt => throw _privateConstructorUsedError; + @JsonKey(name: "updated_at") + DateTime get updatedAt => throw _privateConstructorUsedError; + @JsonKey(name: "bmi") + double get bmi => throw _privateConstructorUsedError; + + /// Serializes this WeightModel to a JSON map. + Map toJson() => throw _privateConstructorUsedError; + + /// Create a copy of WeightModel + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $WeightModelCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $WeightModelCopyWith<$Res> { + factory $WeightModelCopyWith( + WeightModel value, $Res Function(WeightModel) then) = + _$WeightModelCopyWithImpl<$Res, WeightModel>; + @useResult + $Res call( + {@JsonKey(name: "id") int id, + @JsonKey(name: "user_id") int userId, + @JsonKey(name: "weight") int weight, + @JsonKey(name: "created_at") DateTime createdAt, + @JsonKey(name: "updated_at") DateTime updatedAt, + @JsonKey(name: "bmi") double bmi}); +} + +/// @nodoc +class _$WeightModelCopyWithImpl<$Res, $Val extends WeightModel> + implements $WeightModelCopyWith<$Res> { + _$WeightModelCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of WeightModel + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? id = null, + Object? userId = null, + Object? weight = null, + Object? createdAt = null, + Object? updatedAt = null, + Object? bmi = 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, + 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, + bmi: null == bmi + ? _value.bmi + : bmi // ignore: cast_nullable_to_non_nullable + as double, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$WeightModelImplCopyWith<$Res> + implements $WeightModelCopyWith<$Res> { + factory _$$WeightModelImplCopyWith( + _$WeightModelImpl value, $Res Function(_$WeightModelImpl) then) = + __$$WeightModelImplCopyWithImpl<$Res>; + @override + @useResult + $Res call( + {@JsonKey(name: "id") int id, + @JsonKey(name: "user_id") int userId, + @JsonKey(name: "weight") int weight, + @JsonKey(name: "created_at") DateTime createdAt, + @JsonKey(name: "updated_at") DateTime updatedAt, + @JsonKey(name: "bmi") double bmi}); +} + +/// @nodoc +class __$$WeightModelImplCopyWithImpl<$Res> + extends _$WeightModelCopyWithImpl<$Res, _$WeightModelImpl> + implements _$$WeightModelImplCopyWith<$Res> { + __$$WeightModelImplCopyWithImpl( + _$WeightModelImpl _value, $Res Function(_$WeightModelImpl) _then) + : super(_value, _then); + + /// Create a copy of WeightModel + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? id = null, + Object? userId = null, + Object? weight = null, + Object? createdAt = null, + Object? updatedAt = null, + Object? bmi = null, + }) { + return _then(_$WeightModelImpl( + 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, + 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, + bmi: null == bmi + ? _value.bmi + : bmi // ignore: cast_nullable_to_non_nullable + as double, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$WeightModelImpl implements _WeightModel { + const _$WeightModelImpl( + {@JsonKey(name: "id") required this.id, + @JsonKey(name: "user_id") required this.userId, + @JsonKey(name: "weight") required this.weight, + @JsonKey(name: "created_at") required this.createdAt, + @JsonKey(name: "updated_at") required this.updatedAt, + @JsonKey(name: "bmi") required this.bmi}); + + factory _$WeightModelImpl.fromJson(Map json) => + _$$WeightModelImplFromJson(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: "created_at") + final DateTime createdAt; + @override + @JsonKey(name: "updated_at") + final DateTime updatedAt; + @override + @JsonKey(name: "bmi") + final double bmi; + + @override + String toString() { + return 'WeightModel(id: $id, userId: $userId, weight: $weight, createdAt: $createdAt, updatedAt: $updatedAt, bmi: $bmi)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$WeightModelImpl && + (identical(other.id, id) || other.id == id) && + (identical(other.userId, userId) || other.userId == userId) && + (identical(other.weight, weight) || other.weight == weight) && + (identical(other.createdAt, createdAt) || + other.createdAt == createdAt) && + (identical(other.updatedAt, updatedAt) || + other.updatedAt == updatedAt) && + (identical(other.bmi, bmi) || other.bmi == bmi)); + } + + @JsonKey(includeFromJson: false, includeToJson: false) + @override + int get hashCode => + Object.hash(runtimeType, id, userId, weight, createdAt, updatedAt, bmi); + + /// Create a copy of WeightModel + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$WeightModelImplCopyWith<_$WeightModelImpl> get copyWith => + __$$WeightModelImplCopyWithImpl<_$WeightModelImpl>(this, _$identity); + + @override + Map toJson() { + return _$$WeightModelImplToJson( + this, + ); + } +} + +abstract class _WeightModel implements WeightModel { + const factory _WeightModel( + {@JsonKey(name: "id") required final int id, + @JsonKey(name: "user_id") required final int userId, + @JsonKey(name: "weight") required final int weight, + @JsonKey(name: "created_at") required final DateTime createdAt, + @JsonKey(name: "updated_at") required final DateTime updatedAt, + @JsonKey(name: "bmi") required final double bmi}) = _$WeightModelImpl; + + factory _WeightModel.fromJson(Map json) = + _$WeightModelImpl.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: "created_at") + DateTime get createdAt; + @override + @JsonKey(name: "updated_at") + DateTime get updatedAt; + @override + @JsonKey(name: "bmi") + double get bmi; + + /// Create a copy of WeightModel + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + _$$WeightModelImplCopyWith<_$WeightModelImpl> get copyWith => + throw _privateConstructorUsedError; +} diff --git a/lib/features/profile/models/weight_model.g.dart b/lib/features/profile/models/weight_model.g.dart new file mode 100644 index 00000000..cd18ea8b --- /dev/null +++ b/lib/features/profile/models/weight_model.g.dart @@ -0,0 +1,27 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'weight_model.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +_$WeightModelImpl _$$WeightModelImplFromJson(Map json) => + _$WeightModelImpl( + id: (json['id'] as num).toInt(), + userId: (json['user_id'] as num).toInt(), + weight: (json['weight'] as num).toInt(), + createdAt: DateTime.parse(json['created_at'] as String), + updatedAt: DateTime.parse(json['updated_at'] as String), + bmi: (json['bmi'] as num).toDouble(), + ); + +Map _$$WeightModelImplToJson(_$WeightModelImpl instance) => + { + 'id': instance.id, + 'user_id': instance.userId, + 'weight': instance.weight, + 'created_at': instance.createdAt.toIso8601String(), + 'updated_at': instance.updatedAt.toIso8601String(), + 'bmi': instance.bmi, + }; 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 0a08e8de..f6052a4b 100644 --- a/lib/features/profile/presentation/bloc/profile_cubit/profile_cubit.dart +++ b/lib/features/profile/presentation/bloc/profile_cubit/profile_cubit.dart @@ -1,9 +1,10 @@ -import 'package:eatvio_app/core/app_export.dart'; import 'package:eatvio_app/features/profile/presentation/bloc/profile_cubit/profile_state.dart'; import 'package:eatvio_app/features/profile/repositories/profile_repository.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; class ProfileCubit extends Cubit { final ProfileRepository profileRepository; + String _currentPeriod = '1'; ProfileCubit({ required this.profileRepository, @@ -13,6 +14,8 @@ class ProfileCubit extends Cubit { try { emit(ProfileState.loaded( profile: await profileRepository.getProfileBySlug(slug), + profileDetails: await profileRepository.getMyProfileDetails(), + blogPosts: await profileRepository.getBlogPostsByAuthorSlug(slug: slug), )); } catch (e) { emit(ProfileState.error(errorMessage: e.toString())); @@ -20,10 +23,18 @@ class ProfileCubit extends Cubit { } } - getMyProfile() async { + getMyProfile({ + String period = '1', + }) async { + _currentPeriod = period; try { + final profile = await profileRepository.getMyProfile(); emit(ProfileState.loaded( - profile: await profileRepository.getMyProfile(), + profile: profile, + profileDetails: await profileRepository.getMyProfileDetails(), + blogPosts: await profileRepository.getBlogPostsByAuthorSlug(slug: profile.slug), + weightPoints: await profileRepository.getWeight(period: period), + circumferencePoints: await profileRepository.getCircumferences(period: period), )); } catch (e) { emit(ProfileState.error(errorMessage: e.toString())); @@ -42,6 +53,7 @@ class ProfileCubit extends Cubit { waistCircumference: waistCircumference, hipCircumference: hipCircumference, ); + await getMyProfile(period: _currentPeriod); } catch (e) { emit(ProfileState.error(errorMessage: e.toString())); print(e); @@ -49,12 +61,11 @@ class ProfileCubit extends Cubit { } addWeight({ - required int weight, + required double weight, }) async { try { - await profileRepository.addWeight( - weight: weight, - ); + await profileRepository.addWeight(weight: weight); + await getMyProfile(period: _currentPeriod); } 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 1f06bfe4..ec7fd13d 100644 --- a/lib/features/profile/presentation/bloc/profile_cubit/profile_state.dart +++ b/lib/features/profile/presentation/bloc/profile_cubit/profile_state.dart @@ -1,4 +1,7 @@ +import 'package:eatvio_app/features/feed/models/feed_blog_post_model.dart'; +import 'package:eatvio_app/features/profile/models/circumference_model.dart'; import 'package:eatvio_app/features/profile/models/profile_model.dart'; +import 'package:eatvio_app/features/profile/models/weight_model.dart'; import 'package:freezed_annotation/freezed_annotation.dart'; part 'profile_state.freezed.dart'; @@ -11,6 +14,10 @@ abstract class ProfileState with _$ProfileState { const factory ProfileState.loaded({ required ProfileModel profile, + required ProfileDetailsModel profileDetails, + required List blogPosts, + List? weightPoints, + List? circumferencePoints, }) = 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 2658d2e2..8919e36f 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,13 @@ mixin _$ProfileState { TResult when( TResult Function() $default, { required TResult Function() loading, - required TResult Function(ProfileModel profile) loaded, + required TResult Function( + ProfileModel profile, + ProfileDetailsModel profileDetails, + List blogPosts, + List? weightPoints, + List? circumferencePoints) + loaded, required TResult Function(String errorMessage) error, }) => throw _privateConstructorUsedError; @@ -28,7 +34,13 @@ mixin _$ProfileState { TResult? whenOrNull( TResult? Function()? $default, { TResult? Function()? loading, - TResult? Function(ProfileModel profile)? loaded, + TResult? Function( + ProfileModel profile, + ProfileDetailsModel profileDetails, + List blogPosts, + List? weightPoints, + List? circumferencePoints)? + loaded, TResult? Function(String errorMessage)? error, }) => throw _privateConstructorUsedError; @@ -36,7 +48,13 @@ mixin _$ProfileState { TResult maybeWhen( TResult Function()? $default, { TResult Function()? loading, - TResult Function(ProfileModel profile)? loaded, + TResult Function( + ProfileModel profile, + ProfileDetailsModel profileDetails, + List blogPosts, + List? weightPoints, + List? circumferencePoints)? + loaded, TResult Function(String errorMessage)? error, required TResult orElse(), }) => @@ -84,6 +102,9 @@ 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 @@ -100,6 +121,9 @@ 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 @@ -126,7 +150,13 @@ class _$ProfileStateImpl implements _ProfileState { TResult when( TResult Function() $default, { required TResult Function() loading, - required TResult Function(ProfileModel profile) loaded, + required TResult Function( + ProfileModel profile, + ProfileDetailsModel profileDetails, + List blogPosts, + List? weightPoints, + List? circumferencePoints) + loaded, required TResult Function(String errorMessage) error, }) { return $default(); @@ -137,7 +167,13 @@ class _$ProfileStateImpl implements _ProfileState { TResult? whenOrNull( TResult? Function()? $default, { TResult? Function()? loading, - TResult? Function(ProfileModel profile)? loaded, + TResult? Function( + ProfileModel profile, + ProfileDetailsModel profileDetails, + List blogPosts, + List? weightPoints, + List? circumferencePoints)? + loaded, TResult? Function(String errorMessage)? error, }) { return $default?.call(); @@ -148,7 +184,13 @@ class _$ProfileStateImpl implements _ProfileState { TResult maybeWhen( TResult Function()? $default, { TResult Function()? loading, - TResult Function(ProfileModel profile)? loaded, + TResult Function( + ProfileModel profile, + ProfileDetailsModel profileDetails, + List blogPosts, + List? weightPoints, + List? circumferencePoints)? + loaded, TResult Function(String errorMessage)? error, required TResult orElse(), }) { @@ -214,6 +256,9 @@ 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 @@ -241,7 +286,13 @@ class _$ProfileStateLoadingImpl implements ProfileStateLoading { TResult when( TResult Function() $default, { required TResult Function() loading, - required TResult Function(ProfileModel profile) loaded, + required TResult Function( + ProfileModel profile, + ProfileDetailsModel profileDetails, + List blogPosts, + List? weightPoints, + List? circumferencePoints) + loaded, required TResult Function(String errorMessage) error, }) { return loading(); @@ -252,7 +303,13 @@ class _$ProfileStateLoadingImpl implements ProfileStateLoading { TResult? whenOrNull( TResult? Function()? $default, { TResult? Function()? loading, - TResult? Function(ProfileModel profile)? loaded, + TResult? Function( + ProfileModel profile, + ProfileDetailsModel profileDetails, + List blogPosts, + List? weightPoints, + List? circumferencePoints)? + loaded, TResult? Function(String errorMessage)? error, }) { return loading?.call(); @@ -263,7 +320,13 @@ class _$ProfileStateLoadingImpl implements ProfileStateLoading { TResult maybeWhen( TResult Function()? $default, { TResult Function()? loading, - TResult Function(ProfileModel profile)? loaded, + TResult Function( + ProfileModel profile, + ProfileDetailsModel profileDetails, + List blogPosts, + List? weightPoints, + List? circumferencePoints)? + loaded, TResult Function(String errorMessage)? error, required TResult orElse(), }) { @@ -321,9 +384,15 @@ abstract class _$$ProfileStateLoadedImplCopyWith<$Res> { $Res Function(_$ProfileStateLoadedImpl) then) = __$$ProfileStateLoadedImplCopyWithImpl<$Res>; @useResult - $Res call({ProfileModel profile}); + $Res call( + {ProfileModel profile, + ProfileDetailsModel profileDetails, + List blogPosts, + List? weightPoints, + List? circumferencePoints}); $ProfileModelCopyWith<$Res> get profile; + $ProfileDetailsModelCopyWith<$Res> get profileDetails; } /// @nodoc @@ -334,19 +403,43 @@ 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({ Object? profile = null, + Object? profileDetails = null, + Object? blogPosts = null, + Object? weightPoints = freezed, + Object? circumferencePoints = freezed, }) { return _then(_$ProfileStateLoadedImpl( profile: null == profile ? _value.profile : profile // ignore: cast_nullable_to_non_nullable as ProfileModel, + profileDetails: null == profileDetails + ? _value.profileDetails + : profileDetails // ignore: cast_nullable_to_non_nullable + as ProfileDetailsModel, + blogPosts: null == blogPosts + ? _value._blogPosts + : blogPosts // ignore: cast_nullable_to_non_nullable + as List, + weightPoints: freezed == weightPoints + ? _value._weightPoints + : weightPoints // ignore: cast_nullable_to_non_nullable + as List?, + circumferencePoints: freezed == circumferencePoints + ? _value._circumferencePoints + : circumferencePoints // ignore: cast_nullable_to_non_nullable + as List?, )); } + /// Create a copy of ProfileState + /// with the given fields replaced by the non-null parameter values. @override @pragma('vm:prefer-inline') $ProfileModelCopyWith<$Res> get profile { @@ -354,19 +447,67 @@ class __$$ProfileStateLoadedImplCopyWithImpl<$Res> return _then(_value.copyWith(profile: value)); }); } + + /// Create a copy of ProfileState + /// with the given fields replaced by the non-null parameter values. + @override + @pragma('vm:prefer-inline') + $ProfileDetailsModelCopyWith<$Res> get profileDetails { + return $ProfileDetailsModelCopyWith<$Res>(_value.profileDetails, (value) { + return _then(_value.copyWith(profileDetails: value)); + }); + } } /// @nodoc class _$ProfileStateLoadedImpl implements ProfileStateLoaded { - const _$ProfileStateLoadedImpl({required this.profile}); + const _$ProfileStateLoadedImpl( + {required this.profile, + required this.profileDetails, + required final List blogPosts, + final List? weightPoints, + final List? circumferencePoints}) + : _blogPosts = blogPosts, + _weightPoints = weightPoints, + _circumferencePoints = circumferencePoints; @override final ProfileModel profile; + @override + final ProfileDetailsModel profileDetails; + final List _blogPosts; + @override + List get blogPosts { + if (_blogPosts is EqualUnmodifiableListView) return _blogPosts; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(_blogPosts); + } + + final List? _weightPoints; + @override + List? get weightPoints { + final value = _weightPoints; + if (value == null) return null; + if (_weightPoints is EqualUnmodifiableListView) return _weightPoints; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(value); + } + + final List? _circumferencePoints; + @override + List? get circumferencePoints { + final value = _circumferencePoints; + if (value == null) return null; + if (_circumferencePoints is EqualUnmodifiableListView) + return _circumferencePoints; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(value); + } @override String toString() { - return 'ProfileState.loaded(profile: $profile)'; + return 'ProfileState.loaded(profile: $profile, profileDetails: $profileDetails, blogPosts: $blogPosts, weightPoints: $weightPoints, circumferencePoints: $circumferencePoints)'; } @override @@ -374,13 +515,29 @@ class _$ProfileStateLoadedImpl implements ProfileStateLoaded { return identical(this, other) || (other.runtimeType == runtimeType && other is _$ProfileStateLoadedImpl && - (identical(other.profile, profile) || other.profile == profile)); + (identical(other.profile, profile) || other.profile == profile) && + (identical(other.profileDetails, profileDetails) || + other.profileDetails == profileDetails) && + const DeepCollectionEquality() + .equals(other._blogPosts, _blogPosts) && + const DeepCollectionEquality() + .equals(other._weightPoints, _weightPoints) && + const DeepCollectionEquality() + .equals(other._circumferencePoints, _circumferencePoints)); } @override - int get hashCode => Object.hash(runtimeType, profile); + int get hashCode => Object.hash( + runtimeType, + profile, + profileDetails, + const DeepCollectionEquality().hash(_blogPosts), + const DeepCollectionEquality().hash(_weightPoints), + const DeepCollectionEquality().hash(_circumferencePoints)); - @JsonKey(ignore: true) + /// Create a copy of ProfileState + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$ProfileStateLoadedImplCopyWith<_$ProfileStateLoadedImpl> get copyWith => @@ -392,10 +549,17 @@ class _$ProfileStateLoadedImpl implements ProfileStateLoaded { TResult when( TResult Function() $default, { required TResult Function() loading, - required TResult Function(ProfileModel profile) loaded, + required TResult Function( + ProfileModel profile, + ProfileDetailsModel profileDetails, + List blogPosts, + List? weightPoints, + List? circumferencePoints) + loaded, required TResult Function(String errorMessage) error, }) { - return loaded(profile); + return loaded( + profile, profileDetails, blogPosts, weightPoints, circumferencePoints); } @override @@ -403,10 +567,17 @@ class _$ProfileStateLoadedImpl implements ProfileStateLoaded { TResult? whenOrNull( TResult? Function()? $default, { TResult? Function()? loading, - TResult? Function(ProfileModel profile)? loaded, + TResult? Function( + ProfileModel profile, + ProfileDetailsModel profileDetails, + List blogPosts, + List? weightPoints, + List? circumferencePoints)? + loaded, TResult? Function(String errorMessage)? error, }) { - return loaded?.call(profile); + return loaded?.call( + profile, profileDetails, blogPosts, weightPoints, circumferencePoints); } @override @@ -414,12 +585,19 @@ class _$ProfileStateLoadedImpl implements ProfileStateLoaded { TResult maybeWhen( TResult Function()? $default, { TResult Function()? loading, - TResult Function(ProfileModel profile)? loaded, + TResult Function( + ProfileModel profile, + ProfileDetailsModel profileDetails, + List blogPosts, + List? weightPoints, + List? circumferencePoints)? + loaded, TResult Function(String errorMessage)? error, required TResult orElse(), }) { if (loaded != null) { - return loaded(profile); + return loaded(profile, profileDetails, blogPosts, weightPoints, + circumferencePoints); } return orElse(); } @@ -463,11 +641,23 @@ class _$ProfileStateLoadedImpl implements ProfileStateLoaded { } abstract class ProfileStateLoaded implements ProfileState { - const factory ProfileStateLoaded({required final ProfileModel profile}) = + const factory ProfileStateLoaded( + {required final ProfileModel profile, + required final ProfileDetailsModel profileDetails, + required final List blogPosts, + final List? weightPoints, + final List? circumferencePoints}) = _$ProfileStateLoadedImpl; ProfileModel get profile; - @JsonKey(ignore: true) + ProfileDetailsModel get profileDetails; + List get blogPosts; + List? get weightPoints; + List? get circumferencePoints; + + /// Create a copy of ProfileState + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) _$$ProfileStateLoadedImplCopyWith<_$ProfileStateLoadedImpl> get copyWith => throw _privateConstructorUsedError; } @@ -489,6 +679,8 @@ 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({ @@ -528,7 +720,9 @@ class _$ProfileStateErrorImpl implements ProfileStateError { @override int get hashCode => Object.hash(runtimeType, errorMessage); - @JsonKey(ignore: true) + /// Create a copy of ProfileState + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$ProfileStateErrorImplCopyWith<_$ProfileStateErrorImpl> get copyWith => @@ -540,7 +734,13 @@ class _$ProfileStateErrorImpl implements ProfileStateError { TResult when( TResult Function() $default, { required TResult Function() loading, - required TResult Function(ProfileModel profile) loaded, + required TResult Function( + ProfileModel profile, + ProfileDetailsModel profileDetails, + List blogPosts, + List? weightPoints, + List? circumferencePoints) + loaded, required TResult Function(String errorMessage) error, }) { return error(errorMessage); @@ -551,7 +751,13 @@ class _$ProfileStateErrorImpl implements ProfileStateError { TResult? whenOrNull( TResult? Function()? $default, { TResult? Function()? loading, - TResult? Function(ProfileModel profile)? loaded, + TResult? Function( + ProfileModel profile, + ProfileDetailsModel profileDetails, + List blogPosts, + List? weightPoints, + List? circumferencePoints)? + loaded, TResult? Function(String errorMessage)? error, }) { return error?.call(errorMessage); @@ -562,7 +768,13 @@ class _$ProfileStateErrorImpl implements ProfileStateError { TResult maybeWhen( TResult Function()? $default, { TResult Function()? loading, - TResult Function(ProfileModel profile)? loaded, + TResult Function( + ProfileModel profile, + ProfileDetailsModel profileDetails, + List blogPosts, + List? weightPoints, + List? circumferencePoints)? + loaded, TResult Function(String errorMessage)? error, required TResult orElse(), }) { @@ -615,7 +827,10 @@ abstract class ProfileStateError implements ProfileState { _$ProfileStateErrorImpl; String get errorMessage; - @JsonKey(ignore: true) + + /// Create a copy of ProfileState + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) _$$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 e9e37c56..b62c2ec4 100644 --- a/lib/features/profile/presentation/pages/profile_screen.dart +++ b/lib/features/profile/presentation/pages/profile_screen.dart @@ -1,13 +1,21 @@ -import 'package:eatvio_app/core/app_export.dart'; +import 'package:eatvio_app/core/const.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/feed/presentation/widgets/blog_post_widget.dart'; +import 'package:eatvio_app/features/profile/models/circumference_model.dart'; +import 'package:eatvio_app/features/profile/models/weight_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:eatvio_app/theme/theme_helper.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:flutter_svg/flutter_svg.dart'; +import 'package:go_router/go_router.dart'; +import 'package:rive/rive.dart'; +import 'package:share_plus/share_plus.dart'; class ProfileScreen extends StatefulWidget { final Author? author; @@ -19,65 +27,341 @@ class ProfileScreen extends StatefulWidget { } class _ProfileScreenState extends State { - List chartData = []; - List chartPoints = []; + List circumferencePoints = []; + List weightPoints = []; + final List chipsLabelList = ['Вес', 'Замеры', 'ИМТ']; + final List chipsIntervalLabelList = ['1М', '3М', '6М', '1Г', 'ВСЁ ВРЕМЯ']; + final List chipsIntervalList = ['1', '3', '6', '12', 'all']; + int _selectedChipIndex = 0; + int _selectedIntervalChipIndex = 0; + final ProfileCubit profileCubit = sl(); + + @override + void initState() { + super.initState(); + widget.author == null ? profileCubit.getMyProfile() : profileCubit.getProfileBySlug(widget.author!.authorSlug); + } @override Widget build(BuildContext context) { - return BlocProvider( - 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( - toolbarHeight: 0, - ), - body: SingleChildScrollView( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Padding( - padding: const EdgeInsets.only(left: 16, bottom: 32), - child: CircleAvatar( - radius: 32, - backgroundImage: NetworkImage(state.profile.user.profilePhotoUrl), + return BlocBuilder( + bloc: profileCubit, + builder: (BuildContext context, ProfileState state) { + if (state is ProfileStateLoaded) { + if (state.circumferencePoints != null) { + circumferencePoints = state.circumferencePoints!; + weightPoints = state.weightPoints!; + } + return Scaffold( + backgroundColor: Colors.grey.shade200, + appBar: widget.author == null ? AppBar(toolbarHeight: 0) : AppBar(), + body: SingleChildScrollView( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.vertical( + bottom: Radius.circular(16), ), ), - CircumferenceChartWidget(chartData: chartData), - WeightChartWidget(chartPoints: chartPoints), - ImtChartWidget(chartPoints: chartPoints), - ], + child: Column( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Padding( + padding: const EdgeInsets.all(16), + child: Row( + children: [ + CircleAvatar( + radius: 32, + backgroundImage: NetworkImage(state.profile.profilePhotoUrl), + ), + const SizedBox(width: 12), + Text( + state.profile.name, + style: TextStyle( + color: Colors.black, + fontWeight: FontWeight.w500, + height: 1, + ), + ), + const Spacer(), + Row( + mainAxisAlignment: MainAxisAlignment.end, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Container( + child: SvgPicture.asset( + height: 28, + width: 28, + 'assets/icons/subscribers.svg', + colorFilter: ColorFilter.mode(appTheme.blueA400, BlendMode.srcIn), + ), + ), + SizedBox(width: 8), + Column( + children: [ + Text( + '123', + style: TextStyle( + height: 1, + fontSize: 18, + fontWeight: FontWeight.w500, + color: Colors.black87, + ), + ), + Text( + 'Подписчика', + style: TextStyle( + height: 1, + fontSize: 12, + fontWeight: FontWeight.w400, + color: Colors.black38, + ), + ), + ], + ), + ], + ), + GestureDetector( + onTap: () => Share.shareUri( + Uri.parse( + baseUrl + '/ru/profile/' + state.profile.slug, + ), + ), + child: Container( + padding: EdgeInsets.only(left: 16), + child: SvgPicture.asset( + height: 24, + width: 24, + 'assets/icons/share.svg', + colorFilter: ColorFilter.mode(appTheme.blueA400, BlendMode.srcIn), + ), + ), + ), + ], + ), + ), + if (state.profileDetails.additionalInfo.isNotEmpty) + Container( + alignment: Alignment.centerLeft, + padding: const EdgeInsets.all(16), + child: Text( + state.profileDetails.additionalInfo, + style: TextStyle( + color: Colors.black.withOpacity(0.4), + height: 1, + ), + ), + ), + if (widget.author != null) const SizedBox(height: 8), + if (widget.author != null) + Row( + children: [ + SizedBox(width: 16), + GestureDetector( + onTap: () => GoRouter.of(context).pushNamed( + 'chatScreen', + ), + child: Container( + alignment: Alignment.center, + padding: EdgeInsets.all(8), + width: (MediaQuery.of(context).size.width - 40) / 2, + decoration: BoxDecoration( + color: appTheme.blueA400.withOpacity(0.1), + borderRadius: BorderRadius.circular(16), + ), + child: Text( + 'Сообщение', + style: TextStyle( + color: appTheme.blueA400, + ), + ), + ), + ), + SizedBox(width: 8), + Container( + alignment: Alignment.center, + padding: EdgeInsets.all(8), + width: (MediaQuery.of(context).size.width - 40) / 2, + decoration: BoxDecoration( + color: appTheme.blueA400, + borderRadius: BorderRadius.circular(16), + ), + child: Text( + 'Подписаться', + style: TextStyle( + color: Colors.white, + ), + ), + ), + SizedBox(width: 16), + ], + ), + if (widget.author != null) SizedBox(height: 16), + if (widget.author == null) _divider(context), + if (widget.author == null) + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + const SizedBox(height: 8), + SingleChildScrollView( + padding: EdgeInsets.symmetric(horizontal: 16), + scrollDirection: Axis.horizontal, + child: Row( + children: [ + _choiceChipWidget(0), + SizedBox(width: 8), + _choiceChipWidget(1), + SizedBox(width: 8), + _choiceChipWidget(2), + ], + ), + ), + Builder( + builder: (context) { + switch (_selectedChipIndex) { + case 0: + return WeightChartWidget( + weightPoints: weightPoints, + profileCubit: profileCubit, + ); + case 1: + return CircumferenceChartWidget( + circumferencePoints: circumferencePoints, + profileCubit: profileCubit, + ); + case 2: + return ImtChartWidget( + weightPoints: weightPoints, + ); + } + return SizedBox.shrink(); + }, + ), + SizedBox(height: 8), + Row( + children: [ + SizedBox(width: 16), + _choiceIntervalChipWidget(0), + SizedBox(width: 8), + _choiceIntervalChipWidget(1), + SizedBox(width: 8), + _choiceIntervalChipWidget(2), + SizedBox(width: 8), + _choiceIntervalChipWidget(3), + SizedBox(width: 8), + _choiceIntervalChipWidget(4), + ], + ), + SizedBox(height: 8), + ], + ), + ], + ), + ), + SizedBox(height: 16), + ListView.separated( + shrinkWrap: true, + physics: const NeverScrollableScrollPhysics(), + itemBuilder: (context, index) => BlogPostWidget(feedBlogPostModel: state.blogPosts[index]), + separatorBuilder: (context, index) => SizedBox(height: 8), + itemCount: state.blogPosts.length, + ), + SizedBox(height: 16), + ], + ), + ), + ); + } else if (state is ProfileStateError) { + return Scaffold( + appBar: AppBar(), + body: Center( + child: Padding( + padding: const EdgeInsets.all(16), + child: Text(state.errorMessage), + ), + ), + ); + } else { + return Scaffold( + appBar: AppBar(), + body: Center( + child: SizedBox( + height: 32, + width: 32, + child: RiveAnimation.asset( + 'assets/rive_animations/loading.riv', ), ), - ); - } else if (state is ProfileStateError) { - return Scaffold( - appBar: AppBar(), - body: Center( - child: Padding( - padding: const EdgeInsets.all(16), - child: Text(state.errorMessage), - ), - ), - ); - } else { - return Scaffold( - appBar: AppBar(), - body: Center( - child: CircularProgressIndicator(), - ), - ); - } - }, + ), + ); + } + }, + ); + } + + _divider(BuildContext context) { + return Container( + height: 0.4, + width: MediaQuery.of(context).size.width - 32, + decoration: BoxDecoration( + color: Colors.black26, + borderRadius: BorderRadius.circular(16), ), ); } + + _choiceIntervalChipWidget(int index) { + return ChoiceChip( + selectedColor: Colors.grey.withOpacity(0.1), + pressElevation: 0, + showCheckmark: false, + side: BorderSide.none, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(16), + ), + padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4), + label: Text(chipsIntervalLabelList[index]), + labelStyle: TextStyle( + color: appTheme.gray600, + fontWeight: FontWeight.w500, + fontSize: 12, + ), + selected: _selectedIntervalChipIndex == index, + onSelected: (bool selected) { + profileCubit.getMyProfile(period: chipsIntervalList[index]); + setState(() { + _selectedIntervalChipIndex = index; + }); + }, + ); + } + + _choiceChipWidget(int index) { + return ChoiceChip( + selectedColor: appTheme.blueA400, + pressElevation: 0, + showCheckmark: false, + side: BorderSide.none, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(16), + ), + padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4), + label: Text(chipsLabelList[index]), + labelStyle: TextStyle( + color: index == _selectedChipIndex ? Colors.white : appTheme.gray600, + fontWeight: FontWeight.w500, + fontSize: 12, + ), + selected: _selectedChipIndex == index, + backgroundColor: appTheme.gray100, + onSelected: (bool selected) { + setState(() { + _selectedChipIndex = index; + }); + }, + ); + } } diff --git a/lib/features/profile/presentation/widgets/circumference_chart_widget.dart b/lib/features/profile/presentation/widgets/circumference_chart_widget.dart index a4a6af7a..eb37ec13 100644 --- a/lib/features/profile/presentation/widgets/circumference_chart_widget.dart +++ b/lib/features/profile/presentation/widgets/circumference_chart_widget.dart @@ -1,106 +1,373 @@ -import 'package:eatvio_app/features/profile/models/profile_model.dart'; +import 'package:eatvio_app/features/profile/models/circumference_model.dart'; +import 'package:eatvio_app/features/profile/presentation/bloc/profile_cubit/profile_cubit.dart'; +import 'package:eatvio_app/theme/theme_helper.dart'; +import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_charts/charts.dart'; import 'package:intl/intl.dart'; +import 'package:syncfusion_flutter_charts/charts.dart'; -class CircumferenceChartWidget extends StatelessWidget { - final List chartData; +class CircumferenceChartWidget extends StatefulWidget { + final List circumferencePoints; + final ProfileCubit profileCubit; const CircumferenceChartWidget({ super.key, - required this.chartData, + required this.circumferencePoints, + required this.profileCubit, }); + @override + State createState() => _CircumferenceChartWidgetState(); +} + +class _CircumferenceChartWidgetState extends State { + late FixedExtentScrollController chestController; + late FixedExtentScrollController waistController; + late FixedExtentScrollController hipController; + late int chest; + late int waist; + late int hip; + @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, + return Column( + children: [ + if (widget.circumferencePoints.isNotEmpty) + Padding( + padding: EdgeInsets.symmetric(horizontal: 16, vertical: 8), + child: Row( + children: [ + Text( + '${widget.circumferencePoints.last.chestCircumference}', + style: TextStyle( + color: Colors.black, + fontSize: 40, + fontWeight: FontWeight.w500, + ), + ), + if (widget.circumferencePoints.length == 1) + Container( + margin: EdgeInsets.symmetric(horizontal: 12), + width: 8, + height: 8, + decoration: BoxDecoration( + shape: BoxShape.circle, + color: Colors.black12, + ), + ), + if (widget.circumferencePoints.length > 1) + widget.circumferencePoints.last.chestCircumference > widget.circumferencePoints[widget.circumferencePoints.length - 2].chestCircumference + ? Icon( + Icons.arrow_drop_up, + size: 40, + color: Colors.grey, + ) + : Icon( + Icons.arrow_drop_down, + size: 40, + color: Colors.grey, + ), + Text( + '${widget.circumferencePoints.last.waistCircumference}', + style: TextStyle( + color: Colors.black, + fontSize: 40, + fontWeight: FontWeight.w500, + ), + ), + if (widget.circumferencePoints.length == 1) + Container( + margin: EdgeInsets.symmetric(horizontal: 12), + width: 8, + height: 8, + decoration: BoxDecoration( + shape: BoxShape.circle, + color: Colors.black12, + ), + ), + if (widget.circumferencePoints.length > 1) + widget.circumferencePoints.last.waistCircumference > widget.circumferencePoints[widget.circumferencePoints.length - 2].waistCircumference + ? Icon( + Icons.arrow_drop_up, + size: 40, + color: Colors.grey, + ) + : Icon( + Icons.arrow_drop_down, + size: 40, + color: Colors.grey, + ), + Text( + '${widget.circumferencePoints.last.hipCircumference}', + style: TextStyle( + color: Colors.black, + fontSize: 40, + fontWeight: FontWeight.w500, + ), + ), + if (widget.circumferencePoints.length == 1) + Container( + margin: EdgeInsets.symmetric(horizontal: 12), + width: 8, + height: 8, + decoration: BoxDecoration( + shape: BoxShape.circle, + color: Colors.black12, + ), + ), + if (widget.circumferencePoints.length > 1) + widget.circumferencePoints.last.hipCircumference > widget.circumferencePoints[widget.circumferencePoints.length - 2].hipCircumference + ? Icon( + Icons.arrow_drop_up, + size: 40, + color: Colors.grey, + ) + : Icon( + Icons.arrow_drop_down, + size: 40, + color: Colors.grey, + ), + ], + ), + ), + Stack( + alignment: Alignment.bottomRight, + children: [ + SfCartesianChart( + margin: EdgeInsets.symmetric(horizontal: 8), + enableAxisAnimation: true, + plotAreaBorderWidth: 0, + trackballBehavior: TrackballBehavior( + enable: true, + activationMode: ActivationMode.singleTap, + tooltipDisplayMode: TrackballDisplayMode.groupAllPoints, + tooltipSettings: InteractiveTooltip(), + lineType: TrackballLineType.vertical, + ), + primaryXAxis: DateTimeCategoryAxis( + tickPosition: TickPosition.inside, + majorTickLines: MajorTickLines( + size: 0, + ), + edgeLabelPlacement: EdgeLabelPlacement.shift, + dateFormat: DateFormat.MMMd('ru'), + labelStyle: TextStyle( + color: Colors.grey, + ), + majorGridLines: MajorGridLines(dashArray: [1], color: Colors.grey.withOpacity(0.3)), + axisLine: AxisLine( + color: Colors.grey.withOpacity(0.3), + width: 0.4, + ), + ), + primaryYAxis: NumericAxis( + isVisible: false, + labelFormat: '{value} см', + axisLine: AxisLine( + width: 1, + ), + majorTickLines: MajorTickLines(size: 0), + ), + series: _getSplineSeries(), + tooltipBehavior: TooltipBehavior(enable: true), + ), + FloatingActionButton.small( + heroTag: 'addCircumference', + onPressed: () { + if (widget.circumferencePoints.isNotEmpty) { + chest = widget.circumferencePoints.last.chestCircumference; + waist = widget.circumferencePoints.last.waistCircumference; + hip = widget.circumferencePoints.last.hipCircumference; + chestController = FixedExtentScrollController(initialItem: chest - 20); + waistController = FixedExtentScrollController(initialItem: waist - 20); + hipController = FixedExtentScrollController(initialItem: hip - 20); + } else { + chestController = FixedExtentScrollController(); + waistController = FixedExtentScrollController(); + hipController = FixedExtentScrollController(); + } + showModalBottomSheet( + useRootNavigator: true, + context: context, + builder: (context) { + return Column( + children: [ + Expanded( + child: Row( + children: [ + Expanded( + child: CupertinoPicker( + magnification: 1.22, + squeeze: 1.2, + useMagnifier: true, + scrollController: chestController, + itemExtent: 24, + onSelectedItemChanged: (int value) { + chest = value; + }, + children: [ + for (int i = 20; i < 200; i++) Text('$i'), + ], + ), + ), + Expanded( + child: CupertinoPicker( + magnification: 1.22, + squeeze: 1.2, + useMagnifier: true, + scrollController: waistController, + itemExtent: 24, + onSelectedItemChanged: (int value) { + waist = value; + }, + children: [ + for (int i = 20; i < 200; i++) Text('$i'), + ], + ), + ), + Expanded( + child: CupertinoPicker( + magnification: 1.22, + squeeze: 1.2, + useMagnifier: true, + scrollController: hipController, + itemExtent: 24, + onSelectedItemChanged: (int value) { + hip = value; + }, + children: [ + for (int i = 20; i < 200; i++) Text('$i'), + ], + ), + ), + ], + ), + ), + InkWell( + onTap: () { + widget.profileCubit.addCircumference( + chestCircumference: chest + 20, + waistCircumference: waist + 20, + hipCircumference: hip + 20, + ); + Navigator.of(context).pop(); + }, + borderRadius: BorderRadius.circular(16), + child: Ink( + width: MediaQuery.of(context).size.width - 32, + padding: EdgeInsets.all(16), + decoration: BoxDecoration( + color: appTheme.blueA400, + borderRadius: BorderRadius.circular(16), + ), + child: Center( + child: Text( + 'Сохранить', + style: TextStyle( + color: Colors.white, + ), + ), + ), + ), + ), + ], + ); + }, + ); + }, + backgroundColor: appTheme.blueA400, + shape: CircleBorder(), + child: Icon( + Icons.add, + color: Colors.white, + ), + ), + ], ), - ), - primaryYAxis: NumericAxis( - labelFormat: '{value} см', - axisLine: AxisLine( - width: 1, - ), - majorTickLines: MajorTickLines(size: 0), - ), - series: _getSplineSeries(), - tooltipBehavior: TooltipBehavior(enable: true), + ], ); } - List> _getSplineSeries() { + List> _getSplineSeries() { final Color seriesColor1 = Colors.red; - final Color seriesColor2 = Colors.blue; + final Color seriesColor2 = appTheme.blueA400; final Color seriesColor3 = Colors.green; - return >[ - SplineSeries( + return >[ + SplineAreaSeries( markerSettings: MarkerSettings( isVisible: true, color: seriesColor1, - height: 12, - width: 12, + height: 8, + width: 8, ), dataLabelSettings: DataLabelSettings( labelAlignment: ChartDataLabelAlignment.top, isVisible: true, ), - dataSource: chartData, - color: seriesColor1, + dataSource: widget.circumferencePoints, + borderColor: seriesColor1, + gradient: LinearGradient( + colors: [ + seriesColor1.withOpacity(0.14), + Colors.transparent, + ], + begin: Alignment.topCenter, + end: Alignment(0, 0.6), + ), name: 'Грудь', - xValueMapper: (Circumference value, int index) => value.createdAt, - yValueMapper: (Circumference value, int index) => value.chestCircumference, + xValueMapper: (CircumferenceModel value, int index) => value.createdAt, + yValueMapper: (CircumferenceModel value, int index) => value.chestCircumference, ), - SplineSeries( + SplineAreaSeries( markerSettings: MarkerSettings( isVisible: true, color: seriesColor2, - height: 12, - width: 12, + height: 8, + width: 8, ), dataLabelSettings: DataLabelSettings( labelAlignment: ChartDataLabelAlignment.top, isVisible: true, ), - dataSource: chartData, - color: seriesColor2, + dataSource: widget.circumferencePoints, + borderColor: seriesColor2, + gradient: LinearGradient( + colors: [ + seriesColor2.withOpacity(0.14), + Colors.transparent, + ], + begin: Alignment.topCenter, + end: Alignment(0, 0.6), + ), name: 'Талия', - xValueMapper: (Circumference value, int index) => value.createdAt, - yValueMapper: (Circumference value, int index) => value.waistCircumference, + xValueMapper: (CircumferenceModel value, int index) => value.createdAt, + yValueMapper: (CircumferenceModel value, int index) => value.waistCircumference, ), - SplineSeries( + SplineAreaSeries( markerSettings: MarkerSettings( isVisible: true, color: seriesColor3, - height: 12, - width: 12, + height: 8, + width: 8, ), dataLabelSettings: DataLabelSettings( labelAlignment: ChartDataLabelAlignment.top, isVisible: true, ), - dataSource: chartData, - color: seriesColor3, + dataSource: widget.circumferencePoints, + borderColor: seriesColor3, + gradient: LinearGradient( + colors: [ + seriesColor3.withOpacity(0.14), + Colors.transparent, + ], + begin: Alignment.topCenter, + end: Alignment(0, 0.6), + ), name: 'Бёдра', - xValueMapper: (Circumference value, int index) => value.createdAt, - yValueMapper: (Circumference value, int index) => value.hipCircumference, + xValueMapper: (CircumferenceModel value, int index) => value.createdAt, + yValueMapper: (CircumferenceModel 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 index 275a5810..abd8e05b 100644 --- a/lib/features/profile/presentation/widgets/imt_chart_widget.dart +++ b/lib/features/profile/presentation/widgets/imt_chart_widget.dart @@ -1,68 +1,113 @@ -import 'package:eatvio_app/features/profile/models/profile_model.dart' as ProfileModel; +import 'package:eatvio_app/features/profile/models/weight_model.dart'; +import 'package:eatvio_app/theme/theme_helper.dart'; import 'package:flutter/material.dart'; import 'package:syncfusion_flutter_charts/charts.dart'; import 'package:intl/intl.dart'; class ImtChartWidget extends StatelessWidget { - final List chartPoints; + final List weightPoints; const ImtChartWidget({ super.key, - required this.chartPoints, + required this.weightPoints, }); @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, + return Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Padding( + padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8), + child: Row( + children: [ + Text( + '${weightPoints.last.bmi.toStringAsFixed(2)}', + style: TextStyle( + color: Colors.black, + fontSize: 40, + fontWeight: FontWeight.w500, + ), + ), + weightPoints.last.bmi > weightPoints[weightPoints.length - 2].bmi + ? Icon( + Icons.arrow_drop_up, + size: 40, + color: Colors.grey, + ) + : Icon( + Icons.arrow_drop_down, + size: 40, + color: Colors.grey, + ), + ], + ), ), - ), - primaryYAxis: NumericAxis( - labelFormat: '{value} кг', - axisLine: AxisLine( - width: 1, + SfCartesianChart( + margin: EdgeInsets.symmetric(horizontal: 8), + enableAxisAnimation: true, + plotAreaBorderWidth: 0, + trackballBehavior: TrackballBehavior( + enable: true, + activationMode: ActivationMode.singleTap, + tooltipDisplayMode: TrackballDisplayMode.groupAllPoints, + tooltipSettings: InteractiveTooltip(), + lineType: TrackballLineType.vertical, + ), + primaryXAxis: DateTimeCategoryAxis( + initialVisibleMinimum: weightPoints.first.createdAt, + initialVisibleMaximum: weightPoints.last.createdAt, + tickPosition: TickPosition.inside, + majorTickLines: MajorTickLines( + size: 0, + ), + edgeLabelPlacement: EdgeLabelPlacement.shift, + dateFormat: DateFormat.MMMd('ru'), + labelStyle: TextStyle( + color: Colors.grey, + ), + majorGridLines: MajorGridLines(dashArray: [1], color: Colors.grey.withOpacity(0.3)), + axisLine: AxisLine( + color: Colors.grey.withOpacity(0.3), + width: 0.4, + ), + ), + primaryYAxis: NumericAxis( + isVisible: false, + ), + series: _getSplineSeries(), + tooltipBehavior: TooltipBehavior(enable: true), ), - majorTickLines: MajorTickLines(size: 0), - ), - series: _getSplineSeries(), - tooltipBehavior: TooltipBehavior(enable: true), + ], ); } - List> _getSplineSeries() { - return >[ - SplineSeries( + List> _getSplineSeries() { + return >[ + SplineAreaSeries( markerSettings: MarkerSettings( isVisible: true, - color: Colors.blue, - height: 12, - width: 12, + color: appTheme.blueA400, + height: 8, + width: 8, ), dataLabelSettings: DataLabelSettings( labelAlignment: ChartDataLabelAlignment.top, isVisible: true, ), - dataSource: chartPoints, - color: Colors.blue, + dataSource: weightPoints, + borderColor: appTheme.blueA400, + gradient: LinearGradient( + colors: [ + appTheme.blueA400.withOpacity(0.14), + Colors.transparent, + ], + begin: Alignment.topCenter, + end: Alignment(0, 0.6), + ), name: 'ИМТ', - xValueMapper: (ProfileModel.ChartPoint value, int index) => value.createdAt, - yValueMapper: (ProfileModel.ChartPoint value, int index) => double.parse(value.bmi), + xValueMapper: (WeightModel value, int index) => value.createdAt, + yValueMapper: (WeightModel value, int index) => double.parse(value.bmi.toStringAsFixed(2)), ), ]; } diff --git a/lib/features/profile/presentation/widgets/weight_chart_widget.dart b/lib/features/profile/presentation/widgets/weight_chart_widget.dart index eabad3ec..b1c2b7db 100644 --- a/lib/features/profile/presentation/widgets/weight_chart_widget.dart +++ b/lib/features/profile/presentation/widgets/weight_chart_widget.dart @@ -1,68 +1,241 @@ -import 'package:eatvio_app/features/profile/models/profile_model.dart' as ProfileModel; +import 'package:eatvio_app/features/profile/models/weight_model.dart'; +import 'package:eatvio_app/features/profile/presentation/bloc/profile_cubit/profile_cubit.dart'; +import 'package:eatvio_app/theme/theme_helper.dart'; +import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_charts/charts.dart'; import 'package:intl/intl.dart'; +import 'package:syncfusion_flutter_charts/charts.dart'; -class WeightChartWidget extends StatelessWidget { - final List chartPoints; +class WeightChartWidget extends StatefulWidget { + final List weightPoints; + final ProfileCubit profileCubit; const WeightChartWidget({ super.key, - required this.chartPoints, + required this.weightPoints, + required this.profileCubit, }); + @override + State createState() => _WeightChartWidgetState(); +} + +class _WeightChartWidgetState extends State { + late FixedExtentScrollController weightKiloController; + late FixedExtentScrollController weightGramsController; + late int weightKilo; + late int weightGrams; + @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, + return Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + if (widget.weightPoints.isNotEmpty) + Padding( + padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8), + child: Row( + children: [ + Text( + '${widget.weightPoints.last.weight.toStringAsFixed(1)} кг', + style: TextStyle( + color: Colors.black, + fontSize: 40, + fontWeight: FontWeight.w500, + ), + ), + if (widget.weightPoints.length == 1) + Container( + margin: EdgeInsets.symmetric(horizontal: 12), + width: 8, + height: 8, + decoration: BoxDecoration( + shape: BoxShape.circle, + color: Colors.black12, + ), + ), + if (widget.weightPoints.length > 1) + widget.weightPoints.last.weight > widget.weightPoints[widget.weightPoints.length - 2].weight + ? Icon( + Icons.arrow_drop_up, + size: 40, + color: Colors.grey.withOpacity(0.4), + ) + : Icon( + Icons.arrow_drop_down, + size: 40, + color: Colors.grey.withOpacity(0.4), + ), + ], + ), + ), + Stack( + alignment: Alignment.bottomRight, + children: [ + SfCartesianChart( + margin: EdgeInsets.symmetric(horizontal: 8), + enableAxisAnimation: true, + plotAreaBorderWidth: 0, + trackballBehavior: TrackballBehavior( + enable: true, + activationMode: ActivationMode.singleTap, + tooltipDisplayMode: TrackballDisplayMode.groupAllPoints, + tooltipSettings: InteractiveTooltip(), + lineType: TrackballLineType.vertical, + ), + primaryXAxis: DateTimeCategoryAxis( + tickPosition: TickPosition.inside, + majorTickLines: MajorTickLines( + size: 0, + ), + edgeLabelPlacement: EdgeLabelPlacement.shift, + dateFormat: DateFormat.MMMd('ru'), + labelStyle: TextStyle( + color: Colors.grey, + ), + majorGridLines: MajorGridLines(dashArray: [1], color: Colors.grey.withOpacity(0.3)), + axisLine: AxisLine( + color: Colors.grey.withOpacity(0.3), + width: 0.4, + ), + ), + primaryYAxis: NumericAxis( + isVisible: false, + labelFormat: '{value} кг', + majorGridLines: MajorGridLines(dashArray: [1], color: Colors.grey), + axisLine: AxisLine( + width: 1, + ), + majorTickLines: MajorTickLines(size: 0), + ), + series: _getSplineSeries(), + tooltipBehavior: TooltipBehavior(enable: true), + ), + FloatingActionButton.small( + heroTag: 'addWeight', + onPressed: () { + if (widget.weightPoints.isNotEmpty) { + try { + weightKilo = int.parse(widget.weightPoints.last.weight.toString().split('.')[0]); + weightGrams = int.parse(widget.weightPoints.last.weight.toString().split('.')[1][0]); + } catch (e) { + weightGrams = 0; + } + weightKiloController = FixedExtentScrollController(initialItem: weightKilo - 20); + weightGramsController = FixedExtentScrollController(initialItem: weightGrams); + } else { + weightKiloController = FixedExtentScrollController(); + weightGramsController = FixedExtentScrollController(); + } + showModalBottomSheet( + useRootNavigator: true, + context: context, + builder: (context) { + return Column( + children: [ + Expanded( + child: Row( + children: [ + Expanded( + child: CupertinoPicker( + magnification: 1.22, + squeeze: 1.2, + useMagnifier: true, + scrollController: weightKiloController, + itemExtent: 24, + onSelectedItemChanged: (int value) { + weightKilo = value + 20; + }, + children: [ + for (int i = 20; i < 300; i++) Text('$i'), + ], + ), + ), + Expanded( + child: CupertinoPicker( + magnification: 1.22, + squeeze: 1.2, + useMagnifier: true, + scrollController: weightGramsController, + itemExtent: 24, + onSelectedItemChanged: (int value) { + weightGrams = value; + }, + children: [ + for (int i = 0; i < 10; i++) Text('$i'), + ], + ), + ), + ], + ), + ), + InkWell( + onTap: () { + widget.profileCubit.addWeight(weight: double.parse('$weightKilo.$weightGrams')); + Navigator.of(context).pop(); + }, + borderRadius: BorderRadius.circular(16), + child: Ink( + width: MediaQuery.of(context).size.width - 32, + padding: EdgeInsets.all(16), + decoration: BoxDecoration( + color: appTheme.blueA400, + borderRadius: BorderRadius.circular(16), + ), + child: Center( + child: Text( + 'Сохранить', + style: TextStyle( + color: Colors.white, + ), + ), + ), + ), + ), + ], + ); + }, + ); + }, + backgroundColor: appTheme.blueA400, + shape: CircleBorder(), + child: Icon( + Icons.add, + color: Colors.white, + ), + ), + ], ), - ), - primaryYAxis: NumericAxis( - labelFormat: '{value} кг', - axisLine: AxisLine( - width: 1, - ), - majorTickLines: MajorTickLines(size: 0), - ), - series: _getSplineSeries(), - tooltipBehavior: TooltipBehavior(enable: true), + ], ); } - List> _getSplineSeries() { - return >[ - SplineSeries( + List> _getSplineSeries() { + return >[ + SplineAreaSeries( markerSettings: MarkerSettings( isVisible: true, - color: Colors.blue, - height: 12, - width: 12, + color: appTheme.blueA400, + height: 8, + width: 8, ), dataLabelSettings: DataLabelSettings( labelAlignment: ChartDataLabelAlignment.top, isVisible: true, ), - dataSource: chartPoints, - color: Colors.blue, + dataSource: widget.weightPoints, + borderColor: appTheme.blueA400, + gradient: LinearGradient( + colors: [ + appTheme.blueA400.withOpacity(0.14), + Colors.transparent, + ], + begin: Alignment.topCenter, + end: Alignment(0, 0.6), + ), name: 'Вес', - xValueMapper: (ProfileModel.ChartPoint value, int index) => value.createdAt, - yValueMapper: (ProfileModel.ChartPoint value, int index) => value.weight, + xValueMapper: (WeightModel value, int index) => value.createdAt, + yValueMapper: (WeightModel value, int index) => value.weight, ), ]; } diff --git a/lib/features/profile/repositories/profile_repository.dart b/lib/features/profile/repositories/profile_repository.dart index e859c8d6..2e927ca0 100644 --- a/lib/features/profile/repositories/profile_repository.dart +++ b/lib/features/profile/repositories/profile_repository.dart @@ -1,4 +1,7 @@ +import 'package:eatvio_app/features/feed/models/feed_blog_post_model.dart'; +import 'package:eatvio_app/features/profile/models/circumference_model.dart'; import 'package:eatvio_app/features/profile/models/profile_model.dart'; +import 'package:eatvio_app/features/profile/models/weight_model.dart'; import 'package:eatvio_app/features/profile/services/profile_service.dart'; class ProfileRepository { @@ -22,7 +25,15 @@ class ProfileRepository { } } - Future addCircumference({ + Future getMyProfileDetails() async { + try { + return await profileService.getMyProfileDetails(); + } catch (e) { + rethrow; + } + } + + Future addCircumference({ required int chestCircumference, required int waistCircumference, required int hipCircumference, @@ -32,23 +43,70 @@ class ProfileRepository { chestCircumference: chestCircumference, waistCircumference: waistCircumference, hipCircumference: hipCircumference, - )) - .values - .first; + )); } catch (e) { rethrow; } } - Future addWeight({ - required int weight, + Future addWeight({ + required double weight, }) async { try { - return (await profileService.addWeight( - weight: weight, + return (await profileService.addWeight(weight: weight)); + } catch (e) { + rethrow; + } + } + + Future> getBlogPostsByAuthorSlug({ + required String slug, + }) async { + try { + return (await profileService.getBlogPostByAuthorSlug( + slug: slug, )) - .values - .first; + .feedBlogPostList; + } catch (e) { + rethrow; + } + } + + Future> getWeight({ + required String period, + String? slug, + }) async { + try { + if (slug != null) { + return (await profileService.getWeightBySlug( + period: period, + slug: slug, + )); + } else { + return (await profileService.getWeight( + period: period, + )); + } + } catch (e) { + rethrow; + } + } + + Future> getCircumferences({ + required String period, + String? slug, + }) async { + try { + if (slug != null) { + return (await profileService.getCircumferencesBySlug( + period: period, + slug: slug, + )); + } else { + return (await profileService.getCircumferences( + period: period, + )); + } } catch (e) { rethrow; } diff --git a/lib/features/profile/services/profile_service.dart b/lib/features/profile/services/profile_service.dart index 9966a82d..f5490213 100644 --- a/lib/features/profile/services/profile_service.dart +++ b/lib/features/profile/services/profile_service.dart @@ -1,5 +1,8 @@ import 'package:dio/dio.dart'; +import 'package:eatvio_app/features/feed/models/feed_blog_post_settings_model.dart'; +import 'package:eatvio_app/features/profile/models/circumference_model.dart'; import 'package:eatvio_app/features/profile/models/profile_model.dart'; +import 'package:eatvio_app/features/profile/models/weight_model.dart'; import 'package:retrofit/retrofit.dart'; part 'profile_service.g.dart'; @@ -16,15 +19,45 @@ abstract class ProfileService { @GET('/api/profile/index') Future getMyProfile(); + @GET('/api/profile/detailz') + Future getMyProfileDetails(); + @POST('/api/profile/addCircumference') - Future> 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, + Future addWeight({ + @Part() required double weight, + }); + + @GET('/api/blogPosts/search_by_author/{slug}') + Future getBlogPostByAuthorSlug({ + @Path() required String slug, + }); + + @GET('/api/profile/measure/weight/{period}') + Future> getWeight({ + @Path() required String period, + }); + + @GET('/api/profile/measure/weight/{period}/{slug}') + Future> getWeightBySlug({ + @Path() required String period, + @Path() required String slug, + }); + + @GET('/api/profile/measure/circumferences/{period}') + Future> getCircumferences({ + @Path() required String period, + }); + + @GET('/api/profile/measure/circumferences/{period}/{user}') + Future> getCircumferencesBySlug({ + @Path() required String period, + @Path() required String slug, }); } diff --git a/lib/features/profile/services/profile_service.g.dart b/lib/features/profile/services/profile_service.g.dart index 96b65b4d..36b64eb3 100644 --- a/lib/features/profile/services/profile_service.g.dart +++ b/lib/features/profile/services/profile_service.g.dart @@ -88,7 +88,40 @@ class _ProfileService implements ProfileService { } @override - Future> addCircumference({ + Future getMyProfileDetails() 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/detailz', + queryParameters: queryParameters, + data: _data, + ) + .copyWith( + baseUrl: _combineBaseUrls( + _dio.options.baseUrl, + baseUrl, + ))); + final _result = await _dio.fetch>(_options); + late ProfileDetailsModel _value; + try { + _value = ProfileDetailsModel.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, @@ -109,7 +142,7 @@ class _ProfileService implements ProfileService { 'hip_circumference', hipCircumference.toString(), )); - final _options = _setStreamType>(Options( + final _options = _setStreamType(Options( method: 'POST', headers: _headers, extra: _extra, @@ -125,20 +158,11 @@ class _ProfileService implements ProfileService { _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; + await _dio.fetch(_options); } @override - Future> addWeight({required int weight}) async { + Future addWeight({required double weight}) async { final _extra = {}; final queryParameters = {}; final _headers = {}; @@ -147,7 +171,7 @@ class _ProfileService implements ProfileService { 'weight', weight.toString(), )); - final _options = _setStreamType>(Options( + final _options = _setStreamType(Options( method: 'POST', headers: _headers, extra: _extra, @@ -163,11 +187,185 @@ class _ProfileService implements ProfileService { _dio.options.baseUrl, baseUrl, ))); + await _dio.fetch(_options); + } + + @override + Future getBlogPostByAuthorSlug( + {required String slug}) 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/blogPosts/search_by_author/${slug}', + queryParameters: queryParameters, + data: _data, + ) + .copyWith( + baseUrl: _combineBaseUrls( + _dio.options.baseUrl, + baseUrl, + ))); final _result = await _dio.fetch>(_options); - late Map _value; + late FeedBlogPostSettingsModel _value; try { - _value = _result.data!.map((k, dynamic v) => - MapEntry(k, ChartPoint.fromJson(v as Map))); + _value = FeedBlogPostSettingsModel.fromJson(_result.data!); + } on Object catch (e, s) { + errorLogger?.logError(e, s, _options); + rethrow; + } + return _value; + } + + @override + Future> getWeight({required String period}) 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/measure/weight/${period}', + queryParameters: queryParameters, + data: _data, + ) + .copyWith( + baseUrl: _combineBaseUrls( + _dio.options.baseUrl, + baseUrl, + ))); + final _result = await _dio.fetch>(_options); + late List _value; + try { + _value = _result.data! + .map((dynamic i) => WeightModel.fromJson(i as Map)) + .toList(); + } on Object catch (e, s) { + errorLogger?.logError(e, s, _options); + rethrow; + } + return _value; + } + + @override + Future> getWeightBySlug({ + required String period, + required String slug, + }) 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/measure/weight/${period}/${slug}', + queryParameters: queryParameters, + data: _data, + ) + .copyWith( + baseUrl: _combineBaseUrls( + _dio.options.baseUrl, + baseUrl, + ))); + final _result = await _dio.fetch>(_options); + late List _value; + try { + _value = _result.data! + .map((dynamic i) => WeightModel.fromJson(i as Map)) + .toList(); + } on Object catch (e, s) { + errorLogger?.logError(e, s, _options); + rethrow; + } + return _value; + } + + @override + Future> getCircumferences( + {required String period}) 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/measure/circumferences/${period}', + queryParameters: queryParameters, + data: _data, + ) + .copyWith( + baseUrl: _combineBaseUrls( + _dio.options.baseUrl, + baseUrl, + ))); + final _result = await _dio.fetch>(_options); + late List _value; + try { + _value = _result.data! + .map((dynamic i) => + CircumferenceModel.fromJson(i as Map)) + .toList(); + } on Object catch (e, s) { + errorLogger?.logError(e, s, _options); + rethrow; + } + return _value; + } + + @override + Future> getCircumferencesBySlug({ + required String period, + required String slug, + }) 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/measure/circumferences/${period}/{user}', + queryParameters: queryParameters, + data: _data, + ) + .copyWith( + baseUrl: _combineBaseUrls( + _dio.options.baseUrl, + baseUrl, + ))); + final _result = await _dio.fetch>(_options); + late List _value; + try { + _value = _result.data! + .map((dynamic i) => + CircumferenceModel.fromJson(i as Map)) + .toList(); } 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 63f3facb..2bf96fb3 100644 --- a/lib/features/recipes/models/ingredient.freezed.dart +++ b/lib/features/recipes/models/ingredient.freezed.dart @@ -24,8 +24,12 @@ mixin _$Ingredient { String get unit => throw _privateConstructorUsedError; String get portion => throw _privateConstructorUsedError; + /// Serializes this Ingredient to a JSON map. Map toJson() => throw _privateConstructorUsedError; - @JsonKey(ignore: true) + + /// Create a copy of Ingredient + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) $IngredientCopyWith get copyWith => throw _privateConstructorUsedError; } @@ -49,6 +53,8 @@ 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({ @@ -92,6 +98,8 @@ 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({ @@ -147,11 +155,13 @@ class _$IngredientImpl implements _Ingredient { (identical(other.portion, portion) || other.portion == portion)); } - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) @override int get hashCode => Object.hash(runtimeType, name, unit, portion); - @JsonKey(ignore: true) + /// Create a copy of Ingredient + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$IngredientImplCopyWith<_$IngredientImpl> get copyWith => @@ -180,8 +190,11 @@ 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(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) _$$IngredientImplCopyWith<_$IngredientImpl> get copyWith => throw _privateConstructorUsedError; } diff --git a/lib/features/recipes/models/recipe_model.dart b/lib/features/recipes/models/recipe_model.dart index 8b5b8c56..04add902 100644 --- a/lib/features/recipes/models/recipe_model.dart +++ b/lib/features/recipes/models/recipe_model.dart @@ -3,6 +3,7 @@ import 'package:eatvio_app/features/recipes/models/step.dart'; import 'package:freezed_annotation/freezed_annotation.dart'; part 'recipe_model.freezed.dart'; + part 'recipe_model.g.dart'; @freezed diff --git a/lib/features/recipes/models/recipe_model.freezed.dart b/lib/features/recipes/models/recipe_model.freezed.dart index fb93e70a..691ac1f3 100644 --- a/lib/features/recipes/models/recipe_model.freezed.dart +++ b/lib/features/recipes/models/recipe_model.freezed.dart @@ -30,8 +30,12 @@ mixin _$RecipeModel { String? get image => throw _privateConstructorUsedError; int? get cooking_time => throw _privateConstructorUsedError; + /// Serializes this RecipeModel to a JSON map. Map toJson() => throw _privateConstructorUsedError; - @JsonKey(ignore: true) + + /// Create a copy of RecipeModel + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) $RecipeModelCopyWith get copyWith => throw _privateConstructorUsedError; } @@ -64,6 +68,8 @@ 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({ @@ -146,6 +152,8 @@ 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({ @@ -279,7 +287,7 @@ class _$RecipeModelImpl implements _RecipeModel { other.cooking_time == cooking_time)); } - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) @override int get hashCode => Object.hash( runtimeType, @@ -293,7 +301,9 @@ class _$RecipeModelImpl implements _RecipeModel { image, cooking_time); - @JsonKey(ignore: true) + /// Create a copy of RecipeModel + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$RecipeModelImplCopyWith<_$RecipeModelImpl> get copyWith => @@ -340,8 +350,11 @@ 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(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) _$$RecipeModelImplCopyWith<_$RecipeModelImpl> get copyWith => throw _privateConstructorUsedError; } diff --git a/lib/features/recipes/models/recipe_tag_model.dart b/lib/features/recipes/models/recipe_tag_model.dart new file mode 100644 index 00000000..11850791 --- /dev/null +++ b/lib/features/recipes/models/recipe_tag_model.dart @@ -0,0 +1,30 @@ +import 'package:eatvio_app/core/models/pagination_model.dart'; +import 'package:freezed_annotation/freezed_annotation.dart'; + +part 'recipe_tag_model.freezed.dart'; + +part 'recipe_tag_model.g.dart'; + +@freezed +class RecipeTagModel with _$RecipeTagModel { + const factory RecipeTagModel({ + @JsonKey(name: "data") required List data, + @JsonKey(name: "links") required Links links, + @JsonKey(name: "meta") required Meta meta, + }) = _RecipeTagModel; + + factory RecipeTagModel.fromJson(Map json) => _$RecipeTagModelFromJson(json); +} + +@freezed +class RecipeTag with _$RecipeTag { + const factory RecipeTag({ + @JsonKey(name: "id") required int id, + @JsonKey(name: "name") required String name, + @JsonKey(name: "recipes_count") required int recipesCount, + @JsonKey(name: "created_at") required DateTime createdAt, + @JsonKey(name: "updated_at") required DateTime updatedAt, + }) = _RecipeTag; + + factory RecipeTag.fromJson(Map json) => _$RecipeTagFromJson(json); +} diff --git a/lib/features/recipes/models/recipe_tag_model.freezed.dart b/lib/features/recipes/models/recipe_tag_model.freezed.dart new file mode 100644 index 00000000..d9993da3 --- /dev/null +++ b/lib/features/recipes/models/recipe_tag_model.freezed.dart @@ -0,0 +1,506 @@ +// 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 'recipe_tag_model.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'); + +RecipeTagModel _$RecipeTagModelFromJson(Map json) { + return _RecipeTagModel.fromJson(json); +} + +/// @nodoc +mixin _$RecipeTagModel { + @JsonKey(name: "data") + List get data => throw _privateConstructorUsedError; + @JsonKey(name: "links") + Links get links => throw _privateConstructorUsedError; + @JsonKey(name: "meta") + Meta get meta => throw _privateConstructorUsedError; + + /// Serializes this RecipeTagModel to a JSON map. + Map toJson() => throw _privateConstructorUsedError; + + /// Create a copy of RecipeTagModel + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $RecipeTagModelCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $RecipeTagModelCopyWith<$Res> { + factory $RecipeTagModelCopyWith( + RecipeTagModel value, $Res Function(RecipeTagModel) then) = + _$RecipeTagModelCopyWithImpl<$Res, RecipeTagModel>; + @useResult + $Res call( + {@JsonKey(name: "data") List data, + @JsonKey(name: "links") Links links, + @JsonKey(name: "meta") Meta meta}); + + $LinksCopyWith<$Res> get links; + $MetaCopyWith<$Res> get meta; +} + +/// @nodoc +class _$RecipeTagModelCopyWithImpl<$Res, $Val extends RecipeTagModel> + implements $RecipeTagModelCopyWith<$Res> { + _$RecipeTagModelCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of RecipeTagModel + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? data = null, + Object? links = null, + Object? meta = null, + }) { + return _then(_value.copyWith( + data: null == data + ? _value.data + : data // ignore: cast_nullable_to_non_nullable + as List, + links: null == links + ? _value.links + : links // ignore: cast_nullable_to_non_nullable + as Links, + meta: null == meta + ? _value.meta + : meta // ignore: cast_nullable_to_non_nullable + as Meta, + ) as $Val); + } + + /// Create a copy of RecipeTagModel + /// with the given fields replaced by the non-null parameter values. + @override + @pragma('vm:prefer-inline') + $LinksCopyWith<$Res> get links { + return $LinksCopyWith<$Res>(_value.links, (value) { + return _then(_value.copyWith(links: value) as $Val); + }); + } + + /// Create a copy of RecipeTagModel + /// with the given fields replaced by the non-null parameter values. + @override + @pragma('vm:prefer-inline') + $MetaCopyWith<$Res> get meta { + return $MetaCopyWith<$Res>(_value.meta, (value) { + return _then(_value.copyWith(meta: value) as $Val); + }); + } +} + +/// @nodoc +abstract class _$$RecipeTagModelImplCopyWith<$Res> + implements $RecipeTagModelCopyWith<$Res> { + factory _$$RecipeTagModelImplCopyWith(_$RecipeTagModelImpl value, + $Res Function(_$RecipeTagModelImpl) then) = + __$$RecipeTagModelImplCopyWithImpl<$Res>; + @override + @useResult + $Res call( + {@JsonKey(name: "data") List data, + @JsonKey(name: "links") Links links, + @JsonKey(name: "meta") Meta meta}); + + @override + $LinksCopyWith<$Res> get links; + @override + $MetaCopyWith<$Res> get meta; +} + +/// @nodoc +class __$$RecipeTagModelImplCopyWithImpl<$Res> + extends _$RecipeTagModelCopyWithImpl<$Res, _$RecipeTagModelImpl> + implements _$$RecipeTagModelImplCopyWith<$Res> { + __$$RecipeTagModelImplCopyWithImpl( + _$RecipeTagModelImpl _value, $Res Function(_$RecipeTagModelImpl) _then) + : super(_value, _then); + + /// Create a copy of RecipeTagModel + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? data = null, + Object? links = null, + Object? meta = null, + }) { + return _then(_$RecipeTagModelImpl( + data: null == data + ? _value._data + : data // ignore: cast_nullable_to_non_nullable + as List, + links: null == links + ? _value.links + : links // ignore: cast_nullable_to_non_nullable + as Links, + meta: null == meta + ? _value.meta + : meta // ignore: cast_nullable_to_non_nullable + as Meta, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$RecipeTagModelImpl implements _RecipeTagModel { + const _$RecipeTagModelImpl( + {@JsonKey(name: "data") required final List data, + @JsonKey(name: "links") required this.links, + @JsonKey(name: "meta") required this.meta}) + : _data = data; + + factory _$RecipeTagModelImpl.fromJson(Map json) => + _$$RecipeTagModelImplFromJson(json); + + final List _data; + @override + @JsonKey(name: "data") + List get data { + if (_data is EqualUnmodifiableListView) return _data; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(_data); + } + + @override + @JsonKey(name: "links") + final Links links; + @override + @JsonKey(name: "meta") + final Meta meta; + + @override + String toString() { + return 'RecipeTagModel(data: $data, links: $links, meta: $meta)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$RecipeTagModelImpl && + const DeepCollectionEquality().equals(other._data, _data) && + (identical(other.links, links) || other.links == links) && + (identical(other.meta, meta) || other.meta == meta)); + } + + @JsonKey(includeFromJson: false, includeToJson: false) + @override + int get hashCode => Object.hash( + runtimeType, const DeepCollectionEquality().hash(_data), links, meta); + + /// Create a copy of RecipeTagModel + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$RecipeTagModelImplCopyWith<_$RecipeTagModelImpl> get copyWith => + __$$RecipeTagModelImplCopyWithImpl<_$RecipeTagModelImpl>( + this, _$identity); + + @override + Map toJson() { + return _$$RecipeTagModelImplToJson( + this, + ); + } +} + +abstract class _RecipeTagModel implements RecipeTagModel { + const factory _RecipeTagModel( + {@JsonKey(name: "data") required final List data, + @JsonKey(name: "links") required final Links links, + @JsonKey(name: "meta") required final Meta meta}) = _$RecipeTagModelImpl; + + factory _RecipeTagModel.fromJson(Map json) = + _$RecipeTagModelImpl.fromJson; + + @override + @JsonKey(name: "data") + List get data; + @override + @JsonKey(name: "links") + Links get links; + @override + @JsonKey(name: "meta") + Meta get meta; + + /// Create a copy of RecipeTagModel + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + _$$RecipeTagModelImplCopyWith<_$RecipeTagModelImpl> get copyWith => + throw _privateConstructorUsedError; +} + +RecipeTag _$RecipeTagFromJson(Map json) { + return _RecipeTag.fromJson(json); +} + +/// @nodoc +mixin _$RecipeTag { + @JsonKey(name: "id") + int get id => throw _privateConstructorUsedError; + @JsonKey(name: "name") + String get name => throw _privateConstructorUsedError; + @JsonKey(name: "recipes_count") + int get recipesCount => throw _privateConstructorUsedError; + @JsonKey(name: "created_at") + DateTime get createdAt => throw _privateConstructorUsedError; + @JsonKey(name: "updated_at") + DateTime get updatedAt => throw _privateConstructorUsedError; + + /// Serializes this RecipeTag to a JSON map. + Map toJson() => throw _privateConstructorUsedError; + + /// Create a copy of RecipeTag + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $RecipeTagCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $RecipeTagCopyWith<$Res> { + factory $RecipeTagCopyWith(RecipeTag value, $Res Function(RecipeTag) then) = + _$RecipeTagCopyWithImpl<$Res, RecipeTag>; + @useResult + $Res call( + {@JsonKey(name: "id") int id, + @JsonKey(name: "name") String name, + @JsonKey(name: "recipes_count") int recipesCount, + @JsonKey(name: "created_at") DateTime createdAt, + @JsonKey(name: "updated_at") DateTime updatedAt}); +} + +/// @nodoc +class _$RecipeTagCopyWithImpl<$Res, $Val extends RecipeTag> + implements $RecipeTagCopyWith<$Res> { + _$RecipeTagCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of RecipeTag + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? id = null, + Object? name = null, + Object? recipesCount = 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, + name: null == name + ? _value.name + : name // ignore: cast_nullable_to_non_nullable + as String, + recipesCount: null == recipesCount + ? _value.recipesCount + : recipesCount // 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 _$$RecipeTagImplCopyWith<$Res> + implements $RecipeTagCopyWith<$Res> { + factory _$$RecipeTagImplCopyWith( + _$RecipeTagImpl value, $Res Function(_$RecipeTagImpl) then) = + __$$RecipeTagImplCopyWithImpl<$Res>; + @override + @useResult + $Res call( + {@JsonKey(name: "id") int id, + @JsonKey(name: "name") String name, + @JsonKey(name: "recipes_count") int recipesCount, + @JsonKey(name: "created_at") DateTime createdAt, + @JsonKey(name: "updated_at") DateTime updatedAt}); +} + +/// @nodoc +class __$$RecipeTagImplCopyWithImpl<$Res> + extends _$RecipeTagCopyWithImpl<$Res, _$RecipeTagImpl> + implements _$$RecipeTagImplCopyWith<$Res> { + __$$RecipeTagImplCopyWithImpl( + _$RecipeTagImpl _value, $Res Function(_$RecipeTagImpl) _then) + : super(_value, _then); + + /// Create a copy of RecipeTag + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? id = null, + Object? name = null, + Object? recipesCount = null, + Object? createdAt = null, + Object? updatedAt = null, + }) { + return _then(_$RecipeTagImpl( + id: null == id + ? _value.id + : id // ignore: cast_nullable_to_non_nullable + as int, + name: null == name + ? _value.name + : name // ignore: cast_nullable_to_non_nullable + as String, + recipesCount: null == recipesCount + ? _value.recipesCount + : recipesCount // 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 _$RecipeTagImpl implements _RecipeTag { + const _$RecipeTagImpl( + {@JsonKey(name: "id") required this.id, + @JsonKey(name: "name") required this.name, + @JsonKey(name: "recipes_count") required this.recipesCount, + @JsonKey(name: "created_at") required this.createdAt, + @JsonKey(name: "updated_at") required this.updatedAt}); + + factory _$RecipeTagImpl.fromJson(Map json) => + _$$RecipeTagImplFromJson(json); + + @override + @JsonKey(name: "id") + final int id; + @override + @JsonKey(name: "name") + final String name; + @override + @JsonKey(name: "recipes_count") + final int recipesCount; + @override + @JsonKey(name: "created_at") + final DateTime createdAt; + @override + @JsonKey(name: "updated_at") + final DateTime updatedAt; + + @override + String toString() { + return 'RecipeTag(id: $id, name: $name, recipesCount: $recipesCount, createdAt: $createdAt, updatedAt: $updatedAt)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$RecipeTagImpl && + (identical(other.id, id) || other.id == id) && + (identical(other.name, name) || other.name == name) && + (identical(other.recipesCount, recipesCount) || + other.recipesCount == recipesCount) && + (identical(other.createdAt, createdAt) || + other.createdAt == createdAt) && + (identical(other.updatedAt, updatedAt) || + other.updatedAt == updatedAt)); + } + + @JsonKey(includeFromJson: false, includeToJson: false) + @override + int get hashCode => + Object.hash(runtimeType, id, name, recipesCount, createdAt, updatedAt); + + /// Create a copy of RecipeTag + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$RecipeTagImplCopyWith<_$RecipeTagImpl> get copyWith => + __$$RecipeTagImplCopyWithImpl<_$RecipeTagImpl>(this, _$identity); + + @override + Map toJson() { + return _$$RecipeTagImplToJson( + this, + ); + } +} + +abstract class _RecipeTag implements RecipeTag { + const factory _RecipeTag( + {@JsonKey(name: "id") required final int id, + @JsonKey(name: "name") required final String name, + @JsonKey(name: "recipes_count") required final int recipesCount, + @JsonKey(name: "created_at") required final DateTime createdAt, + @JsonKey(name: "updated_at") required final DateTime updatedAt}) = + _$RecipeTagImpl; + + factory _RecipeTag.fromJson(Map json) = + _$RecipeTagImpl.fromJson; + + @override + @JsonKey(name: "id") + int get id; + @override + @JsonKey(name: "name") + String get name; + @override + @JsonKey(name: "recipes_count") + int get recipesCount; + @override + @JsonKey(name: "created_at") + DateTime get createdAt; + @override + @JsonKey(name: "updated_at") + DateTime get updatedAt; + + /// Create a copy of RecipeTag + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + _$$RecipeTagImplCopyWith<_$RecipeTagImpl> get copyWith => + throw _privateConstructorUsedError; +} diff --git a/lib/features/recipes/models/recipe_tag_model.g.dart b/lib/features/recipes/models/recipe_tag_model.g.dart new file mode 100644 index 00000000..cd387547 --- /dev/null +++ b/lib/features/recipes/models/recipe_tag_model.g.dart @@ -0,0 +1,42 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'recipe_tag_model.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +_$RecipeTagModelImpl _$$RecipeTagModelImplFromJson(Map json) => + _$RecipeTagModelImpl( + data: (json['data'] as List) + .map((e) => RecipeTag.fromJson(e as Map)) + .toList(), + links: Links.fromJson(json['links'] as Map), + meta: Meta.fromJson(json['meta'] as Map), + ); + +Map _$$RecipeTagModelImplToJson( + _$RecipeTagModelImpl instance) => + { + 'data': instance.data, + 'links': instance.links, + 'meta': instance.meta, + }; + +_$RecipeTagImpl _$$RecipeTagImplFromJson(Map json) => + _$RecipeTagImpl( + id: (json['id'] as num).toInt(), + name: json['name'] as String, + recipesCount: (json['recipes_count'] as num).toInt(), + createdAt: DateTime.parse(json['created_at'] as String), + updatedAt: DateTime.parse(json['updated_at'] as String), + ); + +Map _$$RecipeTagImplToJson(_$RecipeTagImpl instance) => + { + 'id': instance.id, + 'name': instance.name, + 'recipes_count': instance.recipesCount, + 'created_at': instance.createdAt.toIso8601String(), + 'updated_at': instance.updatedAt.toIso8601String(), + }; diff --git a/lib/features/recipes/models/step.freezed.dart b/lib/features/recipes/models/step.freezed.dart index c2014f4f..040dd5aa 100644 --- a/lib/features/recipes/models/step.freezed.dart +++ b/lib/features/recipes/models/step.freezed.dart @@ -23,8 +23,12 @@ mixin _$Step { String? get image => throw _privateConstructorUsedError; String? get description => throw _privateConstructorUsedError; + /// Serializes this Step to a JSON map. Map toJson() => throw _privateConstructorUsedError; - @JsonKey(ignore: true) + + /// Create a copy of Step + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) $StepCopyWith get copyWith => throw _privateConstructorUsedError; } @@ -46,6 +50,8 @@ 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({ @@ -82,6 +88,8 @@ 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({ @@ -129,11 +137,13 @@ class _$StepImpl implements _Step { other.description == description)); } - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) @override int get hashCode => Object.hash(runtimeType, image, description); - @JsonKey(ignore: true) + /// Create a copy of Step + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$StepImplCopyWith<_$StepImpl> get copyWith => @@ -157,8 +167,11 @@ 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(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) _$$StepImplCopyWith<_$StepImpl> get copyWith => throw _privateConstructorUsedError; } diff --git a/lib/features/recipes/presentation/bloc/recipe_create_cubit.dart b/lib/features/recipes/presentation/bloc/recipe_create_cubit.dart index 5507c0ea..727317bc 100644 --- a/lib/features/recipes/presentation/bloc/recipe_create_cubit.dart +++ b/lib/features/recipes/presentation/bloc/recipe_create_cubit.dart @@ -1,10 +1,11 @@ -import 'package:eatvio_app/core/app_export.dart'; +import 'package:eatvio_app/data/models/selectionPopupModel/selection_popup_model.dart'; import 'package:eatvio_app/features/recipes/models/ingredient.dart'; import 'package:eatvio_app/features/recipes/models/recipe_model.dart'; import 'package:eatvio_app/features/recipes/presentation/bloc/recipe_create_state.dart'; import 'package:eatvio_app/features/recipes/reporitories/recipe_repository.dart'; import 'package:eatvio_app/features/diary/models/product.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:image_picker/image_picker.dart'; class RecipeCreateCubit extends Cubit { 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 9acea107..e15a1a52 100644 --- a/lib/features/recipes/presentation/bloc/recipe_create_state.freezed.dart +++ b/lib/features/recipes/presentation/bloc/recipe_create_state.freezed.dart @@ -147,6 +147,9 @@ 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 @@ -163,6 +166,9 @@ 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 @@ -343,6 +349,9 @@ 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 @@ -551,6 +560,8 @@ 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({ @@ -659,6 +670,8 @@ 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 { @@ -671,6 +684,8 @@ 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 { @@ -679,6 +694,8 @@ 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 { @@ -688,6 +705,8 @@ 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 { @@ -887,7 +906,9 @@ class _$RecipeCreateStateLoadedImpl implements RecipeCreateStateLoaded { selectedStatus ]); - @JsonKey(ignore: true) + /// Create a copy of RecipeCreateState + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$RecipeCreateStateLoadedImplCopyWith<_$RecipeCreateStateLoadedImpl> @@ -1136,7 +1157,10 @@ abstract class RecipeCreateStateLoaded implements RecipeCreateState { SelectionPopupModel get selectedType; SelectionPopupModel get selectedCookingTime; SelectionPopupModel get selectedStatus; - @JsonKey(ignore: true) + + /// Create a copy of RecipeCreateState + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) _$$RecipeCreateStateLoadedImplCopyWith<_$RecipeCreateStateLoadedImpl> get copyWith => throw _privateConstructorUsedError; } @@ -1160,6 +1184,8 @@ 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({ @@ -1199,7 +1225,9 @@ class _$RecipeCreateStateErrorImpl implements RecipeCreateStateError { @override int get hashCode => Object.hash(runtimeType, errorMessage); - @JsonKey(ignore: true) + /// Create a copy of RecipeCreateState + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$RecipeCreateStateErrorImplCopyWith<_$RecipeCreateStateErrorImpl> @@ -1349,7 +1377,10 @@ abstract class RecipeCreateStateError implements RecipeCreateState { _$RecipeCreateStateErrorImpl; String get errorMessage; - @JsonKey(ignore: true) + + /// Create a copy of RecipeCreateState + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) _$$RecipeCreateStateErrorImplCopyWith<_$RecipeCreateStateErrorImpl> get copyWith => throw _privateConstructorUsedError; } diff --git a/lib/features/recipes/presentation/pages/about_recipes_screen.dart b/lib/features/recipes/presentation/pages/about_recipes_screen.dart index 6955aa72..b54fed1f 100644 --- a/lib/features/recipes/presentation/pages/about_recipes_screen.dart +++ b/lib/features/recipes/presentation/pages/about_recipes_screen.dart @@ -1,16 +1,19 @@ import 'dart:io'; - import 'package:cached_network_image/cached_network_image.dart'; -import 'package:eatvio_app/core/app_export.dart'; -import 'package:eatvio_app/features/feed/models/comment_model.dart'; +import 'package:eatvio_app/core/const.dart'; + import 'package:eatvio_app/features/feed/models/recipes_model.dart' as step; import 'package:eatvio_app/features/feed/models/recipes_model.dart'; 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/features/feed/presentation/widgets/comments_widget.dart'; import 'package:eatvio_app/locator_service.dart'; -import 'package:flutter/cupertino.dart'; +import 'package:eatvio_app/theme/theme_helper.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:flutter_html/flutter_html.dart'; import 'package:go_router/go_router.dart'; +import 'package:rive/rive.dart'; class AboutRecipesScreen extends StatefulWidget { final Recipes recipes; @@ -26,21 +29,24 @@ class _AboutRecipesScreenState extends State { final textEditingController = TextEditingController(); int? replyId; - @override - void initState() { - super.initState(); - commentsCubit.getRecipesComments(widget.recipes.slug); - } - @override Widget build(BuildContext context) { return BlocProvider( - create: (BuildContext context) => commentsCubit, - child: BlocBuilder( - builder: (BuildContext context, CommentsState state) { - if (state is CommentsStateError) { - print(state.errorMessage); + create: (BuildContext context) => commentsCubit + ..getComments( + widget.recipes.slug, + CommentSourceType.recipe, + true, + ), + child: BlocConsumer( + listener: (BuildContext context, CommentsState state) { + if (state is CommentsStateLoaded) { + setState(() { + replyId = state.replyId; + }); } + }, + builder: (BuildContext context, CommentsState state) { return Scaffold( resizeToAvoidBottomInset: true, bottomSheet: Container( @@ -59,6 +65,7 @@ class _AboutRecipesScreenState extends State { if (replyId != null) GestureDetector( onTap: () { + context.read().setReplyId(null); setState(() { replyId = null; textEditingController.clear(); @@ -81,7 +88,7 @@ class _AboutRecipesScreenState extends State { ), if (replyId != null) SizedBox(width: 8), SizedBox( - width: mediaQueryData.size.width - (replyId == null ? 64 : 104), + width: MediaQuery.of(context).size.width - (replyId == null ? 64 : 104), child: TextFormField( onChanged: (_) { setState(() {}); @@ -135,11 +142,13 @@ class _AboutRecipesScreenState extends State { GestureDetector( onTap: () { if (textEditingController.text.length > 2) { - commentsCubit.sendRecipesComment( + commentsCubit.sendComment( id: widget.recipes.slug, commentText: textEditingController.text, parentCommentId: replyId, + commentSourceType: CommentSourceType.recipe, ); + context.read().setReplyId(null); setState(() { textEditingController.clear(); replyId = null; @@ -243,19 +252,18 @@ class _AboutRecipesScreenState extends State { ], ), ), - SizedBox(height: 12), - Padding( - padding: const EdgeInsets.symmetric(horizontal: 16), - child: Text( - widget.recipes.description, - style: TextStyle( - color: Colors.black, - fontSize: 14, - fontWeight: FontWeight.w400, - height: 1.2, + if (widget.recipes.description.isNotEmpty) + Padding( + padding: const EdgeInsets.symmetric(horizontal: 8), + child: Html( + data: widget.recipes.description, + style: { + "*": Style( + color: Colors.black87, + ), + }, ), ), - ), SizedBox(height: 12), CachedNetworkImage( imageUrl: baseUrl + '/storage/' + widget.recipes.image, @@ -312,6 +320,18 @@ class _AboutRecipesScreenState extends State { ), itemCount: widget.recipes.steps.length, ), + SizedBox(height: 8), + Padding( + padding: const EdgeInsets.all(16), + child: Container( + height: 0.4, + decoration: BoxDecoration( + color: Colors.grey, + borderRadius: BorderRadius.circular(16), + ), + ), + ), + SizedBox(height: 8), Container( padding: EdgeInsets.symmetric(horizontal: 16), alignment: Alignment.centerLeft, @@ -328,9 +348,21 @@ class _AboutRecipesScreenState extends State { if (state is CommentsStateLoading) Padding( padding: const EdgeInsets.all(32), - child: CupertinoActivityIndicator(), + child: SizedBox( + height: 32, + width: 32, + child: RiveAnimation.asset( + 'assets/rive_animations/loading.riv', + ), + ), + ), + if (state is CommentsStateLoaded) + CommentsWidget( + id: widget.recipes.slug, + commentSourceType: CommentSourceType.recipe, + comment: state.comment, + replyId: replyId, ), - if (state is CommentsStateLoaded) _buildComments(state.comment), ], ), ), @@ -393,100 +425,4 @@ class _AboutRecipesScreenState extends State { ], ); } - - _buildComments(Comment comment) { - return Column( - children: [ - for (int i = 0; i < comment.data.length; i++) ...[ - _comment(comment.data[i]), - if (comment.data[i].childrenComments.isNotEmpty) - for (int j = 0; j < comment.data[i].childrenComments.length; j++) - Padding( - padding: EdgeInsets.only(left: 40), - child: _comment( - comment.data[i].childrenComments[j], - 12, - ), - ), - SizedBox(height: 8), - ], - ], - ); - } - - _comment(Datum datum, [double radius = 16]) { - return Container( - width: MediaQuery.of(context).size.width, - decoration: BoxDecoration( - color: replyId == datum.id ? appTheme.blueA400.withOpacity(0.1) : Colors.white, - borderRadius: BorderRadius.circular(16), - ), - child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 16), - child: Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - CircleAvatar( - foregroundImage: NetworkImage(datum.authorProfileIcon), - radius: radius, - ), - SizedBox(width: 8), - Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisAlignment: MainAxisAlignment.start, - children: [ - Text( - datum.authorName, - style: TextStyle( - height: 1, - color: Colors.grey.shade600, - fontWeight: FontWeight.w500, - ), - ), - SizedBox(width: 4), - Text( - datum.body, - style: TextStyle( - height: 1, - color: Colors.black, - ), - ), - SizedBox(height: 4), - Row( - children: [ - Text( - widget.recipes.createdAt.format('dd MMMM', 'ru'), - style: TextStyle( - color: Colors.grey.shade600, - fontSize: 12, - fontWeight: FontWeight.w400, - height: 1, - ), - ), - SizedBox(width: 16), - GestureDetector( - onTap: () { - setState(() { - replyId = datum.id; - }); - }, - child: Text( - 'Ответить', - style: TextStyle( - height: 1, - fontSize: 12, - color: Colors.grey.shade800, - fontWeight: FontWeight.w500, - ), - ), - ), - ], - ), - ], - ), - ], - ), - ), - ); - } } diff --git a/lib/features/recipes/presentation/pages/recipe_create_screen.dart b/lib/features/recipes/presentation/pages/recipe_create_screen.dart index f40bfc1e..eb1339b4 100644 --- a/lib/features/recipes/presentation/pages/recipe_create_screen.dart +++ b/lib/features/recipes/presentation/pages/recipe_create_screen.dart @@ -1,53 +1,66 @@ import 'dart:convert'; import 'dart:io'; -import 'package:eatvio_app/core/app_export.dart'; + import 'package:eatvio_app/features/diary/models/product.dart'; import 'package:eatvio_app/features/recipes/models/ingredient.dart'; import 'package:eatvio_app/features/recipes/models/recipe_model.dart'; import 'package:eatvio_app/features/recipes/models/step.dart' as step; import 'package:eatvio_app/features/recipes/presentation/bloc/recipe_create_cubit.dart'; import 'package:eatvio_app/features/recipes/presentation/bloc/recipe_create_state.dart'; +import 'package:eatvio_app/locator_service.dart'; +import 'package:eatvio_app/theme/app_decoration.dart'; +import 'package:eatvio_app/theme/custom_text_style.dart'; +import 'package:eatvio_app/theme/theme_helper.dart'; import 'package:eatvio_app/widgets/custom_drop_down.dart'; import 'package:eatvio_app/widgets/custom_text_form_field.dart'; import 'package:flutter/material.dart'; -import 'package:flutter/cupertino.dart'; import 'package:flutter/services.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:image_picker/image_picker.dart'; +import 'package:rive/rive.dart' as rive; -// ignore: must_be_immutable class RecipeCreateScreen extends StatelessWidget { RecipeCreateScreen({Key? key}) : super(key: key); + Widget build(BuildContext context) { - context.read().loadRecipeCreate(); - return BlocBuilder( - builder: (context, state) { - if (state is RecipeCreateStateLoaded) { - return _buildRecipeCreate(context, state); - } else if (state is RecipeCreateStateLoading) { - return Scaffold( - body: Center( - child: CupertinoActivityIndicator(), - ), - ); - } else if (state is RecipeCreateStateError) { - return Scaffold( - body: Padding( - padding: const EdgeInsets.all(16), - child: Center( - child: Text(state.errorMessage), + return BlocProvider( + create: (context) => sl()..loadRecipeCreate(), + child: BlocBuilder( + builder: (context, state) { + if (state is RecipeCreateStateLoaded) { + return _buildRecipeCreate(context, state); + } else if (state is RecipeCreateStateLoading) { + return Scaffold( + body: Center( + child: SizedBox( + height: 32, + width: 32, + child: rive.RiveAnimation.asset( + 'assets/rive_animations/loading.riv', + ), + ), ), - ), - ); - } else - return Scaffold( - body: Padding( - padding: const EdgeInsets.all(16), - child: Center( - child: Text("Неопределенная ошибка"), + ); + } else if (state is RecipeCreateStateError) { + return Scaffold( + body: Padding( + padding: const EdgeInsets.all(16), + child: Center( + child: Text(state.errorMessage), + ), ), - ), - ); - }, + ); + } else + return Scaffold( + body: Padding( + padding: const EdgeInsets.all(16), + child: Center( + child: Text("Неопределенная ошибка"), + ), + ), + ); + }, + ), ); } @@ -386,10 +399,10 @@ class RecipeCreateScreen extends StatelessWidget { _buildIngredient(Ingredient ingredient) { return Container( - margin: EdgeInsets.symmetric(horizontal: 10.h), + margin: EdgeInsets.symmetric(horizontal: 12), padding: EdgeInsets.symmetric( - horizontal: 8.h, - vertical: 6.v, + horizontal: 8, + vertical: 8, ), decoration: AppDecoration.fillGray.copyWith( borderRadius: BorderRadiusStyle.roundedBorder5, @@ -400,8 +413,8 @@ class RecipeCreateScreen extends StatelessWidget { children: [ Padding( padding: EdgeInsets.only( - left: 7.h, - top: 5.v, + left: 8, + top: 8, ), child: Text( ingredient.name.length > 8 ? ingredient.name.substring(0, 8) : ingredient.name, @@ -410,12 +423,12 @@ class RecipeCreateScreen extends StatelessWidget { ), Padding( padding: EdgeInsets.only( - left: 20.h, - top: 3.v, - bottom: 3.v, + left: 24, + top: 4, + bottom: 4, ), child: Text( - ingredient.portion.toString() + ' ' + ingredient.unit.toString().tr, + ingredient.portion.toString() + ' ' + ingredient.unit.toString(), ), ), Spacer(), diff --git a/lib/features/recipes/presentation/pages/recipe_edit_screen.dart b/lib/features/recipes/presentation/pages/recipe_edit_screen.dart index 62aa362e..dc435059 100644 --- a/lib/features/recipes/presentation/pages/recipe_edit_screen.dart +++ b/lib/features/recipes/presentation/pages/recipe_edit_screen.dart @@ -1,24 +1,30 @@ -import 'package:eatvio_app/core/app_export.dart'; +import 'package:eatvio_app/core/const.dart'; import 'package:eatvio_app/features/diary/models/product.dart'; import 'package:eatvio_app/features/recipes/models/ingredient.dart'; import 'package:eatvio_app/features/recipes/models/recipe_model.dart'; import 'package:eatvio_app/features/recipes/models/step.dart' as step; import 'package:eatvio_app/features/recipes/presentation/bloc/recipe_create_cubit.dart'; import 'package:eatvio_app/features/recipes/presentation/bloc/recipe_create_state.dart'; +import 'package:eatvio_app/theme/app_decoration.dart'; +import 'package:eatvio_app/theme/custom_text_style.dart'; +import 'package:eatvio_app/theme/theme_helper.dart'; import 'package:eatvio_app/widgets/custom_drop_down.dart'; import 'package:eatvio_app/widgets/custom_text_form_field.dart'; import 'package:flutter/material.dart'; -import 'package:flutter/cupertino.dart'; import 'package:flutter/services.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:image_picker/image_picker.dart'; +import 'package:rive/rive.dart' as rive; // ignore: must_be_immutable class RecipeEditScreen extends StatelessWidget { final String recipeID; + const RecipeEditScreen({ required this.recipeID, super.key, }); + Widget build(BuildContext context) { if (recipeID != "0") { context.read().loadRecipeById(recipeID); @@ -30,7 +36,13 @@ class RecipeEditScreen extends StatelessWidget { } else if (state is RecipeCreateStateLoading) { return Scaffold( body: Center( - child: CupertinoActivityIndicator(), + child: SizedBox( + height: 32, + width: 32, + child: rive.RiveAnimation.asset( + 'assets/rive_animations/loading.riv', + ), + ), ), ); } else if (state is RecipeCreateStateError) { @@ -395,10 +407,10 @@ class RecipeEditScreen extends StatelessWidget { _buildIngredient(Ingredient ingredient) { return Container( - margin: EdgeInsets.symmetric(horizontal: 10.h), + margin: EdgeInsets.symmetric(horizontal: 12), padding: EdgeInsets.symmetric( - horizontal: 8.h, - vertical: 6.v, + horizontal: 8, + vertical: 8, ), decoration: AppDecoration.fillGray.copyWith( borderRadius: BorderRadiusStyle.roundedBorder5, @@ -409,8 +421,8 @@ class RecipeEditScreen extends StatelessWidget { children: [ Padding( padding: EdgeInsets.only( - left: 7.h, - top: 5.v, + left: 8, + top: 8, ), child: Text( ingredient.name.length > 8 ? ingredient.name.substring(0, 8) : ingredient.name, @@ -419,12 +431,12 @@ class RecipeEditScreen extends StatelessWidget { ), Padding( padding: EdgeInsets.only( - left: 20.h, - top: 3.v, - bottom: 3.v, + left: 24, + top: 4, + bottom: 4, ), child: Text( - ingredient.portion.toString() + ' ' + ingredient.unit.toString().tr, + ingredient.portion.toString() + ' ' + ingredient.unit.toString(), ), ), Spacer(), diff --git a/lib/features/recipes/reporitories/recipe_repository.dart b/lib/features/recipes/reporitories/recipe_repository.dart index e27013c7..cf9a355e 100644 --- a/lib/features/recipes/reporitories/recipe_repository.dart +++ b/lib/features/recipes/reporitories/recipe_repository.dart @@ -2,6 +2,7 @@ import 'dart:convert'; import 'dart:io'; import 'package:eatvio_app/features/recipes/models/recipe_model.dart'; +import 'package:eatvio_app/features/recipes/models/recipe_tag_model.dart'; import 'package:eatvio_app/features/recipes/services/recipe_service.dart'; import 'package:eatvio_app/features/diary/models/product.dart'; @@ -71,4 +72,12 @@ class RecipeRepository { rethrow; } } + + Future> getRecipesTags() async { + try { + return (await recipeService.getTags()).data; + } catch (e) { + rethrow; + } + } } diff --git a/lib/features/recipes/services/recipe_service.dart b/lib/features/recipes/services/recipe_service.dart index d92e6b9c..f0a5e200 100644 --- a/lib/features/recipes/services/recipe_service.dart +++ b/lib/features/recipes/services/recipe_service.dart @@ -3,6 +3,7 @@ import 'dart:io'; import 'package:dio/dio.dart'; import 'package:eatvio_app/features/recipes/models/recipe_model.dart'; +import 'package:eatvio_app/features/recipes/models/recipe_tag_model.dart'; import 'package:retrofit/retrofit.dart'; import 'package:eatvio_app/features/diary/models/product.dart'; @@ -33,4 +34,7 @@ abstract class RecipeService { @POST('/api/recipes/update/{id}') Future editRecipe(@Part() Map recipe, String id); + + @GET('/api/recipes/tags') + Future getTags(); } diff --git a/lib/features/recipes/services/recipe_service.g.dart b/lib/features/recipes/services/recipe_service.g.dart index 43cb10a8..c32c9e8a 100644 --- a/lib/features/recipes/services/recipe_service.g.dart +++ b/lib/features/recipes/services/recipe_service.g.dart @@ -220,6 +220,39 @@ class _RecipeService implements RecipeService { return _value; } + @override + Future getTags() 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/recipes/tags', + queryParameters: queryParameters, + data: _data, + ) + .copyWith( + baseUrl: _combineBaseUrls( + _dio.options.baseUrl, + baseUrl, + ))); + final _result = await _dio.fetch>(_options); + late RecipeTagModel _value; + try { + _value = RecipeTagModel.fromJson(_result.data!); + } on Object catch (e, s) { + errorLogger?.logError(e, s, _options); + rethrow; + } + return _value; + } + RequestOptions _setStreamType(RequestOptions requestOptions) { if (T != dynamic && !(requestOptions.responseType == ResponseType.bytes || diff --git a/lib/features/registration/models/location_model.dart b/lib/features/registration/models/location_model.dart index 01dbe06f..c669bdfd 100644 --- a/lib/features/registration/models/location_model.dart +++ b/lib/features/registration/models/location_model.dart @@ -1,6 +1,7 @@ import 'package:freezed_annotation/freezed_annotation.dart'; part 'location_model.freezed.dart'; + part 'location_model.g.dart'; @freezed diff --git a/lib/features/registration/models/location_model.freezed.dart b/lib/features/registration/models/location_model.freezed.dart index f640ca2e..95f81d60 100644 --- a/lib/features/registration/models/location_model.freezed.dart +++ b/lib/features/registration/models/location_model.freezed.dart @@ -24,8 +24,12 @@ mixin _$LocationModel { @JsonKey(name: 'response_body') String get responseBody => throw _privateConstructorUsedError; + /// Serializes this LocationModel to a JSON map. Map toJson() => throw _privateConstructorUsedError; - @JsonKey(ignore: true) + + /// Create a copy of LocationModel + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) $LocationModelCopyWith get copyWith => throw _privateConstructorUsedError; } @@ -51,6 +55,8 @@ 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({ @@ -91,6 +97,8 @@ 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({ @@ -149,12 +157,14 @@ class _$LocationModelImpl implements _LocationModel { other.responseBody == responseBody)); } - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) @override int get hashCode => Object.hash(runtimeType, const DeepCollectionEquality().hash(_locations), responseBody); - @JsonKey(ignore: true) + /// Create a copy of LocationModel + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$LocationModelImplCopyWith<_$LocationModelImpl> get copyWith => @@ -182,8 +192,11 @@ 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(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) _$$LocationModelImplCopyWith<_$LocationModelImpl> get copyWith => throw _privateConstructorUsedError; } diff --git a/lib/data/models/userRegistrationModel/user_registration_model.dart b/lib/features/registration/models/user_registration_model.dart similarity index 99% rename from lib/data/models/userRegistrationModel/user_registration_model.dart rename to lib/features/registration/models/user_registration_model.dart index 419ee5c7..64b9c9e5 100644 --- a/lib/data/models/userRegistrationModel/user_registration_model.dart +++ b/lib/features/registration/models/user_registration_model.dart @@ -1,6 +1,7 @@ import 'package:freezed_annotation/freezed_annotation.dart'; part 'user_registration_model.freezed.dart'; + part 'user_registration_model.g.dart'; @freezed diff --git a/lib/data/models/userRegistrationModel/user_registration_model.freezed.dart b/lib/features/registration/models/user_registration_model.freezed.dart similarity index 97% rename from lib/data/models/userRegistrationModel/user_registration_model.freezed.dart rename to lib/features/registration/models/user_registration_model.freezed.dart index 4a15327c..fd835a26 100644 --- a/lib/data/models/userRegistrationModel/user_registration_model.freezed.dart +++ b/lib/features/registration/models/user_registration_model.freezed.dart @@ -68,8 +68,12 @@ mixin _$UserRegistrationSheet { @JsonKey(name: 'activity_coefficient') double get activityCoefficient => throw _privateConstructorUsedError; + /// Serializes this UserRegistrationSheet to a JSON map. Map toJson() => throw _privateConstructorUsedError; - @JsonKey(ignore: true) + + /// Create a copy of UserRegistrationSheet + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) $UserRegistrationSheetCopyWith get copyWith => throw _privateConstructorUsedError; } @@ -121,6 +125,8 @@ 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({ @@ -313,6 +319,8 @@ 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({ @@ -627,7 +635,7 @@ class _$UserRegistrationSheetImpl implements _UserRegistrationSheet { other.activityCoefficient == activityCoefficient)); } - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) @override int get hashCode => Object.hashAll([ runtimeType, @@ -660,7 +668,9 @@ class _$UserRegistrationSheetImpl implements _UserRegistrationSheet { activityCoefficient ]); - @JsonKey(ignore: true) + /// Create a copy of UserRegistrationSheet + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$UserRegistrationSheetImplCopyWith<_$UserRegistrationSheetImpl> @@ -787,8 +797,11 @@ 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(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) _$$UserRegistrationSheetImplCopyWith<_$UserRegistrationSheetImpl> get copyWith => throw _privateConstructorUsedError; } diff --git a/lib/data/models/userRegistrationModel/user_registration_model.g.dart b/lib/features/registration/models/user_registration_model.g.dart similarity index 100% rename from lib/data/models/userRegistrationModel/user_registration_model.g.dart rename to lib/features/registration/models/user_registration_model.g.dart diff --git a/lib/features/registration/presentation/bloc/registration_cubit/registration_cubit.dart b/lib/features/registration/presentation/bloc/registration_cubit/registration_cubit.dart index cbb2e16d..89406741 100644 --- a/lib/features/registration/presentation/bloc/registration_cubit/registration_cubit.dart +++ b/lib/features/registration/presentation/bloc/registration_cubit/registration_cubit.dart @@ -1,9 +1,10 @@ import 'package:eatvio_app/app_router.dart'; -import 'package:eatvio_app/core/app_export.dart'; + import 'package:eatvio_app/core/token_storage.dart'; -import 'package:eatvio_app/data/models/userRegistrationModel/user_registration_model.dart'; +import 'package:eatvio_app/features/registration/models/user_registration_model.dart'; import 'package:eatvio_app/features/registration/presentation/bloc/registration_cubit/registration_state.dart'; import 'package:eatvio_app/features/registration/repositories/registration_repository.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:go_router/go_router.dart'; class RegistrationCubit extends Cubit { diff --git a/lib/features/registration/presentation/bloc/registration_cubit/registration_state.dart b/lib/features/registration/presentation/bloc/registration_cubit/registration_state.dart index d1e20906..37fe0a43 100644 --- a/lib/features/registration/presentation/bloc/registration_cubit/registration_state.dart +++ b/lib/features/registration/presentation/bloc/registration_cubit/registration_state.dart @@ -1,4 +1,4 @@ -import 'package:eatvio_app/data/models/userRegistrationModel/user_registration_model.dart'; +import 'package:eatvio_app/features/registration/models/user_registration_model.dart'; import 'package:freezed_annotation/freezed_annotation.dart'; part 'registration_state.freezed.dart'; 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 dcb49236..ae0a9706 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,7 +18,9 @@ final _privateConstructorUsedError = UnsupportedError( mixin _$RegistrationState { UserRegistrationSheet get sheet => throw _privateConstructorUsedError; - @JsonKey(ignore: true) + /// Create a copy of RegistrationState + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) $RegistrationStateCopyWith get copyWith => throw _privateConstructorUsedError; } @@ -44,6 +46,8 @@ 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({ @@ -57,6 +61,8 @@ 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 { @@ -88,6 +94,8 @@ 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({ @@ -126,7 +134,9 @@ class _$RegistrationStateImpl implements _RegistrationState { @override int get hashCode => Object.hash(runtimeType, sheet); - @JsonKey(ignore: true) + /// Create a copy of RegistrationState + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$RegistrationStateImplCopyWith<_$RegistrationStateImpl> get copyWith => @@ -140,8 +150,11 @@ 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(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) _$$RegistrationStateImplCopyWith<_$RegistrationStateImpl> get copyWith => throw _privateConstructorUsedError; } diff --git a/lib/features/registration/presentation/pages/additional_information_screen.dart b/lib/features/registration/presentation/pages/additional_information_screen.dart index 159a599f..01ce3ffa 100644 --- a/lib/features/registration/presentation/pages/additional_information_screen.dart +++ b/lib/features/registration/presentation/pages/additional_information_screen.dart @@ -1,8 +1,8 @@ -import 'package:eatvio_app/core/app_export.dart'; -import 'package:eatvio_app/data/models/userRegistrationModel/user_registration_model.dart'; +import 'package:eatvio_app/features/registration/models/user_registration_model.dart'; import 'package:eatvio_app/features/registration/presentation/bloc/registration_cubit/registration_cubit.dart'; import 'package:eatvio_app/widgets/custom_text_form_field.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; class AdditionalInformationScreen extends StatefulWidget { final UserRegistrationSheet sheet; diff --git a/lib/features/registration/presentation/pages/allergies_screen.dart b/lib/features/registration/presentation/pages/allergies_screen.dart index 5a4e4bc3..430c4438 100644 --- a/lib/features/registration/presentation/pages/allergies_screen.dart +++ b/lib/features/registration/presentation/pages/allergies_screen.dart @@ -1,8 +1,9 @@ -import 'package:eatvio_app/core/app_export.dart'; -import 'package:eatvio_app/data/models/userRegistrationModel/user_registration_model.dart'; +import 'package:eatvio_app/features/registration/models/user_registration_model.dart'; import 'package:eatvio_app/features/registration/presentation/bloc/registration_cubit/registration_cubit.dart'; +import 'package:eatvio_app/generated/l10n.dart'; import 'package:eatvio_app/widgets/custom_text_form_field.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; class AllergiesScreen extends StatefulWidget { final UserRegistrationSheet sheet; @@ -26,12 +27,13 @@ class _AllergiesScreenState extends State { @override Widget build(BuildContext context) { + final s = S.of(context); return SingleChildScrollView( padding: EdgeInsets.only(bottom: 80, left: 16, right: 16, top: 16), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Text("allergies_presence".tr), + Text(s.allergies_presence), SizedBox(height: 4), CustomTextFormField( controller: enterInformationController, diff --git a/lib/features/registration/presentation/pages/blood_pressure_screen.dart b/lib/features/registration/presentation/pages/blood_pressure_screen.dart index d22cf321..5d390876 100644 --- a/lib/features/registration/presentation/pages/blood_pressure_screen.dart +++ b/lib/features/registration/presentation/pages/blood_pressure_screen.dart @@ -1,10 +1,14 @@ -import 'package:eatvio_app/core/app_export.dart'; -import 'package:eatvio_app/data/models/userRegistrationModel/user_registration_model.dart'; +import 'package:eatvio_app/core/utils/image_constant.dart'; +import 'package:eatvio_app/data/models/selectionPopupModel/selection_popup_model.dart'; +import 'package:eatvio_app/features/registration/models/user_registration_model.dart'; import 'package:eatvio_app/features/registration/presentation/bloc/registration_cubit/registration_cubit.dart'; +import 'package:eatvio_app/generated/l10n.dart'; import 'package:eatvio_app/widgets/custom_drop_down.dart'; +import 'package:eatvio_app/widgets/custom_image_view.dart'; import 'package:eatvio_app/widgets/custom_text_form_field.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; class BloodPressureScreen extends StatefulWidget { final UserRegistrationSheet sheet; @@ -49,46 +53,53 @@ class _BloodPressureScreenState extends State { @override Widget build(BuildContext context) { + final s = S.of(context); return SingleChildScrollView( padding: EdgeInsets.only(bottom: 80, left: 16, right: 16, top: 16), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Text("up_pressure".tr), + Text(s.up_pressure), SizedBox(height: 4), CustomTextFormField( inputFormatters: [digitsOnly], controller: upPressureController, autofocus: true, focusNode: upFocusNode, - hintText: "90".tr, + hintText: "90", onChanged: (newValue) { final registrationCubit = context.read(); registrationCubit.updateSheet(registrationCubit.state.sheet.copyWith(bloodPressureUp: int.parse(newValue))); }, ), SizedBox(height: 16), - Text("down_pressure".tr), + Text(s.down_pressure), SizedBox(height: 4), CustomTextFormField( inputFormatters: [digitsOnly], controller: downPressureController, - hintText: "90".tr, + hintText: '90', onChanged: (newValue) { final registrationCubit = context.read(); registrationCubit.updateSheet(registrationCubit.state.sheet.copyWith(bloodPressureDown: int.parse(newValue))); }, ), SizedBox(height: 16), - Text("do_you_have_hypotension_tendency".tr), + Text(s.do_you_have_hypotension_tendency), SizedBox(height: 4), CustomDropDown( icon: Container( - margin: EdgeInsets.fromLTRB(30.h, 11.v, 13.h, 11.v), - decoration: BoxDecoration(borderRadius: BorderRadius.circular(1.h)), - child: CustomImageView(imagePath: ImageConstant.imgFavorite, height: 12.adaptSize, width: 12.adaptSize), + margin: EdgeInsets.all(16), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(4), + ), + child: CustomImageView( + imagePath: ImageConstant.imgFavorite, + height: 16, + width: 16, + ), ), - hintText: "Не выбрано".tr, + hintText: "Не выбрано", items: selectionPopupList, value: selectedPopupHypo, onChanged: (newPopup) { @@ -100,15 +111,21 @@ class _BloodPressureScreenState extends State { }, ), SizedBox(height: 16), - Text("do_you_have_hypertension_tendency".tr), + Text(s.do_you_have_hypertension_tendency), SizedBox(height: 4), CustomDropDown( icon: Container( - margin: EdgeInsets.fromLTRB(30.h, 11.v, 13.h, 11.v), - decoration: BoxDecoration(borderRadius: BorderRadius.circular(1.h)), - child: CustomImageView(imagePath: ImageConstant.imgFavorite, height: 12.adaptSize, width: 12.adaptSize), + margin: EdgeInsets.all(16), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(4), + ), + child: CustomImageView( + imagePath: ImageConstant.imgFavorite, + height: 16, + width: 16, + ), ), - hintText: "Не выбрано".tr, + hintText: "Не выбрано", items: selectionPopupList, value: selectedPopupHyper, onChanged: (newPopup) { diff --git a/lib/features/registration/presentation/pages/body_circumferences_screen.dart b/lib/features/registration/presentation/pages/body_circumferences_screen.dart index a086da35..0f6fc0f2 100644 --- a/lib/features/registration/presentation/pages/body_circumferences_screen.dart +++ b/lib/features/registration/presentation/pages/body_circumferences_screen.dart @@ -1,9 +1,10 @@ -import 'package:eatvio_app/core/app_export.dart'; -import 'package:eatvio_app/data/models/userRegistrationModel/user_registration_model.dart'; +import 'package:eatvio_app/features/registration/models/user_registration_model.dart'; import 'package:eatvio_app/features/registration/presentation/bloc/registration_cubit/registration_cubit.dart'; +import 'package:eatvio_app/generated/l10n.dart'; import 'package:eatvio_app/widgets/custom_text_form_field.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; class BodyCircumferencesScreen extends StatefulWidget { final UserRegistrationSheet sheet; @@ -32,43 +33,44 @@ class _BodyCircumferencesScreenState extends State { @override Widget build(BuildContext context) { + final s = S.of(context); return SingleChildScrollView( padding: EdgeInsets.only(bottom: 80, left: 16, right: 16, top: 16), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Text("chest_circumference".tr), + Text(s.chest_circumference), SizedBox(height: 4), CustomTextFormField( inputFormatters: [digitsOnly], autofocus: true, focusNode: chestFocus, controller: chestCircumferenceController, - hintText: "90".tr, + hintText: '90', onChanged: (value) { final registrationCubit = context.read(); registrationCubit.updateSheet(registrationCubit.state.sheet.copyWith(chestCircumference: int.parse(value))); }, ), SizedBox(height: 16), - Text("waist_circumference".tr), + Text(s.waist_circumference), SizedBox(height: 4), CustomTextFormField( inputFormatters: [digitsOnly], controller: waistCircumferenceController, - hintText: "60".tr, + hintText: "60", onChanged: (value) { final registrationCubit = context.read(); registrationCubit.updateSheet(registrationCubit.state.sheet.copyWith(waistCircumference: int.parse(value))); }, ), SizedBox(height: 16), - Text("hip_circumference".tr), + Text(s.hip_circumference), SizedBox(height: 4), CustomTextFormField( inputFormatters: [digitsOnly], controller: hipCircumferenceController, - hintText: "90".tr, + hintText: '90', textInputAction: TextInputAction.done, onChanged: (value) { final registrationCubit = context.read(); diff --git a/lib/features/registration/presentation/pages/city_of_living_screen.dart b/lib/features/registration/presentation/pages/city_of_living_screen.dart index b4c8cbeb..fffbd19e 100644 --- a/lib/features/registration/presentation/pages/city_of_living_screen.dart +++ b/lib/features/registration/presentation/pages/city_of_living_screen.dart @@ -1,9 +1,11 @@ -import 'package:eatvio_app/core/app_export.dart'; -import 'package:eatvio_app/data/models/userRegistrationModel/user_registration_model.dart'; +import 'package:eatvio_app/data/models/selectionPopupModel/selection_popup_model.dart'; +import 'package:eatvio_app/features/registration/models/user_registration_model.dart'; import 'package:eatvio_app/features/registration/presentation/bloc/registration_cubit/registration_cubit.dart'; -import 'package:eatvio_app/widgets/custom_edit_text_form_field.dart'; +import 'package:eatvio_app/theme/theme_helper.dart'; +import 'package:eatvio_app/widgets/custom_text_form_field.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_typeahead/flutter_typeahead.dart'; import 'package:location/location.dart'; diff --git a/lib/features/registration/presentation/pages/credentials_screen.dart b/lib/features/registration/presentation/pages/credentials_screen.dart index 25b0a2a1..325b3d89 100644 --- a/lib/features/registration/presentation/pages/credentials_screen.dart +++ b/lib/features/registration/presentation/pages/credentials_screen.dart @@ -1,8 +1,9 @@ -import 'package:eatvio_app/core/app_export.dart'; -import 'package:eatvio_app/data/models/userRegistrationModel/user_registration_model.dart'; +import 'package:eatvio_app/features/registration/models/user_registration_model.dart'; import 'package:eatvio_app/features/registration/presentation/bloc/registration_cubit/registration_cubit.dart'; +import 'package:eatvio_app/generated/l10n.dart'; import 'package:eatvio_app/widgets/custom_text_form_field.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; class CredentialsScreen extends StatefulWidget { final UserRegistrationSheet sheet; @@ -30,13 +31,14 @@ class _CredentialsScreenState extends State { @override Widget build(BuildContext context) { + final s = S.of(context); return SingleChildScrollView( padding: EdgeInsets.only(bottom: 80, top: 16, left: 16, right: 16), child: Column( mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.start, children: [ - Text("email".tr), + Text(s.email), SizedBox(height: 4), CustomTextFormField( controller: emailController, @@ -50,7 +52,7 @@ class _CredentialsScreenState extends State { }, ), SizedBox(height: 16), - Text("password".tr), + Text(s.password), SizedBox(height: 4), CustomTextFormField( obscureText: true, @@ -63,7 +65,7 @@ class _CredentialsScreenState extends State { }, ), SizedBox(height: 16), - Text("password_confirmation".tr), + Text(s.password_confirmation), SizedBox(height: 4), CustomTextFormField( obscureText: true, diff --git a/lib/features/registration/presentation/pages/date_of_birth_screen.dart b/lib/features/registration/presentation/pages/date_of_birth_screen.dart index 8d510c15..0ca4b3b9 100644 --- a/lib/features/registration/presentation/pages/date_of_birth_screen.dart +++ b/lib/features/registration/presentation/pages/date_of_birth_screen.dart @@ -1,8 +1,11 @@ -import 'package:eatvio_app/core/app_export.dart'; -import 'package:eatvio_app/data/models/userRegistrationModel/user_registration_model.dart'; +import 'package:eatvio_app/core/utils/date_time_utils.dart'; +import 'package:eatvio_app/features/registration/models/user_registration_model.dart'; import 'package:eatvio_app/features/registration/presentation/bloc/registration_cubit/registration_cubit.dart'; +import 'package:eatvio_app/generated/l10n.dart'; +import 'package:eatvio_app/theme/theme_helper.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:intl/intl.dart'; class DateOfBirthScreen extends StatefulWidget { @@ -31,12 +34,14 @@ class _DateOfBirthScreenState extends State { @override Widget build(BuildContext context) { + final s = S.of(context); + return SingleChildScrollView( padding: EdgeInsets.only(bottom: 80, top: 16, left: 16, right: 16), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Text("date_of_birth".tr), + Text(s.date_of_birth), SizedBox(height: 4), ListTile( onTap: onTapCalendar(context), @@ -67,7 +72,6 @@ class _DateOfBirthScreenState extends State { onDateTimeChanged: (DateTime newDateTime) { setState(() { selectedDate = newDateTime; - print(selectedDate); final registrationCubit = context.read(); registrationCubit.updateSheet(registrationCubit.state.sheet.copyWith(birthdate: selectedDate.toString())); }); @@ -82,15 +86,11 @@ class _DateOfBirthScreenState extends State { context: context, builder: (BuildContext context) => Container( height: 216, - padding: const EdgeInsets.only(top: 6.0), - // The Bottom margin is provided to align the popup above the system - // navigation bar. + padding: const EdgeInsets.only(top: 6), margin: EdgeInsets.only( bottom: MediaQuery.of(context).viewInsets.bottom, ), - // Provide a background color for the popup. color: CupertinoColors.systemBackground.resolveFrom(context), - // Use a SafeArea widget to avoid system overlaps. child: SafeArea( top: false, child: child, diff --git a/lib/features/registration/presentation/pages/favorite_foods_screen.dart b/lib/features/registration/presentation/pages/favorite_foods_screen.dart index bab999ab..2de9c71c 100644 --- a/lib/features/registration/presentation/pages/favorite_foods_screen.dart +++ b/lib/features/registration/presentation/pages/favorite_foods_screen.dart @@ -1,8 +1,9 @@ -import 'package:eatvio_app/core/app_export.dart'; -import 'package:eatvio_app/data/models/userRegistrationModel/user_registration_model.dart'; +import 'package:eatvio_app/features/registration/models/user_registration_model.dart'; import 'package:eatvio_app/features/registration/presentation/bloc/registration_cubit/registration_cubit.dart'; +import 'package:eatvio_app/generated/l10n.dart'; import 'package:eatvio_app/widgets/custom_text_form_field.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; class FavoriteFoodsScreen extends StatefulWidget { final UserRegistrationSheet sheet; @@ -28,16 +29,17 @@ class _FavoriteFoodsScreenState extends State { @override Widget build(BuildContext context) { + final s = S.of(context); return SingleChildScrollView( padding: EdgeInsets.only(bottom: 80, left: 16, right: 16, top: 16), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Text("favorite_foods".tr), + Text(s.favorite_foods), SizedBox(height: 4), CustomTextFormField( controller: favoriteFoodsController, - hintText: "enter_information".tr, + hintText: s.enter_information, maxLines: 7, minLines: 2, focusNode: favoriteFocusNode, @@ -48,11 +50,11 @@ class _FavoriteFoodsScreenState extends State { }, ), SizedBox(height: 16), - Text("unfavorite_foods".tr), + Text(s.unfavorite_foods), SizedBox(height: 4), CustomTextFormField( controller: unFavoriteFoodsController, - hintText: "enter_information".tr, + hintText: s.enter_information, textInputAction: TextInputAction.done, maxLines: 7, minLines: 2, diff --git a/lib/features/registration/presentation/pages/favorite_sports_screen.dart b/lib/features/registration/presentation/pages/favorite_sports_screen.dart index 2856ea75..bf54612e 100644 --- a/lib/features/registration/presentation/pages/favorite_sports_screen.dart +++ b/lib/features/registration/presentation/pages/favorite_sports_screen.dart @@ -1,8 +1,9 @@ -import 'package:eatvio_app/core/app_export.dart'; -import 'package:eatvio_app/data/models/userRegistrationModel/user_registration_model.dart'; +import 'package:eatvio_app/features/registration/models/user_registration_model.dart'; import 'package:eatvio_app/features/registration/presentation/bloc/registration_cubit/registration_cubit.dart'; +import 'package:eatvio_app/generated/l10n.dart'; import 'package:eatvio_app/widgets/custom_text_form_field.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; class FavoriteSportsScreen extends StatefulWidget { final UserRegistrationSheet sheet; @@ -26,12 +27,13 @@ class _FavoriteSportsScreenState extends State { @override Widget build(BuildContext context) { + final s = S.of(context); return SingleChildScrollView( padding: EdgeInsets.only(bottom: 80, left: 16, right: 16, top: 16), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Text("your_favorite_sports".tr), + Text(s.your_favorite_sports), SizedBox(height: 4), CustomTextFormField( controller: enterInformationController, diff --git a/lib/features/registration/presentation/pages/gender_screen.dart b/lib/features/registration/presentation/pages/gender_screen.dart index d1bec2f7..46d56da3 100644 --- a/lib/features/registration/presentation/pages/gender_screen.dart +++ b/lib/features/registration/presentation/pages/gender_screen.dart @@ -1,7 +1,7 @@ -import 'package:eatvio_app/core/app_export.dart'; -import 'package:eatvio_app/data/models/userRegistrationModel/user_registration_model.dart'; +import 'package:eatvio_app/features/registration/models/user_registration_model.dart'; import 'package:eatvio_app/features/registration/presentation/bloc/registration_cubit/registration_cubit.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; class GenderScreen extends StatefulWidget { final UserRegistrationSheet sheet; diff --git a/lib/features/registration/presentation/pages/height_screen.dart b/lib/features/registration/presentation/pages/height_screen.dart index 2aea3690..93ab620b 100644 --- a/lib/features/registration/presentation/pages/height_screen.dart +++ b/lib/features/registration/presentation/pages/height_screen.dart @@ -1,9 +1,10 @@ -import 'package:eatvio_app/core/app_export.dart'; -import 'package:eatvio_app/data/models/userRegistrationModel/user_registration_model.dart'; +import 'package:eatvio_app/features/registration/models/user_registration_model.dart'; import 'package:eatvio_app/features/registration/presentation/bloc/registration_cubit/registration_cubit.dart'; +import 'package:eatvio_app/generated/l10n.dart'; import 'package:eatvio_app/widgets/custom_text_form_field.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; class HeightScreen extends StatefulWidget { final UserRegistrationSheet sheet; @@ -27,12 +28,13 @@ class _HeightScreenState extends State { @override Widget build(BuildContext context) { + final s = S.of(context); return SingleChildScrollView( padding: EdgeInsets.only(bottom: 80, left: 16, right: 16, top: 16), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Text("your_height".tr), + Text(s.your_height), SizedBox(height: 4), CustomTextFormField( textInputAction: TextInputAction.done, diff --git a/lib/features/registration/presentation/pages/language_select_screen.dart b/lib/features/registration/presentation/pages/language_select_screen.dart index 4d95033e..ed167fc1 100644 --- a/lib/features/registration/presentation/pages/language_select_screen.dart +++ b/lib/features/registration/presentation/pages/language_select_screen.dart @@ -1,8 +1,10 @@ -import 'package:eatvio_app/core/app_export.dart'; -import 'package:eatvio_app/data/models/userRegistrationModel/user_registration_model.dart'; +import 'package:eatvio_app/data/models/selectionPopupModel/selection_popup_model.dart'; +import 'package:eatvio_app/features/registration/models/user_registration_model.dart'; import 'package:eatvio_app/features/registration/presentation/bloc/registration_cubit/registration_cubit.dart'; +import 'package:eatvio_app/generated/l10n.dart'; import 'package:eatvio_app/widgets/custom_drop_down.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; class LanguageSelectScreen extends StatefulWidget { final UserRegistrationSheet sheet; @@ -34,18 +36,19 @@ class _LanguageSelectScreenState extends State { @override Widget build(BuildContext context) { + final s = S.of(context); return SingleChildScrollView( padding: EdgeInsets.only(bottom: 80, right: 16, left: 16, top: 16), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( - "preferred_language".tr, + s.preferred_language, ), const SizedBox(height: 4), CustomDropDown( value: value, - hintText: "Не выбрано".tr, + hintText: "Не выбрано", items: dropdownItemList, onChanged: (SelectionPopupModel newValue) => setState(() { value = newValue; diff --git a/lib/features/registration/presentation/pages/medicine_intake_screen.dart b/lib/features/registration/presentation/pages/medicine_intake_screen.dart index fc09d084..2383bd16 100644 --- a/lib/features/registration/presentation/pages/medicine_intake_screen.dart +++ b/lib/features/registration/presentation/pages/medicine_intake_screen.dart @@ -1,8 +1,9 @@ -import 'package:eatvio_app/core/app_export.dart'; -import 'package:eatvio_app/data/models/userRegistrationModel/user_registration_model.dart'; +import 'package:eatvio_app/features/registration/models/user_registration_model.dart'; import 'package:eatvio_app/features/registration/presentation/bloc/registration_cubit/registration_cubit.dart'; +import 'package:eatvio_app/generated/l10n.dart'; import 'package:eatvio_app/widgets/custom_text_form_field.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; class MedicineIntakeScreen extends StatefulWidget { final UserRegistrationSheet sheet; @@ -26,16 +27,17 @@ class _MedicineIntakeScreenState extends State { @override Widget build(BuildContext context) { + final s = S.of(context); return SingleChildScrollView( padding: EdgeInsets.only(bottom: 80, left: 16, right: 16, top: 16), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Text("do_you_take_pills".tr), + Text(s.do_you_take_pills), SizedBox(height: 4), CustomTextFormField( controller: enterInformationController, - hintText: "enter_information".tr, + hintText: s.enter_information, textInputAction: TextInputAction.done, focusNode: infoFocusNode, autofocus: true, diff --git a/lib/features/registration/presentation/pages/name_screen.dart b/lib/features/registration/presentation/pages/name_screen.dart index ae817ed8..b2211961 100644 --- a/lib/features/registration/presentation/pages/name_screen.dart +++ b/lib/features/registration/presentation/pages/name_screen.dart @@ -1,8 +1,9 @@ -import 'package:eatvio_app/core/app_export.dart'; -import 'package:eatvio_app/data/models/userRegistrationModel/user_registration_model.dart'; +import 'package:eatvio_app/features/registration/models/user_registration_model.dart'; import 'package:eatvio_app/features/registration/presentation/bloc/registration_cubit/registration_cubit.dart'; +import 'package:eatvio_app/generated/l10n.dart'; import 'package:eatvio_app/widgets/custom_text_form_field.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; class NameScreen extends StatefulWidget { final UserRegistrationSheet sheet; @@ -28,12 +29,13 @@ class _NameScreenState extends State { @override Widget build(BuildContext context) { + final s = S.of(context); return SingleChildScrollView( padding: EdgeInsets.only(bottom: 80, top: 16, left: 16, right: 16), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Text("first_name".tr), + Text(s.first_name), SizedBox(height: 4), CustomTextFormField( controller: firstNameController, @@ -46,7 +48,7 @@ class _NameScreenState extends State { }, ), SizedBox(height: 16), - Text("last_name".tr), + Text(s.last_name), SizedBox(height: 4), CustomTextFormField( controller: lastNameController, @@ -56,7 +58,7 @@ class _NameScreenState extends State { final registrationCubit = context.read(); registrationCubit.updateSheet(registrationCubit.state.sheet.copyWith(lastName: newValue)); }, - ) + ), ], ), ); diff --git a/lib/features/registration/presentation/pages/registration_screen.dart b/lib/features/registration/presentation/pages/registration_screen.dart index e95639a8..7694582c 100644 --- a/lib/features/registration/presentation/pages/registration_screen.dart +++ b/lib/features/registration/presentation/pages/registration_screen.dart @@ -1,4 +1,4 @@ -import 'package:eatvio_app/core/app_export.dart'; +import 'package:eatvio_app/core/utils/image_constant.dart'; import 'package:eatvio_app/features/registration/presentation/bloc/registration_cubit/registration_cubit.dart'; import 'package:eatvio_app/features/registration/presentation/bloc/registration_cubit/registration_state.dart'; import 'package:eatvio_app/features/registration/presentation/pages/additional_information_screen.dart'; @@ -16,10 +16,14 @@ import 'package:eatvio_app/features/registration/presentation/pages/language_sel import 'package:eatvio_app/features/registration/presentation/pages/medicine_intake_screen.dart'; import 'package:eatvio_app/features/registration/presentation/pages/name_screen.dart'; import 'package:eatvio_app/features/registration/presentation/pages/weight_screen.dart'; +import 'package:eatvio_app/generated/l10n.dart'; import 'package:eatvio_app/locator_service.dart'; +import 'package:eatvio_app/theme/theme_helper.dart'; import 'package:eatvio_app/widgets/app_bar/appbar_title_image.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:go_router/go_router.dart'; +import 'package:rive/rive.dart'; import 'package:validators/validators.dart'; class RegistrationScreen extends StatefulWidget { @@ -55,7 +59,7 @@ class _RegistrationScreenState extends State { focusElevation: 0, elevation: 0, shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(16), + borderRadius: BorderRadius.circular(20), ), backgroundColor: Color(0xFFEAF2FD), onPressed: () async { @@ -82,7 +86,7 @@ class _RegistrationScreenState extends State { elevation: 0, focusElevation: 0, shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(16), + borderRadius: BorderRadius.circular(20), ), backgroundColor: appTheme.blueA400, onPressed: () async { @@ -97,7 +101,7 @@ class _RegistrationScreenState extends State { }, label: Text( 'Продолжить', - style: theme.textTheme.titleSmall, + style: theme.textTheme.titleSmall!.copyWith(color: Colors.white), ), ), ), @@ -177,7 +181,12 @@ class _RegistrationScreenState extends State { Future canGoNext(RegistrationState state) async { switch (step) { case 2: - List errors = validateCredentialsFields(state.sheet.email, state.sheet.password, state.sheet.passwordConfirmation); + List errors = validateCredentialsFields( + state.sheet.email, + state.sheet.password, + state.sheet.passwordConfirmation, + context, + ); if (errors.isEmpty) { return true; } else { @@ -206,6 +215,7 @@ class _RegistrationScreenState extends State { List errors = validateNameFields( state.sheet.firstName.toString(), state.sheet.lastName.toString(), + context, ); if (errors.isEmpty) { return true; @@ -274,6 +284,7 @@ class _RegistrationScreenState extends State { state.sheet.chestCircumference.toString(), state.sheet.waistCircumference.toString(), state.sheet.hipCircumference.toString(), + context, ); if (errors.isEmpty) { return true; @@ -308,7 +319,13 @@ class _RegistrationScreenState extends State { builder: (context) => PopScope( canPop: false, child: Center( - child: CircularProgressIndicator(), + child: SizedBox( + height: 32, + width: 32, + child: RiveAnimation.asset( + 'assets/rive_animations/loading.riv', + ), + ), ), ), ); @@ -333,43 +350,57 @@ class _RegistrationScreenState extends State { String chestCircumference, String waistCircumference, String hipCircumference, + BuildContext context, ) { + final s = S.of(context); + List errors = []; if (chestCircumference.isEmpty | waistCircumference.isEmpty | hipCircumference.isEmpty) { - errors.add('circumference_empty'.tr); + errors.add(s.circumference_empty); } if (![chestCircumference, waistCircumference, hipCircumference].every((circumference) => int.tryParse(circumference) != null)) { - errors.add('circumference_is_not_a_number'.tr); + errors.add(s.circumference_is_not_a_number); } return errors; } - List validateCredentialsFields(String email, String password, String passwordConfirmation) { + List validateCredentialsFields( + String email, + String password, + String passwordConfirmation, + BuildContext context, + ) { + final s = S.of(context); + List errors = []; if (!isEmail(email)) { - errors.add('email_invalid'.tr); + errors.add(s.email_invalid); } if (email.isEmpty) { - errors.add('email_empty'.tr); + errors.add(s.email_empty); } if (password.length < 6) { - errors.add('password_short'.tr); + errors.add(s.password_short); } if (password != passwordConfirmation) { - errors.add('password_confirmation_mismatch'.tr); + errors.add(s.password_confirmation_mismatch); } return errors; } - List validateNameFields(String firstName, String lastName) { + List validateNameFields( + String firstName, + String lastName, + BuildContext context, + ) { List errors = []; if (firstName.isEmpty) { diff --git a/lib/features/registration/presentation/pages/weight_screen.dart b/lib/features/registration/presentation/pages/weight_screen.dart index 300296d6..4f8e9b9f 100644 --- a/lib/features/registration/presentation/pages/weight_screen.dart +++ b/lib/features/registration/presentation/pages/weight_screen.dart @@ -1,9 +1,10 @@ -import 'package:eatvio_app/core/app_export.dart'; -import 'package:eatvio_app/data/models/userRegistrationModel/user_registration_model.dart'; +import 'package:eatvio_app/features/registration/models/user_registration_model.dart'; import 'package:eatvio_app/features/registration/presentation/bloc/registration_cubit/registration_cubit.dart'; +import 'package:eatvio_app/generated/l10n.dart'; import 'package:eatvio_app/widgets/custom_text_form_field.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; class WeightScreen extends StatefulWidget { final UserRegistrationSheet sheet; @@ -27,12 +28,13 @@ class _WeightScreenState extends State { @override Widget build(BuildContext context) { + final s = S.of(context); return SingleChildScrollView( padding: EdgeInsets.only(bottom: 80, left: 16, right: 16, top: 16), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Text("your_weight".tr), + Text(s.your_weight), SizedBox(height: 4), CustomTextFormField( autofocus: true, diff --git a/lib/features/registration/repositories/registration_repository.dart b/lib/features/registration/repositories/registration_repository.dart index d609ee12..e5a32e94 100644 --- a/lib/features/registration/repositories/registration_repository.dart +++ b/lib/features/registration/repositories/registration_repository.dart @@ -1,4 +1,4 @@ -import 'package:eatvio_app/data/models/userRegistrationModel/user_registration_model.dart'; +import 'package:eatvio_app/features/registration/models/user_registration_model.dart'; import 'package:eatvio_app/features/registration/models/location_model.dart'; import 'package:eatvio_app/features/registration/services/registration_service.dart'; diff --git a/lib/features/settings/entities/settings_entity.dart b/lib/features/settings/entities/settings_entity.dart new file mode 100644 index 00000000..4bd31ef3 --- /dev/null +++ b/lib/features/settings/entities/settings_entity.dart @@ -0,0 +1,15 @@ +import 'package:eatvio_app/features/profile/models/profile_model.dart'; +import 'package:eatvio_app/features/settings/models/profile_settings_model.dart'; +import 'package:eatvio_app/features/settings/presentation/bloc/settings_cubit/settings_cubit.dart'; + +class SettingsEntity { + final ProfileSettingsModel profileSettingsModel; + final ProfileDetailsModel profileDetailsModel; + final SettingsCubit settingsCubit; + + SettingsEntity({ + required this.profileSettingsModel, + required this.profileDetailsModel, + required this.settingsCubit, + }); +} diff --git a/lib/features/settings/models/profile_settings_model.dart b/lib/features/settings/models/profile_settings_model.dart new file mode 100644 index 00000000..ebd33e95 --- /dev/null +++ b/lib/features/settings/models/profile_settings_model.dart @@ -0,0 +1,18 @@ +import 'package:freezed_annotation/freezed_annotation.dart'; + +part 'profile_settings_model.freezed.dart'; + +part 'profile_settings_model.g.dart'; + +@freezed +class ProfileSettingsModel with _$ProfileSettingsModel { + const factory ProfileSettingsModel({ + @JsonKey(name: "new_updates_notifications") required dynamic newUpdatesNotifications, + @JsonKey(name: "diary_reminder_notifications") required dynamic diaryReminderNotifications, + @JsonKey(name: "is_mood_fillable") required bool isMoodFillable, + @JsonKey(name: "is_bedtime_fillable") required bool isBedtimeFillable, + @JsonKey(name: "is_public_profile") required bool isPublicProfile, + }) = _ProfileSettingsModel; + + factory ProfileSettingsModel.fromJson(Map json) => _$ProfileSettingsModelFromJson(json); +} diff --git a/lib/features/settings/models/profile_settings_model.freezed.dart b/lib/features/settings/models/profile_settings_model.freezed.dart new file mode 100644 index 00000000..e6a0ff83 --- /dev/null +++ b/lib/features/settings/models/profile_settings_model.freezed.dart @@ -0,0 +1,287 @@ +// 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_settings_model.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'); + +ProfileSettingsModel _$ProfileSettingsModelFromJson(Map json) { + return _ProfileSettingsModel.fromJson(json); +} + +/// @nodoc +mixin _$ProfileSettingsModel { + @JsonKey(name: "new_updates_notifications") + dynamic get newUpdatesNotifications => throw _privateConstructorUsedError; + @JsonKey(name: "diary_reminder_notifications") + dynamic get diaryReminderNotifications => throw _privateConstructorUsedError; + @JsonKey(name: "is_mood_fillable") + bool get isMoodFillable => throw _privateConstructorUsedError; + @JsonKey(name: "is_bedtime_fillable") + bool get isBedtimeFillable => throw _privateConstructorUsedError; + @JsonKey(name: "is_public_profile") + bool get isPublicProfile => throw _privateConstructorUsedError; + + /// Serializes this ProfileSettingsModel to a JSON map. + Map toJson() => throw _privateConstructorUsedError; + + /// Create a copy of ProfileSettingsModel + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $ProfileSettingsModelCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $ProfileSettingsModelCopyWith<$Res> { + factory $ProfileSettingsModelCopyWith(ProfileSettingsModel value, + $Res Function(ProfileSettingsModel) then) = + _$ProfileSettingsModelCopyWithImpl<$Res, ProfileSettingsModel>; + @useResult + $Res call( + {@JsonKey(name: "new_updates_notifications") + dynamic newUpdatesNotifications, + @JsonKey(name: "diary_reminder_notifications") + dynamic diaryReminderNotifications, + @JsonKey(name: "is_mood_fillable") bool isMoodFillable, + @JsonKey(name: "is_bedtime_fillable") bool isBedtimeFillable, + @JsonKey(name: "is_public_profile") bool isPublicProfile}); +} + +/// @nodoc +class _$ProfileSettingsModelCopyWithImpl<$Res, + $Val extends ProfileSettingsModel> + implements $ProfileSettingsModelCopyWith<$Res> { + _$ProfileSettingsModelCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of ProfileSettingsModel + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? newUpdatesNotifications = freezed, + Object? diaryReminderNotifications = freezed, + Object? isMoodFillable = null, + Object? isBedtimeFillable = null, + Object? isPublicProfile = null, + }) { + return _then(_value.copyWith( + newUpdatesNotifications: freezed == newUpdatesNotifications + ? _value.newUpdatesNotifications + : newUpdatesNotifications // ignore: cast_nullable_to_non_nullable + as dynamic, + diaryReminderNotifications: freezed == diaryReminderNotifications + ? _value.diaryReminderNotifications + : diaryReminderNotifications // ignore: cast_nullable_to_non_nullable + as dynamic, + isMoodFillable: null == isMoodFillable + ? _value.isMoodFillable + : isMoodFillable // ignore: cast_nullable_to_non_nullable + as bool, + isBedtimeFillable: null == isBedtimeFillable + ? _value.isBedtimeFillable + : isBedtimeFillable // ignore: cast_nullable_to_non_nullable + as bool, + isPublicProfile: null == isPublicProfile + ? _value.isPublicProfile + : isPublicProfile // ignore: cast_nullable_to_non_nullable + as bool, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$ProfileSettingsModelImplCopyWith<$Res> + implements $ProfileSettingsModelCopyWith<$Res> { + factory _$$ProfileSettingsModelImplCopyWith(_$ProfileSettingsModelImpl value, + $Res Function(_$ProfileSettingsModelImpl) then) = + __$$ProfileSettingsModelImplCopyWithImpl<$Res>; + @override + @useResult + $Res call( + {@JsonKey(name: "new_updates_notifications") + dynamic newUpdatesNotifications, + @JsonKey(name: "diary_reminder_notifications") + dynamic diaryReminderNotifications, + @JsonKey(name: "is_mood_fillable") bool isMoodFillable, + @JsonKey(name: "is_bedtime_fillable") bool isBedtimeFillable, + @JsonKey(name: "is_public_profile") bool isPublicProfile}); +} + +/// @nodoc +class __$$ProfileSettingsModelImplCopyWithImpl<$Res> + extends _$ProfileSettingsModelCopyWithImpl<$Res, _$ProfileSettingsModelImpl> + implements _$$ProfileSettingsModelImplCopyWith<$Res> { + __$$ProfileSettingsModelImplCopyWithImpl(_$ProfileSettingsModelImpl _value, + $Res Function(_$ProfileSettingsModelImpl) _then) + : super(_value, _then); + + /// Create a copy of ProfileSettingsModel + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? newUpdatesNotifications = freezed, + Object? diaryReminderNotifications = freezed, + Object? isMoodFillable = null, + Object? isBedtimeFillable = null, + Object? isPublicProfile = null, + }) { + return _then(_$ProfileSettingsModelImpl( + newUpdatesNotifications: freezed == newUpdatesNotifications + ? _value.newUpdatesNotifications + : newUpdatesNotifications // ignore: cast_nullable_to_non_nullable + as dynamic, + diaryReminderNotifications: freezed == diaryReminderNotifications + ? _value.diaryReminderNotifications + : diaryReminderNotifications // ignore: cast_nullable_to_non_nullable + as dynamic, + isMoodFillable: null == isMoodFillable + ? _value.isMoodFillable + : isMoodFillable // ignore: cast_nullable_to_non_nullable + as bool, + isBedtimeFillable: null == isBedtimeFillable + ? _value.isBedtimeFillable + : isBedtimeFillable // ignore: cast_nullable_to_non_nullable + as bool, + isPublicProfile: null == isPublicProfile + ? _value.isPublicProfile + : isPublicProfile // ignore: cast_nullable_to_non_nullable + as bool, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$ProfileSettingsModelImpl implements _ProfileSettingsModel { + const _$ProfileSettingsModelImpl( + {@JsonKey(name: "new_updates_notifications") + required this.newUpdatesNotifications, + @JsonKey(name: "diary_reminder_notifications") + required this.diaryReminderNotifications, + @JsonKey(name: "is_mood_fillable") required this.isMoodFillable, + @JsonKey(name: "is_bedtime_fillable") required this.isBedtimeFillable, + @JsonKey(name: "is_public_profile") required this.isPublicProfile}); + + factory _$ProfileSettingsModelImpl.fromJson(Map json) => + _$$ProfileSettingsModelImplFromJson(json); + + @override + @JsonKey(name: "new_updates_notifications") + final dynamic newUpdatesNotifications; + @override + @JsonKey(name: "diary_reminder_notifications") + final dynamic diaryReminderNotifications; + @override + @JsonKey(name: "is_mood_fillable") + final bool isMoodFillable; + @override + @JsonKey(name: "is_bedtime_fillable") + final bool isBedtimeFillable; + @override + @JsonKey(name: "is_public_profile") + final bool isPublicProfile; + + @override + String toString() { + return 'ProfileSettingsModel(newUpdatesNotifications: $newUpdatesNotifications, diaryReminderNotifications: $diaryReminderNotifications, isMoodFillable: $isMoodFillable, isBedtimeFillable: $isBedtimeFillable, isPublicProfile: $isPublicProfile)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$ProfileSettingsModelImpl && + const DeepCollectionEquality().equals( + other.newUpdatesNotifications, newUpdatesNotifications) && + const DeepCollectionEquality().equals( + other.diaryReminderNotifications, diaryReminderNotifications) && + (identical(other.isMoodFillable, isMoodFillable) || + other.isMoodFillable == isMoodFillable) && + (identical(other.isBedtimeFillable, isBedtimeFillable) || + other.isBedtimeFillable == isBedtimeFillable) && + (identical(other.isPublicProfile, isPublicProfile) || + other.isPublicProfile == isPublicProfile)); + } + + @JsonKey(includeFromJson: false, includeToJson: false) + @override + int get hashCode => Object.hash( + runtimeType, + const DeepCollectionEquality().hash(newUpdatesNotifications), + const DeepCollectionEquality().hash(diaryReminderNotifications), + isMoodFillable, + isBedtimeFillable, + isPublicProfile); + + /// Create a copy of ProfileSettingsModel + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$ProfileSettingsModelImplCopyWith<_$ProfileSettingsModelImpl> + get copyWith => + __$$ProfileSettingsModelImplCopyWithImpl<_$ProfileSettingsModelImpl>( + this, _$identity); + + @override + Map toJson() { + return _$$ProfileSettingsModelImplToJson( + this, + ); + } +} + +abstract class _ProfileSettingsModel implements ProfileSettingsModel { + const factory _ProfileSettingsModel( + {@JsonKey(name: "new_updates_notifications") + required final dynamic newUpdatesNotifications, + @JsonKey(name: "diary_reminder_notifications") + required final dynamic diaryReminderNotifications, + @JsonKey(name: "is_mood_fillable") required final bool isMoodFillable, + @JsonKey(name: "is_bedtime_fillable") + required final bool isBedtimeFillable, + @JsonKey(name: "is_public_profile") + required final bool isPublicProfile}) = _$ProfileSettingsModelImpl; + + factory _ProfileSettingsModel.fromJson(Map json) = + _$ProfileSettingsModelImpl.fromJson; + + @override + @JsonKey(name: "new_updates_notifications") + dynamic get newUpdatesNotifications; + @override + @JsonKey(name: "diary_reminder_notifications") + dynamic get diaryReminderNotifications; + @override + @JsonKey(name: "is_mood_fillable") + bool get isMoodFillable; + @override + @JsonKey(name: "is_bedtime_fillable") + bool get isBedtimeFillable; + @override + @JsonKey(name: "is_public_profile") + bool get isPublicProfile; + + /// Create a copy of ProfileSettingsModel + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + _$$ProfileSettingsModelImplCopyWith<_$ProfileSettingsModelImpl> + get copyWith => throw _privateConstructorUsedError; +} diff --git a/lib/features/settings/models/profile_settings_model.g.dart b/lib/features/settings/models/profile_settings_model.g.dart new file mode 100644 index 00000000..d7a7e6eb --- /dev/null +++ b/lib/features/settings/models/profile_settings_model.g.dart @@ -0,0 +1,27 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'profile_settings_model.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +_$ProfileSettingsModelImpl _$$ProfileSettingsModelImplFromJson( + Map json) => + _$ProfileSettingsModelImpl( + newUpdatesNotifications: json['new_updates_notifications'], + diaryReminderNotifications: json['diary_reminder_notifications'], + isMoodFillable: json['is_mood_fillable'] as bool, + isBedtimeFillable: json['is_bedtime_fillable'] as bool, + isPublicProfile: json['is_public_profile'] as bool, + ); + +Map _$$ProfileSettingsModelImplToJson( + _$ProfileSettingsModelImpl instance) => + { + 'new_updates_notifications': instance.newUpdatesNotifications, + 'diary_reminder_notifications': instance.diaryReminderNotifications, + 'is_mood_fillable': instance.isMoodFillable, + 'is_bedtime_fillable': instance.isBedtimeFillable, + 'is_public_profile': instance.isPublicProfile, + }; diff --git a/lib/features/settings/presentation/bloc/settings_cubit/settings_cubit.dart b/lib/features/settings/presentation/bloc/settings_cubit/settings_cubit.dart new file mode 100644 index 00000000..ce448c88 --- /dev/null +++ b/lib/features/settings/presentation/bloc/settings_cubit/settings_cubit.dart @@ -0,0 +1,57 @@ +import 'package:eatvio_app/features/profile/models/profile_model.dart'; +import 'package:eatvio_app/features/profile/repositories/profile_repository.dart'; +import 'package:eatvio_app/features/settings/models/profile_settings_model.dart'; +import 'package:eatvio_app/features/settings/presentation/bloc/settings_cubit/settings_state.dart'; +import 'package:eatvio_app/features/settings/repositories/service_repository.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; + +class SettingsCubit extends Cubit { + final ProfileRepository profileRepository; + final SettingsRepository settingsRepository; + + SettingsCubit({ + required this.profileRepository, + required this.settingsRepository, + }) : super(const SettingsState.loading()); + + Future init() async { + try { + emit(SettingsState.loaded( + profileSettings: await settingsRepository.getProfileSettings(), + profileDetails: await profileRepository.getMyProfileDetails(), + )); + } catch (e) { + emit(SettingsState.error(errorMessage: e.toString())); + } + } + + updateProfileDetails({ + required ProfileDetailsModel profileDetailsModel, + }) async { + try { + await settingsRepository.updateProfileDetails( + profileDetailsModel: profileDetailsModel, + ); + } catch (e) { + print(e); + rethrow; + } finally { + await init(); + } + } + + updateProfileSettings({ + required ProfileSettingsModel profileSettingsModel, + }) async { + try { + await settingsRepository.updateProfileSettings( + profileSettingsModel: profileSettingsModel, + ); + } catch (e) { + print(e); + rethrow; + } finally { + await init(); + } + } +} diff --git a/lib/features/settings/presentation/bloc/settings_cubit/settings_state.dart b/lib/features/settings/presentation/bloc/settings_cubit/settings_state.dart new file mode 100644 index 00000000..41977b39 --- /dev/null +++ b/lib/features/settings/presentation/bloc/settings_cubit/settings_state.dart @@ -0,0 +1,21 @@ +import 'package:eatvio_app/features/profile/models/profile_model.dart'; +import 'package:eatvio_app/features/settings/models/profile_settings_model.dart'; +import 'package:freezed_annotation/freezed_annotation.dart'; + +part 'settings_state.freezed.dart'; + +@freezed +abstract class SettingsState with _$SettingsState { + const factory SettingsState() = _SettingsState; + + const factory SettingsState.loading() = SettingsStateLoading; + + const factory SettingsState.loaded({ + required ProfileSettingsModel profileSettings, + required ProfileDetailsModel profileDetails, + }) = SettingsStateLoaded; + + const factory SettingsState.error({ + required String errorMessage, + }) = SettingsStateError; +} diff --git a/lib/features/settings/presentation/bloc/settings_cubit/settings_state.freezed.dart b/lib/features/settings/presentation/bloc/settings_cubit/settings_state.freezed.dart new file mode 100644 index 00000000..f19981b6 --- /dev/null +++ b/lib/features/settings/presentation/bloc/settings_cubit/settings_state.freezed.dart @@ -0,0 +1,703 @@ +// 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 'settings_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 _$SettingsState { + @optionalTypeArgs + TResult when( + TResult Function() $default, { + required TResult Function() loading, + required TResult Function(ProfileSettingsModel profileSettings, + ProfileDetailsModel profileDetails) + loaded, + required TResult Function(String errorMessage) error, + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult? whenOrNull( + TResult? Function()? $default, { + TResult? Function()? loading, + TResult? Function(ProfileSettingsModel profileSettings, + ProfileDetailsModel profileDetails)? + loaded, + TResult? Function(String errorMessage)? error, + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult maybeWhen( + TResult Function()? $default, { + TResult Function()? loading, + TResult Function(ProfileSettingsModel profileSettings, + ProfileDetailsModel profileDetails)? + loaded, + TResult Function(String errorMessage)? error, + required TResult orElse(), + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult map( + TResult Function(_SettingsState value) $default, { + required TResult Function(SettingsStateLoading value) loading, + required TResult Function(SettingsStateLoaded value) loaded, + required TResult Function(SettingsStateError value) error, + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult? mapOrNull( + TResult? Function(_SettingsState value)? $default, { + TResult? Function(SettingsStateLoading value)? loading, + TResult? Function(SettingsStateLoaded value)? loaded, + TResult? Function(SettingsStateError value)? error, + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult maybeMap( + TResult Function(_SettingsState value)? $default, { + TResult Function(SettingsStateLoading value)? loading, + TResult Function(SettingsStateLoaded value)? loaded, + TResult Function(SettingsStateError value)? error, + required TResult orElse(), + }) => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $SettingsStateCopyWith<$Res> { + factory $SettingsStateCopyWith( + SettingsState value, $Res Function(SettingsState) then) = + _$SettingsStateCopyWithImpl<$Res, SettingsState>; +} + +/// @nodoc +class _$SettingsStateCopyWithImpl<$Res, $Val extends SettingsState> + implements $SettingsStateCopyWith<$Res> { + _$SettingsStateCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of SettingsState + /// with the given fields replaced by the non-null parameter values. +} + +/// @nodoc +abstract class _$$SettingsStateImplCopyWith<$Res> { + factory _$$SettingsStateImplCopyWith( + _$SettingsStateImpl value, $Res Function(_$SettingsStateImpl) then) = + __$$SettingsStateImplCopyWithImpl<$Res>; +} + +/// @nodoc +class __$$SettingsStateImplCopyWithImpl<$Res> + extends _$SettingsStateCopyWithImpl<$Res, _$SettingsStateImpl> + implements _$$SettingsStateImplCopyWith<$Res> { + __$$SettingsStateImplCopyWithImpl( + _$SettingsStateImpl _value, $Res Function(_$SettingsStateImpl) _then) + : super(_value, _then); + + /// Create a copy of SettingsState + /// with the given fields replaced by the non-null parameter values. +} + +/// @nodoc + +class _$SettingsStateImpl implements _SettingsState { + const _$SettingsStateImpl(); + + @override + String toString() { + return 'SettingsState()'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && other is _$SettingsStateImpl); + } + + @override + int get hashCode => runtimeType.hashCode; + + @override + @optionalTypeArgs + TResult when( + TResult Function() $default, { + required TResult Function() loading, + required TResult Function(ProfileSettingsModel profileSettings, + ProfileDetailsModel profileDetails) + loaded, + required TResult Function(String errorMessage) error, + }) { + return $default(); + } + + @override + @optionalTypeArgs + TResult? whenOrNull( + TResult? Function()? $default, { + TResult? Function()? loading, + TResult? Function(ProfileSettingsModel profileSettings, + ProfileDetailsModel profileDetails)? + loaded, + TResult? Function(String errorMessage)? error, + }) { + return $default?.call(); + } + + @override + @optionalTypeArgs + TResult maybeWhen( + TResult Function()? $default, { + TResult Function()? loading, + TResult Function(ProfileSettingsModel profileSettings, + ProfileDetailsModel profileDetails)? + loaded, + TResult Function(String errorMessage)? error, + required TResult orElse(), + }) { + if ($default != null) { + return $default(); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map( + TResult Function(_SettingsState value) $default, { + required TResult Function(SettingsStateLoading value) loading, + required TResult Function(SettingsStateLoaded value) loaded, + required TResult Function(SettingsStateError value) error, + }) { + return $default(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull( + TResult? Function(_SettingsState value)? $default, { + TResult? Function(SettingsStateLoading value)? loading, + TResult? Function(SettingsStateLoaded value)? loaded, + TResult? Function(SettingsStateError value)? error, + }) { + return $default?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap( + TResult Function(_SettingsState value)? $default, { + TResult Function(SettingsStateLoading value)? loading, + TResult Function(SettingsStateLoaded value)? loaded, + TResult Function(SettingsStateError value)? error, + required TResult orElse(), + }) { + if ($default != null) { + return $default(this); + } + return orElse(); + } +} + +abstract class _SettingsState implements SettingsState { + const factory _SettingsState() = _$SettingsStateImpl; +} + +/// @nodoc +abstract class _$$SettingsStateLoadingImplCopyWith<$Res> { + factory _$$SettingsStateLoadingImplCopyWith(_$SettingsStateLoadingImpl value, + $Res Function(_$SettingsStateLoadingImpl) then) = + __$$SettingsStateLoadingImplCopyWithImpl<$Res>; +} + +/// @nodoc +class __$$SettingsStateLoadingImplCopyWithImpl<$Res> + extends _$SettingsStateCopyWithImpl<$Res, _$SettingsStateLoadingImpl> + implements _$$SettingsStateLoadingImplCopyWith<$Res> { + __$$SettingsStateLoadingImplCopyWithImpl(_$SettingsStateLoadingImpl _value, + $Res Function(_$SettingsStateLoadingImpl) _then) + : super(_value, _then); + + /// Create a copy of SettingsState + /// with the given fields replaced by the non-null parameter values. +} + +/// @nodoc + +class _$SettingsStateLoadingImpl implements SettingsStateLoading { + const _$SettingsStateLoadingImpl(); + + @override + String toString() { + return 'SettingsState.loading()'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$SettingsStateLoadingImpl); + } + + @override + int get hashCode => runtimeType.hashCode; + + @override + @optionalTypeArgs + TResult when( + TResult Function() $default, { + required TResult Function() loading, + required TResult Function(ProfileSettingsModel profileSettings, + ProfileDetailsModel profileDetails) + loaded, + required TResult Function(String errorMessage) error, + }) { + return loading(); + } + + @override + @optionalTypeArgs + TResult? whenOrNull( + TResult? Function()? $default, { + TResult? Function()? loading, + TResult? Function(ProfileSettingsModel profileSettings, + ProfileDetailsModel profileDetails)? + loaded, + TResult? Function(String errorMessage)? error, + }) { + return loading?.call(); + } + + @override + @optionalTypeArgs + TResult maybeWhen( + TResult Function()? $default, { + TResult Function()? loading, + TResult Function(ProfileSettingsModel profileSettings, + ProfileDetailsModel profileDetails)? + loaded, + TResult Function(String errorMessage)? error, + required TResult orElse(), + }) { + if (loading != null) { + return loading(); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map( + TResult Function(_SettingsState value) $default, { + required TResult Function(SettingsStateLoading value) loading, + required TResult Function(SettingsStateLoaded value) loaded, + required TResult Function(SettingsStateError value) error, + }) { + return loading(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull( + TResult? Function(_SettingsState value)? $default, { + TResult? Function(SettingsStateLoading value)? loading, + TResult? Function(SettingsStateLoaded value)? loaded, + TResult? Function(SettingsStateError value)? error, + }) { + return loading?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap( + TResult Function(_SettingsState value)? $default, { + TResult Function(SettingsStateLoading value)? loading, + TResult Function(SettingsStateLoaded value)? loaded, + TResult Function(SettingsStateError value)? error, + required TResult orElse(), + }) { + if (loading != null) { + return loading(this); + } + return orElse(); + } +} + +abstract class SettingsStateLoading implements SettingsState { + const factory SettingsStateLoading() = _$SettingsStateLoadingImpl; +} + +/// @nodoc +abstract class _$$SettingsStateLoadedImplCopyWith<$Res> { + factory _$$SettingsStateLoadedImplCopyWith(_$SettingsStateLoadedImpl value, + $Res Function(_$SettingsStateLoadedImpl) then) = + __$$SettingsStateLoadedImplCopyWithImpl<$Res>; + @useResult + $Res call( + {ProfileSettingsModel profileSettings, + ProfileDetailsModel profileDetails}); + + $ProfileSettingsModelCopyWith<$Res> get profileSettings; + $ProfileDetailsModelCopyWith<$Res> get profileDetails; +} + +/// @nodoc +class __$$SettingsStateLoadedImplCopyWithImpl<$Res> + extends _$SettingsStateCopyWithImpl<$Res, _$SettingsStateLoadedImpl> + implements _$$SettingsStateLoadedImplCopyWith<$Res> { + __$$SettingsStateLoadedImplCopyWithImpl(_$SettingsStateLoadedImpl _value, + $Res Function(_$SettingsStateLoadedImpl) _then) + : super(_value, _then); + + /// Create a copy of SettingsState + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? profileSettings = null, + Object? profileDetails = null, + }) { + return _then(_$SettingsStateLoadedImpl( + profileSettings: null == profileSettings + ? _value.profileSettings + : profileSettings // ignore: cast_nullable_to_non_nullable + as ProfileSettingsModel, + profileDetails: null == profileDetails + ? _value.profileDetails + : profileDetails // ignore: cast_nullable_to_non_nullable + as ProfileDetailsModel, + )); + } + + /// Create a copy of SettingsState + /// with the given fields replaced by the non-null parameter values. + @override + @pragma('vm:prefer-inline') + $ProfileSettingsModelCopyWith<$Res> get profileSettings { + return $ProfileSettingsModelCopyWith<$Res>(_value.profileSettings, (value) { + return _then(_value.copyWith(profileSettings: value)); + }); + } + + /// Create a copy of SettingsState + /// with the given fields replaced by the non-null parameter values. + @override + @pragma('vm:prefer-inline') + $ProfileDetailsModelCopyWith<$Res> get profileDetails { + return $ProfileDetailsModelCopyWith<$Res>(_value.profileDetails, (value) { + return _then(_value.copyWith(profileDetails: value)); + }); + } +} + +/// @nodoc + +class _$SettingsStateLoadedImpl implements SettingsStateLoaded { + const _$SettingsStateLoadedImpl( + {required this.profileSettings, required this.profileDetails}); + + @override + final ProfileSettingsModel profileSettings; + @override + final ProfileDetailsModel profileDetails; + + @override + String toString() { + return 'SettingsState.loaded(profileSettings: $profileSettings, profileDetails: $profileDetails)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$SettingsStateLoadedImpl && + (identical(other.profileSettings, profileSettings) || + other.profileSettings == profileSettings) && + (identical(other.profileDetails, profileDetails) || + other.profileDetails == profileDetails)); + } + + @override + int get hashCode => Object.hash(runtimeType, profileSettings, profileDetails); + + /// Create a copy of SettingsState + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$SettingsStateLoadedImplCopyWith<_$SettingsStateLoadedImpl> get copyWith => + __$$SettingsStateLoadedImplCopyWithImpl<_$SettingsStateLoadedImpl>( + this, _$identity); + + @override + @optionalTypeArgs + TResult when( + TResult Function() $default, { + required TResult Function() loading, + required TResult Function(ProfileSettingsModel profileSettings, + ProfileDetailsModel profileDetails) + loaded, + required TResult Function(String errorMessage) error, + }) { + return loaded(profileSettings, profileDetails); + } + + @override + @optionalTypeArgs + TResult? whenOrNull( + TResult? Function()? $default, { + TResult? Function()? loading, + TResult? Function(ProfileSettingsModel profileSettings, + ProfileDetailsModel profileDetails)? + loaded, + TResult? Function(String errorMessage)? error, + }) { + return loaded?.call(profileSettings, profileDetails); + } + + @override + @optionalTypeArgs + TResult maybeWhen( + TResult Function()? $default, { + TResult Function()? loading, + TResult Function(ProfileSettingsModel profileSettings, + ProfileDetailsModel profileDetails)? + loaded, + TResult Function(String errorMessage)? error, + required TResult orElse(), + }) { + if (loaded != null) { + return loaded(profileSettings, profileDetails); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map( + TResult Function(_SettingsState value) $default, { + required TResult Function(SettingsStateLoading value) loading, + required TResult Function(SettingsStateLoaded value) loaded, + required TResult Function(SettingsStateError value) error, + }) { + return loaded(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull( + TResult? Function(_SettingsState value)? $default, { + TResult? Function(SettingsStateLoading value)? loading, + TResult? Function(SettingsStateLoaded value)? loaded, + TResult? Function(SettingsStateError value)? error, + }) { + return loaded?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap( + TResult Function(_SettingsState value)? $default, { + TResult Function(SettingsStateLoading value)? loading, + TResult Function(SettingsStateLoaded value)? loaded, + TResult Function(SettingsStateError value)? error, + required TResult orElse(), + }) { + if (loaded != null) { + return loaded(this); + } + return orElse(); + } +} + +abstract class SettingsStateLoaded implements SettingsState { + const factory SettingsStateLoaded( + {required final ProfileSettingsModel profileSettings, + required final ProfileDetailsModel profileDetails}) = + _$SettingsStateLoadedImpl; + + ProfileSettingsModel get profileSettings; + ProfileDetailsModel get profileDetails; + + /// Create a copy of SettingsState + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + _$$SettingsStateLoadedImplCopyWith<_$SettingsStateLoadedImpl> get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class _$$SettingsStateErrorImplCopyWith<$Res> { + factory _$$SettingsStateErrorImplCopyWith(_$SettingsStateErrorImpl value, + $Res Function(_$SettingsStateErrorImpl) then) = + __$$SettingsStateErrorImplCopyWithImpl<$Res>; + @useResult + $Res call({String errorMessage}); +} + +/// @nodoc +class __$$SettingsStateErrorImplCopyWithImpl<$Res> + extends _$SettingsStateCopyWithImpl<$Res, _$SettingsStateErrorImpl> + implements _$$SettingsStateErrorImplCopyWith<$Res> { + __$$SettingsStateErrorImplCopyWithImpl(_$SettingsStateErrorImpl _value, + $Res Function(_$SettingsStateErrorImpl) _then) + : super(_value, _then); + + /// Create a copy of SettingsState + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? errorMessage = null, + }) { + return _then(_$SettingsStateErrorImpl( + errorMessage: null == errorMessage + ? _value.errorMessage + : errorMessage // ignore: cast_nullable_to_non_nullable + as String, + )); + } +} + +/// @nodoc + +class _$SettingsStateErrorImpl implements SettingsStateError { + const _$SettingsStateErrorImpl({required this.errorMessage}); + + @override + final String errorMessage; + + @override + String toString() { + return 'SettingsState.error(errorMessage: $errorMessage)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$SettingsStateErrorImpl && + (identical(other.errorMessage, errorMessage) || + other.errorMessage == errorMessage)); + } + + @override + int get hashCode => Object.hash(runtimeType, errorMessage); + + /// Create a copy of SettingsState + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$SettingsStateErrorImplCopyWith<_$SettingsStateErrorImpl> get copyWith => + __$$SettingsStateErrorImplCopyWithImpl<_$SettingsStateErrorImpl>( + this, _$identity); + + @override + @optionalTypeArgs + TResult when( + TResult Function() $default, { + required TResult Function() loading, + required TResult Function(ProfileSettingsModel profileSettings, + ProfileDetailsModel profileDetails) + loaded, + required TResult Function(String errorMessage) error, + }) { + return error(errorMessage); + } + + @override + @optionalTypeArgs + TResult? whenOrNull( + TResult? Function()? $default, { + TResult? Function()? loading, + TResult? Function(ProfileSettingsModel profileSettings, + ProfileDetailsModel profileDetails)? + loaded, + TResult? Function(String errorMessage)? error, + }) { + return error?.call(errorMessage); + } + + @override + @optionalTypeArgs + TResult maybeWhen( + TResult Function()? $default, { + TResult Function()? loading, + TResult Function(ProfileSettingsModel profileSettings, + ProfileDetailsModel profileDetails)? + loaded, + TResult Function(String errorMessage)? error, + required TResult orElse(), + }) { + if (error != null) { + return error(errorMessage); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map( + TResult Function(_SettingsState value) $default, { + required TResult Function(SettingsStateLoading value) loading, + required TResult Function(SettingsStateLoaded value) loaded, + required TResult Function(SettingsStateError value) error, + }) { + return error(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull( + TResult? Function(_SettingsState value)? $default, { + TResult? Function(SettingsStateLoading value)? loading, + TResult? Function(SettingsStateLoaded value)? loaded, + TResult? Function(SettingsStateError value)? error, + }) { + return error?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap( + TResult Function(_SettingsState value)? $default, { + TResult Function(SettingsStateLoading value)? loading, + TResult Function(SettingsStateLoaded value)? loaded, + TResult Function(SettingsStateError value)? error, + required TResult orElse(), + }) { + if (error != null) { + return error(this); + } + return orElse(); + } +} + +abstract class SettingsStateError implements SettingsState { + const factory SettingsStateError({required final String errorMessage}) = + _$SettingsStateErrorImpl; + + String get errorMessage; + + /// Create a copy of SettingsState + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + _$$SettingsStateErrorImplCopyWith<_$SettingsStateErrorImpl> get copyWith => + throw _privateConstructorUsedError; +} diff --git a/lib/features/settings/presentation/pages/change_password_screen.dart b/lib/features/settings/presentation/pages/change_password_screen.dart new file mode 100644 index 00000000..b67df070 --- /dev/null +++ b/lib/features/settings/presentation/pages/change_password_screen.dart @@ -0,0 +1,28 @@ +import 'package:eatvio_app/features/settings/entities/settings_entity.dart'; +import 'package:flutter/material.dart'; + +class ChangePasswordScreen extends StatefulWidget { + final SettingsEntity settingsEntity; + + const ChangePasswordScreen({ + super.key, + required this.settingsEntity, + }); + + @override + State createState() => _ChangePasswordScreenState(); +} + +class _ChangePasswordScreenState extends State { + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + title: Text('Смена пароля'), + ), + body: Center( + child: Text('Coming soon...'), + ), + ); + } +} diff --git a/lib/features/settings/presentation/pages/general_info_screen.dart b/lib/features/settings/presentation/pages/general_info_screen.dart new file mode 100644 index 00000000..4ad9e084 --- /dev/null +++ b/lib/features/settings/presentation/pages/general_info_screen.dart @@ -0,0 +1,233 @@ +import 'package:eatvio_app/core/utils/date_time_utils.dart'; +import 'package:eatvio_app/data/models/selectionPopupModel/selection_popup_model.dart'; +import 'package:eatvio_app/features/settings/entities/settings_entity.dart'; +import 'package:eatvio_app/features/settings/presentation/bloc/settings_cubit/settings_state.dart'; +import 'package:eatvio_app/generated/l10n.dart'; +import 'package:eatvio_app/theme/theme_helper.dart'; +import 'package:eatvio_app/widgets/custom_drop_down.dart'; +import 'package:eatvio_app/widgets/custom_text_form_field.dart'; +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; +import 'package:go_router/go_router.dart'; + +class GeneralInfoScreen extends StatefulWidget { + final SettingsEntity settingsEntity; + + const GeneralInfoScreen({ + super.key, + required this.settingsEntity, + }); + + @override + State createState() => _GeneralInfoScreenState(); +} + +class _GeneralInfoScreenState extends State { + final firstNameController = TextEditingController(); + final lastNameController = TextEditingController(); + late DateTime selectedDate; + late SelectionPopupModel gender; + final countryController = TextEditingController(); + final cityController = TextEditingController(); + final languageController = TextEditingController(); + late SelectionPopupModel isPublicProfile; + + final List genderSelectionPopupList = [ + SelectionPopupModel(id: 0, title: 'Женский', value: 'female'), + SelectionPopupModel(id: 1, title: 'Мужской', value: 'male'), + ]; + + final List isPublicProfileSelectionPopupList = [ + SelectionPopupModel(id: 0, title: 'Только зарегистрированным', value: false), + SelectionPopupModel(id: 1, title: 'Всем', value: true), + ]; + + @override + void initState() { + super.initState(); + selectedDate = DateTime.now(); + firstNameController.text = widget.settingsEntity.profileDetailsModel.firstName; + lastNameController.text = widget.settingsEntity.profileDetailsModel.lastName; + selectedDate = DateTime.parse(widget.settingsEntity.profileDetailsModel.birthdate); + gender = widget.settingsEntity.profileDetailsModel.gender == 'male' ? genderSelectionPopupList[1] : genderSelectionPopupList[0]; + countryController.text = widget.settingsEntity.profileDetailsModel.country; + cityController.text = widget.settingsEntity.profileDetailsModel.city; + languageController.text = widget.settingsEntity.profileDetailsModel.lang; + isPublicProfile = + widget.settingsEntity.profileSettingsModel.isPublicProfile == true ? isPublicProfileSelectionPopupList[1] : isPublicProfileSelectionPopupList[0]; + } + + @override + Widget build(BuildContext context) { + final s = S.of(context); + + return Scaffold( + appBar: AppBar( + title: Text('Общая информация'), + ), + bottomSheet: _saveButton(), + body: SingleChildScrollView( + physics: const BouncingScrollPhysics(), + padding: EdgeInsets.all(16) + EdgeInsets.only(bottom: 64), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text(s.first_name), + SizedBox(height: 4), + CustomTextFormField( + controller: firstNameController, + hintText: 'Введите имя', + onChanged: (newValue) {}, + ), + SizedBox(height: 16), + Text(s.last_name), + SizedBox(height: 4), + CustomTextFormField( + controller: lastNameController, + hintText: 'Введите фамилию', + onChanged: (newValue) {}, + ), + SizedBox(height: 16), + Text(s.date_of_birth), + SizedBox(height: 4), + ListTile( + onTap: onTapCalendar(context), + trailing: Icon( + Icons.keyboard_arrow_down_rounded, + color: Colors.grey.shade700, + ), + contentPadding: EdgeInsets.symmetric(horizontal: 12), + title: Text(selectedDate.format('dd MMMM yyyy', 'ru')), + tileColor: Color(0xFFF6F6F6), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(20), + ), + ), + SizedBox(height: 16), + Text('Пол'), + SizedBox(height: 4), + CustomDropDown( + items: genderSelectionPopupList, + value: gender, + onChanged: (newValue) { + setState(() { + gender = newValue; + }); + }, + ), + SizedBox(height: 16), + Text('Страна'), + SizedBox(height: 4), + CustomTextFormField( + controller: countryController, + ), + SizedBox(height: 16), + Text('Город'), + SizedBox(height: 4), + CustomTextFormField( + controller: cityController, + ), + SizedBox(height: 16), + Text('Предпочтительный язык общения'), + SizedBox(height: 4), + CustomTextFormField( + controller: languageController, + ), + SizedBox(height: 16), + Text('Показывать анкету'), + SizedBox(height: 4), + CustomDropDown( + items: isPublicProfileSelectionPopupList, + value: isPublicProfile, + onChanged: (newValue) { + setState(() { + isPublicProfile = newValue; + }); + }, + ), + ], + ), + ), + ); + } + + onTapCalendar(BuildContext context) { + return () { + _showDialog( + CupertinoDatePicker( + initialDateTime: selectedDate, + maximumDate: DateTime.now(), + minimumDate: DateTime(1900), + mode: CupertinoDatePickerMode.date, + onDateTimeChanged: (DateTime newDateTime) { + setState(() { + selectedDate = newDateTime; + }); + }, + ), + ); + }; + } + + void _showDialog(Widget child) { + showCupertinoModalPopup( + context: context, + builder: (BuildContext context) => Container( + height: 216, + padding: const EdgeInsets.only(top: 6), + margin: EdgeInsets.only( + bottom: MediaQuery.of(context).viewInsets.bottom, + ), + color: CupertinoColors.systemBackground.resolveFrom(context), + child: SafeArea( + top: false, + child: child, + ), + ), + ); + } + + _saveButton() { + return InkWell( + onTap: () { + widget.settingsEntity.settingsCubit.updateProfileDetails( + profileDetailsModel: (widget.settingsEntity.settingsCubit.state as SettingsStateLoaded).profileDetails.copyWith( + firstName: firstNameController.text, + lastName: lastNameController.text, + birthdate: selectedDate.toString(), + gender: gender.value, + country: countryController.text, + city: cityController.text, + lang: languageController.text, + ), + ); + widget.settingsEntity.settingsCubit.updateProfileSettings( + profileSettingsModel: (widget.settingsEntity.settingsCubit.state as SettingsStateLoaded).profileSettings.copyWith( + isPublicProfile: isPublicProfile.value, + ), + ); + GoRouter.of(context).pop(); + }, + borderRadius: BorderRadius.circular(20), + child: Ink( + height: 52, + width: MediaQuery.of(context).size.width - 32, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(20), + color: appTheme.blueA400, + ), + child: Center( + child: Text( + 'Сохранить', + style: TextStyle( + color: Colors.white, + height: 1, + fontWeight: FontWeight.w600, + fontSize: 18, + ), + ), + ), + ), + ); + } +} diff --git a/lib/features/settings/presentation/pages/other_info_screen.dart b/lib/features/settings/presentation/pages/other_info_screen.dart new file mode 100644 index 00000000..2799b853 --- /dev/null +++ b/lib/features/settings/presentation/pages/other_info_screen.dart @@ -0,0 +1,163 @@ +import 'package:eatvio_app/features/settings/entities/settings_entity.dart'; +import 'package:eatvio_app/features/settings/presentation/bloc/settings_cubit/settings_state.dart'; +import 'package:eatvio_app/generated/l10n.dart'; +import 'package:eatvio_app/theme/theme_helper.dart'; +import 'package:eatvio_app/widgets/custom_text_form_field.dart'; +import 'package:flutter/material.dart'; +import 'package:go_router/go_router.dart'; + +class OtherInfoScreen extends StatefulWidget { + final SettingsEntity settingsEntity; + + const OtherInfoScreen({ + super.key, + required this.settingsEntity, + }); + + @override + State createState() => _OtherInfoScreenState(); +} + +class _OtherInfoScreenState extends State { + final aboutAllergyController = TextEditingController(); + final aboutTakingPillsController = TextEditingController(); + final aboutSportHobbiesController = TextEditingController(); + final favoriteFoodsController = TextEditingController(); + final unFavouriteFoodsController = TextEditingController(); + final additionalInfoController = TextEditingController(); + + @override + void initState() { + super.initState(); + aboutAllergyController.text = widget.settingsEntity.profileDetailsModel.aboutAlergy; + aboutTakingPillsController.text = widget.settingsEntity.profileDetailsModel.aboutTakingPils; + aboutSportHobbiesController.text = widget.settingsEntity.profileDetailsModel.aboutSportHobbies; + favoriteFoodsController.text = widget.settingsEntity.profileDetailsModel.favoriteFoods; + unFavouriteFoodsController.text = widget.settingsEntity.profileDetailsModel.unfavoriteFoods; + additionalInfoController.text = widget.settingsEntity.profileDetailsModel.additionalInfo; + } + + @override + Widget build(BuildContext context) { + final s = S.of(context); + + return Scaffold( + appBar: AppBar( + title: Text('Прочая информаиця'), + ), + bottomSheet: _saveButton(), + body: SingleChildScrollView( + padding: EdgeInsets.all(16) + EdgeInsets.only(bottom: 64), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text(s.allergies_presence), + SizedBox(height: 4), + CustomTextFormField( + controller: aboutAllergyController, + hintText: 'Например: орехи, мёд и т.д.', + autofocus: true, + minLines: 2, + maxLines: 8, + onChanged: (newValue) {}, + ), + SizedBox(height: 16), + Text(s.do_you_take_pills), + SizedBox(height: 4), + CustomTextFormField( + controller: aboutTakingPillsController, + hintText: s.enter_information, + autofocus: true, + minLines: 2, + maxLines: 8, + onChanged: (newValue) {}, + ), + SizedBox(height: 16), + Text(s.your_favorite_sports), + SizedBox(height: 4), + CustomTextFormField( + controller: aboutSportHobbiesController, + hintText: + "Я занимаюсь плаванием , почти каждый вечер прогулки на свежем воздухе, пару раз в месяц играю в волейбол. Стараюсь не сидеть на месте!", + autofocus: true, + maxLines: 8, + onChanged: (newValue) {}, + ), + SizedBox(height: 16), + Text(s.favorite_foods), + SizedBox(height: 4), + CustomTextFormField( + controller: favoriteFoodsController, + hintText: s.enter_information, + maxLines: 7, + minLines: 2, + onChanged: (newValue) {}, + ), + SizedBox(height: 16), + Text(s.unfavorite_foods), + SizedBox(height: 4), + CustomTextFormField( + controller: unFavouriteFoodsController, + hintText: s.enter_information, + maxLines: 7, + minLines: 2, + onChanged: (newValue) {}, + ), + SizedBox(height: 16), + Text( + 'Дополнительная информация', + maxLines: 2, + overflow: TextOverflow.ellipsis, + textAlign: TextAlign.start, + ), + SizedBox(height: 4), + CustomTextFormField( + controller: additionalInfoController, + hintText: "У меня крепкое здоровье, но последнее время часто утомляюсь, однако, это мне не мешает радоваться жизни", + maxLines: 8, + onChanged: (newValue) {}, + ), + ], + ), + ), + ); + } + + _saveButton() { + return InkWell( + onTap: () { + widget.settingsEntity.settingsCubit.updateProfileDetails( + profileDetailsModel: (widget.settingsEntity.settingsCubit.state as SettingsStateLoaded).profileDetails.copyWith( + aboutAlergy: aboutAllergyController.text, + aboutTakingPils: aboutTakingPillsController.text, + aboutSportHobbies: aboutSportHobbiesController.text, + favoriteFoods: favoriteFoodsController.text, + unfavoriteFoods: unFavouriteFoodsController.text, + additionalInfo: additionalInfoController.text, + ), + ); + GoRouter.of(context).pop(); + }, + borderRadius: BorderRadius.circular(20), + child: Ink( + height: 52, + width: MediaQuery.of(context).size.width - 32, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(20), + color: appTheme.blueA400, + ), + child: Center( + child: Text( + 'Сохранить', + style: TextStyle( + color: Colors.white, + height: 1, + fontWeight: FontWeight.w600, + fontSize: 18, + ), + ), + ), + ), + ); + } +} diff --git a/lib/features/settings/presentation/pages/physical_activity_screen.dart b/lib/features/settings/presentation/pages/physical_activity_screen.dart new file mode 100644 index 00000000..7718403d --- /dev/null +++ b/lib/features/settings/presentation/pages/physical_activity_screen.dart @@ -0,0 +1,171 @@ +import 'package:eatvio_app/features/settings/entities/settings_entity.dart'; +import 'package:eatvio_app/features/settings/presentation/bloc/settings_cubit/settings_state.dart'; +import 'package:eatvio_app/theme/theme_helper.dart'; +import 'package:flutter/material.dart'; +import 'package:go_router/go_router.dart'; + +class PhysicalActivityScreen extends StatefulWidget { + final SettingsEntity settingsEntity; + + const PhysicalActivityScreen({ + super.key, + required this.settingsEntity, + }); + + @override + State createState() => _PhysicalActivityScreenState(); +} + +enum PhysicalActivity { minimum, low, medium, high, extreme } + +class _PhysicalActivityScreenState extends State { + late PhysicalActivity? _physicalActivity; + + @override + void initState() { + super.initState(); + switch (widget.settingsEntity.profileDetailsModel.activityCoefficient) { + case 1.2: + _physicalActivity = PhysicalActivity.minimum; + break; + case 1.375: + _physicalActivity = PhysicalActivity.low; + break; + case 1.55: + _physicalActivity = PhysicalActivity.medium; + break; + case 1.7: + _physicalActivity = PhysicalActivity.high; + break; + case 1.9: + _physicalActivity = PhysicalActivity.extreme; + break; + } + } + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + title: Text('Физическая нагрузка'), + ), + bottomSheet: _saveButton(), + body: SingleChildScrollView( + physics: const BouncingScrollPhysics(), + padding: const EdgeInsets.only(top: 16, bottom: 80), + child: Column( + children: [ + RadioListTile( + contentPadding: EdgeInsets.only(left: 8, right: 16), + title: const Text('1,2 — минимальный (сидячая работа, отсутствие физических нагрузок);'), + value: PhysicalActivity.minimum, + groupValue: _physicalActivity, + onChanged: (PhysicalActivity? value) { + setState(() { + _physicalActivity = value; + }); + }, + ), + RadioListTile( + contentPadding: EdgeInsets.only(left: 8, right: 16), + title: const Text('1,375 — низкий (тренировки не менее 20 мин 1–3 раза в неделю);'), + value: PhysicalActivity.low, + groupValue: _physicalActivity, + onChanged: (PhysicalActivity? value) { + setState(() { + _physicalActivity = value; + }); + }, + ), + RadioListTile( + contentPadding: EdgeInsets.only(left: 8, right: 16), + title: const Text('1,55 — умеренный (тренировки 30–60 мин 3–4 раза в неделю);'), + value: PhysicalActivity.medium, + groupValue: _physicalActivity, + onChanged: (PhysicalActivity? value) { + setState(() { + _physicalActivity = value; + }); + }, + ), + RadioListTile( + contentPadding: EdgeInsets.only(left: 8, right: 16), + title: const Text('1,7 — высокий (тренировки 30–60 мин 5–7 раза в неделю; тяжёлая физическая работа);'), + value: PhysicalActivity.high, + groupValue: _physicalActivity, + onChanged: (PhysicalActivity? value) { + setState(() { + _physicalActivity = value; + }); + }, + ), + RadioListTile( + contentPadding: EdgeInsets.only(left: 8, right: 16), + title: const Text('1,9 — экстремальный (несколько интенсивных тренировок в день'), + value: PhysicalActivity.extreme, + groupValue: _physicalActivity, + onChanged: (PhysicalActivity? value) { + setState(() { + _physicalActivity = value; + }); + }, + ), + ], + ), + ), + ); + } + + _saveButton() { + return InkWell( + onTap: () { + late final double activityCoefficient; + switch (_physicalActivity) { + case PhysicalActivity.minimum: + activityCoefficient = 1.2; + break; + case PhysicalActivity.low: + activityCoefficient = 1.375; + break; + case PhysicalActivity.medium: + activityCoefficient = 1.55; + break; + case PhysicalActivity.high: + activityCoefficient = 1.7; + break; + case PhysicalActivity.extreme: + activityCoefficient = 1.9; + break; + default: + break; + } + widget.settingsEntity.settingsCubit.updateProfileDetails( + profileDetailsModel: (widget.settingsEntity.settingsCubit.state as SettingsStateLoaded).profileDetails.copyWith( + activityCoefficient: activityCoefficient, + ), + ); + GoRouter.of(context).pop(); + }, + borderRadius: BorderRadius.circular(20), + child: Ink( + height: 52, + width: MediaQuery.of(context).size.width - 32, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(20), + color: appTheme.blueA400, + ), + child: Center( + child: Text( + 'Сохранить', + style: TextStyle( + color: Colors.white, + height: 1, + fontWeight: FontWeight.w600, + fontSize: 18, + ), + ), + ), + ), + ); + } +} diff --git a/lib/features/settings/presentation/pages/physical_form_screen.dart b/lib/features/settings/presentation/pages/physical_form_screen.dart new file mode 100644 index 00000000..4bd34b94 --- /dev/null +++ b/lib/features/settings/presentation/pages/physical_form_screen.dart @@ -0,0 +1,127 @@ +import 'package:eatvio_app/features/settings/entities/settings_entity.dart'; +import 'package:eatvio_app/features/settings/presentation/bloc/settings_cubit/settings_state.dart'; +import 'package:eatvio_app/generated/l10n.dart'; +import 'package:eatvio_app/theme/theme_helper.dart'; +import 'package:eatvio_app/widgets/custom_text_form_field.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; +import 'package:go_router/go_router.dart'; + +class PhysicalFormScreen extends StatefulWidget { + final SettingsEntity settingsEntity; + + const PhysicalFormScreen({ + super.key, + required this.settingsEntity, + }); + + @override + State createState() => _PhysicalFormScreenState(); +} + +class _PhysicalFormScreenState extends State { + final digitsOnly = FilteringTextInputFormatter.digitsOnly; + final chestCircumferenceController = TextEditingController(); + final waistCircumferenceController = TextEditingController(); + final hipCircumferenceController = TextEditingController(); + final heightController = TextEditingController(); + + @override + void initState() { + super.initState(); + chestCircumferenceController.text = widget.settingsEntity.profileDetailsModel.chestCircumference.toString(); + waistCircumferenceController.text = widget.settingsEntity.profileDetailsModel.waistCircumference.toString(); + hipCircumferenceController.text = widget.settingsEntity.profileDetailsModel.hipCircumference.toString(); + heightController.text = widget.settingsEntity.profileDetailsModel.height.toString(); + } + + @override + Widget build(BuildContext context) { + final s = S.of(context); + + return Scaffold( + appBar: AppBar( + title: Text('Физическая форма'), + ), + bottomSheet: _saveButton(), + body: SingleChildScrollView( + physics: const BouncingScrollPhysics(), + padding: EdgeInsets.all(16) + EdgeInsets.only(bottom: 64), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text(s.chest_circumference), + SizedBox(height: 4), + CustomTextFormField( + inputFormatters: [digitsOnly], + controller: chestCircumferenceController, + hintText: 'см', + ), + SizedBox(height: 16), + Text(s.waist_circumference), + SizedBox(height: 4), + CustomTextFormField( + inputFormatters: [digitsOnly], + controller: waistCircumferenceController, + hintText: 'см', + ), + SizedBox(height: 16), + Text(s.hip_circumference), + SizedBox(height: 4), + CustomTextFormField( + inputFormatters: [digitsOnly], + controller: hipCircumferenceController, + hintText: 'см', + textInputAction: TextInputAction.done, + ), + SizedBox(height: 16), + Text('Рост'), + SizedBox(height: 4), + CustomTextFormField( + inputFormatters: [digitsOnly], + controller: heightController, + hintText: 'см', + textInputAction: TextInputAction.done, + ), + ], + ), + ), + ); + } + + _saveButton() { + return InkWell( + onTap: () { + widget.settingsEntity.settingsCubit.updateProfileDetails( + profileDetailsModel: (widget.settingsEntity.settingsCubit.state as SettingsStateLoaded).profileDetails.copyWith( + chestCircumference: int.parse(chestCircumferenceController.text), + waistCircumference: int.parse(waistCircumferenceController.text), + hipCircumference: int.parse(hipCircumferenceController.text), + height: int.parse(heightController.text), + ), + ); + GoRouter.of(context).pop(); + }, + borderRadius: BorderRadius.circular(20), + child: Ink( + height: 52, + width: MediaQuery.of(context).size.width - 32, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(20), + color: appTheme.blueA400, + ), + child: Center( + child: Text( + 'Сохранить', + style: TextStyle( + color: Colors.white, + height: 1, + fontWeight: FontWeight.w600, + fontSize: 18, + ), + ), + ), + ), + ); + } +} diff --git a/lib/features/settings/presentation/pages/pressure_screen.dart b/lib/features/settings/presentation/pages/pressure_screen.dart new file mode 100644 index 00000000..7c1ee72a --- /dev/null +++ b/lib/features/settings/presentation/pages/pressure_screen.dart @@ -0,0 +1,144 @@ +import 'package:eatvio_app/data/models/selectionPopupModel/selection_popup_model.dart'; +import 'package:eatvio_app/features/settings/entities/settings_entity.dart'; +import 'package:eatvio_app/features/settings/presentation/bloc/settings_cubit/settings_state.dart'; +import 'package:eatvio_app/generated/l10n.dart'; +import 'package:eatvio_app/theme/theme_helper.dart'; +import 'package:eatvio_app/widgets/custom_drop_down.dart'; +import 'package:eatvio_app/widgets/custom_text_form_field.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; +import 'package:go_router/go_router.dart'; + +class PressureScreen extends StatefulWidget { + final SettingsEntity settingsEntity; + + const PressureScreen({ + super.key, + required this.settingsEntity, + }); + + @override + State createState() => _PressureScreenState(); +} + +class _PressureScreenState extends State { + final digitsOnly = FilteringTextInputFormatter.digitsOnly; + final bloodPressureUpController = TextEditingController(); + final bloodPressureDownController = TextEditingController(); + late SelectionPopupModel hypo; + late SelectionPopupModel hyper; + + @override + void initState() { + super.initState(); + bloodPressureUpController.text = widget.settingsEntity.profileDetailsModel.bloodPressureUp.toString(); + bloodPressureDownController.text = widget.settingsEntity.profileDetailsModel.bloodPressureDown.toString(); + hypo = widget.settingsEntity.profileDetailsModel.hasHypo ? selectionPopupList[1] : selectionPopupList[0]; + hyper = widget.settingsEntity.profileDetailsModel.hasHyper ? selectionPopupList[1] : selectionPopupList[0]; + } + + final List selectionPopupList = [ + SelectionPopupModel(id: 0, title: 'Нет', value: false), + SelectionPopupModel(id: 1, title: 'Да', value: true), + ]; + + @override + Widget build(BuildContext context) { + final s = S.of(context); + + return Scaffold( + appBar: AppBar( + title: Text('Давление'), + ), + bottomSheet: _saveButton(), + body: SingleChildScrollView( + physics: const BouncingScrollPhysics(), + padding: EdgeInsets.all(16) + EdgeInsets.only(bottom: 64), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text(s.up_pressure), + SizedBox(height: 4), + CustomTextFormField( + controller: bloodPressureUpController, + inputFormatters: [digitsOnly], + hintText: "90", + onChanged: (newValue) {}, + ), + SizedBox(height: 16), + Text(s.down_pressure), + SizedBox(height: 4), + CustomTextFormField( + controller: bloodPressureDownController, + inputFormatters: [digitsOnly], + hintText: '90', + onChanged: (newValue) {}, + ), + SizedBox(height: 16), + Text(s.do_you_have_hypotension_tendency), + SizedBox(height: 4), + CustomDropDown( + items: selectionPopupList, + value: hypo, + hintText: "Не выбрано", + onChanged: (newPopup) { + setState(() { + hypo = newPopup; + }); + }, + ), + SizedBox(height: 16), + Text(s.do_you_have_hypertension_tendency), + SizedBox(height: 4), + CustomDropDown( + items: selectionPopupList, + value: hyper, + hintText: "Не выбрано", + onChanged: (newPopup) { + setState(() { + hyper = newPopup; + }); + }, + ), + ], + ), + ), + ); + } + + _saveButton() { + return InkWell( + onTap: () { + widget.settingsEntity.settingsCubit.updateProfileDetails( + profileDetailsModel: (widget.settingsEntity.settingsCubit.state as SettingsStateLoaded).profileDetails.copyWith( + bloodPressureUp: int.parse(bloodPressureUpController.text), + bloodPressureDown: int.parse(bloodPressureDownController.text), + hasHyper: hyper.value, + hasHypo: hypo.value, + ), + ); + GoRouter.of(context).pop(); + }, + borderRadius: BorderRadius.circular(20), + child: Ink( + height: 52, + width: MediaQuery.of(context).size.width - 32, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(20), + color: appTheme.blueA400, + ), + child: Center( + child: Text( + 'Сохранить', + style: TextStyle( + color: Colors.white, + height: 1, + fontWeight: FontWeight.w600, + fontSize: 18, + ), + ), + ), + ), + ); + } +} diff --git a/lib/features/settings/presentation/pages/settings_screen.dart b/lib/features/settings/presentation/pages/settings_screen.dart new file mode 100644 index 00000000..0a18843f --- /dev/null +++ b/lib/features/settings/presentation/pages/settings_screen.dart @@ -0,0 +1,438 @@ +import 'package:eatvio_app/core/const.dart'; +import 'package:eatvio_app/features/settings/entities/settings_entity.dart'; +import 'package:eatvio_app/features/settings/presentation/bloc/settings_cubit/settings_cubit.dart'; +import 'package:eatvio_app/features/settings/presentation/bloc/settings_cubit/settings_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:flutter_bloc/flutter_bloc.dart'; +import 'package:go_router/go_router.dart'; +import 'package:rive/rive.dart'; +import 'package:url_launcher/url_launcher.dart'; + +class SettingsScreen extends StatefulWidget { + const SettingsScreen({super.key}); + + @override + State createState() => _SettingsScreenState(); +} + +class _SettingsScreenState extends State { + final SettingsCubit settingsCubit = sl()..init(); + late bool updatesNotificationsSwitchState; + late bool fillDiaryNotificationsSwitchState; + late bool bedTimeSwitchState; + late bool moodSwitchState; + + @override + Widget build(BuildContext context) { + return BlocProvider( + create: (BuildContext context) => settingsCubit, + child: BlocConsumer( + bloc: settingsCubit, + listener: (BuildContext context, SettingsState state) { + if (state is SettingsStateLoaded) { + updatesNotificationsSwitchState = state.profileSettings.newUpdatesNotifications == 1 ? true : false; + fillDiaryNotificationsSwitchState = state.profileSettings.diaryReminderNotifications == 1 ? true : false; + bedTimeSwitchState = state.profileSettings.isBedtimeFillable; + moodSwitchState = state.profileSettings.isMoodFillable; + } + }, + builder: (BuildContext context, SettingsState state) { + if (state is SettingsStateLoaded) { + return Scaffold( + appBar: AppBar( + title: Text('Настройки'), + ), + body: SingleChildScrollView( + padding: EdgeInsets.symmetric(vertical: 16), + physics: const BouncingScrollPhysics(), + child: Column( + children: [ + _additionalInfo(state), + const SizedBox(height: 12), + _notifications(state), + const SizedBox(height: 12), + _aboutEatvio(state), + const SizedBox(height: 12), + _becomeConsultantButton(state), + const SizedBox(height: 8), + _deleteAccountButton(state), + ], + ), + ), + ); + } + if (state is SettingsStateError) { + return Scaffold( + body: Padding( + padding: const EdgeInsets.all(16), + child: Center(child: Text(state.errorMessage)), + ), + ); + } + return Scaffold( + body: Center( + child: SizedBox( + height: 32, + width: 32, + child: RiveAnimation.asset( + 'assets/rive_animations/loading.riv', + ), + ), + ), + ); + }, + ), + ); + } + + _additionalInfo(SettingsStateLoaded state) { + return Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Padding( + padding: const EdgeInsets.symmetric(horizontal: 16), + child: Text( + 'Дополнительаная информация', + style: TextStyle( + fontSize: 16, + height: 1, + color: Colors.grey, + fontFamily: 'Mulish', + ), + ), + ), + _tile( + onTap: () => GoRouter.of(context).pushNamed( + 'generalInfoScreen', + extra: SettingsEntity( + profileSettingsModel: state.profileSettings, + profileDetailsModel: state.profileDetails, + settingsCubit: settingsCubit, + ), + ), + title: 'Общая информация', + ), + _divider(context), + _tile( + onTap: () => GoRouter.of(context).pushNamed( + 'physicalFormScreen', + extra: SettingsEntity( + profileSettingsModel: state.profileSettings, + profileDetailsModel: state.profileDetails, + settingsCubit: settingsCubit, + ), + ), + title: 'Физическая форма', + ), + _divider(context), + _tile( + onTap: () => GoRouter.of(context).pushNamed( + 'pressureScreen', + extra: SettingsEntity( + profileSettingsModel: state.profileSettings, + profileDetailsModel: state.profileDetails, + settingsCubit: settingsCubit, + ), + ), + title: 'Давление', + ), + _divider(context), + _tile( + onTap: () => GoRouter.of(context).pushNamed( + 'otherInfoScreen', + extra: SettingsEntity( + profileSettingsModel: state.profileSettings, + profileDetailsModel: state.profileDetails, + settingsCubit: settingsCubit, + ), + ), + title: 'Прочая информация', + ), + _divider(context), + _tile( + onTap: () => GoRouter.of(context).pushNamed( + 'physicalActivityScreen', + extra: SettingsEntity( + profileSettingsModel: state.profileSettings, + profileDetailsModel: state.profileDetails, + settingsCubit: settingsCubit, + ), + ), + title: 'Физическая нагрузка', + ), + _divider(context), + _tile( + onTap: () => GoRouter.of(context).pushNamed( + 'changePasswordScreen', + extra: SettingsEntity( + profileSettingsModel: state.profileSettings, + profileDetailsModel: state.profileDetails, + settingsCubit: settingsCubit, + ), + ), + title: 'Сменить пароль', + ), + ], + ); + } + + _notifications(SettingsStateLoaded state) { + return Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Padding( + padding: const EdgeInsets.symmetric(horizontal: 16), + child: Text( + 'Уведомления', + style: TextStyle( + fontSize: 16, + height: 1, + color: Colors.grey, + ), + ), + ), + _tile( + padding: EdgeInsets.symmetric(horizontal: 16), + onTap: () { + setState(() { + updatesNotificationsSwitchState = !updatesNotificationsSwitchState; + }); + settingsCubit.updateProfileSettings( + profileSettingsModel: state.profileSettings.copyWith( + newUpdatesNotifications: updatesNotificationsSwitchState, + ), + ); + }, + title: 'Уведомление о новых обновлениях', + trailing: CupertinoSwitch( + value: updatesNotificationsSwitchState, + activeColor: appTheme.blueA400, + onChanged: (newValue) { + setState(() { + updatesNotificationsSwitchState = newValue; + }); + settingsCubit.updateProfileSettings( + profileSettingsModel: state.profileSettings.copyWith( + newUpdatesNotifications: updatesNotificationsSwitchState, + ), + ); + }, + ), + ), + _divider(context), + _tile( + padding: EdgeInsets.symmetric(horizontal: 16), + onTap: () { + setState(() { + fillDiaryNotificationsSwitchState = !fillDiaryNotificationsSwitchState; + }); + settingsCubit.updateProfileSettings( + profileSettingsModel: state.profileSettings.copyWith( + diaryReminderNotifications: fillDiaryNotificationsSwitchState, + ), + ); + }, + title: 'Напоминание о заполнении дневника', + trailing: CupertinoSwitch( + value: fillDiaryNotificationsSwitchState, + activeColor: appTheme.blueA400, + onChanged: (newValue) { + setState(() { + fillDiaryNotificationsSwitchState = newValue; + }); + settingsCubit.updateProfileSettings( + profileSettingsModel: state.profileSettings.copyWith( + diaryReminderNotifications: fillDiaryNotificationsSwitchState, + ), + ); + }, + ), + ), + _divider(context), + _tile( + padding: EdgeInsets.symmetric(horizontal: 16), + onTap: () { + setState(() { + moodSwitchState = !moodSwitchState; + }); + settingsCubit.updateProfileSettings( + profileSettingsModel: state.profileSettings.copyWith( + isMoodFillable: moodSwitchState, + ), + ); + }, + title: 'Указывать “настроение” в заполнение дневника', + trailing: CupertinoSwitch( + value: moodSwitchState, + activeColor: appTheme.blueA400, + onChanged: (newValue) { + setState(() { + moodSwitchState = newValue; + }); + settingsCubit.updateProfileSettings( + profileSettingsModel: state.profileSettings.copyWith( + isMoodFillable: moodSwitchState, + ), + ); + }, + ), + ), + _divider(context), + _tile( + padding: EdgeInsets.symmetric(horizontal: 16), + onTap: () { + setState(() { + bedTimeSwitchState = !bedTimeSwitchState; + }); + settingsCubit.updateProfileSettings( + profileSettingsModel: state.profileSettings.copyWith( + isBedtimeFillable: bedTimeSwitchState, + ), + ); + }, + title: 'Указывать “отход ко сну” в заполнение дневника', + trailing: CupertinoSwitch( + value: bedTimeSwitchState, + activeColor: appTheme.blueA400, + onChanged: (newValue) { + setState(() { + bedTimeSwitchState = newValue; + }); + settingsCubit.updateProfileSettings( + profileSettingsModel: state.profileSettings.copyWith( + isBedtimeFillable: bedTimeSwitchState, + ), + ); + }, + ), + ), + ], + ); + } + + _aboutEatvio(SettingsStateLoaded state) { + return Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Padding( + padding: const EdgeInsets.symmetric(horizontal: 16), + child: Text( + 'О Eatvio', + style: TextStyle( + fontSize: 16, + height: 1, + color: Colors.grey, + ), + ), + ), + _tile( + title: 'О компании', + onTap: () async => await launchUrl(Uri.parse(baseUrl + '/ru/company-details')), + ), + _divider(context), + _tile( + title: 'Пользовательское соглашение', + onTap: () async => await launchUrl(Uri.parse(baseUrl + '/oferta_bs.pdf')), + ), + ], + ); + } + + _becomeConsultantButton(SettingsStateLoaded state) { + return Padding( + padding: EdgeInsets.symmetric(horizontal: 16), + child: InkWell( + onTap: () {}, + borderRadius: BorderRadius.circular(20), + child: Ink( + height: 52, + width: MediaQuery.of(context).size.width - 16, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(20), + color: appTheme.blueA400, + ), + child: Center( + child: Text( + 'Стать консультантом', + style: TextStyle( + color: Colors.white, + height: 1, + fontSize: 18, + ), + ), + ), + ), + ), + ); + } + + _deleteAccountButton(SettingsStateLoaded state) { + return Padding( + padding: EdgeInsets.symmetric(horizontal: 16), + child: InkWell( + onTap: () {}, + borderRadius: BorderRadius.circular(20), + child: Ink( + height: 52, + width: MediaQuery.of(context).size.width - 16, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(20), + color: Color(0xFFEAEAEA), + ), + child: Center( + child: Text( + 'Удалить аккаунт', + style: TextStyle( + color: Colors.black, + height: 1, + fontSize: 18, + ), + ), + ), + ), + ), + ); + } + + _tile({ + required String title, + required Function() onTap, + Widget? trailing, + EdgeInsets? padding, + }) { + return ListTile( + contentPadding: padding, + onTap: onTap, + title: Text( + title, + style: TextStyle( + fontSize: 14, + fontWeight: FontWeight.w500, + height: 1, + ), + ), + trailing: trailing ?? + Icon( + Icons.arrow_forward_ios_rounded, + size: 12, + color: Colors.black38, + ), + ); + } + + _divider(BuildContext context) { + return Center( + child: Container( + height: 0.4, + width: MediaQuery.of(context).size.width - 32, + decoration: BoxDecoration( + color: Colors.black26, + borderRadius: BorderRadius.circular(16), + ), + ), + ); + } +} diff --git a/lib/features/settings/repositories/service_repository.dart b/lib/features/settings/repositories/service_repository.dart new file mode 100644 index 00000000..eb462de3 --- /dev/null +++ b/lib/features/settings/repositories/service_repository.dart @@ -0,0 +1,41 @@ +import 'package:eatvio_app/features/profile/models/profile_model.dart'; +import 'package:eatvio_app/features/settings/models/profile_settings_model.dart'; +import 'package:eatvio_app/features/settings/services/settings_service.dart'; + +class SettingsRepository { + final SettingsService settingsService; + + const SettingsRepository({required this.settingsService}); + + Future getProfileSettings() async { + try { + return await settingsService.getProfileSettings(); + } catch (e) { + rethrow; + } + } + + Future updateProfileSettings({ + required ProfileSettingsModel profileSettingsModel, + }) async { + try { + return await settingsService.updateProfileSettings( + data: profileSettingsModel.toJson(), + ); + } catch (e) { + rethrow; + } + } + + Future updateProfileDetails({ + required ProfileDetailsModel profileDetailsModel, + }) async { + try { + return await settingsService.updateProfileDetails( + data: profileDetailsModel.toJson(), + ); + } catch (e) { + rethrow; + } + } +} diff --git a/lib/features/settings/services/settings_service.dart b/lib/features/settings/services/settings_service.dart new file mode 100644 index 00000000..71d5de73 --- /dev/null +++ b/lib/features/settings/services/settings_service.dart @@ -0,0 +1,24 @@ +import 'package:dio/dio.dart'; +import 'package:eatvio_app/features/profile/models/profile_model.dart'; +import 'package:eatvio_app/features/settings/models/profile_settings_model.dart'; +import 'package:retrofit/retrofit.dart'; + +part 'settings_service.g.dart'; + +@RestApi() +abstract class SettingsService { + factory SettingsService(Dio dio, {String baseUrl}) = _SettingsService; + + @GET('/api/profile/settings') + Future getProfileSettings(); + + @POST('/api/profile/settings/update') + Future updateProfileSettings({ + @Body() required Map data, + }); + + @POST('/api/profile/update') + Future updateProfileDetails({ + @Body() required Map data, + }); +} diff --git a/lib/features/settings/services/settings_service.g.dart b/lib/features/settings/services/settings_service.g.dart new file mode 100644 index 00000000..f1d38de5 --- /dev/null +++ b/lib/features/settings/services/settings_service.g.dart @@ -0,0 +1,156 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'settings_service.dart'; + +// ************************************************************************** +// RetrofitGenerator +// ************************************************************************** + +// ignore_for_file: unnecessary_brace_in_string_interps,no_leading_underscores_for_local_identifiers,unused_element + +class _SettingsService implements SettingsService { + _SettingsService( + this._dio, { + this.baseUrl, + this.errorLogger, + }); + + final Dio _dio; + + String? baseUrl; + + final ParseErrorLogger? errorLogger; + + @override + Future getProfileSettings() 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/settings', + queryParameters: queryParameters, + data: _data, + ) + .copyWith( + baseUrl: _combineBaseUrls( + _dio.options.baseUrl, + baseUrl, + ))); + final _result = await _dio.fetch>(_options); + late ProfileSettingsModel _value; + try { + _value = ProfileSettingsModel.fromJson(_result.data!); + } on Object catch (e, s) { + errorLogger?.logError(e, s, _options); + rethrow; + } + return _value; + } + + @override + Future updateProfileSettings( + {required Map data}) async { + final _extra = {}; + final queryParameters = {}; + final _headers = {}; + final _data = {}; + _data.addAll(data); + final _options = _setStreamType(Options( + method: 'POST', + headers: _headers, + extra: _extra, + ) + .compose( + _dio.options, + '/api/profile/settings/update', + queryParameters: queryParameters, + data: _data, + ) + .copyWith( + baseUrl: _combineBaseUrls( + _dio.options.baseUrl, + baseUrl, + ))); + final _result = await _dio.fetch>(_options); + late ProfileSettingsModel _value; + try { + _value = ProfileSettingsModel.fromJson(_result.data!); + } on Object catch (e, s) { + errorLogger?.logError(e, s, _options); + rethrow; + } + return _value; + } + + @override + Future updateProfileDetails( + {required Map data}) async { + final _extra = {}; + final queryParameters = {}; + final _headers = {}; + final _data = {}; + _data.addAll(data); + final _options = _setStreamType(Options( + method: 'POST', + headers: _headers, + extra: _extra, + ) + .compose( + _dio.options, + '/api/profile/update', + queryParameters: queryParameters, + data: _data, + ) + .copyWith( + baseUrl: _combineBaseUrls( + _dio.options.baseUrl, + baseUrl, + ))); + final _result = await _dio.fetch>(_options); + late ProfileDetailsModel _value; + try { + _value = ProfileDetailsModel.fromJson(_result.data!); + } on Object catch (e, s) { + errorLogger?.logError(e, s, _options); + rethrow; + } + return _value; + } + + RequestOptions _setStreamType(RequestOptions requestOptions) { + if (T != dynamic && + !(requestOptions.responseType == ResponseType.bytes || + requestOptions.responseType == ResponseType.stream)) { + if (T == String) { + requestOptions.responseType = ResponseType.plain; + } else { + requestOptions.responseType = ResponseType.json; + } + } + return requestOptions; + } + + String _combineBaseUrls( + String dioBaseUrl, + String? baseUrl, + ) { + if (baseUrl == null || baseUrl.trim().isEmpty) { + return dioBaseUrl; + } + + final url = Uri.parse(baseUrl); + + if (url.isAbsolute) { + return url.toString(); + } + + return Uri.parse(dioBaseUrl).resolveUri(url).toString(); + } +} diff --git a/lib/generated/intl/messages_all.dart b/lib/generated/intl/messages_all.dart new file mode 100644 index 00000000..203415cc --- /dev/null +++ b/lib/generated/intl/messages_all.dart @@ -0,0 +1,63 @@ +// DO NOT EDIT. This is code generated via package:intl/generate_localized.dart +// This is a library that looks up messages for specific locales by +// delegating to the appropriate library. + +// Ignore issues from commonly used lints in this file. +// ignore_for_file:implementation_imports, file_names, unnecessary_new +// ignore_for_file:unnecessary_brace_in_string_interps, directives_ordering +// ignore_for_file:argument_type_not_assignable, invalid_assignment +// ignore_for_file:prefer_single_quotes, prefer_generic_function_type_aliases +// ignore_for_file:comment_references + +import 'dart:async'; + +import 'package:flutter/foundation.dart'; +import 'package:intl/intl.dart'; +import 'package:intl/message_lookup_by_library.dart'; +import 'package:intl/src/intl_helpers.dart'; + +import 'messages_en.dart' as messages_en; + +typedef Future LibraryLoader(); +Map _deferredLibraries = { + 'en': () => new SynchronousFuture(null), +}; + +MessageLookupByLibrary? _findExact(String localeName) { + switch (localeName) { + case 'en': + return messages_en.messages; + default: + return null; + } +} + +/// User programs should call this before using [localeName] for messages. +Future initializeMessages(String localeName) { + var availableLocale = Intl.verifiedLocale( + localeName, (locale) => _deferredLibraries[locale] != null, + onFailure: (_) => null); + if (availableLocale == null) { + return new SynchronousFuture(false); + } + var lib = _deferredLibraries[availableLocale]; + lib == null ? new SynchronousFuture(false) : lib(); + initializeInternalMessageLookup(() => new CompositeMessageLookup()); + messageLookup.addLocale(availableLocale, _findGeneratedMessagesFor); + return new SynchronousFuture(true); +} + +bool _messagesExistFor(String locale) { + try { + return _findExact(locale) != null; + } catch (e) { + return false; + } +} + +MessageLookupByLibrary? _findGeneratedMessagesFor(String locale) { + var actualLocale = + Intl.verifiedLocale(locale, _messagesExistFor, onFailure: (_) => null); + if (actualLocale == null) return null; + return _findExact(actualLocale); +} diff --git a/lib/generated/intl/messages_en.dart b/lib/generated/intl/messages_en.dart new file mode 100644 index 00000000..34f0eb48 --- /dev/null +++ b/lib/generated/intl/messages_en.dart @@ -0,0 +1,175 @@ +// DO NOT EDIT. This is code generated via package:intl/generate_localized.dart +// This is a library that provides messages for a en locale. All the +// messages from the main program should be duplicated here with the same +// function name. + +// Ignore issues from commonly used lints in this file. +// ignore_for_file:unnecessary_brace_in_string_interps, unnecessary_new +// ignore_for_file:prefer_single_quotes,comment_references, directives_ordering +// ignore_for_file:annotate_overrides,prefer_generic_function_type_aliases +// ignore_for_file:unused_import, file_names, avoid_escaping_inner_quotes +// ignore_for_file:unnecessary_string_interpolations, unnecessary_string_escapes + +import 'package:intl/intl.dart'; +import 'package:intl/message_lookup_by_library.dart'; + +final messages = new MessageLookup(); + +typedef String MessageIfAbsent(String messageStr, List args); + +class MessageLookup extends MessageLookupByLibrary { + String get localeName => 'en'; + + final messages = _notInlinedMessages(_notInlinedMessages); + static Map _notInlinedMessages(_) => { + "Moscow": MessageLookupByLibrary.simpleMessage("Москва"), + "Russia": MessageLookupByLibrary.simpleMessage("Россия"), + "active": MessageLookupByLibrary.simpleMessage("Активен"), + "add_measure": MessageLookupByLibrary.simpleMessage("Добавить замер"), + "additional_information": + MessageLookupByLibrary.simpleMessage("Дополнительная информация"), + "admin": MessageLookupByLibrary.simpleMessage("Админ"), + "allergies_presence": + MessageLookupByLibrary.simpleMessage("Наличие аллергии"), + "archived": MessageLookupByLibrary.simpleMessage("В архиве"), + "authentificate": MessageLookupByLibrary.simpleMessage("Войти"), + "average_pressure": MessageLookupByLibrary.simpleMessage( + "Средние показатели давления:"), + "bodymass_chart": MessageLookupByLibrary.simpleMessage("График ИМТ"), + "chat": MessageLookupByLibrary.simpleMessage("Чат"), + "chest": MessageLookupByLibrary.simpleMessage("Грудь"), + "chest_circumference": + MessageLookupByLibrary.simpleMessage("Обхват груди"), + "circumference_empty": MessageLookupByLibrary.simpleMessage( + "Все замеры обязательны к заполнению"), + "circumference_is_not_a_number": MessageLookupByLibrary.simpleMessage( + "Все замеры должны быть числами"), + "circumferences_chart": + MessageLookupByLibrary.simpleMessage("График обхватов"), + "city": MessageLookupByLibrary.simpleMessage("Город"), + "city_of_living": + MessageLookupByLibrary.simpleMessage("Город проживания"), + "continueButton": MessageLookupByLibrary.simpleMessage("Продолжить"), + "country": MessageLookupByLibrary.simpleMessage("Страна"), + "date_of_birth": MessageLookupByLibrary.simpleMessage("Дата рождения"), + "diary": MessageLookupByLibrary.simpleMessage("Дневник"), + "do_you_have_hypertension_tendency": + MessageLookupByLibrary.simpleMessage("Есть ли у вас гипертония?"), + "do_you_have_hypotension_tendency": + MessageLookupByLibrary.simpleMessage("Есть ли у вас гипотония?"), + "do_you_take_pills": MessageLookupByLibrary.simpleMessage( + "Принимаете ли вы лекарства или бады?"), + "down_pressure": + MessageLookupByLibrary.simpleMessage("Нижние показатели давления:"), + "draft": MessageLookupByLibrary.simpleMessage("Черновик"), + "email": MessageLookupByLibrary.simpleMessage("Элетронная почта"), + "email_empty": MessageLookupByLibrary.simpleMessage( + "Необходимо ввести адрес электронной почты"), + "email_invalid": MessageLookupByLibrary.simpleMessage( + "Некорректный адрес электронной почты"), + "enter_additional_information": MessageLookupByLibrary.simpleMessage( + "Введите любую дополнительную информацию на своё усмотрение:"), + "enter_information": + MessageLookupByLibrary.simpleMessage("Введите информацию..."), + "exit": MessageLookupByLibrary.simpleMessage("Выйти"), + "favorite_foods": + MessageLookupByLibrary.simpleMessage("Любимые продукты"), + "favorite_unfavorite_foods": MessageLookupByLibrary.simpleMessage( + "Ваши любимые/нелюбимые продукты питания?"), + "female": MessageLookupByLibrary.simpleMessage("Женский"), + "fill_in_information": + MessageLookupByLibrary.simpleMessage("Заполните информацию:"), + "finish": MessageLookupByLibrary.simpleMessage("Завершить"), + "first_name": MessageLookupByLibrary.simpleMessage("Имя"), + "first_name_empty": MessageLookupByLibrary.simpleMessage( + "Имя обязательно для заполнения"), + "first_name_short": MessageLookupByLibrary.simpleMessage( + "В имени должен быть минимум 1 символ"), + "gr": MessageLookupByLibrary.simpleMessage("гр"), + "grams": MessageLookupByLibrary.simpleMessage("гр"), + "height_measurements": + MessageLookupByLibrary.simpleMessage("Замер роста"), + "hip_circumference": + MessageLookupByLibrary.simpleMessage("Обхват бедер"), + "hips": MessageLookupByLibrary.simpleMessage("Бедра"), + "in_progress": MessageLookupByLibrary.simpleMessage("В процессе"), + "initial_measurements": + MessageLookupByLibrary.simpleMessage("Первичные замеры"), + "language": MessageLookupByLibrary.simpleMessage("Язык"), + "last_name": MessageLookupByLibrary.simpleMessage("Фамилия"), + "last_name_empty": MessageLookupByLibrary.simpleMessage( + "Фамилия обязательна для заполнения"), + "last_name_short": MessageLookupByLibrary.simpleMessage( + "В фамилии должен быть минимум 6 символов"), + "lbl_english": MessageLookupByLibrary.simpleMessage("English"), + "loading": MessageLookupByLibrary.simpleMessage("Загрузка..."), + "male": MessageLookupByLibrary.simpleMessage("Мужской"), + "msg_network_err": + MessageLookupByLibrary.simpleMessage("Сетевая ошибка!"), + "msg_something_went_wrong": + MessageLookupByLibrary.simpleMessage("Что то пошло не так!"), + "my_blog": MessageLookupByLibrary.simpleMessage("Мой блог"), + "my_settings": MessageLookupByLibrary.simpleMessage("Мои настройки"), + "name_empty": MessageLookupByLibrary.simpleMessage( + "Имя пользователя обязательно для заполнения"), + "name_short": MessageLookupByLibrary.simpleMessage( + "В имени пользователя должно быть минимум 6 символов"), + "no": MessageLookupByLibrary.simpleMessage("Нет"), + "no_account": + MessageLookupByLibrary.simpleMessage("У меня нет аккаунта"), + "password": MessageLookupByLibrary.simpleMessage("Пароль"), + "password_confirmation": + MessageLookupByLibrary.simpleMessage("Подтвердите пароль"), + "password_confirmation_mismatch": + MessageLookupByLibrary.simpleMessage("Пароли не совпадают"), + "password_empty": MessageLookupByLibrary.simpleMessage( + "Пароль обязателен для заполнения"), + "password_short": MessageLookupByLibrary.simpleMessage( + "В пароле должно быть минимум 6 символов"), + "pcs": MessageLookupByLibrary.simpleMessage("шт"), + "place_of_living": + MessageLookupByLibrary.simpleMessage("Место проживания"), + "plans_complete": + MessageLookupByLibrary.simpleMessage("Пройденные планы"), + "preferred_language": + MessageLookupByLibrary.simpleMessage("Предпочитаемый язык общения"), + "pressure_empty": MessageLookupByLibrary.simpleMessage( + "Все показатели давления обязательны к заполнению"), + "pressure_is_not_a_number": MessageLookupByLibrary.simpleMessage( + "Все показатели давления должны быть числами"), + "profile": MessageLookupByLibrary.simpleMessage("Профиль"), + "save": MessageLookupByLibrary.simpleMessage("Сохранить"), + "settings": MessageLookupByLibrary.simpleMessage("Настройки"), + "skip": MessageLookupByLibrary.simpleMessage("Пропустить"), + "tell_your_schedule": MessageLookupByLibrary.simpleMessage( + "Расскажите в свободной форме о том как просыпаетесь, когда едите, когда ложитесь спать:"), + "unfavorite_foods": + MessageLookupByLibrary.simpleMessage("Нелюбимые продукты"), + "up_pressure": MessageLookupByLibrary.simpleMessage( + "Верхние показатели давления:"), + "user_authorization": + MessageLookupByLibrary.simpleMessage("Аутентификация"), + "user_registration": + MessageLookupByLibrary.simpleMessage("Регистрация пользователя"), + "username": MessageLookupByLibrary.simpleMessage("Имя пользователя"), + "waist": MessageLookupByLibrary.simpleMessage("Талия"), + "waist_circumference": + MessageLookupByLibrary.simpleMessage("Обхват талии"), + "weight": MessageLookupByLibrary.simpleMessage("Вес"), + "weight_chart": MessageLookupByLibrary.simpleMessage("График веса"), + "weight_measurements": + MessageLookupByLibrary.simpleMessage("Замер веса"), + "what_is_your_name": + MessageLookupByLibrary.simpleMessage("Как вас зовут?"), + "wrong_credentials": MessageLookupByLibrary.simpleMessage( + "Неверные данные пользователя"), + "your_blood_pressure": + MessageLookupByLibrary.simpleMessage("Ваше артериальное давление?"), + "your_favorite_sports": + MessageLookupByLibrary.simpleMessage("Ваши спортивные увлечения?"), + "your_gender": MessageLookupByLibrary.simpleMessage("Ваш пол?"), + "your_height": MessageLookupByLibrary.simpleMessage("Ваш рост:"), + "your_schedule": MessageLookupByLibrary.simpleMessage("Ваш режим дня?"), + "your_weight": MessageLookupByLibrary.simpleMessage("Ваш вес:") + }; +} diff --git a/lib/generated/l10n.dart b/lib/generated/l10n.dart new file mode 100644 index 00000000..b54c60ae --- /dev/null +++ b/lib/generated/l10n.dart @@ -0,0 +1,1058 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND +import 'package:flutter/material.dart'; +import 'package:intl/intl.dart'; +import 'intl/messages_all.dart'; + +// ************************************************************************** +// Generator: Flutter Intl IDE plugin +// Made by Localizely +// ************************************************************************** + +// ignore_for_file: non_constant_identifier_names, lines_longer_than_80_chars +// ignore_for_file: join_return_with_assignment, prefer_final_in_for_each +// ignore_for_file: avoid_redundant_argument_values, avoid_escaping_inner_quotes + +class S { + S(); + + static S? _current; + + static S get current { + assert(_current != null, + 'No instance of S was loaded. Try to initialize the S delegate before accessing S.current.'); + return _current!; + } + + static const AppLocalizationDelegate delegate = AppLocalizationDelegate(); + + static Future load(Locale locale) { + final name = (locale.countryCode?.isEmpty ?? false) + ? locale.languageCode + : locale.toString(); + final localeName = Intl.canonicalizedLocale(name); + return initializeMessages(localeName).then((_) { + Intl.defaultLocale = localeName; + final instance = S(); + S._current = instance; + + return instance; + }); + } + + static S of(BuildContext context) { + final instance = S.maybeOf(context); + assert(instance != null, + 'No instance of S present in the widget tree. Did you add S.delegate in localizationsDelegates?'); + return instance!; + } + + static S? maybeOf(BuildContext context) { + return Localizations.of(context, S); + } + + /// `Регистрация пользователя` + String get user_registration { + return Intl.message( + 'Регистрация пользователя', + name: 'user_registration', + desc: '', + args: [], + ); + } + + /// `Элетронная почта` + String get email { + return Intl.message( + 'Элетронная почта', + name: 'email', + desc: '', + args: [], + ); + } + + /// `Имя пользователя` + String get username { + return Intl.message( + 'Имя пользователя', + name: 'username', + desc: '', + args: [], + ); + } + + /// `Пароль` + String get password { + return Intl.message( + 'Пароль', + name: 'password', + desc: '', + args: [], + ); + } + + /// `Подтвердите пароль` + String get password_confirmation { + return Intl.message( + 'Подтвердите пароль', + name: 'password_confirmation', + desc: '', + args: [], + ); + } + + /// `Неверные данные пользователя` + String get wrong_credentials { + return Intl.message( + 'Неверные данные пользователя', + name: 'wrong_credentials', + desc: '', + args: [], + ); + } + + /// `Имя` + String get first_name { + return Intl.message( + 'Имя', + name: 'first_name', + desc: '', + args: [], + ); + } + + /// `Фамилия` + String get last_name { + return Intl.message( + 'Фамилия', + name: 'last_name', + desc: '', + args: [], + ); + } + + /// `Как вас зовут?` + String get what_is_your_name { + return Intl.message( + 'Как вас зовут?', + name: 'what_is_your_name', + desc: '', + args: [], + ); + } + + /// `Дата рождения` + String get date_of_birth { + return Intl.message( + 'Дата рождения', + name: 'date_of_birth', + desc: '', + args: [], + ); + } + + /// `Страна` + String get country { + return Intl.message( + 'Страна', + name: 'country', + desc: '', + args: [], + ); + } + + /// `Россия` + String get Russia { + return Intl.message( + 'Россия', + name: 'Russia', + desc: '', + args: [], + ); + } + + /// `Город` + String get city { + return Intl.message( + 'Город', + name: 'city', + desc: '', + args: [], + ); + } + + /// `Москва` + String get Moscow { + return Intl.message( + 'Москва', + name: 'Moscow', + desc: '', + args: [], + ); + } + + /// `Место проживания` + String get place_of_living { + return Intl.message( + 'Место проживания', + name: 'place_of_living', + desc: '', + args: [], + ); + } + + /// `Обхват бедер` + String get hip_circumference { + return Intl.message( + 'Обхват бедер', + name: 'hip_circumference', + desc: '', + args: [], + ); + } + + /// `Обхват груди` + String get chest_circumference { + return Intl.message( + 'Обхват груди', + name: 'chest_circumference', + desc: '', + args: [], + ); + } + + /// `Обхват талии` + String get waist_circumference { + return Intl.message( + 'Обхват талии', + name: 'waist_circumference', + desc: '', + args: [], + ); + } + + /// `Первичные замеры` + String get initial_measurements { + return Intl.message( + 'Первичные замеры', + name: 'initial_measurements', + desc: '', + args: [], + ); + } + + /// `Мужской` + String get male { + return Intl.message( + 'Мужской', + name: 'male', + desc: '', + args: [], + ); + } + + /// `Женский` + String get female { + return Intl.message( + 'Женский', + name: 'female', + desc: '', + args: [], + ); + } + + /// `Замер веса` + String get weight_measurements { + return Intl.message( + 'Замер веса', + name: 'weight_measurements', + desc: '', + args: [], + ); + } + + /// `Ваш вес:` + String get your_weight { + return Intl.message( + 'Ваш вес:', + name: 'your_weight', + desc: '', + args: [], + ); + } + + /// `Замер роста` + String get height_measurements { + return Intl.message( + 'Замер роста', + name: 'height_measurements', + desc: '', + args: [], + ); + } + + /// `Ваш рост:` + String get your_height { + return Intl.message( + 'Ваш рост:', + name: 'your_height', + desc: '', + args: [], + ); + } + + /// `Наличие аллергии` + String get allergies_presence { + return Intl.message( + 'Наличие аллергии', + name: 'allergies_presence', + desc: '', + args: [], + ); + } + + /// `Принимаете ли вы лекарства или бады?` + String get do_you_take_pills { + return Intl.message( + 'Принимаете ли вы лекарства или бады?', + name: 'do_you_take_pills', + desc: '', + args: [], + ); + } + + /// `Ваш пол?` + String get your_gender { + return Intl.message( + 'Ваш пол?', + name: 'your_gender', + desc: '', + args: [], + ); + } + + /// `Нет` + String get no { + return Intl.message( + 'Нет', + name: 'no', + desc: '', + args: [], + ); + } + + /// `Есть ли у вас гипертония?` + String get do_you_have_hypertension_tendency { + return Intl.message( + 'Есть ли у вас гипертония?', + name: 'do_you_have_hypertension_tendency', + desc: '', + args: [], + ); + } + + /// `Ваше артериальное давление?` + String get your_blood_pressure { + return Intl.message( + 'Ваше артериальное давление?', + name: 'your_blood_pressure', + desc: '', + args: [], + ); + } + + /// `Средние показатели давления:` + String get average_pressure { + return Intl.message( + 'Средние показатели давления:', + name: 'average_pressure', + desc: '', + args: [], + ); + } + + /// `Верхние показатели давления:` + String get up_pressure { + return Intl.message( + 'Верхние показатели давления:', + name: 'up_pressure', + desc: '', + args: [], + ); + } + + /// `Нижние показатели давления:` + String get down_pressure { + return Intl.message( + 'Нижние показатели давления:', + name: 'down_pressure', + desc: '', + args: [], + ); + } + + /// `Есть ли у вас гипотония?` + String get do_you_have_hypotension_tendency { + return Intl.message( + 'Есть ли у вас гипотония?', + name: 'do_you_have_hypotension_tendency', + desc: '', + args: [], + ); + } + + /// `Ваши спортивные увлечения?` + String get your_favorite_sports { + return Intl.message( + 'Ваши спортивные увлечения?', + name: 'your_favorite_sports', + desc: '', + args: [], + ); + } + + /// `Любимые продукты` + String get favorite_foods { + return Intl.message( + 'Любимые продукты', + name: 'favorite_foods', + desc: '', + args: [], + ); + } + + /// `Ваши любимые/нелюбимые продукты питания?` + String get favorite_unfavorite_foods { + return Intl.message( + 'Ваши любимые/нелюбимые продукты питания?', + name: 'favorite_unfavorite_foods', + desc: '', + args: [], + ); + } + + /// `Нелюбимые продукты` + String get unfavorite_foods { + return Intl.message( + 'Нелюбимые продукты', + name: 'unfavorite_foods', + desc: '', + args: [], + ); + } + + /// `Ваш режим дня?` + String get your_schedule { + return Intl.message( + 'Ваш режим дня?', + name: 'your_schedule', + desc: '', + args: [], + ); + } + + /// `Расскажите в свободной форме о том как просыпаетесь, когда едите, когда ложитесь спать:` + String get tell_your_schedule { + return Intl.message( + 'Расскажите в свободной форме о том как просыпаетесь, когда едите, когда ложитесь спать:', + name: 'tell_your_schedule', + desc: '', + args: [], + ); + } + + /// `Дополнительная информация` + String get additional_information { + return Intl.message( + 'Дополнительная информация', + name: 'additional_information', + desc: '', + args: [], + ); + } + + /// `Введите любую дополнительную информацию на своё усмотрение:` + String get enter_additional_information { + return Intl.message( + 'Введите любую дополнительную информацию на своё усмотрение:', + name: 'enter_additional_information', + desc: '', + args: [], + ); + } + + /// `English` + String get lbl_english { + return Intl.message( + 'English', + name: 'lbl_english', + desc: '', + args: [], + ); + } + + /// `Завершить` + String get finish { + return Intl.message( + 'Завершить', + name: 'finish', + desc: '', + args: [], + ); + } + + /// `Предпочитаемый язык общения` + String get preferred_language { + return Intl.message( + 'Предпочитаемый язык общения', + name: 'preferred_language', + desc: '', + args: [], + ); + } + + /// `Продолжить` + String get continueButton { + return Intl.message( + 'Продолжить', + name: 'continueButton', + desc: '', + args: [], + ); + } + + /// `Пропустить` + String get skip { + return Intl.message( + 'Пропустить', + name: 'skip', + desc: '', + args: [], + ); + } + + /// `Заполните информацию:` + String get fill_in_information { + return Intl.message( + 'Заполните информацию:', + name: 'fill_in_information', + desc: '', + args: [], + ); + } + + /// `Введите информацию...` + String get enter_information { + return Intl.message( + 'Введите информацию...', + name: 'enter_information', + desc: '', + args: [], + ); + } + + /// `Сетевая ошибка!` + String get msg_network_err { + return Intl.message( + 'Сетевая ошибка!', + name: 'msg_network_err', + desc: '', + args: [], + ); + } + + /// `Что то пошло не так!` + String get msg_something_went_wrong { + return Intl.message( + 'Что то пошло не так!', + name: 'msg_something_went_wrong', + desc: '', + args: [], + ); + } + + /// `Необходимо ввести адрес электронной почты` + String get email_empty { + return Intl.message( + 'Необходимо ввести адрес электронной почты', + name: 'email_empty', + desc: '', + args: [], + ); + } + + /// `Некорректный адрес электронной почты` + String get email_invalid { + return Intl.message( + 'Некорректный адрес электронной почты', + name: 'email_invalid', + desc: '', + args: [], + ); + } + + /// `Пароль обязателен для заполнения` + String get password_empty { + return Intl.message( + 'Пароль обязателен для заполнения', + name: 'password_empty', + desc: '', + args: [], + ); + } + + /// `В пароле должно быть минимум 6 символов` + String get password_short { + return Intl.message( + 'В пароле должно быть минимум 6 символов', + name: 'password_short', + desc: '', + args: [], + ); + } + + /// `Имя пользователя обязательно для заполнения` + String get name_empty { + return Intl.message( + 'Имя пользователя обязательно для заполнения', + name: 'name_empty', + desc: '', + args: [], + ); + } + + /// `В имени пользователя должно быть минимум 6 символов` + String get name_short { + return Intl.message( + 'В имени пользователя должно быть минимум 6 символов', + name: 'name_short', + desc: '', + args: [], + ); + } + + /// `Пароли не совпадают` + String get password_confirmation_mismatch { + return Intl.message( + 'Пароли не совпадают', + name: 'password_confirmation_mismatch', + desc: '', + args: [], + ); + } + + /// `Имя обязательно для заполнения` + String get first_name_empty { + return Intl.message( + 'Имя обязательно для заполнения', + name: 'first_name_empty', + desc: '', + args: [], + ); + } + + /// `В имени должен быть минимум 1 символ` + String get first_name_short { + return Intl.message( + 'В имени должен быть минимум 1 символ', + name: 'first_name_short', + desc: '', + args: [], + ); + } + + /// `Фамилия обязательна для заполнения` + String get last_name_empty { + return Intl.message( + 'Фамилия обязательна для заполнения', + name: 'last_name_empty', + desc: '', + args: [], + ); + } + + /// `В фамилии должен быть минимум 6 символов` + String get last_name_short { + return Intl.message( + 'В фамилии должен быть минимум 6 символов', + name: 'last_name_short', + desc: '', + args: [], + ); + } + + /// `Все замеры обязательны к заполнению` + String get circumference_empty { + return Intl.message( + 'Все замеры обязательны к заполнению', + name: 'circumference_empty', + desc: '', + args: [], + ); + } + + /// `Все замеры должны быть числами` + String get circumference_is_not_a_number { + return Intl.message( + 'Все замеры должны быть числами', + name: 'circumference_is_not_a_number', + desc: '', + args: [], + ); + } + + /// `Все показатели давления обязательны к заполнению` + String get pressure_empty { + return Intl.message( + 'Все показатели давления обязательны к заполнению', + name: 'pressure_empty', + desc: '', + args: [], + ); + } + + /// `Все показатели давления должны быть числами` + String get pressure_is_not_a_number { + return Intl.message( + 'Все показатели давления должны быть числами', + name: 'pressure_is_not_a_number', + desc: '', + args: [], + ); + } + + /// `У меня нет аккаунта` + String get no_account { + return Intl.message( + 'У меня нет аккаунта', + name: 'no_account', + desc: '', + args: [], + ); + } + + /// `Войти` + String get authentificate { + return Intl.message( + 'Войти', + name: 'authentificate', + desc: '', + args: [], + ); + } + + /// `Аутентификация` + String get user_authorization { + return Intl.message( + 'Аутентификация', + name: 'user_authorization', + desc: '', + args: [], + ); + } + + /// `Загрузка...` + String get loading { + return Intl.message( + 'Загрузка...', + name: 'loading', + desc: '', + args: [], + ); + } + + /// `График веса` + String get weight_chart { + return Intl.message( + 'График веса', + name: 'weight_chart', + desc: '', + args: [], + ); + } + + /// `График обхватов` + String get circumferences_chart { + return Intl.message( + 'График обхватов', + name: 'circumferences_chart', + desc: '', + args: [], + ); + } + + /// `Город проживания` + String get city_of_living { + return Intl.message( + 'Город проживания', + name: 'city_of_living', + desc: '', + args: [], + ); + } + + /// `График ИМТ` + String get bodymass_chart { + return Intl.message( + 'График ИМТ', + name: 'bodymass_chart', + desc: '', + args: [], + ); + } + + /// `Грудь` + String get chest { + return Intl.message( + 'Грудь', + name: 'chest', + desc: '', + args: [], + ); + } + + /// `Талия` + String get waist { + return Intl.message( + 'Талия', + name: 'waist', + desc: '', + args: [], + ); + } + + /// `Бедра` + String get hips { + return Intl.message( + 'Бедра', + name: 'hips', + desc: '', + args: [], + ); + } + + /// `Выйти` + String get exit { + return Intl.message( + 'Выйти', + name: 'exit', + desc: '', + args: [], + ); + } + + /// `Активен` + String get active { + return Intl.message( + 'Активен', + name: 'active', + desc: '', + args: [], + ); + } + + /// `В архиве` + String get archived { + return Intl.message( + 'В архиве', + name: 'archived', + desc: '', + args: [], + ); + } + + /// `Черновик` + String get draft { + return Intl.message( + 'Черновик', + name: 'draft', + desc: '', + args: [], + ); + } + + /// `Мой блог` + String get my_blog { + return Intl.message( + 'Мой блог', + name: 'my_blog', + desc: '', + args: [], + ); + } + + /// `Язык` + String get language { + return Intl.message( + 'Язык', + name: 'language', + desc: '', + args: [], + ); + } + + /// `В процессе` + String get in_progress { + return Intl.message( + 'В процессе', + name: 'in_progress', + desc: '', + args: [], + ); + } + + /// `Добавить замер` + String get add_measure { + return Intl.message( + 'Добавить замер', + name: 'add_measure', + desc: '', + args: [], + ); + } + + /// `Вес` + String get weight { + return Intl.message( + 'Вес', + name: 'weight', + desc: '', + args: [], + ); + } + + /// `Пройденные планы` + String get plans_complete { + return Intl.message( + 'Пройденные планы', + name: 'plans_complete', + desc: '', + args: [], + ); + } + + /// `Мои настройки` + String get my_settings { + return Intl.message( + 'Мои настройки', + name: 'my_settings', + desc: '', + args: [], + ); + } + + /// `Настройки` + String get settings { + return Intl.message( + 'Настройки', + name: 'settings', + desc: '', + args: [], + ); + } + + /// `Профиль` + String get profile { + return Intl.message( + 'Профиль', + name: 'profile', + desc: '', + args: [], + ); + } + + /// `Чат` + String get chat { + return Intl.message( + 'Чат', + name: 'chat', + desc: '', + args: [], + ); + } + + /// `Админ` + String get admin { + return Intl.message( + 'Админ', + name: 'admin', + desc: '', + args: [], + ); + } + + /// `Дневник` + String get diary { + return Intl.message( + 'Дневник', + name: 'diary', + desc: '', + args: [], + ); + } + + /// `Сохранить` + String get save { + return Intl.message( + 'Сохранить', + name: 'save', + desc: '', + args: [], + ); + } + + /// `шт` + String get pcs { + return Intl.message( + 'шт', + name: 'pcs', + desc: '', + args: [], + ); + } + + /// `гр` + String get gr { + return Intl.message( + 'гр', + name: 'gr', + desc: '', + args: [], + ); + } + + /// `гр` + String get grams { + return Intl.message( + 'гр', + name: 'grams', + desc: '', + args: [], + ); + } +} + +class AppLocalizationDelegate extends LocalizationsDelegate { + const AppLocalizationDelegate(); + + List get supportedLocales { + return const [ + Locale.fromSubtags(languageCode: 'en'), + ]; + } + + @override + bool isSupported(Locale locale) => _isSupported(locale); + @override + Future load(Locale locale) => S.load(locale); + @override + bool shouldReload(AppLocalizationDelegate old) => false; + + bool _isSupported(Locale locale) { + for (var supportedLocale in supportedLocales) { + if (supportedLocale.languageCode == locale.languageCode) { + return true; + } + } + return false; + } +} diff --git a/lib/localization/ru/ru_translations.dart b/lib/l10n/intl_en.arb similarity index 80% rename from lib/localization/ru/ru_translations.dart rename to lib/l10n/intl_en.arb index aff8f268..8d2d512c 100644 --- a/lib/localization/ru/ru_translations.dart +++ b/lib/l10n/intl_en.arb @@ -1,44 +1,32 @@ -final Map ru = { - //credentials Screen +{ "user_registration": "Регистрация пользователя", "email": "Элетронная почта", "username": "Имя пользователя", "password": "Пароль", "password_confirmation": "Подтвердите пароль", - 'wrong_credentials': "Неверные данные пользователя", - - //name Screen + "wrong_credentials": "Неверные данные пользователя", "first_name": "Имя", "last_name": "Фамилия", "what_is_your_name": "Как вас зовут?", - - // date_of_birth Screen "date_of_birth": "Дата рождения", - // city_of_living Screen - "country": "Страна", "Russia": "Россия", "city": "Город", "Moscow": "Москва", + "country": "Страна", + "Russia": "Россия", + "city": "Город", + "Moscow": "Москва", "place_of_living": "Место проживания", - - // body_circumferences Screen - "hip_circumference": "Обхват бедер", "chest_circumference": "Обхват груди", + "hip_circumference": "Обхват бедер", + "chest_circumference": "Обхват груди", "waist_circumference": "Обхват талии", "initial_measurements": "Первичные замеры", - "male": "Мужской", "female": "Женский", - // weight Screen - "weight_measurements": "Замер веса", "your_weight": "Ваш вес:", - "height_measurements": "Замер роста", "your_height": "Ваш рост:", - - // allergies Screen + "weight_measurements": "Замер веса", + "your_weight": "Ваш вес:", + "height_measurements": "Замер роста", + "your_height": "Ваш рост:", "allergies_presence": "Наличие аллергии", - - // medicine_intake Screen "do_you_take_pills": "Принимаете ли вы лекарства или бады?", - - // gender Screen "your_gender": "Ваш пол?", - - // blood_pressure Screen "no": "Нет", "do_you_have_hypertension_tendency": "Есть ли у вас гипертония?", "your_blood_pressure": "Ваше артериальное давление?", @@ -46,39 +34,23 @@ final Map ru = { "up_pressure": "Верхние показатели давления:", "down_pressure": "Нижние показатели давления:", "do_you_have_hypotension_tendency": "Есть ли у вас гипотония?", - - // favorite_sports Screen "your_favorite_sports": "Ваши спортивные увлечения?", - - // favorite_foods Screen "favorite_foods": "Любимые продукты", "favorite_unfavorite_foods": "Ваши любимые/нелюбимые продукты питания?", "unfavorite_foods": "Нелюбимые продукты", - - // schedule Screen "your_schedule": "Ваш режим дня?", "tell_your_schedule": "Расскажите в свободной форме о том как просыпаетесь, когда едите, когда ложитесь спать:", - - // additional_information Screen "additional_information": "Дополнительная информация", "enter_additional_information": "Введите любую дополнительную информацию на своё усмотрение:", - - // language_select Screen "lbl_english": "English", "finish": "Завершить", "preferred_language": "Предпочитаемый язык общения", - - // Common String - "continue": "Продолжить", "skip": "Пропустить", + "continueButton": "Продолжить", + "skip": "Пропустить", "fill_in_information": "Заполните информацию:", "enter_information": "Введите информацию...", - - // Network Error String "msg_network_err": "Сетевая ошибка!", "msg_something_went_wrong": "Что то пошло не так!", - - // Errors - // Credentials "email_empty": "Необходимо ввести адрес электронной почты", "email_invalid": "Некорректный адрес электронной почты", "password_empty": "Пароль обязателен для заполнения", @@ -86,27 +58,17 @@ final Map ru = { "name_empty": "Имя пользователя обязательно для заполнения", "name_short": "В имени пользователя должно быть минимум 6 символов", "password_confirmation_mismatch": "Пароли не совпадают", - - // Name "first_name_empty": "Имя обязательно для заполнения", "first_name_short": "В имени должен быть минимум 1 символ", "last_name_empty": "Фамилия обязательна для заполнения", "last_name_short": "В фамилии должен быть минимум 6 символов", - - // Body Circumference "circumference_empty": "Все замеры обязательны к заполнению", "circumference_is_not_a_number": "Все замеры должны быть числами", - - // Body Circumference "pressure_empty": "Все показатели давления обязательны к заполнению", "pressure_is_not_a_number": "Все показатели давления должны быть числами", - - // Authorization "no_account": "У меня нет аккаунта", "authentificate": "Войти", "user_authorization": "Аутентификация", - - // Личный кабинет Screen "loading": "Загрузка...", "weight_chart": "График веса", "circumferences_chart": "График обхватов", @@ -120,12 +82,13 @@ final Map ru = { "archived": "В архиве", "draft": "Черновик", "my_blog": "Мой блог", - "language": "Язык:", + "language": "Язык", "in_progress": "В процессе", "add_measure": "Добавить замер", "weight": "Вес", "plans_complete": "Пройденные планы", "my_settings": "Мои настройки", + "settings": "Настройки", "profile": "Профиль", "chat": "Чат", "admin": "Админ", @@ -133,5 +96,5 @@ final Map ru = { "save": "Сохранить", "pcs": "шт", "gr": "гр", - "grams": "гр", -}; + "grams": "гр" +} \ No newline at end of file diff --git a/lib/localization/app_localization.dart b/lib/localization/app_localization.dart deleted file mode 100644 index b477c9a4..00000000 --- a/lib/localization/app_localization.dart +++ /dev/null @@ -1,60 +0,0 @@ -import 'package:eatvio_app/app_router.dart'; -import 'package:flutter/cupertino.dart'; -//import 'en_us/en_us_translations.dart'; -import 'package:flutter/foundation.dart'; - -import 'ru/ru_translations.dart'; - -class AppLocalization { - AppLocalization(this.locale); - - Locale locale; - - static final Map> _localizedValues = { - 'ru': ru, - }; - - /*static final Map> __localizedValues = { - 'en': enUs - };*/ - - static AppLocalization of() { - final context = AppRouter.navigatorKey.currentContext; - if (context != null) { - return Localizations.of(context, AppLocalization)!; - } else { - // Обработка ситуации, когда context равен null - return AppLocalization( - Locale( - 'ru', - '', - ), - ); // Возвращаем дефолтное значение или обработку ошибки - } - } - - static List languages() => _localizedValues.keys.toList(); - - String getString(String text) => _localizedValues[locale.languageCode]![text] ?? text; -} - -class AppLocalizationDelegate extends LocalizationsDelegate { - const AppLocalizationDelegate(); - - @override - bool isSupported(Locale locale) => AppLocalization.languages().contains(locale.languageCode); - - //Returning a SynchronousFuture here because an async "load" operation - //cause an async "load" operation - @override - Future load(Locale locale) { - return SynchronousFuture(AppLocalization(locale)); - } - - @override - bool shouldReload(AppLocalizationDelegate old) => false; -} - -extension LocalizationExtension on String { - String get tr => AppLocalization.of().getString(this); -} diff --git a/lib/localization/en_us/en_us_translations.dart b/lib/localization/en_us/en_us_translations.dart deleted file mode 100644 index c68f1315..00000000 --- a/lib/localization/en_us/en_us_translations.dart +++ /dev/null @@ -1,63 +0,0 @@ -final Map enUs = { - // date_of_birth Screen - "date_of_birth": "Date of Birth", - - // city_of_living Screen - "country": "Country", "Russia": "Russia", "city": "City", "Moscow": "Moscow", - "place_of_living": "Place of Living", - - // body_circumferences Screen - "hip_circumference": "Hip circumference", - "chest_circumference": "Chest circumference", - "waist_circumference": "Waist circumference", - "initial_measurements": "Initial measurements", - - // weight Screen - "weight_measurements": "Weight measurements", "your_weight": "Your weight:", - "height_measurements": "Height measurements", "your_height": "Your height:", - - // allergies Screen - "allergies_presence": "Allergies presence", - - // medicine_intake Screen - "do_you_take_pills": "Do you take pills or supplements?", - - // gender Screen - "your_gender": "Your Gender?", - - // blood_pressure Screen - "no": "No", - "do_you_have_hypertension_tendency": "Do you have a tendency for hypertension?", - "your_blood_pressure": "Your blood pressure?", - "average_pressure": "Average pressure:", - "do_you_have_hypotension_tendency": "Do you have a tendency for hypotension?", - - // favorite_sports Screen - "your_favorite_sports": "Your Favorite Sports?", - - // favorite_foods Screen - "favorite_foods": "Favorite Foods:", - "favorite_unfavorite_foods": "Your most ot reast favorite foods?", - "unfavorite_foods": "Unfavorite Foods:", - - // schedule Screen - "your_schedule": "Your Daily Schedule?", - "tell_your_schedule": "Tell us about your daily routine, when you wake up, eat, and go to sleep:", - - // additional_information Screen - "additional_information": "Additional Information:", - "enter_additional_information": "Enter any additional information you would like to share:", - - // language_select Screen - "lbl_english": "English", - "preferred_language": "Preferred Language", - - // Common String - "continue": "Continue", "skip": "Skip", - "fill_in_information": "Fill in Information:", - "enter_information": "Enter Information...", - -// Network Error String - "msg_network_err": "Network Error!", - "msg_something_went_wrong": "Something went wrong!", -}; diff --git a/lib/locator_service.dart b/lib/locator_service.dart index a73d21f1..e51ccc7c 100644 --- a/lib/locator_service.dart +++ b/lib/locator_service.dart @@ -1,5 +1,5 @@ import 'package:dio/dio.dart'; -import 'package:eatvio_app/core/constants/constants.dart'; +import 'package:eatvio_app/core/const.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'; @@ -20,6 +20,9 @@ import 'package:eatvio_app/features/feed/presentation/bloc/feed_cubit/feed_cubit import 'package:eatvio_app/features/feed/presentation/bloc/recipes_cubit/recipes_cubit.dart'; import 'package:eatvio_app/features/feed/repositories/feed_repository.dart'; import 'package:eatvio_app/features/feed/services/feed_service.dart'; +import 'package:eatvio_app/features/plans/presentation/bloc/plans_cubit/plans_cubit.dart'; +import 'package:eatvio_app/features/plans/repositories/plans_repository.dart'; +import 'package:eatvio_app/features/plans/services/plans_service.dart'; import 'package:eatvio_app/features/profile/presentation/bloc/profile_cubit/profile_cubit.dart'; import 'package:eatvio_app/features/profile/repositories/profile_repository.dart'; import 'package:eatvio_app/features/profile/services/profile_service.dart'; @@ -29,20 +32,24 @@ import 'package:eatvio_app/features/recipes/services/recipe_service.dart'; import 'package:eatvio_app/features/registration/presentation/bloc/registration_cubit/registration_cubit.dart'; import 'package:eatvio_app/features/registration/repositories/registration_repository.dart'; import 'package:eatvio_app/features/registration/services/registration_service.dart'; +import 'package:eatvio_app/features/settings/presentation/bloc/settings_cubit/settings_cubit.dart'; +import 'package:eatvio_app/features/settings/repositories/service_repository.dart'; +import 'package:eatvio_app/features/settings/services/settings_service.dart'; import 'package:get_it/get_it.dart'; final sl = GetIt.instance; Future init() async { - // BLoC / Cubit + // Cubit singletons sl.registerLazySingleton(() => InitializationCubit(chatRepository: sl())); sl.registerLazySingleton(() => NewMessagesCubit()); sl.registerLazySingleton(() => NotificationsCubit()); + // Cubit factories sl.registerFactory(() => RegistrationCubit(registrationRepository: sl())); sl.registerFactory(() => ChatRoomCubit(chatRepository: sl(), initializationCubit: sl())); sl.registerFactory(() => FeedCubit(feedRepository: sl())); - sl.registerFactory(() => RecipesCubit(feedRepository: sl())); + sl.registerFactory(() => RecipesCubit(feedRepository: sl(), recipeRepository: sl())); sl.registerFactory(() => DiaryBloc(diaryRepository: sl())); sl.registerFactory(() => CalendarCubit(calendarRepository: sl())); sl.registerFactory(() => ProfileCubit(profileRepository: sl())); @@ -51,6 +58,8 @@ Future init() async { sl.registerFactory(() => DietsCubit(feedRepository: sl())); sl.registerFactory(() => CommentsCubit(feedRepository: sl())); sl.registerFactory(() => ChatSelectCubit(chatRepository: sl())); + sl.registerFactory(() => PlansCubit(plansRepository: sl())); + sl.registerFactory(() => SettingsCubit(profileRepository: sl(), settingsRepository: sl())); // Repository sl.registerLazySingleton(() => ChatRepository(chatService: sl())); @@ -60,6 +69,8 @@ Future init() async { sl.registerLazySingleton(() => CalendarRepository(calendarService: sl())); sl.registerLazySingleton(() => ProfileRepository(profileService: sl())); sl.registerLazySingleton(() => RecipeRepository(recipeService: sl())); + sl.registerLazySingleton(() => PlansRepository(plansService: sl())); + sl.registerLazySingleton(() => SettingsRepository(settingsService: sl())); // Services sl.registerLazySingleton(() => ChatService(sl())); @@ -69,6 +80,8 @@ Future init() async { sl.registerLazySingleton(() => CalendarService(sl())); sl.registerLazySingleton(() => ProfileService(sl())); sl.registerLazySingleton(() => RecipeService(sl())); + sl.registerLazySingleton(() => PlansService(sl())); + sl.registerLazySingleton(() => SettingsService(sl())); // External sl.registerLazySingleton( diff --git a/lib/main.dart b/lib/main.dart index a0867795..ce09857f 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,38 +1,20 @@ import 'package:eatvio_app/app_router.dart'; 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'; -import 'package:eatvio_app/features/feed/presentation/bloc/diets_cubit/diets_cubit.dart'; -import 'package:eatvio_app/features/feed/presentation/bloc/feed_cubit/feed_cubit.dart'; -import 'package:eatvio_app/features/feed/presentation/bloc/recipes_cubit/recipes_cubit.dart'; -import 'package:eatvio_app/features/recipes/presentation/bloc/recipe_create_cubit.dart'; +import 'package:eatvio_app/generated/l10n.dart'; import 'package:eatvio_app/locator_service.dart' as di; import 'package:eatvio_app/locator_service.dart'; -import 'package:eatvio_app/presentation/profile/my_profile_screen/bloc/my_profile_bloc.dart'; -import 'package:eatvio_app/presentation/profile/my_profile_screen/models/my_profile_model.dart'; +import 'package:eatvio_app/theme/theme_helper.dart'; import 'package:flutter/material.dart'; -import 'package:flutter/services.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_localizations/flutter_localizations.dart'; -import 'package:intl/date_symbol_data_local.dart'; import 'package:keyboard_dismisser/keyboard_dismisser.dart'; -import 'core/app_export.dart'; -var globalMessengerKey = GlobalKey(); - -void main() async { +Future main() async { WidgetsFlutterBinding.ensureInitialized(); await di.init(); - SystemChrome.setPreferredOrientations([ - DeviceOrientation.landscapeLeft, - DeviceOrientation.landscapeRight, - DeviceOrientation.portraitUp, - ]); - initializeDateFormatting().then((_) => runApp(MyApp())); + runApp(MyApp()); } class MyApp extends StatelessWidget { @@ -43,39 +25,19 @@ class MyApp extends StatelessWidget { BlocProvider(create: (context) => sl()), BlocProvider(create: (context) => sl()), BlocProvider(create: (context) => sl()), - BlocProvider(create: (context) => sl()..getMyProfile()), - BlocProvider(create: (context) => sl()..loadFeedBlogPostList()), - BlocProvider(create: (context) => sl()..loadRecipesList()), - BlocProvider(create: (context) => sl()..loadDiets()), - BlocProvider(create: (context) => MyProfileBloc(MyProfileState(myProfileModelObj: MyProfileModel()))..add(MyProfileInitialEvent())), - BlocProvider(create: (context) => sl()..add(LoadDiary())), - BlocProvider(create: (context) => sl()..getChatRooms()), - BlocProvider(create: (context) => sl()..loadCalendarList()), - BlocProvider(create: (context) => sl()..loadRecipeCreate()), ], - child: BlocListener( - listener: (BuildContext context, InitializationState state) {}, - child: KeyboardDismisser( - gestures: [ - GestureType.onTap, - GestureType.onPanUpdateDownDirection, + child: KeyboardDismisser( + child: MaterialApp.router( + theme: ThemeHelper().themeData(), + routerConfig: AppRouter.appRouter, + debugShowCheckedModeBanner: false, + localizationsDelegates: const [ + S.delegate, + GlobalMaterialLocalizations.delegate, + GlobalWidgetsLocalizations.delegate, + GlobalCupertinoLocalizations.delegate, ], - child: MaterialApp.router( - theme: theme, - routerConfig: AppRouter.appRouter, - debugShowCheckedModeBanner: false, - localizationsDelegates: [ - AppLocalizationDelegate(), - GlobalMaterialLocalizations.delegate, - GlobalWidgetsLocalizations.delegate, - GlobalCupertinoLocalizations.delegate, - ], - supportedLocales: [ - Locale( - 'ru', - ), - ], - ), + supportedLocales: S.delegate.supportedLocales, ), ), ); diff --git a/lib/presentation/auth/auth_screen/auth_screen.dart b/lib/old/auth/auth_screen/auth_screen.dart similarity index 90% rename from lib/presentation/auth/auth_screen/auth_screen.dart rename to lib/old/auth/auth_screen/auth_screen.dart index 502eff15..fc8cb13f 100644 --- a/lib/presentation/auth/auth_screen/auth_screen.dart +++ b/lib/old/auth/auth_screen/auth_screen.dart @@ -1,10 +1,14 @@ import 'dart:convert'; -import 'package:eatvio_app/core/app_export.dart'; +import 'package:eatvio_app/core/const.dart'; import 'package:eatvio_app/core/token_storage.dart'; +import 'package:eatvio_app/core/utils/image_constant.dart'; +import 'package:eatvio_app/generated/l10n.dart'; +import 'package:eatvio_app/theme/theme_helper.dart'; 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:flutter_bloc/flutter_bloc.dart'; import 'package:go_router/go_router.dart'; import 'package:http/http.dart' as http; import 'package:url_launcher/url_launcher.dart'; @@ -36,6 +40,7 @@ class _AuthScreenState extends State { @override Widget build(BuildContext context) { + final s = S.of(context); return Scaffold( appBar: AppBar( centerTitle: true, @@ -47,7 +52,7 @@ class _AuthScreenState extends State { child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Text("email".tr), + Text(s.email), SizedBox(height: 4), BlocSelector( selector: (state) => state.emailController, @@ -62,7 +67,7 @@ class _AuthScreenState extends State { }, ), SizedBox(height: 16), - Text("password".tr), + Text(s.password), SizedBox(height: 4), BlocSelector( selector: (state) => state.passwordController, @@ -130,13 +135,13 @@ class _AuthScreenState extends State { elevation: 0, focusElevation: 0, shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(16), + borderRadius: BorderRadius.circular(20), ), backgroundColor: appTheme.blueA400, onPressed: onTapAuth(state, context), label: Text( 'Войти', - style: theme.textTheme.titleSmall, + style: theme.textTheme.titleSmall!.copyWith(color: Colors.white), ), ), ); @@ -150,6 +155,7 @@ class _AuthScreenState extends State { } onTapAuth(AuthState state, BuildContext context) { + final s = S.of(context); return () async { List errors = validateFields(state.emailController!.text, state.passwordController!.text); if (errors.isEmpty) { @@ -174,7 +180,7 @@ class _AuthScreenState extends State { context: context, builder: (context) => AlertDialog( title: Text('Ошибка'), - content: Text('wrong_credentials'.tr), + content: Text(s.wrong_credentials), actions: [ TextButton( onPressed: () => Navigator.pop(context), @@ -209,22 +215,24 @@ class _AuthScreenState extends State { } List validateFields(String email, String password) { + final s = S.of(context); + List errors = []; if (!isEmail(email)) { - errors.add('email_invalid'.tr); + errors.add(s.email_invalid); } if (email.isEmpty) { - errors.add('email_empty'.tr); + errors.add(s.email_empty); } if (password.isEmpty) { - errors.add('password_empty'.tr); + errors.add(s.password_empty); } if (password.length < 6) { - errors.add('password_short'.tr); + errors.add(s.password_short); } return errors; diff --git a/lib/presentation/auth/auth_screen/bloc/auth_bloc.dart b/lib/old/auth/auth_screen/bloc/auth_bloc.dart similarity index 83% rename from lib/presentation/auth/auth_screen/bloc/auth_bloc.dart rename to lib/old/auth/auth_screen/bloc/auth_bloc.dart index 0d8f67ad..f75da299 100644 --- a/lib/presentation/auth/auth_screen/bloc/auth_bloc.dart +++ b/lib/old/auth/auth_screen/bloc/auth_bloc.dart @@ -1,8 +1,7 @@ -import 'package:eatvio_app/presentation/auth/auth_screen/models/auth_model.dart'; +import 'package:eatvio_app/old/auth/auth_screen/models/auth_model.dart'; import 'package:equatable/equatable.dart'; import 'package:flutter/material.dart'; - -import '/core/app_export.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; part 'auth_event.dart'; part 'auth_state.dart'; diff --git a/lib/presentation/auth/auth_screen/bloc/auth_event.dart b/lib/old/auth/auth_screen/bloc/auth_event.dart similarity index 100% rename from lib/presentation/auth/auth_screen/bloc/auth_event.dart rename to lib/old/auth/auth_screen/bloc/auth_event.dart diff --git a/lib/presentation/auth/auth_screen/bloc/auth_state.dart b/lib/old/auth/auth_screen/bloc/auth_state.dart similarity index 100% rename from lib/presentation/auth/auth_screen/bloc/auth_state.dart rename to lib/old/auth/auth_screen/bloc/auth_state.dart diff --git a/lib/presentation/auth/auth_screen/models/auth_model.dart b/lib/old/auth/auth_screen/models/auth_model.dart similarity index 100% rename from lib/presentation/auth/auth_screen/models/auth_model.dart rename to lib/old/auth/auth_screen/models/auth_model.dart diff --git a/lib/presentation/diary/diary_edit_screen/bloc/diary_edit_state.dart b/lib/old/diary/diary_edit_screen/bloc/diary_edit_state.dart similarity index 100% rename from lib/presentation/diary/diary_edit_screen/bloc/diary_edit_state.dart rename to lib/old/diary/diary_edit_screen/bloc/diary_edit_state.dart diff --git a/lib/presentation/diary/diary_edit_screen/diary_edit_screen.dart b/lib/old/diary/diary_edit_screen/diary_edit_screen.dart similarity index 99% rename from lib/presentation/diary/diary_edit_screen/diary_edit_screen.dart rename to lib/old/diary/diary_edit_screen/diary_edit_screen.dart index 5237efb6..57e167d7 100644 --- a/lib/presentation/diary/diary_edit_screen/diary_edit_screen.dart +++ b/lib/old/diary/diary_edit_screen/diary_edit_screen.dart @@ -8,7 +8,7 @@ import 'package:flutter_form_builder/flutter_form_builder.dart'; import 'package:fl_chart/fl_chart.dart'; import 'package:image_picker/image_picker.dart'; import 'package:flutter_dotenv/flutter_dotenv.dart'; -import 'package:eatvio_app/core/app_export.dart'; + import 'package:eatvio_app/widgets/custom_edit_text_form_field.dart'; import 'package:eatvio_app/widgets/custom_edit_drop_down.dart'; import 'package:eatvio_app/widgets/custom_outlined_button.dart'; diff --git a/lib/presentation/diary/diary_edit_screen/models/diary_edit_model.dart b/lib/old/diary/diary_edit_screen/models/diary_edit_model.dart similarity index 100% rename from lib/presentation/diary/diary_edit_screen/models/diary_edit_model.dart rename to lib/old/diary/diary_edit_screen/models/diary_edit_model.dart diff --git a/lib/presentation/diets/diet_create_screen/bloc/diet_create_bloc.dart b/lib/old/diets/diet_create_screen/bloc/diet_create_bloc.dart similarity index 99% rename from lib/presentation/diets/diet_create_screen/bloc/diet_create_bloc.dart rename to lib/old/diets/diet_create_screen/bloc/diet_create_bloc.dart index db2f02a9..3491e60f 100644 --- a/lib/presentation/diets/diet_create_screen/bloc/diet_create_bloc.dart +++ b/lib/old/diets/diet_create_screen/bloc/diet_create_bloc.dart @@ -2,15 +2,15 @@ import 'dart:async'; import 'dart:convert'; import 'package:eatvio_app/app_router.dart'; +import 'package:eatvio_app/core/const.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:eatvio_app/old/diets/diet_create_screen/models/diet_create_model.dart'; import 'package:equatable/equatable.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:go_router/go_router.dart'; import 'package:http/http.dart' as http; -import '/core/app_export.dart'; - part 'diet_create_event.dart'; part 'diet_create_state.dart'; diff --git a/lib/presentation/diets/diet_create_screen/bloc/diet_create_event.dart b/lib/old/diets/diet_create_screen/bloc/diet_create_event.dart similarity index 100% rename from lib/presentation/diets/diet_create_screen/bloc/diet_create_event.dart rename to lib/old/diets/diet_create_screen/bloc/diet_create_event.dart diff --git a/lib/presentation/diets/diet_create_screen/bloc/diet_create_state.dart b/lib/old/diets/diet_create_screen/bloc/diet_create_state.dart similarity index 100% rename from lib/presentation/diets/diet_create_screen/bloc/diet_create_state.dart rename to lib/old/diets/diet_create_screen/bloc/diet_create_state.dart diff --git a/lib/presentation/diets/diet_create_screen/diet_create_screen.dart b/lib/old/diets/diet_create_screen/diet_create_screen.dart similarity index 92% rename from lib/presentation/diets/diet_create_screen/diet_create_screen.dart rename to lib/old/diets/diet_create_screen/diet_create_screen.dart index 2ade3f80..bad75b05 100644 --- a/lib/presentation/diets/diet_create_screen/diet_create_screen.dart +++ b/lib/old/diets/diet_create_screen/diet_create_screen.dart @@ -1,5 +1,6 @@ -import 'package:eatvio_app/core/app_export.dart'; +import 'package:eatvio_app/theme/app_decoration.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; import 'bloc/diet_create_bloc.dart'; import 'models/diet_create_model.dart'; @@ -38,7 +39,6 @@ class DietCreateScreen extends StatelessWidget { } _buildDietCreate(BuildContext context, DietCreateLoadedState state) { - mediaQueryData = MediaQuery.of(context); return SafeArea( child: Scaffold( resizeToAvoidBottomInset: false, @@ -47,14 +47,14 @@ class DietCreateScreen extends StatelessWidget { decoration: AppDecoration.fillGray, child: ListView( children: [ - SizedBox(height: 30.v), + SizedBox(height: 30), Container( margin: EdgeInsets.only( - left: 16.h, - right: 20.h, - bottom: 10.h, + left: 16, + right: 20, + bottom: 10, ), - padding: EdgeInsets.all(12.h), + padding: EdgeInsets.all(12), decoration: BoxDecoration( color: Colors.white, borderRadius: const BorderRadius.all(Radius.circular(12)), diff --git a/lib/presentation/diets/diet_create_screen/models/diet_create_model.dart b/lib/old/diets/diet_create_screen/models/diet_create_model.dart similarity index 100% rename from lib/presentation/diets/diet_create_screen/models/diet_create_model.dart rename to lib/old/diets/diet_create_screen/models/diet_create_model.dart diff --git a/lib/presentation/diets/diet_edit_screen/bloc/diet_edit_bloc.dart b/lib/old/diets/diet_edit_screen/bloc/diet_edit_bloc.dart similarity index 95% rename from lib/presentation/diets/diet_edit_screen/bloc/diet_edit_bloc.dart rename to lib/old/diets/diet_edit_screen/bloc/diet_edit_bloc.dart index 5f92e25b..1fd4610a 100644 --- a/lib/presentation/diets/diet_edit_screen/bloc/diet_edit_bloc.dart +++ b/lib/old/diets/diet_edit_screen/bloc/diet_edit_bloc.dart @@ -2,15 +2,15 @@ import 'dart:async'; import 'dart:convert'; import 'package:eatvio_app/app_router.dart'; +import 'package:eatvio_app/core/const.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:eatvio_app/old/diets/diet_edit_screen/models/diet_edit_model.dart'; import 'package:equatable/equatable.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:go_router/go_router.dart'; import 'package:http/http.dart' as http; -import '/core/app_export.dart'; - part 'diet_edit_event.dart'; part 'diet_edit_state.dart'; diff --git a/lib/presentation/diets/diet_edit_screen/bloc/diet_edit_event.dart b/lib/old/diets/diet_edit_screen/bloc/diet_edit_event.dart similarity index 100% rename from lib/presentation/diets/diet_edit_screen/bloc/diet_edit_event.dart rename to lib/old/diets/diet_edit_screen/bloc/diet_edit_event.dart diff --git a/lib/presentation/diets/diet_edit_screen/bloc/diet_edit_state.dart b/lib/old/diets/diet_edit_screen/bloc/diet_edit_state.dart similarity index 100% rename from lib/presentation/diets/diet_edit_screen/bloc/diet_edit_state.dart rename to lib/old/diets/diet_edit_screen/bloc/diet_edit_state.dart diff --git a/lib/presentation/diets/diet_edit_screen/diet_edit_screen.dart b/lib/old/diets/diet_edit_screen/diet_edit_screen.dart similarity index 86% rename from lib/presentation/diets/diet_edit_screen/diet_edit_screen.dart rename to lib/old/diets/diet_edit_screen/diet_edit_screen.dart index d76d79d7..57b857b0 100644 --- a/lib/presentation/diets/diet_edit_screen/diet_edit_screen.dart +++ b/lib/old/diets/diet_edit_screen/diet_edit_screen.dart @@ -1,6 +1,9 @@ import 'package:cached_network_image/cached_network_image.dart'; -import 'package:eatvio_app/core/app_export.dart'; +import 'package:eatvio_app/core/const.dart'; +import 'package:eatvio_app/theme/app_decoration.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:rive/rive.dart'; import 'bloc/diet_edit_bloc.dart'; import 'models/diet_edit_model.dart'; @@ -39,7 +42,6 @@ class DietEditScreen extends StatelessWidget { } _buildDietEdit(BuildContext context, DietEditLoadedState state) { - mediaQueryData = MediaQuery.of(context); return SafeArea( child: Scaffold( resizeToAvoidBottomInset: false, @@ -48,14 +50,14 @@ class DietEditScreen extends StatelessWidget { decoration: AppDecoration.fillGray, child: ListView( children: [ - SizedBox(height: 30.v), + SizedBox(height: 30), Container( margin: EdgeInsets.only( - left: 16.h, - right: 20.h, - bottom: 10.h, + left: 16, + right: 20, + bottom: 10, ), - padding: EdgeInsets.all(12.h), + padding: EdgeInsets.all(12), decoration: BoxDecoration( color: Colors.white, borderRadius: const BorderRadius.all(Radius.circular(12)), @@ -77,7 +79,13 @@ class DietEditScreen extends StatelessWidget { backgroundImage: imageProvider, radius: 25, ), - placeholder: (context, url) => CircularProgressIndicator(), + placeholder: (context, url) => SizedBox( + height: 32, + width: 32, + child: RiveAnimation.asset( + 'assets/rive_animations/loading.riv', + ), + ), errorWidget: (context, url, error) => CircleAvatar( child: Icon(Icons.person), backgroundColor: Colors.white, diff --git a/lib/presentation/diets/diet_edit_screen/models/diet_edit_model.dart b/lib/old/diets/diet_edit_screen/models/diet_edit_model.dart similarity index 100% rename from lib/presentation/diets/diet_edit_screen/models/diet_edit_model.dart rename to lib/old/diets/diet_edit_screen/models/diet_edit_model.dart diff --git a/lib/presentation/diets/diet_select_screen/bloc/diet_select_bloc.dart b/lib/old/diets/diet_select_screen/bloc/diet_select_bloc.dart similarity index 91% rename from lib/presentation/diets/diet_select_screen/bloc/diet_select_bloc.dart rename to lib/old/diets/diet_select_screen/bloc/diet_select_bloc.dart index 6910f250..69bd3d7b 100644 --- a/lib/presentation/diets/diet_select_screen/bloc/diet_select_bloc.dart +++ b/lib/old/diets/diet_select_screen/bloc/diet_select_bloc.dart @@ -1,18 +1,18 @@ -//import 'package:eatvio_app/presentation/auth/auth_screen/auth_screen.dart'; +//import 'package:eatvio_app/old/auth/auth_screen/auth_screen.dart'; import 'dart:async'; import 'dart:convert'; import 'package:eatvio_app/app_router.dart'; +import 'package:eatvio_app/core/const.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:eatvio_app/old/diets/diet_select_screen/models/diet_select_model.dart'; import 'package:equatable/equatable.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:go_router/go_router.dart'; import 'package:http/http.dart' as http; import 'package:image_picker/image_picker.dart'; -import '/core/app_export.dart'; - part 'diet_select_event.dart'; part 'diet_select_state.dart'; diff --git a/lib/presentation/diets/diet_select_screen/bloc/diet_select_event.dart b/lib/old/diets/diet_select_screen/bloc/diet_select_event.dart similarity index 100% rename from lib/presentation/diets/diet_select_screen/bloc/diet_select_event.dart rename to lib/old/diets/diet_select_screen/bloc/diet_select_event.dart diff --git a/lib/presentation/diets/diet_select_screen/bloc/diet_select_state.dart b/lib/old/diets/diet_select_screen/bloc/diet_select_state.dart similarity index 100% rename from lib/presentation/diets/diet_select_screen/bloc/diet_select_state.dart rename to lib/old/diets/diet_select_screen/bloc/diet_select_state.dart diff --git a/lib/presentation/diets/diet_select_screen/diet_select_screen.dart b/lib/old/diets/diet_select_screen/diet_select_screen.dart similarity index 82% rename from lib/presentation/diets/diet_select_screen/diet_select_screen.dart rename to lib/old/diets/diet_select_screen/diet_select_screen.dart index 3f4a8ce8..b4e517c2 100644 --- a/lib/presentation/diets/diet_select_screen/diet_select_screen.dart +++ b/lib/old/diets/diet_select_screen/diet_select_screen.dart @@ -1,10 +1,14 @@ import 'package:cached_network_image/cached_network_image.dart'; -import 'package:eatvio_app/core/app_export.dart'; +import 'package:eatvio_app/core/const.dart'; +import 'package:eatvio_app/core/utils/image_constant.dart'; +import 'package:eatvio_app/theme/custom_text_style.dart'; import 'package:eatvio_app/widgets/app_bar/appbar_leading_image.dart'; import 'package:eatvio_app/widgets/app_bar/appbar_subtitle.dart'; import 'package:eatvio_app/widgets/app_bar/custom_app_bar.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:go_router/go_router.dart'; +import 'package:rive/rive.dart'; import 'bloc/diet_select_bloc.dart'; import 'models/diet_select_model.dart'; @@ -24,7 +28,13 @@ class DietSelectScreen extends StatelessWidget { // Это начальное состояние, данные ещё не загружены. return Scaffold( body: Center( - child: CircularProgressIndicator(), + child: SizedBox( + height: 32, + width: 32, + child: RiveAnimation.asset( + 'assets/rive_animations/loading.riv', + ), + ), ), ); } else if (state is DietSelectLoadedState) { @@ -34,7 +44,13 @@ class DietSelectScreen extends StatelessWidget { // Другие состояния, если они есть. return Scaffold( body: Center( - child: CircularProgressIndicator(), + child: SizedBox( + height: 32, + width: 32, + child: RiveAnimation.asset( + 'assets/rive_animations/loading.riv', + ), + ), ), ); } @@ -74,20 +90,20 @@ class DietSelectScreen extends StatelessWidget { ], ), child: CustomAppBar( - height: 54.v, - leadingWidth: 28.h, + height: 54, + leadingWidth: 28, leading: AppbarLeadingImage( imagePath: ImageConstant.imgArrowLeft, - margin: EdgeInsets.only(left: 16.h, top: 15.v, bottom: 15.v), + margin: EdgeInsets.only(left: 16, top: 15, bottom: 15), onTap: () => GoRouter.of(context).pop(), ), title: Padding( - padding: EdgeInsets.only(left: 20.h), + padding: EdgeInsets.only(left: 20), child: Row( children: [ AppbarSubtitle( text: "Диеты", - margin: EdgeInsets.only(left: 80.h, top: 12.v, bottom: 9.v), + margin: EdgeInsets.only(left: 80, top: 12, bottom: 9), ), Spacer(), Padding( @@ -139,7 +155,13 @@ class DietSelectScreen extends StatelessWidget { backgroundImage: imageProvider, radius: 25, ), - placeholder: (context, url) => CircularProgressIndicator(), + placeholder: (context, url) => SizedBox( + height: 32, + width: 32, + child: RiveAnimation.asset( + 'assets/rive_animations/loading.riv', + ), + ), errorWidget: (context, url, error) => CircleAvatar( child: Icon(Icons.person), backgroundColor: Colors.white, diff --git a/lib/presentation/diets/diet_select_screen/models/diet_select_model.dart b/lib/old/diets/diet_select_screen/models/diet_select_model.dart similarity index 100% rename from lib/presentation/diets/diet_select_screen/models/diet_select_model.dart rename to lib/old/diets/diet_select_screen/models/diet_select_model.dart diff --git a/lib/presentation/diets/diet_show_screen/bloc/diet_show_bloc.dart b/lib/old/diets/diet_show_screen/bloc/diet_show_bloc.dart similarity index 94% rename from lib/presentation/diets/diet_show_screen/bloc/diet_show_bloc.dart rename to lib/old/diets/diet_show_screen/bloc/diet_show_bloc.dart index b680d054..91026abc 100644 --- a/lib/presentation/diets/diet_show_screen/bloc/diet_show_bloc.dart +++ b/lib/old/diets/diet_show_screen/bloc/diet_show_bloc.dart @@ -2,15 +2,15 @@ import 'dart:async'; import 'dart:convert'; import 'package:eatvio_app/app_router.dart'; +import 'package:eatvio_app/core/const.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:eatvio_app/old/diets/diet_show_screen/models/diet_show_model.dart'; import 'package:equatable/equatable.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:go_router/go_router.dart'; import 'package:http/http.dart' as http; -import '/core/app_export.dart'; - part 'diet_show_event.dart'; part 'diet_show_state.dart'; diff --git a/lib/presentation/diets/diet_show_screen/bloc/diet_show_event.dart b/lib/old/diets/diet_show_screen/bloc/diet_show_event.dart similarity index 100% rename from lib/presentation/diets/diet_show_screen/bloc/diet_show_event.dart rename to lib/old/diets/diet_show_screen/bloc/diet_show_event.dart diff --git a/lib/presentation/diets/diet_show_screen/bloc/diet_show_state.dart b/lib/old/diets/diet_show_screen/bloc/diet_show_state.dart similarity index 100% rename from lib/presentation/diets/diet_show_screen/bloc/diet_show_state.dart rename to lib/old/diets/diet_show_screen/bloc/diet_show_state.dart diff --git a/lib/presentation/diets/diet_show_screen/diet_show_screen.dart b/lib/old/diets/diet_show_screen/diet_show_screen.dart similarity index 86% rename from lib/presentation/diets/diet_show_screen/diet_show_screen.dart rename to lib/old/diets/diet_show_screen/diet_show_screen.dart index 9fae1efd..4339ccbc 100644 --- a/lib/presentation/diets/diet_show_screen/diet_show_screen.dart +++ b/lib/old/diets/diet_show_screen/diet_show_screen.dart @@ -1,7 +1,11 @@ import 'package:cached_network_image/cached_network_image.dart'; -import 'package:eatvio_app/core/app_export.dart'; +import 'package:eatvio_app/core/const.dart'; +import 'package:eatvio_app/theme/app_decoration.dart'; +import 'package:eatvio_app/theme/custom_text_style.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:go_router/go_router.dart'; +import 'package:rive/rive.dart'; import 'bloc/diet_show_bloc.dart'; import 'models/diet_show_model.dart'; @@ -40,7 +44,6 @@ class DietScreen extends StatelessWidget { } _buildDiet(BuildContext context, DietLoadedState state) { - mediaQueryData = MediaQuery.of(context); return SafeArea( child: Scaffold( resizeToAvoidBottomInset: false, @@ -49,14 +52,14 @@ class DietScreen extends StatelessWidget { decoration: AppDecoration.fillGray, child: ListView( children: [ - SizedBox(height: 30.v), + SizedBox(height: 30), Container( margin: EdgeInsets.only( - left: 16.h, - right: 20.h, - bottom: 10.h, + left: 16, + right: 20, + bottom: 10, ), - padding: EdgeInsets.all(12.h), + padding: EdgeInsets.all(12), decoration: BoxDecoration( color: Colors.white, borderRadius: const BorderRadius.all(Radius.circular(12)), @@ -78,7 +81,13 @@ class DietScreen extends StatelessWidget { backgroundImage: imageProvider, radius: 25, ), - placeholder: (context, url) => CircularProgressIndicator(), + placeholder: (context, url) => SizedBox( + height: 32, + width: 32, + child: RiveAnimation.asset( + 'assets/rive_animations/loading.riv', + ), + ), errorWidget: (context, url, error) => CircleAvatar( child: Icon(Icons.person), backgroundColor: Colors.white, diff --git a/lib/presentation/diets/diet_show_screen/models/diet_show_model.dart b/lib/old/diets/diet_show_screen/models/diet_show_model.dart similarity index 100% rename from lib/presentation/diets/diet_show_screen/models/diet_show_model.dart rename to lib/old/diets/diet_show_screen/models/diet_show_model.dart diff --git a/lib/presentation/feed/blog_post_create_screen/bloc/blog_post_create_bloc.dart b/lib/old/feed/blog_post_create_screen/bloc/blog_post_create_bloc.dart similarity index 94% rename from lib/presentation/feed/blog_post_create_screen/bloc/blog_post_create_bloc.dart rename to lib/old/feed/blog_post_create_screen/bloc/blog_post_create_bloc.dart index 0cfd4cc4..15e80977 100644 --- a/lib/presentation/feed/blog_post_create_screen/bloc/blog_post_create_bloc.dart +++ b/lib/old/feed/blog_post_create_screen/bloc/blog_post_create_bloc.dart @@ -2,16 +2,16 @@ import 'dart:async'; import 'package:dio/dio.dart'; import 'package:eatvio_app/app_router.dart'; +import 'package:eatvio_app/core/const.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:eatvio_app/old/feed/blog_post_create_screen/models/blog_post_create_model.dart'; import 'package:equatable/equatable.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:go_router/go_router.dart'; import 'package:image_picker/image_picker.dart'; -import '/core/app_export.dart'; - part 'blog_post_create_event.dart'; part 'blog_post_create_state.dart'; diff --git a/lib/presentation/feed/blog_post_create_screen/bloc/blog_post_create_event.dart b/lib/old/feed/blog_post_create_screen/bloc/blog_post_create_event.dart similarity index 100% rename from lib/presentation/feed/blog_post_create_screen/bloc/blog_post_create_event.dart rename to lib/old/feed/blog_post_create_screen/bloc/blog_post_create_event.dart diff --git a/lib/presentation/feed/blog_post_create_screen/bloc/blog_post_create_state.dart b/lib/old/feed/blog_post_create_screen/bloc/blog_post_create_state.dart similarity index 100% rename from lib/presentation/feed/blog_post_create_screen/bloc/blog_post_create_state.dart rename to lib/old/feed/blog_post_create_screen/bloc/blog_post_create_state.dart diff --git a/lib/presentation/feed/blog_post_create_screen/models/blog_post_create_model.dart b/lib/old/feed/blog_post_create_screen/models/blog_post_create_model.dart similarity index 100% rename from lib/presentation/feed/blog_post_create_screen/models/blog_post_create_model.dart rename to lib/old/feed/blog_post_create_screen/models/blog_post_create_model.dart diff --git a/lib/presentation/feed/blog_post_edit_screen/bloc/blog_post_edit_bloc.dart b/lib/old/feed/blog_post_edit_screen/bloc/blog_post_edit_bloc.dart similarity index 94% rename from lib/presentation/feed/blog_post_edit_screen/bloc/blog_post_edit_bloc.dart rename to lib/old/feed/blog_post_edit_screen/bloc/blog_post_edit_bloc.dart index 813a66d0..553e301d 100644 --- a/lib/presentation/feed/blog_post_edit_screen/bloc/blog_post_edit_bloc.dart +++ b/lib/old/feed/blog_post_edit_screen/bloc/blog_post_edit_bloc.dart @@ -2,17 +2,16 @@ import 'dart:async'; import 'dart:convert'; import 'package:eatvio_app/app_router.dart'; +import 'package:eatvio_app/core/const.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:eatvio_app/old/feed/blog_post_edit_screen/models/blog_post_edit_model.dart'; import 'package:equatable/equatable.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:go_router/go_router.dart'; import 'package:http/http.dart' as http; -import '/core/app_export.dart'; - -part 'blog_post_edit_event.dart'; -part 'blog_post_edit_state.dart'; +part 'blog_post_edit_event.dart';part 'blog_post_edit_state.dart'; /// A bloc that manages the state of a BlogPostEdit according to the event that is dispatched to it. class BlogPostEditBloc extends Bloc { diff --git a/lib/presentation/feed/blog_post_edit_screen/bloc/blog_post_edit_event.dart b/lib/old/feed/blog_post_edit_screen/bloc/blog_post_edit_event.dart similarity index 100% rename from lib/presentation/feed/blog_post_edit_screen/bloc/blog_post_edit_event.dart rename to lib/old/feed/blog_post_edit_screen/bloc/blog_post_edit_event.dart diff --git a/lib/presentation/feed/blog_post_edit_screen/bloc/blog_post_edit_state.dart b/lib/old/feed/blog_post_edit_screen/bloc/blog_post_edit_state.dart similarity index 100% rename from lib/presentation/feed/blog_post_edit_screen/bloc/blog_post_edit_state.dart rename to lib/old/feed/blog_post_edit_screen/bloc/blog_post_edit_state.dart diff --git a/lib/presentation/feed/blog_post_edit_screen/blog_post_edit_screen.dart b/lib/old/feed/blog_post_edit_screen/blog_post_edit_screen.dart similarity index 78% rename from lib/presentation/feed/blog_post_edit_screen/blog_post_edit_screen.dart rename to lib/old/feed/blog_post_edit_screen/blog_post_edit_screen.dart index ba691376..7669284a 100644 --- a/lib/presentation/feed/blog_post_edit_screen/blog_post_edit_screen.dart +++ b/lib/old/feed/blog_post_edit_screen/blog_post_edit_screen.dart @@ -1,6 +1,9 @@ import 'package:cached_network_image/cached_network_image.dart'; -import 'package:eatvio_app/core/app_export.dart'; +import 'package:eatvio_app/core/const.dart'; +import 'package:eatvio_app/theme/app_decoration.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:rive/rive.dart'; import 'bloc/blog_post_edit_bloc.dart'; import 'models/blog_post_edit_model.dart'; @@ -22,7 +25,13 @@ class BlogPostEditScreen extends StatelessWidget { if (state is BlogPostEditInitialState) { return Scaffold( body: Center( - child: CircularProgressIndicator(), + child: SizedBox( + height: 32, + width: 32, + child: RiveAnimation.asset( + 'assets/rive_animations/loading.riv', + ), + ), ), ); } else if (state is BlogPostEditLoadedState) { @@ -34,7 +43,13 @@ class BlogPostEditScreen extends StatelessWidget { } else { return Scaffold( body: Center( - child: CircularProgressIndicator(), + child: SizedBox( + height: 32, + width: 32, + child: RiveAnimation.asset( + 'assets/rive_animations/loading.riv', + ), + ), ), ); } @@ -43,7 +58,6 @@ class BlogPostEditScreen extends StatelessWidget { } _buildBlogPostEdit(BuildContext context, BlogPostEditLoadedState state) { - mediaQueryData = MediaQuery.of(context); return Scaffold( resizeToAvoidBottomInset: false, body: Container( @@ -51,14 +65,14 @@ class BlogPostEditScreen extends StatelessWidget { decoration: AppDecoration.fillGray, child: ListView( children: [ - SizedBox(height: 30.v), + SizedBox(height: 30), Container( margin: EdgeInsets.only( - left: 16.h, - right: 20.h, - bottom: 10.h, + left: 16, + right: 20, + bottom: 10, ), - padding: EdgeInsets.all(12.h), + padding: EdgeInsets.all(12), decoration: BoxDecoration( color: Colors.white, borderRadius: const BorderRadius.all(Radius.circular(12)), @@ -80,7 +94,13 @@ class BlogPostEditScreen extends StatelessWidget { backgroundImage: imageProvider, radius: 25, ), - placeholder: (context, url) => CircularProgressIndicator(), + placeholder: (context, url) => SizedBox( + height: 32, + width: 32, + child: RiveAnimation.asset( + 'assets/rive_animations/loading.riv', + ), + ), errorWidget: (context, url, error) => CircleAvatar( child: Icon(Icons.person), backgroundColor: Colors.white, diff --git a/lib/presentation/feed/blog_post_edit_screen/models/blog_post_edit_model.dart b/lib/old/feed/blog_post_edit_screen/models/blog_post_edit_model.dart similarity index 100% rename from lib/presentation/feed/blog_post_edit_screen/models/blog_post_edit_model.dart rename to lib/old/feed/blog_post_edit_screen/models/blog_post_edit_model.dart diff --git a/lib/presentation/feed/blog_post_screen/models/blog_post_model.dart b/lib/old/feed/blog_post_screen/models/blog_post_model.dart similarity index 85% rename from lib/presentation/feed/blog_post_screen/models/blog_post_model.dart rename to lib/old/feed/blog_post_screen/models/blog_post_model.dart index 106b3b59..1230d998 100644 --- a/lib/presentation/feed/blog_post_screen/models/blog_post_model.dart +++ b/lib/old/feed/blog_post_screen/models/blog_post_model.dart @@ -1,6 +1,6 @@ // ignore_for_file: must_be_immutable -import 'package:eatvio_app/presentation/feed/blog_post_screen/models/comment_model.dart'; +import 'package:eatvio_app/old/feed/blog_post_screen/models/comment_model.dart'; import 'package:equatable/equatable.dart'; class BlogPostModel extends Equatable { diff --git a/lib/presentation/feed/blog_post_screen/models/comment_model.dart b/lib/old/feed/blog_post_screen/models/comment_model.dart similarity index 72% rename from lib/presentation/feed/blog_post_screen/models/comment_model.dart rename to lib/old/feed/blog_post_screen/models/comment_model.dart index 2b9c7133..f5bb4131 100644 --- a/lib/presentation/feed/blog_post_screen/models/comment_model.dart +++ b/lib/old/feed/blog_post_screen/models/comment_model.dart @@ -1,7 +1,4 @@ -import 'package:eatvio_app/core/app_export.dart'; - -/// This class is used in the [userprofile_item_widget] screen. -// ignore_for_file: must_be_immutable +import 'package:eatvio_app/core/utils/image_constant.dart'; class CommentModel { CommentModel({ diff --git a/lib/presentation/recipe/recipe_show_screen/widgets/comment_widget.dart b/lib/old/feed/blog_post_screen/widgets/comment_widget.dart similarity index 74% rename from lib/presentation/recipe/recipe_show_screen/widgets/comment_widget.dart rename to lib/old/feed/blog_post_screen/widgets/comment_widget.dart index ed2e075c..da9f5dfb 100644 --- a/lib/presentation/recipe/recipe_show_screen/widgets/comment_widget.dart +++ b/lib/old/feed/blog_post_screen/widgets/comment_widget.dart @@ -1,9 +1,14 @@ // ignore_for_file: must_be_immutable import 'package:cached_network_image/cached_network_image.dart'; -import 'package:eatvio_app/core/app_export.dart'; -import 'package:eatvio_app/presentation/feed/blog_post_screen/models/comment_model.dart'; +import 'package:eatvio_app/core/const.dart'; +import 'package:eatvio_app/core/utils/image_constant.dart'; +import 'package:eatvio_app/old/feed/blog_post_screen/models/comment_model.dart'; +import 'package:eatvio_app/theme/custom_text_style.dart'; +import 'package:eatvio_app/theme/theme_helper.dart'; +import 'package:eatvio_app/widgets/custom_image_view.dart'; import 'package:flutter/material.dart'; +import 'package:rive/rive.dart'; class CommentWidget extends StatelessWidget { CommentWidget(this.commentModelObj, {Key? key}) @@ -17,11 +22,11 @@ class CommentWidget extends StatelessWidget { Widget build(BuildContext context) { return Container( margin: EdgeInsets.only( - left: 16.h, - right: 20.h, - bottom: 10.h, + left: 16, + right: 20, + bottom: 10, ), - padding: EdgeInsets.all(12.h), + padding: EdgeInsets.all(12), decoration: BoxDecoration( color: Colors.white, borderRadius: const BorderRadius.all(Radius.circular(12)), @@ -44,7 +49,13 @@ class CommentWidget extends StatelessWidget { backgroundImage: imageProvider, radius: 25, ), - placeholder: (context, url) => CircularProgressIndicator(), + placeholder: (context, url) => SizedBox( + height: 32, + width: 32, + child: RiveAnimation.asset( + 'assets/rive_animations/loading.riv', + ), + ), errorWidget: (context, url, error) => CircleAvatar( child: Icon(Icons.person), backgroundColor: Colors.white, @@ -54,15 +65,15 @@ class CommentWidget extends StatelessWidget { Expanded( child: Padding( padding: EdgeInsets.only( - left: 12.h, - top: 2.v, - bottom: 11.v, + left: 12, + top: 2, + bottom: 11, ), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ SizedBox( - width: 227.h, + width: 227, child: Row( children: [ Text( @@ -71,7 +82,7 @@ class CommentWidget extends StatelessWidget { ), Spacer(), Padding( - padding: EdgeInsets.only(left: 6.h), + padding: EdgeInsets.only(left: 6), child: Text( commentModelObj.dateText!, style: theme.textTheme.bodyMedium, @@ -80,7 +91,7 @@ class CommentWidget extends StatelessWidget { ], ), ), - SizedBox(height: 6.v), + SizedBox(height: 6), Text( commentModelObj.greetingText!, style: CustomTextStyles.bodyMediumBluegray800, @@ -91,8 +102,8 @@ class CommentWidget extends StatelessWidget { ), CustomImageView( imagePath: ImageConstant.imgSend, - height: 30.v, - width: 30.h, + height: 30, + width: 30, margin: EdgeInsets.only(left: 5), ), ], diff --git a/lib/presentation/feed/feed_screen/widgets/feed_scroll_item.dart b/lib/old/feed/feed_screen/widgets/feed_scroll_item.dart similarity index 90% rename from lib/presentation/feed/feed_screen/widgets/feed_scroll_item.dart rename to lib/old/feed/feed_screen/widgets/feed_scroll_item.dart index bc3b1613..da1ca390 100644 --- a/lib/presentation/feed/feed_screen/widgets/feed_scroll_item.dart +++ b/lib/old/feed/feed_screen/widgets/feed_scroll_item.dart @@ -1,4 +1,4 @@ -import 'package:eatvio_app/core/app_export.dart'; +import 'package:eatvio_app/theme/custom_text_style.dart'; import 'package:flutter/material.dart'; class ScrollItem extends StatelessWidget { diff --git a/lib/presentation/feed/feed_screen/widgets/feed_search_view.dart b/lib/old/feed/feed_screen/widgets/feed_search_view.dart similarity index 90% rename from lib/presentation/feed/feed_screen/widgets/feed_search_view.dart rename to lib/old/feed/feed_screen/widgets/feed_search_view.dart index bbfff40f..579a0a29 100644 --- a/lib/presentation/feed/feed_screen/widgets/feed_search_view.dart +++ b/lib/old/feed/feed_screen/widgets/feed_search_view.dart @@ -1,4 +1,4 @@ -import 'package:eatvio_app/core/app_export.dart'; +import 'package:eatvio_app/theme/custom_text_style.dart'; import 'package:flutter/material.dart'; class CustomSearchView extends StatelessWidget { @@ -118,34 +118,34 @@ class CustomSearchView extends StatelessWidget { ), prefixIconConstraints: prefixConstraints ?? BoxConstraints( - maxHeight: 40.v, + maxHeight: 40, ), suffixIconConstraints: suffixConstraints ?? BoxConstraints( - maxHeight: 40.v, + maxHeight: 40, ), isDense: true, contentPadding: contentPadding ?? EdgeInsets.only( - top: 11.v, - right: 11.h, - bottom: 11.v, + top: 11, + right: 11, + bottom: 11, ), fillColor: fillColor ?? Colors.grey[200], filled: filled, border: borderDecoration ?? OutlineInputBorder( - borderRadius: BorderRadius.circular(8.h), + borderRadius: BorderRadius.circular(8), borderSide: BorderSide.none, ), enabledBorder: borderDecoration ?? OutlineInputBorder( - borderRadius: BorderRadius.circular(8.h), + borderRadius: BorderRadius.circular(8), borderSide: BorderSide.none, ), focusedBorder: borderDecoration ?? OutlineInputBorder( - borderRadius: BorderRadius.circular(8.h), + borderRadius: BorderRadius.circular(8), borderSide: BorderSide.none, ), ); diff --git a/lib/presentation/glossary/glossary_screen/bloc/glossary_screen_bloc.dart b/lib/old/glossary/glossary_screen/bloc/glossary_screen_bloc.dart similarity index 94% rename from lib/presentation/glossary/glossary_screen/bloc/glossary_screen_bloc.dart rename to lib/old/glossary/glossary_screen/bloc/glossary_screen_bloc.dart index c45d5569..3c3817d4 100644 --- a/lib/presentation/glossary/glossary_screen/bloc/glossary_screen_bloc.dart +++ b/lib/old/glossary/glossary_screen/bloc/glossary_screen_bloc.dart @@ -2,15 +2,16 @@ import 'dart:async'; import 'dart:convert'; import 'package:eatvio_app/app_router.dart'; +import 'package:eatvio_app/core/const.dart'; import 'package:eatvio_app/core/token_storage.dart'; -import 'package:eatvio_app/presentation/glossary/glossary_screen/models/glossary_screen_model.dart'; +import 'package:eatvio_app/data/models/selectionPopupModel/selection_popup_model.dart'; +import 'package:eatvio_app/old/glossary/glossary_screen/models/glossary_screen_model.dart'; import 'package:equatable/equatable.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:go_router/go_router.dart'; import 'package:http/http.dart' as http; -import '/core/app_export.dart'; - part 'glossary_screen_event.dart'; part 'glossary_screen_state.dart'; diff --git a/lib/presentation/glossary/glossary_screen/bloc/glossary_screen_event.dart b/lib/old/glossary/glossary_screen/bloc/glossary_screen_event.dart similarity index 100% rename from lib/presentation/glossary/glossary_screen/bloc/glossary_screen_event.dart rename to lib/old/glossary/glossary_screen/bloc/glossary_screen_event.dart diff --git a/lib/presentation/glossary/glossary_screen/bloc/glossary_screen_state.dart b/lib/old/glossary/glossary_screen/bloc/glossary_screen_state.dart similarity index 100% rename from lib/presentation/glossary/glossary_screen/bloc/glossary_screen_state.dart rename to lib/old/glossary/glossary_screen/bloc/glossary_screen_state.dart diff --git a/lib/presentation/glossary/glossary_screen/glossary_screen.dart b/lib/old/glossary/glossary_screen/glossary_screen.dart similarity index 89% rename from lib/presentation/glossary/glossary_screen/glossary_screen.dart rename to lib/old/glossary/glossary_screen/glossary_screen.dart index e8453187..aa07d867 100644 --- a/lib/presentation/glossary/glossary_screen/glossary_screen.dart +++ b/lib/old/glossary/glossary_screen/glossary_screen.dart @@ -1,10 +1,15 @@ import 'package:cached_network_image/cached_network_image.dart'; -import 'package:eatvio_app/core/app_export.dart'; -import 'package:eatvio_app/presentation/glossary/glossary_screen/widgets/glossary_scroll_item.dart'; -import 'package:eatvio_app/presentation/glossary/glossary_screen/widgets/glossary_search_widget.dart'; +import 'package:eatvio_app/core/const.dart'; +import 'package:eatvio_app/data/models/selectionPopupModel/selection_popup_model.dart'; +import 'package:eatvio_app/old/glossary/glossary_screen/widgets/glossary_scroll_item.dart'; +import 'package:eatvio_app/old/glossary/glossary_screen/widgets/glossary_search_widget.dart'; +import 'package:eatvio_app/theme/custom_button_style.dart'; +import 'package:eatvio_app/theme/custom_text_style.dart'; import 'package:eatvio_app/widgets/custom_drop_down.dart'; import 'package:eatvio_app/widgets/custom_outlined_button.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:rive/rive.dart'; import 'bloc/glossary_screen_bloc.dart'; import 'models/glossary_screen_model.dart'; @@ -26,7 +31,13 @@ class GlossaryScreen extends StatelessWidget { // Это начальное состояние, данные ещё не загружены. return Scaffold( body: Center( - child: CircularProgressIndicator(), + child: SizedBox( + height: 32, + width: 32, + child: RiveAnimation.asset( + 'assets/rive_animations/loading.riv', + ), + ), ), ); } else if (state is GlossaryLoadedState) { @@ -39,7 +50,13 @@ class GlossaryScreen extends StatelessWidget { // Другие состояния, если они есть. return Scaffold( body: Center( - child: CircularProgressIndicator(), + child: SizedBox( + height: 32, + width: 32, + child: RiveAnimation.asset( + 'assets/rive_animations/loading.riv', + ), + ), ), ); } @@ -246,7 +263,13 @@ class GlossaryScreen extends StatelessWidget { backgroundImage: imageProvider, radius: 25, ), - placeholder: (context, url) => CircularProgressIndicator(), + placeholder: (context, url) => SizedBox( + height: 32, + width: 32, + child: RiveAnimation.asset( + 'assets/rive_animations/loading.riv', + ), + ), errorWidget: (context, url, error) => CircleAvatar( child: Icon(Icons.person), backgroundColor: Colors.white, diff --git a/lib/presentation/glossary/glossary_screen/models/glossary_screen_model.dart b/lib/old/glossary/glossary_screen/models/glossary_screen_model.dart similarity index 100% rename from lib/presentation/glossary/glossary_screen/models/glossary_screen_model.dart rename to lib/old/glossary/glossary_screen/models/glossary_screen_model.dart diff --git a/lib/presentation/glossary/glossary_screen/widgets/glossary_scroll_item.dart b/lib/old/glossary/glossary_screen/widgets/glossary_scroll_item.dart similarity index 90% rename from lib/presentation/glossary/glossary_screen/widgets/glossary_scroll_item.dart rename to lib/old/glossary/glossary_screen/widgets/glossary_scroll_item.dart index bc3b1613..da1ca390 100644 --- a/lib/presentation/glossary/glossary_screen/widgets/glossary_scroll_item.dart +++ b/lib/old/glossary/glossary_screen/widgets/glossary_scroll_item.dart @@ -1,4 +1,4 @@ -import 'package:eatvio_app/core/app_export.dart'; +import 'package:eatvio_app/theme/custom_text_style.dart'; import 'package:flutter/material.dart'; class ScrollItem extends StatelessWidget { diff --git a/lib/presentation/glossary/glossary_screen/widgets/glossary_search_widget.dart b/lib/old/glossary/glossary_screen/widgets/glossary_search_widget.dart similarity index 90% rename from lib/presentation/glossary/glossary_screen/widgets/glossary_search_widget.dart rename to lib/old/glossary/glossary_screen/widgets/glossary_search_widget.dart index bbfff40f..579a0a29 100644 --- a/lib/presentation/glossary/glossary_screen/widgets/glossary_search_widget.dart +++ b/lib/old/glossary/glossary_screen/widgets/glossary_search_widget.dart @@ -1,4 +1,4 @@ -import 'package:eatvio_app/core/app_export.dart'; +import 'package:eatvio_app/theme/custom_text_style.dart'; import 'package:flutter/material.dart'; class CustomSearchView extends StatelessWidget { @@ -118,34 +118,34 @@ class CustomSearchView extends StatelessWidget { ), prefixIconConstraints: prefixConstraints ?? BoxConstraints( - maxHeight: 40.v, + maxHeight: 40, ), suffixIconConstraints: suffixConstraints ?? BoxConstraints( - maxHeight: 40.v, + maxHeight: 40, ), isDense: true, contentPadding: contentPadding ?? EdgeInsets.only( - top: 11.v, - right: 11.h, - bottom: 11.v, + top: 11, + right: 11, + bottom: 11, ), fillColor: fillColor ?? Colors.grey[200], filled: filled, border: borderDecoration ?? OutlineInputBorder( - borderRadius: BorderRadius.circular(8.h), + borderRadius: BorderRadius.circular(8), borderSide: BorderSide.none, ), enabledBorder: borderDecoration ?? OutlineInputBorder( - borderRadius: BorderRadius.circular(8.h), + borderRadius: BorderRadius.circular(8), borderSide: BorderSide.none, ), focusedBorder: borderDecoration ?? OutlineInputBorder( - borderRadius: BorderRadius.circular(8.h), + borderRadius: BorderRadius.circular(8), borderSide: BorderSide.none, ), ); diff --git a/lib/presentation/plans/plan_create_screen/bloc/plan_create_bloc.dart b/lib/old/plans/plan_create_screen/bloc/plan_create_bloc.dart similarity index 99% rename from lib/presentation/plans/plan_create_screen/bloc/plan_create_bloc.dart rename to lib/old/plans/plan_create_screen/bloc/plan_create_bloc.dart index 871c2dc1..fa446a7c 100644 --- a/lib/presentation/plans/plan_create_screen/bloc/plan_create_bloc.dart +++ b/lib/old/plans/plan_create_screen/bloc/plan_create_bloc.dart @@ -2,15 +2,15 @@ import 'dart:async'; import 'dart:convert'; import 'package:eatvio_app/app_router.dart'; +import 'package:eatvio_app/core/const.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:eatvio_app/old/plans/plan_create_screen/models/plan_create_model.dart'; import 'package:equatable/equatable.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:go_router/go_router.dart'; import 'package:http/http.dart' as http; -import '/core/app_export.dart'; - part 'plan_create_event.dart'; part 'plan_create_state.dart'; diff --git a/lib/presentation/plans/plan_create_screen/bloc/plan_create_event.dart b/lib/old/plans/plan_create_screen/bloc/plan_create_event.dart similarity index 100% rename from lib/presentation/plans/plan_create_screen/bloc/plan_create_event.dart rename to lib/old/plans/plan_create_screen/bloc/plan_create_event.dart diff --git a/lib/presentation/plans/plan_create_screen/bloc/plan_create_state.dart b/lib/old/plans/plan_create_screen/bloc/plan_create_state.dart similarity index 100% rename from lib/presentation/plans/plan_create_screen/bloc/plan_create_state.dart rename to lib/old/plans/plan_create_screen/bloc/plan_create_state.dart diff --git a/lib/presentation/plans/plan_create_screen/models/plan_create_model.dart b/lib/old/plans/plan_create_screen/models/plan_create_model.dart similarity index 100% rename from lib/presentation/plans/plan_create_screen/models/plan_create_model.dart rename to lib/old/plans/plan_create_screen/models/plan_create_model.dart diff --git a/lib/presentation/plans/plan_create_screen/plan_create_screen.dart b/lib/old/plans/plan_create_screen/plan_create_screen.dart similarity index 92% rename from lib/presentation/plans/plan_create_screen/plan_create_screen.dart rename to lib/old/plans/plan_create_screen/plan_create_screen.dart index 165be86b..284d94b2 100644 --- a/lib/presentation/plans/plan_create_screen/plan_create_screen.dart +++ b/lib/old/plans/plan_create_screen/plan_create_screen.dart @@ -1,5 +1,6 @@ -import 'package:eatvio_app/core/app_export.dart'; +import 'package:eatvio_app/theme/app_decoration.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; import 'bloc/plan_create_bloc.dart'; import 'models/plan_create_model.dart'; @@ -38,7 +39,6 @@ class PlanCreateScreen extends StatelessWidget { } _buildPlanCreate(BuildContext context, PlanCreateLoadedState state) { - mediaQueryData = MediaQuery.of(context); return SafeArea( child: Scaffold( resizeToAvoidBottomInset: false, @@ -47,14 +47,14 @@ class PlanCreateScreen extends StatelessWidget { decoration: AppDecoration.fillGray, child: ListView( children: [ - SizedBox(height: 30.v), + SizedBox(height: 30), Container( margin: EdgeInsets.only( - left: 16.h, - right: 20.h, - bottom: 10.h, + left: 16, + right: 20, + bottom: 10, ), - padding: EdgeInsets.all(12.h), + padding: EdgeInsets.all(12), decoration: BoxDecoration( color: Colors.white, borderRadius: const BorderRadius.all(Radius.circular(12)), diff --git a/lib/presentation/plans/plan_edit_screen/bloc/plan_edit_bloc.dart b/lib/old/plans/plan_edit_screen/bloc/plan_edit_bloc.dart similarity index 95% rename from lib/presentation/plans/plan_edit_screen/bloc/plan_edit_bloc.dart rename to lib/old/plans/plan_edit_screen/bloc/plan_edit_bloc.dart index 656e671c..ca78a970 100644 --- a/lib/presentation/plans/plan_edit_screen/bloc/plan_edit_bloc.dart +++ b/lib/old/plans/plan_edit_screen/bloc/plan_edit_bloc.dart @@ -2,15 +2,15 @@ import 'dart:async'; import 'dart:convert'; import 'package:eatvio_app/app_router.dart'; +import 'package:eatvio_app/core/const.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:eatvio_app/old/plans/plan_edit_screen/models/plan_edit_model.dart'; import 'package:equatable/equatable.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:go_router/go_router.dart'; import 'package:http/http.dart' as http; -import '/core/app_export.dart'; - part 'plan_edit_event.dart'; part 'plan_edit_state.dart'; diff --git a/lib/presentation/plans/plan_edit_screen/bloc/plan_edit_event.dart b/lib/old/plans/plan_edit_screen/bloc/plan_edit_event.dart similarity index 100% rename from lib/presentation/plans/plan_edit_screen/bloc/plan_edit_event.dart rename to lib/old/plans/plan_edit_screen/bloc/plan_edit_event.dart diff --git a/lib/presentation/plans/plan_edit_screen/bloc/plan_edit_state.dart b/lib/old/plans/plan_edit_screen/bloc/plan_edit_state.dart similarity index 100% rename from lib/presentation/plans/plan_edit_screen/bloc/plan_edit_state.dart rename to lib/old/plans/plan_edit_screen/bloc/plan_edit_state.dart diff --git a/lib/presentation/plans/plan_edit_screen/models/plan_edit_model.dart b/lib/old/plans/plan_edit_screen/models/plan_edit_model.dart similarity index 100% rename from lib/presentation/plans/plan_edit_screen/models/plan_edit_model.dart rename to lib/old/plans/plan_edit_screen/models/plan_edit_model.dart diff --git a/lib/presentation/plans/plan_edit_screen/plan_edit_screen.dart b/lib/old/plans/plan_edit_screen/plan_edit_screen.dart similarity index 86% rename from lib/presentation/plans/plan_edit_screen/plan_edit_screen.dart rename to lib/old/plans/plan_edit_screen/plan_edit_screen.dart index c7005746..31fbd435 100644 --- a/lib/presentation/plans/plan_edit_screen/plan_edit_screen.dart +++ b/lib/old/plans/plan_edit_screen/plan_edit_screen.dart @@ -1,6 +1,9 @@ import 'package:cached_network_image/cached_network_image.dart'; -import 'package:eatvio_app/core/app_export.dart'; +import 'package:eatvio_app/core/const.dart'; +import 'package:eatvio_app/theme/app_decoration.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:rive/rive.dart'; import 'bloc/plan_edit_bloc.dart'; import 'models/plan_edit_model.dart'; @@ -39,7 +42,6 @@ class PlanEditScreen extends StatelessWidget { } _buildPlanEdit(BuildContext context, PlanEditLoadedState state) { - mediaQueryData = MediaQuery.of(context); return SafeArea( child: Scaffold( resizeToAvoidBottomInset: false, @@ -48,14 +50,14 @@ class PlanEditScreen extends StatelessWidget { decoration: AppDecoration.fillGray, child: ListView( children: [ - SizedBox(height: 30.v), + SizedBox(height: 30), Container( margin: EdgeInsets.only( - left: 16.h, - right: 20.h, - bottom: 10.h, + left: 16, + right: 20, + bottom: 10, ), - padding: EdgeInsets.all(12.h), + padding: EdgeInsets.all(12), decoration: BoxDecoration( color: Colors.white, borderRadius: const BorderRadius.all(Radius.circular(12)), @@ -77,7 +79,13 @@ class PlanEditScreen extends StatelessWidget { backgroundImage: imageProvider, radius: 25, ), - placeholder: (context, url) => CircularProgressIndicator(), + placeholder: (context, url) => SizedBox( + height: 32, + width: 32, + child: RiveAnimation.asset( + 'assets/rive_animations/loading.riv', + ), + ), errorWidget: (context, url, error) => CircleAvatar( child: Icon(Icons.person), backgroundColor: Colors.white, diff --git a/lib/presentation/plans/plan_select_screen/bloc/plan_select_bloc.dart b/lib/old/plans/plan_select_screen/bloc/plan_select_bloc.dart similarity index 90% rename from lib/presentation/plans/plan_select_screen/bloc/plan_select_bloc.dart rename to lib/old/plans/plan_select_screen/bloc/plan_select_bloc.dart index fa32b77f..a08a00f2 100644 --- a/lib/presentation/plans/plan_select_screen/bloc/plan_select_bloc.dart +++ b/lib/old/plans/plan_select_screen/bloc/plan_select_bloc.dart @@ -1,18 +1,18 @@ -//import 'package:eatvio_app/presentation/auth/auth_screen/auth_screen.dart'; +//import 'package:eatvio_app/old/auth/auth_screen/auth_screen.dart'; import 'dart:async'; import 'dart:convert'; import 'package:eatvio_app/app_router.dart'; +import 'package:eatvio_app/core/const.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:eatvio_app/old/plans/plan_select_screen/models/plan_select_model.dart'; import 'package:equatable/equatable.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:go_router/go_router.dart'; import 'package:http/http.dart' as http; import 'package:image_picker/image_picker.dart'; -import '/core/app_export.dart'; - part 'plan_select_event.dart'; part 'plan_select_state.dart'; diff --git a/lib/presentation/plans/plan_select_screen/bloc/plan_select_event.dart b/lib/old/plans/plan_select_screen/bloc/plan_select_event.dart similarity index 100% rename from lib/presentation/plans/plan_select_screen/bloc/plan_select_event.dart rename to lib/old/plans/plan_select_screen/bloc/plan_select_event.dart diff --git a/lib/presentation/plans/plan_select_screen/bloc/plan_select_state.dart b/lib/old/plans/plan_select_screen/bloc/plan_select_state.dart similarity index 100% rename from lib/presentation/plans/plan_select_screen/bloc/plan_select_state.dart rename to lib/old/plans/plan_select_screen/bloc/plan_select_state.dart diff --git a/lib/presentation/plans/plan_select_screen/models/plan_select_model.dart b/lib/old/plans/plan_select_screen/models/plan_select_model.dart similarity index 100% rename from lib/presentation/plans/plan_select_screen/models/plan_select_model.dart rename to lib/old/plans/plan_select_screen/models/plan_select_model.dart diff --git a/lib/presentation/plans/plan_select_screen/plan_select_screen.dart b/lib/old/plans/plan_select_screen/plan_select_screen.dart similarity index 82% rename from lib/presentation/plans/plan_select_screen/plan_select_screen.dart rename to lib/old/plans/plan_select_screen/plan_select_screen.dart index 1508c75e..991ffe24 100644 --- a/lib/presentation/plans/plan_select_screen/plan_select_screen.dart +++ b/lib/old/plans/plan_select_screen/plan_select_screen.dart @@ -1,10 +1,14 @@ import 'package:cached_network_image/cached_network_image.dart'; -import 'package:eatvio_app/core/app_export.dart'; +import 'package:eatvio_app/core/const.dart'; +import 'package:eatvio_app/core/utils/image_constant.dart'; +import 'package:eatvio_app/theme/custom_text_style.dart'; import 'package:eatvio_app/widgets/app_bar/appbar_leading_image.dart'; import 'package:eatvio_app/widgets/app_bar/appbar_subtitle.dart'; import 'package:eatvio_app/widgets/app_bar/custom_app_bar.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:go_router/go_router.dart'; +import 'package:rive/rive.dart'; import 'bloc/plan_select_bloc.dart'; import 'models/plan_select_model.dart'; @@ -24,7 +28,13 @@ class PlanSelectScreen extends StatelessWidget { // Это начальное состояние, данные ещё не загружены. return Scaffold( body: Center( - child: CircularProgressIndicator(), + child: SizedBox( + height: 32, + width: 32, + child: RiveAnimation.asset( + 'assets/rive_animations/loading.riv', + ), + ), ), ); } else if (state is PlanSelectLoadedState) { @@ -34,7 +44,13 @@ class PlanSelectScreen extends StatelessWidget { // Другие состояния, если они есть. return Scaffold( body: Center( - child: CircularProgressIndicator(), + child: SizedBox( + height: 32, + width: 32, + child: RiveAnimation.asset( + 'assets/rive_animations/loading.riv', + ), + ), ), ); } @@ -74,20 +90,20 @@ class PlanSelectScreen extends StatelessWidget { ], ), child: CustomAppBar( - height: 54.v, - leadingWidth: 28.h, + height: 54, + leadingWidth: 28, leading: AppbarLeadingImage( imagePath: ImageConstant.imgArrowLeft, - margin: EdgeInsets.only(left: 16.h, top: 15.v, bottom: 15.v), + margin: EdgeInsets.only(left: 16, top: 15, bottom: 15), onTap: () => GoRouter.of(context).pop(), ), title: Padding( - padding: EdgeInsets.only(left: 20.h), + padding: EdgeInsets.only(left: 20), child: Row( children: [ AppbarSubtitle( text: "Планы", - margin: EdgeInsets.only(left: 80.h, top: 12.v, bottom: 9.v), + margin: EdgeInsets.only(left: 80, top: 12, bottom: 9), ), Spacer(), Padding( @@ -139,7 +155,13 @@ class PlanSelectScreen extends StatelessWidget { backgroundImage: imageProvider, radius: 25, ), - placeholder: (context, url) => CircularProgressIndicator(), + placeholder: (context, url) => SizedBox( + height: 32, + width: 32, + child: RiveAnimation.asset( + 'assets/rive_animations/loading.riv', + ), + ), errorWidget: (context, url, error) => CircleAvatar( child: Icon(Icons.person), backgroundColor: Colors.white, diff --git a/lib/presentation/plans/plan_show_screen/bloc/plan_show_bloc.dart b/lib/old/plans/plan_show_screen/bloc/plan_show_bloc.dart similarity index 94% rename from lib/presentation/plans/plan_show_screen/bloc/plan_show_bloc.dart rename to lib/old/plans/plan_show_screen/bloc/plan_show_bloc.dart index f09463a9..36cdea7f 100644 --- a/lib/presentation/plans/plan_show_screen/bloc/plan_show_bloc.dart +++ b/lib/old/plans/plan_show_screen/bloc/plan_show_bloc.dart @@ -2,15 +2,15 @@ import 'dart:async'; import 'dart:convert'; import 'package:eatvio_app/app_router.dart'; +import 'package:eatvio_app/core/const.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:eatvio_app/old/plans/plan_show_screen/models/plan_show_model.dart'; import 'package:equatable/equatable.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:go_router/go_router.dart'; import 'package:http/http.dart' as http; -import '/core/app_export.dart'; - part 'plan_show_event.dart'; part 'plan_show_state.dart'; diff --git a/lib/presentation/plans/plan_show_screen/bloc/plan_show_event.dart b/lib/old/plans/plan_show_screen/bloc/plan_show_event.dart similarity index 100% rename from lib/presentation/plans/plan_show_screen/bloc/plan_show_event.dart rename to lib/old/plans/plan_show_screen/bloc/plan_show_event.dart diff --git a/lib/presentation/plans/plan_show_screen/bloc/plan_show_state.dart b/lib/old/plans/plan_show_screen/bloc/plan_show_state.dart similarity index 100% rename from lib/presentation/plans/plan_show_screen/bloc/plan_show_state.dart rename to lib/old/plans/plan_show_screen/bloc/plan_show_state.dart diff --git a/lib/presentation/plans/plan_show_screen/models/plan_show_model.dart b/lib/old/plans/plan_show_screen/models/plan_show_model.dart similarity index 100% rename from lib/presentation/plans/plan_show_screen/models/plan_show_model.dart rename to lib/old/plans/plan_show_screen/models/plan_show_model.dart diff --git a/lib/presentation/plans/plan_show_screen/plan_show_screen.dart b/lib/old/plans/plan_show_screen/plan_show_screen.dart similarity index 86% rename from lib/presentation/plans/plan_show_screen/plan_show_screen.dart rename to lib/old/plans/plan_show_screen/plan_show_screen.dart index bf618680..f2467d2b 100644 --- a/lib/presentation/plans/plan_show_screen/plan_show_screen.dart +++ b/lib/old/plans/plan_show_screen/plan_show_screen.dart @@ -1,7 +1,11 @@ import 'package:cached_network_image/cached_network_image.dart'; -import 'package:eatvio_app/core/app_export.dart'; +import 'package:eatvio_app/core/const.dart'; +import 'package:eatvio_app/theme/app_decoration.dart'; +import 'package:eatvio_app/theme/custom_text_style.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:go_router/go_router.dart'; +import 'package:rive/rive.dart'; import 'bloc/plan_show_bloc.dart'; import 'models/plan_show_model.dart'; @@ -40,7 +44,6 @@ class PlanScreen extends StatelessWidget { } _buildPlan(BuildContext context, PlanLoadedState state) { - mediaQueryData = MediaQuery.of(context); return SafeArea( child: Scaffold( resizeToAvoidBottomInset: false, @@ -49,14 +52,14 @@ class PlanScreen extends StatelessWidget { decoration: AppDecoration.fillGray, child: ListView( children: [ - SizedBox(height: 30.v), + SizedBox(height: 30), Container( margin: EdgeInsets.only( - left: 16.h, - right: 20.h, - bottom: 10.h, + left: 16, + right: 20, + bottom: 10, ), - padding: EdgeInsets.all(12.h), + padding: EdgeInsets.all(12), decoration: BoxDecoration( color: Colors.white, borderRadius: const BorderRadius.all(Radius.circular(12)), @@ -78,7 +81,13 @@ class PlanScreen extends StatelessWidget { backgroundImage: imageProvider, radius: 25, ), - placeholder: (context, url) => CircularProgressIndicator(), + placeholder: (context, url) => SizedBox( + height: 32, + width: 32, + child: RiveAnimation.asset( + 'assets/rive_animations/loading.riv', + ), + ), errorWidget: (context, url, error) => CircleAvatar( child: Icon(Icons.person), backgroundColor: Colors.white, diff --git a/lib/presentation/profile/my_profile_screen/bloc/my_profile_bloc.dart b/lib/old/profile/my_profile_screen/bloc/my_profile_bloc.dart similarity index 97% rename from lib/presentation/profile/my_profile_screen/bloc/my_profile_bloc.dart rename to lib/old/profile/my_profile_screen/bloc/my_profile_bloc.dart index 4678416e..7d08ecfe 100644 --- a/lib/presentation/profile/my_profile_screen/bloc/my_profile_bloc.dart +++ b/lib/old/profile/my_profile_screen/bloc/my_profile_bloc.dart @@ -1,18 +1,17 @@ -//import 'package:eatvio_app/presentation/auth/auth_screen/auth_screen.dart'; import 'dart:async'; import 'dart:convert'; import 'package:eatvio_app/app_router.dart'; +import 'package:eatvio_app/core/const.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:eatvio_app/old/profile/my_profile_screen/models/my_profile_model.dart'; import 'package:equatable/equatable.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:go_router/go_router.dart'; import 'package:http/http.dart' as http; import 'package:image_picker/image_picker.dart'; -import '/core/app_export.dart'; - part 'my_profile_event.dart'; part 'my_profile_state.dart'; @@ -27,18 +26,18 @@ class MyProfileBloc extends Bloc { MyProfileInitialEvent event, Emitter emit, ) async { + print('1'); try { if (!await TokenStorage.haveTokenInStorage()) { AppRouter.navigatorKey.currentContext?.goNamed('authScreen'); } - //final token = - // "9|laravel_sanctum_KFXbccDcWEvTPfJmV99EQv1ne AggmpR2TidVGDPN34fa201a"; final response = await http.get( Uri.parse(baseUrl + '/api/profile/index'), headers: { 'Authorization': 'Bearer ${await TokenStorage.getTokenFromStorage()}', }, ); + print('2'); if (response.statusCode == 200) { final data = jsonDecode(response.body); if (data is Map && diff --git a/lib/presentation/profile/my_profile_screen/bloc/my_profile_event.dart b/lib/old/profile/my_profile_screen/bloc/my_profile_event.dart similarity index 100% rename from lib/presentation/profile/my_profile_screen/bloc/my_profile_event.dart rename to lib/old/profile/my_profile_screen/bloc/my_profile_event.dart diff --git a/lib/presentation/profile/my_profile_screen/bloc/my_profile_state.dart b/lib/old/profile/my_profile_screen/bloc/my_profile_state.dart similarity index 100% rename from lib/presentation/profile/my_profile_screen/bloc/my_profile_state.dart rename to lib/old/profile/my_profile_screen/bloc/my_profile_state.dart diff --git a/lib/presentation/profile/my_profile_screen/models/my_profile_model.dart b/lib/old/profile/my_profile_screen/models/my_profile_model.dart similarity index 100% rename from lib/presentation/profile/my_profile_screen/models/my_profile_model.dart rename to lib/old/profile/my_profile_screen/models/my_profile_model.dart diff --git a/lib/presentation/profile/my_profile_screen/my_settings_screen.dart b/lib/old/profile/my_profile_screen/my_settings_screen.dart similarity index 85% rename from lib/presentation/profile/my_profile_screen/my_settings_screen.dart rename to lib/old/profile/my_profile_screen/my_settings_screen.dart index 4cd47b18..9f3df67e 100644 --- a/lib/presentation/profile/my_profile_screen/my_settings_screen.dart +++ b/lib/old/profile/my_profile_screen/my_settings_screen.dart @@ -1,4 +1,4 @@ -import 'package:eatvio_app/core/app_export.dart'; +import 'package:eatvio_app/core/utils/image_constant.dart'; import 'package:eatvio_app/widgets/app_bar/appbar_leading_image.dart'; import 'package:eatvio_app/widgets/app_bar/appbar_subtitle.dart'; import 'package:eatvio_app/widgets/app_bar/custom_app_bar.dart'; @@ -8,7 +8,9 @@ import 'package:eatvio_app/widgets/custom_language_drop_down.dart'; import 'package:eatvio_app/widgets/custom_notification_screen.dart'; import 'package:eatvio_app/widgets/custom_section_title.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:go_router/go_router.dart'; +import 'package:rive/rive.dart'; import 'bloc/my_profile_bloc.dart'; import 'models/my_profile_model.dart'; @@ -28,7 +30,13 @@ class MySettingsScreen extends StatelessWidget { // Это начальное состояние, данные ещё не загружены. return Scaffold( body: Center( - child: CircularProgressIndicator(), + child: SizedBox( + height: 32, + width: 32, + child: RiveAnimation.asset( + 'assets/rive_animations/loading.riv', + ), + ), ), ); } else if (state is MyProfileLoadedState) { @@ -38,7 +46,13 @@ class MySettingsScreen extends StatelessWidget { // Другие состояния, если они есть. return Scaffold( body: Center( - child: CircularProgressIndicator(), + child: SizedBox( + height: 32, + width: 32, + child: RiveAnimation.asset( + 'assets/rive_animations/loading.riv', + ), + ), ), ); } @@ -78,24 +92,24 @@ class MySettingsScreen extends StatelessWidget { ], ), child: CustomAppBar( - height: 54.v, - leadingWidth: 28.h, + height: 54, + leadingWidth: 28, leading: AppbarLeadingImage( imagePath: ImageConstant.imgArrowLeft, - margin: EdgeInsets.only(left: 16.h, top: 15.v, bottom: 15.v), + margin: EdgeInsets.only(left: 16, top: 15, bottom: 15), onTap: () => GoRouter.of(context).pop(), ), title: Padding( - padding: EdgeInsets.only(left: 20.h), - child: Row(children: [AppbarSubtitle(text: state.user?['name'], margin: EdgeInsets.only(left: 80.h, top: 12.v, bottom: 9.v))]), + padding: EdgeInsets.only(left: 20), + child: Row(children: [AppbarSubtitle(text: state.user?['name'], margin: EdgeInsets.only(left: 80, top: 12, bottom: 9))]), ), ), ), SizedBox(height: 20), Container( padding: EdgeInsets.symmetric( - horizontal: 24.h, - vertical: 12.v, + horizontal: 24, + vertical: 12, ), decoration: BoxDecoration( color: Colors.white, @@ -119,8 +133,8 @@ class MySettingsScreen extends StatelessWidget { SizedBox(height: 20), Container( padding: EdgeInsets.symmetric( - horizontal: 24.h, - vertical: 12.v, + horizontal: 24, + vertical: 12, ), decoration: BoxDecoration( color: Colors.white, @@ -145,8 +159,8 @@ class MySettingsScreen extends StatelessWidget { SizedBox(height: 20), Container( padding: EdgeInsets.symmetric( - horizontal: 24.h, - vertical: 12.v, + horizontal: 24, + vertical: 12, ), decoration: BoxDecoration( color: Colors.white, diff --git a/lib/presentation/recipe/recipe_edit_screen/bloc/recipe_edit_bloc.dart b/lib/old/recipe/recipe_edit_screen/bloc/recipe_edit_bloc.dart similarity index 98% rename from lib/presentation/recipe/recipe_edit_screen/bloc/recipe_edit_bloc.dart rename to lib/old/recipe/recipe_edit_screen/bloc/recipe_edit_bloc.dart index fa817935..77866907 100644 --- a/lib/presentation/recipe/recipe_edit_screen/bloc/recipe_edit_bloc.dart +++ b/lib/old/recipe/recipe_edit_screen/bloc/recipe_edit_bloc.dart @@ -2,15 +2,15 @@ import 'dart:async'; import 'dart:convert'; import 'package:eatvio_app/app_router.dart'; +import 'package:eatvio_app/core/const.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:eatvio_app/old/recipe/recipe_edit_screen/models/recipe_edit_model.dart'; import 'package:equatable/equatable.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:go_router/go_router.dart'; import 'package:http/http.dart' as http; -import '/core/app_export.dart'; - part 'recipe_edit_event.dart'; part 'recipe_edit_state.dart'; diff --git a/lib/presentation/recipe/recipe_edit_screen/bloc/recipe_edit_event.dart b/lib/old/recipe/recipe_edit_screen/bloc/recipe_edit_event.dart similarity index 100% rename from lib/presentation/recipe/recipe_edit_screen/bloc/recipe_edit_event.dart rename to lib/old/recipe/recipe_edit_screen/bloc/recipe_edit_event.dart diff --git a/lib/presentation/recipe/recipe_edit_screen/bloc/recipe_edit_state.dart b/lib/old/recipe/recipe_edit_screen/bloc/recipe_edit_state.dart similarity index 100% rename from lib/presentation/recipe/recipe_edit_screen/bloc/recipe_edit_state.dart rename to lib/old/recipe/recipe_edit_screen/bloc/recipe_edit_state.dart diff --git a/lib/presentation/recipe/recipe_edit_screen/models/recipe_edit_model.dart b/lib/old/recipe/recipe_edit_screen/models/recipe_edit_model.dart similarity index 100% rename from lib/presentation/recipe/recipe_edit_screen/models/recipe_edit_model.dart rename to lib/old/recipe/recipe_edit_screen/models/recipe_edit_model.dart diff --git a/lib/presentation/recipe/recipe_edit_screen/recipe_edit_screen.dart b/lib/old/recipe/recipe_edit_screen/recipe_edit_screen.dart similarity index 87% rename from lib/presentation/recipe/recipe_edit_screen/recipe_edit_screen.dart rename to lib/old/recipe/recipe_edit_screen/recipe_edit_screen.dart index e3dbcbe6..1318211a 100644 --- a/lib/presentation/recipe/recipe_edit_screen/recipe_edit_screen.dart +++ b/lib/old/recipe/recipe_edit_screen/recipe_edit_screen.dart @@ -1,12 +1,19 @@ import 'package:cached_network_image/cached_network_image.dart'; -import 'package:eatvio_app/core/app_export.dart'; +import 'package:eatvio_app/core/const.dart'; +import 'package:eatvio_app/core/utils/image_constant.dart'; +import 'package:eatvio_app/theme/app_decoration.dart'; +import 'package:eatvio_app/theme/custom_button_style.dart'; +import 'package:eatvio_app/theme/custom_text_style.dart'; +import 'package:eatvio_app/theme/theme_helper.dart'; import 'package:eatvio_app/widgets/app_bar/appbar_leading_image.dart'; import 'package:eatvio_app/widgets/app_bar/appbar_subtitle.dart'; import 'package:eatvio_app/widgets/app_bar/custom_app_bar.dart'; import 'package:eatvio_app/widgets/custom_outlined_button.dart'; import 'package:eatvio_app/widgets/custom_text_form_field.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:go_router/go_router.dart'; +import 'package:rive/rive.dart'; import 'bloc/recipe_edit_bloc.dart'; import 'models/recipe_edit_model.dart'; @@ -45,7 +52,6 @@ class RecipeEditScreen extends StatelessWidget { } _buildRecipeEdit(BuildContext context, RecipeEditLoadedState state) { - mediaQueryData = MediaQuery.of(context); List steps = []; if (state.steps != null) { for (int i = 0; i < state.steps!.length; i++) { @@ -68,14 +74,14 @@ class RecipeEditScreen extends StatelessWidget { child: ListView( children: [ _buldAppBar(context), - SizedBox(height: 20.v), + SizedBox(height: 20), _buildRecipeInfo(state, context), - SizedBox(height: 20.v), + SizedBox(height: 20), Column( crossAxisAlignment: CrossAxisAlignment.stretch, children: steps, ), - SizedBox(height: 20.v), + SizedBox(height: 20), _buildAdditional(context, state), ], ), @@ -87,7 +93,7 @@ class RecipeEditScreen extends StatelessWidget { _buldAppBar(BuildContext context) { return Container( - margin: EdgeInsets.all(16.h), + margin: EdgeInsets.all(16), decoration: BoxDecoration( color: Colors.white, borderRadius: const BorderRadius.all(Radius.circular(12)), @@ -101,11 +107,11 @@ class RecipeEditScreen extends StatelessWidget { ], ), child: CustomAppBar( - height: 54.v, - leadingWidth: 28.h, + height: 54, + leadingWidth: 28, leading: AppbarLeadingImage( imagePath: ImageConstant.imgArrowLeft, - margin: EdgeInsets.only(left: 16.h, top: 15.v, bottom: 15.v), + margin: EdgeInsets.only(left: 16, top: 15, bottom: 15), onTap: onTapBack(context), ), title: Align( @@ -121,11 +127,11 @@ class RecipeEditScreen extends StatelessWidget { _buildRecipeInfo(RecipeEditLoadedState state, BuildContext context) { return Container( margin: EdgeInsets.only( - left: 16.h, - right: 16.h, - bottom: 10.h, + left: 16, + right: 16, + bottom: 10, ), - padding: EdgeInsets.all(12.h), + padding: EdgeInsets.all(12), decoration: BoxDecoration( color: Colors.white, borderRadius: const BorderRadius.all(Radius.circular(12)), @@ -150,7 +156,13 @@ class RecipeEditScreen extends StatelessWidget { // Установите ширину равной ширине родительского элемента height: 200.0, fit: BoxFit.cover, - placeholder: (context, url) => CircularProgressIndicator(), + placeholder: (context, url) => SizedBox( + height: 32, + width: 32, + child: RiveAnimation.asset( + 'assets/rive_animations/loading.riv', + ), + ), errorWidget: (context, url, error) => Icon(Icons.error), ) else @@ -162,7 +174,7 @@ class RecipeEditScreen extends StatelessWidget { hintText: "Введите название рецепта", fillColor: appTheme.gray50, borderDecoration: OutlineInputBorder( - borderRadius: BorderRadius.circular(5.h), + borderRadius: BorderRadius.circular(5), borderSide: BorderSide( color: appTheme.gray50, width: 1, @@ -177,7 +189,7 @@ class RecipeEditScreen extends StatelessWidget { maxLines: 4, fillColor: appTheme.gray50, borderDecoration: OutlineInputBorder( - borderRadius: BorderRadius.circular(5.h), + borderRadius: BorderRadius.circular(5), borderSide: BorderSide( color: appTheme.gray50, width: 1, @@ -204,8 +216,8 @@ class RecipeEditScreen extends StatelessWidget { if (!isLoading) Container( padding: EdgeInsets.symmetric( - horizontal: 40.h, - vertical: 80.v, + horizontal: 40, + vertical: 80, ), decoration: AppDecoration.fillGray.copyWith( borderRadius: BorderRadiusStyle.roundedBorder5, @@ -216,8 +228,8 @@ class RecipeEditScreen extends StatelessWidget { children: [ Padding( padding: EdgeInsets.only( - left: 7.h, - top: 5.v, + left: 7, + top: 5, ), child: Text( "Добавить фото", @@ -234,9 +246,9 @@ class RecipeEditScreen extends StatelessWidget { ), /*if (isLoading) Container( - margin: EdgeInsets.symmetric(horizontal: 10.h), + margin: EdgeInsets.symmetric(horizontal: 10), padding: EdgeInsets.symmetric( - horizontal: 40.h, + horizontal: 40, vertical: 80.v, ), decoration: AppDecoration.fillGray.copyWith( @@ -259,11 +271,11 @@ class RecipeEditScreen extends StatelessWidget { return Container( margin: EdgeInsets.only( - left: 16.h, - right: 16.h, - bottom: 10.h, + left: 16, + right: 16, + bottom: 10, ), - padding: EdgeInsets.all(12.h), + padding: EdgeInsets.all(12), decoration: BoxDecoration( color: Colors.white, borderRadius: const BorderRadius.all(Radius.circular(12)), @@ -293,7 +305,7 @@ class RecipeEditScreen extends StatelessWidget { maxLines: 4, fillColor: appTheme.gray50, borderDecoration: OutlineInputBorder( - borderRadius: BorderRadius.circular(5.h), + borderRadius: BorderRadius.circular(5), borderSide: BorderSide( color: appTheme.gray50, width: 1, @@ -309,7 +321,13 @@ class RecipeEditScreen extends StatelessWidget { height: 200.0, // Задайте постоянную высоту элемента fit: BoxFit.cover, - placeholder: (context, url) => CircularProgressIndicator(), + placeholder: (context, url) => SizedBox( + height: 32, + width: 32, + child: RiveAnimation.asset( + 'assets/rive_animations/loading.riv', + ), + ), errorWidget: (context, url, error) => Icon(Icons.error), ) else @@ -362,11 +380,11 @@ class RecipeEditScreen extends StatelessWidget { _buildAdditional(BuildContext context, RecipeEditLoadedState state) { return Container( margin: EdgeInsets.only( - left: 16.h, - right: 16.h, - bottom: 10.h, + left: 16, + right: 16, + bottom: 10, ), - padding: EdgeInsets.all(12.h), + padding: EdgeInsets.all(12), decoration: BoxDecoration( color: Colors.white, borderRadius: const BorderRadius.all(Radius.circular(12)), @@ -391,7 +409,7 @@ class RecipeEditScreen extends StatelessWidget { hintText: "YouTube", fillColor: appTheme.gray50, borderDecoration: OutlineInputBorder( - borderRadius: BorderRadius.circular(5.h), + borderRadius: BorderRadius.circular(5), borderSide: BorderSide( color: appTheme.gray50, width: 1, @@ -415,7 +433,7 @@ class RecipeEditScreen extends StatelessWidget { initialValue: initialText, fillColor: appTheme.gray50, borderDecoration: OutlineInputBorder( - borderRadius: BorderRadius.circular(5.h), + borderRadius: BorderRadius.circular(5), borderSide: BorderSide( color: appTheme.gray50, width: 1, diff --git a/lib/presentation/recipe/recipe_select_screen/bloc/recipe_select_bloc.dart b/lib/old/recipe/recipe_select_screen/bloc/recipe_select_bloc.dart similarity index 93% rename from lib/presentation/recipe/recipe_select_screen/bloc/recipe_select_bloc.dart rename to lib/old/recipe/recipe_select_screen/bloc/recipe_select_bloc.dart index 21f14634..43cad165 100644 --- a/lib/presentation/recipe/recipe_select_screen/bloc/recipe_select_bloc.dart +++ b/lib/old/recipe/recipe_select_screen/bloc/recipe_select_bloc.dart @@ -2,16 +2,16 @@ import 'dart:async'; import 'package:dio/dio.dart'; import 'package:eatvio_app/app_router.dart'; +import 'package:eatvio_app/core/const.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:eatvio_app/old/recipe/recipe_select_screen/models/recipe_select_model.dart'; import 'package:equatable/equatable.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:go_router/go_router.dart'; import 'package:image_picker/image_picker.dart'; -import '/core/app_export.dart'; - part 'recipe_select_event.dart'; part 'recipe_select_state.dart'; diff --git a/lib/presentation/recipe/recipe_select_screen/bloc/recipe_select_event.dart b/lib/old/recipe/recipe_select_screen/bloc/recipe_select_event.dart similarity index 100% rename from lib/presentation/recipe/recipe_select_screen/bloc/recipe_select_event.dart rename to lib/old/recipe/recipe_select_screen/bloc/recipe_select_event.dart diff --git a/lib/presentation/recipe/recipe_select_screen/bloc/recipe_select_state.dart b/lib/old/recipe/recipe_select_screen/bloc/recipe_select_state.dart similarity index 100% rename from lib/presentation/recipe/recipe_select_screen/bloc/recipe_select_state.dart rename to lib/old/recipe/recipe_select_screen/bloc/recipe_select_state.dart diff --git a/lib/presentation/recipe/recipe_select_screen/models/recipe_select_model.dart b/lib/old/recipe/recipe_select_screen/models/recipe_select_model.dart similarity index 100% rename from lib/presentation/recipe/recipe_select_screen/models/recipe_select_model.dart rename to lib/old/recipe/recipe_select_screen/models/recipe_select_model.dart diff --git a/lib/presentation/recipe/recipe_select_screen/recipe_select_screen.dart b/lib/old/recipe/recipe_select_screen/recipe_select_screen.dart similarity index 82% rename from lib/presentation/recipe/recipe_select_screen/recipe_select_screen.dart rename to lib/old/recipe/recipe_select_screen/recipe_select_screen.dart index 2f7d2cc1..2d181146 100644 --- a/lib/presentation/recipe/recipe_select_screen/recipe_select_screen.dart +++ b/lib/old/recipe/recipe_select_screen/recipe_select_screen.dart @@ -1,10 +1,14 @@ import 'package:cached_network_image/cached_network_image.dart'; -import 'package:eatvio_app/core/app_export.dart'; +import 'package:eatvio_app/core/const.dart'; +import 'package:eatvio_app/core/utils/image_constant.dart'; +import 'package:eatvio_app/theme/custom_text_style.dart'; import 'package:eatvio_app/widgets/app_bar/appbar_leading_image.dart'; import 'package:eatvio_app/widgets/app_bar/appbar_subtitle.dart'; import 'package:eatvio_app/widgets/app_bar/custom_app_bar.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:go_router/go_router.dart'; +import 'package:rive/rive.dart'; import 'bloc/recipe_select_bloc.dart'; import 'models/recipe_select_model.dart'; @@ -23,7 +27,13 @@ class RecipeSelectScreen extends StatelessWidget { if (state is RecipeSelectInitialState) { return Scaffold( body: Center( - child: CircularProgressIndicator(), + child: SizedBox( + height: 32, + width: 32, + child: RiveAnimation.asset( + 'assets/rive_animations/loading.riv', + ), + ), ), ); } else if (state is RecipeSelectLoadedState) { @@ -32,7 +42,13 @@ class RecipeSelectScreen extends StatelessWidget { } else { return Scaffold( body: Center( - child: CircularProgressIndicator(), + child: SizedBox( + height: 32, + width: 32, + child: RiveAnimation.asset( + 'assets/rive_animations/loading.riv', + ), + ), ), ); } @@ -72,20 +88,20 @@ class RecipeSelectScreen extends StatelessWidget { ], ), child: CustomAppBar( - height: 54.v, - leadingWidth: 28.h, + height: 54, + leadingWidth: 28, leading: AppbarLeadingImage( imagePath: ImageConstant.imgArrowLeft, - margin: EdgeInsets.only(left: 16.h, top: 15.v, bottom: 15.v), + margin: EdgeInsets.only(left: 16, top: 15, bottom: 15), onTap: () => GoRouter.of(context).pop(), ), title: Padding( - padding: EdgeInsets.only(left: 20.h), + padding: EdgeInsets.only(left: 20), child: Row( children: [ AppbarSubtitle( text: "Рецепты", - margin: EdgeInsets.only(left: 80.h, top: 12.v, bottom: 9.v), + margin: EdgeInsets.only(left: 80, top: 12, bottom: 9), ), Spacer(), Padding( @@ -138,7 +154,13 @@ class RecipeSelectScreen extends StatelessWidget { backgroundImage: imageProvider, radius: 25, ), - placeholder: (context, url) => CircularProgressIndicator(), + placeholder: (context, url) => SizedBox( + height: 32, + width: 32, + child: RiveAnimation.asset( + 'assets/rive_animations/loading.riv', + ), + ), errorWidget: (context, url, error) => CircleAvatar( child: Icon(Icons.person), backgroundColor: Colors.white, diff --git a/lib/presentation/users/subscribers_screen/bloc/subscribers_bloc.dart b/lib/old/users/subscribers_screen/bloc/subscribers_bloc.dart similarity index 91% rename from lib/presentation/users/subscribers_screen/bloc/subscribers_bloc.dart rename to lib/old/users/subscribers_screen/bloc/subscribers_bloc.dart index f29ace07..a72d6554 100644 --- a/lib/presentation/users/subscribers_screen/bloc/subscribers_bloc.dart +++ b/lib/old/users/subscribers_screen/bloc/subscribers_bloc.dart @@ -1,17 +1,17 @@ -//import 'package:eatvio_app/presentation/auth/auth_screen/auth_screen.dart'; +//import 'package:eatvio_app/old/auth/auth_screen/auth_screen.dart'; import 'dart:async'; import 'dart:convert'; import 'package:eatvio_app/app_router.dart'; +import 'package:eatvio_app/core/const.dart'; import 'package:eatvio_app/core/token_storage.dart'; -import 'package:eatvio_app/presentation/users/subscribers_screen/models/subscribers_model.dart'; +import 'package:eatvio_app/old/users/subscribers_screen/models/subscribers_model.dart'; import 'package:equatable/equatable.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:go_router/go_router.dart'; import 'package:http/http.dart' as http; -import '/core/app_export.dart'; - part 'subscribers_event.dart'; part 'subscribers_state.dart'; diff --git a/lib/presentation/users/subscribers_screen/bloc/subscribers_event.dart b/lib/old/users/subscribers_screen/bloc/subscribers_event.dart similarity index 100% rename from lib/presentation/users/subscribers_screen/bloc/subscribers_event.dart rename to lib/old/users/subscribers_screen/bloc/subscribers_event.dart diff --git a/lib/presentation/users/subscribers_screen/bloc/subscribers_state.dart b/lib/old/users/subscribers_screen/bloc/subscribers_state.dart similarity index 100% rename from lib/presentation/users/subscribers_screen/bloc/subscribers_state.dart rename to lib/old/users/subscribers_screen/bloc/subscribers_state.dart diff --git a/lib/presentation/users/subscribers_screen/models/subscribers_model.dart b/lib/old/users/subscribers_screen/models/subscribers_model.dart similarity index 100% rename from lib/presentation/users/subscribers_screen/models/subscribers_model.dart rename to lib/old/users/subscribers_screen/models/subscribers_model.dart diff --git a/lib/presentation/users/subscribers_screen/subscribers_screen.dart b/lib/old/users/subscribers_screen/subscribers_screen.dart similarity index 86% rename from lib/presentation/users/subscribers_screen/subscribers_screen.dart rename to lib/old/users/subscribers_screen/subscribers_screen.dart index bb968f23..adef5d67 100644 --- a/lib/presentation/users/subscribers_screen/subscribers_screen.dart +++ b/lib/old/users/subscribers_screen/subscribers_screen.dart @@ -1,12 +1,17 @@ import 'package:cached_network_image/cached_network_image.dart'; -import 'package:eatvio_app/core/app_export.dart'; -import 'package:eatvio_app/presentation/feed/feed_screen/widgets/feed_search_view.dart'; +import 'package:eatvio_app/core/const.dart'; +import 'package:eatvio_app/core/utils/image_constant.dart'; +import 'package:eatvio_app/theme/custom_button_style.dart'; +import 'package:eatvio_app/theme/custom_text_style.dart'; import 'package:eatvio_app/widgets/app_bar/appbar_leading_image.dart'; import 'package:eatvio_app/widgets/app_bar/appbar_subtitle.dart'; import 'package:eatvio_app/widgets/app_bar/custom_app_bar.dart'; import 'package:eatvio_app/widgets/custom_outlined_button.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:go_router/go_router.dart'; +import 'package:rive/rive.dart' as rive; +import 'package:rive/rive.dart'; import 'bloc/subscribers_bloc.dart'; import 'models/subscribers_model.dart'; @@ -23,9 +28,12 @@ class SubscribersScreen extends StatelessWidget { builder: (context, state) { if (state is SubscribersInitialState) { // Это начальное состояние, данные ещё не загружены. - return CircularProgressIndicator( - color: Colors.white, - backgroundColor: Colors.white, + return SizedBox( + height: 32, + width: 32, + child: rive.RiveAnimation.asset( + 'assets/rive_animations/loading.riv', + ), ); } else if (state is SubscribersLoadedState) { // Данные загружены, можно строить экран. @@ -66,20 +74,20 @@ class SubscribersScreen extends StatelessWidget { ], ), child: CustomAppBar( - height: 54.v, - leadingWidth: 28.h, + height: 54, + leadingWidth: 28, leading: AppbarLeadingImage( imagePath: ImageConstant.imgArrowLeft, - margin: EdgeInsets.only(left: 16.h, top: 15.v, bottom: 15.v), + margin: EdgeInsets.only(left: 16, top: 15, bottom: 15), onTap: () => GoRouter.of(context).pop(), ), title: Padding( - padding: EdgeInsets.only(left: 20.h), + padding: EdgeInsets.only(left: 20), child: Row( children: [ AppbarSubtitle( text: "Мои подписчики", - margin: EdgeInsets.only(left: 80.h, top: 12.v, bottom: 9.v), + margin: EdgeInsets.only(left: 80, top: 12, bottom: 9), ), Spacer(), Padding( @@ -121,9 +129,6 @@ class SubscribersScreen extends StatelessWidget { padding: const EdgeInsets.all(12.0), child: Column( children: [ - CustomSearchView( - hintText: "Поиск", - ), SizedBox(height: 10), Row( children: [ @@ -188,7 +193,13 @@ class SubscribersScreen extends StatelessWidget { backgroundImage: imageProvider, radius: 25, ), - placeholder: (context, url) => CircularProgressIndicator(), + placeholder: (context, url) => SizedBox( + height: 32, + width: 32, + child: RiveAnimation.asset( + 'assets/rive_animations/loading.riv', + ), + ), errorWidget: (context, url, error) => CircleAvatar( child: Icon(Icons.person), backgroundColor: Colors.white, diff --git a/lib/presentation/feed/blog_post_screen/widgets/comment_widget.dart b/lib/presentation/feed/blog_post_screen/widgets/comment_widget.dart deleted file mode 100644 index ed2e075c..00000000 --- a/lib/presentation/feed/blog_post_screen/widgets/comment_widget.dart +++ /dev/null @@ -1,102 +0,0 @@ -// ignore_for_file: must_be_immutable - -import 'package:cached_network_image/cached_network_image.dart'; -import 'package:eatvio_app/core/app_export.dart'; -import 'package:eatvio_app/presentation/feed/blog_post_screen/models/comment_model.dart'; -import 'package:flutter/material.dart'; - -class CommentWidget extends StatelessWidget { - CommentWidget(this.commentModelObj, {Key? key}) - : super( - key: key, - ); - - CommentModel commentModelObj; - - @override - Widget build(BuildContext context) { - return Container( - margin: EdgeInsets.only( - left: 16.h, - right: 20.h, - bottom: 10.h, - ), - padding: EdgeInsets.all(12.h), - decoration: BoxDecoration( - color: Colors.white, - borderRadius: const BorderRadius.all(Radius.circular(12)), - boxShadow: [ - BoxShadow( - color: Colors.grey.withOpacity(0.5), - spreadRadius: 2, - blurRadius: 5, - offset: Offset(0, 3), - ), - ], - ), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, // Move the main axis alignment to space between - crossAxisAlignment: CrossAxisAlignment.center, // Center the items vertically - children: [ - CachedNetworkImage( - imageUrl: baseUrl + '/storage/' + commentModelObj.userImage!, - imageBuilder: (context, imageProvider) => CircleAvatar( - backgroundImage: imageProvider, - radius: 25, - ), - placeholder: (context, url) => CircularProgressIndicator(), - errorWidget: (context, url, error) => CircleAvatar( - child: Icon(Icons.person), - backgroundColor: Colors.white, - radius: 25, - ), - ), - Expanded( - child: Padding( - padding: EdgeInsets.only( - left: 12.h, - top: 2.v, - bottom: 11.v, - ), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - SizedBox( - width: 227.h, - child: Row( - children: [ - Text( - commentModelObj.username!.length <= 15 ? commentModelObj.username! : commentModelObj.username!.substring(0, 15) + '...', - style: theme.textTheme.titleMedium, - ), - Spacer(), - Padding( - padding: EdgeInsets.only(left: 6.h), - child: Text( - commentModelObj.dateText!, - style: theme.textTheme.bodyMedium, - ), - ), - ], - ), - ), - SizedBox(height: 6.v), - Text( - commentModelObj.greetingText!, - style: CustomTextStyles.bodyMediumBluegray800, - ), - ], - ), - ), - ), - CustomImageView( - imagePath: ImageConstant.imgSend, - height: 30.v, - width: 30.h, - margin: EdgeInsets.only(left: 5), - ), - ], - ), - ); - } -} diff --git a/lib/presentation/profile/my_profile_screen/my_profile_screen.dart b/lib/presentation/profile/my_profile_screen/my_profile_screen.dart deleted file mode 100644 index d10b70ab..00000000 --- a/lib/presentation/profile/my_profile_screen/my_profile_screen.dart +++ /dev/null @@ -1,964 +0,0 @@ -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 { - static Widget builder(BuildContext context) { - return BlocProvider( - create: (context) => MyProfileBloc( - MyProfileState( - myProfileModelObj: MyProfileModel(), - ), - )..add(MyProfileInitialEvent()), - child: MyProfileScreen(), - ); - } - - Widget build(BuildContext context) { - return BlocBuilder( - builder: (context, state) { - if (state is MyProfileInitialState) { - // Это начальное состояние, данные ещё не загружены. - return Scaffold( - body: Center( - child: CircularProgressIndicator(), - ), - ); - } else if (state is MyProfileLoadedState) { - // Данные загружены, можно строить экран. - return _buildMyProfileScreen(context, state); - } else if (state is MyProfileErrorState) { - // Произошла ошибка при загрузке данных. - return Center(child: Text(state.errorMessage)); - } else { - // Другие состояния, если они есть. - return Scaffold( - body: Center( - child: CircularProgressIndicator(), - ), - ); - } - }, - ); - } - - _buildMyProfileScreen(BuildContext context, MyProfileLoadedState state) { - mediaQueryData = MediaQuery.of(context); - return Scaffold( - appBar: AppBar( - toolbarHeight: 0, - automaticallyImplyLeading: false, - ), - backgroundColor: Colors.grey[200], - resizeToAvoidBottomInset: true, - body: SingleChildScrollView( - child: Container( - width: double.maxFinite, - decoration: BoxDecoration(color: Colors.grey[200]), - child: Padding( - padding: EdgeInsets.all(16), - child: Column( - children: [ - SizedBox(height: 30.v), - Container( - padding: EdgeInsets.symmetric( - horizontal: 24.h, - vertical: 12.v, - ), - decoration: BoxDecoration( - color: Colors.white, - borderRadius: const BorderRadius.all(Radius.circular(12)), - boxShadow: [ - BoxShadow( - color: Colors.grey.withOpacity(0.5), - spreadRadius: 2, - blurRadius: 5, - offset: Offset(0, 3), - ), - ], - ), - child: _buildInfo(context, state), - ), - SizedBox(height: 15.v), - Container( - padding: EdgeInsets.symmetric( - horizontal: 24.h, - vertical: 12.v, - ), - decoration: BoxDecoration( - color: Colors.white, - borderRadius: const BorderRadius.all(Radius.circular(12)), - boxShadow: [ - BoxShadow( - color: Colors.grey.withOpacity(0.5), - spreadRadius: 2, - blurRadius: 5, - offset: Offset(0, 3), - ), - ], - ), - child: _buildCarousel(context, state), - ), - SizedBox(height: 15.v), - if (!state.plans!.isEmpty) - Container( - padding: EdgeInsets.symmetric( - horizontal: 24.h, - vertical: 12.v, - ), - decoration: BoxDecoration( - color: Colors.white, - borderRadius: const BorderRadius.all(Radius.circular(12)), - boxShadow: [ - BoxShadow( - color: Colors.grey.withOpacity(0.5), - spreadRadius: 2, - blurRadius: 5, - offset: Offset(0, 3), - ), - ], - ), - child: _buildPlans( - context, - state.plans?.map((plan) => plan['name']).toList(), - state.plans?.map((plan) => plan['image']).toList(), - state.plans?.map((plan) => plan['state']).toList(), - ), - ), - SizedBox(height: 5.v), - ], - ), - ), - ), - ), - ); - } - - /// Section Widget - _buildInfo(BuildContext context, MyProfileLoadedState state) { - return Column( - children: [ - GestureDetector( - onTap: () => addImage(context), - child: CachedNetworkImage( - imageUrl: baseUrl + '/storage/' + (state.user?['profile_photo_path'] ?? ''), - imageBuilder: (context, imageProvider) => CircleAvatar( - backgroundImage: imageProvider, - radius: 60, - ), - placeholder: (context, url) => CircularProgressIndicator(), - errorWidget: (context, url, error) => CircleAvatar( - child: Icon(Icons.person), - backgroundColor: Colors.white, - radius: 60, - ), - ), - ), - AppbarSubtitle(text: state.user?['name'] ?? ''), - SizedBox(height: 20.v), - Text(state.userDetails?['additional_info'] ?? ''), - ], - ); - } - - addImage(BuildContext context) async { - final picker = ImagePicker(); - XFile? image = await picker.pickImage(source: ImageSource.gallery); - if (image != null) { - context.read().add(UploadAvatar(image)); - } - } - - onTapSettings(BuildContext context) { - return () { - GoRouter.of(context).goNamed('mySettingsScreen'); - }; - } - - _buildCarousel(BuildContext contex, MyProfileLoadedState state) { - return CarouselSlider( - options: CarouselOptions(height: 340), - items: [1, 2, 3].map((chartType) { - return Builder( - builder: (BuildContext context) { - switch (chartType) { - case 1: // График веса - return GestureDetector( - onTap: () => _editWeight(context, state), - child: Column( - children: [ - Text( - "weight_chart".tr, - style: CustomTextStyles.titleMediumBlack.copyWith( - color: appTheme.black900, - ), - ), - 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, - ), - ], - ), - ); - case 2: // График ИМТ - return Column( - children: [ - Text( - "bodymass_chart".tr, - style: CustomTextStyles.titleMediumBlack.copyWith( - color: appTheme.black900, - ), - ), - 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, - ), - ], - ); - case 3: //График обхватов - return GestureDetector( - onTap: () => _editCircumference(context, state), - child: Column( - children: [ - Text( - "circumferences_chart".tr, - style: CustomTextStyles.titleMediumBlack.copyWith( - color: appTheme.black900, - ), - ), - SizedBox(height: 30.v), - _buildCircumferenceChart(context, state.circumferences, state.chartDates), - _buildChartLegend(), - ], - ), - ); - default: - return Text('text', style: TextStyle(fontSize: 16.0)); - } - }, - ); - }).toList(), - ); - } - - _buildChartLegend() { - final colors = [Colors.pink, Colors.green, Colors.purple]; - final titles = ["chest".tr, "waist".tr, "hips".tr]; - final style = TextStyle( - color: Colors.black, - fontWeight: FontWeight.bold, - ); - return Column( - children: [ - Row( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - children: [ - for (var i = 0; i < colors.length; i++) - Container( - child: Row( - children: [ - Container( - width: 16, - height: 16, - color: colors[i], - ), - SizedBox(width: 8), - Text(titles[i], style: style), - ], - ), - ), - ], - ), - ], - ); - } - - _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]), - ); - } - - 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: 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) { - return Padding( - padding: EdgeInsets.only(left: 7.h), - child: Column( - children: [ - Padding( - padding: EdgeInsets.only(left: 15.h), - child: Text("plans_complete".tr, style: CustomTextStyles.titleMediumBlack.copyWith(color: appTheme.black900)), - ), - SizedBox(height: 5.v), - Container( - decoration: AppDecoration.outlineBlueGray.copyWith(borderRadius: BorderRadiusStyle.roundedBorder5), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - SizedBox( - height: 105.v, - width: 343.h, - child: Stack( - alignment: Alignment.bottomCenter, - children: [ - Align( - alignment: Alignment.topCenter, - child: ListView.builder( - itemCount: plans?.length ?? 0, - itemBuilder: (context, i) { - String state = states?[i]; - var boxColor = appTheme.greenA700; - switch (states?[i]) { - case 'active': - boxColor = appTheme.greenA700; - break; - case 'archived': // График ИМТ - boxColor = appTheme.gray400; - break; - case 'draft': - boxColor = appTheme.deepOrange900; - break; - case 'in_progress': //График обхватов - boxColor = appTheme.lightGreen300; - break; - } - return SizedBox( - height: 40.v, - width: 343.h, - child: Stack( - alignment: Alignment.bottomRight, - children: [ - Align( - alignment: Alignment.topCenter, - child: Container( - margin: EdgeInsets.only(bottom: 11.v), - padding: EdgeInsets.symmetric(horizontal: 6.h, vertical: 4.v), - decoration: AppDecoration.fillGray.copyWith(borderRadius: BorderRadiusStyle.roundedBorder5), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Padding( - padding: EdgeInsets.only(bottom: 1.v), - child: Text(plans![i], style: CustomTextStyles.titleSmallBluegray800Bold), - ), - Container( - height: 19.v, - width: 100.h, - decoration: BoxDecoration(color: boxColor, borderRadius: BorderRadius.circular(5.h)), - ), - ], - ), - ), - ), - Align( - alignment: Alignment.center, - child: Container( - margin: EdgeInsets.only(bottom: 12.h), - child: Image.network( - baseUrl + '/storage/' + imagePaths?[i], - height: 25.adaptSize, - width: 25.adaptSize, - ), - ), - ), - Align( - alignment: Alignment.bottomRight, - child: Container( - width: 70.h, - margin: EdgeInsets.only(bottom: 14.h, right: 22.h), - child: Text("$state".tr, maxLines: 3, overflow: TextOverflow.ellipsis, style: theme.textTheme.titleSmall), - ), - ), - ], - ), - ); - }, - ), - ), - ], - ), - ), - ], - ), - ), - ], - ), - ); - } - - List _bodyMassIndex(List weightPoints, int height) { - List bmiList = []; - for (double weight in weightPoints) { - double bmi = weight / ((height / 100) * (height / 100)); - bmiList.add(bmi); - } - return bmiList; - } - - _editCircumference(BuildContext context, MyProfileLoadedState state) { - showDialog( - context: context, - builder: (context) { - //final digitsOnly = FilteringTextInputFormatter.digitsOnly; - return AlertDialog( - title: Center(child: Text("Добавить замер")), - - content: SizedBox( - width: 200, // Ширина диалогового окна - height: 300, // Высота диалогового окна - child: ListView( - children: [ - Padding( - padding: EdgeInsets.symmetric(vertical: 5.v), - child: Text("chest_circumference".tr, style: theme.textTheme.bodyLarge), - ), - SizedBox(height: 5.v), - CustomTextFormField( - controller: state.chestCircumferenceController, - keyboardType: TextInputType.number, - inputFormatters: [ - FilteringTextInputFormatter.digitsOnly, // Ограничение ввода только цифрами - ], - ), - Padding( - padding: EdgeInsets.symmetric(vertical: 15.v), - child: Text("waist_circumference".tr, style: theme.textTheme.bodyLarge), - ), - SizedBox(height: 5.v), - CustomTextFormField( - controller: state.waistCircumferenceController, - keyboardType: TextInputType.number, - inputFormatters: [ - FilteringTextInputFormatter.digitsOnly, // Ограничение ввода только цифрами - ], - ), - Padding( - padding: EdgeInsets.symmetric(vertical: 15.v), - child: Text("hip_circumference".tr, style: theme.textTheme.bodyLarge), - ), - SizedBox(height: 5.v), - CustomTextFormField( - controller: state.hipCircumferenceController, - keyboardType: TextInputType.number, - inputFormatters: [ - FilteringTextInputFormatter.digitsOnly, // Ограничение ввода только цифрами - ], - ), - ], - ), - ), - actions: [ - TextButton( - onPressed: onTapOk(context), - child: Text("Отмена", style: theme.textTheme.bodyLarge), - ), - TextButton( - onPressed: sendEditData(state, context), - child: Text( - "Изменить", - style: CustomTextStyles.titleMediumBlack.copyWith( - color: Colors.blue, - ), - ), - ), - ], - backgroundColor: Colors.white, - titlePadding: EdgeInsets.all(20.0), // Можете настроить отступы по вашему желанию - ); - }, - ); - } - - sendEditData(MyProfileLoadedState state, BuildContext context) { - return () async { - Map data = { - "chest_circumference": state.chestCircumferenceController?.text, - "waist_circumference": state.waistCircumferenceController?.text, - "hip_circumference": state.hipCircumferenceController?.text, - }; - - // Преобразование Map в JSON - String jsonData = json.encode(data); - - // Отправка HTTP-запроса - try { - final token = state.token; - final response = await http.post( - Uri.parse(baseUrl + '/api/profile/addCircumference'), - headers: { - 'Content-Type': 'application/json', - 'Authorization': 'Bearer $token', - }, - body: jsonData, - ); - - if (response.statusCode == 201) { - GoRouter.of(context).go('/my-profile-screen'); - } else { - // Ошибка от сервера - print("Ошибка при отправке данных. Код ответа: ${response.statusCode}"); - } - } catch (e) { - // Обработка ошибок при отправке запроса - print("Ошибка при отправке запроса: $e"); - } - Navigator.pop(context); - }; - } - - _editWeight(BuildContext context, MyProfileLoadedState state) { - showDialog( - context: context, - builder: (context) { - return AlertDialog( - content: SizedBox( - width: 200, // Ширина диалогового окна - height: 100, // Высота диалогового окна - child: ListView( - children: [ - Padding( - padding: EdgeInsets.symmetric(vertical: 5), - child: Text("weight".tr, style: theme.textTheme.bodyLarge), - ), - SizedBox(height: 5), - CustomTextFormField( - controller: state.weightController, - keyboardType: TextInputType.number, - inputFormatters: [ - FilteringTextInputFormatter.digitsOnly, - ], - ), - ], - ), - ), - actions: [ - TextButton( - onPressed: () => Navigator.of(context).pop(), - child: Text("Отмена", style: theme.textTheme.bodyLarge), - ), - TextButton( - onPressed: () => saveWeight(state, context), - child: Text( - "Изменить", - style: CustomTextStyles.titleMediumBlack.copyWith( - color: Colors.blue, - ), - ), - ), - ], - backgroundColor: Colors.white, - titlePadding: EdgeInsets.all(20.0), - ); - }, - ); - } - - void saveWeight(MyProfileLoadedState state, BuildContext context) { - addWeight(state, context); - Navigator.of(context).pop(); // Закрыть диалоговое окно после изменения веса - } - - onTapOk(BuildContext context) { - return () { - Navigator.pop(context); - }; - } - - addWeight(MyProfileLoadedState state, BuildContext context) { - return () async { - Map data = { - "weight": state.weightController!.text, - }; - // Преобразование Map в JSON - String jsonData = json.encode(data); - - // Отправка HTTP-запроса - try { - final token = state.token; - final response = await http.post( - Uri.parse(baseUrl + '/api/profile/addWeight'), - headers: { - 'Content-Type': 'application/json', - 'Authorization': 'Bearer $token', - }, - body: jsonData, - ); - - if (response.statusCode == 201) { - GoRouter.of(context).go('/my-profile-screen'); - } else { - // Ошибка от сервера - print("Ошибка при отправке данных. Код ответа: ${response.statusCode}"); - } - } catch (e) { - // Обработка ошибок при отправке запроса - print("Ошибка при отправке запроса: $e"); - } - }; - } -} 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 deleted file mode 100644 index 2ae1d76d..00000000 --- a/lib/presentation/recipe/recipe_show_screen/bloc/recipe_show_bloc.dart +++ /dev/null @@ -1,199 +0,0 @@ -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:http/http.dart' as http; -import 'package:intl/intl.dart'; - -import '/core/app_export.dart'; - -part 'recipe_show_event.dart'; -part 'recipe_show_state.dart'; - -/// A bloc that manages the state of a Recipe according to the event that is dispatched to it. -class RecipeBloc extends Bloc { - RecipeBloc(RecipeState initialState) : super(initialState) { - on(_onInitialize); - on(_deleteEntry); - on(_createComment); - } - - _onInitialize( - RecipeInitialEvent event, - Emitter emit, - ) async { - try { - 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 ${await TokenStorage.getTokenFromStorage()}', - }, - ); - if (response.statusCode == 200) { - final data = jsonDecode(response.body); - if (data is Map) { - if (state is RecipeLoadedState) { - var currentState = state as RecipeLoadedState; - emit( - currentState.copyWith( - recipeModelObj: currentState.recipeModelObj, - recipe: currentState.recipe, - token: currentState.token, - commentController: currentState.commentController, - comments: currentState.comments, - steps: currentState.steps, - author: currentState.author, - ), - ); - } else { - emit( - RecipeLoadedState( - token: await TokenStorage.getTokenFromStorage(), - recipe: data, - steps: data['steps'], - author: await _fetchAuthor(data['id']), - comments: fillCommentList(await _fetchComments(data['id'])), - tags: await _fetchTags(data['id']), - commentController: TextEditingController(), - ), - ); - } - } else { - // Один или несколько ключевых полей отсутствуют, обрабатываем ошибку - emit(RecipeErrorState('Некоторые необходимые данные отсутствуют.')); - } - } else { - // Статус ответа не равен 200, обрабатываем ошибку - emit(RecipeErrorState('Ошибка сервера: ${response.statusCode}')); - } - } catch (e) { - // Ошибка при декодировании JSON или другая ошибка выполнения - emit(RecipeErrorState('Ошибка при получении данных о чатах: $e')); - } - } - - FutureOr _deleteEntry(DeleteEntry event, Emitter emit) async { - 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 ${await TokenStorage.getTokenFromStorage()}', - }, - ); - if (response.statusCode == 200) { - AppRouter.navigatorKey.currentContext?.goNamed('recipeSelectScreen'); - } else { - // Статус ответа не равен 200, обрабатываем ошибку - emit(RecipeErrorState('Ошибка: ${response.statusCode}')); - } - } - - FutureOr _createComment(CreateComment event, Emitter emit) async { - if (state is RecipeLoadedState) { - var currentState = state as RecipeLoadedState; - // Отправляем данные по HTTP маршруту и ждем ответ - var response = await _sendCommentData(currentState.token, event.body, currentState.recipe?['id']); - if (response.statusCode == 200) { - var updatedComments = fillCommentList(await _fetchComments(currentState.recipe?['id'])); - var updatedState = currentState.copyWith( - comments: updatedComments, - commentController: TextEditingController(), // Clear the comment input field - ); - emit(updatedState); // Emit the updated state to trigger a screen update - } - } - } - - _fetchAuthor(int id) async { - if (!await TokenStorage.haveTokenInStorage()) { - AppRouter.navigatorKey.currentContext?.goNamed('authScreen'); - } - - final response = await http.get( - Uri.parse(baseUrl + '/api/recipes/getAuthor/$id'), - headers: { - 'Authorization': 'Bearer ${await TokenStorage.getTokenFromStorage()}', - }, - ); - final data = jsonDecode(response.body); - return data; - } - - Future _fetchComments(int id) async { - if (!await TokenStorage.haveTokenInStorage()) { - AppRouter.navigatorKey.currentContext?.goNamed('authScreen'); - } - final response = await http.get( - Uri.parse(baseUrl + '/api/recipes/getComments/$id'), - headers: { - 'Authorization': 'Bearer ${await TokenStorage.getTokenFromStorage()}', - }, - ); - final data = jsonDecode(response.body); - return data; - } - - _fetchTags(int id) async { - if (!await TokenStorage.haveTokenInStorage()) { - AppRouter.navigatorKey.currentContext?.goNamed('authScreen'); - } - - final response = await http.get( - Uri.parse(baseUrl + '/api/recipes/getTags/$id'), - headers: { - 'Authorization': 'Bearer ${await TokenStorage.getTokenFromStorage()}', - }, - ); - final data = jsonDecode(response.body); - return data; - } - - List fillCommentList(List comments) { - List list = []; - for (int i = 0; i < comments.length; i++) { - list.add( - CommentModel( - id: comments[i]['id'].toString(), - userImage: comments[i]['profile_photo_path'], - username: comments[i]['name'], - dateText: DateFormat('dd.MM').format(DateTime.parse(comments[i]['updated_at'])), - greetingText: comments[i]['body'], - ), - ); - } - return list; - } - - Future _sendCommentData(String? token, String body, int id) async { - String url = baseUrl + '/api/recipes/createComment/$id'; - final Map credentials = { - 'id': id, - 'body': body, - }; - - var response = await http.post( - Uri.parse(url), - headers: { - 'Content-Type': 'application/json', - 'Authorization': 'Bearer $token', - }, - body: json.encode(credentials), - encoding: utf8, - ); - - return response; - } -} diff --git a/lib/presentation/recipe/recipe_show_screen/bloc/recipe_show_event.dart b/lib/presentation/recipe/recipe_show_screen/bloc/recipe_show_event.dart deleted file mode 100644 index f2e71b7b..00000000 --- a/lib/presentation/recipe/recipe_show_screen/bloc/recipe_show_event.dart +++ /dev/null @@ -1,34 +0,0 @@ -// ignore_for_file: must_be_immutable - -part of 'recipe_show_bloc.dart'; - -/// Abstract class for all events that can be dispatched from the -///Recipe widget. -/// -/// Events must be immutable and implement the [Equatable] interface. -@immutable -abstract class RecipeEvent extends Equatable {} - -/// Event that is dispatched when the Recipe widget is first created. -class RecipeInitialEvent extends RecipeEvent { - @override - List get props => []; -} - -class DeleteEntry extends RecipeEvent { - DeleteEntry(this.id); - - final int id; - - @override - List get props => [id]; -} - -class CreateComment extends RecipeEvent { - CreateComment(this.body); - - final String body; - - @override - List get props => [body]; -} diff --git a/lib/presentation/recipe/recipe_show_screen/bloc/recipe_show_state.dart b/lib/presentation/recipe/recipe_show_screen/bloc/recipe_show_state.dart deleted file mode 100644 index 0b7b2e83..00000000 --- a/lib/presentation/recipe/recipe_show_screen/bloc/recipe_show_state.dart +++ /dev/null @@ -1,91 +0,0 @@ -// ignore_for_file: must_be_immutable - -part of 'recipe_show_bloc.dart'; - -/// Represents the state of Recipe in the application. -/// - -class RecipeState extends Equatable { - RecipeState({ - this.recipeModelObj, - }); - - RecipeModel? recipeModelObj; - - @override - List get props => [recipeModelObj]; - - RecipeState copyWith({RecipeModel? recipeModelObj}) { - return RecipeState( - recipeModelObj: recipeModelObj ?? this.recipeModelObj, - ); - } -} - -class RecipeLoadedState extends RecipeState { - RecipeLoadedState({ - this.recipeModelObj, - this.recipe, - this.author, - this.comments, - this.token, - this.commentController, - this.tags, - this.steps, - }); - - RecipeModel? recipeModelObj; - Map? recipe; - Map? author; - List? comments; - TextEditingController? commentController; - List? steps; - List? tags; - String? token; - - @override - List get props => [ - recipeModelObj, - recipe, - author, - comments, - token, - commentController, - steps, - ]; - - RecipeLoadedState copyWith({ - RecipeModel? recipeModelObj, - Map? recipe, - Map? author, - TextEditingController? commentController, - String? token, - List? tags, - List? steps, - List? comments, - }) { - return RecipeLoadedState( - recipeModelObj: recipeModelObj ?? this.recipeModelObj, - recipe: recipe ?? this.recipe, - author: author ?? this.author, - tags: tags ?? this.tags, - token: token ?? this.token, - commentController: commentController ?? this.commentController, - steps: steps ?? this.steps, - comments: comments ?? this.comments, - ); - } -} - -class RecipeErrorState extends RecipeState { - final String errorMessage; - - RecipeErrorState(this.errorMessage); - - @override - List get props => [errorMessage]; -} - -class RecipeInitialState extends RecipeState { - RecipeInitialState({required RecipeModel recipeModelObj}) : super(recipeModelObj: recipeModelObj); -} diff --git a/lib/presentation/recipe/recipe_show_screen/models/recipe_show_model.dart b/lib/presentation/recipe/recipe_show_screen/models/recipe_show_model.dart deleted file mode 100644 index 1786388e..00000000 --- a/lib/presentation/recipe/recipe_show_screen/models/recipe_show_model.dart +++ /dev/null @@ -1,19 +0,0 @@ -// ignore_for_file: must_be_immutable - -import 'package:equatable/equatable.dart'; - -/// This class defines the variables used in the [recipe_screen], -/// and is typically used to hold data that is passed between different parts of the application. - -class RecipeModel extends Equatable { - final String recipeID; - - RecipeModel({required String recipeID}) : recipeID = recipeID; - - RecipeModel copyWith(String recipeID) { - return RecipeModel(recipeID: recipeID); - } - - @override - List get props => [recipeID]; -} diff --git a/lib/presentation/recipe/recipe_show_screen/recipe_show_screen.dart b/lib/presentation/recipe/recipe_show_screen/recipe_show_screen.dart deleted file mode 100644 index c42813d4..00000000 --- a/lib/presentation/recipe/recipe_show_screen/recipe_show_screen.dart +++ /dev/null @@ -1,473 +0,0 @@ -import 'package:cached_network_image/cached_network_image.dart'; -import 'package:eatvio_app/core/app_export.dart'; -import 'package:eatvio_app/presentation/feed/blog_post_screen/widgets/comment_widget.dart'; -import 'package:eatvio_app/widgets/custom_edit_text_form_field.dart'; -import 'package:eatvio_app/widgets/custom_outlined_button.dart'; -import 'package:flutter/material.dart'; -import 'package:go_router/go_router.dart'; -import 'package:intl/intl.dart'; - -import 'bloc/recipe_show_bloc.dart'; -import 'models/recipe_show_model.dart'; - -class RecipeScreen extends StatelessWidget { - const RecipeScreen({Key? key}) : super(key: key); - - static Widget builder(BuildContext context) { - final recipeID = ModalRoute.of(context)!.settings.arguments; - return BlocProvider( - create: (context) => RecipeBloc(RecipeState(recipeModelObj: RecipeModel(recipeID: recipeID.toString())))..add(RecipeInitialEvent()), - child: RecipeScreen(), - ); - } - - Widget build(BuildContext context) { - return BlocBuilder( - builder: (context, state) { - if (state is RecipeInitialState) { - // Это начальное состояние, данные ещё не загружены. - return Container( - color: Colors.white, - ); - } else if (state is RecipeLoadedState) { - // Данные загружены, можно строить экран. - return _buildRecipe(context, state); - } else if (state is RecipeErrorState) { - // Произошла ошибка при загрузке данных. - return Center(child: Text(state.errorMessage)); - } else { - // Другие состояния, если они есть. - return Container(); // Пустой контейнер для необработанных состояний. - } - }, - ); - } - - _buildRecipe(BuildContext context, RecipeLoadedState state) { - mediaQueryData = MediaQuery.of(context); - List steps = []; - if (state.steps != null) { - for (int i = 0; i < state.steps!.length; i++) { - steps.add(_buildStep(context, state, i)); - } - } - return Scaffold( - appBar: AppBar( - toolbarHeight: 0, - automaticallyImplyLeading: false, - ), - resizeToAvoidBottomInset: false, - body: Container( - width: double.maxFinite, - decoration: AppDecoration.fillGray, - child: ListView( - children: [ - SizedBox(height: 15.v), - _buildHeaderRow(context, state), - SizedBox(height: 15.v), - _buildRecipeData(context, state), - SizedBox(height: 15.v), - Column( - crossAxisAlignment: CrossAxisAlignment.stretch, - children: steps, - ), - SizedBox(height: 15.v), - _buildTextField(context, state), - SizedBox(height: 15.v), - _buildCommentSection(context, state), - ], - ), - ), - ); - } - - _buildHeaderRow(BuildContext context, RecipeLoadedState state) { - final String name = state.author?['name']; - return Container( - margin: EdgeInsets.symmetric(horizontal: 16.h, vertical: 16.h), - padding: EdgeInsets.symmetric( - horizontal: 24.h, - vertical: 12.v, - ), - decoration: BoxDecoration( - color: Colors.white, - borderRadius: const BorderRadius.all(Radius.circular(12)), - boxShadow: [ - BoxShadow( - color: Colors.grey.withOpacity(0.5), - spreadRadius: 2, - blurRadius: 5, - offset: Offset(0, 3), - ), - ], - ), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - CustomImageView( - imagePath: ImageConstant.imgArrowLeft, - onTap: () => GoRouter.of(context).pop(), - ), - Padding( - padding: EdgeInsets.only(top: 1.v), - child: Row( - children: [ - Align( - alignment: Alignment.centerRight, - child: Text( - "$name", - style: CustomTextStyles.titleMediumBlack, - ), - ), - CachedNetworkImage( - imageUrl: baseUrl + '/storage/' + (state.author?['profile_photo_path'] ?? ''), - imageBuilder: (context, imageProvider) => CircleAvatar( - backgroundImage: imageProvider, - radius: 25, - ), - placeholder: (context, url) => CircularProgressIndicator(), - errorWidget: (context, url, error) => CircleAvatar( - child: Icon(Icons.person), - backgroundColor: Colors.white, - radius: 25, - ), - ), - ], - ), - ), - ], - ), - ); - } - - _buildRecipeData(BuildContext context, RecipeLoadedState state) { - return Container( - margin: EdgeInsets.only( - left: 16.h, - right: 20.h, - bottom: 10.h, - ), - padding: EdgeInsets.all(12.h), - decoration: BoxDecoration( - color: Colors.white, - borderRadius: const BorderRadius.all(Radius.circular(12)), - boxShadow: [ - BoxShadow( - color: Colors.grey.withOpacity(0.5), - spreadRadius: 2, - blurRadius: 5, - offset: Offset(0, 3), - ), - ], - ), - child: Column( - mainAxisSize: MainAxisSize.min, - children: [ - Row( - children: [ - Text( - state.recipe?['title'], - style: CustomTextStyles.titleMediumBlack, - ), - Spacer(), - PopupMenuButton( - onSelected: (value) => tapMenu(value, context, state), - itemBuilder: (BuildContext context) => >[ - PopupMenuItem( - value: 'edit', - child: Text('Редактировать'), - ), - PopupMenuItem( - value: 'delete', - child: Text('Удалить'), - ), - ], - ), - ], - ), - SizedBox(height: 8.0), - _buildImage(state), - SizedBox(height: 16.0), - Text( - state.recipe?['description'], - style: CustomTextStyles.bodyMediumBluegray800, - ), - SizedBox(height: 16.0), - Align( - alignment: Alignment.topLeft, - child: Text( - DateFormat('dd.MM.yyyy').format(DateTime.parse(state.recipe?['updated_at'])), - style: theme.textTheme.bodyMedium, - ), - ), - SizedBox(height: 16.0), - _buildTags(state.tags), - SizedBox(height: 16.0), - Row( - children: [ - Padding( - padding: EdgeInsets.only(left: 24), - child: Row( - children: [ - Padding( - padding: EdgeInsets.only(right: 8), - child: Icon(Icons.favorite_outline), - ), - Text( - "Нравится", - style: CustomTextStyles.titleMediumSemiBold, - ), - ], - ), - ), - Spacer(), - Padding( - padding: EdgeInsets.only(right: 24), - child: Row( - children: [ - Padding( - padding: const EdgeInsets.only(right: 8), - child: Icon(Icons.share_outlined), - ), - Text( - "Поделиться", - style: CustomTextStyles.titleMediumSemiBold, - ), - ], - ), - ), - ], - ), - ], - ), - ); - } - - _buildTags(List? tags) { - return Wrap( - spacing: 8.0, - runSpacing: 4.0, - children: tags!.map((tag) { - return Chip( - label: Text(tag['name']), - ); - }).toList(), - ); - } - - _buildImage(RecipeLoadedState state) { - return CachedNetworkImage( - imageUrl: baseUrl + '/storage/' + (state.recipe?['image'] ?? ''), - imageBuilder: (context, imageProvider) => Stack( - children: [ - ClipRRect( - borderRadius: const BorderRadius.all(Radius.circular(8.0)), - child: Image( - image: imageProvider, - ), - ), - Positioned( - bottom: 0, - left: 0, - right: 0, - child: Container( - padding: EdgeInsets.symmetric(horizontal: 8.0, vertical: 4.0), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Padding( - padding: const EdgeInsets.only(left: 48.0), - child: Row( - children: [ - Icon( - Icons.remove_red_eye, - color: Colors.white, - ), - SizedBox(width: 4.0), - Text( - '24', - style: TextStyle(color: Colors.white), - ), - ], - ), - ), - Row( - children: [ - Icon( - Icons.favorite, - color: Colors.white, - ), - SizedBox(width: 4.0), - Text( - '24', - style: TextStyle(color: Colors.white), - ), - ], - ), - Padding( - padding: const EdgeInsets.only(right: 48.0), - child: Row( - children: [ - Icon( - Icons.comment_outlined, - color: Colors.white, - ), - SizedBox(width: 4.0), - Text( - '${state.comments?.length}', - style: TextStyle(color: Colors.white), - ), - ], - ), - ), - ], - ), - ), - ), - ], - ), - placeholder: (context, url) => CircularProgressIndicator(), - ); - } - - void tapMenu(String value, BuildContext context, RecipeLoadedState state) { - if (value == 'edit') { - GoRouter.of(context).goNamed( - 'recipeEditScreen', - extra: state.recipe?['id'].toString(), - ); - } else if (value == 'delete') { - context.read().add(DeleteEntry(state.recipe?['id'])); - } - } - - _buildTextField(BuildContext context, RecipeLoadedState state) { - return Container( - margin: EdgeInsets.only( - left: 16.h, - right: 20.h, - bottom: 10.h, - ), - padding: EdgeInsets.all(12.h), - decoration: BoxDecoration( - color: Colors.white, - borderRadius: const BorderRadius.all(Radius.circular(12)), - boxShadow: [ - BoxShadow( - color: Colors.grey.withOpacity(0.5), - spreadRadius: 2, - blurRadius: 5, - offset: Offset(0, 3), - ), - ], - ), - child: Column( - mainAxisSize: MainAxisSize.min, - children: [ - Column( - children: [ - CustomTextFormField( - controller: state.commentController, - maxLines: 4, - ), - SizedBox(height: 15.h), - CustomOutlinedButton( - text: "Оставить отзыв", - margin: EdgeInsets.only(bottom: 5), - buttonStyle: CustomButtonStyles.outlinePrimaryTL15, - decoration: BoxDecoration( - color: Colors.transparent, - ), - onPressed: () => context.read().add(CreateComment(state.commentController!.text)), - // Установите прозрачный фон - ), - ], - ), - ], - ), - ); - } - - _buildCommentSection(BuildContext context, RecipeLoadedState state) { - if (state.comments != null && state.comments!.isNotEmpty) { - return Column( - crossAxisAlignment: CrossAxisAlignment.stretch, - children: [ - for (int i = 0; i < state.comments!.length; i++) - Column( - crossAxisAlignment: CrossAxisAlignment.stretch, - children: [ - CommentWidget(state.comments![i]), - SizedBox(height: 10.0), // Separator - ], - ), - ], - ); - } else { - // Return a message or placeholder widget when there are no comments - return Column( - children: [ - Center( - child: Text('No comments available'), - ), - SizedBox( - height: 20, - ), - ], - ); - } - } - - /// Navigates to the previous screen. - onTapArrowleftone(BuildContext context) { - GoRouter.of(context).pop(); - } - - Widget _buildStep(BuildContext context, RecipeLoadedState state, int i) { - return Container( - margin: EdgeInsets.only( - left: 16.h, - right: 16.h, - bottom: 10.h, - ), - padding: EdgeInsets.all(12.h), - decoration: BoxDecoration( - color: Colors.white, - borderRadius: const BorderRadius.all(Radius.circular(12)), - boxShadow: [ - BoxShadow( - color: Colors.grey.withOpacity(0.5), - spreadRadius: 2, - blurRadius: 5, - offset: Offset(0, 3), - ), - ], - ), - child: Column( - mainAxisSize: MainAxisSize.min, - children: [ - Align( - alignment: Alignment.centerLeft, - child: Text( - "Шаг ${i + 1}", - style: CustomTextStyles.titleMediumSemiBold, - ), - ), - SizedBox(height: 16.0), - CachedNetworkImage( - imageUrl: baseUrl + '/storage/' + (state.steps?[i]['image']), - width: double.infinity, - // Установите ширину равной ширине родительского элемента - height: 200.0, - // Задайте постоянную высоту элемента - fit: BoxFit.cover, - placeholder: (context, url) => CircularProgressIndicator(), - errorWidget: (context, url, error) => Icon(Icons.error), - ), - SizedBox(height: 16.0), - Text(state.steps?[i]['description']), - ], - ), - ); - } -} diff --git a/lib/theme/app_decoration.dart b/lib/theme/app_decoration.dart index c84477ef..3868338c 100644 --- a/lib/theme/app_decoration.dart +++ b/lib/theme/app_decoration.dart @@ -1,4 +1,4 @@ -import 'package:eatvio_app/core/app_export.dart'; +import 'package:eatvio_app/theme/theme_helper.dart'; import 'package:flutter/material.dart'; class AppDecoration { @@ -12,7 +12,7 @@ class AppDecoration { color: theme.colorScheme.onPrimary, border: Border.all( color: appTheme.blueA400, - width: 1.h, + width: 1, ), ); @@ -20,7 +20,7 @@ class AppDecoration { color: theme.colorScheme.onPrimary, border: Border.all( color: theme.colorScheme.primary, - width: 1.h, + width: 1, ), ); @@ -55,7 +55,7 @@ class AppDecoration { static BoxDecoration get outlineBlueGray => BoxDecoration( border: Border.all( color: appTheme.blueGray800, - width: 1.h, + width: 1, strokeAlign: strokeAlignOutside, ), ); @@ -64,12 +64,12 @@ class AppDecoration { class BorderRadiusStyle { // Circle borders static BorderRadius get circleBorder8 => BorderRadius.circular( - 8.h, + 8, ); // Rounded borders static BorderRadius get roundedBorder1 => BorderRadius.circular( - 1.h, + 1, ); // Outline decorations @@ -78,8 +78,8 @@ class BorderRadiusStyle { boxShadow: [ BoxShadow( color: appTheme.black900.withOpacity(0.15), - spreadRadius: 2.h, - blurRadius: 2.h, + spreadRadius: 2, + blurRadius: 2, offset: Offset( 0, 2, @@ -91,66 +91,54 @@ class BorderRadiusStyle { static BoxDecoration get outlineBlueGray => BoxDecoration( border: Border.all( color: appTheme.blueGray800, - width: 1.h, + width: 1, strokeAlign: strokeAlignOutside, ), ); // Circle borders static BorderRadius get circleBorder17 => BorderRadius.circular( - 17.h, + 17, ); static BorderRadius get circleBorder20 => BorderRadius.circular( - 20.h, + 20, ); static BorderRadius get circleBorder62 => BorderRadius.circular( - 62.h, + 62, ); // Custom borders static BorderRadius get customBorderBL8 => BorderRadius.only( - bottomLeft: Radius.circular(8.h), + bottomLeft: Radius.circular(8), ); static BorderRadius get customBorderTL5 => BorderRadius.vertical( - top: Radius.circular(5.h), + top: Radius.circular(5), ); static BorderRadius get customBorderTL51 => BorderRadius.only( - topLeft: Radius.circular(5.h), - bottomRight: Radius.circular(5.h), + topLeft: Radius.circular(5), + bottomRight: Radius.circular(5), ); // Rounded borders static BorderRadius get roundedBorder12 => BorderRadius.circular( - 12.h, + 12, ); static BorderRadius get roundedBorder5 => BorderRadius.circular( - 5.h, + 5, ); static BorderRadius get roundedBorder8 => BorderRadius.circular( - 8.h, + 8, ); } -// Comment/Uncomment the below code based on your Flutter SDK version. - -// For Flutter SDK Version 3.7.2 or greater. - double get strokeAlignInside => BorderSide.strokeAlignInside; double get strokeAlignCenter => BorderSide.strokeAlignCenter; double get strokeAlignOutside => BorderSide.strokeAlignOutside; - -// For Flutter SDK Version 3.7.1 or less. - -// StrokeAlign get strokeAlignInside => StrokeAlign.inside; -// -// StrokeAlign get strokeAlignCenter => StrokeAlign.center; -// -// StrokeAlign get strokeAlignOutside => StrokeAlign.outside; diff --git a/lib/theme/custom_button_style.dart b/lib/theme/custom_button_style.dart index bcd021c1..57e3ca9e 100644 --- a/lib/theme/custom_button_style.dart +++ b/lib/theme/custom_button_style.dart @@ -1,4 +1,4 @@ -import 'package:eatvio_app/core/app_export.dart'; +import 'package:eatvio_app/theme/theme_helper.dart'; import 'package:flutter/material.dart'; /// A class that offers pre-defined button styles for customizing button appearance. @@ -11,7 +11,7 @@ class CustomButtonStyles { width: 0, ), shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(15.h), + borderRadius: BorderRadius.circular(15), ), ); diff --git a/lib/theme/custom_text_style.dart b/lib/theme/custom_text_style.dart index 1ed606cd..7cf7b69e 100644 --- a/lib/theme/custom_text_style.dart +++ b/lib/theme/custom_text_style.dart @@ -1,7 +1,6 @@ +import 'package:eatvio_app/theme/theme_helper.dart'; import 'package:flutter/material.dart'; -import '../core/app_export.dart'; - /// A collection of pre-defined text styles for customizing text appearance, /// categorized by different font families and weights. /// Additionally, this class includes extensions on [TextStyle] to easily apply specific font families to text. @@ -21,7 +20,7 @@ class CustomTextStyles { static get bodyMediumBlack90013 => theme.textTheme.bodyMedium!.copyWith( color: appTheme.black900, - fontSize: 13.fSize, + fontSize: 13, ); static get bodyMediumBluegray800 => theme.textTheme.bodyMedium!.copyWith( @@ -42,27 +41,27 @@ class CustomTextStyles { static get bodySmallMulishBlack900 => theme.textTheme.bodySmall!.mulish.copyWith( color: appTheme.black900, - fontSize: 12.fSize, + fontSize: 12, ); static get bodySmallMulishBluegray800 => theme.textTheme.bodySmall!.mulish.copyWith( color: appTheme.blueGray800, - fontSize: 12.fSize, + fontSize: 12, ); static get bodySmallMulishBluegray80012 => theme.textTheme.bodySmall!.mulish.copyWith( color: appTheme.blueGray800, - fontSize: 12.fSize, + fontSize: 12, ); static get bodySmallMulishBluegray80012_1 => theme.textTheme.bodySmall!.mulish.copyWith( color: appTheme.blueGray800, - fontSize: 12.fSize, + fontSize: 12, ); static get bodySmallMulishBluegray900 => theme.textTheme.bodySmall!.mulish.copyWith( color: appTheme.blueGray900, - fontSize: 12.fSize, + fontSize: 12, ); static get bodySmallMulishGray600 => theme.textTheme.bodySmall!.mulish.copyWith( @@ -71,12 +70,12 @@ class CustomTextStyles { static get bodySmallMulishPrimary => theme.textTheme.bodySmall!.mulish.copyWith( color: theme.colorScheme.primary, - fontSize: 12.fSize, + fontSize: 12, ); static get bodySmallSegoeUIBlack900 => theme.textTheme.bodySmall!.segoeUI.copyWith( color: appTheme.black900, - fontSize: 12.fSize, + fontSize: 12, ); // Label text style @@ -90,11 +89,11 @@ class CustomTextStyles { // Title text style static get titleMedium16 => theme.textTheme.titleMedium!.copyWith( - fontSize: 16.fSize, + fontSize: 16, ); static get titleMediumBlack => theme.textTheme.titleMedium!.copyWith( - fontSize: 17.fSize, + fontSize: 17, fontWeight: FontWeight.w900, ); @@ -131,7 +130,7 @@ class CustomTextStyles { ); static get titleSmallBold => theme.textTheme.titleSmall!.copyWith( - fontSize: 15.fSize, + fontSize: 15, fontWeight: FontWeight.w700, ); diff --git a/lib/theme/theme_helper.dart b/lib/theme/theme_helper.dart index 20fa5474..ab5c1d2d 100644 --- a/lib/theme/theme_helper.dart +++ b/lib/theme/theme_helper.dart @@ -2,8 +2,6 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:google_fonts/google_fonts.dart'; -import '../../core/app_export.dart'; - /// Helper class for managing themes and colors. class ThemeHelper { // The current app theme @@ -44,49 +42,7 @@ class ThemeHelper { var colorScheme = _supportedColorScheme[_appTheme] ?? ColorSchemes.primaryColorScheme; return ThemeData( - textTheme: GoogleFonts.mulishTextTheme().copyWith( - bodyLarge: TextStyle( - color: appTheme.blueGray400, - fontSize: 18, - fontWeight: FontWeight.w400, - ), - headlineSmall: TextStyle( - color: colorScheme.primary, - fontWeight: FontWeight.w600, - fontSize: 24, - ), - titleMedium: TextStyle( - color: colorScheme.primary, - fontWeight: FontWeight.w700, - fontSize: 18, - ), - titleSmall: TextStyle( - color: colorScheme.onPrimary, - fontWeight: FontWeight.w700, - fontSize: 15, - ), - bodyMedium: TextStyle( - color: appTheme.blueGray400, - fontWeight: FontWeight.w400, - fontSize: 14, - ), - bodySmall: TextStyle( - color: appTheme.gray500, - fontWeight: FontWeight.w400, - fontSize: 10, - ), - labelLarge: TextStyle( - color: appTheme.blueGray800, - fontWeight: FontWeight.w600, - fontSize: 12, - ), - ), - pageTransitionsTheme: PageTransitionsTheme( - builders: { - TargetPlatform.android: CupertinoPageTransitionsBuilder(), - TargetPlatform.iOS: CupertinoPageTransitionsBuilder(), - }, - ), + textTheme: GoogleFonts.mulishTextTheme(), visualDensity: VisualDensity.standard, colorScheme: colorScheme, scaffoldBackgroundColor: colorScheme.onPrimary, @@ -106,10 +62,10 @@ class ThemeHelper { backgroundColor: Colors.transparent, side: BorderSide( color: colorScheme.primary, - width: 1.h, + width: 1, ), shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(15.h), + borderRadius: BorderRadius.circular(20), ), visualDensity: const VisualDensity( vertical: -4, diff --git a/lib/widgets/app_bar/appbar_leading_image.dart b/lib/widgets/app_bar/appbar_leading_image.dart index 003d9f03..0f930dcb 100644 --- a/lib/widgets/app_bar/appbar_leading_image.dart +++ b/lib/widgets/app_bar/appbar_leading_image.dart @@ -1,22 +1,16 @@ -import 'package:eatvio_app/core/app_export.dart'; +import 'package:eatvio_app/widgets/custom_image_view.dart'; import 'package:flutter/material.dart'; -// ignore: must_be_immutable class AppbarLeadingImage extends StatelessWidget { - AppbarLeadingImage({ - Key? key, + const AppbarLeadingImage({ this.imagePath, this.margin, this.onTap, - }) : super( - key: key, - ); + }); - String? imagePath; - - EdgeInsetsGeometry? margin; - - Function? onTap; + final String? imagePath; + final EdgeInsetsGeometry? margin; + final Function? onTap; @override Widget build(BuildContext context) { @@ -26,8 +20,8 @@ class AppbarLeadingImage extends StatelessWidget { padding: margin ?? EdgeInsets.zero, child: CustomImageView( imagePath: imagePath, - height: 26.v, - width: 13.h, + height: 26, + width: 13, fit: BoxFit.contain, ), ), diff --git a/lib/widgets/app_bar/appbar_subtitle.dart b/lib/widgets/app_bar/appbar_subtitle.dart index 75784abc..ff1325f7 100644 --- a/lib/widgets/app_bar/appbar_subtitle.dart +++ b/lib/widgets/app_bar/appbar_subtitle.dart @@ -1,22 +1,17 @@ -import 'package:eatvio_app/core/app_export.dart'; +import 'package:eatvio_app/theme/custom_text_style.dart'; +import 'package:eatvio_app/theme/theme_helper.dart'; import 'package:flutter/material.dart'; -// ignore: must_be_immutable class AppbarSubtitle extends StatelessWidget { - AppbarSubtitle({ - Key? key, + const AppbarSubtitle({ required this.text, this.margin, this.onTap, - }) : super( - key: key, - ); + }); - String text; - - EdgeInsetsGeometry? margin; - - Function? onTap; + final String text; + final EdgeInsetsGeometry? margin; + final Function? onTap; @override Widget build(BuildContext context) { diff --git a/lib/widgets/app_bar/appbar_title_circleimage.dart b/lib/widgets/app_bar/appbar_title_circleimage.dart deleted file mode 100644 index 02224f3c..00000000 --- a/lib/widgets/app_bar/appbar_title_circleimage.dart +++ /dev/null @@ -1,36 +0,0 @@ -import 'package:eatvio_app/core/app_export.dart'; -import 'package:flutter/material.dart'; - -// ignore: must_be_immutable -class AppbarTitleCircleimage extends StatelessWidget { - AppbarTitleCircleimage({ - Key? key, - this.imagePath, - this.margin, - }) : super( - key: key, - ); - - String? imagePath; - - EdgeInsetsGeometry? margin; - - @override - Widget build(BuildContext context) { - return InkWell( - borderRadius: BorderRadiusStyle.circleBorder8, - child: Padding( - padding: margin ?? EdgeInsets.zero, - child: CustomImageView( - imagePath: imagePath, - height: 40.adaptSize, - width: 40.adaptSize, - fit: BoxFit.contain, - radius: BorderRadius.circular( - 20.h, - ), - ), - ), - ); - } -} diff --git a/lib/widgets/app_bar/appbar_title_image.dart b/lib/widgets/app_bar/appbar_title_image.dart index 429ab4d8..cf7fedcf 100644 --- a/lib/widgets/app_bar/appbar_title_image.dart +++ b/lib/widgets/app_bar/appbar_title_image.dart @@ -1,7 +1,6 @@ -import 'package:eatvio_app/core/app_export.dart'; +import 'package:eatvio_app/widgets/custom_image_view.dart'; import 'package:flutter/material.dart'; -// ignore: must_be_immutable class AppbarTitleImage extends StatelessWidget { const AppbarTitleImage({required this.imagePath, super.key}); diff --git a/lib/widgets/app_bar/custom_app_bar.dart b/lib/widgets/app_bar/custom_app_bar.dart index 469e9315..ce58516a 100644 --- a/lib/widgets/app_bar/custom_app_bar.dart +++ b/lib/widgets/app_bar/custom_app_bar.dart @@ -1,4 +1,3 @@ -import 'package:eatvio_app/core/app_export.dart'; import 'package:flutter/material.dart'; // ignore: must_be_immutable @@ -11,26 +10,19 @@ class CustomAppBar extends StatelessWidget implements PreferredSizeWidget { this.title, this.centerTitle, this.actions, - }) : super( - key: key, - ); + }) : super(key: key); final double? height; - final double? leadingWidth; - final Widget? leading; - final Widget? title; - final bool? centerTitle; - final List? actions; @override Widget build(BuildContext context) { return AppBar( - toolbarHeight: height ?? 56.v, + toolbarHeight: height ?? 56, automaticallyImplyLeading: false, backgroundColor: Colors.transparent, leadingWidth: leadingWidth ?? 0, @@ -43,8 +35,5 @@ class CustomAppBar extends StatelessWidget implements PreferredSizeWidget { } @override - Size get preferredSize => Size( - mediaQueryData.size.width, - height ?? 56.v, - ); + Size get preferredSize => Size(double.infinity, height ?? 56); } diff --git a/lib/widgets/app_bar/exit_button.dart b/lib/widgets/app_bar/exit_button.dart deleted file mode 100644 index ee0d27dd..00000000 --- a/lib/widgets/app_bar/exit_button.dart +++ /dev/null @@ -1,40 +0,0 @@ -import 'package:eatvio_app/core/app_export.dart'; -import 'package:flutter/material.dart'; - -// ignore: must_be_immutable -class ExitButton extends StatelessWidget { - ExitButton({ - Key? key, - required this.text, - this.margin, - this.onTap, - }) : super( - key: key, - ); - - String text; - - EdgeInsetsGeometry? margin; - - Function? onTap; - - @override - Widget build(BuildContext context) { - return GestureDetector( - onTap: onTapCall, - child: Padding( - padding: margin ?? EdgeInsets.zero, - child: Text( - text, - style: CustomTextStyles.titleSmallRed200.copyWith( - color: Colors.red, - ), - ), - ), - ); - } - - void onTapCall() { - onTap!.call(); - } -} diff --git a/lib/widgets/chart_axis.dart b/lib/widgets/chart_axis.dart deleted file mode 100644 index f137c6d3..00000000 --- a/lib/widgets/chart_axis.dart +++ /dev/null @@ -1,145 +0,0 @@ -/*import 'package:flutter/material.dart'; -import 'package:fl_chart/fl_chart.dart'; - -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]), - ); - } - - 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: 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), - ), - ); - }, - ), - ), - ); -} -*/ diff --git a/lib/widgets/chart_bars.dart b/lib/widgets/chart_bars.dart deleted file mode 100644 index eac9e99c..00000000 --- a/lib/widgets/chart_bars.dart +++ /dev/null @@ -1,79 +0,0 @@ -/*import 'package:flutter/material.dart'; -import 'package:fl_chart/fl_chart.dart'; - -void main() { - runApp(MyApp()); -} - -class MyApp extends StatelessWidget { - @override - Widget build(BuildContext context) { - return MaterialApp( - home: Scaffold( - appBar: AppBar( - title: Text('Nutrition Chart'), - ), - body: Center( - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Container( - height: 300, - width: 300, - child: BarChart( - BarChartData( - barTouchData: BarTouchData(enabled: false), - titlesData: FlTitlesData( - show: true, - bottomTitles: SideTitles( - showTitles: true, - getTextStyles: (value) => - const TextStyle(color: Colors.black, fontSize: 14), - margin: 10, - showTitles: (double value) { - switch (value.toInt()) { - case 0: - return 'Calories'; - case 1: - return 'Protein'; - case 2: - return 'Fat'; - case 3: - return 'Carbs'; - default: - return ''; - } - }, - ), - leftTitles: SideTitles(showTitles: false), - ), - borderData: FlBorderData(show: false), - barGroups: [ - BarChartGroupData(x: 0, barRods: [ - BarChartRodData(y: 200, color: Colors.blue), - BarChartRodData(y: 150, color: Colors.blueAccent), - ]), - BarChartGroupData(x: 1, barRods: [ - BarChartRodData(y: 50, color: Colors.red), - BarChartRodData(y: 60, color: Colors.deepOrange), - ]), - BarChartGroupData(x: 2, barRods: [ - BarChartRodData(y: 80, color: Colors.green), - BarChartRodData(y: 70, color: Colors.lightGreen), - ]), - BarChartGroupData(x: 3, barRods: [ - BarChartRodData(y: 100, color: Colors.orange), - BarChartRodData(y: 120, color: Colors.orangeAccent), - ]), - ], - ), - ), - ), - ], - ), - ), - ), - ); - } -} -*/ diff --git a/lib/widgets/custom_autocomplete.dart b/lib/widgets/custom_autocomplete.dart deleted file mode 100644 index 66e042dc..00000000 --- a/lib/widgets/custom_autocomplete.dart +++ /dev/null @@ -1,80 +0,0 @@ -/* -class CustomTextFormField extends StatelessWidget { - // ... - - final AutocompleteOptions autocompleteOptions; - - const CustomTextFormField({ - // ... (остальные параметры) - required this.autocompleteOptions, - }) : super(key: key); - - @override - Widget build(BuildContext context) { - return alignment != null - ? Align( - alignment: alignment ?? Alignment.center, - child: autocompleteFieldWidget, - ) - : autocompleteFieldWidget; - } - - Widget get autocompleteFieldWidget => SizedBox( - width: width ?? double.maxFinite, - child: Autocomplete( - optionsBuilder: (TextEditingValue textEditingValue) { - if (textEditingValue.text == '') { - return const Iterable.empty(); - } - return autocompleteOptions.options.where((String option) { - return option - .toLowerCase() - .contains(textEditingValue.text.toLowerCase()); - }); - }, - onSelected: (String value) { - controller?.text = value; - onChanged?.call(value); - }, - fieldViewBuilder: (BuildContext context, - TextEditingController textEditingController, - FocusNode focusNode, - VoidCallback onFieldSubmitted) { - return TextFormField( - controller: textEditingController, - focusNode: focusNode, - autofocus: autofocus!, - style: textStyle ?? theme.textTheme.titleMedium, - obscureText: obscureText!, - textInputAction: textInputAction, - maxLines: maxLines ?? 1, - decoration: decoration, - validator: validator, - keyboardType: keyboardType, - onSaved: onSaved, - onChanged: onChanged, - inputFormatters: inputFormatters, - initialValue: initialValue, - onFieldSubmitted: (_) => onFieldSubmitted(), - ); - }, - optionsViewBuilder: (BuildContext context, - AutocompleteOnSelected onSelected, - Iterable options) { - return Material( - elevation: 4.0, - child: ListView( - children: options.map((String option) { - return ListTile( - title: Text(option), - onTap: () { - onSelected(option); - }, - ); - }).toList(), - ), - ); - }, - ), - ); -}*/ diff --git a/lib/widgets/custom_drop_down.dart b/lib/widgets/custom_drop_down.dart index 96367d61..7522893a 100644 --- a/lib/widgets/custom_drop_down.dart +++ b/lib/widgets/custom_drop_down.dart @@ -1,9 +1,8 @@ -import 'package:eatvio_app/core/app_export.dart'; +import 'package:eatvio_app/data/models/selectionPopupModel/selection_popup_model.dart'; import 'package:flutter/material.dart'; class CustomDropDown extends StatelessWidget { - CustomDropDown({ - Key? key, + const CustomDropDown({ this.alignment, this.width, this.focusNode, @@ -24,48 +23,27 @@ class CustomDropDown extends StatelessWidget { this.validator, this.onChanged, this.value, - }) : super( - key: key, - ); + }); final Alignment? alignment; - final double? width; - final FocusNode? focusNode; - final Widget? icon; - final bool? autofocus; - final TextStyle? textStyle; - final List? items; - final String? hintText; - final TextStyle? hintStyle; - final Widget? prefix; - final BoxConstraints? prefixConstraints; - final Widget? suffix; - final BoxConstraints? suffixConstraints; - final EdgeInsets? contentPadding; - final InputBorder? borderDecoration; - final Color? fillColor; - final bool? filled; - final SelectionPopupModel? value; - final FormFieldValidator? validator; - final Function(SelectionPopupModel)? onChanged; @override @@ -84,12 +62,13 @@ class CustomDropDown extends StatelessWidget { icon: Icon(Icons.keyboard_arrow_down_rounded), autofocus: autofocus!, value: value, + isDense: true, isExpanded: true, - style: textStyle ?? - TextStyle( - fontSize: 16, - fontWeight: FontWeight.w400, - ), + style: TextStyle( + fontSize: 16, + color: Colors.black, + fontWeight: FontWeight.w400, + ), items: items?.map((SelectionPopupModel item) { return DropdownMenuItem( value: item, @@ -116,45 +95,39 @@ class CustomDropDown extends StatelessWidget { InputDecoration _buildInputDecoration(BuildContext context) { return InputDecoration( + labelStyle: TextStyle( + fontSize: 16, + color: Colors.black, + fontWeight: FontWeight.w400, + ), hintText: hintText ?? "", hintStyle: hintStyle ?? TextStyle( fontSize: 16, fontWeight: FontWeight.w400, color: Colors.grey.shade400, + height: 1, ), prefixIcon: prefix, prefixIconConstraints: prefixConstraints, suffixIcon: suffix, - suffixIconConstraints: suffixConstraints, isDense: true, - contentPadding: contentPadding ?? EdgeInsets.all(8), - fillColor: fillColor ?? Theme.of(context).colorScheme.onPrimary, + suffixIconConstraints: suffixConstraints, + contentPadding: EdgeInsets.symmetric(vertical: 16, horizontal: 12), + fillColor: Color(0xFFF6F6F6), filled: filled, - border: borderDecoration ?? - OutlineInputBorder( - borderRadius: BorderRadius.circular(8), - borderSide: BorderSide( - color: Colors.grey.shade400, - width: 1, - ), - ), - enabledBorder: borderDecoration ?? - OutlineInputBorder( - borderRadius: BorderRadius.circular(8), - borderSide: BorderSide( - color: Colors.grey.shade400, - width: 1, - ), - ), - focusedBorder: borderDecoration ?? - OutlineInputBorder( - borderRadius: BorderRadius.circular(8), - borderSide: BorderSide( - color: appTheme.blueA400, - width: 1, - ), - ), + border: OutlineInputBorder( + borderRadius: const BorderRadius.all(Radius.circular(20)), + borderSide: BorderSide.none, + ), + enabledBorder: OutlineInputBorder( + borderRadius: const BorderRadius.all(Radius.circular(20)), + borderSide: BorderSide.none, + ), + focusedBorder: OutlineInputBorder( + borderRadius: const BorderRadius.all(Radius.circular(20)), + borderSide: BorderSide.none, + ), ); } } diff --git a/lib/widgets/custom_edit_drop_down.dart b/lib/widgets/custom_edit_drop_down.dart deleted file mode 100644 index 7f56bbd8..00000000 --- a/lib/widgets/custom_edit_drop_down.dart +++ /dev/null @@ -1,145 +0,0 @@ -import 'package:eatvio_app/core/app_export.dart'; -import 'package:flutter/material.dart'; - -class CustomDropDown extends StatelessWidget { - CustomDropDown({ - Key? key, - this.alignment, - this.width, - this.focusNode, - this.icon, - this.autofocus = true, - this.textStyle, - this.items, - this.hintText, - this.hintStyle, - this.prefix, - this.prefixConstraints, - this.suffix, - this.suffixConstraints, - this.contentPadding, - this.borderDecoration, - this.fillColor, - this.filled = true, - this.validator, - this.onChanged, - this.defaultValue, - }) : super( - key: key, - ); - - final Alignment? alignment; - - final double? width; - - final FocusNode? focusNode; - - final Widget? icon; - - final bool? autofocus; - - final TextStyle? textStyle; - - final List? items; - - final String? hintText; - - final TextStyle? hintStyle; - - final Widget? prefix; - - final BoxConstraints? prefixConstraints; - - final Widget? suffix; - - final BoxConstraints? suffixConstraints; - - final EdgeInsets? contentPadding; - - final InputBorder? borderDecoration; - - final Color? fillColor; - - final bool? filled; - - final SelectionPopupModel? defaultValue; - - final FormFieldValidator? validator; - - final Function(SelectionPopupModel)? onChanged; - - @override - Widget build(BuildContext context) { - return alignment != null - ? Align( - alignment: alignment ?? Alignment.center, - child: _buildDropDownWidget(context), - ) - : _buildDropDownWidget(context); - } - - _buildDropDownWidget(BuildContext context) { - return SizedBox( - width: width ?? double.maxFinite, - child: DropdownButtonFormField( - focusNode: focusNode ?? FocusNode(), - icon: icon, - autofocus: autofocus!, - style: textStyle ?? Theme.of(context).textTheme.titleMedium, - items: items?.map((SelectionPopupModel item) { - return DropdownMenuItem( - value: item, - child: Text( - item.title, - overflow: TextOverflow.ellipsis, - style: hintStyle ?? Theme.of(context).textTheme.titleMedium, - ), - ); - }).toList(), - decoration: _buildInputDecoration(context), - validator: validator, - value: defaultValue, - onChanged: onDropDownChanged, - ), - ); - } - - void onDropDownChanged(value) { - onChanged!(value!); - } - - InputDecoration _buildInputDecoration(BuildContext context) { - return InputDecoration( - hintText: hintText ?? "", - hintStyle: hintStyle ?? Theme.of(context).textTheme.titleMedium, - prefixIcon: prefix, - prefixIconConstraints: prefixConstraints, - suffixIcon: suffix, - suffixIconConstraints: suffixConstraints, - isDense: true, - contentPadding: contentPadding ?? - EdgeInsets.only( - left: 6, - top: 6, - bottom: 6, - ), - fillColor: fillColor ?? Theme.of(context).colorScheme.onPrimary, - filled: filled, - border: borderDecoration ?? - OutlineInputBorder( - borderRadius: const BorderRadius.all(Radius.circular(8)), - borderSide: BorderSide(color: Colors.grey, width: 1), - ), - enabledBorder: borderDecoration ?? - OutlineInputBorder( - borderRadius: const BorderRadius.all(Radius.circular(8)), - borderSide: BorderSide(color: Colors.grey, width: 1), - ), - focusedBorder: borderDecoration ?? - OutlineInputBorder( - borderRadius: const BorderRadius.all(Radius.circular(8)), - borderSide: BorderSide(color: Colors.grey, width: 1), - ), - ); - } -} diff --git a/lib/widgets/custom_edit_text_form_field.dart b/lib/widgets/custom_edit_text_form_field.dart deleted file mode 100644 index 13a3df86..00000000 --- a/lib/widgets/custom_edit_text_form_field.dart +++ /dev/null @@ -1,154 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:flutter/services.dart'; - -class CustomTextFormField extends StatelessWidget { - CustomTextFormField({ - Key? key, - this.alignment, - this.width, - this.controller, - this.focusNode, - this.autofocus = false, - this.textStyle, - this.obscureText = false, - this.textInputAction = TextInputAction.next, - this.textInputType = TextInputType.text, - this.maxLines, - this.hintText, - this.hintStyle, - this.prefix, - this.prefixConstraints, - this.suffix, - this.suffixConstraints, - this.onFieldSubmitted, - this.initialValue, - this.contentPadding, - this.inputFormatters, - this.borderDecoration, - this.fillColor, - this.filled = true, - this.validator, - this.keyboardType, - this.onChanged, - this.onSaved, - }) : super( - key: key, - ); - - final Alignment? alignment; - - final double? width; - - final TextEditingController? controller; - - final FocusNode? focusNode; - - final bool? autofocus; - - final TextStyle? textStyle; - - final bool? obscureText; - - final List? inputFormatters; - - final TextInputAction? textInputAction; - - final TextInputType? textInputType; - - final int? maxLines; - - final String? hintText; - - final TextStyle? hintStyle; - - final Widget? prefix; - - final BoxConstraints? prefixConstraints; - - final Widget? suffix; - - final Function(String)? onFieldSubmitted; - - final BoxConstraints? suffixConstraints; - - final EdgeInsets? contentPadding; - - final InputBorder? borderDecoration; - - final Color? fillColor; - - final bool? filled; - - final TextInputType? keyboardType; - - final String? initialValue; - - final FormFieldValidator? validator; - - final void Function(String?)? onSaved; - - final ValueChanged? onChanged; - - @override - Widget build(BuildContext context) { - return alignment != null - ? Align( - alignment: alignment ?? Alignment.center, - child: _buildTextFormFieldWidget(context), - ) - : _buildTextFormFieldWidget(context); - } - - _buildTextFormFieldWidget(BuildContext context) { - return SizedBox( - width: width ?? double.maxFinite, - child: TextFormField( - controller: controller, - focusNode: focusNode ?? FocusNode(), - autofocus: autofocus!, - style: textStyle ?? Theme.of(context).textTheme.titleMedium, - obscureText: obscureText!, - textInputAction: textInputAction, - maxLines: maxLines ?? 1, - decoration: _buildInputDecoration(context), - validator: validator, - keyboardType: keyboardType, - onSaved: onSaved, - onChanged: onChanged, - onFieldSubmitted: onFieldSubmitted, - inputFormatters: inputFormatters, - initialValue: initialValue, - ), - ); - } - - InputDecoration _buildInputDecoration(BuildContext context) { - return InputDecoration( - hintText: hintText ?? "", - hintStyle: hintStyle ?? Theme.of(context).textTheme.bodyLarge, - prefixIcon: prefix, - prefixIconConstraints: prefixConstraints, - suffixIcon: suffix, - suffixIconConstraints: suffixConstraints, - isDense: true, - contentPadding: contentPadding ?? EdgeInsets.all(6), - fillColor: fillColor ?? Theme.of(context).colorScheme.onPrimary, - filled: filled, - border: borderDecoration ?? - OutlineInputBorder( - borderRadius: const BorderRadius.all(Radius.circular(8)), - borderSide: BorderSide(color: Colors.grey, width: 1), - ), - enabledBorder: borderDecoration ?? - OutlineInputBorder( - borderRadius: const BorderRadius.all(Radius.circular(8)), - borderSide: BorderSide(color: Colors.grey, width: 1), - ), - focusedBorder: borderDecoration ?? - OutlineInputBorder( - borderRadius: const BorderRadius.all(Radius.circular(8)), - borderSide: BorderSide(color: Colors.grey, width: 1), - ), - ); - } -} diff --git a/lib/widgets/custom_expandable_list.dart b/lib/widgets/custom_expandable_list.dart index 2489c0d7..dfda23f9 100644 --- a/lib/widgets/custom_expandable_list.dart +++ b/lib/widgets/custom_expandable_list.dart @@ -1,13 +1,16 @@ import 'dart:convert'; - -import 'package:eatvio_app/core/app_export.dart'; +import 'package:rive/rive.dart' as rive; +import 'package:eatvio_app/core/const.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/generated/l10n.dart'; +import 'package:eatvio_app/old/profile/my_profile_screen/bloc/my_profile_bloc.dart'; +import 'package:eatvio_app/theme/custom_button_style.dart'; import 'package:eatvio_app/widgets/custom_hyper_switch.dart'; import 'package:eatvio_app/widgets/custom_hypo_switch.dart'; import 'package:eatvio_app/widgets/next_step_button.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:go_router/go_router.dart'; import 'package:http/http.dart' as http; import 'package:intl/intl.dart'; @@ -53,9 +56,12 @@ class _ExpandableListState extends State { builder: (context, state) { if (state is MyProfileInitialState) { // Это начальное состояние, данные ещё не загружены. - return CircularProgressIndicator( - color: Colors.white, - backgroundColor: Colors.white, + return SizedBox( + height: 32, + width: 32, + child: rive.RiveAnimation.asset( + 'assets/rive_animations/loading.riv', + ), ); } else if (state is MyProfileLoadedState) { // Данные загружены, можно строить форму. @@ -84,6 +90,7 @@ class _ExpandableListState extends State { } _buildForm(BuildContext context, MyProfileLoadedState state) { + final s = S.of(context); List cities = [ 'Москва', 'Санкт-Петербург', @@ -131,14 +138,14 @@ class _ExpandableListState extends State { children: [ TextField( controller: state.firstNameFormController, - decoration: InputDecoration(labelText: 'first_name'.tr), + decoration: InputDecoration(labelText: s.first_name), ), TextField( controller: state.lastNameFormController, - decoration: InputDecoration(labelText: 'last_name'.tr), + decoration: InputDecoration(labelText: s.last_name), ), TextField( - decoration: InputDecoration(labelText: 'date_of_birth'.tr), + decoration: InputDecoration(labelText: s.date_of_birth), controller: state.dateFormController, onTap: inputTime(context, state), ), @@ -152,7 +159,7 @@ class _ExpandableListState extends State { child: Text(value), ); }).toList(), - decoration: InputDecoration(labelText: 'country'.tr), + decoration: InputDecoration(labelText: s.country), ), DropdownButtonFormField( hint: Text(state.selectedCity ?? "Не выбрано"), @@ -164,78 +171,78 @@ class _ExpandableListState extends State { child: Text(value), ); }).toList(), - decoration: InputDecoration(labelText: 'city_of_living'.tr), + decoration: InputDecoration(labelText: s.city_of_living), ), TextField( controller: state.weightFormController, - decoration: InputDecoration(labelText: 'weight_measurements'.tr), + decoration: InputDecoration(labelText: s.weight_measurements), keyboardType: TextInputType.number, inputFormatters: [digitsOnly], ), TextField( controller: state.heightFormController, - decoration: InputDecoration(labelText: 'height_measurements'.tr), + decoration: InputDecoration(labelText: s.height_measurements), keyboardType: TextInputType.number, inputFormatters: [digitsOnly], ), TextField( controller: state.chestCircumferenceFormController, - decoration: InputDecoration(labelText: 'chest_circumference'.tr), + decoration: InputDecoration(labelText: s.chest_circumference), keyboardType: TextInputType.number, inputFormatters: [digitsOnly], ), TextField( controller: state.waistCircumferenceFormController, - decoration: InputDecoration(labelText: 'waist_circumference'.tr), + decoration: InputDecoration(labelText: s.waist_circumference), keyboardType: TextInputType.number, inputFormatters: [digitsOnly], ), TextField( controller: state.hipCircumferenceFormController, - decoration: InputDecoration(labelText: 'hip_circumference'.tr), + decoration: InputDecoration(labelText: s.hip_circumference), keyboardType: TextInputType.number, inputFormatters: [digitsOnly], ), TextField( controller: state.upPressureFormController, - decoration: InputDecoration(labelText: 'up_pressure'.tr), + decoration: InputDecoration(labelText: s.up_pressure), keyboardType: TextInputType.number, inputFormatters: [digitsOnly], ), TextField( controller: state.downPressureFormController, - decoration: InputDecoration(labelText: 'down_pressure'.tr), + decoration: InputDecoration(labelText: s.down_pressure), keyboardType: TextInputType.number, inputFormatters: [digitsOnly], ), TextField( controller: state.allergiesFormController, - decoration: InputDecoration(labelText: 'allergies_presence'.tr), + decoration: InputDecoration(labelText: s.allergies_presence), maxLines: null, ), TextField( controller: state.pillsFormController, - decoration: InputDecoration(labelText: 'do_you_take_pills'.tr), + decoration: InputDecoration(labelText: s.do_you_take_pills), maxLines: null, ), TextField( controller: state.sportsFormController, - decoration: InputDecoration(labelText: 'your_favorite_sports'.tr), + decoration: InputDecoration(labelText: s.your_favorite_sports), maxLines: null, ), TextField( controller: state.favoriteFormController, - decoration: InputDecoration(labelText: 'favorite_foods'.tr), + decoration: InputDecoration(labelText: s.favorite_foods), maxLines: null, ), TextField( controller: state.unfavoriteFormController, - decoration: InputDecoration(labelText: 'unfavorite_foods'.tr), + decoration: InputDecoration(labelText: s.unfavorite_foods), maxLines: null, ), TextField( controller: state.additionalFormController, - decoration: InputDecoration(labelText: 'additional_information'.tr), + decoration: InputDecoration(labelText: s.additional_information), maxLines: null, ), DropdownButtonFormField( @@ -258,19 +265,19 @@ class _ExpandableListState extends State { ), Row( children: [ - HypoSwitch('do_you_have_hypotension_tendency'.tr, state), + HypoSwitch(s.do_you_have_hypotension_tendency, state), ], ), Row( children: [ - HyperSwitch('do_you_have_hypertension_tendency'.tr, state), + HyperSwitch(s.do_you_have_hypertension_tendency, state), ], ), NextStepButton( onPressed: () => sendProfileData(state), buttonStyle: CustomButtonStyles.outlinePrimaryTL15, - text: "save".tr.toUpperCase(), - margin: EdgeInsets.only(top: 20.h, bottom: 20.h), + text: s.save.toUpperCase(), + margin: EdgeInsets.only(top: 20, bottom: 20), ), ], ); diff --git a/lib/widgets/custom_hyper_switch.dart b/lib/widgets/custom_hyper_switch.dart index 3d28d053..93b1a340 100644 --- a/lib/widgets/custom_hyper_switch.dart +++ b/lib/widgets/custom_hyper_switch.dart @@ -1,5 +1,5 @@ -import 'package:eatvio_app/core/app_export.dart'; -import 'package:eatvio_app/presentation/profile/my_profile_screen/bloc/my_profile_bloc.dart'; +import 'package:eatvio_app/old/profile/my_profile_screen/bloc/my_profile_bloc.dart'; +import 'package:eatvio_app/theme/theme_helper.dart'; import 'package:flutter/material.dart'; class HyperSwitch extends StatefulWidget { diff --git a/lib/widgets/custom_hypo_switch.dart b/lib/widgets/custom_hypo_switch.dart index 9504e5f1..ab5e11ab 100644 --- a/lib/widgets/custom_hypo_switch.dart +++ b/lib/widgets/custom_hypo_switch.dart @@ -1,5 +1,5 @@ -import 'package:eatvio_app/core/app_export.dart'; -import 'package:eatvio_app/presentation/profile/my_profile_screen/bloc/my_profile_bloc.dart'; +import 'package:eatvio_app/old/profile/my_profile_screen/bloc/my_profile_bloc.dart'; +import 'package:eatvio_app/theme/theme_helper.dart'; import 'package:flutter/material.dart'; class HypoSwitch extends StatefulWidget { diff --git a/lib/widgets/custom_icon_button.dart b/lib/widgets/custom_icon_button.dart deleted file mode 100644 index d029004a..00000000 --- a/lib/widgets/custom_icon_button.dart +++ /dev/null @@ -1,65 +0,0 @@ -import 'package:flutter/material.dart'; - -class CustomIconButton extends StatelessWidget { - CustomIconButton({ - Key? key, - this.alignment, - this.height, - this.width, - this.padding, - this.decoration, - this.child, - this.onTap, - }) : super(key: key); - - final Alignment? alignment; - final double? height; - final double? width; - final EdgeInsetsGeometry? padding; - final BoxDecoration? decoration; - final Widget? child; - final VoidCallback? onTap; - - @override - Widget build(BuildContext context) { - return alignment != null - ? Align( - alignment: alignment ?? Alignment.center, - child: _buildIconButtonWidget(), - ) - : _buildIconButtonWidget(); - } - - _buildIconButtonWidget() { - return SizedBox( - height: height ?? 0, - width: width ?? 0, - child: IconButton( - padding: EdgeInsets.zero, - icon: Container( - height: height ?? 0, - width: width ?? 0, - padding: padding ?? EdgeInsets.zero, - decoration: decoration ?? - BoxDecoration( - color: Colors.black, - borderRadius: const BorderRadius.all(Radius.circular(9)), - border: const Border.fromBorderSide( - BorderSide(color: Colors.blueGrey, width: 1), - ), - ), - child: child, - ), - onPressed: onTap, - ), - ); - } -} - -/// Extension on [CustomIconButton] to facilitate inclusion of all types of border style etc -extension IconButtonStyleHelper on CustomIconButton { - static BoxDecoration get fillBlueA => BoxDecoration( - color: Colors.blue, - borderRadius: const BorderRadius.all(Radius.circular(14)), - ); -} diff --git a/lib/widgets/custom_navigation_menu_item.dart b/lib/widgets/custom_navigation_menu_item.dart deleted file mode 100644 index 3307daaf..00000000 --- a/lib/widgets/custom_navigation_menu_item.dart +++ /dev/null @@ -1,40 +0,0 @@ -import 'package:eatvio_app/core/app_export.dart'; -import 'package:flutter/material.dart'; - -class MenuItem extends StatelessWidget { - final String icon; - final String text; - final VoidCallback onTap; - - const MenuItem({ - required this.icon, - required this.text, - required this.onTap, - }); - - @override - Widget build(BuildContext context) { - return InkWell( - onTap: onTap, - child: Padding( - padding: const EdgeInsets.all(8.0), - child: Row( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.center, // Выравнивание по центру вертикально - children: [ - CustomImageView( - color: appTheme.blueA400, - imagePath: icon, - height: 24.0, - width: 24.0, - ), - SizedBox( - width: 8.0, - ), // Добавляем небольшой отступ между иконкой и текстом - Text(text), - ], - ), - ), - ); - } -} diff --git a/lib/widgets/custom_notification_screen.dart b/lib/widgets/custom_notification_screen.dart index 72fd860b..20c2055b 100644 --- a/lib/widgets/custom_notification_screen.dart +++ b/lib/widgets/custom_notification_screen.dart @@ -1,4 +1,4 @@ -import 'package:eatvio_app/core/app_export.dart'; +import 'package:eatvio_app/theme/theme_helper.dart'; import 'package:flutter/material.dart'; class NotificationSwitch extends StatefulWidget { diff --git a/lib/widgets/custom_outlined_button.dart b/lib/widgets/custom_outlined_button.dart index 4b17491e..549052f8 100644 --- a/lib/widgets/custom_outlined_button.dart +++ b/lib/widgets/custom_outlined_button.dart @@ -1,4 +1,4 @@ -import 'package:eatvio_app/core/app_export.dart'; +import 'package:eatvio_app/theme/custom_text_style.dart'; import 'package:eatvio_app/widgets/base_button.dart'; import 'package:flutter/material.dart'; @@ -41,7 +41,7 @@ class CustomOutlinedButton extends BaseButton { return Align( alignment: alignment ?? Alignment.center, child: Container( - height: this.height ?? 30.v, + height: this.height ?? 30, width: this.width ?? double.maxFinite, margin: margin, decoration: decoration, @@ -65,7 +65,7 @@ class CustomOutlinedButton extends BaseButton { ); } else { return Container( - height: this.height ?? 30.v, + height: this.height ?? 30, width: this.width ?? double.maxFinite, margin: margin, decoration: decoration, @@ -91,7 +91,7 @@ class CustomOutlinedButton extends BaseButton { /*_buildAppBarbuildOutlinedButtonWidget() { return Container( - height: this.height ?? 30.v, + height: this.height ?? 30, width: this.width ?? double.maxFinite, margin: margin, decoration: decoration, diff --git a/lib/widgets/custom_text_form_field.dart b/lib/widgets/custom_text_form_field.dart index a2b6c74f..4c0b0005 100644 --- a/lib/widgets/custom_text_form_field.dart +++ b/lib/widgets/custom_text_form_field.dart @@ -1,4 +1,4 @@ -import 'package:eatvio_app/core/app_export.dart'; +import 'package:eatvio_app/theme/theme_helper.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; @@ -79,6 +79,7 @@ class CustomTextFormField extends StatelessWidget { style: TextStyle( fontSize: 16, color: Colors.black, + fontWeight: FontWeight.w500, ), obscureText: obscureText!, textInputAction: textInputAction, @@ -90,39 +91,30 @@ class CustomTextFormField extends StatelessWidget { hintStyle: TextStyle( fontSize: 16, color: Colors.grey.shade400, - fontWeight: FontWeight.w400, + fontWeight: FontWeight.w500, ), prefixIcon: prefix, prefixIconConstraints: prefixConstraints, suffixIcon: suffix, suffixIconConstraints: suffixConstraints, isDense: false, - contentPadding: EdgeInsets.all(8), - fillColor: fillColor ?? theme.colorScheme.onPrimary, - filled: filled, + contentPadding: EdgeInsets.symmetric(vertical: 16, horizontal: 12), + fillColor: Color(0xFFF6F6F6), + filled: true, border: borderDecoration ?? OutlineInputBorder( - borderRadius: BorderRadius.circular(12), - borderSide: BorderSide( - color: Colors.grey.shade400, - width: 1, - ), + borderRadius: BorderRadius.circular(20), + borderSide: BorderSide.none, ), enabledBorder: borderDecoration ?? OutlineInputBorder( - borderRadius: BorderRadius.circular(12), - borderSide: BorderSide( - color: Colors.grey.shade400, - width: 1, - ), + borderRadius: BorderRadius.circular(20), + borderSide: BorderSide.none, ), focusedBorder: borderDecoration ?? OutlineInputBorder( - borderRadius: BorderRadius.circular(12), - borderSide: BorderSide( - color: appTheme.blueA400, - width: 1, - ), + borderRadius: BorderRadius.circular(20), + borderSide: BorderSide.none, ), ), keyboardType: keyboardType, diff --git a/lib/widgets/next_step_button.dart b/lib/widgets/next_step_button.dart index 455f8f94..05332f15 100644 --- a/lib/widgets/next_step_button.dart +++ b/lib/widgets/next_step_button.dart @@ -1,4 +1,4 @@ -import 'package:eatvio_app/core/app_export.dart'; +import 'package:eatvio_app/theme/theme_helper.dart'; import 'package:eatvio_app/widgets/base_button.dart'; import 'package:flutter/material.dart'; @@ -41,7 +41,7 @@ class NextStepButton extends BaseButton { ? Align( alignment: alignment!, child: Container( - height: this.height ?? 30.v, + height: this.height ?? 30, width: this.width ?? double.maxFinite, margin: margin, decoration: decoration, @@ -64,7 +64,7 @@ class NextStepButton extends BaseButton { ), ) : Container( - height: this.height ?? 30.v, + height: this.height ?? 30, width: this.width ?? double.maxFinite, margin: margin, decoration: decoration, diff --git a/lib/widgets/nutrition_chart.dart b/lib/widgets/nutrition_chart.dart deleted file mode 100644 index 455f8f94..00000000 --- a/lib/widgets/nutrition_chart.dart +++ /dev/null @@ -1,89 +0,0 @@ -import 'package:eatvio_app/core/app_export.dart'; -import 'package:eatvio_app/widgets/base_button.dart'; -import 'package:flutter/material.dart'; - -class NextStepButton extends BaseButton { - NextStepButton({ - Key? key, - this.decoration, - this.leftIcon, - this.rightIcon, - this.label, - VoidCallback? onPressed, - ButtonStyle? buttonStyle, - TextStyle? buttonTextStyle, - bool? isDisabled, - Alignment? alignment, - double? height, - double? width, - EdgeInsets? margin, - required String text, - }) : super( - text: text, - onPressed: onPressed, - buttonStyle: buttonStyle, - isDisabled: isDisabled, - buttonTextStyle: buttonTextStyle, - height: height, - alignment: alignment, - width: width, - margin: margin, - ); - - final BoxDecoration? decoration; - final Widget? leftIcon; - final Widget? rightIcon; - final Widget? label; - - @override - Widget build(BuildContext context) { - return (alignment != null) - ? Align( - alignment: alignment!, - child: Container( - height: this.height ?? 30.v, - width: this.width ?? double.maxFinite, - margin: margin, - decoration: decoration, - child: OutlinedButton( - style: buttonStyle, - onPressed: isDisabled ?? false ? null : onPressed ?? () {}, - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - leftIcon ?? const SizedBox.shrink(), - Text( - text, - style: buttonTextStyle ?? theme.textTheme.titleSmall, - ), - rightIcon ?? const SizedBox.shrink(), - ], - ), - ), - ), - ) - : Container( - height: this.height ?? 30.v, - width: this.width ?? double.maxFinite, - margin: margin, - decoration: decoration, - child: OutlinedButton( - style: buttonStyle, - onPressed: isDisabled ?? false ? null : onPressed ?? () {}, - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - leftIcon ?? const SizedBox.shrink(), - Text( - text, - style: buttonTextStyle ?? theme.textTheme.titleSmall, - ), - rightIcon ?? const SizedBox.shrink(), - ], - ), - ), - ); - } -} diff --git a/logs/errors.log b/logs/errors.log deleted file mode 100644 index e69de29b..00000000 diff --git a/pubspec.yaml b/pubspec.yaml index 514eb4a2..0b30677b 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -16,45 +16,44 @@ dependencies: flutter_secure_storage: ^9.2.2 flutter_bloc: ^8.1.6 cached_network_image: ^3.4.1 - flutter_svg: ^2.0.10 + flutter_svg: ^2.0.10+1 equatable: ^2.0.5 freezed_annotation: ^2.4.4 json_annotation: ^4.9.0 validators: ^3.0.0 path_provider: ^2.1.4 - fl_chart: ^0.68.0 - flutter_spinkit: ^5.2.1 - carousel_slider_plus: ^7.0.0 - flutter_form_builder: ^9.3.0 + carousel_slider_plus: ^7.0.1 + flutter_form_builder: ^9.4.1 image_picker: ^1.1.2 flutter_typeahead: ^5.2.0 - go_router: ^14.2.6 + go_router: ^14.2.7 keyboard_dismisser: ^3.0.0 - retrofit: ^4.2.0 + retrofit: ^4.4.1 get_it: ^7.7.0 - dio: ^5.6.0 + dio: ^5.7.0 dart_pusher_channels: ^1.2.3 photo_view: ^0.15.0 dismissible_page: ^1.0.2 url_launcher: ^6.3.0 easy_debounce: ^2.0.3 - lazy_load_scrollview: ^1.3.0 badges: ^3.1.2 google_fonts: ^6.2.1 location: ^6.0.2 - syncfusion_flutter_charts: ^26.2.11 + syncfusion_flutter_charts: ^27.1.48 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 + share_plus: ^10.0.2 + flutter_html: ^3.0.0-beta.2 + file_picker: ^8.1.2 + audioplayers: ^6.1.0 + intl: ^0.19.0 + rive: ^0.13.14 dev_dependencies: - build_runner: ^2.4.11 - freezed: ^2.5.2 + build_runner: ^2.4.12 + freezed: ^2.5.7 json_serializable: ^6.8.0 - retrofit_generator: ^8.2.0 + retrofit_generator: ^9.1.2 flutter_test: sdk: flutter @@ -66,3 +65,7 @@ flutter: - assets/images/ - assets/audio/ - assets/icons/ + - assets/rive_animations/ + +flutter_intl: + enabled: true diff --git a/test/auth_test.dart b/test/auth_test.dart index e131dc88..bd789695 100644 --- a/test/auth_test.dart +++ b/test/auth_test.dart @@ -1,31 +1,26 @@ -import 'package:eatvio_app/core/app_export.dart'; +import 'package:eatvio_app/generated/l10n.dart'; +import 'package:eatvio_app/old/auth/auth_screen/auth_screen.dart'; +import 'package:eatvio_app/old/auth/auth_screen/bloc/auth_bloc.dart'; +import 'package:eatvio_app/old/auth/auth_screen/models/auth_model.dart'; import 'package:flutter/material.dart'; -import 'package:flutter_test/flutter_test.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_localizations/flutter_localizations.dart'; -import 'package:eatvio_app/presentation/auth/auth_screen/auth_screen.dart'; -import 'package:eatvio_app/presentation/auth/auth_screen/bloc/auth_bloc.dart'; -import 'package:eatvio_app/presentation/auth/auth_screen/models/auth_model.dart'; +import 'package:flutter_test/flutter_test.dart'; void main() { group('AuthScreen', () { - testWidgets('renders AuthScreen with initial state', - (WidgetTester tester) async { + testWidgets('renders AuthScreen with initial state', (WidgetTester tester) async { final authBloc = AuthBloc(AuthState(authModelObj: AuthModel())); await tester.pumpWidget( MaterialApp( - localizationsDelegates: [ - AppLocalizationDelegate(), + localizationsDelegates: const [ + S.delegate, GlobalMaterialLocalizations.delegate, GlobalWidgetsLocalizations.delegate, GlobalCupertinoLocalizations.delegate, ], - supportedLocales: [ - Locale( - 'ru', - '', - ), - ], + supportedLocales: S.delegate.supportedLocales, home: BlocProvider( create: (context) => authBloc, child: Builder(