Merge pull request 'Update main repository' (#105) from maxxkim/eatvio_app:main into main
Reviewed-on: eatvio/eatvio_app#105
This commit is contained in:
2
.env
2
.env
@@ -1,2 +0,0 @@
|
||||
SERVER_ROOT='https://mobile-stage.eatvio.ru/api'
|
||||
STORAGE_URL='https://mobile-stage.eatvio.ru/storage/'
|
||||
@@ -78,7 +78,6 @@ jobs:
|
||||
|
||||
- name: Test
|
||||
run: |
|
||||
touch .env
|
||||
flutter test
|
||||
|
||||
- name: Build apk
|
||||
|
||||
@@ -89,7 +89,6 @@ jobs:
|
||||
|
||||
- name: Test
|
||||
run: |
|
||||
touch .env
|
||||
flutter test
|
||||
|
||||
- name: Build apk
|
||||
|
||||
2
.gitignore
vendored
2
.gitignore
vendored
@@ -6,4 +6,4 @@
|
||||
/.flutter-plugins
|
||||
/.flutter-plugins-dependencies
|
||||
/.packages
|
||||
/.env
|
||||
/node_modules/
|
||||
|
||||
7
Makefile
Normal file
7
Makefile
Normal file
@@ -0,0 +1,7 @@
|
||||
run-tests:
|
||||
flutter test
|
||||
|
||||
run-analyse:
|
||||
flutter analyze
|
||||
|
||||
run-checks: run-analyse run-tests
|
||||
@@ -1,13 +1,9 @@
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.eatvioapp.app">
|
||||
<!-- io.flutter.app.FlutterApplication is an android.app.Application that
|
||||
calls FlutterMain.startInitialization(this); in its onCreate method.
|
||||
In most cases you can leave this as-is, but you if you want to provide
|
||||
additional functionality it is fine to subclass or reimplement
|
||||
FlutterApplication and put your custom class here. -->
|
||||
|
||||
<uses-permission android:name="android.permission.INTERNET"/>
|
||||
|
||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
|
||||
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION"/>
|
||||
|
||||
<application
|
||||
android:label="Eatvio"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
allprojects {
|
||||
repositories {
|
||||
google()
|
||||
jcenter()
|
||||
mavenCentral()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -26,4 +26,4 @@
|
||||
<orderEntry type="library" name="Flutter for Android" level="project" />
|
||||
<orderEntry type="library" name="KotlinJavaRuntime" level="project" />
|
||||
</component>
|
||||
</module>
|
||||
</module>
|
||||
@@ -18,8 +18,8 @@ pluginManagement {
|
||||
|
||||
plugins {
|
||||
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
|
||||
id "com.android.application" version "7.3.0" apply false
|
||||
id "org.jetbrains.kotlin.android" version "1.7.10" apply false
|
||||
id "com.android.application" version "7.3.1" apply false
|
||||
id "org.jetbrains.kotlin.android" version "1.9.10" apply false
|
||||
}
|
||||
|
||||
include ":app"
|
||||
|
||||
97
flutter_01.log
Normal file
97
flutter_01.log
Normal file
@@ -0,0 +1,97 @@
|
||||
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.<anonymous closure> (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)
|
||||
<asynchronous suspension>
|
||||
#10 FlutterCommand.run.<anonymous closure> (package:flutter_tools/src/runner/flutter_command.dart:1394:27)
|
||||
<asynchronous suspension>
|
||||
#11 AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:153:19)
|
||||
<asynchronous suspension>
|
||||
#12 CommandRunner.runCommand (package:args/command_runner.dart:212:13)
|
||||
<asynchronous suspension>
|
||||
#13 FlutterCommandRunner.runCommand.<anonymous closure> (package:flutter_tools/src/runner/flutter_command_runner.dart:372:9)
|
||||
<asynchronous suspension>
|
||||
#14 AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:153:19)
|
||||
<asynchronous suspension>
|
||||
#15 FlutterCommandRunner.runCommand (package:flutter_tools/src/runner/flutter_command_runner.dart:308:5)
|
||||
<asynchronous suspension>
|
||||
#16 run.<anonymous closure>.<anonymous closure> (package:flutter_tools/runner.dart:130:9)
|
||||
<asynchronous suspension>
|
||||
#17 AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:153:19)
|
||||
<asynchronous suspension>
|
||||
#18 main (package:flutter_tools/executable.dart:93:3)
|
||||
<asynchronous suspension>
|
||||
```
|
||||
|
||||
## 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.
|
||||
```
|
||||
@@ -57,5 +57,7 @@
|
||||
<key>NSAllowsArbitraryLoads</key>
|
||||
<true/>
|
||||
</dict>
|
||||
<key>NSLocationWhenInUseUsageDescription</key>
|
||||
<string></string>
|
||||
</dict>
|
||||
</plist>
|
||||
|
||||
BIN
ios/build/ios/Pods.build/Release-iphonesimulator/FMDB.build/dgph
Normal file
BIN
ios/build/ios/Pods.build/Release-iphonesimulator/FMDB.build/dgph
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,37 +1,28 @@
|
||||
import 'package:eatvio_app/core/initialization_cubit/initialization_cubit.dart';
|
||||
import 'package:eatvio_app/core/token_storage.dart';
|
||||
import 'package:eatvio_app/features/blog_post/presentation/pages/blog_post_screen.dart';
|
||||
import 'package:eatvio_app/features/blog_post_create/presentation/pages/blog_post_create_screen.dart';
|
||||
import 'package:eatvio_app/features/bottom_navigation_bar/presentation/widgets/bottom_navigation_bar_widget.dart';
|
||||
import 'package:eatvio_app/features/calendar/presentation/pages/calendar_screen.dart';
|
||||
import 'package:eatvio_app/features/chat/presentation/pages/chat_screen.dart';
|
||||
import 'package:eatvio_app/features/chat/presentation/pages/chat_select_screen/chat_select_screen.dart';
|
||||
import 'package:eatvio_app/features/chat/presentation/pages/photo_view_screen.dart';
|
||||
import 'package:eatvio_app/features/diary/presentation/pages/diary_screen.dart';
|
||||
import 'package:eatvio_app/features/feed/models/recipes_model.dart';
|
||||
import 'package:eatvio_app/features/feed/presentation/pages/feed_screen.dart';
|
||||
import 'package:eatvio_app/features/recipes/presentation/pages/about_recipes_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/diary/diary_edit_screen/diary_edit_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_create_screen/blog_post_create_screen.dart';
|
||||
import 'package:eatvio_app/presentation/feed/blog_post_edit_screen/blog_post_edit_screen.dart';
|
||||
import 'package:eatvio_app/presentation/feed/blog_post_screen/blog_post_screen.dart';
|
||||
import 'package:eatvio_app/presentation/feed/feed_screen/feed_screen.dart';
|
||||
import 'package:eatvio_app/presentation/glossary/glossary_screen/glossary_screen.dart';
|
||||
import 'package:eatvio_app/presentation/plans/plan_select_screen/plan_select_screen.dart';
|
||||
import 'package:eatvio_app/presentation/profile/my_profile_screen/my_profile_screen.dart';
|
||||
import 'package:eatvio_app/presentation/profile/my_profile_screen/my_settings_screen.dart';
|
||||
import 'package:eatvio_app/presentation/recipe/recipe_select_screen/recipe_select_screen.dart';
|
||||
import 'package:eatvio_app/presentation/registration/additional_information_screen/additional_information_screen.dart';
|
||||
import 'package:eatvio_app/presentation/registration/allergies_screen/allergies_screen.dart';
|
||||
import 'package:eatvio_app/presentation/registration/blood_pressure_screen/blood_pressure_screen.dart';
|
||||
import 'package:eatvio_app/presentation/registration/body_circumferences_screen/body_circumferences_screen.dart';
|
||||
import 'package:eatvio_app/presentation/registration/city_of_living_screen/city_of_living_screen.dart';
|
||||
import 'package:eatvio_app/presentation/registration/credentials_screen/credentials_screen.dart';
|
||||
import 'package:eatvio_app/presentation/registration/date_of_birth_screen/date_of_birth_screen.dart';
|
||||
import 'package:eatvio_app/presentation/registration/favorite_foods_screen/favorite_foods_screen.dart';
|
||||
import 'package:eatvio_app/presentation/registration/favorite_sports_screen/favorite_sports_screen.dart';
|
||||
import 'package:eatvio_app/presentation/registration/gender_screen/gender_screen.dart';
|
||||
import 'package:eatvio_app/presentation/registration/height_screen/height_screen.dart';
|
||||
import 'package:eatvio_app/presentation/registration/language_select_screen/language_select_screen.dart';
|
||||
import 'package:eatvio_app/presentation/registration/medicine_intake_screen/medicine_intake_screen.dart';
|
||||
import 'package:eatvio_app/presentation/registration/name_screen/name_screen.dart';
|
||||
import 'package:eatvio_app/presentation/registration/weight_screen/weight_screen.dart';
|
||||
import 'package:eatvio_app/widgets/bottom_navigation_bar_widget.dart';
|
||||
import 'package:eatvio_app/features/chat/presentation/pages/photo_view_screen.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
|
||||
class AppRouter {
|
||||
@@ -45,111 +36,17 @@ class AppRouter {
|
||||
path: '/auth-screen',
|
||||
name: 'authScreen',
|
||||
redirect: (context, state) async {
|
||||
if (await TokenStorage.haveTokenInStorage()) return '/my-profile-screen';
|
||||
if (await TokenStorage.haveTokenInStorage()) {
|
||||
return '/my-profile-screen';
|
||||
}
|
||||
return null;
|
||||
},
|
||||
builder: (context, state) => AuthScreen.builder(context),
|
||||
routes: [
|
||||
GoRoute(
|
||||
path: 'language-select-screen',
|
||||
name: 'languageSelectScreen',
|
||||
builder: (context, state) => LanguageSelectScreen.builder(context),
|
||||
routes: [
|
||||
GoRoute(
|
||||
path: 'credentials-screen',
|
||||
name: 'credentialsScreen',
|
||||
builder: (context, state) => CredentialsScreen.builder(context, state.extra),
|
||||
routes: [
|
||||
GoRoute(
|
||||
path: 'name-screen',
|
||||
name: 'nameScreen',
|
||||
builder: (context, state) => NameScreen.builder(context, state.extra),
|
||||
routes: [
|
||||
GoRoute(
|
||||
path: 'gender-screen',
|
||||
name: 'genderScreen',
|
||||
builder: (context, state) => GenderScreen.builder(context, state.extra),
|
||||
routes: [
|
||||
GoRoute(
|
||||
path: 'date-of-birth-screen',
|
||||
name: 'dateOfBirthScreen',
|
||||
builder: (context, state) => DateOfBirthScreen.builder(context, state.extra),
|
||||
routes: [
|
||||
GoRoute(
|
||||
path: 'city-of-living-screen',
|
||||
name: 'cityOfLivingScreen',
|
||||
builder: (context, state) => CityOfLivingScreen.builder(context, state.extra),
|
||||
routes: [
|
||||
GoRoute(
|
||||
path: 'body-circumferences-screen',
|
||||
name: 'bodyCircumferencesScreen',
|
||||
builder: (context, state) => BodyCircumferencesScreen.builder(context, state.extra),
|
||||
routes: [
|
||||
GoRoute(
|
||||
path: 'weight-screen',
|
||||
name: 'weightScreen',
|
||||
builder: (context, state) => WeightScreen.builder(context, state.extra),
|
||||
routes: [
|
||||
GoRoute(
|
||||
path: 'height-screen',
|
||||
name: 'heightScreen',
|
||||
builder: (context, state) => HeightScreen.builder(context, state.extra),
|
||||
routes: [
|
||||
GoRoute(
|
||||
path: 'blood-pressure-screen',
|
||||
name: 'bloodPressureScreen',
|
||||
builder: (context, state) => BloodPressureScreen.builder(context, state.extra),
|
||||
routes: [
|
||||
GoRoute(
|
||||
path: 'favorite-sports-screen',
|
||||
name: 'favoriteSportsScreen',
|
||||
builder: (context, state) => FavoriteSportsScreen.builder(context, state.extra),
|
||||
routes: [
|
||||
GoRoute(
|
||||
name: 'allergiesScreen',
|
||||
path: 'allergiesScreen',
|
||||
builder: (context, state) => AllergiesScreen.builder(context, state.extra),
|
||||
routes: [
|
||||
GoRoute(
|
||||
name: 'medicineIntakeScreen',
|
||||
path: 'medicine-intake-screen',
|
||||
builder: (context, state) => MedicineIntakeScreen.builder(context, state.extra),
|
||||
),
|
||||
GoRoute(
|
||||
name: 'favoriteFoodsScreen',
|
||||
path: 'favorite-foods-screen',
|
||||
builder: (context, state) => FavoriteFoodsScreen.builder(context, state.extra),
|
||||
routes: [
|
||||
GoRoute(
|
||||
path: 'additional-information-screen',
|
||||
name: 'additionalInformationScreen',
|
||||
builder: (context, state) => AdditionalInformationScreen.builder(context, state.extra),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
path: 'registration-screen',
|
||||
name: 'registrationScreen',
|
||||
builder: (context, state) => const RegistrationScreen(),
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -161,43 +58,26 @@ class AppRouter {
|
||||
GoRoute(
|
||||
path: '/my-profile-screen',
|
||||
name: 'myProfileScreen',
|
||||
redirect: (context, state) async {
|
||||
await context.read<InitializationCubit>().runInitialization();
|
||||
return null;
|
||||
},
|
||||
builder: (context, state) => MyProfileScreen(),
|
||||
),
|
||||
GoRoute(
|
||||
path: '/feed-screen',
|
||||
name: 'feedScreen',
|
||||
builder: (context, state) => FeedScreen(),
|
||||
routes: [
|
||||
GoRoute(
|
||||
path: 'blog-post-create-screen',
|
||||
name: 'blogPostCreateScreen',
|
||||
builder: (context, state) => BlogPostCreateScreen.builder(context),
|
||||
),
|
||||
GoRoute(
|
||||
path: 'blog-post-screen',
|
||||
name: 'blogPostScreen',
|
||||
builder: (context, state) => BlogPostScreen.builder(
|
||||
context,
|
||||
state.extra.toString(),
|
||||
),
|
||||
routes: [
|
||||
GoRoute(
|
||||
path: 'blog-post-edit-screen',
|
||||
name: 'blogPostEditScreen',
|
||||
builder: (context, state) => BlogPostEditScreen.builder(
|
||||
context,
|
||||
state.extra,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
GoRoute(
|
||||
path: '/diary-screen',
|
||||
name: 'diaryScreen',
|
||||
builder: (context, state) => DiaryEditScreen(),
|
||||
),
|
||||
path: '/diary-screen',
|
||||
name: 'diaryScreen',
|
||||
builder: (context, state) {
|
||||
if (state.extra != null)
|
||||
return DiaryScreen(diaryID: state.extra as String);
|
||||
else
|
||||
return DiaryScreen(diaryID: '0');
|
||||
}),
|
||||
GoRoute(
|
||||
path: '/chat-select-screen',
|
||||
name: 'chatSelectScreen',
|
||||
@@ -205,6 +85,32 @@ class AppRouter {
|
||||
),
|
||||
],
|
||||
),
|
||||
GoRoute(
|
||||
path: '/about-recipes-screen',
|
||||
name: 'aboutRecipesScreen',
|
||||
builder: (context, state) => AboutRecipesScreen(
|
||||
recipes: state.extra as Recipes,
|
||||
),
|
||||
),
|
||||
GoRoute(
|
||||
path: '/blog-post-create-screen',
|
||||
name: 'blogPostCreateScreen',
|
||||
builder: (context, state) => BlogPostCreateScreen.builder(context),
|
||||
),
|
||||
GoRoute(
|
||||
path: '/blog-post-screen',
|
||||
name: 'blogPostScreen',
|
||||
builder: (context, state) =>
|
||||
BlogPostScreen(blogPostID: state.extra as String),
|
||||
),
|
||||
GoRoute(
|
||||
path: '/blog-post-edit-screen',
|
||||
name: 'blogPostEditScreen',
|
||||
builder: (context, state) => BlogPostEditScreen.builder(
|
||||
context,
|
||||
state.extra,
|
||||
),
|
||||
),
|
||||
GoRoute(
|
||||
path: '/chat-screen',
|
||||
name: 'chatScreen',
|
||||
@@ -235,6 +141,11 @@ class AppRouter {
|
||||
name: 'planSelectScreen',
|
||||
builder: (context, state) => PlanSelectScreen.builder(context),
|
||||
),
|
||||
GoRoute(
|
||||
path: '/calendar-screen',
|
||||
name: 'calendarScreen',
|
||||
builder: (context, state) => CalendarScreen(),
|
||||
),
|
||||
GoRoute(
|
||||
path: '/glossary-screen',
|
||||
name: 'glossaryScreen',
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
export 'package:flutter_bloc/flutter_bloc.dart';
|
||||
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/pref_utils.dart';
|
||||
@@ -11,6 +11,7 @@ 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/bloc/theme_bloc.dart';
|
||||
export '../theme/custom_button_style.dart';
|
||||
export 'package:eatvio_app/core/utils/date_time_utils.dart';
|
||||
|
||||
@@ -1 +1 @@
|
||||
|
||||
const String baseUrl = 'https://dev2.eatvio.com';
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:eatvio_app/main.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class ServerException implements Exception {}
|
||||
|
||||
@@ -13,8 +13,7 @@ class NoInternetException implements Exception {
|
||||
|
||||
NoInternetException([String message = 'NoInternetException Occurred']) {
|
||||
if (globalMessengerKey.currentState != null) {
|
||||
globalMessengerKey.currentState!
|
||||
.showSnackBar(SnackBar(content: Text(message)));
|
||||
globalMessengerKey.currentState!.showSnackBar(SnackBar(content: Text(message)));
|
||||
}
|
||||
this._message = message;
|
||||
}
|
||||
|
||||
@@ -1,61 +1,100 @@
|
||||
import 'package:dart_pusher_channels/dart_pusher_channels.dart';
|
||||
import 'package:eatvio_app/core/app_export.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';
|
||||
|
||||
class InitializationCubit extends Cubit<InitializationState> {
|
||||
final ChatRepository chatRepository;
|
||||
bool wasInitialized = false;
|
||||
|
||||
InitializationCubit({required this.chatRepository}) : super(const InitializationState.loading());
|
||||
|
||||
runInitialization() async {
|
||||
try {
|
||||
await TokenStorage.haveTokenInStorage();
|
||||
// final wsUrl = await chatRepository.getWebsocket();
|
||||
// final options = PusherChannelsOptions.fromHost(
|
||||
// scheme: 'wss',
|
||||
// key: wsUrl.key,
|
||||
// host: wsUrl.host,
|
||||
// shouldSupplyMetadataQueries: true,
|
||||
// metadata: PusherChannelsOptionsMetadata.byDefault(),
|
||||
// port: 443,
|
||||
// );
|
||||
// final client = PusherChannelsClient.websocket(
|
||||
// options: options,
|
||||
// connectionErrorHandler: (exception, trace, refresh) {
|
||||
// refresh();
|
||||
// },
|
||||
// minimumReconnectDelayDuration: const Duration(
|
||||
// seconds: 1,
|
||||
// ),
|
||||
// defaultActivityDuration: const Duration(
|
||||
// seconds: 120,
|
||||
// ),
|
||||
// activityDurationOverride: const Duration(
|
||||
// seconds: 120,
|
||||
// ),
|
||||
// waitForPongDuration: const Duration(
|
||||
// seconds: 30,
|
||||
// ),
|
||||
// );
|
||||
// await client.connect();
|
||||
// final myPrivateChannel = client.privateChannel(
|
||||
// 'private-message-events.${wsUrl.userId}',
|
||||
// authorizationDelegate: EndpointAuthorizableChannelTokenAuthorizationDelegate.forPrivateChannel(
|
||||
// authorizationEndpoint: Uri.parse('https://mobile-stage.eatvio.ru/broadcasting/auth'),
|
||||
// headers: {
|
||||
// 'Authorization' : 'Bearer ${await TokenStorage.getTokenFromStorage()}',
|
||||
// },
|
||||
// ),
|
||||
// );
|
||||
// myPrivateChannel.subscribe();
|
||||
// myPrivateChannel.bindToAll().listen((event) {
|
||||
// print(event.name);
|
||||
// });
|
||||
emit(const InitializationState.success());
|
||||
} catch (e) {
|
||||
print(e);
|
||||
emit(InitializationState.error(errorMessage: e.toString()));
|
||||
Future<void> subscribeNotifications(int userId, PusherChannelsClient client) async {
|
||||
final privateNotificationChannel = await client.privateChannel(
|
||||
'private-message-events.$userId',
|
||||
authorizationDelegate: EndpointAuthorizableChannelTokenAuthorizationDelegate.forPrivateChannel(
|
||||
authorizationEndpoint: Uri.parse(baseUrl + '/broadcasting/auth'),
|
||||
headers: {
|
||||
'Authorization': 'Bearer ${await TokenStorage.getTokenFromStorage()}',
|
||||
},
|
||||
),
|
||||
);
|
||||
|
||||
privateNotificationChannel.subscribe();
|
||||
|
||||
privateNotificationChannel.bindToAll().listen((event) {
|
||||
sl<NotificationsCubit>().incrementCounter();
|
||||
});
|
||||
}
|
||||
|
||||
Future<void> subscribeChatMessages(int userId, PusherChannelsClient client) async {
|
||||
final privateMessagesChannel = await client.privateChannel(
|
||||
'private-new-chat-messages.$userId',
|
||||
authorizationDelegate: EndpointAuthorizableChannelTokenAuthorizationDelegate.forPrivateChannel(
|
||||
authorizationEndpoint: Uri.parse(baseUrl + '/broadcasting/auth'),
|
||||
headers: {
|
||||
'Authorization': 'Bearer ${await TokenStorage.getTokenFromStorage()}',
|
||||
},
|
||||
),
|
||||
);
|
||||
|
||||
privateMessagesChannel.subscribe();
|
||||
|
||||
privateMessagesChannel.bindToAll().listen((event) {
|
||||
sl<NewMessagesCubit>().incrementCounter();
|
||||
});
|
||||
}
|
||||
|
||||
Future<void> runInitialization() async {
|
||||
if (!wasInitialized) {
|
||||
wasInitialized = true;
|
||||
try {
|
||||
await TokenStorage.haveTokenInStorage();
|
||||
final wsUrl = await chatRepository.getWebsocket();
|
||||
final options = PusherChannelsOptions.fromHost(
|
||||
scheme: 'wss',
|
||||
key: wsUrl.key,
|
||||
host: wsUrl.host,
|
||||
shouldSupplyMetadataQueries: true,
|
||||
metadata: PusherChannelsOptionsMetadata.byDefault(),
|
||||
port: 443,
|
||||
);
|
||||
final client = PusherChannelsClient.websocket(
|
||||
options: options,
|
||||
connectionErrorHandler: (exception, trace, refresh) {
|
||||
refresh();
|
||||
},
|
||||
minimumReconnectDelayDuration: const Duration(
|
||||
seconds: 1,
|
||||
),
|
||||
defaultActivityDuration: const Duration(
|
||||
seconds: 120,
|
||||
),
|
||||
activityDurationOverride: const Duration(
|
||||
seconds: 120,
|
||||
),
|
||||
waitForPongDuration: const Duration(
|
||||
seconds: 30,
|
||||
),
|
||||
);
|
||||
await client.connect();
|
||||
|
||||
await subscribeNotifications(wsUrl.userId, client);
|
||||
await subscribeChatMessages(wsUrl.userId, client);
|
||||
|
||||
emit(InitializationState.success(
|
||||
client: client,
|
||||
));
|
||||
} catch (e) {
|
||||
emit(InitializationState.error(
|
||||
errorMessage: e.toString(),
|
||||
));
|
||||
rethrow;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import 'package:dart_pusher_channels/dart_pusher_channels.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
||||
part 'initialization_state.freezed.dart';
|
||||
@@ -8,7 +9,11 @@ abstract class InitializationState with _$InitializationState {
|
||||
|
||||
const factory InitializationState.loading() = InitializationStateLoading;
|
||||
|
||||
const factory InitializationState.success() = InitializationStateSuccess;
|
||||
const factory InitializationState.success({
|
||||
required PusherChannelsClient client,
|
||||
}) = InitializationStateSuccess;
|
||||
|
||||
const factory InitializationState.error({required String errorMessage}) = InitializationStateError;
|
||||
const factory InitializationState.error({
|
||||
required String errorMessage,
|
||||
}) = InitializationStateError;
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ mixin _$InitializationState {
|
||||
TResult when<TResult extends Object?>(
|
||||
TResult Function() $default, {
|
||||
required TResult Function() loading,
|
||||
required TResult Function() success,
|
||||
required TResult Function(PusherChannelsClient client) success,
|
||||
required TResult Function(String errorMessage) error,
|
||||
}) =>
|
||||
throw _privateConstructorUsedError;
|
||||
@@ -28,7 +28,7 @@ mixin _$InitializationState {
|
||||
TResult? whenOrNull<TResult extends Object?>(
|
||||
TResult? Function()? $default, {
|
||||
TResult? Function()? loading,
|
||||
TResult? Function()? success,
|
||||
TResult? Function(PusherChannelsClient client)? success,
|
||||
TResult? Function(String errorMessage)? error,
|
||||
}) =>
|
||||
throw _privateConstructorUsedError;
|
||||
@@ -36,7 +36,7 @@ mixin _$InitializationState {
|
||||
TResult maybeWhen<TResult extends Object?>(
|
||||
TResult Function()? $default, {
|
||||
TResult Function()? loading,
|
||||
TResult Function()? success,
|
||||
TResult Function(PusherChannelsClient client)? success,
|
||||
TResult Function(String errorMessage)? error,
|
||||
required TResult orElse(),
|
||||
}) =>
|
||||
@@ -127,7 +127,7 @@ class _$InitializationStateImpl implements _InitializationState {
|
||||
TResult when<TResult extends Object?>(
|
||||
TResult Function() $default, {
|
||||
required TResult Function() loading,
|
||||
required TResult Function() success,
|
||||
required TResult Function(PusherChannelsClient client) success,
|
||||
required TResult Function(String errorMessage) error,
|
||||
}) {
|
||||
return $default();
|
||||
@@ -138,7 +138,7 @@ class _$InitializationStateImpl implements _InitializationState {
|
||||
TResult? whenOrNull<TResult extends Object?>(
|
||||
TResult? Function()? $default, {
|
||||
TResult? Function()? loading,
|
||||
TResult? Function()? success,
|
||||
TResult? Function(PusherChannelsClient client)? success,
|
||||
TResult? Function(String errorMessage)? error,
|
||||
}) {
|
||||
return $default?.call();
|
||||
@@ -149,7 +149,7 @@ class _$InitializationStateImpl implements _InitializationState {
|
||||
TResult maybeWhen<TResult extends Object?>(
|
||||
TResult Function()? $default, {
|
||||
TResult Function()? loading,
|
||||
TResult Function()? success,
|
||||
TResult Function(PusherChannelsClient client)? success,
|
||||
TResult Function(String errorMessage)? error,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
@@ -245,7 +245,7 @@ class _$InitializationStateLoadingImpl implements InitializationStateLoading {
|
||||
TResult when<TResult extends Object?>(
|
||||
TResult Function() $default, {
|
||||
required TResult Function() loading,
|
||||
required TResult Function() success,
|
||||
required TResult Function(PusherChannelsClient client) success,
|
||||
required TResult Function(String errorMessage) error,
|
||||
}) {
|
||||
return loading();
|
||||
@@ -256,7 +256,7 @@ class _$InitializationStateLoadingImpl implements InitializationStateLoading {
|
||||
TResult? whenOrNull<TResult extends Object?>(
|
||||
TResult? Function()? $default, {
|
||||
TResult? Function()? loading,
|
||||
TResult? Function()? success,
|
||||
TResult? Function(PusherChannelsClient client)? success,
|
||||
TResult? Function(String errorMessage)? error,
|
||||
}) {
|
||||
return loading?.call();
|
||||
@@ -267,7 +267,7 @@ class _$InitializationStateLoadingImpl implements InitializationStateLoading {
|
||||
TResult maybeWhen<TResult extends Object?>(
|
||||
TResult Function()? $default, {
|
||||
TResult Function()? loading,
|
||||
TResult Function()? success,
|
||||
TResult Function(PusherChannelsClient client)? success,
|
||||
TResult Function(String errorMessage)? error,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
@@ -325,6 +325,8 @@ abstract class _$$InitializationStateSuccessImplCopyWith<$Res> {
|
||||
_$InitializationStateSuccessImpl value,
|
||||
$Res Function(_$InitializationStateSuccessImpl) then) =
|
||||
__$$InitializationStateSuccessImplCopyWithImpl<$Res>;
|
||||
@useResult
|
||||
$Res call({PusherChannelsClient client});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@@ -336,37 +338,61 @@ class __$$InitializationStateSuccessImplCopyWithImpl<$Res>
|
||||
_$InitializationStateSuccessImpl _value,
|
||||
$Res Function(_$InitializationStateSuccessImpl) _then)
|
||||
: super(_value, _then);
|
||||
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? client = null,
|
||||
}) {
|
||||
return _then(_$InitializationStateSuccessImpl(
|
||||
client: null == client
|
||||
? _value.client
|
||||
: client // ignore: cast_nullable_to_non_nullable
|
||||
as PusherChannelsClient,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
class _$InitializationStateSuccessImpl implements InitializationStateSuccess {
|
||||
const _$InitializationStateSuccessImpl();
|
||||
const _$InitializationStateSuccessImpl({required this.client});
|
||||
|
||||
@override
|
||||
final PusherChannelsClient client;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'InitializationState.success()';
|
||||
return 'InitializationState.success(client: $client)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$InitializationStateSuccessImpl);
|
||||
other is _$InitializationStateSuccessImpl &&
|
||||
(identical(other.client, client) || other.client == client));
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => runtimeType.hashCode;
|
||||
int get hashCode => Object.hash(runtimeType, client);
|
||||
|
||||
@JsonKey(ignore: true)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$InitializationStateSuccessImplCopyWith<_$InitializationStateSuccessImpl>
|
||||
get copyWith => __$$InitializationStateSuccessImplCopyWithImpl<
|
||||
_$InitializationStateSuccessImpl>(this, _$identity);
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult when<TResult extends Object?>(
|
||||
TResult Function() $default, {
|
||||
required TResult Function() loading,
|
||||
required TResult Function() success,
|
||||
required TResult Function(PusherChannelsClient client) success,
|
||||
required TResult Function(String errorMessage) error,
|
||||
}) {
|
||||
return success();
|
||||
return success(client);
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -374,10 +400,10 @@ class _$InitializationStateSuccessImpl implements InitializationStateSuccess {
|
||||
TResult? whenOrNull<TResult extends Object?>(
|
||||
TResult? Function()? $default, {
|
||||
TResult? Function()? loading,
|
||||
TResult? Function()? success,
|
||||
TResult? Function(PusherChannelsClient client)? success,
|
||||
TResult? Function(String errorMessage)? error,
|
||||
}) {
|
||||
return success?.call();
|
||||
return success?.call(client);
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -385,12 +411,12 @@ class _$InitializationStateSuccessImpl implements InitializationStateSuccess {
|
||||
TResult maybeWhen<TResult extends Object?>(
|
||||
TResult Function()? $default, {
|
||||
TResult Function()? loading,
|
||||
TResult Function()? success,
|
||||
TResult Function(PusherChannelsClient client)? success,
|
||||
TResult Function(String errorMessage)? error,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (success != null) {
|
||||
return success();
|
||||
return success(client);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
@@ -434,7 +460,14 @@ class _$InitializationStateSuccessImpl implements InitializationStateSuccess {
|
||||
}
|
||||
|
||||
abstract class InitializationStateSuccess implements InitializationState {
|
||||
const factory InitializationStateSuccess() = _$InitializationStateSuccessImpl;
|
||||
const factory InitializationStateSuccess(
|
||||
{required final PusherChannelsClient client}) =
|
||||
_$InitializationStateSuccessImpl;
|
||||
|
||||
PusherChannelsClient get client;
|
||||
@JsonKey(ignore: true)
|
||||
_$$InitializationStateSuccessImplCopyWith<_$InitializationStateSuccessImpl>
|
||||
get copyWith => throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@@ -508,7 +541,7 @@ class _$InitializationStateErrorImpl implements InitializationStateError {
|
||||
TResult when<TResult extends Object?>(
|
||||
TResult Function() $default, {
|
||||
required TResult Function() loading,
|
||||
required TResult Function() success,
|
||||
required TResult Function(PusherChannelsClient client) success,
|
||||
required TResult Function(String errorMessage) error,
|
||||
}) {
|
||||
return error(errorMessage);
|
||||
@@ -519,7 +552,7 @@ class _$InitializationStateErrorImpl implements InitializationStateError {
|
||||
TResult? whenOrNull<TResult extends Object?>(
|
||||
TResult? Function()? $default, {
|
||||
TResult? Function()? loading,
|
||||
TResult? Function()? success,
|
||||
TResult? Function(PusherChannelsClient client)? success,
|
||||
TResult? Function(String errorMessage)? error,
|
||||
}) {
|
||||
return error?.call(errorMessage);
|
||||
@@ -530,7 +563,7 @@ class _$InitializationStateErrorImpl implements InitializationStateError {
|
||||
TResult maybeWhen<TResult extends Object?>(
|
||||
TResult Function()? $default, {
|
||||
TResult Function()? loading,
|
||||
TResult Function()? success,
|
||||
TResult Function(PusherChannelsClient client)? success,
|
||||
TResult Function(String errorMessage)? error,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
|
||||
@@ -15,6 +15,7 @@ class ImageConstant {
|
||||
static String imageNotFound = 'assets/images/image_not_found.png';
|
||||
|
||||
static String imaGlass = 'assets/images/image_glass.svg';
|
||||
|
||||
// Настройки images
|
||||
|
||||
static String imgClose = '$imagePath/img_close.svg';
|
||||
@@ -24,15 +25,13 @@ class ImageConstant {
|
||||
// Блог images
|
||||
static String imgRectangle14 = '$imagePath/img_rectangle_14.png';
|
||||
|
||||
static String imgRectangle14220x341 =
|
||||
'$imagePath/img_rectangle_14_220x341.png';
|
||||
static String imgRectangle14220x341 = '$imagePath/img_rectangle_14_220x341.png';
|
||||
|
||||
// Блог - Tab Container images
|
||||
static String imgCrop = '$imagePath/img_crop.svg';
|
||||
|
||||
// Статья images
|
||||
static String imgRectangle14220x375 =
|
||||
'$imagePath/img_rectangle_14_220x375.png';
|
||||
static String imgRectangle14220x375 = '$imagePath/img_rectangle_14_220x375.png';
|
||||
|
||||
static String imgVector = '$imagePath/img_vector.svg';
|
||||
|
||||
@@ -116,13 +115,11 @@ class ImageConstant {
|
||||
|
||||
static String imgNavBlueGray400 = '$imagePath/img_nav_blue_gray_400.svg';
|
||||
|
||||
static String imgNavBlueGray40024x23 =
|
||||
'$imagePath/img_nav_blue_gray_400_24x23.svg';
|
||||
static String imgNavBlueGray40024x23 = '$imagePath/img_nav_blue_gray_400_24x23.svg';
|
||||
|
||||
static String imgNavPrimary = '$imagePath/img_nav_primary.svg';
|
||||
|
||||
static String imgNavBlueGray40024x25 =
|
||||
'$imagePath/img_nav_blue_gray_400_24x25.svg';
|
||||
static String imgNavBlueGray40024x25 = '$imagePath/img_nav_blue_gray_400_24x25.svg';
|
||||
|
||||
static String imgEye = '$imagePath/img_eye.svg';
|
||||
|
||||
@@ -134,11 +131,9 @@ class ImageConstant {
|
||||
|
||||
static String imgEllipse142x42 = '$imagePath/img_ellipse_1_42x42.png';
|
||||
|
||||
static String imgIconMoreHorizontal =
|
||||
'$imagePath/img_icon_more_horizontal.svg';
|
||||
static String imgIconMoreHorizontal = '$imagePath/img_icon_more_horizontal.svg';
|
||||
|
||||
static String imgRectangle14250x311 =
|
||||
'$imagePath/img_rectangle_14_250x311.png';
|
||||
static String imgRectangle14250x311 = '$imagePath/img_rectangle_14_250x311.png';
|
||||
|
||||
static String imgIconMessageSquare = '$imagePath/img_icon_message_square.svg';
|
||||
|
||||
|
||||
@@ -8,18 +8,19 @@ class ProgressDialogUtils {
|
||||
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<Color>(
|
||||
Colors.white,
|
||||
),
|
||||
barrierDismissible: isCancellable,
|
||||
context: AppRouter.navigatorKey.currentState!.overlay!.context,
|
||||
builder: (BuildContext context) {
|
||||
return Center(
|
||||
child: CircularProgressIndicator.adaptive(
|
||||
strokeWidth: 4,
|
||||
valueColor: AlwaysStoppedAnimation<Color>(
|
||||
Colors.white,
|
||||
),
|
||||
);
|
||||
},);
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
isProgressVisible = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,8 @@ 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,);
|
||||
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.
|
||||
@@ -30,8 +31,7 @@ extension ResponsiveExtension on num {
|
||||
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);
|
||||
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 {
|
||||
|
||||
@@ -1,15 +1,13 @@
|
||||
///SelectionPopupModel is common model
|
||||
///used for setting data into dropdowns
|
||||
class SelectionPopupModel {
|
||||
int? id;
|
||||
String title;
|
||||
dynamic value;
|
||||
bool isSelected;
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
||||
SelectionPopupModel({
|
||||
this.id,
|
||||
required this.title,
|
||||
this.value,
|
||||
this.isSelected = false,
|
||||
});
|
||||
part 'selection_popup_model.freezed.dart';
|
||||
|
||||
@freezed
|
||||
class SelectionPopupModel with _$SelectionPopupModel {
|
||||
const factory SelectionPopupModel({
|
||||
int? id,
|
||||
required String title,
|
||||
dynamic value,
|
||||
@Default(false) bool isSelected,
|
||||
}) = _SelectionPopupModel;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,189 @@
|
||||
// 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 'selection_popup_model.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// FreezedGenerator
|
||||
// **************************************************************************
|
||||
|
||||
T _$identity<T>(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 _$SelectionPopupModel {
|
||||
int? get id => throw _privateConstructorUsedError;
|
||||
String get title => throw _privateConstructorUsedError;
|
||||
dynamic get value => throw _privateConstructorUsedError;
|
||||
bool get isSelected => throw _privateConstructorUsedError;
|
||||
|
||||
@JsonKey(ignore: true)
|
||||
$SelectionPopupModelCopyWith<SelectionPopupModel> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class $SelectionPopupModelCopyWith<$Res> {
|
||||
factory $SelectionPopupModelCopyWith(
|
||||
SelectionPopupModel value, $Res Function(SelectionPopupModel) then) =
|
||||
_$SelectionPopupModelCopyWithImpl<$Res, SelectionPopupModel>;
|
||||
@useResult
|
||||
$Res call({int? id, String title, dynamic value, bool isSelected});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class _$SelectionPopupModelCopyWithImpl<$Res, $Val extends SelectionPopupModel>
|
||||
implements $SelectionPopupModelCopyWith<$Res> {
|
||||
_$SelectionPopupModelCopyWithImpl(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 = freezed,
|
||||
Object? title = null,
|
||||
Object? value = freezed,
|
||||
Object? isSelected = null,
|
||||
}) {
|
||||
return _then(_value.copyWith(
|
||||
id: freezed == id
|
||||
? _value.id
|
||||
: id // ignore: cast_nullable_to_non_nullable
|
||||
as int?,
|
||||
title: null == title
|
||||
? _value.title
|
||||
: title // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
value: freezed == value
|
||||
? _value.value
|
||||
: value // ignore: cast_nullable_to_non_nullable
|
||||
as dynamic,
|
||||
isSelected: null == isSelected
|
||||
? _value.isSelected
|
||||
: isSelected // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
) as $Val);
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$SelectionPopupModelImplCopyWith<$Res>
|
||||
implements $SelectionPopupModelCopyWith<$Res> {
|
||||
factory _$$SelectionPopupModelImplCopyWith(_$SelectionPopupModelImpl value,
|
||||
$Res Function(_$SelectionPopupModelImpl) then) =
|
||||
__$$SelectionPopupModelImplCopyWithImpl<$Res>;
|
||||
@override
|
||||
@useResult
|
||||
$Res call({int? id, String title, dynamic value, bool isSelected});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$SelectionPopupModelImplCopyWithImpl<$Res>
|
||||
extends _$SelectionPopupModelCopyWithImpl<$Res, _$SelectionPopupModelImpl>
|
||||
implements _$$SelectionPopupModelImplCopyWith<$Res> {
|
||||
__$$SelectionPopupModelImplCopyWithImpl(_$SelectionPopupModelImpl _value,
|
||||
$Res Function(_$SelectionPopupModelImpl) _then)
|
||||
: super(_value, _then);
|
||||
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? id = freezed,
|
||||
Object? title = null,
|
||||
Object? value = freezed,
|
||||
Object? isSelected = null,
|
||||
}) {
|
||||
return _then(_$SelectionPopupModelImpl(
|
||||
id: freezed == id
|
||||
? _value.id
|
||||
: id // ignore: cast_nullable_to_non_nullable
|
||||
as int?,
|
||||
title: null == title
|
||||
? _value.title
|
||||
: title // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
value: freezed == value
|
||||
? _value.value
|
||||
: value // ignore: cast_nullable_to_non_nullable
|
||||
as dynamic,
|
||||
isSelected: null == isSelected
|
||||
? _value.isSelected
|
||||
: isSelected // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
class _$SelectionPopupModelImpl implements _SelectionPopupModel {
|
||||
const _$SelectionPopupModelImpl(
|
||||
{this.id, required this.title, this.value, this.isSelected = false});
|
||||
|
||||
@override
|
||||
final int? id;
|
||||
@override
|
||||
final String title;
|
||||
@override
|
||||
final dynamic value;
|
||||
@override
|
||||
@JsonKey()
|
||||
final bool isSelected;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'SelectionPopupModel(id: $id, title: $title, value: $value, isSelected: $isSelected)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$SelectionPopupModelImpl &&
|
||||
(identical(other.id, id) || other.id == id) &&
|
||||
(identical(other.title, title) || other.title == title) &&
|
||||
const DeepCollectionEquality().equals(other.value, value) &&
|
||||
(identical(other.isSelected, isSelected) ||
|
||||
other.isSelected == isSelected));
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType, id, title,
|
||||
const DeepCollectionEquality().hash(value), isSelected);
|
||||
|
||||
@JsonKey(ignore: true)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$SelectionPopupModelImplCopyWith<_$SelectionPopupModelImpl> get copyWith =>
|
||||
__$$SelectionPopupModelImplCopyWithImpl<_$SelectionPopupModelImpl>(
|
||||
this, _$identity);
|
||||
}
|
||||
|
||||
abstract class _SelectionPopupModel implements SelectionPopupModel {
|
||||
const factory _SelectionPopupModel(
|
||||
{final int? id,
|
||||
required final String title,
|
||||
final dynamic value,
|
||||
final bool isSelected}) = _$SelectionPopupModelImpl;
|
||||
|
||||
@override
|
||||
int? get id;
|
||||
@override
|
||||
String get title;
|
||||
@override
|
||||
dynamic get value;
|
||||
@override
|
||||
bool get isSelected;
|
||||
@override
|
||||
@JsonKey(ignore: true)
|
||||
_$$SelectionPopupModelImplCopyWith<_$SelectionPopupModelImpl> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
import 'package:hive/hive.dart';
|
||||
|
||||
/// https://pub.dev/packages/flutter_secure_storage TODO replace hive to secure_storage for token storage
|
||||
@HiveType(typeId: 0)
|
||||
class TokenModel {
|
||||
|
||||
@@ -1,92 +1,39 @@
|
||||
class UserRegistrationSheet {
|
||||
String name;
|
||||
String firstName;
|
||||
String lastName;
|
||||
String email;
|
||||
String password;
|
||||
String passwordConfirmation;
|
||||
String termsAccepted;
|
||||
String birthdate;
|
||||
String gender;
|
||||
String country;
|
||||
String city;
|
||||
String lang;
|
||||
String weight;
|
||||
String height;
|
||||
String chestCircumference;
|
||||
String waistCircumference;
|
||||
String hipCircumference;
|
||||
String bloodPressureUp;
|
||||
String bloodPressureDown;
|
||||
String hasHypo = '';
|
||||
String hasHyper = '';
|
||||
String aboutAllergy = '';
|
||||
String aboutTakingPils = '';
|
||||
String aboutSportHobbies = '';
|
||||
String favoriteFoods = '';
|
||||
String unfavoriteFoods = '';
|
||||
String additionalInfo = '';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
||||
UserRegistrationSheet({
|
||||
required this.name,
|
||||
required this.firstName,
|
||||
required this.lastName,
|
||||
required this.email,
|
||||
required this.password,
|
||||
required this.passwordConfirmation,
|
||||
required this.termsAccepted,
|
||||
required this.birthdate,
|
||||
required this.gender,
|
||||
required this.country,
|
||||
required this.city,
|
||||
required this.lang,
|
||||
required this.weight,
|
||||
required this.height,
|
||||
required this.chestCircumference,
|
||||
required this.waistCircumference,
|
||||
required this.hipCircumference,
|
||||
required this.bloodPressureUp,
|
||||
required this.bloodPressureDown,
|
||||
required this.hasHypo,
|
||||
required this.hasHyper,
|
||||
required this.aboutAllergy,
|
||||
required this.aboutTakingPils,
|
||||
required this.aboutSportHobbies,
|
||||
required this.favoriteFoods,
|
||||
required this.unfavoriteFoods,
|
||||
required this.additionalInfo,
|
||||
});
|
||||
part 'user_registration_model.freezed.dart';
|
||||
part 'user_registration_model.g.dart';
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'name': name,
|
||||
'first_name': firstName,
|
||||
'last_name': lastName,
|
||||
'email': email,
|
||||
'password': password,
|
||||
'password_confirmation': passwordConfirmation,
|
||||
'terms': termsAccepted,
|
||||
'birthdate': birthdate.toString(),
|
||||
'gender': gender,
|
||||
'country': country,
|
||||
'city': city,
|
||||
'lang': lang,
|
||||
'weight': weight,
|
||||
'height': height,
|
||||
'chest_circumference': chestCircumference,
|
||||
'waist_circumference': waistCircumference,
|
||||
'hip_circumference': hipCircumference,
|
||||
'blood_pressure_up': bloodPressureUp,
|
||||
'blood_pressure_down': bloodPressureDown,
|
||||
'has_hypo': hasHypo,
|
||||
'has_hyper': hasHyper,
|
||||
'about_alergy': aboutAllergy,
|
||||
'about_taking_pils': aboutTakingPils,
|
||||
'about_sport_hobbies': aboutSportHobbies,
|
||||
'favorite_foods': favoriteFoods,
|
||||
'unfavorite_foods': unfavoriteFoods,
|
||||
'additional_info': additionalInfo,
|
||||
'activity_coefficient': '1.2',
|
||||
};
|
||||
}
|
||||
@freezed
|
||||
class UserRegistrationSheet with _$UserRegistrationSheet {
|
||||
const factory UserRegistrationSheet({
|
||||
@JsonKey(name: 'first_name') required String firstName,
|
||||
@JsonKey(name: 'last_name') required String lastName,
|
||||
required String email,
|
||||
required String password,
|
||||
@JsonKey(name: 'password_confirmation') required String passwordConfirmation,
|
||||
@Default('accepted') @JsonKey(name: 'terms') String termsAccepted,
|
||||
required String birthdate,
|
||||
required String gender,
|
||||
required String location,
|
||||
@JsonKey(name: 'response_body') required String responseBody,
|
||||
required String lang,
|
||||
required int weight,
|
||||
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: 'about_alergy') required String aboutAllergy,
|
||||
@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,
|
||||
@Default(1.2) @JsonKey(name: 'activity_coefficient') double activityCoefficient,
|
||||
}) = _UserRegistrationSheet;
|
||||
|
||||
factory UserRegistrationSheet.fromJson(Map<String, Object?> json) => _$UserRegistrationSheetFromJson(json);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,794 @@
|
||||
// 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 'user_registration_model.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// FreezedGenerator
|
||||
// **************************************************************************
|
||||
|
||||
T _$identity<T>(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');
|
||||
|
||||
UserRegistrationSheet _$UserRegistrationSheetFromJson(
|
||||
Map<String, dynamic> json) {
|
||||
return _UserRegistrationSheet.fromJson(json);
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
mixin _$UserRegistrationSheet {
|
||||
@JsonKey(name: 'first_name')
|
||||
String get firstName => throw _privateConstructorUsedError;
|
||||
@JsonKey(name: 'last_name')
|
||||
String get lastName => throw _privateConstructorUsedError;
|
||||
String get email => throw _privateConstructorUsedError;
|
||||
String get password => throw _privateConstructorUsedError;
|
||||
@JsonKey(name: 'password_confirmation')
|
||||
String get passwordConfirmation => throw _privateConstructorUsedError;
|
||||
@JsonKey(name: 'terms')
|
||||
String get termsAccepted => throw _privateConstructorUsedError;
|
||||
String get birthdate => throw _privateConstructorUsedError;
|
||||
String get gender => throw _privateConstructorUsedError;
|
||||
String get location => throw _privateConstructorUsedError;
|
||||
@JsonKey(name: 'response_body')
|
||||
String get responseBody => throw _privateConstructorUsedError;
|
||||
String get lang => throw _privateConstructorUsedError;
|
||||
int get weight => throw _privateConstructorUsedError;
|
||||
int get height => 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: 'blood_pressure_up')
|
||||
int get bloodPressureUp => throw _privateConstructorUsedError;
|
||||
@JsonKey(name: 'blood_pressure_down')
|
||||
int get bloodPressureDown => throw _privateConstructorUsedError;
|
||||
@JsonKey(name: 'has_hypo')
|
||||
int get hasHypo => throw _privateConstructorUsedError;
|
||||
@JsonKey(name: 'has_hyper')
|
||||
int get hasHyper => throw _privateConstructorUsedError;
|
||||
@JsonKey(name: 'about_alergy')
|
||||
String get aboutAllergy => throw _privateConstructorUsedError;
|
||||
@JsonKey(name: 'about_taking_pils')
|
||||
String get aboutTakingPils => throw _privateConstructorUsedError;
|
||||
@JsonKey(name: 'about_sport_hobbies')
|
||||
String get aboutSportHobbies => throw _privateConstructorUsedError;
|
||||
@JsonKey(name: 'favorite_foods')
|
||||
String get favoriteFoods => throw _privateConstructorUsedError;
|
||||
@JsonKey(name: 'unfavorite_foods')
|
||||
String get unfavoriteFoods => throw _privateConstructorUsedError;
|
||||
@JsonKey(name: 'additional_info')
|
||||
String get additionalInfo => throw _privateConstructorUsedError;
|
||||
@JsonKey(name: 'activity_coefficient')
|
||||
double get activityCoefficient => throw _privateConstructorUsedError;
|
||||
|
||||
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
|
||||
@JsonKey(ignore: true)
|
||||
$UserRegistrationSheetCopyWith<UserRegistrationSheet> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class $UserRegistrationSheetCopyWith<$Res> {
|
||||
factory $UserRegistrationSheetCopyWith(UserRegistrationSheet value,
|
||||
$Res Function(UserRegistrationSheet) then) =
|
||||
_$UserRegistrationSheetCopyWithImpl<$Res, UserRegistrationSheet>;
|
||||
@useResult
|
||||
$Res call(
|
||||
{@JsonKey(name: 'first_name') String firstName,
|
||||
@JsonKey(name: 'last_name') String lastName,
|
||||
String email,
|
||||
String password,
|
||||
@JsonKey(name: 'password_confirmation') String passwordConfirmation,
|
||||
@JsonKey(name: 'terms') String termsAccepted,
|
||||
String birthdate,
|
||||
String gender,
|
||||
String location,
|
||||
@JsonKey(name: 'response_body') String responseBody,
|
||||
String lang,
|
||||
int weight,
|
||||
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: 'about_alergy') String aboutAllergy,
|
||||
@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: 'activity_coefficient') double activityCoefficient});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class _$UserRegistrationSheetCopyWithImpl<$Res,
|
||||
$Val extends UserRegistrationSheet>
|
||||
implements $UserRegistrationSheetCopyWith<$Res> {
|
||||
_$UserRegistrationSheetCopyWithImpl(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? firstName = null,
|
||||
Object? lastName = null,
|
||||
Object? email = null,
|
||||
Object? password = null,
|
||||
Object? passwordConfirmation = null,
|
||||
Object? termsAccepted = null,
|
||||
Object? birthdate = null,
|
||||
Object? gender = null,
|
||||
Object? location = null,
|
||||
Object? responseBody = null,
|
||||
Object? lang = null,
|
||||
Object? weight = null,
|
||||
Object? height = null,
|
||||
Object? chestCircumference = null,
|
||||
Object? waistCircumference = null,
|
||||
Object? hipCircumference = null,
|
||||
Object? bloodPressureUp = null,
|
||||
Object? bloodPressureDown = null,
|
||||
Object? hasHypo = null,
|
||||
Object? hasHyper = null,
|
||||
Object? aboutAllergy = null,
|
||||
Object? aboutTakingPils = null,
|
||||
Object? aboutSportHobbies = null,
|
||||
Object? favoriteFoods = null,
|
||||
Object? unfavoriteFoods = null,
|
||||
Object? additionalInfo = null,
|
||||
Object? activityCoefficient = null,
|
||||
}) {
|
||||
return _then(_value.copyWith(
|
||||
firstName: null == firstName
|
||||
? _value.firstName
|
||||
: firstName // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
lastName: null == lastName
|
||||
? _value.lastName
|
||||
: lastName // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
email: null == email
|
||||
? _value.email
|
||||
: email // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
password: null == password
|
||||
? _value.password
|
||||
: password // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
passwordConfirmation: null == passwordConfirmation
|
||||
? _value.passwordConfirmation
|
||||
: passwordConfirmation // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
termsAccepted: null == termsAccepted
|
||||
? _value.termsAccepted
|
||||
: termsAccepted // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
birthdate: null == birthdate
|
||||
? _value.birthdate
|
||||
: birthdate // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
gender: null == gender
|
||||
? _value.gender
|
||||
: gender // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
location: null == location
|
||||
? _value.location
|
||||
: location // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
responseBody: null == responseBody
|
||||
? _value.responseBody
|
||||
: responseBody // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
lang: null == lang
|
||||
? _value.lang
|
||||
: lang // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
weight: null == weight
|
||||
? _value.weight
|
||||
: weight // ignore: cast_nullable_to_non_nullable
|
||||
as int,
|
||||
height: null == height
|
||||
? _value.height
|
||||
: height // 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,
|
||||
bloodPressureUp: null == bloodPressureUp
|
||||
? _value.bloodPressureUp
|
||||
: bloodPressureUp // ignore: cast_nullable_to_non_nullable
|
||||
as int,
|
||||
bloodPressureDown: null == bloodPressureDown
|
||||
? _value.bloodPressureDown
|
||||
: bloodPressureDown // ignore: cast_nullable_to_non_nullable
|
||||
as int,
|
||||
hasHypo: null == hasHypo
|
||||
? _value.hasHypo
|
||||
: hasHypo // ignore: cast_nullable_to_non_nullable
|
||||
as int,
|
||||
hasHyper: null == hasHyper
|
||||
? _value.hasHyper
|
||||
: hasHyper // ignore: cast_nullable_to_non_nullable
|
||||
as int,
|
||||
aboutAllergy: null == aboutAllergy
|
||||
? _value.aboutAllergy
|
||||
: aboutAllergy // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
aboutTakingPils: null == aboutTakingPils
|
||||
? _value.aboutTakingPils
|
||||
: aboutTakingPils // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
aboutSportHobbies: null == aboutSportHobbies
|
||||
? _value.aboutSportHobbies
|
||||
: aboutSportHobbies // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
favoriteFoods: null == favoriteFoods
|
||||
? _value.favoriteFoods
|
||||
: favoriteFoods // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
unfavoriteFoods: null == unfavoriteFoods
|
||||
? _value.unfavoriteFoods
|
||||
: unfavoriteFoods // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
additionalInfo: null == additionalInfo
|
||||
? _value.additionalInfo
|
||||
: additionalInfo // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
activityCoefficient: null == activityCoefficient
|
||||
? _value.activityCoefficient
|
||||
: activityCoefficient // ignore: cast_nullable_to_non_nullable
|
||||
as double,
|
||||
) as $Val);
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$UserRegistrationSheetImplCopyWith<$Res>
|
||||
implements $UserRegistrationSheetCopyWith<$Res> {
|
||||
factory _$$UserRegistrationSheetImplCopyWith(
|
||||
_$UserRegistrationSheetImpl value,
|
||||
$Res Function(_$UserRegistrationSheetImpl) then) =
|
||||
__$$UserRegistrationSheetImplCopyWithImpl<$Res>;
|
||||
@override
|
||||
@useResult
|
||||
$Res call(
|
||||
{@JsonKey(name: 'first_name') String firstName,
|
||||
@JsonKey(name: 'last_name') String lastName,
|
||||
String email,
|
||||
String password,
|
||||
@JsonKey(name: 'password_confirmation') String passwordConfirmation,
|
||||
@JsonKey(name: 'terms') String termsAccepted,
|
||||
String birthdate,
|
||||
String gender,
|
||||
String location,
|
||||
@JsonKey(name: 'response_body') String responseBody,
|
||||
String lang,
|
||||
int weight,
|
||||
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: 'about_alergy') String aboutAllergy,
|
||||
@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: 'activity_coefficient') double activityCoefficient});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$UserRegistrationSheetImplCopyWithImpl<$Res>
|
||||
extends _$UserRegistrationSheetCopyWithImpl<$Res,
|
||||
_$UserRegistrationSheetImpl>
|
||||
implements _$$UserRegistrationSheetImplCopyWith<$Res> {
|
||||
__$$UserRegistrationSheetImplCopyWithImpl(_$UserRegistrationSheetImpl _value,
|
||||
$Res Function(_$UserRegistrationSheetImpl) _then)
|
||||
: super(_value, _then);
|
||||
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? firstName = null,
|
||||
Object? lastName = null,
|
||||
Object? email = null,
|
||||
Object? password = null,
|
||||
Object? passwordConfirmation = null,
|
||||
Object? termsAccepted = null,
|
||||
Object? birthdate = null,
|
||||
Object? gender = null,
|
||||
Object? location = null,
|
||||
Object? responseBody = null,
|
||||
Object? lang = null,
|
||||
Object? weight = null,
|
||||
Object? height = null,
|
||||
Object? chestCircumference = null,
|
||||
Object? waistCircumference = null,
|
||||
Object? hipCircumference = null,
|
||||
Object? bloodPressureUp = null,
|
||||
Object? bloodPressureDown = null,
|
||||
Object? hasHypo = null,
|
||||
Object? hasHyper = null,
|
||||
Object? aboutAllergy = null,
|
||||
Object? aboutTakingPils = null,
|
||||
Object? aboutSportHobbies = null,
|
||||
Object? favoriteFoods = null,
|
||||
Object? unfavoriteFoods = null,
|
||||
Object? additionalInfo = null,
|
||||
Object? activityCoefficient = null,
|
||||
}) {
|
||||
return _then(_$UserRegistrationSheetImpl(
|
||||
firstName: null == firstName
|
||||
? _value.firstName
|
||||
: firstName // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
lastName: null == lastName
|
||||
? _value.lastName
|
||||
: lastName // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
email: null == email
|
||||
? _value.email
|
||||
: email // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
password: null == password
|
||||
? _value.password
|
||||
: password // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
passwordConfirmation: null == passwordConfirmation
|
||||
? _value.passwordConfirmation
|
||||
: passwordConfirmation // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
termsAccepted: null == termsAccepted
|
||||
? _value.termsAccepted
|
||||
: termsAccepted // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
birthdate: null == birthdate
|
||||
? _value.birthdate
|
||||
: birthdate // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
gender: null == gender
|
||||
? _value.gender
|
||||
: gender // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
location: null == location
|
||||
? _value.location
|
||||
: location // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
responseBody: null == responseBody
|
||||
? _value.responseBody
|
||||
: responseBody // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
lang: null == lang
|
||||
? _value.lang
|
||||
: lang // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
weight: null == weight
|
||||
? _value.weight
|
||||
: weight // ignore: cast_nullable_to_non_nullable
|
||||
as int,
|
||||
height: null == height
|
||||
? _value.height
|
||||
: height // 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,
|
||||
bloodPressureUp: null == bloodPressureUp
|
||||
? _value.bloodPressureUp
|
||||
: bloodPressureUp // ignore: cast_nullable_to_non_nullable
|
||||
as int,
|
||||
bloodPressureDown: null == bloodPressureDown
|
||||
? _value.bloodPressureDown
|
||||
: bloodPressureDown // ignore: cast_nullable_to_non_nullable
|
||||
as int,
|
||||
hasHypo: null == hasHypo
|
||||
? _value.hasHypo
|
||||
: hasHypo // ignore: cast_nullable_to_non_nullable
|
||||
as int,
|
||||
hasHyper: null == hasHyper
|
||||
? _value.hasHyper
|
||||
: hasHyper // ignore: cast_nullable_to_non_nullable
|
||||
as int,
|
||||
aboutAllergy: null == aboutAllergy
|
||||
? _value.aboutAllergy
|
||||
: aboutAllergy // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
aboutTakingPils: null == aboutTakingPils
|
||||
? _value.aboutTakingPils
|
||||
: aboutTakingPils // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
aboutSportHobbies: null == aboutSportHobbies
|
||||
? _value.aboutSportHobbies
|
||||
: aboutSportHobbies // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
favoriteFoods: null == favoriteFoods
|
||||
? _value.favoriteFoods
|
||||
: favoriteFoods // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
unfavoriteFoods: null == unfavoriteFoods
|
||||
? _value.unfavoriteFoods
|
||||
: unfavoriteFoods // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
additionalInfo: null == additionalInfo
|
||||
? _value.additionalInfo
|
||||
: additionalInfo // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
activityCoefficient: null == activityCoefficient
|
||||
? _value.activityCoefficient
|
||||
: activityCoefficient // ignore: cast_nullable_to_non_nullable
|
||||
as double,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@JsonSerializable()
|
||||
class _$UserRegistrationSheetImpl implements _UserRegistrationSheet {
|
||||
const _$UserRegistrationSheetImpl(
|
||||
{@JsonKey(name: 'first_name') required this.firstName,
|
||||
@JsonKey(name: 'last_name') required this.lastName,
|
||||
required this.email,
|
||||
required this.password,
|
||||
@JsonKey(name: 'password_confirmation')
|
||||
required this.passwordConfirmation,
|
||||
@JsonKey(name: 'terms') this.termsAccepted = 'accepted',
|
||||
required this.birthdate,
|
||||
required this.gender,
|
||||
required this.location,
|
||||
@JsonKey(name: 'response_body') required this.responseBody,
|
||||
required this.lang,
|
||||
required this.weight,
|
||||
required this.height,
|
||||
@JsonKey(name: 'chest_circumference') required this.chestCircumference,
|
||||
@JsonKey(name: 'waist_circumference') required this.waistCircumference,
|
||||
@JsonKey(name: 'hip_circumference') required this.hipCircumference,
|
||||
@JsonKey(name: 'blood_pressure_up') required this.bloodPressureUp,
|
||||
@JsonKey(name: 'blood_pressure_down') required this.bloodPressureDown,
|
||||
@JsonKey(name: 'has_hypo') required this.hasHypo,
|
||||
@JsonKey(name: 'has_hyper') required this.hasHyper,
|
||||
@JsonKey(name: 'about_alergy') required this.aboutAllergy,
|
||||
@JsonKey(name: 'about_taking_pils') required this.aboutTakingPils,
|
||||
@JsonKey(name: 'about_sport_hobbies') required this.aboutSportHobbies,
|
||||
@JsonKey(name: 'favorite_foods') required this.favoriteFoods,
|
||||
@JsonKey(name: 'unfavorite_foods') required this.unfavoriteFoods,
|
||||
@JsonKey(name: 'additional_info') required this.additionalInfo,
|
||||
@JsonKey(name: 'activity_coefficient') this.activityCoefficient = 1.2});
|
||||
|
||||
factory _$UserRegistrationSheetImpl.fromJson(Map<String, dynamic> json) =>
|
||||
_$$UserRegistrationSheetImplFromJson(json);
|
||||
|
||||
@override
|
||||
@JsonKey(name: 'first_name')
|
||||
final String firstName;
|
||||
@override
|
||||
@JsonKey(name: 'last_name')
|
||||
final String lastName;
|
||||
@override
|
||||
final String email;
|
||||
@override
|
||||
final String password;
|
||||
@override
|
||||
@JsonKey(name: 'password_confirmation')
|
||||
final String passwordConfirmation;
|
||||
@override
|
||||
@JsonKey(name: 'terms')
|
||||
final String termsAccepted;
|
||||
@override
|
||||
final String birthdate;
|
||||
@override
|
||||
final String gender;
|
||||
@override
|
||||
final String location;
|
||||
@override
|
||||
@JsonKey(name: 'response_body')
|
||||
final String responseBody;
|
||||
@override
|
||||
final String lang;
|
||||
@override
|
||||
final int weight;
|
||||
@override
|
||||
final int height;
|
||||
@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: 'blood_pressure_up')
|
||||
final int bloodPressureUp;
|
||||
@override
|
||||
@JsonKey(name: 'blood_pressure_down')
|
||||
final int bloodPressureDown;
|
||||
@override
|
||||
@JsonKey(name: 'has_hypo')
|
||||
final int hasHypo;
|
||||
@override
|
||||
@JsonKey(name: 'has_hyper')
|
||||
final int hasHyper;
|
||||
@override
|
||||
@JsonKey(name: 'about_alergy')
|
||||
final String aboutAllergy;
|
||||
@override
|
||||
@JsonKey(name: 'about_taking_pils')
|
||||
final String aboutTakingPils;
|
||||
@override
|
||||
@JsonKey(name: 'about_sport_hobbies')
|
||||
final String aboutSportHobbies;
|
||||
@override
|
||||
@JsonKey(name: 'favorite_foods')
|
||||
final String favoriteFoods;
|
||||
@override
|
||||
@JsonKey(name: 'unfavorite_foods')
|
||||
final String unfavoriteFoods;
|
||||
@override
|
||||
@JsonKey(name: 'additional_info')
|
||||
final String additionalInfo;
|
||||
@override
|
||||
@JsonKey(name: 'activity_coefficient')
|
||||
final double activityCoefficient;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'UserRegistrationSheet(firstName: $firstName, lastName: $lastName, email: $email, password: $password, passwordConfirmation: $passwordConfirmation, termsAccepted: $termsAccepted, birthdate: $birthdate, gender: $gender, location: $location, responseBody: $responseBody, lang: $lang, weight: $weight, height: $height, chestCircumference: $chestCircumference, waistCircumference: $waistCircumference, hipCircumference: $hipCircumference, bloodPressureUp: $bloodPressureUp, bloodPressureDown: $bloodPressureDown, hasHypo: $hasHypo, hasHyper: $hasHyper, aboutAllergy: $aboutAllergy, aboutTakingPils: $aboutTakingPils, aboutSportHobbies: $aboutSportHobbies, favoriteFoods: $favoriteFoods, unfavoriteFoods: $unfavoriteFoods, additionalInfo: $additionalInfo, activityCoefficient: $activityCoefficient)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$UserRegistrationSheetImpl &&
|
||||
(identical(other.firstName, firstName) ||
|
||||
other.firstName == firstName) &&
|
||||
(identical(other.lastName, lastName) ||
|
||||
other.lastName == lastName) &&
|
||||
(identical(other.email, email) || other.email == email) &&
|
||||
(identical(other.password, password) ||
|
||||
other.password == password) &&
|
||||
(identical(other.passwordConfirmation, passwordConfirmation) ||
|
||||
other.passwordConfirmation == passwordConfirmation) &&
|
||||
(identical(other.termsAccepted, termsAccepted) ||
|
||||
other.termsAccepted == termsAccepted) &&
|
||||
(identical(other.birthdate, birthdate) ||
|
||||
other.birthdate == birthdate) &&
|
||||
(identical(other.gender, gender) || other.gender == gender) &&
|
||||
(identical(other.location, location) ||
|
||||
other.location == location) &&
|
||||
(identical(other.responseBody, responseBody) ||
|
||||
other.responseBody == responseBody) &&
|
||||
(identical(other.lang, lang) || other.lang == lang) &&
|
||||
(identical(other.weight, weight) || other.weight == weight) &&
|
||||
(identical(other.height, height) || other.height == height) &&
|
||||
(identical(other.chestCircumference, chestCircumference) ||
|
||||
other.chestCircumference == chestCircumference) &&
|
||||
(identical(other.waistCircumference, waistCircumference) ||
|
||||
other.waistCircumference == waistCircumference) &&
|
||||
(identical(other.hipCircumference, hipCircumference) ||
|
||||
other.hipCircumference == hipCircumference) &&
|
||||
(identical(other.bloodPressureUp, bloodPressureUp) ||
|
||||
other.bloodPressureUp == bloodPressureUp) &&
|
||||
(identical(other.bloodPressureDown, bloodPressureDown) ||
|
||||
other.bloodPressureDown == bloodPressureDown) &&
|
||||
(identical(other.hasHypo, hasHypo) || other.hasHypo == hasHypo) &&
|
||||
(identical(other.hasHyper, hasHyper) ||
|
||||
other.hasHyper == hasHyper) &&
|
||||
(identical(other.aboutAllergy, aboutAllergy) ||
|
||||
other.aboutAllergy == aboutAllergy) &&
|
||||
(identical(other.aboutTakingPils, aboutTakingPils) ||
|
||||
other.aboutTakingPils == aboutTakingPils) &&
|
||||
(identical(other.aboutSportHobbies, aboutSportHobbies) ||
|
||||
other.aboutSportHobbies == aboutSportHobbies) &&
|
||||
(identical(other.favoriteFoods, favoriteFoods) ||
|
||||
other.favoriteFoods == favoriteFoods) &&
|
||||
(identical(other.unfavoriteFoods, unfavoriteFoods) ||
|
||||
other.unfavoriteFoods == unfavoriteFoods) &&
|
||||
(identical(other.additionalInfo, additionalInfo) ||
|
||||
other.additionalInfo == additionalInfo) &&
|
||||
(identical(other.activityCoefficient, activityCoefficient) ||
|
||||
other.activityCoefficient == activityCoefficient));
|
||||
}
|
||||
|
||||
@JsonKey(ignore: true)
|
||||
@override
|
||||
int get hashCode => Object.hashAll([
|
||||
runtimeType,
|
||||
firstName,
|
||||
lastName,
|
||||
email,
|
||||
password,
|
||||
passwordConfirmation,
|
||||
termsAccepted,
|
||||
birthdate,
|
||||
gender,
|
||||
location,
|
||||
responseBody,
|
||||
lang,
|
||||
weight,
|
||||
height,
|
||||
chestCircumference,
|
||||
waistCircumference,
|
||||
hipCircumference,
|
||||
bloodPressureUp,
|
||||
bloodPressureDown,
|
||||
hasHypo,
|
||||
hasHyper,
|
||||
aboutAllergy,
|
||||
aboutTakingPils,
|
||||
aboutSportHobbies,
|
||||
favoriteFoods,
|
||||
unfavoriteFoods,
|
||||
additionalInfo,
|
||||
activityCoefficient
|
||||
]);
|
||||
|
||||
@JsonKey(ignore: true)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$UserRegistrationSheetImplCopyWith<_$UserRegistrationSheetImpl>
|
||||
get copyWith => __$$UserRegistrationSheetImplCopyWithImpl<
|
||||
_$UserRegistrationSheetImpl>(this, _$identity);
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
return _$$UserRegistrationSheetImplToJson(
|
||||
this,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
abstract class _UserRegistrationSheet implements UserRegistrationSheet {
|
||||
const factory _UserRegistrationSheet(
|
||||
{@JsonKey(name: 'first_name') required final String firstName,
|
||||
@JsonKey(name: 'last_name') required final String lastName,
|
||||
required final String email,
|
||||
required final String password,
|
||||
@JsonKey(name: 'password_confirmation')
|
||||
required final String passwordConfirmation,
|
||||
@JsonKey(name: 'terms') final String termsAccepted,
|
||||
required final String birthdate,
|
||||
required final String gender,
|
||||
required final String location,
|
||||
@JsonKey(name: 'response_body') required final String responseBody,
|
||||
required final String lang,
|
||||
required final int weight,
|
||||
required final int height,
|
||||
@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: '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: 'about_alergy') required final String aboutAllergy,
|
||||
@JsonKey(name: 'about_taking_pils') required final String aboutTakingPils,
|
||||
@JsonKey(name: 'about_sport_hobbies')
|
||||
required final String aboutSportHobbies,
|
||||
@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: 'activity_coefficient')
|
||||
final double activityCoefficient}) = _$UserRegistrationSheetImpl;
|
||||
|
||||
factory _UserRegistrationSheet.fromJson(Map<String, dynamic> json) =
|
||||
_$UserRegistrationSheetImpl.fromJson;
|
||||
|
||||
@override
|
||||
@JsonKey(name: 'first_name')
|
||||
String get firstName;
|
||||
@override
|
||||
@JsonKey(name: 'last_name')
|
||||
String get lastName;
|
||||
@override
|
||||
String get email;
|
||||
@override
|
||||
String get password;
|
||||
@override
|
||||
@JsonKey(name: 'password_confirmation')
|
||||
String get passwordConfirmation;
|
||||
@override
|
||||
@JsonKey(name: 'terms')
|
||||
String get termsAccepted;
|
||||
@override
|
||||
String get birthdate;
|
||||
@override
|
||||
String get gender;
|
||||
@override
|
||||
String get location;
|
||||
@override
|
||||
@JsonKey(name: 'response_body')
|
||||
String get responseBody;
|
||||
@override
|
||||
String get lang;
|
||||
@override
|
||||
int get weight;
|
||||
@override
|
||||
int get height;
|
||||
@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: 'blood_pressure_up')
|
||||
int get bloodPressureUp;
|
||||
@override
|
||||
@JsonKey(name: 'blood_pressure_down')
|
||||
int get bloodPressureDown;
|
||||
@override
|
||||
@JsonKey(name: 'has_hypo')
|
||||
int get hasHypo;
|
||||
@override
|
||||
@JsonKey(name: 'has_hyper')
|
||||
int get hasHyper;
|
||||
@override
|
||||
@JsonKey(name: 'about_alergy')
|
||||
String get aboutAllergy;
|
||||
@override
|
||||
@JsonKey(name: 'about_taking_pils')
|
||||
String get aboutTakingPils;
|
||||
@override
|
||||
@JsonKey(name: 'about_sport_hobbies')
|
||||
String get aboutSportHobbies;
|
||||
@override
|
||||
@JsonKey(name: 'favorite_foods')
|
||||
String get favoriteFoods;
|
||||
@override
|
||||
@JsonKey(name: 'unfavorite_foods')
|
||||
String get unfavoriteFoods;
|
||||
@override
|
||||
@JsonKey(name: 'additional_info')
|
||||
String get additionalInfo;
|
||||
@override
|
||||
@JsonKey(name: 'activity_coefficient')
|
||||
double get activityCoefficient;
|
||||
@override
|
||||
@JsonKey(ignore: true)
|
||||
_$$UserRegistrationSheetImplCopyWith<_$UserRegistrationSheetImpl>
|
||||
get copyWith => throw _privateConstructorUsedError;
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'user_registration_model.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
_$UserRegistrationSheetImpl _$$UserRegistrationSheetImplFromJson(
|
||||
Map<String, dynamic> json) =>
|
||||
_$UserRegistrationSheetImpl(
|
||||
firstName: json['first_name'] as String,
|
||||
lastName: json['last_name'] as String,
|
||||
email: json['email'] as String,
|
||||
password: json['password'] as String,
|
||||
passwordConfirmation: json['password_confirmation'] as String,
|
||||
termsAccepted: json['terms'] as String? ?? 'accepted',
|
||||
birthdate: json['birthdate'] as String,
|
||||
gender: json['gender'] as String,
|
||||
location: json['location'] as String,
|
||||
responseBody: json['response_body'] as String,
|
||||
lang: json['lang'] as String,
|
||||
weight: (json['weight'] as num).toInt(),
|
||||
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(),
|
||||
aboutAllergy: 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,
|
||||
activityCoefficient:
|
||||
(json['activity_coefficient'] as num?)?.toDouble() ?? 1.2,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$$UserRegistrationSheetImplToJson(
|
||||
_$UserRegistrationSheetImpl instance) =>
|
||||
<String, dynamic>{
|
||||
'first_name': instance.firstName,
|
||||
'last_name': instance.lastName,
|
||||
'email': instance.email,
|
||||
'password': instance.password,
|
||||
'password_confirmation': instance.passwordConfirmation,
|
||||
'terms': instance.termsAccepted,
|
||||
'birthdate': instance.birthdate,
|
||||
'gender': instance.gender,
|
||||
'location': instance.location,
|
||||
'response_body': instance.responseBody,
|
||||
'lang': instance.lang,
|
||||
'weight': instance.weight,
|
||||
'height': instance.height,
|
||||
'chest_circumference': instance.chestCircumference,
|
||||
'waist_circumference': instance.waistCircumference,
|
||||
'hip_circumference': instance.hipCircumference,
|
||||
'blood_pressure_up': instance.bloodPressureUp,
|
||||
'blood_pressure_down': instance.bloodPressureDown,
|
||||
'has_hypo': instance.hasHypo,
|
||||
'has_hyper': instance.hasHyper,
|
||||
'about_alergy': instance.aboutAllergy,
|
||||
'about_taking_pils': instance.aboutTakingPils,
|
||||
'about_sport_hobbies': instance.aboutSportHobbies,
|
||||
'favorite_foods': instance.favoriteFoods,
|
||||
'unfavorite_foods': instance.unfavoriteFoods,
|
||||
'additional_info': instance.additionalInfo,
|
||||
'activity_coefficient': instance.activityCoefficient,
|
||||
};
|
||||
22
lib/features/blog_post/models/blog_post_model.dart
Normal file
22
lib/features/blog_post/models/blog_post_model.dart
Normal file
@@ -0,0 +1,22 @@
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
||||
part 'blog_post_model.freezed.dart';
|
||||
part 'blog_post_model.g.dart';
|
||||
|
||||
@freezed
|
||||
class BlogPostModel with _$BlogPostModel {
|
||||
const factory BlogPostModel({
|
||||
required int id,
|
||||
required String state,
|
||||
String? image,
|
||||
required String description,
|
||||
String? author_name,
|
||||
String? author_avatar_path,
|
||||
@JsonKey(name: "youtube_url") required String youtubeUrl,
|
||||
@JsonKey(name: "created_at") required DateTime createdAt,
|
||||
@JsonKey(name: "updated_at") required DateTime updatedAt,
|
||||
required String title,
|
||||
}) = _BlogPostModel;
|
||||
|
||||
factory BlogPostModel.fromJson(Map<String, Object?> json) => _$BlogPostModelFromJson(json);
|
||||
}
|
||||
351
lib/features/blog_post/models/blog_post_model.freezed.dart
Normal file
351
lib/features/blog_post/models/blog_post_model.freezed.dart
Normal file
@@ -0,0 +1,351 @@
|
||||
// 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 'blog_post_model.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// FreezedGenerator
|
||||
// **************************************************************************
|
||||
|
||||
T _$identity<T>(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');
|
||||
|
||||
BlogPostModel _$BlogPostModelFromJson(Map<String, dynamic> json) {
|
||||
return _BlogPostModel.fromJson(json);
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
mixin _$BlogPostModel {
|
||||
int get id => throw _privateConstructorUsedError;
|
||||
String get state => throw _privateConstructorUsedError;
|
||||
String? get image => throw _privateConstructorUsedError;
|
||||
String get description => throw _privateConstructorUsedError;
|
||||
String? get author_name => throw _privateConstructorUsedError;
|
||||
String? get author_avatar_path => throw _privateConstructorUsedError;
|
||||
@JsonKey(name: "youtube_url")
|
||||
String get youtubeUrl => throw _privateConstructorUsedError;
|
||||
@JsonKey(name: "created_at")
|
||||
DateTime get createdAt => throw _privateConstructorUsedError;
|
||||
@JsonKey(name: "updated_at")
|
||||
DateTime get updatedAt => throw _privateConstructorUsedError;
|
||||
String get title => throw _privateConstructorUsedError;
|
||||
|
||||
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
|
||||
@JsonKey(ignore: true)
|
||||
$BlogPostModelCopyWith<BlogPostModel> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class $BlogPostModelCopyWith<$Res> {
|
||||
factory $BlogPostModelCopyWith(
|
||||
BlogPostModel value, $Res Function(BlogPostModel) then) =
|
||||
_$BlogPostModelCopyWithImpl<$Res, BlogPostModel>;
|
||||
@useResult
|
||||
$Res call(
|
||||
{int id,
|
||||
String state,
|
||||
String? image,
|
||||
String description,
|
||||
String? author_name,
|
||||
String? author_avatar_path,
|
||||
@JsonKey(name: "youtube_url") String youtubeUrl,
|
||||
@JsonKey(name: "created_at") DateTime createdAt,
|
||||
@JsonKey(name: "updated_at") DateTime updatedAt,
|
||||
String title});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class _$BlogPostModelCopyWithImpl<$Res, $Val extends BlogPostModel>
|
||||
implements $BlogPostModelCopyWith<$Res> {
|
||||
_$BlogPostModelCopyWithImpl(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? state = null,
|
||||
Object? image = freezed,
|
||||
Object? description = null,
|
||||
Object? author_name = freezed,
|
||||
Object? author_avatar_path = freezed,
|
||||
Object? youtubeUrl = null,
|
||||
Object? createdAt = null,
|
||||
Object? updatedAt = null,
|
||||
Object? title = null,
|
||||
}) {
|
||||
return _then(_value.copyWith(
|
||||
id: null == id
|
||||
? _value.id
|
||||
: id // ignore: cast_nullable_to_non_nullable
|
||||
as int,
|
||||
state: null == state
|
||||
? _value.state
|
||||
: state // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
image: freezed == image
|
||||
? _value.image
|
||||
: image // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
description: null == description
|
||||
? _value.description
|
||||
: description // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
author_name: freezed == author_name
|
||||
? _value.author_name
|
||||
: author_name // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
author_avatar_path: freezed == author_avatar_path
|
||||
? _value.author_avatar_path
|
||||
: author_avatar_path // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
youtubeUrl: null == youtubeUrl
|
||||
? _value.youtubeUrl
|
||||
: youtubeUrl // 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,
|
||||
title: null == title
|
||||
? _value.title
|
||||
: title // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
) as $Val);
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$BlogPostModelImplCopyWith<$Res>
|
||||
implements $BlogPostModelCopyWith<$Res> {
|
||||
factory _$$BlogPostModelImplCopyWith(
|
||||
_$BlogPostModelImpl value, $Res Function(_$BlogPostModelImpl) then) =
|
||||
__$$BlogPostModelImplCopyWithImpl<$Res>;
|
||||
@override
|
||||
@useResult
|
||||
$Res call(
|
||||
{int id,
|
||||
String state,
|
||||
String? image,
|
||||
String description,
|
||||
String? author_name,
|
||||
String? author_avatar_path,
|
||||
@JsonKey(name: "youtube_url") String youtubeUrl,
|
||||
@JsonKey(name: "created_at") DateTime createdAt,
|
||||
@JsonKey(name: "updated_at") DateTime updatedAt,
|
||||
String title});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$BlogPostModelImplCopyWithImpl<$Res>
|
||||
extends _$BlogPostModelCopyWithImpl<$Res, _$BlogPostModelImpl>
|
||||
implements _$$BlogPostModelImplCopyWith<$Res> {
|
||||
__$$BlogPostModelImplCopyWithImpl(
|
||||
_$BlogPostModelImpl _value, $Res Function(_$BlogPostModelImpl) _then)
|
||||
: super(_value, _then);
|
||||
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? id = null,
|
||||
Object? state = null,
|
||||
Object? image = freezed,
|
||||
Object? description = null,
|
||||
Object? author_name = freezed,
|
||||
Object? author_avatar_path = freezed,
|
||||
Object? youtubeUrl = null,
|
||||
Object? createdAt = null,
|
||||
Object? updatedAt = null,
|
||||
Object? title = null,
|
||||
}) {
|
||||
return _then(_$BlogPostModelImpl(
|
||||
id: null == id
|
||||
? _value.id
|
||||
: id // ignore: cast_nullable_to_non_nullable
|
||||
as int,
|
||||
state: null == state
|
||||
? _value.state
|
||||
: state // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
image: freezed == image
|
||||
? _value.image
|
||||
: image // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
description: null == description
|
||||
? _value.description
|
||||
: description // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
author_name: freezed == author_name
|
||||
? _value.author_name
|
||||
: author_name // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
author_avatar_path: freezed == author_avatar_path
|
||||
? _value.author_avatar_path
|
||||
: author_avatar_path // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
youtubeUrl: null == youtubeUrl
|
||||
? _value.youtubeUrl
|
||||
: youtubeUrl // 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,
|
||||
title: null == title
|
||||
? _value.title
|
||||
: title // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@JsonSerializable()
|
||||
class _$BlogPostModelImpl implements _BlogPostModel {
|
||||
const _$BlogPostModelImpl(
|
||||
{required this.id,
|
||||
required this.state,
|
||||
this.image,
|
||||
required this.description,
|
||||
this.author_name,
|
||||
this.author_avatar_path,
|
||||
@JsonKey(name: "youtube_url") required this.youtubeUrl,
|
||||
@JsonKey(name: "created_at") required this.createdAt,
|
||||
@JsonKey(name: "updated_at") required this.updatedAt,
|
||||
required this.title});
|
||||
|
||||
factory _$BlogPostModelImpl.fromJson(Map<String, dynamic> json) =>
|
||||
_$$BlogPostModelImplFromJson(json);
|
||||
|
||||
@override
|
||||
final int id;
|
||||
@override
|
||||
final String state;
|
||||
@override
|
||||
final String? image;
|
||||
@override
|
||||
final String description;
|
||||
@override
|
||||
final String? author_name;
|
||||
@override
|
||||
final String? author_avatar_path;
|
||||
@override
|
||||
@JsonKey(name: "youtube_url")
|
||||
final String youtubeUrl;
|
||||
@override
|
||||
@JsonKey(name: "created_at")
|
||||
final DateTime createdAt;
|
||||
@override
|
||||
@JsonKey(name: "updated_at")
|
||||
final DateTime updatedAt;
|
||||
@override
|
||||
final String title;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'BlogPostModel(id: $id, state: $state, image: $image, description: $description, author_name: $author_name, author_avatar_path: $author_avatar_path, youtubeUrl: $youtubeUrl, createdAt: $createdAt, updatedAt: $updatedAt, title: $title)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$BlogPostModelImpl &&
|
||||
(identical(other.id, id) || other.id == id) &&
|
||||
(identical(other.state, state) || other.state == state) &&
|
||||
(identical(other.image, image) || other.image == image) &&
|
||||
(identical(other.description, description) ||
|
||||
other.description == description) &&
|
||||
(identical(other.author_name, author_name) ||
|
||||
other.author_name == author_name) &&
|
||||
(identical(other.author_avatar_path, author_avatar_path) ||
|
||||
other.author_avatar_path == author_avatar_path) &&
|
||||
(identical(other.youtubeUrl, youtubeUrl) ||
|
||||
other.youtubeUrl == youtubeUrl) &&
|
||||
(identical(other.createdAt, createdAt) ||
|
||||
other.createdAt == createdAt) &&
|
||||
(identical(other.updatedAt, updatedAt) ||
|
||||
other.updatedAt == updatedAt) &&
|
||||
(identical(other.title, title) || other.title == title));
|
||||
}
|
||||
|
||||
@JsonKey(ignore: true)
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType, id, state, image, description,
|
||||
author_name, author_avatar_path, youtubeUrl, createdAt, updatedAt, title);
|
||||
|
||||
@JsonKey(ignore: true)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$BlogPostModelImplCopyWith<_$BlogPostModelImpl> get copyWith =>
|
||||
__$$BlogPostModelImplCopyWithImpl<_$BlogPostModelImpl>(this, _$identity);
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
return _$$BlogPostModelImplToJson(
|
||||
this,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
abstract class _BlogPostModel implements BlogPostModel {
|
||||
const factory _BlogPostModel(
|
||||
{required final int id,
|
||||
required final String state,
|
||||
final String? image,
|
||||
required final String description,
|
||||
final String? author_name,
|
||||
final String? author_avatar_path,
|
||||
@JsonKey(name: "youtube_url") required final String youtubeUrl,
|
||||
@JsonKey(name: "created_at") required final DateTime createdAt,
|
||||
@JsonKey(name: "updated_at") required final DateTime updatedAt,
|
||||
required final String title}) = _$BlogPostModelImpl;
|
||||
|
||||
factory _BlogPostModel.fromJson(Map<String, dynamic> json) =
|
||||
_$BlogPostModelImpl.fromJson;
|
||||
|
||||
@override
|
||||
int get id;
|
||||
@override
|
||||
String get state;
|
||||
@override
|
||||
String? get image;
|
||||
@override
|
||||
String get description;
|
||||
@override
|
||||
String? get author_name;
|
||||
@override
|
||||
String? get author_avatar_path;
|
||||
@override
|
||||
@JsonKey(name: "youtube_url")
|
||||
String get youtubeUrl;
|
||||
@override
|
||||
@JsonKey(name: "created_at")
|
||||
DateTime get createdAt;
|
||||
@override
|
||||
@JsonKey(name: "updated_at")
|
||||
DateTime get updatedAt;
|
||||
@override
|
||||
String get title;
|
||||
@override
|
||||
@JsonKey(ignore: true)
|
||||
_$$BlogPostModelImplCopyWith<_$BlogPostModelImpl> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
35
lib/features/blog_post/models/blog_post_model.g.dart
Normal file
35
lib/features/blog_post/models/blog_post_model.g.dart
Normal file
@@ -0,0 +1,35 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'blog_post_model.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
_$BlogPostModelImpl _$$BlogPostModelImplFromJson(Map<String, dynamic> json) =>
|
||||
_$BlogPostModelImpl(
|
||||
id: (json['id'] as num).toInt(),
|
||||
state: json['state'] as String,
|
||||
image: json['image'] as String?,
|
||||
description: json['description'] as String,
|
||||
author_name: json['author_name'] as String?,
|
||||
author_avatar_path: json['author_avatar_path'] as String?,
|
||||
youtubeUrl: json['youtube_url'] as String,
|
||||
createdAt: DateTime.parse(json['created_at'] as String),
|
||||
updatedAt: DateTime.parse(json['updated_at'] as String),
|
||||
title: json['title'] as String,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$$BlogPostModelImplToJson(_$BlogPostModelImpl instance) =>
|
||||
<String, dynamic>{
|
||||
'id': instance.id,
|
||||
'state': instance.state,
|
||||
'image': instance.image,
|
||||
'description': instance.description,
|
||||
'author_name': instance.author_name,
|
||||
'author_avatar_path': instance.author_avatar_path,
|
||||
'youtube_url': instance.youtubeUrl,
|
||||
'created_at': instance.createdAt.toIso8601String(),
|
||||
'updated_at': instance.updatedAt.toIso8601String(),
|
||||
'title': instance.title,
|
||||
};
|
||||
@@ -0,0 +1,20 @@
|
||||
import 'package:eatvio_app/core/app_export.dart';
|
||||
import 'package:eatvio_app/features/blog_post/presentation/bloc/blog_post_state.dart';
|
||||
import 'package:eatvio_app/features/blog_post/repositories/blog_post_repository.dart';
|
||||
|
||||
class BlogPostCubit extends Cubit<BlogPostState> {
|
||||
final BlogPostRepository blogPostRepository;
|
||||
|
||||
BlogPostCubit({required this.blogPostRepository}) : super(const BlogPostState.loading());
|
||||
|
||||
loadBlogPost(String blogPostID) async {
|
||||
emit(const BlogPostState.loading());
|
||||
try {
|
||||
final blogPost = await blogPostRepository.getBlogPost(blogPostID);
|
||||
emit(BlogPostState.loaded(blogPost: blogPost));
|
||||
} catch (e) {
|
||||
emit(BlogPostState.error(errorMessage: e.toString()));
|
||||
print(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
import 'package:eatvio_app/features/blog_post/models/blog_post_model.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
||||
part 'blog_post_state.freezed.dart';
|
||||
|
||||
@freezed
|
||||
abstract class BlogPostState with _$BlogPostState {
|
||||
const factory BlogPostState() = _BlogPostState;
|
||||
|
||||
const factory BlogPostState.loading() = BlogPostStateLoading;
|
||||
|
||||
const factory BlogPostState.loaded({
|
||||
required BlogPostModel blogPost,
|
||||
}) = BlogPostStateLoaded;
|
||||
|
||||
const factory BlogPostState.error({
|
||||
required String errorMessage,
|
||||
}) = BlogPostStateError;
|
||||
}
|
||||
@@ -0,0 +1,622 @@
|
||||
// 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 'blog_post_state.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// FreezedGenerator
|
||||
// **************************************************************************
|
||||
|
||||
T _$identity<T>(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 _$BlogPostState {
|
||||
@optionalTypeArgs
|
||||
TResult when<TResult extends Object?>(
|
||||
TResult Function() $default, {
|
||||
required TResult Function() loading,
|
||||
required TResult Function(BlogPostModel blogPost) loaded,
|
||||
required TResult Function(String errorMessage) error,
|
||||
}) =>
|
||||
throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult? whenOrNull<TResult extends Object?>(
|
||||
TResult? Function()? $default, {
|
||||
TResult? Function()? loading,
|
||||
TResult? Function(BlogPostModel blogPost)? loaded,
|
||||
TResult? Function(String errorMessage)? error,
|
||||
}) =>
|
||||
throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult maybeWhen<TResult extends Object?>(
|
||||
TResult Function()? $default, {
|
||||
TResult Function()? loading,
|
||||
TResult Function(BlogPostModel blogPost)? loaded,
|
||||
TResult Function(String errorMessage)? error,
|
||||
required TResult orElse(),
|
||||
}) =>
|
||||
throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult map<TResult extends Object?>(
|
||||
TResult Function(_BlogPostState value) $default, {
|
||||
required TResult Function(BlogPostStateLoading value) loading,
|
||||
required TResult Function(BlogPostStateLoaded value) loaded,
|
||||
required TResult Function(BlogPostStateError value) error,
|
||||
}) =>
|
||||
throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult? mapOrNull<TResult extends Object?>(
|
||||
TResult? Function(_BlogPostState value)? $default, {
|
||||
TResult? Function(BlogPostStateLoading value)? loading,
|
||||
TResult? Function(BlogPostStateLoaded value)? loaded,
|
||||
TResult? Function(BlogPostStateError value)? error,
|
||||
}) =>
|
||||
throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult maybeMap<TResult extends Object?>(
|
||||
TResult Function(_BlogPostState value)? $default, {
|
||||
TResult Function(BlogPostStateLoading value)? loading,
|
||||
TResult Function(BlogPostStateLoaded value)? loaded,
|
||||
TResult Function(BlogPostStateError value)? error,
|
||||
required TResult orElse(),
|
||||
}) =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class $BlogPostStateCopyWith<$Res> {
|
||||
factory $BlogPostStateCopyWith(
|
||||
BlogPostState value, $Res Function(BlogPostState) then) =
|
||||
_$BlogPostStateCopyWithImpl<$Res, BlogPostState>;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class _$BlogPostStateCopyWithImpl<$Res, $Val extends BlogPostState>
|
||||
implements $BlogPostStateCopyWith<$Res> {
|
||||
_$BlogPostStateCopyWithImpl(this._value, this._then);
|
||||
|
||||
// ignore: unused_field
|
||||
final $Val _value;
|
||||
// ignore: unused_field
|
||||
final $Res Function($Val) _then;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$BlogPostStateImplCopyWith<$Res> {
|
||||
factory _$$BlogPostStateImplCopyWith(
|
||||
_$BlogPostStateImpl value, $Res Function(_$BlogPostStateImpl) then) =
|
||||
__$$BlogPostStateImplCopyWithImpl<$Res>;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$BlogPostStateImplCopyWithImpl<$Res>
|
||||
extends _$BlogPostStateCopyWithImpl<$Res, _$BlogPostStateImpl>
|
||||
implements _$$BlogPostStateImplCopyWith<$Res> {
|
||||
__$$BlogPostStateImplCopyWithImpl(
|
||||
_$BlogPostStateImpl _value, $Res Function(_$BlogPostStateImpl) _then)
|
||||
: super(_value, _then);
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
class _$BlogPostStateImpl implements _BlogPostState {
|
||||
const _$BlogPostStateImpl();
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'BlogPostState()';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType && other is _$BlogPostStateImpl);
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => runtimeType.hashCode;
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult when<TResult extends Object?>(
|
||||
TResult Function() $default, {
|
||||
required TResult Function() loading,
|
||||
required TResult Function(BlogPostModel blogPost) loaded,
|
||||
required TResult Function(String errorMessage) error,
|
||||
}) {
|
||||
return $default();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? whenOrNull<TResult extends Object?>(
|
||||
TResult? Function()? $default, {
|
||||
TResult? Function()? loading,
|
||||
TResult? Function(BlogPostModel blogPost)? loaded,
|
||||
TResult? Function(String errorMessage)? error,
|
||||
}) {
|
||||
return $default?.call();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeWhen<TResult extends Object?>(
|
||||
TResult Function()? $default, {
|
||||
TResult Function()? loading,
|
||||
TResult Function(BlogPostModel blogPost)? loaded,
|
||||
TResult Function(String errorMessage)? error,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if ($default != null) {
|
||||
return $default();
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult map<TResult extends Object?>(
|
||||
TResult Function(_BlogPostState value) $default, {
|
||||
required TResult Function(BlogPostStateLoading value) loading,
|
||||
required TResult Function(BlogPostStateLoaded value) loaded,
|
||||
required TResult Function(BlogPostStateError value) error,
|
||||
}) {
|
||||
return $default(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? mapOrNull<TResult extends Object?>(
|
||||
TResult? Function(_BlogPostState value)? $default, {
|
||||
TResult? Function(BlogPostStateLoading value)? loading,
|
||||
TResult? Function(BlogPostStateLoaded value)? loaded,
|
||||
TResult? Function(BlogPostStateError value)? error,
|
||||
}) {
|
||||
return $default?.call(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeMap<TResult extends Object?>(
|
||||
TResult Function(_BlogPostState value)? $default, {
|
||||
TResult Function(BlogPostStateLoading value)? loading,
|
||||
TResult Function(BlogPostStateLoaded value)? loaded,
|
||||
TResult Function(BlogPostStateError value)? error,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if ($default != null) {
|
||||
return $default(this);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
}
|
||||
|
||||
abstract class _BlogPostState implements BlogPostState {
|
||||
const factory _BlogPostState() = _$BlogPostStateImpl;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$BlogPostStateLoadingImplCopyWith<$Res> {
|
||||
factory _$$BlogPostStateLoadingImplCopyWith(_$BlogPostStateLoadingImpl value,
|
||||
$Res Function(_$BlogPostStateLoadingImpl) then) =
|
||||
__$$BlogPostStateLoadingImplCopyWithImpl<$Res>;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$BlogPostStateLoadingImplCopyWithImpl<$Res>
|
||||
extends _$BlogPostStateCopyWithImpl<$Res, _$BlogPostStateLoadingImpl>
|
||||
implements _$$BlogPostStateLoadingImplCopyWith<$Res> {
|
||||
__$$BlogPostStateLoadingImplCopyWithImpl(_$BlogPostStateLoadingImpl _value,
|
||||
$Res Function(_$BlogPostStateLoadingImpl) _then)
|
||||
: super(_value, _then);
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
class _$BlogPostStateLoadingImpl implements BlogPostStateLoading {
|
||||
const _$BlogPostStateLoadingImpl();
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'BlogPostState.loading()';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$BlogPostStateLoadingImpl);
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => runtimeType.hashCode;
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult when<TResult extends Object?>(
|
||||
TResult Function() $default, {
|
||||
required TResult Function() loading,
|
||||
required TResult Function(BlogPostModel blogPost) loaded,
|
||||
required TResult Function(String errorMessage) error,
|
||||
}) {
|
||||
return loading();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? whenOrNull<TResult extends Object?>(
|
||||
TResult? Function()? $default, {
|
||||
TResult? Function()? loading,
|
||||
TResult? Function(BlogPostModel blogPost)? loaded,
|
||||
TResult? Function(String errorMessage)? error,
|
||||
}) {
|
||||
return loading?.call();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeWhen<TResult extends Object?>(
|
||||
TResult Function()? $default, {
|
||||
TResult Function()? loading,
|
||||
TResult Function(BlogPostModel blogPost)? loaded,
|
||||
TResult Function(String errorMessage)? error,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (loading != null) {
|
||||
return loading();
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult map<TResult extends Object?>(
|
||||
TResult Function(_BlogPostState value) $default, {
|
||||
required TResult Function(BlogPostStateLoading value) loading,
|
||||
required TResult Function(BlogPostStateLoaded value) loaded,
|
||||
required TResult Function(BlogPostStateError value) error,
|
||||
}) {
|
||||
return loading(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? mapOrNull<TResult extends Object?>(
|
||||
TResult? Function(_BlogPostState value)? $default, {
|
||||
TResult? Function(BlogPostStateLoading value)? loading,
|
||||
TResult? Function(BlogPostStateLoaded value)? loaded,
|
||||
TResult? Function(BlogPostStateError value)? error,
|
||||
}) {
|
||||
return loading?.call(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeMap<TResult extends Object?>(
|
||||
TResult Function(_BlogPostState value)? $default, {
|
||||
TResult Function(BlogPostStateLoading value)? loading,
|
||||
TResult Function(BlogPostStateLoaded value)? loaded,
|
||||
TResult Function(BlogPostStateError value)? error,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (loading != null) {
|
||||
return loading(this);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
}
|
||||
|
||||
abstract class BlogPostStateLoading implements BlogPostState {
|
||||
const factory BlogPostStateLoading() = _$BlogPostStateLoadingImpl;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$BlogPostStateLoadedImplCopyWith<$Res> {
|
||||
factory _$$BlogPostStateLoadedImplCopyWith(_$BlogPostStateLoadedImpl value,
|
||||
$Res Function(_$BlogPostStateLoadedImpl) then) =
|
||||
__$$BlogPostStateLoadedImplCopyWithImpl<$Res>;
|
||||
@useResult
|
||||
$Res call({BlogPostModel blogPost});
|
||||
|
||||
$BlogPostModelCopyWith<$Res> get blogPost;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$BlogPostStateLoadedImplCopyWithImpl<$Res>
|
||||
extends _$BlogPostStateCopyWithImpl<$Res, _$BlogPostStateLoadedImpl>
|
||||
implements _$$BlogPostStateLoadedImplCopyWith<$Res> {
|
||||
__$$BlogPostStateLoadedImplCopyWithImpl(_$BlogPostStateLoadedImpl _value,
|
||||
$Res Function(_$BlogPostStateLoadedImpl) _then)
|
||||
: super(_value, _then);
|
||||
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? blogPost = null,
|
||||
}) {
|
||||
return _then(_$BlogPostStateLoadedImpl(
|
||||
blogPost: null == blogPost
|
||||
? _value.blogPost
|
||||
: blogPost // ignore: cast_nullable_to_non_nullable
|
||||
as BlogPostModel,
|
||||
));
|
||||
}
|
||||
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
$BlogPostModelCopyWith<$Res> get blogPost {
|
||||
return $BlogPostModelCopyWith<$Res>(_value.blogPost, (value) {
|
||||
return _then(_value.copyWith(blogPost: value));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
class _$BlogPostStateLoadedImpl implements BlogPostStateLoaded {
|
||||
const _$BlogPostStateLoadedImpl({required this.blogPost});
|
||||
|
||||
@override
|
||||
final BlogPostModel blogPost;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'BlogPostState.loaded(blogPost: $blogPost)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$BlogPostStateLoadedImpl &&
|
||||
(identical(other.blogPost, blogPost) ||
|
||||
other.blogPost == blogPost));
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType, blogPost);
|
||||
|
||||
@JsonKey(ignore: true)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$BlogPostStateLoadedImplCopyWith<_$BlogPostStateLoadedImpl> get copyWith =>
|
||||
__$$BlogPostStateLoadedImplCopyWithImpl<_$BlogPostStateLoadedImpl>(
|
||||
this, _$identity);
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult when<TResult extends Object?>(
|
||||
TResult Function() $default, {
|
||||
required TResult Function() loading,
|
||||
required TResult Function(BlogPostModel blogPost) loaded,
|
||||
required TResult Function(String errorMessage) error,
|
||||
}) {
|
||||
return loaded(blogPost);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? whenOrNull<TResult extends Object?>(
|
||||
TResult? Function()? $default, {
|
||||
TResult? Function()? loading,
|
||||
TResult? Function(BlogPostModel blogPost)? loaded,
|
||||
TResult? Function(String errorMessage)? error,
|
||||
}) {
|
||||
return loaded?.call(blogPost);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeWhen<TResult extends Object?>(
|
||||
TResult Function()? $default, {
|
||||
TResult Function()? loading,
|
||||
TResult Function(BlogPostModel blogPost)? loaded,
|
||||
TResult Function(String errorMessage)? error,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (loaded != null) {
|
||||
return loaded(blogPost);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult map<TResult extends Object?>(
|
||||
TResult Function(_BlogPostState value) $default, {
|
||||
required TResult Function(BlogPostStateLoading value) loading,
|
||||
required TResult Function(BlogPostStateLoaded value) loaded,
|
||||
required TResult Function(BlogPostStateError value) error,
|
||||
}) {
|
||||
return loaded(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? mapOrNull<TResult extends Object?>(
|
||||
TResult? Function(_BlogPostState value)? $default, {
|
||||
TResult? Function(BlogPostStateLoading value)? loading,
|
||||
TResult? Function(BlogPostStateLoaded value)? loaded,
|
||||
TResult? Function(BlogPostStateError value)? error,
|
||||
}) {
|
||||
return loaded?.call(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeMap<TResult extends Object?>(
|
||||
TResult Function(_BlogPostState value)? $default, {
|
||||
TResult Function(BlogPostStateLoading value)? loading,
|
||||
TResult Function(BlogPostStateLoaded value)? loaded,
|
||||
TResult Function(BlogPostStateError value)? error,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (loaded != null) {
|
||||
return loaded(this);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
}
|
||||
|
||||
abstract class BlogPostStateLoaded implements BlogPostState {
|
||||
const factory BlogPostStateLoaded({required final BlogPostModel blogPost}) =
|
||||
_$BlogPostStateLoadedImpl;
|
||||
|
||||
BlogPostModel get blogPost;
|
||||
@JsonKey(ignore: true)
|
||||
_$$BlogPostStateLoadedImplCopyWith<_$BlogPostStateLoadedImpl> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$BlogPostStateErrorImplCopyWith<$Res> {
|
||||
factory _$$BlogPostStateErrorImplCopyWith(_$BlogPostStateErrorImpl value,
|
||||
$Res Function(_$BlogPostStateErrorImpl) then) =
|
||||
__$$BlogPostStateErrorImplCopyWithImpl<$Res>;
|
||||
@useResult
|
||||
$Res call({String errorMessage});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$BlogPostStateErrorImplCopyWithImpl<$Res>
|
||||
extends _$BlogPostStateCopyWithImpl<$Res, _$BlogPostStateErrorImpl>
|
||||
implements _$$BlogPostStateErrorImplCopyWith<$Res> {
|
||||
__$$BlogPostStateErrorImplCopyWithImpl(_$BlogPostStateErrorImpl _value,
|
||||
$Res Function(_$BlogPostStateErrorImpl) _then)
|
||||
: super(_value, _then);
|
||||
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? errorMessage = null,
|
||||
}) {
|
||||
return _then(_$BlogPostStateErrorImpl(
|
||||
errorMessage: null == errorMessage
|
||||
? _value.errorMessage
|
||||
: errorMessage // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
class _$BlogPostStateErrorImpl implements BlogPostStateError {
|
||||
const _$BlogPostStateErrorImpl({required this.errorMessage});
|
||||
|
||||
@override
|
||||
final String errorMessage;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'BlogPostState.error(errorMessage: $errorMessage)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$BlogPostStateErrorImpl &&
|
||||
(identical(other.errorMessage, errorMessage) ||
|
||||
other.errorMessage == errorMessage));
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType, errorMessage);
|
||||
|
||||
@JsonKey(ignore: true)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$BlogPostStateErrorImplCopyWith<_$BlogPostStateErrorImpl> get copyWith =>
|
||||
__$$BlogPostStateErrorImplCopyWithImpl<_$BlogPostStateErrorImpl>(
|
||||
this, _$identity);
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult when<TResult extends Object?>(
|
||||
TResult Function() $default, {
|
||||
required TResult Function() loading,
|
||||
required TResult Function(BlogPostModel blogPost) loaded,
|
||||
required TResult Function(String errorMessage) error,
|
||||
}) {
|
||||
return error(errorMessage);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? whenOrNull<TResult extends Object?>(
|
||||
TResult? Function()? $default, {
|
||||
TResult? Function()? loading,
|
||||
TResult? Function(BlogPostModel blogPost)? loaded,
|
||||
TResult? Function(String errorMessage)? error,
|
||||
}) {
|
||||
return error?.call(errorMessage);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeWhen<TResult extends Object?>(
|
||||
TResult Function()? $default, {
|
||||
TResult Function()? loading,
|
||||
TResult Function(BlogPostModel blogPost)? loaded,
|
||||
TResult Function(String errorMessage)? error,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (error != null) {
|
||||
return error(errorMessage);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult map<TResult extends Object?>(
|
||||
TResult Function(_BlogPostState value) $default, {
|
||||
required TResult Function(BlogPostStateLoading value) loading,
|
||||
required TResult Function(BlogPostStateLoaded value) loaded,
|
||||
required TResult Function(BlogPostStateError value) error,
|
||||
}) {
|
||||
return error(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? mapOrNull<TResult extends Object?>(
|
||||
TResult? Function(_BlogPostState value)? $default, {
|
||||
TResult? Function(BlogPostStateLoading value)? loading,
|
||||
TResult? Function(BlogPostStateLoaded value)? loaded,
|
||||
TResult? Function(BlogPostStateError value)? error,
|
||||
}) {
|
||||
return error?.call(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeMap<TResult extends Object?>(
|
||||
TResult Function(_BlogPostState value)? $default, {
|
||||
TResult Function(BlogPostStateLoading value)? loading,
|
||||
TResult Function(BlogPostStateLoaded value)? loaded,
|
||||
TResult Function(BlogPostStateError value)? error,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (error != null) {
|
||||
return error(this);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
}
|
||||
|
||||
abstract class BlogPostStateError implements BlogPostState {
|
||||
const factory BlogPostStateError({required final String errorMessage}) =
|
||||
_$BlogPostStateErrorImpl;
|
||||
|
||||
String get errorMessage;
|
||||
@JsonKey(ignore: true)
|
||||
_$$BlogPostStateErrorImplCopyWith<_$BlogPostStateErrorImpl> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
@@ -1,64 +1,40 @@
|
||||
import 'package:go_router/go_router.dart';
|
||||
|
||||
import 'bloc/blog_post_bloc.dart';
|
||||
import 'models/blog_post_model.dart';
|
||||
import 'widgets/comment_widget.dart';
|
||||
import 'package:cached_network_image/cached_network_image.dart';
|
||||
import 'package:eatvio_app/core/app_export.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:eatvio_app/features/blog_post/presentation/bloc/blog_post_cubit.dart';
|
||||
import 'package:eatvio_app/features/blog_post/presentation/bloc/blog_post_state.dart';
|
||||
import 'package:eatvio_app/locator_service.dart';
|
||||
import 'package:eatvio_app/widgets/custom_edit_text_form_field.dart';
|
||||
import 'package:eatvio_app/widgets/custom_outlined_button.dart';
|
||||
import 'package:cached_network_image/cached_network_image.dart';
|
||||
import 'package:flutter_dotenv/flutter_dotenv.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
|
||||
class BlogPostScreen extends StatelessWidget {
|
||||
const BlogPostScreen({Key? key}) : super(key: key);
|
||||
final String blogPostID;
|
||||
|
||||
static Widget builder(BuildContext context, String blog_postID) {
|
||||
return BlocProvider<BlogPostBloc>(
|
||||
create: (context) => BlogPostBloc(
|
||||
BlogPostState(
|
||||
blog_postModelObj: BlogPostModel(
|
||||
blog_postID: blog_postID.toString(),
|
||||
),
|
||||
),
|
||||
)..add(
|
||||
BlogPostInitialEvent(),
|
||||
),
|
||||
child: BlogPostScreen(),
|
||||
);
|
||||
}
|
||||
const BlogPostScreen({super.key, required this.blogPostID});
|
||||
|
||||
Widget build(BuildContext context) {
|
||||
return BlocBuilder<BlogPostBloc, BlogPostState>(
|
||||
builder: (context, state) {
|
||||
if (state is BlogPostInitialState) {
|
||||
return Scaffold(
|
||||
body: Center(
|
||||
child: CircularProgressIndicator(),
|
||||
),
|
||||
);
|
||||
} else if (state is BlogPostLoadedState) {
|
||||
// Данные загружены, можно строить экран.
|
||||
return _buildBlogPost(context, state);
|
||||
} else if (state is BlogPostErrorState) {
|
||||
// Произошла ошибка при загрузке данных.
|
||||
return Center(
|
||||
child: Text(state.errorMessage),
|
||||
);
|
||||
} else {
|
||||
return Scaffold(
|
||||
body: Center(
|
||||
child: CircularProgressIndicator(),
|
||||
),
|
||||
);
|
||||
// Другие состояния, если они есть.
|
||||
}
|
||||
},
|
||||
return BlocProvider<BlogPostCubit>(
|
||||
create: (context) => sl<BlogPostCubit>()..loadBlogPost(blogPostID),
|
||||
child: BlocBuilder<BlogPostCubit, BlogPostState>(
|
||||
builder: (context, state) {
|
||||
if (state is BlogPostStateLoaded) {
|
||||
return _buildBlogPost(context, state);
|
||||
} else {
|
||||
return Scaffold(
|
||||
body: Center(
|
||||
child: CupertinoActivityIndicator(),
|
||||
),
|
||||
);
|
||||
}
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
_buildBlogPost(BuildContext context, BlogPostLoadedState state) {
|
||||
_buildBlogPost(BuildContext context, BlogPostStateLoaded state) {
|
||||
return SafeArea(
|
||||
child: Scaffold(
|
||||
resizeToAvoidBottomInset: false,
|
||||
@@ -82,8 +58,8 @@ class BlogPostScreen extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
_buildHeaderRow(BuildContext context, BlogPostLoadedState state) {
|
||||
final String name = state.author?['name'];
|
||||
_buildHeaderRow(BuildContext context, BlogPostStateLoaded state) {
|
||||
final String name = state.blogPost.title;
|
||||
return Container(
|
||||
margin: EdgeInsets.symmetric(horizontal: 16.h, vertical: 16.h),
|
||||
padding: EdgeInsets.symmetric(
|
||||
@@ -121,7 +97,7 @@ class BlogPostScreen extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
CachedNetworkImage(
|
||||
imageUrl: dotenv.env['STORAGE_URL']! + (state.author?['profile_photo_path'] ?? ''),
|
||||
imageUrl: baseUrl + '/storage/' + (state.blogPost.author_avatar_path ?? ''),
|
||||
imageBuilder: (context, imageProvider) => CircleAvatar(
|
||||
backgroundImage: imageProvider,
|
||||
radius: 25,
|
||||
@@ -141,7 +117,7 @@ class BlogPostScreen extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
_buildBlogPostData(BuildContext context, BlogPostLoadedState state) {
|
||||
_buildBlogPostData(BuildContext context, BlogPostStateLoaded state) {
|
||||
return Container(
|
||||
margin: EdgeInsets.only(
|
||||
left: 16.h,
|
||||
@@ -161,79 +137,90 @@ class BlogPostScreen extends StatelessWidget {
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Column(mainAxisSize: MainAxisSize.min, children: [
|
||||
Row(
|
||||
children: [
|
||||
Text(
|
||||
state.blog_post?['title'],
|
||||
style: CustomTextStyles.titleMediumBlack,
|
||||
),
|
||||
Spacer(),
|
||||
PopupMenuButton<String>(
|
||||
onSelected: (value) => tapMenu(value, context, state),
|
||||
itemBuilder: (BuildContext context) => <PopupMenuEntry<String>>[
|
||||
PopupMenuItem<String>(
|
||||
value: 'edit',
|
||||
child: Text('Редактировать'),
|
||||
),
|
||||
PopupMenuItem<String>(
|
||||
value: 'delete',
|
||||
child: Text('Удалить'),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
SizedBox(height: 8.0),
|
||||
_buildImage(state),
|
||||
SizedBox(height: 16.0),
|
||||
Text(
|
||||
state.blog_post?['description'],
|
||||
style: CustomTextStyles.bodyMediumBluegray800,
|
||||
),
|
||||
SizedBox(height: 16.0),
|
||||
Align(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Text(
|
||||
state.blogPost.title,
|
||||
style: CustomTextStyles.titleMediumBlack,
|
||||
),
|
||||
Spacer(),
|
||||
PopupMenuButton<String>(
|
||||
onSelected: (value) => tapMenu(value, context, state),
|
||||
itemBuilder: (BuildContext context) => <PopupMenuEntry<String>>[
|
||||
PopupMenuItem<String>(
|
||||
value: 'edit',
|
||||
child: Text('Редактировать'),
|
||||
),
|
||||
PopupMenuItem<String>(
|
||||
value: 'delete',
|
||||
child: Text('Удалить'),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
SizedBox(height: 8.0),
|
||||
_buildImage(state),
|
||||
SizedBox(height: 16.0),
|
||||
Text(
|
||||
state.blogPost.description,
|
||||
style: CustomTextStyles.bodyMediumBluegray800,
|
||||
),
|
||||
SizedBox(height: 16.0),
|
||||
Align(
|
||||
alignment: Alignment.topLeft,
|
||||
child: Text(
|
||||
DateFormat('dd.MM.yyyy').format(DateTime.parse(state.blog_post?['updated_at'])),
|
||||
DateFormat('dd.MM.yyyy').format(state.blogPost.updatedAt),
|
||||
style: theme.textTheme.bodyMedium,
|
||||
),),
|
||||
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),
|
||||
SizedBox(height: 8),
|
||||
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,
|
||||
),
|
||||
],
|
||||
),
|
||||
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,
|
||||
),
|
||||
],
|
||||
),
|
||||
],),),
|
||||
],),
|
||||
],),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
_buildImage(BlogPostLoadedState state) {
|
||||
_buildImage(BlogPostStateLoaded state) {
|
||||
return CachedNetworkImage(
|
||||
imageUrl: dotenv.env['STORAGE_URL']! + (state.blog_post?['image'] ?? ''),
|
||||
imageUrl: baseUrl + '/storage/' + (state.blogPost.image ?? ""),
|
||||
imageBuilder: (context, imageProvider) => Stack(
|
||||
children: [
|
||||
ClipRRect(
|
||||
@@ -290,7 +277,7 @@ class BlogPostScreen extends StatelessWidget {
|
||||
),
|
||||
SizedBox(width: 4.0),
|
||||
Text(
|
||||
'${state.comments?.length}',
|
||||
'42',
|
||||
style: TextStyle(color: Colors.white),
|
||||
),
|
||||
],
|
||||
@@ -306,18 +293,18 @@ class BlogPostScreen extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
void tapMenu(String value, BuildContext context, BlogPostLoadedState state) {
|
||||
void tapMenu(String value, BuildContext context, BlogPostStateLoaded state) {
|
||||
if (value == 'edit') {
|
||||
GoRouter.of(context).goNamed(
|
||||
GoRouter.of(context).pushNamed(
|
||||
'blogPostEditScreen',
|
||||
extra: state.blog_post?['id'].toString(),
|
||||
extra: state.blogPost.id.toString(),
|
||||
);
|
||||
} else if (value == 'delete') {
|
||||
context.read<BlogPostBloc>().add(DeleteEntry(state.blog_post?['id']));
|
||||
// context.read<BlogPostB>().add(DeleteEntry(state.blog_post?['id']));
|
||||
}
|
||||
}
|
||||
|
||||
_buildTextField(BuildContext context, BlogPostLoadedState state) {
|
||||
_buildTextField(BuildContext context, BlogPostStateLoaded state) {
|
||||
return Container(
|
||||
margin: EdgeInsets.only(
|
||||
left: 16.h,
|
||||
@@ -343,7 +330,7 @@ class BlogPostScreen extends StatelessWidget {
|
||||
Column(
|
||||
children: [
|
||||
CustomTextFormField(
|
||||
controller: state.commentController,
|
||||
// controller: state.commentController,
|
||||
maxLines: 4,
|
||||
),
|
||||
SizedBox(height: 15.h),
|
||||
@@ -354,7 +341,9 @@ class BlogPostScreen extends StatelessWidget {
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.transparent,
|
||||
),
|
||||
onPressed: () => context.read<BlogPostBloc>().add(CreateComment(state.commentController!.text)),
|
||||
/* onPressed: () => context
|
||||
.read<BlogPostBloc>()
|
||||
.add(CreateComment(state.commentController!.text)),*/
|
||||
// Установите прозрачный фон
|
||||
),
|
||||
],
|
||||
@@ -364,9 +353,9 @@ class BlogPostScreen extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
_buildCommentSection(BuildContext context, BlogPostLoadedState state) {
|
||||
if (state.comments != null && state.comments!.isNotEmpty) {
|
||||
return Column(
|
||||
_buildCommentSection(BuildContext context, BlogPostStateLoaded state) {
|
||||
/* if (state.comments != null && state.comments!.isNotEmpty) {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
for (int i = 0; i < state.comments!.length; i++)
|
||||
@@ -380,15 +369,14 @@ class BlogPostScreen extends StatelessWidget {
|
||||
],
|
||||
);
|
||||
} else {
|
||||
// Return a message or placeholder widget when there are no comments
|
||||
return Center(
|
||||
child: Text('No comments available'),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// Navigates to the previous screen.
|
||||
onTapArrowleftone(BuildContext context) {
|
||||
GoRouter.of(context).pop();
|
||||
// Return a message or placeholder widget when there are no comments*/
|
||||
return Center(
|
||||
child: Text('No comments available'),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// Navigates to the previous screen.
|
||||
onTapArrowleftone(BuildContext context) {
|
||||
GoRouter.of(context).pop();
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
import 'package:eatvio_app/features/blog_post/models/blog_post_model.dart';
|
||||
import 'package:eatvio_app/features/blog_post/services/blog_post_service.dart';
|
||||
|
||||
class BlogPostRepository {
|
||||
final BlogPostService blogPostService;
|
||||
|
||||
BlogPostRepository({required this.blogPostService});
|
||||
|
||||
Future<BlogPostModel> getBlogPost(String blogPostID) async {
|
||||
try {
|
||||
return await blogPostService.getBlogPost(blogPostID);
|
||||
} catch (e) {
|
||||
rethrow;
|
||||
}
|
||||
}
|
||||
}
|
||||
13
lib/features/blog_post/services/blog_post_service.dart
Normal file
13
lib/features/blog_post/services/blog_post_service.dart
Normal file
@@ -0,0 +1,13 @@
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:eatvio_app/features/blog_post/models/blog_post_model.dart';
|
||||
import 'package:retrofit/retrofit.dart';
|
||||
|
||||
part 'blog_post_service.g.dart';
|
||||
|
||||
@RestApi()
|
||||
abstract class BlogPostService {
|
||||
factory BlogPostService(Dio dio, {String baseUrl}) = _BlogPostService;
|
||||
|
||||
@GET('/api/blogPosts/show/{id}')
|
||||
Future<BlogPostModel> getBlogPost(@Path() String id);
|
||||
}
|
||||
77
lib/features/blog_post/services/blog_post_service.g.dart
Normal file
77
lib/features/blog_post/services/blog_post_service.g.dart
Normal file
@@ -0,0 +1,77 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'blog_post_service.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// RetrofitGenerator
|
||||
// **************************************************************************
|
||||
|
||||
// ignore_for_file: unnecessary_brace_in_string_interps,no_leading_underscores_for_local_identifiers,unused_element
|
||||
|
||||
class _BlogPostService implements BlogPostService {
|
||||
_BlogPostService(
|
||||
this._dio, {
|
||||
this.baseUrl,
|
||||
});
|
||||
|
||||
final Dio _dio;
|
||||
|
||||
String? baseUrl;
|
||||
|
||||
@override
|
||||
Future<BlogPostModel> getBlogPost(String id) async {
|
||||
final _extra = <String, dynamic>{};
|
||||
final queryParameters = <String, dynamic>{};
|
||||
final _headers = <String, dynamic>{};
|
||||
const Map<String, dynamic>? _data = null;
|
||||
final _result = await _dio
|
||||
.fetch<Map<String, dynamic>>(_setStreamType<BlogPostModel>(Options(
|
||||
method: 'GET',
|
||||
headers: _headers,
|
||||
extra: _extra,
|
||||
)
|
||||
.compose(
|
||||
_dio.options,
|
||||
'/api/blogPosts/show/${id}',
|
||||
queryParameters: queryParameters,
|
||||
data: _data,
|
||||
)
|
||||
.copyWith(
|
||||
baseUrl: _combineBaseUrls(
|
||||
_dio.options.baseUrl,
|
||||
baseUrl,
|
||||
))));
|
||||
final _value = BlogPostModel.fromJson(_result.data!);
|
||||
return _value;
|
||||
}
|
||||
|
||||
RequestOptions _setStreamType<T>(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();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
/*
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
||||
part '../../../presentation/feed/blog_post_create_screen/models/blog_post_create_credentials_model.freezed.dart';
|
||||
part '../../../presentation/feed/blog_post_create_screen/models/blog_post_create_credentials_model.g.dart';
|
||||
|
||||
@freezed
|
||||
class BlogPostCreateCredentialsModel with _$BlogPostCreateCredentialsModel {
|
||||
const factory BlogPostCreateCredentialsModel({
|
||||
required String title,
|
||||
required String description,
|
||||
@JsonKey(name: 'youtube_url') required String youtubeUrl,
|
||||
@Default('active') String status,
|
||||
}) = _BlogPostCreateCredentialsModel;
|
||||
|
||||
factory BlogPostCreateCredentialsModel.fromJson(Map<String, Object?> json) => _$BlogPostCreateCredentialsModelFromJson(json);
|
||||
}
|
||||
*/
|
||||
@@ -0,0 +1,209 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:eatvio_app/core/app_export.dart';
|
||||
import 'package:eatvio_app/widgets/custom_text_form_field.dart';
|
||||
import 'package:flutter/material.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);
|
||||
|
||||
static Widget builder(BuildContext context) {
|
||||
final blog_postID = ModalRoute.of(context)!.settings.arguments;
|
||||
return BlocProvider<BlogPostCreateBloc>(
|
||||
create: (context) => BlogPostCreateBloc(BlogPostCreateState(blog_postModelObj: BlogPostCreateModel(blog_postID: blog_postID.toString())))
|
||||
..add(BlogPostCreateInitialEvent()),
|
||||
child: BlogPostCreateScreen(),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
State<BlogPostCreateScreen> createState() => _BlogPostCreateScreenState();
|
||||
}
|
||||
|
||||
class _BlogPostCreateScreenState extends State<BlogPostCreateScreen> {
|
||||
Widget build(BuildContext context) {
|
||||
return BlocBuilder<BlogPostCreateBloc, BlogPostCreateState>(
|
||||
builder: (context, state) {
|
||||
if (state is BlogPostCreateInitialState) {
|
||||
// Это начальное состояние, данные ещё не загружены.
|
||||
return Container(
|
||||
color: Colors.white,
|
||||
);
|
||||
} else if (state is BlogPostCreateLoadedState) {
|
||||
// Данные загружены, можно строить экран.
|
||||
return _buildBlogPostCreate(context, state);
|
||||
} else if (state is BlogPostCreateErrorState) {
|
||||
// Произошла ошибка при загрузке данных.
|
||||
return Center(child: Text(state.errorMessage));
|
||||
} else {
|
||||
// Другие состояния, если они есть.
|
||||
return Container(); // Пустой контейнер для необработанных состояний.
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
_buildBlogPostCreate(BuildContext context, BlogPostCreateLoadedState state) {
|
||||
return Scaffold(
|
||||
resizeToAvoidBottomInset: false,
|
||||
appBar: AppBar(),
|
||||
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.blueA400,
|
||||
onPressed: () => _submitForm(context, state.title!.text, state.description!.text, state.youtubeURL!.text),
|
||||
label: Text(
|
||||
'Создать',
|
||||
style: theme.textTheme.titleSmall,
|
||||
),
|
||||
),
|
||||
),
|
||||
body: SingleChildScrollView(
|
||||
padding: EdgeInsets.all(16),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text('Заголовок'),
|
||||
SizedBox(height: 8),
|
||||
CustomTextFormField(
|
||||
controller: state.title,
|
||||
validator: _validateTitle,
|
||||
),
|
||||
SizedBox(height: 16),
|
||||
Text('Описание'),
|
||||
SizedBox(height: 8),
|
||||
CustomTextFormField(
|
||||
controller: state.description,
|
||||
validator: _validateDescription,
|
||||
maxLines: 6,
|
||||
minLines: 1,
|
||||
),
|
||||
SizedBox(height: 16),
|
||||
Text('Ссылка на видео'),
|
||||
SizedBox(height: 8),
|
||||
CustomTextFormField(
|
||||
controller: state.youtubeURL,
|
||||
validator: _validateYouTubeLink,
|
||||
),
|
||||
SizedBox(height: 16),
|
||||
Text('Изображение поста'),
|
||||
SizedBox(height: 8),
|
||||
_buildAddPhoto(context, state),
|
||||
SizedBox(height: 80),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
_submitForm(BuildContext context, String title, String description, String youtubeURL) async {
|
||||
String? titleError = _validateTitle(title);
|
||||
String? descriptionError = _validateDescription(description);
|
||||
String? youtubeURLError = _validateYouTubeLink(youtubeURL);
|
||||
|
||||
if (titleError != null || descriptionError != null || youtubeURLError != null) {
|
||||
// Display error messages or handle invalid input as needed
|
||||
// For example, show a snackbar with the error message
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(content: Text(titleError ?? descriptionError ?? youtubeURLError!)),
|
||||
);
|
||||
} else {
|
||||
// Proceed with form submission
|
||||
context.read<BlogPostCreateBloc>().add(CreateBlogPost());
|
||||
}
|
||||
}
|
||||
|
||||
_buildAddPhoto(BuildContext context, BlogPostCreateLoadedState state) {
|
||||
bool isLoading = state.isLoading;
|
||||
return GestureDetector(
|
||||
onTap: addImage(context, isLoading),
|
||||
child: Stack(
|
||||
children: [
|
||||
if (state.image == null)
|
||||
Container(
|
||||
height: 128,
|
||||
decoration: AppDecoration.fillGray.copyWith(
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Icon(
|
||||
Icons.photo_library,
|
||||
color: appTheme.blueGray300,
|
||||
),
|
||||
SizedBox(width: 8),
|
||||
Text(
|
||||
"Добавить фото",
|
||||
selectionColor: appTheme.blueA400,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
if (state.image != null)
|
||||
ClipRRect(
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
child: Image(
|
||||
image: FileImage(
|
||||
File(state.image!.path),
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
addImage(BuildContext context, bool isLoading) {
|
||||
if (!isLoading) {
|
||||
return () async {
|
||||
final picker = ImagePicker();
|
||||
XFile? image = await picker.pickImage(source: ImageSource.gallery);
|
||||
if (image != null) {
|
||||
context.read<BlogPostCreateBloc>().add(UploadImages(image));
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
String? _validateTitle(value) {
|
||||
if (value!.isEmpty) {
|
||||
return 'Пожалуйста, введите заголовок';
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
String? _validateDescription(value) {
|
||||
if (value!.isEmpty) {
|
||||
return 'Пожалуйста, введите описание';
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
String? _validateYouTubeLink(value) {
|
||||
if (value!.isEmpty) {
|
||||
return 'Пожалуйста, введите ссылку';
|
||||
} else if (!_isValidUrl(value)) {
|
||||
return 'Пожалуйста, введите корректную ссылку';
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
bool _isValidUrl(String url) {
|
||||
final RegExp urlRegExp = new RegExp(r"^(http|https):\/\/([\w-]+\.)+[\w-]+(\/[\w-./?%&=]*)?$");
|
||||
return urlRegExp.hasMatch(url);
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
import 'package:eatvio_app/features/blog_post_create/models/blog_post_create_credentials_model.dart';
|
||||
import 'package:eatvio_app/features/blog_post_create/services/blog_service.dart';
|
||||
|
||||
class BlogRepository {
|
||||
final BlogService blogService;
|
||||
|
||||
BlogRepository({
|
||||
required this.blogService,
|
||||
});
|
||||
|
||||
Future<BlogPostCreateCredentialsModel> createBlogPost(BlogPostCreateCredentialsModel model) async {
|
||||
try {
|
||||
return (await blogService.createBlogPost(model));
|
||||
} catch (e) {
|
||||
print(e);
|
||||
throw (e);
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
16
lib/features/blog_post_create/services/blog_service.dart
Normal file
16
lib/features/blog_post_create/services/blog_service.dart
Normal file
@@ -0,0 +1,16 @@
|
||||
/*
|
||||
import 'package:eatvio_app/features/blog_post_create/models/blog_post_create_credentials_model.dart';
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:retrofit/retrofit.dart';
|
||||
|
||||
part 'blog_service.g.dart';
|
||||
|
||||
@RestApi()
|
||||
abstract class BlogService {
|
||||
factory BlogService(Dio dio, {String baseUrl}) = _BlogService;
|
||||
|
||||
@POST('/blog_post/create')
|
||||
Future<BlogPostCreateCredentialsModel> createBlogPost(
|
||||
BlogPostCreateCredentialsModel model);
|
||||
}
|
||||
*/
|
||||
@@ -0,0 +1,13 @@
|
||||
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';
|
||||
|
||||
class NewMessagesCubit extends Cubit<NewMessagesState> {
|
||||
int _messagesCount = 0;
|
||||
|
||||
NewMessagesCubit() : super(const NewMessagesState.empty());
|
||||
|
||||
incrementCounter() {
|
||||
_messagesCount++;
|
||||
emit(NewMessagesState.loaded(messagesCount: _messagesCount));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
||||
part 'new_messages_state.freezed.dart';
|
||||
|
||||
@freezed
|
||||
abstract class NewMessagesState with _$NewMessagesState {
|
||||
const factory NewMessagesState() = _NewMessagesState;
|
||||
|
||||
const factory NewMessagesState.empty() = NewMessagesStateEmpty;
|
||||
|
||||
const factory NewMessagesState.loaded({
|
||||
required int messagesCount,
|
||||
}) = NewMessagesStateLoaded;
|
||||
|
||||
const factory NewMessagesState.error({
|
||||
required String errorMessage,
|
||||
}) = NewMessagesStateError;
|
||||
}
|
||||
@@ -0,0 +1,616 @@
|
||||
// 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 'new_messages_state.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// FreezedGenerator
|
||||
// **************************************************************************
|
||||
|
||||
T _$identity<T>(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 _$NewMessagesState {
|
||||
@optionalTypeArgs
|
||||
TResult when<TResult extends Object?>(
|
||||
TResult Function() $default, {
|
||||
required TResult Function() empty,
|
||||
required TResult Function(int messagesCount) loaded,
|
||||
required TResult Function(String errorMessage) error,
|
||||
}) =>
|
||||
throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult? whenOrNull<TResult extends Object?>(
|
||||
TResult? Function()? $default, {
|
||||
TResult? Function()? empty,
|
||||
TResult? Function(int messagesCount)? loaded,
|
||||
TResult? Function(String errorMessage)? error,
|
||||
}) =>
|
||||
throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult maybeWhen<TResult extends Object?>(
|
||||
TResult Function()? $default, {
|
||||
TResult Function()? empty,
|
||||
TResult Function(int messagesCount)? loaded,
|
||||
TResult Function(String errorMessage)? error,
|
||||
required TResult orElse(),
|
||||
}) =>
|
||||
throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult map<TResult extends Object?>(
|
||||
TResult Function(_NewMessagesState value) $default, {
|
||||
required TResult Function(NewMessagesStateEmpty value) empty,
|
||||
required TResult Function(NewMessagesStateLoaded value) loaded,
|
||||
required TResult Function(NewMessagesStateError value) error,
|
||||
}) =>
|
||||
throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult? mapOrNull<TResult extends Object?>(
|
||||
TResult? Function(_NewMessagesState value)? $default, {
|
||||
TResult? Function(NewMessagesStateEmpty value)? empty,
|
||||
TResult? Function(NewMessagesStateLoaded value)? loaded,
|
||||
TResult? Function(NewMessagesStateError value)? error,
|
||||
}) =>
|
||||
throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult maybeMap<TResult extends Object?>(
|
||||
TResult Function(_NewMessagesState value)? $default, {
|
||||
TResult Function(NewMessagesStateEmpty value)? empty,
|
||||
TResult Function(NewMessagesStateLoaded value)? loaded,
|
||||
TResult Function(NewMessagesStateError value)? error,
|
||||
required TResult orElse(),
|
||||
}) =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class $NewMessagesStateCopyWith<$Res> {
|
||||
factory $NewMessagesStateCopyWith(
|
||||
NewMessagesState value, $Res Function(NewMessagesState) then) =
|
||||
_$NewMessagesStateCopyWithImpl<$Res, NewMessagesState>;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class _$NewMessagesStateCopyWithImpl<$Res, $Val extends NewMessagesState>
|
||||
implements $NewMessagesStateCopyWith<$Res> {
|
||||
_$NewMessagesStateCopyWithImpl(this._value, this._then);
|
||||
|
||||
// ignore: unused_field
|
||||
final $Val _value;
|
||||
// ignore: unused_field
|
||||
final $Res Function($Val) _then;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$NewMessagesStateImplCopyWith<$Res> {
|
||||
factory _$$NewMessagesStateImplCopyWith(_$NewMessagesStateImpl value,
|
||||
$Res Function(_$NewMessagesStateImpl) then) =
|
||||
__$$NewMessagesStateImplCopyWithImpl<$Res>;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$NewMessagesStateImplCopyWithImpl<$Res>
|
||||
extends _$NewMessagesStateCopyWithImpl<$Res, _$NewMessagesStateImpl>
|
||||
implements _$$NewMessagesStateImplCopyWith<$Res> {
|
||||
__$$NewMessagesStateImplCopyWithImpl(_$NewMessagesStateImpl _value,
|
||||
$Res Function(_$NewMessagesStateImpl) _then)
|
||||
: super(_value, _then);
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
class _$NewMessagesStateImpl implements _NewMessagesState {
|
||||
const _$NewMessagesStateImpl();
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'NewMessagesState()';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType && other is _$NewMessagesStateImpl);
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => runtimeType.hashCode;
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult when<TResult extends Object?>(
|
||||
TResult Function() $default, {
|
||||
required TResult Function() empty,
|
||||
required TResult Function(int messagesCount) loaded,
|
||||
required TResult Function(String errorMessage) error,
|
||||
}) {
|
||||
return $default();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? whenOrNull<TResult extends Object?>(
|
||||
TResult? Function()? $default, {
|
||||
TResult? Function()? empty,
|
||||
TResult? Function(int messagesCount)? loaded,
|
||||
TResult? Function(String errorMessage)? error,
|
||||
}) {
|
||||
return $default?.call();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeWhen<TResult extends Object?>(
|
||||
TResult Function()? $default, {
|
||||
TResult Function()? empty,
|
||||
TResult Function(int messagesCount)? loaded,
|
||||
TResult Function(String errorMessage)? error,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if ($default != null) {
|
||||
return $default();
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult map<TResult extends Object?>(
|
||||
TResult Function(_NewMessagesState value) $default, {
|
||||
required TResult Function(NewMessagesStateEmpty value) empty,
|
||||
required TResult Function(NewMessagesStateLoaded value) loaded,
|
||||
required TResult Function(NewMessagesStateError value) error,
|
||||
}) {
|
||||
return $default(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? mapOrNull<TResult extends Object?>(
|
||||
TResult? Function(_NewMessagesState value)? $default, {
|
||||
TResult? Function(NewMessagesStateEmpty value)? empty,
|
||||
TResult? Function(NewMessagesStateLoaded value)? loaded,
|
||||
TResult? Function(NewMessagesStateError value)? error,
|
||||
}) {
|
||||
return $default?.call(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeMap<TResult extends Object?>(
|
||||
TResult Function(_NewMessagesState value)? $default, {
|
||||
TResult Function(NewMessagesStateEmpty value)? empty,
|
||||
TResult Function(NewMessagesStateLoaded value)? loaded,
|
||||
TResult Function(NewMessagesStateError value)? error,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if ($default != null) {
|
||||
return $default(this);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
}
|
||||
|
||||
abstract class _NewMessagesState implements NewMessagesState {
|
||||
const factory _NewMessagesState() = _$NewMessagesStateImpl;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$NewMessagesStateEmptyImplCopyWith<$Res> {
|
||||
factory _$$NewMessagesStateEmptyImplCopyWith(
|
||||
_$NewMessagesStateEmptyImpl value,
|
||||
$Res Function(_$NewMessagesStateEmptyImpl) then) =
|
||||
__$$NewMessagesStateEmptyImplCopyWithImpl<$Res>;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$NewMessagesStateEmptyImplCopyWithImpl<$Res>
|
||||
extends _$NewMessagesStateCopyWithImpl<$Res, _$NewMessagesStateEmptyImpl>
|
||||
implements _$$NewMessagesStateEmptyImplCopyWith<$Res> {
|
||||
__$$NewMessagesStateEmptyImplCopyWithImpl(_$NewMessagesStateEmptyImpl _value,
|
||||
$Res Function(_$NewMessagesStateEmptyImpl) _then)
|
||||
: super(_value, _then);
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
class _$NewMessagesStateEmptyImpl implements NewMessagesStateEmpty {
|
||||
const _$NewMessagesStateEmptyImpl();
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'NewMessagesState.empty()';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$NewMessagesStateEmptyImpl);
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => runtimeType.hashCode;
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult when<TResult extends Object?>(
|
||||
TResult Function() $default, {
|
||||
required TResult Function() empty,
|
||||
required TResult Function(int messagesCount) loaded,
|
||||
required TResult Function(String errorMessage) error,
|
||||
}) {
|
||||
return empty();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? whenOrNull<TResult extends Object?>(
|
||||
TResult? Function()? $default, {
|
||||
TResult? Function()? empty,
|
||||
TResult? Function(int messagesCount)? loaded,
|
||||
TResult? Function(String errorMessage)? error,
|
||||
}) {
|
||||
return empty?.call();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeWhen<TResult extends Object?>(
|
||||
TResult Function()? $default, {
|
||||
TResult Function()? empty,
|
||||
TResult Function(int messagesCount)? loaded,
|
||||
TResult Function(String errorMessage)? error,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (empty != null) {
|
||||
return empty();
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult map<TResult extends Object?>(
|
||||
TResult Function(_NewMessagesState value) $default, {
|
||||
required TResult Function(NewMessagesStateEmpty value) empty,
|
||||
required TResult Function(NewMessagesStateLoaded value) loaded,
|
||||
required TResult Function(NewMessagesStateError value) error,
|
||||
}) {
|
||||
return empty(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? mapOrNull<TResult extends Object?>(
|
||||
TResult? Function(_NewMessagesState value)? $default, {
|
||||
TResult? Function(NewMessagesStateEmpty value)? empty,
|
||||
TResult? Function(NewMessagesStateLoaded value)? loaded,
|
||||
TResult? Function(NewMessagesStateError value)? error,
|
||||
}) {
|
||||
return empty?.call(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeMap<TResult extends Object?>(
|
||||
TResult Function(_NewMessagesState value)? $default, {
|
||||
TResult Function(NewMessagesStateEmpty value)? empty,
|
||||
TResult Function(NewMessagesStateLoaded value)? loaded,
|
||||
TResult Function(NewMessagesStateError value)? error,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (empty != null) {
|
||||
return empty(this);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
}
|
||||
|
||||
abstract class NewMessagesStateEmpty implements NewMessagesState {
|
||||
const factory NewMessagesStateEmpty() = _$NewMessagesStateEmptyImpl;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$NewMessagesStateLoadedImplCopyWith<$Res> {
|
||||
factory _$$NewMessagesStateLoadedImplCopyWith(
|
||||
_$NewMessagesStateLoadedImpl value,
|
||||
$Res Function(_$NewMessagesStateLoadedImpl) then) =
|
||||
__$$NewMessagesStateLoadedImplCopyWithImpl<$Res>;
|
||||
@useResult
|
||||
$Res call({int messagesCount});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$NewMessagesStateLoadedImplCopyWithImpl<$Res>
|
||||
extends _$NewMessagesStateCopyWithImpl<$Res, _$NewMessagesStateLoadedImpl>
|
||||
implements _$$NewMessagesStateLoadedImplCopyWith<$Res> {
|
||||
__$$NewMessagesStateLoadedImplCopyWithImpl(
|
||||
_$NewMessagesStateLoadedImpl _value,
|
||||
$Res Function(_$NewMessagesStateLoadedImpl) _then)
|
||||
: super(_value, _then);
|
||||
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? messagesCount = null,
|
||||
}) {
|
||||
return _then(_$NewMessagesStateLoadedImpl(
|
||||
messagesCount: null == messagesCount
|
||||
? _value.messagesCount
|
||||
: messagesCount // ignore: cast_nullable_to_non_nullable
|
||||
as int,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
class _$NewMessagesStateLoadedImpl implements NewMessagesStateLoaded {
|
||||
const _$NewMessagesStateLoadedImpl({required this.messagesCount});
|
||||
|
||||
@override
|
||||
final int messagesCount;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'NewMessagesState.loaded(messagesCount: $messagesCount)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$NewMessagesStateLoadedImpl &&
|
||||
(identical(other.messagesCount, messagesCount) ||
|
||||
other.messagesCount == messagesCount));
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType, messagesCount);
|
||||
|
||||
@JsonKey(ignore: true)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$NewMessagesStateLoadedImplCopyWith<_$NewMessagesStateLoadedImpl>
|
||||
get copyWith => __$$NewMessagesStateLoadedImplCopyWithImpl<
|
||||
_$NewMessagesStateLoadedImpl>(this, _$identity);
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult when<TResult extends Object?>(
|
||||
TResult Function() $default, {
|
||||
required TResult Function() empty,
|
||||
required TResult Function(int messagesCount) loaded,
|
||||
required TResult Function(String errorMessage) error,
|
||||
}) {
|
||||
return loaded(messagesCount);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? whenOrNull<TResult extends Object?>(
|
||||
TResult? Function()? $default, {
|
||||
TResult? Function()? empty,
|
||||
TResult? Function(int messagesCount)? loaded,
|
||||
TResult? Function(String errorMessage)? error,
|
||||
}) {
|
||||
return loaded?.call(messagesCount);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeWhen<TResult extends Object?>(
|
||||
TResult Function()? $default, {
|
||||
TResult Function()? empty,
|
||||
TResult Function(int messagesCount)? loaded,
|
||||
TResult Function(String errorMessage)? error,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (loaded != null) {
|
||||
return loaded(messagesCount);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult map<TResult extends Object?>(
|
||||
TResult Function(_NewMessagesState value) $default, {
|
||||
required TResult Function(NewMessagesStateEmpty value) empty,
|
||||
required TResult Function(NewMessagesStateLoaded value) loaded,
|
||||
required TResult Function(NewMessagesStateError value) error,
|
||||
}) {
|
||||
return loaded(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? mapOrNull<TResult extends Object?>(
|
||||
TResult? Function(_NewMessagesState value)? $default, {
|
||||
TResult? Function(NewMessagesStateEmpty value)? empty,
|
||||
TResult? Function(NewMessagesStateLoaded value)? loaded,
|
||||
TResult? Function(NewMessagesStateError value)? error,
|
||||
}) {
|
||||
return loaded?.call(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeMap<TResult extends Object?>(
|
||||
TResult Function(_NewMessagesState value)? $default, {
|
||||
TResult Function(NewMessagesStateEmpty value)? empty,
|
||||
TResult Function(NewMessagesStateLoaded value)? loaded,
|
||||
TResult Function(NewMessagesStateError value)? error,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (loaded != null) {
|
||||
return loaded(this);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
}
|
||||
|
||||
abstract class NewMessagesStateLoaded implements NewMessagesState {
|
||||
const factory NewMessagesStateLoaded({required final int messagesCount}) =
|
||||
_$NewMessagesStateLoadedImpl;
|
||||
|
||||
int get messagesCount;
|
||||
@JsonKey(ignore: true)
|
||||
_$$NewMessagesStateLoadedImplCopyWith<_$NewMessagesStateLoadedImpl>
|
||||
get copyWith => throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$NewMessagesStateErrorImplCopyWith<$Res> {
|
||||
factory _$$NewMessagesStateErrorImplCopyWith(
|
||||
_$NewMessagesStateErrorImpl value,
|
||||
$Res Function(_$NewMessagesStateErrorImpl) then) =
|
||||
__$$NewMessagesStateErrorImplCopyWithImpl<$Res>;
|
||||
@useResult
|
||||
$Res call({String errorMessage});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$NewMessagesStateErrorImplCopyWithImpl<$Res>
|
||||
extends _$NewMessagesStateCopyWithImpl<$Res, _$NewMessagesStateErrorImpl>
|
||||
implements _$$NewMessagesStateErrorImplCopyWith<$Res> {
|
||||
__$$NewMessagesStateErrorImplCopyWithImpl(_$NewMessagesStateErrorImpl _value,
|
||||
$Res Function(_$NewMessagesStateErrorImpl) _then)
|
||||
: super(_value, _then);
|
||||
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? errorMessage = null,
|
||||
}) {
|
||||
return _then(_$NewMessagesStateErrorImpl(
|
||||
errorMessage: null == errorMessage
|
||||
? _value.errorMessage
|
||||
: errorMessage // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
class _$NewMessagesStateErrorImpl implements NewMessagesStateError {
|
||||
const _$NewMessagesStateErrorImpl({required this.errorMessage});
|
||||
|
||||
@override
|
||||
final String errorMessage;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'NewMessagesState.error(errorMessage: $errorMessage)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$NewMessagesStateErrorImpl &&
|
||||
(identical(other.errorMessage, errorMessage) ||
|
||||
other.errorMessage == errorMessage));
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType, errorMessage);
|
||||
|
||||
@JsonKey(ignore: true)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$NewMessagesStateErrorImplCopyWith<_$NewMessagesStateErrorImpl>
|
||||
get copyWith => __$$NewMessagesStateErrorImplCopyWithImpl<
|
||||
_$NewMessagesStateErrorImpl>(this, _$identity);
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult when<TResult extends Object?>(
|
||||
TResult Function() $default, {
|
||||
required TResult Function() empty,
|
||||
required TResult Function(int messagesCount) loaded,
|
||||
required TResult Function(String errorMessage) error,
|
||||
}) {
|
||||
return error(errorMessage);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? whenOrNull<TResult extends Object?>(
|
||||
TResult? Function()? $default, {
|
||||
TResult? Function()? empty,
|
||||
TResult? Function(int messagesCount)? loaded,
|
||||
TResult? Function(String errorMessage)? error,
|
||||
}) {
|
||||
return error?.call(errorMessage);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeWhen<TResult extends Object?>(
|
||||
TResult Function()? $default, {
|
||||
TResult Function()? empty,
|
||||
TResult Function(int messagesCount)? loaded,
|
||||
TResult Function(String errorMessage)? error,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (error != null) {
|
||||
return error(errorMessage);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult map<TResult extends Object?>(
|
||||
TResult Function(_NewMessagesState value) $default, {
|
||||
required TResult Function(NewMessagesStateEmpty value) empty,
|
||||
required TResult Function(NewMessagesStateLoaded value) loaded,
|
||||
required TResult Function(NewMessagesStateError value) error,
|
||||
}) {
|
||||
return error(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? mapOrNull<TResult extends Object?>(
|
||||
TResult? Function(_NewMessagesState value)? $default, {
|
||||
TResult? Function(NewMessagesStateEmpty value)? empty,
|
||||
TResult? Function(NewMessagesStateLoaded value)? loaded,
|
||||
TResult? Function(NewMessagesStateError value)? error,
|
||||
}) {
|
||||
return error?.call(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeMap<TResult extends Object?>(
|
||||
TResult Function(_NewMessagesState value)? $default, {
|
||||
TResult Function(NewMessagesStateEmpty value)? empty,
|
||||
TResult Function(NewMessagesStateLoaded value)? loaded,
|
||||
TResult Function(NewMessagesStateError value)? error,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (error != null) {
|
||||
return error(this);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
}
|
||||
|
||||
abstract class NewMessagesStateError implements NewMessagesState {
|
||||
const factory NewMessagesStateError({required final String errorMessage}) =
|
||||
_$NewMessagesStateErrorImpl;
|
||||
|
||||
String get errorMessage;
|
||||
@JsonKey(ignore: true)
|
||||
_$$NewMessagesStateErrorImplCopyWith<_$NewMessagesStateErrorImpl>
|
||||
get copyWith => throw _privateConstructorUsedError;
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
import 'package:eatvio_app/core/app_export.dart';
|
||||
import 'package:eatvio_app/features/bottom_navigation_bar/presentation/bloc/notifications_cubit/notifications_state.dart';
|
||||
|
||||
class NotificationsCubit extends Cubit<NotificationsState> {
|
||||
int _notificationsCount = 0;
|
||||
|
||||
NotificationsCubit() : super(const NotificationsState.empty());
|
||||
|
||||
incrementCounter() {
|
||||
_notificationsCount++;
|
||||
emit(NotificationsState.loaded(notificationsCount: _notificationsCount));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
||||
part 'notifications_state.freezed.dart';
|
||||
|
||||
@freezed
|
||||
abstract class NotificationsState with _$NotificationsState {
|
||||
const factory NotificationsState() = _NotificationsState;
|
||||
|
||||
const factory NotificationsState.empty() = NotificationsStateEmpty;
|
||||
|
||||
const factory NotificationsState.loaded({
|
||||
required int notificationsCount,
|
||||
}) = NotificationsStateLoaded;
|
||||
|
||||
const factory NotificationsState.error({
|
||||
required String errorMessage,
|
||||
}) = NotificationsStateError;
|
||||
}
|
||||
@@ -0,0 +1,621 @@
|
||||
// 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 'notifications_state.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// FreezedGenerator
|
||||
// **************************************************************************
|
||||
|
||||
T _$identity<T>(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 _$NotificationsState {
|
||||
@optionalTypeArgs
|
||||
TResult when<TResult extends Object?>(
|
||||
TResult Function() $default, {
|
||||
required TResult Function() empty,
|
||||
required TResult Function(int notificationsCount) loaded,
|
||||
required TResult Function(String errorMessage) error,
|
||||
}) =>
|
||||
throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult? whenOrNull<TResult extends Object?>(
|
||||
TResult? Function()? $default, {
|
||||
TResult? Function()? empty,
|
||||
TResult? Function(int notificationsCount)? loaded,
|
||||
TResult? Function(String errorMessage)? error,
|
||||
}) =>
|
||||
throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult maybeWhen<TResult extends Object?>(
|
||||
TResult Function()? $default, {
|
||||
TResult Function()? empty,
|
||||
TResult Function(int notificationsCount)? loaded,
|
||||
TResult Function(String errorMessage)? error,
|
||||
required TResult orElse(),
|
||||
}) =>
|
||||
throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult map<TResult extends Object?>(
|
||||
TResult Function(_NotificationsState value) $default, {
|
||||
required TResult Function(NotificationsStateEmpty value) empty,
|
||||
required TResult Function(NotificationsStateLoaded value) loaded,
|
||||
required TResult Function(NotificationsStateError value) error,
|
||||
}) =>
|
||||
throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult? mapOrNull<TResult extends Object?>(
|
||||
TResult? Function(_NotificationsState value)? $default, {
|
||||
TResult? Function(NotificationsStateEmpty value)? empty,
|
||||
TResult? Function(NotificationsStateLoaded value)? loaded,
|
||||
TResult? Function(NotificationsStateError value)? error,
|
||||
}) =>
|
||||
throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult maybeMap<TResult extends Object?>(
|
||||
TResult Function(_NotificationsState value)? $default, {
|
||||
TResult Function(NotificationsStateEmpty value)? empty,
|
||||
TResult Function(NotificationsStateLoaded value)? loaded,
|
||||
TResult Function(NotificationsStateError value)? error,
|
||||
required TResult orElse(),
|
||||
}) =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class $NotificationsStateCopyWith<$Res> {
|
||||
factory $NotificationsStateCopyWith(
|
||||
NotificationsState value, $Res Function(NotificationsState) then) =
|
||||
_$NotificationsStateCopyWithImpl<$Res, NotificationsState>;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class _$NotificationsStateCopyWithImpl<$Res, $Val extends NotificationsState>
|
||||
implements $NotificationsStateCopyWith<$Res> {
|
||||
_$NotificationsStateCopyWithImpl(this._value, this._then);
|
||||
|
||||
// ignore: unused_field
|
||||
final $Val _value;
|
||||
// ignore: unused_field
|
||||
final $Res Function($Val) _then;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$NotificationsStateImplCopyWith<$Res> {
|
||||
factory _$$NotificationsStateImplCopyWith(_$NotificationsStateImpl value,
|
||||
$Res Function(_$NotificationsStateImpl) then) =
|
||||
__$$NotificationsStateImplCopyWithImpl<$Res>;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$NotificationsStateImplCopyWithImpl<$Res>
|
||||
extends _$NotificationsStateCopyWithImpl<$Res, _$NotificationsStateImpl>
|
||||
implements _$$NotificationsStateImplCopyWith<$Res> {
|
||||
__$$NotificationsStateImplCopyWithImpl(_$NotificationsStateImpl _value,
|
||||
$Res Function(_$NotificationsStateImpl) _then)
|
||||
: super(_value, _then);
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
class _$NotificationsStateImpl implements _NotificationsState {
|
||||
const _$NotificationsStateImpl();
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'NotificationsState()';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType && other is _$NotificationsStateImpl);
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => runtimeType.hashCode;
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult when<TResult extends Object?>(
|
||||
TResult Function() $default, {
|
||||
required TResult Function() empty,
|
||||
required TResult Function(int notificationsCount) loaded,
|
||||
required TResult Function(String errorMessage) error,
|
||||
}) {
|
||||
return $default();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? whenOrNull<TResult extends Object?>(
|
||||
TResult? Function()? $default, {
|
||||
TResult? Function()? empty,
|
||||
TResult? Function(int notificationsCount)? loaded,
|
||||
TResult? Function(String errorMessage)? error,
|
||||
}) {
|
||||
return $default?.call();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeWhen<TResult extends Object?>(
|
||||
TResult Function()? $default, {
|
||||
TResult Function()? empty,
|
||||
TResult Function(int notificationsCount)? loaded,
|
||||
TResult Function(String errorMessage)? error,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if ($default != null) {
|
||||
return $default();
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult map<TResult extends Object?>(
|
||||
TResult Function(_NotificationsState value) $default, {
|
||||
required TResult Function(NotificationsStateEmpty value) empty,
|
||||
required TResult Function(NotificationsStateLoaded value) loaded,
|
||||
required TResult Function(NotificationsStateError value) error,
|
||||
}) {
|
||||
return $default(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? mapOrNull<TResult extends Object?>(
|
||||
TResult? Function(_NotificationsState value)? $default, {
|
||||
TResult? Function(NotificationsStateEmpty value)? empty,
|
||||
TResult? Function(NotificationsStateLoaded value)? loaded,
|
||||
TResult? Function(NotificationsStateError value)? error,
|
||||
}) {
|
||||
return $default?.call(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeMap<TResult extends Object?>(
|
||||
TResult Function(_NotificationsState value)? $default, {
|
||||
TResult Function(NotificationsStateEmpty value)? empty,
|
||||
TResult Function(NotificationsStateLoaded value)? loaded,
|
||||
TResult Function(NotificationsStateError value)? error,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if ($default != null) {
|
||||
return $default(this);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
}
|
||||
|
||||
abstract class _NotificationsState implements NotificationsState {
|
||||
const factory _NotificationsState() = _$NotificationsStateImpl;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$NotificationsStateEmptyImplCopyWith<$Res> {
|
||||
factory _$$NotificationsStateEmptyImplCopyWith(
|
||||
_$NotificationsStateEmptyImpl value,
|
||||
$Res Function(_$NotificationsStateEmptyImpl) then) =
|
||||
__$$NotificationsStateEmptyImplCopyWithImpl<$Res>;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$NotificationsStateEmptyImplCopyWithImpl<$Res>
|
||||
extends _$NotificationsStateCopyWithImpl<$Res,
|
||||
_$NotificationsStateEmptyImpl>
|
||||
implements _$$NotificationsStateEmptyImplCopyWith<$Res> {
|
||||
__$$NotificationsStateEmptyImplCopyWithImpl(
|
||||
_$NotificationsStateEmptyImpl _value,
|
||||
$Res Function(_$NotificationsStateEmptyImpl) _then)
|
||||
: super(_value, _then);
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
class _$NotificationsStateEmptyImpl implements NotificationsStateEmpty {
|
||||
const _$NotificationsStateEmptyImpl();
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'NotificationsState.empty()';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$NotificationsStateEmptyImpl);
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => runtimeType.hashCode;
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult when<TResult extends Object?>(
|
||||
TResult Function() $default, {
|
||||
required TResult Function() empty,
|
||||
required TResult Function(int notificationsCount) loaded,
|
||||
required TResult Function(String errorMessage) error,
|
||||
}) {
|
||||
return empty();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? whenOrNull<TResult extends Object?>(
|
||||
TResult? Function()? $default, {
|
||||
TResult? Function()? empty,
|
||||
TResult? Function(int notificationsCount)? loaded,
|
||||
TResult? Function(String errorMessage)? error,
|
||||
}) {
|
||||
return empty?.call();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeWhen<TResult extends Object?>(
|
||||
TResult Function()? $default, {
|
||||
TResult Function()? empty,
|
||||
TResult Function(int notificationsCount)? loaded,
|
||||
TResult Function(String errorMessage)? error,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (empty != null) {
|
||||
return empty();
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult map<TResult extends Object?>(
|
||||
TResult Function(_NotificationsState value) $default, {
|
||||
required TResult Function(NotificationsStateEmpty value) empty,
|
||||
required TResult Function(NotificationsStateLoaded value) loaded,
|
||||
required TResult Function(NotificationsStateError value) error,
|
||||
}) {
|
||||
return empty(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? mapOrNull<TResult extends Object?>(
|
||||
TResult? Function(_NotificationsState value)? $default, {
|
||||
TResult? Function(NotificationsStateEmpty value)? empty,
|
||||
TResult? Function(NotificationsStateLoaded value)? loaded,
|
||||
TResult? Function(NotificationsStateError value)? error,
|
||||
}) {
|
||||
return empty?.call(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeMap<TResult extends Object?>(
|
||||
TResult Function(_NotificationsState value)? $default, {
|
||||
TResult Function(NotificationsStateEmpty value)? empty,
|
||||
TResult Function(NotificationsStateLoaded value)? loaded,
|
||||
TResult Function(NotificationsStateError value)? error,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (empty != null) {
|
||||
return empty(this);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
}
|
||||
|
||||
abstract class NotificationsStateEmpty implements NotificationsState {
|
||||
const factory NotificationsStateEmpty() = _$NotificationsStateEmptyImpl;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$NotificationsStateLoadedImplCopyWith<$Res> {
|
||||
factory _$$NotificationsStateLoadedImplCopyWith(
|
||||
_$NotificationsStateLoadedImpl value,
|
||||
$Res Function(_$NotificationsStateLoadedImpl) then) =
|
||||
__$$NotificationsStateLoadedImplCopyWithImpl<$Res>;
|
||||
@useResult
|
||||
$Res call({int notificationsCount});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$NotificationsStateLoadedImplCopyWithImpl<$Res>
|
||||
extends _$NotificationsStateCopyWithImpl<$Res,
|
||||
_$NotificationsStateLoadedImpl>
|
||||
implements _$$NotificationsStateLoadedImplCopyWith<$Res> {
|
||||
__$$NotificationsStateLoadedImplCopyWithImpl(
|
||||
_$NotificationsStateLoadedImpl _value,
|
||||
$Res Function(_$NotificationsStateLoadedImpl) _then)
|
||||
: super(_value, _then);
|
||||
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? notificationsCount = null,
|
||||
}) {
|
||||
return _then(_$NotificationsStateLoadedImpl(
|
||||
notificationsCount: null == notificationsCount
|
||||
? _value.notificationsCount
|
||||
: notificationsCount // ignore: cast_nullable_to_non_nullable
|
||||
as int,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
class _$NotificationsStateLoadedImpl implements NotificationsStateLoaded {
|
||||
const _$NotificationsStateLoadedImpl({required this.notificationsCount});
|
||||
|
||||
@override
|
||||
final int notificationsCount;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'NotificationsState.loaded(notificationsCount: $notificationsCount)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$NotificationsStateLoadedImpl &&
|
||||
(identical(other.notificationsCount, notificationsCount) ||
|
||||
other.notificationsCount == notificationsCount));
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType, notificationsCount);
|
||||
|
||||
@JsonKey(ignore: true)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$NotificationsStateLoadedImplCopyWith<_$NotificationsStateLoadedImpl>
|
||||
get copyWith => __$$NotificationsStateLoadedImplCopyWithImpl<
|
||||
_$NotificationsStateLoadedImpl>(this, _$identity);
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult when<TResult extends Object?>(
|
||||
TResult Function() $default, {
|
||||
required TResult Function() empty,
|
||||
required TResult Function(int notificationsCount) loaded,
|
||||
required TResult Function(String errorMessage) error,
|
||||
}) {
|
||||
return loaded(notificationsCount);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? whenOrNull<TResult extends Object?>(
|
||||
TResult? Function()? $default, {
|
||||
TResult? Function()? empty,
|
||||
TResult? Function(int notificationsCount)? loaded,
|
||||
TResult? Function(String errorMessage)? error,
|
||||
}) {
|
||||
return loaded?.call(notificationsCount);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeWhen<TResult extends Object?>(
|
||||
TResult Function()? $default, {
|
||||
TResult Function()? empty,
|
||||
TResult Function(int notificationsCount)? loaded,
|
||||
TResult Function(String errorMessage)? error,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (loaded != null) {
|
||||
return loaded(notificationsCount);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult map<TResult extends Object?>(
|
||||
TResult Function(_NotificationsState value) $default, {
|
||||
required TResult Function(NotificationsStateEmpty value) empty,
|
||||
required TResult Function(NotificationsStateLoaded value) loaded,
|
||||
required TResult Function(NotificationsStateError value) error,
|
||||
}) {
|
||||
return loaded(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? mapOrNull<TResult extends Object?>(
|
||||
TResult? Function(_NotificationsState value)? $default, {
|
||||
TResult? Function(NotificationsStateEmpty value)? empty,
|
||||
TResult? Function(NotificationsStateLoaded value)? loaded,
|
||||
TResult? Function(NotificationsStateError value)? error,
|
||||
}) {
|
||||
return loaded?.call(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeMap<TResult extends Object?>(
|
||||
TResult Function(_NotificationsState value)? $default, {
|
||||
TResult Function(NotificationsStateEmpty value)? empty,
|
||||
TResult Function(NotificationsStateLoaded value)? loaded,
|
||||
TResult Function(NotificationsStateError value)? error,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (loaded != null) {
|
||||
return loaded(this);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
}
|
||||
|
||||
abstract class NotificationsStateLoaded implements NotificationsState {
|
||||
const factory NotificationsStateLoaded(
|
||||
{required final int notificationsCount}) = _$NotificationsStateLoadedImpl;
|
||||
|
||||
int get notificationsCount;
|
||||
@JsonKey(ignore: true)
|
||||
_$$NotificationsStateLoadedImplCopyWith<_$NotificationsStateLoadedImpl>
|
||||
get copyWith => throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$NotificationsStateErrorImplCopyWith<$Res> {
|
||||
factory _$$NotificationsStateErrorImplCopyWith(
|
||||
_$NotificationsStateErrorImpl value,
|
||||
$Res Function(_$NotificationsStateErrorImpl) then) =
|
||||
__$$NotificationsStateErrorImplCopyWithImpl<$Res>;
|
||||
@useResult
|
||||
$Res call({String errorMessage});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$NotificationsStateErrorImplCopyWithImpl<$Res>
|
||||
extends _$NotificationsStateCopyWithImpl<$Res,
|
||||
_$NotificationsStateErrorImpl>
|
||||
implements _$$NotificationsStateErrorImplCopyWith<$Res> {
|
||||
__$$NotificationsStateErrorImplCopyWithImpl(
|
||||
_$NotificationsStateErrorImpl _value,
|
||||
$Res Function(_$NotificationsStateErrorImpl) _then)
|
||||
: super(_value, _then);
|
||||
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? errorMessage = null,
|
||||
}) {
|
||||
return _then(_$NotificationsStateErrorImpl(
|
||||
errorMessage: null == errorMessage
|
||||
? _value.errorMessage
|
||||
: errorMessage // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
class _$NotificationsStateErrorImpl implements NotificationsStateError {
|
||||
const _$NotificationsStateErrorImpl({required this.errorMessage});
|
||||
|
||||
@override
|
||||
final String errorMessage;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'NotificationsState.error(errorMessage: $errorMessage)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$NotificationsStateErrorImpl &&
|
||||
(identical(other.errorMessage, errorMessage) ||
|
||||
other.errorMessage == errorMessage));
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType, errorMessage);
|
||||
|
||||
@JsonKey(ignore: true)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$NotificationsStateErrorImplCopyWith<_$NotificationsStateErrorImpl>
|
||||
get copyWith => __$$NotificationsStateErrorImplCopyWithImpl<
|
||||
_$NotificationsStateErrorImpl>(this, _$identity);
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult when<TResult extends Object?>(
|
||||
TResult Function() $default, {
|
||||
required TResult Function() empty,
|
||||
required TResult Function(int notificationsCount) loaded,
|
||||
required TResult Function(String errorMessage) error,
|
||||
}) {
|
||||
return error(errorMessage);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? whenOrNull<TResult extends Object?>(
|
||||
TResult? Function()? $default, {
|
||||
TResult? Function()? empty,
|
||||
TResult? Function(int notificationsCount)? loaded,
|
||||
TResult? Function(String errorMessage)? error,
|
||||
}) {
|
||||
return error?.call(errorMessage);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeWhen<TResult extends Object?>(
|
||||
TResult Function()? $default, {
|
||||
TResult Function()? empty,
|
||||
TResult Function(int notificationsCount)? loaded,
|
||||
TResult Function(String errorMessage)? error,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (error != null) {
|
||||
return error(errorMessage);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult map<TResult extends Object?>(
|
||||
TResult Function(_NotificationsState value) $default, {
|
||||
required TResult Function(NotificationsStateEmpty value) empty,
|
||||
required TResult Function(NotificationsStateLoaded value) loaded,
|
||||
required TResult Function(NotificationsStateError value) error,
|
||||
}) {
|
||||
return error(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? mapOrNull<TResult extends Object?>(
|
||||
TResult? Function(_NotificationsState value)? $default, {
|
||||
TResult? Function(NotificationsStateEmpty value)? empty,
|
||||
TResult? Function(NotificationsStateLoaded value)? loaded,
|
||||
TResult? Function(NotificationsStateError value)? error,
|
||||
}) {
|
||||
return error?.call(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeMap<TResult extends Object?>(
|
||||
TResult Function(_NotificationsState value)? $default, {
|
||||
TResult Function(NotificationsStateEmpty value)? empty,
|
||||
TResult Function(NotificationsStateLoaded value)? loaded,
|
||||
TResult Function(NotificationsStateError value)? error,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (error != null) {
|
||||
return error(this);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
}
|
||||
|
||||
abstract class NotificationsStateError implements NotificationsState {
|
||||
const factory NotificationsStateError({required final String errorMessage}) =
|
||||
_$NotificationsStateErrorImpl;
|
||||
|
||||
String get errorMessage;
|
||||
@JsonKey(ignore: true)
|
||||
_$$NotificationsStateErrorImplCopyWith<_$NotificationsStateErrorImpl>
|
||||
get copyWith => throw _privateConstructorUsedError;
|
||||
}
|
||||
@@ -1,6 +1,11 @@
|
||||
import 'package:badges/badges.dart' as badges;
|
||||
import 'package:eatvio_app/core/app_export.dart';
|
||||
import 'package:flutter/material.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/widgets/custom_navigation_menu.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_svg/flutter_svg.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
|
||||
@@ -113,36 +118,56 @@ class _BottomNavigationBarWidgetState extends State<BottomNavigationBarWidget> {
|
||||
),
|
||||
BottomNavigationBarItem(
|
||||
label: "chat".tr,
|
||||
icon: SvgPicture.asset(
|
||||
ImageConstant.imgChat,
|
||||
width: 24,
|
||||
height: 24,
|
||||
),
|
||||
activeIcon: SvgPicture.asset(
|
||||
ImageConstant.imgChat,
|
||||
width: 24,
|
||||
height: 24,
|
||||
colorFilter: ColorFilter.mode(
|
||||
appTheme.blueA400,
|
||||
BlendMode.srcIn,
|
||||
),
|
||||
icon: BlocBuilder<NewMessagesCubit, NewMessagesState>(
|
||||
builder: (BuildContext context, NewMessagesState state) {
|
||||
return badges.Badge(
|
||||
position: badges.BadgePosition.topEnd(),
|
||||
badgeContent: Text(
|
||||
(state is NewMessagesStateLoaded) ? state.messagesCount.toString() : '0',
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
child: SvgPicture.asset(
|
||||
ImageConstant.imgChat,
|
||||
width: 24,
|
||||
height: 24,
|
||||
colorFilter: currentBottomNavBarIndex == 3
|
||||
? ColorFilter.mode(
|
||||
appTheme.blueA400,
|
||||
BlendMode.srcIn,
|
||||
)
|
||||
: null,
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
BottomNavigationBarItem(
|
||||
label: '',
|
||||
icon: SvgPicture.asset(
|
||||
ImageConstant.imgBell,
|
||||
width: 24,
|
||||
height: 24,
|
||||
),
|
||||
activeIcon: SvgPicture.asset(
|
||||
ImageConstant.imgBell,
|
||||
width: 24,
|
||||
height: 24,
|
||||
colorFilter: ColorFilter.mode(
|
||||
appTheme.blueA400,
|
||||
BlendMode.srcIn,
|
||||
),
|
||||
icon: BlocBuilder<NotificationsCubit, NotificationsState>(
|
||||
builder: (BuildContext context, NotificationsState state) {
|
||||
return badges.Badge(
|
||||
position: badges.BadgePosition.topEnd(),
|
||||
badgeContent: Text(
|
||||
(state is NotificationsStateLoaded) ? state.notificationsCount.toString() : '0',
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
child: SvgPicture.asset(
|
||||
ImageConstant.imgBell,
|
||||
colorFilter: currentBottomNavBarIndex == 4
|
||||
? ColorFilter.mode(
|
||||
appTheme.blueA400,
|
||||
BlendMode.srcIn,
|
||||
)
|
||||
: null,
|
||||
width: 24,
|
||||
height: 24,
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
BottomNavigationBarItem(
|
||||
22
lib/features/calendar/models/calendar_entry_model.dart
Normal file
22
lib/features/calendar/models/calendar_entry_model.dart
Normal file
@@ -0,0 +1,22 @@
|
||||
/// This class is used in the [userprofile_item_widget] screen.
|
||||
// ignore_for_file: must_be_immutable
|
||||
|
||||
class CalendarEntryModel {
|
||||
String? date;
|
||||
String? status;
|
||||
String id;
|
||||
bool is_current_day_included_in_the_chosen_diet_progression;
|
||||
|
||||
CalendarEntryModel({
|
||||
this.date,
|
||||
this.status,
|
||||
required this.id,
|
||||
required this.is_current_day_included_in_the_chosen_diet_progression,
|
||||
}) {
|
||||
date = date;
|
||||
status = status;
|
||||
id = id;
|
||||
is_current_day_included_in_the_chosen_diet_progression =
|
||||
is_current_day_included_in_the_chosen_diet_progression;
|
||||
}
|
||||
}
|
||||
16
lib/features/calendar/models/calendar_model.dart
Normal file
16
lib/features/calendar/models/calendar_model.dart
Normal file
@@ -0,0 +1,16 @@
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
||||
part 'calendar_model.freezed.dart';
|
||||
part 'calendar_model.g.dart';
|
||||
|
||||
@freezed
|
||||
class CalendarModel with _$CalendarModel {
|
||||
const factory CalendarModel({
|
||||
required String date,
|
||||
required bool is_current_day_included_in_the_chosen_diet_progression,
|
||||
Object? diary,
|
||||
}) = _CalendarModel;
|
||||
|
||||
factory CalendarModel.fromJson(Map<String, Object?> json) =>
|
||||
_$CalendarModelFromJson(json);
|
||||
}
|
||||
202
lib/features/calendar/models/calendar_model.freezed.dart
Normal file
202
lib/features/calendar/models/calendar_model.freezed.dart
Normal file
@@ -0,0 +1,202 @@
|
||||
// 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 'calendar_model.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// FreezedGenerator
|
||||
// **************************************************************************
|
||||
|
||||
T _$identity<T>(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');
|
||||
|
||||
CalendarModel _$CalendarModelFromJson(Map<String, dynamic> json) {
|
||||
return _CalendarModel.fromJson(json);
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
mixin _$CalendarModel {
|
||||
String get date => throw _privateConstructorUsedError;
|
||||
bool get is_current_day_included_in_the_chosen_diet_progression =>
|
||||
throw _privateConstructorUsedError;
|
||||
Object? get diary => throw _privateConstructorUsedError;
|
||||
|
||||
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
|
||||
@JsonKey(ignore: true)
|
||||
$CalendarModelCopyWith<CalendarModel> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class $CalendarModelCopyWith<$Res> {
|
||||
factory $CalendarModelCopyWith(
|
||||
CalendarModel value, $Res Function(CalendarModel) then) =
|
||||
_$CalendarModelCopyWithImpl<$Res, CalendarModel>;
|
||||
@useResult
|
||||
$Res call(
|
||||
{String date,
|
||||
bool is_current_day_included_in_the_chosen_diet_progression,
|
||||
Object? diary});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class _$CalendarModelCopyWithImpl<$Res, $Val extends CalendarModel>
|
||||
implements $CalendarModelCopyWith<$Res> {
|
||||
_$CalendarModelCopyWithImpl(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? date = null,
|
||||
Object? is_current_day_included_in_the_chosen_diet_progression = null,
|
||||
Object? diary = freezed,
|
||||
}) {
|
||||
return _then(_value.copyWith(
|
||||
date: null == date
|
||||
? _value.date
|
||||
: date // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
is_current_day_included_in_the_chosen_diet_progression: null ==
|
||||
is_current_day_included_in_the_chosen_diet_progression
|
||||
? _value.is_current_day_included_in_the_chosen_diet_progression
|
||||
: is_current_day_included_in_the_chosen_diet_progression // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
diary: freezed == diary ? _value.diary : diary,
|
||||
) as $Val);
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$CalendarModelImplCopyWith<$Res>
|
||||
implements $CalendarModelCopyWith<$Res> {
|
||||
factory _$$CalendarModelImplCopyWith(
|
||||
_$CalendarModelImpl value, $Res Function(_$CalendarModelImpl) then) =
|
||||
__$$CalendarModelImplCopyWithImpl<$Res>;
|
||||
@override
|
||||
@useResult
|
||||
$Res call(
|
||||
{String date,
|
||||
bool is_current_day_included_in_the_chosen_diet_progression,
|
||||
Object? diary});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$CalendarModelImplCopyWithImpl<$Res>
|
||||
extends _$CalendarModelCopyWithImpl<$Res, _$CalendarModelImpl>
|
||||
implements _$$CalendarModelImplCopyWith<$Res> {
|
||||
__$$CalendarModelImplCopyWithImpl(
|
||||
_$CalendarModelImpl _value, $Res Function(_$CalendarModelImpl) _then)
|
||||
: super(_value, _then);
|
||||
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? date = null,
|
||||
Object? is_current_day_included_in_the_chosen_diet_progression = null,
|
||||
Object? diary = freezed,
|
||||
}) {
|
||||
return _then(_$CalendarModelImpl(
|
||||
date: null == date
|
||||
? _value.date
|
||||
: date // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
is_current_day_included_in_the_chosen_diet_progression: null ==
|
||||
is_current_day_included_in_the_chosen_diet_progression
|
||||
? _value.is_current_day_included_in_the_chosen_diet_progression
|
||||
: is_current_day_included_in_the_chosen_diet_progression // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
diary: freezed == diary ? _value.diary : diary,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@JsonSerializable()
|
||||
class _$CalendarModelImpl implements _CalendarModel {
|
||||
const _$CalendarModelImpl(
|
||||
{required this.date,
|
||||
required this.is_current_day_included_in_the_chosen_diet_progression,
|
||||
this.diary});
|
||||
|
||||
factory _$CalendarModelImpl.fromJson(Map<String, dynamic> json) =>
|
||||
_$$CalendarModelImplFromJson(json);
|
||||
|
||||
@override
|
||||
final String date;
|
||||
@override
|
||||
final bool is_current_day_included_in_the_chosen_diet_progression;
|
||||
@override
|
||||
final Object? diary;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'CalendarModel(date: $date, is_current_day_included_in_the_chosen_diet_progression: $is_current_day_included_in_the_chosen_diet_progression, diary: $diary)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$CalendarModelImpl &&
|
||||
(identical(other.date, date) || other.date == date) &&
|
||||
(identical(
|
||||
other
|
||||
.is_current_day_included_in_the_chosen_diet_progression,
|
||||
is_current_day_included_in_the_chosen_diet_progression) ||
|
||||
other.is_current_day_included_in_the_chosen_diet_progression ==
|
||||
is_current_day_included_in_the_chosen_diet_progression) &&
|
||||
const DeepCollectionEquality().equals(other.diary, diary));
|
||||
}
|
||||
|
||||
@JsonKey(ignore: true)
|
||||
@override
|
||||
int get hashCode => Object.hash(
|
||||
runtimeType,
|
||||
date,
|
||||
is_current_day_included_in_the_chosen_diet_progression,
|
||||
const DeepCollectionEquality().hash(diary));
|
||||
|
||||
@JsonKey(ignore: true)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$CalendarModelImplCopyWith<_$CalendarModelImpl> get copyWith =>
|
||||
__$$CalendarModelImplCopyWithImpl<_$CalendarModelImpl>(this, _$identity);
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
return _$$CalendarModelImplToJson(
|
||||
this,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
abstract class _CalendarModel implements CalendarModel {
|
||||
const factory _CalendarModel(
|
||||
{required final String date,
|
||||
required final bool
|
||||
is_current_day_included_in_the_chosen_diet_progression,
|
||||
final Object? diary}) = _$CalendarModelImpl;
|
||||
|
||||
factory _CalendarModel.fromJson(Map<String, dynamic> json) =
|
||||
_$CalendarModelImpl.fromJson;
|
||||
|
||||
@override
|
||||
String get date;
|
||||
@override
|
||||
bool get is_current_day_included_in_the_chosen_diet_progression;
|
||||
@override
|
||||
Object? get diary;
|
||||
@override
|
||||
@JsonKey(ignore: true)
|
||||
_$$CalendarModelImplCopyWith<_$CalendarModelImpl> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
24
lib/features/calendar/models/calendar_model.g.dart
Normal file
24
lib/features/calendar/models/calendar_model.g.dart
Normal file
@@ -0,0 +1,24 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'calendar_model.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
_$CalendarModelImpl _$$CalendarModelImplFromJson(Map<String, dynamic> json) =>
|
||||
_$CalendarModelImpl(
|
||||
date: json['date'] as String,
|
||||
is_current_day_included_in_the_chosen_diet_progression:
|
||||
json['is_current_day_included_in_the_chosen_diet_progression']
|
||||
as bool,
|
||||
diary: json['diary'],
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$$CalendarModelImplToJson(_$CalendarModelImpl instance) =>
|
||||
<String, dynamic>{
|
||||
'date': instance.date,
|
||||
'is_current_day_included_in_the_chosen_diet_progression':
|
||||
instance.is_current_day_included_in_the_chosen_diet_progression,
|
||||
'diary': instance.diary,
|
||||
};
|
||||
20
lib/features/calendar/presentation/bloc/calendar_cubit.dart
Normal file
20
lib/features/calendar/presentation/bloc/calendar_cubit.dart
Normal file
@@ -0,0 +1,20 @@
|
||||
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';
|
||||
|
||||
class CalendarCubit extends Cubit<CalendarState> {
|
||||
final CalendarRepository calendarRepository;
|
||||
|
||||
CalendarCubit({required this.calendarRepository})
|
||||
: super(const CalendarState.loading());
|
||||
|
||||
loadCalendarList() async {
|
||||
emit(const CalendarState.loading());
|
||||
try {
|
||||
final calendarList = await calendarRepository.getCalendar();
|
||||
emit(CalendarState.loaded(calendarList: calendarList));
|
||||
} catch (e) {
|
||||
emit(CalendarState.error(errorMessage: e.toString()));
|
||||
}
|
||||
}
|
||||
}
|
||||
19
lib/features/calendar/presentation/bloc/calendar_state.dart
Normal file
19
lib/features/calendar/presentation/bloc/calendar_state.dart
Normal file
@@ -0,0 +1,19 @@
|
||||
import 'package:eatvio_app/features/calendar/models/calendar_model.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
||||
part 'calendar_state.freezed.dart';
|
||||
|
||||
@freezed
|
||||
abstract class CalendarState with _$CalendarState {
|
||||
const factory CalendarState() = _CalendarState;
|
||||
|
||||
const factory CalendarState.loading() = CalendarStateLoading;
|
||||
|
||||
const factory CalendarState.loaded({
|
||||
required List<CalendarModel> calendarList,
|
||||
}) = CalendarStateLoaded;
|
||||
|
||||
const factory CalendarState.error({
|
||||
required String errorMessage,
|
||||
}) = CalendarStateError;
|
||||
}
|
||||
@@ -0,0 +1,621 @@
|
||||
// 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 'calendar_state.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// FreezedGenerator
|
||||
// **************************************************************************
|
||||
|
||||
T _$identity<T>(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 _$CalendarState {
|
||||
@optionalTypeArgs
|
||||
TResult when<TResult extends Object?>(
|
||||
TResult Function() $default, {
|
||||
required TResult Function() loading,
|
||||
required TResult Function(List<CalendarModel> calendarList) loaded,
|
||||
required TResult Function(String errorMessage) error,
|
||||
}) =>
|
||||
throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult? whenOrNull<TResult extends Object?>(
|
||||
TResult? Function()? $default, {
|
||||
TResult? Function()? loading,
|
||||
TResult? Function(List<CalendarModel> calendarList)? loaded,
|
||||
TResult? Function(String errorMessage)? error,
|
||||
}) =>
|
||||
throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult maybeWhen<TResult extends Object?>(
|
||||
TResult Function()? $default, {
|
||||
TResult Function()? loading,
|
||||
TResult Function(List<CalendarModel> calendarList)? loaded,
|
||||
TResult Function(String errorMessage)? error,
|
||||
required TResult orElse(),
|
||||
}) =>
|
||||
throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult map<TResult extends Object?>(
|
||||
TResult Function(_CalendarState value) $default, {
|
||||
required TResult Function(CalendarStateLoading value) loading,
|
||||
required TResult Function(CalendarStateLoaded value) loaded,
|
||||
required TResult Function(CalendarStateError value) error,
|
||||
}) =>
|
||||
throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult? mapOrNull<TResult extends Object?>(
|
||||
TResult? Function(_CalendarState value)? $default, {
|
||||
TResult? Function(CalendarStateLoading value)? loading,
|
||||
TResult? Function(CalendarStateLoaded value)? loaded,
|
||||
TResult? Function(CalendarStateError value)? error,
|
||||
}) =>
|
||||
throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult maybeMap<TResult extends Object?>(
|
||||
TResult Function(_CalendarState value)? $default, {
|
||||
TResult Function(CalendarStateLoading value)? loading,
|
||||
TResult Function(CalendarStateLoaded value)? loaded,
|
||||
TResult Function(CalendarStateError value)? error,
|
||||
required TResult orElse(),
|
||||
}) =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class $CalendarStateCopyWith<$Res> {
|
||||
factory $CalendarStateCopyWith(
|
||||
CalendarState value, $Res Function(CalendarState) then) =
|
||||
_$CalendarStateCopyWithImpl<$Res, CalendarState>;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class _$CalendarStateCopyWithImpl<$Res, $Val extends CalendarState>
|
||||
implements $CalendarStateCopyWith<$Res> {
|
||||
_$CalendarStateCopyWithImpl(this._value, this._then);
|
||||
|
||||
// ignore: unused_field
|
||||
final $Val _value;
|
||||
// ignore: unused_field
|
||||
final $Res Function($Val) _then;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$CalendarStateImplCopyWith<$Res> {
|
||||
factory _$$CalendarStateImplCopyWith(
|
||||
_$CalendarStateImpl value, $Res Function(_$CalendarStateImpl) then) =
|
||||
__$$CalendarStateImplCopyWithImpl<$Res>;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$CalendarStateImplCopyWithImpl<$Res>
|
||||
extends _$CalendarStateCopyWithImpl<$Res, _$CalendarStateImpl>
|
||||
implements _$$CalendarStateImplCopyWith<$Res> {
|
||||
__$$CalendarStateImplCopyWithImpl(
|
||||
_$CalendarStateImpl _value, $Res Function(_$CalendarStateImpl) _then)
|
||||
: super(_value, _then);
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
class _$CalendarStateImpl implements _CalendarState {
|
||||
const _$CalendarStateImpl();
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'CalendarState()';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType && other is _$CalendarStateImpl);
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => runtimeType.hashCode;
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult when<TResult extends Object?>(
|
||||
TResult Function() $default, {
|
||||
required TResult Function() loading,
|
||||
required TResult Function(List<CalendarModel> calendarList) loaded,
|
||||
required TResult Function(String errorMessage) error,
|
||||
}) {
|
||||
return $default();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? whenOrNull<TResult extends Object?>(
|
||||
TResult? Function()? $default, {
|
||||
TResult? Function()? loading,
|
||||
TResult? Function(List<CalendarModel> calendarList)? loaded,
|
||||
TResult? Function(String errorMessage)? error,
|
||||
}) {
|
||||
return $default?.call();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeWhen<TResult extends Object?>(
|
||||
TResult Function()? $default, {
|
||||
TResult Function()? loading,
|
||||
TResult Function(List<CalendarModel> calendarList)? loaded,
|
||||
TResult Function(String errorMessage)? error,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if ($default != null) {
|
||||
return $default();
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult map<TResult extends Object?>(
|
||||
TResult Function(_CalendarState value) $default, {
|
||||
required TResult Function(CalendarStateLoading value) loading,
|
||||
required TResult Function(CalendarStateLoaded value) loaded,
|
||||
required TResult Function(CalendarStateError value) error,
|
||||
}) {
|
||||
return $default(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? mapOrNull<TResult extends Object?>(
|
||||
TResult? Function(_CalendarState value)? $default, {
|
||||
TResult? Function(CalendarStateLoading value)? loading,
|
||||
TResult? Function(CalendarStateLoaded value)? loaded,
|
||||
TResult? Function(CalendarStateError value)? error,
|
||||
}) {
|
||||
return $default?.call(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeMap<TResult extends Object?>(
|
||||
TResult Function(_CalendarState value)? $default, {
|
||||
TResult Function(CalendarStateLoading value)? loading,
|
||||
TResult Function(CalendarStateLoaded value)? loaded,
|
||||
TResult Function(CalendarStateError value)? error,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if ($default != null) {
|
||||
return $default(this);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
}
|
||||
|
||||
abstract class _CalendarState implements CalendarState {
|
||||
const factory _CalendarState() = _$CalendarStateImpl;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$CalendarStateLoadingImplCopyWith<$Res> {
|
||||
factory _$$CalendarStateLoadingImplCopyWith(_$CalendarStateLoadingImpl value,
|
||||
$Res Function(_$CalendarStateLoadingImpl) then) =
|
||||
__$$CalendarStateLoadingImplCopyWithImpl<$Res>;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$CalendarStateLoadingImplCopyWithImpl<$Res>
|
||||
extends _$CalendarStateCopyWithImpl<$Res, _$CalendarStateLoadingImpl>
|
||||
implements _$$CalendarStateLoadingImplCopyWith<$Res> {
|
||||
__$$CalendarStateLoadingImplCopyWithImpl(_$CalendarStateLoadingImpl _value,
|
||||
$Res Function(_$CalendarStateLoadingImpl) _then)
|
||||
: super(_value, _then);
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
class _$CalendarStateLoadingImpl implements CalendarStateLoading {
|
||||
const _$CalendarStateLoadingImpl();
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'CalendarState.loading()';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$CalendarStateLoadingImpl);
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => runtimeType.hashCode;
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult when<TResult extends Object?>(
|
||||
TResult Function() $default, {
|
||||
required TResult Function() loading,
|
||||
required TResult Function(List<CalendarModel> calendarList) loaded,
|
||||
required TResult Function(String errorMessage) error,
|
||||
}) {
|
||||
return loading();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? whenOrNull<TResult extends Object?>(
|
||||
TResult? Function()? $default, {
|
||||
TResult? Function()? loading,
|
||||
TResult? Function(List<CalendarModel> calendarList)? loaded,
|
||||
TResult? Function(String errorMessage)? error,
|
||||
}) {
|
||||
return loading?.call();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeWhen<TResult extends Object?>(
|
||||
TResult Function()? $default, {
|
||||
TResult Function()? loading,
|
||||
TResult Function(List<CalendarModel> calendarList)? loaded,
|
||||
TResult Function(String errorMessage)? error,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (loading != null) {
|
||||
return loading();
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult map<TResult extends Object?>(
|
||||
TResult Function(_CalendarState value) $default, {
|
||||
required TResult Function(CalendarStateLoading value) loading,
|
||||
required TResult Function(CalendarStateLoaded value) loaded,
|
||||
required TResult Function(CalendarStateError value) error,
|
||||
}) {
|
||||
return loading(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? mapOrNull<TResult extends Object?>(
|
||||
TResult? Function(_CalendarState value)? $default, {
|
||||
TResult? Function(CalendarStateLoading value)? loading,
|
||||
TResult? Function(CalendarStateLoaded value)? loaded,
|
||||
TResult? Function(CalendarStateError value)? error,
|
||||
}) {
|
||||
return loading?.call(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeMap<TResult extends Object?>(
|
||||
TResult Function(_CalendarState value)? $default, {
|
||||
TResult Function(CalendarStateLoading value)? loading,
|
||||
TResult Function(CalendarStateLoaded value)? loaded,
|
||||
TResult Function(CalendarStateError value)? error,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (loading != null) {
|
||||
return loading(this);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
}
|
||||
|
||||
abstract class CalendarStateLoading implements CalendarState {
|
||||
const factory CalendarStateLoading() = _$CalendarStateLoadingImpl;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$CalendarStateLoadedImplCopyWith<$Res> {
|
||||
factory _$$CalendarStateLoadedImplCopyWith(_$CalendarStateLoadedImpl value,
|
||||
$Res Function(_$CalendarStateLoadedImpl) then) =
|
||||
__$$CalendarStateLoadedImplCopyWithImpl<$Res>;
|
||||
@useResult
|
||||
$Res call({List<CalendarModel> calendarList});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$CalendarStateLoadedImplCopyWithImpl<$Res>
|
||||
extends _$CalendarStateCopyWithImpl<$Res, _$CalendarStateLoadedImpl>
|
||||
implements _$$CalendarStateLoadedImplCopyWith<$Res> {
|
||||
__$$CalendarStateLoadedImplCopyWithImpl(_$CalendarStateLoadedImpl _value,
|
||||
$Res Function(_$CalendarStateLoadedImpl) _then)
|
||||
: super(_value, _then);
|
||||
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? calendarList = null,
|
||||
}) {
|
||||
return _then(_$CalendarStateLoadedImpl(
|
||||
calendarList: null == calendarList
|
||||
? _value._calendarList
|
||||
: calendarList // ignore: cast_nullable_to_non_nullable
|
||||
as List<CalendarModel>,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
class _$CalendarStateLoadedImpl implements CalendarStateLoaded {
|
||||
const _$CalendarStateLoadedImpl(
|
||||
{required final List<CalendarModel> calendarList})
|
||||
: _calendarList = calendarList;
|
||||
|
||||
final List<CalendarModel> _calendarList;
|
||||
@override
|
||||
List<CalendarModel> get calendarList {
|
||||
if (_calendarList is EqualUnmodifiableListView) return _calendarList;
|
||||
// ignore: implicit_dynamic_type
|
||||
return EqualUnmodifiableListView(_calendarList);
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'CalendarState.loaded(calendarList: $calendarList)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$CalendarStateLoadedImpl &&
|
||||
const DeepCollectionEquality()
|
||||
.equals(other._calendarList, _calendarList));
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(
|
||||
runtimeType, const DeepCollectionEquality().hash(_calendarList));
|
||||
|
||||
@JsonKey(ignore: true)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$CalendarStateLoadedImplCopyWith<_$CalendarStateLoadedImpl> get copyWith =>
|
||||
__$$CalendarStateLoadedImplCopyWithImpl<_$CalendarStateLoadedImpl>(
|
||||
this, _$identity);
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult when<TResult extends Object?>(
|
||||
TResult Function() $default, {
|
||||
required TResult Function() loading,
|
||||
required TResult Function(List<CalendarModel> calendarList) loaded,
|
||||
required TResult Function(String errorMessage) error,
|
||||
}) {
|
||||
return loaded(calendarList);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? whenOrNull<TResult extends Object?>(
|
||||
TResult? Function()? $default, {
|
||||
TResult? Function()? loading,
|
||||
TResult? Function(List<CalendarModel> calendarList)? loaded,
|
||||
TResult? Function(String errorMessage)? error,
|
||||
}) {
|
||||
return loaded?.call(calendarList);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeWhen<TResult extends Object?>(
|
||||
TResult Function()? $default, {
|
||||
TResult Function()? loading,
|
||||
TResult Function(List<CalendarModel> calendarList)? loaded,
|
||||
TResult Function(String errorMessage)? error,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (loaded != null) {
|
||||
return loaded(calendarList);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult map<TResult extends Object?>(
|
||||
TResult Function(_CalendarState value) $default, {
|
||||
required TResult Function(CalendarStateLoading value) loading,
|
||||
required TResult Function(CalendarStateLoaded value) loaded,
|
||||
required TResult Function(CalendarStateError value) error,
|
||||
}) {
|
||||
return loaded(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? mapOrNull<TResult extends Object?>(
|
||||
TResult? Function(_CalendarState value)? $default, {
|
||||
TResult? Function(CalendarStateLoading value)? loading,
|
||||
TResult? Function(CalendarStateLoaded value)? loaded,
|
||||
TResult? Function(CalendarStateError value)? error,
|
||||
}) {
|
||||
return loaded?.call(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeMap<TResult extends Object?>(
|
||||
TResult Function(_CalendarState value)? $default, {
|
||||
TResult Function(CalendarStateLoading value)? loading,
|
||||
TResult Function(CalendarStateLoaded value)? loaded,
|
||||
TResult Function(CalendarStateError value)? error,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (loaded != null) {
|
||||
return loaded(this);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
}
|
||||
|
||||
abstract class CalendarStateLoaded implements CalendarState {
|
||||
const factory CalendarStateLoaded(
|
||||
{required final List<CalendarModel> calendarList}) =
|
||||
_$CalendarStateLoadedImpl;
|
||||
|
||||
List<CalendarModel> get calendarList;
|
||||
@JsonKey(ignore: true)
|
||||
_$$CalendarStateLoadedImplCopyWith<_$CalendarStateLoadedImpl> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$CalendarStateErrorImplCopyWith<$Res> {
|
||||
factory _$$CalendarStateErrorImplCopyWith(_$CalendarStateErrorImpl value,
|
||||
$Res Function(_$CalendarStateErrorImpl) then) =
|
||||
__$$CalendarStateErrorImplCopyWithImpl<$Res>;
|
||||
@useResult
|
||||
$Res call({String errorMessage});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$CalendarStateErrorImplCopyWithImpl<$Res>
|
||||
extends _$CalendarStateCopyWithImpl<$Res, _$CalendarStateErrorImpl>
|
||||
implements _$$CalendarStateErrorImplCopyWith<$Res> {
|
||||
__$$CalendarStateErrorImplCopyWithImpl(_$CalendarStateErrorImpl _value,
|
||||
$Res Function(_$CalendarStateErrorImpl) _then)
|
||||
: super(_value, _then);
|
||||
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? errorMessage = null,
|
||||
}) {
|
||||
return _then(_$CalendarStateErrorImpl(
|
||||
errorMessage: null == errorMessage
|
||||
? _value.errorMessage
|
||||
: errorMessage // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
class _$CalendarStateErrorImpl implements CalendarStateError {
|
||||
const _$CalendarStateErrorImpl({required this.errorMessage});
|
||||
|
||||
@override
|
||||
final String errorMessage;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'CalendarState.error(errorMessage: $errorMessage)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$CalendarStateErrorImpl &&
|
||||
(identical(other.errorMessage, errorMessage) ||
|
||||
other.errorMessage == errorMessage));
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType, errorMessage);
|
||||
|
||||
@JsonKey(ignore: true)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$CalendarStateErrorImplCopyWith<_$CalendarStateErrorImpl> get copyWith =>
|
||||
__$$CalendarStateErrorImplCopyWithImpl<_$CalendarStateErrorImpl>(
|
||||
this, _$identity);
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult when<TResult extends Object?>(
|
||||
TResult Function() $default, {
|
||||
required TResult Function() loading,
|
||||
required TResult Function(List<CalendarModel> calendarList) loaded,
|
||||
required TResult Function(String errorMessage) error,
|
||||
}) {
|
||||
return error(errorMessage);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? whenOrNull<TResult extends Object?>(
|
||||
TResult? Function()? $default, {
|
||||
TResult? Function()? loading,
|
||||
TResult? Function(List<CalendarModel> calendarList)? loaded,
|
||||
TResult? Function(String errorMessage)? error,
|
||||
}) {
|
||||
return error?.call(errorMessage);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeWhen<TResult extends Object?>(
|
||||
TResult Function()? $default, {
|
||||
TResult Function()? loading,
|
||||
TResult Function(List<CalendarModel> calendarList)? loaded,
|
||||
TResult Function(String errorMessage)? error,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (error != null) {
|
||||
return error(errorMessage);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult map<TResult extends Object?>(
|
||||
TResult Function(_CalendarState value) $default, {
|
||||
required TResult Function(CalendarStateLoading value) loading,
|
||||
required TResult Function(CalendarStateLoaded value) loaded,
|
||||
required TResult Function(CalendarStateError value) error,
|
||||
}) {
|
||||
return error(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? mapOrNull<TResult extends Object?>(
|
||||
TResult? Function(_CalendarState value)? $default, {
|
||||
TResult? Function(CalendarStateLoading value)? loading,
|
||||
TResult? Function(CalendarStateLoaded value)? loaded,
|
||||
TResult? Function(CalendarStateError value)? error,
|
||||
}) {
|
||||
return error?.call(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeMap<TResult extends Object?>(
|
||||
TResult Function(_CalendarState value)? $default, {
|
||||
TResult Function(CalendarStateLoading value)? loading,
|
||||
TResult Function(CalendarStateLoaded value)? loaded,
|
||||
TResult Function(CalendarStateError value)? error,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (error != null) {
|
||||
return error(this);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
}
|
||||
|
||||
abstract class CalendarStateError implements CalendarState {
|
||||
const factory CalendarStateError({required final String errorMessage}) =
|
||||
_$CalendarStateErrorImpl;
|
||||
|
||||
String get errorMessage;
|
||||
@JsonKey(ignore: true)
|
||||
_$$CalendarStateErrorImplCopyWith<_$CalendarStateErrorImpl> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
283
lib/features/calendar/presentation/pages/calendar_screen.dart
Normal file
283
lib/features/calendar/presentation/pages/calendar_screen.dart
Normal file
@@ -0,0 +1,283 @@
|
||||
// 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: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';
|
||||
|
||||
// ignore: must_be_immutable
|
||||
class CalendarScreen extends StatelessWidget {
|
||||
CalendarScreen({Key? key}) : super(key: key);
|
||||
Widget build(BuildContext context) {
|
||||
return BlocBuilder<CalendarCubit, CalendarState>(
|
||||
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),
|
||||
),
|
||||
),
|
||||
);
|
||||
} else
|
||||
return Scaffold(
|
||||
body: Padding(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Center(
|
||||
child: Text("Неопределенная ошибка"),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildCalendar(BuildContext context, CalendarStateLoaded state) {
|
||||
return Stack(alignment: Alignment.bottomCenter, children: [
|
||||
FormBuilder(
|
||||
child: Scaffold(
|
||||
appBar: AppBar(
|
||||
toolbarHeight: 0,
|
||||
automaticallyImplyLeading: false,
|
||||
),
|
||||
backgroundColor: Colors.white,
|
||||
resizeToAvoidBottomInset: true,
|
||||
body: SizedBox(
|
||||
width: double.maxFinite,
|
||||
child: Column(
|
||||
children: [
|
||||
Expanded(
|
||||
child: SingleChildScrollView(
|
||||
child: Padding(
|
||||
padding: EdgeInsets.only(bottom: 5.v),
|
||||
child: Column(
|
||||
children: [
|
||||
SizedBox(height: 20.v),
|
||||
_buildCalendarBody(context, state),
|
||||
SizedBox(height: 20.v),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
]);
|
||||
}
|
||||
|
||||
_buildCalendarBody(BuildContext context, CalendarStateLoaded state) {
|
||||
return ListView.separated(
|
||||
padding: EdgeInsets.all(8),
|
||||
shrinkWrap: true,
|
||||
physics: NeverScrollableScrollPhysics(),
|
||||
separatorBuilder: (context, index) {
|
||||
return SizedBox(
|
||||
height: 2.v,
|
||||
);
|
||||
},
|
||||
itemCount: state.calendarList.length,
|
||||
itemBuilder: (context, index) {
|
||||
Map<String, dynamic> diary = {};
|
||||
if (state.calendarList[index].diary is List<dynamic>) {
|
||||
diary['status'] = 'Скоро';
|
||||
return InkWell(
|
||||
borderRadius: BorderRadiusStyle.circleBorder8,
|
||||
child: Ink(
|
||||
padding: EdgeInsets.all(8),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadiusStyle.circleBorder8,
|
||||
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),
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
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)
|
||||
Container(
|
||||
padding: EdgeInsets.all(
|
||||
4.0), // Отступы внутри контейнера
|
||||
decoration: BoxDecoration(
|
||||
color: Color.fromRGBO(13, 110, 253, 1),
|
||||
borderRadius: BorderRadius.circular(
|
||||
24.0), // Закругленные углы
|
||||
),
|
||||
child: Text(
|
||||
'Посмотреть диету на день',
|
||||
style: CustomTextStyles
|
||||
.titleSmallBold, // Предполагается, что текст белый
|
||||
),
|
||||
),
|
||||
if (!state.calendarList[index]
|
||||
.is_current_day_included_in_the_chosen_diet_progression)
|
||||
Container(
|
||||
padding: EdgeInsets.all(
|
||||
4.0), // Отступы внутри контейнера
|
||||
decoration: BoxDecoration(
|
||||
color: Color.fromRGBO(108, 117, 125, 1),
|
||||
borderRadius: BorderRadius.circular(
|
||||
24.0), // Закругленные углы
|
||||
),
|
||||
child: Text(
|
||||
'Cкоро',
|
||||
style: CustomTextStyles
|
||||
.titleSmallBold, // Предполагается, что текст белый
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
} else {
|
||||
diary = state.calendarList[index].diary as Map<String, dynamic>;
|
||||
print(state.calendarList[index]);
|
||||
return InkWell(
|
||||
borderRadius: BorderRadiusStyle.circleBorder8,
|
||||
onTap: () => GoRouter.of(context).go(
|
||||
'/diary-screen',
|
||||
extra: diary['id'].toString(),
|
||||
),
|
||||
child: Ink(
|
||||
padding: EdgeInsets.all(8),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadiusStyle.circleBorder8,
|
||||
color: getBackgroundColor(diary['state']),
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
formatDate(state.calendarList[index].date),
|
||||
style: theme.textTheme.titleMedium,
|
||||
),
|
||||
SizedBox(height: 2.v),
|
||||
Row(children: [
|
||||
Container(
|
||||
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), // Закругленные углы
|
||||
),
|
||||
child: Text(
|
||||
_getStateText(diary['state'] ?? ''),
|
||||
style: CustomTextStyles
|
||||
.titleSmallBold, // Предполагается, что текст белый
|
||||
),
|
||||
),
|
||||
SizedBox(width: 4),
|
||||
if (diary['state'] == 'started')
|
||||
Container(
|
||||
padding: EdgeInsets.all(
|
||||
4.0), // Отступы внутри контейнера
|
||||
decoration: BoxDecoration(
|
||||
color: Color.fromRGBO(13, 110, 253, 1),
|
||||
borderRadius: BorderRadius.circular(
|
||||
24.0), // Закругленные углы
|
||||
),
|
||||
child: Text(
|
||||
'Заполнить отчет',
|
||||
style: CustomTextStyles
|
||||
.titleSmallBold, // Предполагается, что текст белый
|
||||
),
|
||||
),
|
||||
if (diary['state'] == 'finished')
|
||||
Container(
|
||||
padding: EdgeInsets.all(
|
||||
4.0), // Отступы внутри контейнера
|
||||
decoration: BoxDecoration(
|
||||
color: Color.fromRGBO(13, 110, 253, 1),
|
||||
borderRadius: BorderRadius.circular(
|
||||
24.0), // Закругленные углы
|
||||
),
|
||||
child: Text(
|
||||
'Изменить отчет',
|
||||
style: CustomTextStyles
|
||||
.titleSmallBold, // Предполагается, что текст белый
|
||||
),
|
||||
),
|
||||
]),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
String _getStateText(String state) {
|
||||
switch (state) {
|
||||
case 'finished':
|
||||
return 'Готово';
|
||||
case 'started':
|
||||
return 'В процессе';
|
||||
default:
|
||||
return ''; // Возвращаем пустую строку, если состояние не распознано
|
||||
}
|
||||
}
|
||||
|
||||
String formatDate(String dateString) {
|
||||
// Преобразуем строку в объект DateTime
|
||||
DateTime dateTime = DateTime.parse(dateString);
|
||||
|
||||
// Форматируем дату
|
||||
String formattedDate = DateFormat('d MMMM', 'ru_RU').format(dateTime);
|
||||
|
||||
// Возвращаем результат в нужном формате
|
||||
return '$formattedDate';
|
||||
}
|
||||
|
||||
Color getBackgroundColor(String? status) {
|
||||
switch (status) {
|
||||
case 'finished':
|
||||
return Color.fromRGBO(1, 154, 62, .1);
|
||||
case 'started':
|
||||
return Color.fromRGBO(154, 74, 1, .1);
|
||||
default:
|
||||
return Color.fromRGBO(126, 136, 151, .1);
|
||||
}
|
||||
}
|
||||
16
lib/features/calendar/repositories/calendar_repository.dart
Normal file
16
lib/features/calendar/repositories/calendar_repository.dart
Normal file
@@ -0,0 +1,16 @@
|
||||
import 'package:eatvio_app/features/calendar/models/calendar_model.dart';
|
||||
import 'package:eatvio_app/features/calendar/services/calendar_service.dart';
|
||||
|
||||
class CalendarRepository {
|
||||
final CalendarService calendarService;
|
||||
|
||||
CalendarRepository({required this.calendarService});
|
||||
|
||||
Future<List<CalendarModel>> getCalendar() async {
|
||||
try {
|
||||
return await calendarService.getCalendar();
|
||||
} catch (e) {
|
||||
rethrow;
|
||||
}
|
||||
}
|
||||
}
|
||||
13
lib/features/calendar/services/calendar_service.dart
Normal file
13
lib/features/calendar/services/calendar_service.dart
Normal file
@@ -0,0 +1,13 @@
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:eatvio_app/features/calendar/models/calendar_model.dart';
|
||||
import 'package:retrofit/retrofit.dart';
|
||||
|
||||
part 'calendar_service.g.dart';
|
||||
|
||||
@RestApi()
|
||||
abstract class CalendarService {
|
||||
factory CalendarService(Dio dio, {String baseUrl}) = _CalendarService;
|
||||
|
||||
@GET('/api/calendar/index')
|
||||
Future<List<CalendarModel>> getCalendar();
|
||||
}
|
||||
79
lib/features/calendar/services/calendar_service.g.dart
Normal file
79
lib/features/calendar/services/calendar_service.g.dart
Normal file
@@ -0,0 +1,79 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'calendar_service.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// RetrofitGenerator
|
||||
// **************************************************************************
|
||||
|
||||
// ignore_for_file: unnecessary_brace_in_string_interps,no_leading_underscores_for_local_identifiers,unused_element
|
||||
|
||||
class _CalendarService implements CalendarService {
|
||||
_CalendarService(
|
||||
this._dio, {
|
||||
this.baseUrl,
|
||||
});
|
||||
|
||||
final Dio _dio;
|
||||
|
||||
String? baseUrl;
|
||||
|
||||
@override
|
||||
Future<List<CalendarModel>> getCalendar() async {
|
||||
final _extra = <String, dynamic>{};
|
||||
final queryParameters = <String, dynamic>{};
|
||||
final _headers = <String, dynamic>{};
|
||||
const Map<String, dynamic>? _data = null;
|
||||
final _result = await _dio
|
||||
.fetch<List<dynamic>>(_setStreamType<List<CalendarModel>>(Options(
|
||||
method: 'GET',
|
||||
headers: _headers,
|
||||
extra: _extra,
|
||||
)
|
||||
.compose(
|
||||
_dio.options,
|
||||
'/api/calendar/index',
|
||||
queryParameters: queryParameters,
|
||||
data: _data,
|
||||
)
|
||||
.copyWith(
|
||||
baseUrl: _combineBaseUrls(
|
||||
_dio.options.baseUrl,
|
||||
baseUrl,
|
||||
))));
|
||||
var _value = _result.data!
|
||||
.map((dynamic i) => CalendarModel.fromJson(i as Map<String, dynamic>))
|
||||
.toList();
|
||||
return _value;
|
||||
}
|
||||
|
||||
RequestOptions _setStreamType<T>(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();
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
||||
part 'chat_message_model.freezed.dart';
|
||||
|
||||
part 'chat_message_model.g.dart';
|
||||
|
||||
@freezed
|
||||
@@ -9,7 +8,7 @@ class ChatMessageModel with _$ChatMessageModel {
|
||||
const factory ChatMessageModel({
|
||||
required int id,
|
||||
required String data,
|
||||
@JsonKey(name: 'media_data') required List<dynamic> mediaData,
|
||||
@JsonKey(name: 'media_data') required List<dynamic>? mediaData,
|
||||
@JsonKey(name: 'author_id') required int authorId,
|
||||
@JsonKey(name: 'updated_at') required String updatedAt,
|
||||
}) = _ChatMessageModel;
|
||||
|
||||
@@ -23,7 +23,7 @@ mixin _$ChatMessageModel {
|
||||
int get id => throw _privateConstructorUsedError;
|
||||
String get data => throw _privateConstructorUsedError;
|
||||
@JsonKey(name: 'media_data')
|
||||
List<dynamic> get mediaData => throw _privateConstructorUsedError;
|
||||
List<dynamic>? get mediaData => throw _privateConstructorUsedError;
|
||||
@JsonKey(name: 'author_id')
|
||||
int get authorId => throw _privateConstructorUsedError;
|
||||
@JsonKey(name: 'updated_at')
|
||||
@@ -44,7 +44,7 @@ abstract class $ChatMessageModelCopyWith<$Res> {
|
||||
$Res call(
|
||||
{int id,
|
||||
String data,
|
||||
@JsonKey(name: 'media_data') List<dynamic> mediaData,
|
||||
@JsonKey(name: 'media_data') List<dynamic>? mediaData,
|
||||
@JsonKey(name: 'author_id') int authorId,
|
||||
@JsonKey(name: 'updated_at') String updatedAt});
|
||||
}
|
||||
@@ -64,7 +64,7 @@ class _$ChatMessageModelCopyWithImpl<$Res, $Val extends ChatMessageModel>
|
||||
$Res call({
|
||||
Object? id = null,
|
||||
Object? data = null,
|
||||
Object? mediaData = null,
|
||||
Object? mediaData = freezed,
|
||||
Object? authorId = null,
|
||||
Object? updatedAt = null,
|
||||
}) {
|
||||
@@ -77,10 +77,10 @@ class _$ChatMessageModelCopyWithImpl<$Res, $Val extends ChatMessageModel>
|
||||
? _value.data
|
||||
: data // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
mediaData: null == mediaData
|
||||
mediaData: freezed == mediaData
|
||||
? _value.mediaData
|
||||
: mediaData // ignore: cast_nullable_to_non_nullable
|
||||
as List<dynamic>,
|
||||
as List<dynamic>?,
|
||||
authorId: null == authorId
|
||||
? _value.authorId
|
||||
: authorId // ignore: cast_nullable_to_non_nullable
|
||||
@@ -104,7 +104,7 @@ abstract class _$$ChatMessageModelImplCopyWith<$Res>
|
||||
$Res call(
|
||||
{int id,
|
||||
String data,
|
||||
@JsonKey(name: 'media_data') List<dynamic> mediaData,
|
||||
@JsonKey(name: 'media_data') List<dynamic>? mediaData,
|
||||
@JsonKey(name: 'author_id') int authorId,
|
||||
@JsonKey(name: 'updated_at') String updatedAt});
|
||||
}
|
||||
@@ -122,7 +122,7 @@ class __$$ChatMessageModelImplCopyWithImpl<$Res>
|
||||
$Res call({
|
||||
Object? id = null,
|
||||
Object? data = null,
|
||||
Object? mediaData = null,
|
||||
Object? mediaData = freezed,
|
||||
Object? authorId = null,
|
||||
Object? updatedAt = null,
|
||||
}) {
|
||||
@@ -135,10 +135,10 @@ class __$$ChatMessageModelImplCopyWithImpl<$Res>
|
||||
? _value.data
|
||||
: data // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
mediaData: null == mediaData
|
||||
mediaData: freezed == mediaData
|
||||
? _value._mediaData
|
||||
: mediaData // ignore: cast_nullable_to_non_nullable
|
||||
as List<dynamic>,
|
||||
as List<dynamic>?,
|
||||
authorId: null == authorId
|
||||
? _value.authorId
|
||||
: authorId // ignore: cast_nullable_to_non_nullable
|
||||
@@ -157,7 +157,7 @@ class _$ChatMessageModelImpl implements _ChatMessageModel {
|
||||
const _$ChatMessageModelImpl(
|
||||
{required this.id,
|
||||
required this.data,
|
||||
@JsonKey(name: 'media_data') required final List<dynamic> mediaData,
|
||||
@JsonKey(name: 'media_data') required final List<dynamic>? mediaData,
|
||||
@JsonKey(name: 'author_id') required this.authorId,
|
||||
@JsonKey(name: 'updated_at') required this.updatedAt})
|
||||
: _mediaData = mediaData;
|
||||
@@ -169,13 +169,15 @@ class _$ChatMessageModelImpl implements _ChatMessageModel {
|
||||
final int id;
|
||||
@override
|
||||
final String data;
|
||||
final List<dynamic> _mediaData;
|
||||
final List<dynamic>? _mediaData;
|
||||
@override
|
||||
@JsonKey(name: 'media_data')
|
||||
List<dynamic> get mediaData {
|
||||
List<dynamic>? get mediaData {
|
||||
final value = _mediaData;
|
||||
if (value == null) return null;
|
||||
if (_mediaData is EqualUnmodifiableListView) return _mediaData;
|
||||
// ignore: implicit_dynamic_type
|
||||
return EqualUnmodifiableListView(_mediaData);
|
||||
return EqualUnmodifiableListView(value);
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -229,7 +231,7 @@ abstract class _ChatMessageModel implements ChatMessageModel {
|
||||
const factory _ChatMessageModel(
|
||||
{required final int id,
|
||||
required final String data,
|
||||
@JsonKey(name: 'media_data') required final List<dynamic> mediaData,
|
||||
@JsonKey(name: 'media_data') required final List<dynamic>? mediaData,
|
||||
@JsonKey(name: 'author_id') required final int authorId,
|
||||
@JsonKey(name: 'updated_at') required final String updatedAt}) =
|
||||
_$ChatMessageModelImpl;
|
||||
@@ -243,7 +245,7 @@ abstract class _ChatMessageModel implements ChatMessageModel {
|
||||
String get data;
|
||||
@override
|
||||
@JsonKey(name: 'media_data')
|
||||
List<dynamic> get mediaData;
|
||||
List<dynamic>? get mediaData;
|
||||
@override
|
||||
@JsonKey(name: 'author_id')
|
||||
int get authorId;
|
||||
|
||||
@@ -11,7 +11,7 @@ _$ChatMessageModelImpl _$$ChatMessageModelImplFromJson(
|
||||
_$ChatMessageModelImpl(
|
||||
id: (json['id'] as num).toInt(),
|
||||
data: json['data'] as String,
|
||||
mediaData: json['media_data'] as List<dynamic>,
|
||||
mediaData: json['media_data'] as List<dynamic>?,
|
||||
authorId: (json['author_id'] as num).toInt(),
|
||||
updatedAt: json['updated_at'] as String,
|
||||
);
|
||||
|
||||
17
lib/features/chat/models/chat_messages_model.dart
Normal file
17
lib/features/chat/models/chat_messages_model.dart
Normal file
@@ -0,0 +1,17 @@
|
||||
import 'package:eatvio_app/features/chat/models/chat_message_model.dart';
|
||||
import 'package:eatvio_app/features/chat/models/chat_meta_model.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
||||
part 'chat_messages_model.freezed.dart';
|
||||
|
||||
part 'chat_messages_model.g.dart';
|
||||
|
||||
@freezed
|
||||
class ChatMessagesModel with _$ChatMessagesModel {
|
||||
const factory ChatMessagesModel({
|
||||
@JsonKey(name: 'data') required List<ChatMessageModel> messagesList,
|
||||
required ChatMetaModel meta,
|
||||
}) = _ChatMessagesModel;
|
||||
|
||||
factory ChatMessagesModel.fromJson(Map<String, Object?> json) => _$ChatMessagesModelFromJson(json);
|
||||
}
|
||||
203
lib/features/chat/models/chat_messages_model.freezed.dart
Normal file
203
lib/features/chat/models/chat_messages_model.freezed.dart
Normal file
@@ -0,0 +1,203 @@
|
||||
// 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 'chat_messages_model.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// FreezedGenerator
|
||||
// **************************************************************************
|
||||
|
||||
T _$identity<T>(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');
|
||||
|
||||
ChatMessagesModel _$ChatMessagesModelFromJson(Map<String, dynamic> json) {
|
||||
return _ChatMessagesModel.fromJson(json);
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
mixin _$ChatMessagesModel {
|
||||
@JsonKey(name: 'data')
|
||||
List<ChatMessageModel> get messagesList => throw _privateConstructorUsedError;
|
||||
ChatMetaModel get meta => throw _privateConstructorUsedError;
|
||||
|
||||
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
|
||||
@JsonKey(ignore: true)
|
||||
$ChatMessagesModelCopyWith<ChatMessagesModel> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class $ChatMessagesModelCopyWith<$Res> {
|
||||
factory $ChatMessagesModelCopyWith(
|
||||
ChatMessagesModel value, $Res Function(ChatMessagesModel) then) =
|
||||
_$ChatMessagesModelCopyWithImpl<$Res, ChatMessagesModel>;
|
||||
@useResult
|
||||
$Res call(
|
||||
{@JsonKey(name: 'data') List<ChatMessageModel> messagesList,
|
||||
ChatMetaModel meta});
|
||||
|
||||
$ChatMetaModelCopyWith<$Res> get meta;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class _$ChatMessagesModelCopyWithImpl<$Res, $Val extends ChatMessagesModel>
|
||||
implements $ChatMessagesModelCopyWith<$Res> {
|
||||
_$ChatMessagesModelCopyWithImpl(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? messagesList = null,
|
||||
Object? meta = null,
|
||||
}) {
|
||||
return _then(_value.copyWith(
|
||||
messagesList: null == messagesList
|
||||
? _value.messagesList
|
||||
: messagesList // ignore: cast_nullable_to_non_nullable
|
||||
as List<ChatMessageModel>,
|
||||
meta: null == meta
|
||||
? _value.meta
|
||||
: meta // ignore: cast_nullable_to_non_nullable
|
||||
as ChatMetaModel,
|
||||
) as $Val);
|
||||
}
|
||||
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
$ChatMetaModelCopyWith<$Res> get meta {
|
||||
return $ChatMetaModelCopyWith<$Res>(_value.meta, (value) {
|
||||
return _then(_value.copyWith(meta: value) as $Val);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$ChatMessagesModelImplCopyWith<$Res>
|
||||
implements $ChatMessagesModelCopyWith<$Res> {
|
||||
factory _$$ChatMessagesModelImplCopyWith(_$ChatMessagesModelImpl value,
|
||||
$Res Function(_$ChatMessagesModelImpl) then) =
|
||||
__$$ChatMessagesModelImplCopyWithImpl<$Res>;
|
||||
@override
|
||||
@useResult
|
||||
$Res call(
|
||||
{@JsonKey(name: 'data') List<ChatMessageModel> messagesList,
|
||||
ChatMetaModel meta});
|
||||
|
||||
@override
|
||||
$ChatMetaModelCopyWith<$Res> get meta;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$ChatMessagesModelImplCopyWithImpl<$Res>
|
||||
extends _$ChatMessagesModelCopyWithImpl<$Res, _$ChatMessagesModelImpl>
|
||||
implements _$$ChatMessagesModelImplCopyWith<$Res> {
|
||||
__$$ChatMessagesModelImplCopyWithImpl(_$ChatMessagesModelImpl _value,
|
||||
$Res Function(_$ChatMessagesModelImpl) _then)
|
||||
: super(_value, _then);
|
||||
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? messagesList = null,
|
||||
Object? meta = null,
|
||||
}) {
|
||||
return _then(_$ChatMessagesModelImpl(
|
||||
messagesList: null == messagesList
|
||||
? _value._messagesList
|
||||
: messagesList // ignore: cast_nullable_to_non_nullable
|
||||
as List<ChatMessageModel>,
|
||||
meta: null == meta
|
||||
? _value.meta
|
||||
: meta // ignore: cast_nullable_to_non_nullable
|
||||
as ChatMetaModel,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@JsonSerializable()
|
||||
class _$ChatMessagesModelImpl implements _ChatMessagesModel {
|
||||
const _$ChatMessagesModelImpl(
|
||||
{@JsonKey(name: 'data')
|
||||
required final List<ChatMessageModel> messagesList,
|
||||
required this.meta})
|
||||
: _messagesList = messagesList;
|
||||
|
||||
factory _$ChatMessagesModelImpl.fromJson(Map<String, dynamic> json) =>
|
||||
_$$ChatMessagesModelImplFromJson(json);
|
||||
|
||||
final List<ChatMessageModel> _messagesList;
|
||||
@override
|
||||
@JsonKey(name: 'data')
|
||||
List<ChatMessageModel> get messagesList {
|
||||
if (_messagesList is EqualUnmodifiableListView) return _messagesList;
|
||||
// ignore: implicit_dynamic_type
|
||||
return EqualUnmodifiableListView(_messagesList);
|
||||
}
|
||||
|
||||
@override
|
||||
final ChatMetaModel meta;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'ChatMessagesModel(messagesList: $messagesList, meta: $meta)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$ChatMessagesModelImpl &&
|
||||
const DeepCollectionEquality()
|
||||
.equals(other._messagesList, _messagesList) &&
|
||||
(identical(other.meta, meta) || other.meta == meta));
|
||||
}
|
||||
|
||||
@JsonKey(ignore: true)
|
||||
@override
|
||||
int get hashCode => Object.hash(
|
||||
runtimeType, const DeepCollectionEquality().hash(_messagesList), meta);
|
||||
|
||||
@JsonKey(ignore: true)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$ChatMessagesModelImplCopyWith<_$ChatMessagesModelImpl> get copyWith =>
|
||||
__$$ChatMessagesModelImplCopyWithImpl<_$ChatMessagesModelImpl>(
|
||||
this, _$identity);
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
return _$$ChatMessagesModelImplToJson(
|
||||
this,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
abstract class _ChatMessagesModel implements ChatMessagesModel {
|
||||
const factory _ChatMessagesModel(
|
||||
{@JsonKey(name: 'data')
|
||||
required final List<ChatMessageModel> messagesList,
|
||||
required final ChatMetaModel meta}) = _$ChatMessagesModelImpl;
|
||||
|
||||
factory _ChatMessagesModel.fromJson(Map<String, dynamic> json) =
|
||||
_$ChatMessagesModelImpl.fromJson;
|
||||
|
||||
@override
|
||||
@JsonKey(name: 'data')
|
||||
List<ChatMessageModel> get messagesList;
|
||||
@override
|
||||
ChatMetaModel get meta;
|
||||
@override
|
||||
@JsonKey(ignore: true)
|
||||
_$$ChatMessagesModelImplCopyWith<_$ChatMessagesModelImpl> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
23
lib/features/chat/models/chat_messages_model.g.dart
Normal file
23
lib/features/chat/models/chat_messages_model.g.dart
Normal file
@@ -0,0 +1,23 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'chat_messages_model.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
_$ChatMessagesModelImpl _$$ChatMessagesModelImplFromJson(
|
||||
Map<String, dynamic> json) =>
|
||||
_$ChatMessagesModelImpl(
|
||||
messagesList: (json['data'] as List<dynamic>)
|
||||
.map((e) => ChatMessageModel.fromJson(e as Map<String, dynamic>))
|
||||
.toList(),
|
||||
meta: ChatMetaModel.fromJson(json['meta'] as Map<String, dynamic>),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$$ChatMessagesModelImplToJson(
|
||||
_$ChatMessagesModelImpl instance) =>
|
||||
<String, dynamic>{
|
||||
'data': instance.messagesList,
|
||||
'meta': instance.meta,
|
||||
};
|
||||
13
lib/features/chat/models/chat_meta_model.dart
Normal file
13
lib/features/chat/models/chat_meta_model.dart
Normal file
@@ -0,0 +1,13 @@
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
||||
part 'chat_meta_model.freezed.dart';
|
||||
part 'chat_meta_model.g.dart';
|
||||
|
||||
@freezed
|
||||
class ChatMetaModel with _$ChatMetaModel {
|
||||
const factory ChatMetaModel({
|
||||
@JsonKey(name: "last_page") required int lastPage,
|
||||
}) = _ChatMetaModel;
|
||||
|
||||
factory ChatMetaModel.fromJson(Map<String, Object?> json) => _$ChatMetaModelFromJson(json);
|
||||
}
|
||||
158
lib/features/chat/models/chat_meta_model.freezed.dart
Normal file
158
lib/features/chat/models/chat_meta_model.freezed.dart
Normal file
@@ -0,0 +1,158 @@
|
||||
// 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 'chat_meta_model.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// FreezedGenerator
|
||||
// **************************************************************************
|
||||
|
||||
T _$identity<T>(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');
|
||||
|
||||
ChatMetaModel _$ChatMetaModelFromJson(Map<String, dynamic> json) {
|
||||
return _ChatMetaModel.fromJson(json);
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
mixin _$ChatMetaModel {
|
||||
@JsonKey(name: "last_page")
|
||||
int get lastPage => throw _privateConstructorUsedError;
|
||||
|
||||
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
|
||||
@JsonKey(ignore: true)
|
||||
$ChatMetaModelCopyWith<ChatMetaModel> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class $ChatMetaModelCopyWith<$Res> {
|
||||
factory $ChatMetaModelCopyWith(
|
||||
ChatMetaModel value, $Res Function(ChatMetaModel) then) =
|
||||
_$ChatMetaModelCopyWithImpl<$Res, ChatMetaModel>;
|
||||
@useResult
|
||||
$Res call({@JsonKey(name: "last_page") int lastPage});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class _$ChatMetaModelCopyWithImpl<$Res, $Val extends ChatMetaModel>
|
||||
implements $ChatMetaModelCopyWith<$Res> {
|
||||
_$ChatMetaModelCopyWithImpl(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? lastPage = null,
|
||||
}) {
|
||||
return _then(_value.copyWith(
|
||||
lastPage: null == lastPage
|
||||
? _value.lastPage
|
||||
: lastPage // ignore: cast_nullable_to_non_nullable
|
||||
as int,
|
||||
) as $Val);
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$ChatMetaModelImplCopyWith<$Res>
|
||||
implements $ChatMetaModelCopyWith<$Res> {
|
||||
factory _$$ChatMetaModelImplCopyWith(
|
||||
_$ChatMetaModelImpl value, $Res Function(_$ChatMetaModelImpl) then) =
|
||||
__$$ChatMetaModelImplCopyWithImpl<$Res>;
|
||||
@override
|
||||
@useResult
|
||||
$Res call({@JsonKey(name: "last_page") int lastPage});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$ChatMetaModelImplCopyWithImpl<$Res>
|
||||
extends _$ChatMetaModelCopyWithImpl<$Res, _$ChatMetaModelImpl>
|
||||
implements _$$ChatMetaModelImplCopyWith<$Res> {
|
||||
__$$ChatMetaModelImplCopyWithImpl(
|
||||
_$ChatMetaModelImpl _value, $Res Function(_$ChatMetaModelImpl) _then)
|
||||
: super(_value, _then);
|
||||
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? lastPage = null,
|
||||
}) {
|
||||
return _then(_$ChatMetaModelImpl(
|
||||
lastPage: null == lastPage
|
||||
? _value.lastPage
|
||||
: lastPage // ignore: cast_nullable_to_non_nullable
|
||||
as int,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@JsonSerializable()
|
||||
class _$ChatMetaModelImpl implements _ChatMetaModel {
|
||||
const _$ChatMetaModelImpl(
|
||||
{@JsonKey(name: "last_page") required this.lastPage});
|
||||
|
||||
factory _$ChatMetaModelImpl.fromJson(Map<String, dynamic> json) =>
|
||||
_$$ChatMetaModelImplFromJson(json);
|
||||
|
||||
@override
|
||||
@JsonKey(name: "last_page")
|
||||
final int lastPage;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'ChatMetaModel(lastPage: $lastPage)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$ChatMetaModelImpl &&
|
||||
(identical(other.lastPage, lastPage) ||
|
||||
other.lastPage == lastPage));
|
||||
}
|
||||
|
||||
@JsonKey(ignore: true)
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType, lastPage);
|
||||
|
||||
@JsonKey(ignore: true)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$ChatMetaModelImplCopyWith<_$ChatMetaModelImpl> get copyWith =>
|
||||
__$$ChatMetaModelImplCopyWithImpl<_$ChatMetaModelImpl>(this, _$identity);
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
return _$$ChatMetaModelImplToJson(
|
||||
this,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
abstract class _ChatMetaModel implements ChatMetaModel {
|
||||
const factory _ChatMetaModel(
|
||||
{@JsonKey(name: "last_page") required final int lastPage}) =
|
||||
_$ChatMetaModelImpl;
|
||||
|
||||
factory _ChatMetaModel.fromJson(Map<String, dynamic> json) =
|
||||
_$ChatMetaModelImpl.fromJson;
|
||||
|
||||
@override
|
||||
@JsonKey(name: "last_page")
|
||||
int get lastPage;
|
||||
@override
|
||||
@JsonKey(ignore: true)
|
||||
_$$ChatMetaModelImplCopyWith<_$ChatMetaModelImpl> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
17
lib/features/chat/models/chat_meta_model.g.dart
Normal file
17
lib/features/chat/models/chat_meta_model.g.dart
Normal file
@@ -0,0 +1,17 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'chat_meta_model.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
_$ChatMetaModelImpl _$$ChatMetaModelImplFromJson(Map<String, dynamic> json) =>
|
||||
_$ChatMetaModelImpl(
|
||||
lastPage: (json['last_page'] as num).toInt(),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$$ChatMetaModelImplToJson(_$ChatMetaModelImpl instance) =>
|
||||
<String, dynamic>{
|
||||
'last_page': instance.lastPage,
|
||||
};
|
||||
@@ -1,10 +1,8 @@
|
||||
import 'package:eatvio_app/features/chat/models/chat_message_model.dart';
|
||||
import 'package:eatvio_app/features/chat/models/chat_room_settings_model.dart';
|
||||
import 'package:eatvio_app/features/chat/models/chat_user_model.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
||||
part 'chat_room_model.freezed.dart';
|
||||
|
||||
part 'chat_room_model.g.dart';
|
||||
|
||||
@freezed
|
||||
@@ -12,7 +10,6 @@ class ChatRoomModel with _$ChatRoomModel {
|
||||
const factory ChatRoomModel({
|
||||
required String id,
|
||||
@JsonKey(name: 'chat_room_setting') required ChatRoomSettingsModel chatRoomSettings,
|
||||
required List<ChatMessageModel> messages,
|
||||
required Map<String, ChatUserModel> users,
|
||||
}) = _ChatRoomModel;
|
||||
|
||||
|
||||
@@ -24,7 +24,6 @@ mixin _$ChatRoomModel {
|
||||
@JsonKey(name: 'chat_room_setting')
|
||||
ChatRoomSettingsModel get chatRoomSettings =>
|
||||
throw _privateConstructorUsedError;
|
||||
List<ChatMessageModel> get messages => throw _privateConstructorUsedError;
|
||||
Map<String, ChatUserModel> get users => throw _privateConstructorUsedError;
|
||||
|
||||
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
|
||||
@@ -43,7 +42,6 @@ abstract class $ChatRoomModelCopyWith<$Res> {
|
||||
{String id,
|
||||
@JsonKey(name: 'chat_room_setting')
|
||||
ChatRoomSettingsModel chatRoomSettings,
|
||||
List<ChatMessageModel> messages,
|
||||
Map<String, ChatUserModel> users});
|
||||
|
||||
$ChatRoomSettingsModelCopyWith<$Res> get chatRoomSettings;
|
||||
@@ -64,7 +62,6 @@ class _$ChatRoomModelCopyWithImpl<$Res, $Val extends ChatRoomModel>
|
||||
$Res call({
|
||||
Object? id = null,
|
||||
Object? chatRoomSettings = null,
|
||||
Object? messages = null,
|
||||
Object? users = null,
|
||||
}) {
|
||||
return _then(_value.copyWith(
|
||||
@@ -76,10 +73,6 @@ class _$ChatRoomModelCopyWithImpl<$Res, $Val extends ChatRoomModel>
|
||||
? _value.chatRoomSettings
|
||||
: chatRoomSettings // ignore: cast_nullable_to_non_nullable
|
||||
as ChatRoomSettingsModel,
|
||||
messages: null == messages
|
||||
? _value.messages
|
||||
: messages // ignore: cast_nullable_to_non_nullable
|
||||
as List<ChatMessageModel>,
|
||||
users: null == users
|
||||
? _value.users
|
||||
: users // ignore: cast_nullable_to_non_nullable
|
||||
@@ -109,7 +102,6 @@ abstract class _$$ChatRoomModelImplCopyWith<$Res>
|
||||
{String id,
|
||||
@JsonKey(name: 'chat_room_setting')
|
||||
ChatRoomSettingsModel chatRoomSettings,
|
||||
List<ChatMessageModel> messages,
|
||||
Map<String, ChatUserModel> users});
|
||||
|
||||
@override
|
||||
@@ -129,7 +121,6 @@ class __$$ChatRoomModelImplCopyWithImpl<$Res>
|
||||
$Res call({
|
||||
Object? id = null,
|
||||
Object? chatRoomSettings = null,
|
||||
Object? messages = null,
|
||||
Object? users = null,
|
||||
}) {
|
||||
return _then(_$ChatRoomModelImpl(
|
||||
@@ -141,10 +132,6 @@ class __$$ChatRoomModelImplCopyWithImpl<$Res>
|
||||
? _value.chatRoomSettings
|
||||
: chatRoomSettings // ignore: cast_nullable_to_non_nullable
|
||||
as ChatRoomSettingsModel,
|
||||
messages: null == messages
|
||||
? _value._messages
|
||||
: messages // ignore: cast_nullable_to_non_nullable
|
||||
as List<ChatMessageModel>,
|
||||
users: null == users
|
||||
? _value._users
|
||||
: users // ignore: cast_nullable_to_non_nullable
|
||||
@@ -159,10 +146,8 @@ class _$ChatRoomModelImpl implements _ChatRoomModel {
|
||||
const _$ChatRoomModelImpl(
|
||||
{required this.id,
|
||||
@JsonKey(name: 'chat_room_setting') required this.chatRoomSettings,
|
||||
required final List<ChatMessageModel> messages,
|
||||
required final Map<String, ChatUserModel> users})
|
||||
: _messages = messages,
|
||||
_users = users;
|
||||
: _users = users;
|
||||
|
||||
factory _$ChatRoomModelImpl.fromJson(Map<String, dynamic> json) =>
|
||||
_$$ChatRoomModelImplFromJson(json);
|
||||
@@ -172,14 +157,6 @@ class _$ChatRoomModelImpl implements _ChatRoomModel {
|
||||
@override
|
||||
@JsonKey(name: 'chat_room_setting')
|
||||
final ChatRoomSettingsModel chatRoomSettings;
|
||||
final List<ChatMessageModel> _messages;
|
||||
@override
|
||||
List<ChatMessageModel> get messages {
|
||||
if (_messages is EqualUnmodifiableListView) return _messages;
|
||||
// ignore: implicit_dynamic_type
|
||||
return EqualUnmodifiableListView(_messages);
|
||||
}
|
||||
|
||||
final Map<String, ChatUserModel> _users;
|
||||
@override
|
||||
Map<String, ChatUserModel> get users {
|
||||
@@ -190,7 +167,7 @@ class _$ChatRoomModelImpl implements _ChatRoomModel {
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'ChatRoomModel(id: $id, chatRoomSettings: $chatRoomSettings, messages: $messages, users: $users)';
|
||||
return 'ChatRoomModel(id: $id, chatRoomSettings: $chatRoomSettings, users: $users)';
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -201,17 +178,12 @@ class _$ChatRoomModelImpl implements _ChatRoomModel {
|
||||
(identical(other.id, id) || other.id == id) &&
|
||||
(identical(other.chatRoomSettings, chatRoomSettings) ||
|
||||
other.chatRoomSettings == chatRoomSettings) &&
|
||||
const DeepCollectionEquality().equals(other._messages, _messages) &&
|
||||
const DeepCollectionEquality().equals(other._users, _users));
|
||||
}
|
||||
|
||||
@JsonKey(ignore: true)
|
||||
@override
|
||||
int get hashCode => Object.hash(
|
||||
runtimeType,
|
||||
id,
|
||||
chatRoomSettings,
|
||||
const DeepCollectionEquality().hash(_messages),
|
||||
int get hashCode => Object.hash(runtimeType, id, chatRoomSettings,
|
||||
const DeepCollectionEquality().hash(_users));
|
||||
|
||||
@JsonKey(ignore: true)
|
||||
@@ -233,7 +205,6 @@ abstract class _ChatRoomModel implements ChatRoomModel {
|
||||
{required final String id,
|
||||
@JsonKey(name: 'chat_room_setting')
|
||||
required final ChatRoomSettingsModel chatRoomSettings,
|
||||
required final List<ChatMessageModel> messages,
|
||||
required final Map<String, ChatUserModel> users}) = _$ChatRoomModelImpl;
|
||||
|
||||
factory _ChatRoomModel.fromJson(Map<String, dynamic> json) =
|
||||
@@ -245,8 +216,6 @@ abstract class _ChatRoomModel implements ChatRoomModel {
|
||||
@JsonKey(name: 'chat_room_setting')
|
||||
ChatRoomSettingsModel get chatRoomSettings;
|
||||
@override
|
||||
List<ChatMessageModel> get messages;
|
||||
@override
|
||||
Map<String, ChatUserModel> get users;
|
||||
@override
|
||||
@JsonKey(ignore: true)
|
||||
|
||||
@@ -11,9 +11,6 @@ _$ChatRoomModelImpl _$$ChatRoomModelImplFromJson(Map<String, dynamic> json) =>
|
||||
id: json['id'] as String,
|
||||
chatRoomSettings: ChatRoomSettingsModel.fromJson(
|
||||
json['chat_room_setting'] as Map<String, dynamic>),
|
||||
messages: (json['messages'] as List<dynamic>)
|
||||
.map((e) => ChatMessageModel.fromJson(e as Map<String, dynamic>))
|
||||
.toList(),
|
||||
users: (json['users'] as Map<String, dynamic>).map(
|
||||
(k, e) =>
|
||||
MapEntry(k, ChatUserModel.fromJson(e as Map<String, dynamic>)),
|
||||
@@ -24,6 +21,5 @@ Map<String, dynamic> _$$ChatRoomModelImplToJson(_$ChatRoomModelImpl instance) =>
|
||||
<String, dynamic>{
|
||||
'id': instance.id,
|
||||
'chat_room_setting': instance.chatRoomSettings,
|
||||
'messages': instance.messages,
|
||||
'users': instance.users,
|
||||
};
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
||||
part 'chat_room_settings_model.freezed.dart';
|
||||
|
||||
part 'chat_room_settings_model.g.dart';
|
||||
|
||||
@freezed
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
||||
part 'chat_user_model.freezed.dart';
|
||||
|
||||
part 'chat_user_model.g.dart';
|
||||
|
||||
@freezed
|
||||
@@ -9,10 +8,8 @@ class ChatUserModel with _$ChatUserModel {
|
||||
const factory ChatUserModel({
|
||||
required int id,
|
||||
required String name,
|
||||
@JsonKey(name: 'profile_photo_path')
|
||||
String? profilePhotoPath,
|
||||
@JsonKey(name: 'profile_photo_url')
|
||||
String? profilePhotoUrl,
|
||||
@JsonKey(name: 'profile_photo_path') String? profilePhotoPath,
|
||||
@JsonKey(name: 'profile_photo_url') String? profilePhotoUrl,
|
||||
}) = _ChatUserModel;
|
||||
|
||||
factory ChatUserModel.fromJson(Map<String, Object?> json) => _$ChatUserModelFromJson(json);
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
||||
part 'websocket_info_model.freezed.dart';
|
||||
|
||||
part 'websocket_info_model.g.dart';
|
||||
|
||||
@freezed
|
||||
@@ -11,8 +10,7 @@ class WebsocketInfoModel with _$WebsocketInfoModel {
|
||||
required String host,
|
||||
required String port,
|
||||
required String cluster,
|
||||
@JsonKey(name: 'user_id')
|
||||
required int userId,
|
||||
@JsonKey(name: 'user_id') required int userId,
|
||||
}) = _WebsocketInfoModel;
|
||||
|
||||
factory WebsocketInfoModel.fromJson(Map<String, Object?> json) => _$WebsocketInfoModelFromJson(json);
|
||||
|
||||
@@ -1,20 +1,152 @@
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
|
||||
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/initialization_cubit/initialization_cubit.dart';
|
||||
import 'package:eatvio_app/core/initialization_cubit/initialization_state.dart';
|
||||
import 'package:eatvio_app/core/token_storage.dart';
|
||||
import 'package:eatvio_app/features/chat/models/chat_message_model.dart';
|
||||
import 'package:eatvio_app/features/chat/presentation/bloc/chat_room_cubit/chat_room_state.dart';
|
||||
import 'package:eatvio_app/features/chat/repositories/chat_repository.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
|
||||
class ChatRoomCubit extends Cubit<ChatRoomState> {
|
||||
final ChatRepository chatRepository;
|
||||
final InitializationCubit initializationCubit;
|
||||
|
||||
int currentPage = 1;
|
||||
late final int lastPage;
|
||||
bool isLoading = false;
|
||||
|
||||
late final PusherChannelsClient client;
|
||||
late final PrivateChannel privateChatChannel;
|
||||
|
||||
ChatRoomCubit({
|
||||
required this.chatRepository,
|
||||
required this.initializationCubit,
|
||||
}) : super(ChatRoomState.loading());
|
||||
|
||||
loadNextPage(String chatId) async {
|
||||
if (currentPage < lastPage && !isLoading) {
|
||||
isLoading = true;
|
||||
|
||||
emit(ChatRoomState.loaded(
|
||||
chatRoom: (state as ChatRoomStateLoaded).chatRoom,
|
||||
chatMessages: (state as ChatRoomStateLoaded).chatMessages,
|
||||
isTyping: (state as ChatRoomStateLoaded).isTyping,
|
||||
isLoading: isLoading,
|
||||
));
|
||||
|
||||
try {
|
||||
final chatMessages = await chatRepository.getChatMessages(chatId, currentPage + 1);
|
||||
|
||||
isLoading = false;
|
||||
emit(ChatRoomState.loaded(
|
||||
chatRoom: (state as ChatRoomStateLoaded).chatRoom,
|
||||
chatMessages: [...(state as ChatRoomStateLoaded).chatMessages, ...chatMessages.messagesList],
|
||||
isTyping: (state as ChatRoomStateLoaded).isTyping,
|
||||
isLoading: isLoading,
|
||||
));
|
||||
|
||||
currentPage++;
|
||||
} catch (e) {
|
||||
print(e);
|
||||
emit(ChatRoomState.error(errorMessage: 'Ошибка получеия данных'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
initChat(String chatId) async {
|
||||
try {
|
||||
final chatRoomModel = await chatRepository.getChatRoom(chatId);
|
||||
emit(ChatRoomState.loaded(chatRoomModel: chatRoomModel));
|
||||
final chatRoom = await chatRepository.getChatRoom(chatId);
|
||||
|
||||
final chatMessages = await chatRepository.getChatMessages(chatId, currentPage);
|
||||
lastPage = chatMessages.meta.lastPage;
|
||||
|
||||
await subscribeToChatChannel(initCubit: initializationCubit, chatId: chatId);
|
||||
|
||||
emit(ChatRoomState.loaded(
|
||||
chatRoom: chatRoom,
|
||||
chatMessages: chatMessages.messagesList,
|
||||
isTyping: false,
|
||||
isLoading: isLoading,
|
||||
));
|
||||
} catch (e) {
|
||||
print(e);
|
||||
emit(ChatRoomState.error(errorMessage: 'Ошибка получеия данных'));
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> subscribeToChatChannel({
|
||||
required InitializationCubit initCubit,
|
||||
required String chatId,
|
||||
}) async {
|
||||
client = (initCubit.state as InitializationStateSuccess).client;
|
||||
|
||||
privateChatChannel = await client.privateChannel(
|
||||
'private-direct-chat.$chatId',
|
||||
authorizationDelegate: EndpointAuthorizableChannelTokenAuthorizationDelegate.forPrivateChannel(
|
||||
authorizationEndpoint: Uri.parse(baseUrl + '/broadcasting/auth'),
|
||||
headers: {
|
||||
'Authorization': 'Bearer ${await TokenStorage.getTokenFromStorage()}',
|
||||
},
|
||||
),
|
||||
);
|
||||
|
||||
privateChatChannel.subscribe();
|
||||
|
||||
privateChatChannel.bind('App\\Events\\ChatMessageUpdated').listen((event) {
|
||||
List<ChatMessageModel> messagesList = [
|
||||
ChatMessageModel.fromJson(jsonDecode(event.data)['message']),
|
||||
...(state as ChatRoomStateLoaded).chatMessages,
|
||||
];
|
||||
emit(
|
||||
ChatRoomState.loaded(
|
||||
chatRoom: (state as ChatRoomStateLoaded).chatRoom,
|
||||
chatMessages: messagesList,
|
||||
isTyping: (state as ChatRoomStateLoaded).isTyping,
|
||||
isLoading: isLoading,
|
||||
),
|
||||
);
|
||||
});
|
||||
|
||||
privateChatChannel.bind('client-typing').listen((event) {
|
||||
emit(
|
||||
ChatRoomState.loaded(
|
||||
chatRoom: (state as ChatRoomStateLoaded).chatRoom,
|
||||
chatMessages: (state as ChatRoomStateLoaded).chatMessages,
|
||||
isTyping: true,
|
||||
isLoading: isLoading,
|
||||
),
|
||||
);
|
||||
EasyDebounce.debounce(
|
||||
'client-typing',
|
||||
Duration(seconds: 3),
|
||||
() => emit(
|
||||
ChatRoomState.loaded(
|
||||
chatRoom: (state as ChatRoomStateLoaded).chatRoom,
|
||||
chatMessages: (state as ChatRoomStateLoaded).chatMessages,
|
||||
isTyping: false,
|
||||
isLoading: isLoading,
|
||||
),
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
sendMessage({
|
||||
required String chatId,
|
||||
required String data,
|
||||
required List<File> filesList,
|
||||
}) async {
|
||||
await chatRepository.sendMessage(chatId: chatId, data: data);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> close() async {
|
||||
privateChatChannel.unsubscribe();
|
||||
super.close();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import 'package:eatvio_app/features/chat/models/chat_message_model.dart';
|
||||
import 'package:eatvio_app/features/chat/models/chat_room_model.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
||||
@@ -10,7 +11,10 @@ abstract class ChatRoomState with _$ChatRoomState {
|
||||
const factory ChatRoomState.loading() = ChatRoomStateLoading;
|
||||
|
||||
const factory ChatRoomState.loaded({
|
||||
required ChatRoomModel chatRoomModel,
|
||||
required ChatRoomModel chatRoom,
|
||||
required List<ChatMessageModel> chatMessages,
|
||||
required bool isTyping,
|
||||
required bool isLoading,
|
||||
}) = ChatRoomStateLoaded;
|
||||
|
||||
const factory ChatRoomState.error({
|
||||
|
||||
@@ -20,7 +20,9 @@ mixin _$ChatRoomState {
|
||||
TResult when<TResult extends Object?>(
|
||||
TResult Function() $default, {
|
||||
required TResult Function() loading,
|
||||
required TResult Function(ChatRoomModel chatRoomModel) loaded,
|
||||
required TResult Function(ChatRoomModel chatRoom,
|
||||
List<ChatMessageModel> chatMessages, bool isTyping, bool isLoading)
|
||||
loaded,
|
||||
required TResult Function(String errorMessage) error,
|
||||
}) =>
|
||||
throw _privateConstructorUsedError;
|
||||
@@ -28,7 +30,9 @@ mixin _$ChatRoomState {
|
||||
TResult? whenOrNull<TResult extends Object?>(
|
||||
TResult? Function()? $default, {
|
||||
TResult? Function()? loading,
|
||||
TResult? Function(ChatRoomModel chatRoomModel)? loaded,
|
||||
TResult? Function(ChatRoomModel chatRoom,
|
||||
List<ChatMessageModel> chatMessages, bool isTyping, bool isLoading)?
|
||||
loaded,
|
||||
TResult? Function(String errorMessage)? error,
|
||||
}) =>
|
||||
throw _privateConstructorUsedError;
|
||||
@@ -36,7 +40,9 @@ mixin _$ChatRoomState {
|
||||
TResult maybeWhen<TResult extends Object?>(
|
||||
TResult Function()? $default, {
|
||||
TResult Function()? loading,
|
||||
TResult Function(ChatRoomModel chatRoomModel)? loaded,
|
||||
TResult Function(ChatRoomModel chatRoom,
|
||||
List<ChatMessageModel> chatMessages, bool isTyping, bool isLoading)?
|
||||
loaded,
|
||||
TResult Function(String errorMessage)? error,
|
||||
required TResult orElse(),
|
||||
}) =>
|
||||
@@ -126,7 +132,9 @@ class _$ChatRoomStateImpl implements _ChatRoomState {
|
||||
TResult when<TResult extends Object?>(
|
||||
TResult Function() $default, {
|
||||
required TResult Function() loading,
|
||||
required TResult Function(ChatRoomModel chatRoomModel) loaded,
|
||||
required TResult Function(ChatRoomModel chatRoom,
|
||||
List<ChatMessageModel> chatMessages, bool isTyping, bool isLoading)
|
||||
loaded,
|
||||
required TResult Function(String errorMessage) error,
|
||||
}) {
|
||||
return $default();
|
||||
@@ -137,7 +145,9 @@ class _$ChatRoomStateImpl implements _ChatRoomState {
|
||||
TResult? whenOrNull<TResult extends Object?>(
|
||||
TResult? Function()? $default, {
|
||||
TResult? Function()? loading,
|
||||
TResult? Function(ChatRoomModel chatRoomModel)? loaded,
|
||||
TResult? Function(ChatRoomModel chatRoom,
|
||||
List<ChatMessageModel> chatMessages, bool isTyping, bool isLoading)?
|
||||
loaded,
|
||||
TResult? Function(String errorMessage)? error,
|
||||
}) {
|
||||
return $default?.call();
|
||||
@@ -148,7 +158,9 @@ class _$ChatRoomStateImpl implements _ChatRoomState {
|
||||
TResult maybeWhen<TResult extends Object?>(
|
||||
TResult Function()? $default, {
|
||||
TResult Function()? loading,
|
||||
TResult Function(ChatRoomModel chatRoomModel)? loaded,
|
||||
TResult Function(ChatRoomModel chatRoom,
|
||||
List<ChatMessageModel> chatMessages, bool isTyping, bool isLoading)?
|
||||
loaded,
|
||||
TResult Function(String errorMessage)? error,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
@@ -241,7 +253,9 @@ class _$ChatRoomStateLoadingImpl implements ChatRoomStateLoading {
|
||||
TResult when<TResult extends Object?>(
|
||||
TResult Function() $default, {
|
||||
required TResult Function() loading,
|
||||
required TResult Function(ChatRoomModel chatRoomModel) loaded,
|
||||
required TResult Function(ChatRoomModel chatRoom,
|
||||
List<ChatMessageModel> chatMessages, bool isTyping, bool isLoading)
|
||||
loaded,
|
||||
required TResult Function(String errorMessage) error,
|
||||
}) {
|
||||
return loading();
|
||||
@@ -252,7 +266,9 @@ class _$ChatRoomStateLoadingImpl implements ChatRoomStateLoading {
|
||||
TResult? whenOrNull<TResult extends Object?>(
|
||||
TResult? Function()? $default, {
|
||||
TResult? Function()? loading,
|
||||
TResult? Function(ChatRoomModel chatRoomModel)? loaded,
|
||||
TResult? Function(ChatRoomModel chatRoom,
|
||||
List<ChatMessageModel> chatMessages, bool isTyping, bool isLoading)?
|
||||
loaded,
|
||||
TResult? Function(String errorMessage)? error,
|
||||
}) {
|
||||
return loading?.call();
|
||||
@@ -263,7 +279,9 @@ class _$ChatRoomStateLoadingImpl implements ChatRoomStateLoading {
|
||||
TResult maybeWhen<TResult extends Object?>(
|
||||
TResult Function()? $default, {
|
||||
TResult Function()? loading,
|
||||
TResult Function(ChatRoomModel chatRoomModel)? loaded,
|
||||
TResult Function(ChatRoomModel chatRoom,
|
||||
List<ChatMessageModel> chatMessages, bool isTyping, bool isLoading)?
|
||||
loaded,
|
||||
TResult Function(String errorMessage)? error,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
@@ -321,9 +339,13 @@ abstract class _$$ChatRoomStateLoadedImplCopyWith<$Res> {
|
||||
$Res Function(_$ChatRoomStateLoadedImpl) then) =
|
||||
__$$ChatRoomStateLoadedImplCopyWithImpl<$Res>;
|
||||
@useResult
|
||||
$Res call({ChatRoomModel chatRoomModel});
|
||||
$Res call(
|
||||
{ChatRoomModel chatRoom,
|
||||
List<ChatMessageModel> chatMessages,
|
||||
bool isTyping,
|
||||
bool isLoading});
|
||||
|
||||
$ChatRoomModelCopyWith<$Res> get chatRoomModel;
|
||||
$ChatRoomModelCopyWith<$Res> get chatRoom;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@@ -337,21 +359,36 @@ class __$$ChatRoomStateLoadedImplCopyWithImpl<$Res>
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? chatRoomModel = null,
|
||||
Object? chatRoom = null,
|
||||
Object? chatMessages = null,
|
||||
Object? isTyping = null,
|
||||
Object? isLoading = null,
|
||||
}) {
|
||||
return _then(_$ChatRoomStateLoadedImpl(
|
||||
chatRoomModel: null == chatRoomModel
|
||||
? _value.chatRoomModel
|
||||
: chatRoomModel // ignore: cast_nullable_to_non_nullable
|
||||
chatRoom: null == chatRoom
|
||||
? _value.chatRoom
|
||||
: chatRoom // ignore: cast_nullable_to_non_nullable
|
||||
as ChatRoomModel,
|
||||
chatMessages: null == chatMessages
|
||||
? _value._chatMessages
|
||||
: chatMessages // ignore: cast_nullable_to_non_nullable
|
||||
as List<ChatMessageModel>,
|
||||
isTyping: null == isTyping
|
||||
? _value.isTyping
|
||||
: isTyping // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
isLoading: null == isLoading
|
||||
? _value.isLoading
|
||||
: isLoading // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
));
|
||||
}
|
||||
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
$ChatRoomModelCopyWith<$Res> get chatRoomModel {
|
||||
return $ChatRoomModelCopyWith<$Res>(_value.chatRoomModel, (value) {
|
||||
return _then(_value.copyWith(chatRoomModel: value));
|
||||
$ChatRoomModelCopyWith<$Res> get chatRoom {
|
||||
return $ChatRoomModelCopyWith<$Res>(_value.chatRoom, (value) {
|
||||
return _then(_value.copyWith(chatRoom: value));
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -359,14 +396,31 @@ class __$$ChatRoomStateLoadedImplCopyWithImpl<$Res>
|
||||
/// @nodoc
|
||||
|
||||
class _$ChatRoomStateLoadedImpl implements ChatRoomStateLoaded {
|
||||
const _$ChatRoomStateLoadedImpl({required this.chatRoomModel});
|
||||
const _$ChatRoomStateLoadedImpl(
|
||||
{required this.chatRoom,
|
||||
required final List<ChatMessageModel> chatMessages,
|
||||
required this.isTyping,
|
||||
required this.isLoading})
|
||||
: _chatMessages = chatMessages;
|
||||
|
||||
@override
|
||||
final ChatRoomModel chatRoomModel;
|
||||
final ChatRoomModel chatRoom;
|
||||
final List<ChatMessageModel> _chatMessages;
|
||||
@override
|
||||
List<ChatMessageModel> get chatMessages {
|
||||
if (_chatMessages is EqualUnmodifiableListView) return _chatMessages;
|
||||
// ignore: implicit_dynamic_type
|
||||
return EqualUnmodifiableListView(_chatMessages);
|
||||
}
|
||||
|
||||
@override
|
||||
final bool isTyping;
|
||||
@override
|
||||
final bool isLoading;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'ChatRoomState.loaded(chatRoomModel: $chatRoomModel)';
|
||||
return 'ChatRoomState.loaded(chatRoom: $chatRoom, chatMessages: $chatMessages, isTyping: $isTyping, isLoading: $isLoading)';
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -374,12 +428,19 @@ class _$ChatRoomStateLoadedImpl implements ChatRoomStateLoaded {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$ChatRoomStateLoadedImpl &&
|
||||
(identical(other.chatRoomModel, chatRoomModel) ||
|
||||
other.chatRoomModel == chatRoomModel));
|
||||
(identical(other.chatRoom, chatRoom) ||
|
||||
other.chatRoom == chatRoom) &&
|
||||
const DeepCollectionEquality()
|
||||
.equals(other._chatMessages, _chatMessages) &&
|
||||
(identical(other.isTyping, isTyping) ||
|
||||
other.isTyping == isTyping) &&
|
||||
(identical(other.isLoading, isLoading) ||
|
||||
other.isLoading == isLoading));
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType, chatRoomModel);
|
||||
int get hashCode => Object.hash(runtimeType, chatRoom,
|
||||
const DeepCollectionEquality().hash(_chatMessages), isTyping, isLoading);
|
||||
|
||||
@JsonKey(ignore: true)
|
||||
@override
|
||||
@@ -393,10 +454,12 @@ class _$ChatRoomStateLoadedImpl implements ChatRoomStateLoaded {
|
||||
TResult when<TResult extends Object?>(
|
||||
TResult Function() $default, {
|
||||
required TResult Function() loading,
|
||||
required TResult Function(ChatRoomModel chatRoomModel) loaded,
|
||||
required TResult Function(ChatRoomModel chatRoom,
|
||||
List<ChatMessageModel> chatMessages, bool isTyping, bool isLoading)
|
||||
loaded,
|
||||
required TResult Function(String errorMessage) error,
|
||||
}) {
|
||||
return loaded(chatRoomModel);
|
||||
return loaded(chatRoom, chatMessages, isTyping, isLoading);
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -404,10 +467,12 @@ class _$ChatRoomStateLoadedImpl implements ChatRoomStateLoaded {
|
||||
TResult? whenOrNull<TResult extends Object?>(
|
||||
TResult? Function()? $default, {
|
||||
TResult? Function()? loading,
|
||||
TResult? Function(ChatRoomModel chatRoomModel)? loaded,
|
||||
TResult? Function(ChatRoomModel chatRoom,
|
||||
List<ChatMessageModel> chatMessages, bool isTyping, bool isLoading)?
|
||||
loaded,
|
||||
TResult? Function(String errorMessage)? error,
|
||||
}) {
|
||||
return loaded?.call(chatRoomModel);
|
||||
return loaded?.call(chatRoom, chatMessages, isTyping, isLoading);
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -415,12 +480,14 @@ class _$ChatRoomStateLoadedImpl implements ChatRoomStateLoaded {
|
||||
TResult maybeWhen<TResult extends Object?>(
|
||||
TResult Function()? $default, {
|
||||
TResult Function()? loading,
|
||||
TResult Function(ChatRoomModel chatRoomModel)? loaded,
|
||||
TResult Function(ChatRoomModel chatRoom,
|
||||
List<ChatMessageModel> chatMessages, bool isTyping, bool isLoading)?
|
||||
loaded,
|
||||
TResult Function(String errorMessage)? error,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (loaded != null) {
|
||||
return loaded(chatRoomModel);
|
||||
return loaded(chatRoom, chatMessages, isTyping, isLoading);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
@@ -465,9 +532,15 @@ class _$ChatRoomStateLoadedImpl implements ChatRoomStateLoaded {
|
||||
|
||||
abstract class ChatRoomStateLoaded implements ChatRoomState {
|
||||
const factory ChatRoomStateLoaded(
|
||||
{required final ChatRoomModel chatRoomModel}) = _$ChatRoomStateLoadedImpl;
|
||||
{required final ChatRoomModel chatRoom,
|
||||
required final List<ChatMessageModel> chatMessages,
|
||||
required final bool isTyping,
|
||||
required final bool isLoading}) = _$ChatRoomStateLoadedImpl;
|
||||
|
||||
ChatRoomModel get chatRoomModel;
|
||||
ChatRoomModel get chatRoom;
|
||||
List<ChatMessageModel> get chatMessages;
|
||||
bool get isTyping;
|
||||
bool get isLoading;
|
||||
@JsonKey(ignore: true)
|
||||
_$$ChatRoomStateLoadedImplCopyWith<_$ChatRoomStateLoadedImpl> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
@@ -541,7 +614,9 @@ class _$ChatRoomStateErrorImpl implements ChatRoomStateError {
|
||||
TResult when<TResult extends Object?>(
|
||||
TResult Function() $default, {
|
||||
required TResult Function() loading,
|
||||
required TResult Function(ChatRoomModel chatRoomModel) loaded,
|
||||
required TResult Function(ChatRoomModel chatRoom,
|
||||
List<ChatMessageModel> chatMessages, bool isTyping, bool isLoading)
|
||||
loaded,
|
||||
required TResult Function(String errorMessage) error,
|
||||
}) {
|
||||
return error(errorMessage);
|
||||
@@ -552,7 +627,9 @@ class _$ChatRoomStateErrorImpl implements ChatRoomStateError {
|
||||
TResult? whenOrNull<TResult extends Object?>(
|
||||
TResult? Function()? $default, {
|
||||
TResult? Function()? loading,
|
||||
TResult? Function(ChatRoomModel chatRoomModel)? loaded,
|
||||
TResult? Function(ChatRoomModel chatRoom,
|
||||
List<ChatMessageModel> chatMessages, bool isTyping, bool isLoading)?
|
||||
loaded,
|
||||
TResult? Function(String errorMessage)? error,
|
||||
}) {
|
||||
return error?.call(errorMessage);
|
||||
@@ -563,7 +640,9 @@ class _$ChatRoomStateErrorImpl implements ChatRoomStateError {
|
||||
TResult maybeWhen<TResult extends Object?>(
|
||||
TResult Function()? $default, {
|
||||
TResult Function()? loading,
|
||||
TResult Function(ChatRoomModel chatRoomModel)? loaded,
|
||||
TResult Function(ChatRoomModel chatRoom,
|
||||
List<ChatMessageModel> chatMessages, bool isTyping, bool isLoading)?
|
||||
loaded,
|
||||
TResult Function(String errorMessage)? error,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
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:flutter/cupertino.dart';
|
||||
import 'package:eatvio_app/core/app_export.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:lazy_load_scrollview/lazy_load_scrollview.dart';
|
||||
|
||||
class ChatScreen extends StatefulWidget {
|
||||
final String chatId;
|
||||
@@ -19,21 +20,23 @@ class ChatScreen extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _ChatScreenState extends State<ChatScreen> {
|
||||
final scrollController = ScrollController();
|
||||
final TextEditingController textEditingController = TextEditingController();
|
||||
|
||||
Widget build(BuildContext context) {
|
||||
return BlocProvider<ChatRoomCubit>(
|
||||
create: (BuildContext context) => sl()..initChat(widget.chatId),
|
||||
child: BlocBuilder<ChatRoomCubit, ChatRoomState>(
|
||||
builder: (context, state) {
|
||||
if (state is ChatRoomStateLoading) {
|
||||
return Scaffold(
|
||||
body: Center(
|
||||
child: CupertinoActivityIndicator(),
|
||||
),
|
||||
);
|
||||
} else if (state is ChatRoomStateLoaded) {
|
||||
if (state is ChatRoomStateLoaded) {
|
||||
return _buildChat(context, state);
|
||||
} else if (state is ChatRoomStateError) {
|
||||
return Center(child: Text(state.errorMessage));
|
||||
return Scaffold(
|
||||
appBar: AppBar(),
|
||||
body: Center(
|
||||
child: Text(state.errorMessage),
|
||||
),
|
||||
);
|
||||
} else {
|
||||
return Scaffold(
|
||||
body: Center(
|
||||
@@ -47,16 +50,11 @@ class _ChatScreenState extends State<ChatScreen> {
|
||||
}
|
||||
|
||||
_buildChat(BuildContext context, ChatRoomStateLoaded state) {
|
||||
mediaQueryData = MediaQuery.of(context);
|
||||
return Scaffold(
|
||||
resizeToAvoidBottomInset: true,
|
||||
backgroundColor: PrimaryColors().gray50,
|
||||
appBar: AppBar(
|
||||
titleSpacing: 0,
|
||||
centerTitle: false,
|
||||
backgroundColor: Colors.white,
|
||||
forceMaterialTransparency: true,
|
||||
elevation: 0,
|
||||
title: Row(
|
||||
children: [
|
||||
Container(
|
||||
@@ -68,7 +66,7 @@ class _ChatScreenState extends State<ChatScreen> {
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
child: Text(
|
||||
state.chatRoomModel.users['to_chat_user']!.name.split(' ').first[0] + state.chatRoomModel.users['to_chat_user']!.name.split(' ')[1][0],
|
||||
state.chatRoom.users['to_chat_user']!.name.split(' ').first[0] + state.chatRoom.users['to_chat_user']!.name.split(' ')[1][0],
|
||||
style: TextStyle(
|
||||
color: Color(0xFF7F9CF5),
|
||||
fontWeight: FontWeight.w400,
|
||||
@@ -77,11 +75,27 @@ class _ChatScreenState extends State<ChatScreen> {
|
||||
),
|
||||
),
|
||||
SizedBox(width: 16),
|
||||
Text(
|
||||
state.chatRoomModel.users['to_chat_user']!.name,
|
||||
style: CustomTextStyles.titleSmallBold.copyWith(
|
||||
color: PrimaryColors().blueGray800,
|
||||
),
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
state.chatRoom.users['to_chat_user']!.name,
|
||||
style: CustomTextStyles.titleSmallBold.copyWith(
|
||||
color: PrimaryColors().blueGray800,
|
||||
),
|
||||
),
|
||||
AnimatedCrossFade(
|
||||
firstChild: Text(
|
||||
'Печатает...',
|
||||
style: CustomTextStyles.bodySmallMulishPrimary,
|
||||
),
|
||||
firstCurve: Curves.easeIn,
|
||||
secondCurve: Curves.easeOut,
|
||||
secondChild: const SizedBox.shrink(),
|
||||
crossFadeState: state.isTyping ? CrossFadeState.showFirst : CrossFadeState.showSecond,
|
||||
duration: Duration(milliseconds: 150),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -94,24 +108,39 @@ class _ChatScreenState extends State<ChatScreen> {
|
||||
child: Container(
|
||||
color: Color(0xFFF0F2F5),
|
||||
width: double.maxFinite,
|
||||
child: CustomScrollView(
|
||||
reverse: true,
|
||||
slivers: [
|
||||
SliverPadding(
|
||||
padding: EdgeInsets.symmetric(vertical: 16),
|
||||
sliver: SliverList(
|
||||
delegate: SliverChildBuilderDelegate(
|
||||
(context, index) => ChatBubbleWidget(
|
||||
text: state.chatRoomModel.messages[state.chatRoomModel.messages.length - index - 1].data,
|
||||
isCurrentUser: state.chatRoomModel.users['to_chat_user']!.id !=
|
||||
state.chatRoomModel.messages[state.chatRoomModel.messages.length - index - 1].authorId,
|
||||
mediaData: state.chatRoomModel.messages[state.chatRoomModel.messages.length - index - 1].mediaData,
|
||||
child: LazyLoadScrollView(
|
||||
onEndOfPage: () => context.read<ChatRoomCubit>().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(
|
||||
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),
|
||||
),
|
||||
childCount: state.chatRoomModel.messages.length,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -123,7 +152,7 @@ class _ChatScreenState extends State<ChatScreen> {
|
||||
SizedBox(width: 8),
|
||||
InkWell(
|
||||
onTap: () {},
|
||||
borderRadius: BorderRadiusStyle.circleBorder17,
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
child: Ink(
|
||||
height: 32,
|
||||
width: 32,
|
||||
@@ -138,12 +167,12 @@ class _ChatScreenState extends State<ChatScreen> {
|
||||
SizedBox(
|
||||
width: mediaQueryData.size.width - 96,
|
||||
child: TextFormField(
|
||||
controller: textEditingController,
|
||||
maxLines: 5,
|
||||
minLines: 1,
|
||||
keyboardType: TextInputType.multiline,
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontFamily: 'Mulish',
|
||||
fontWeight: FontWeight.w400,
|
||||
color: Colors.black,
|
||||
),
|
||||
@@ -152,27 +181,26 @@ class _ChatScreenState extends State<ChatScreen> {
|
||||
hintText: 'Сообщение',
|
||||
hintStyle: TextStyle(
|
||||
fontSize: 16,
|
||||
fontFamily: 'Mulish',
|
||||
fontWeight: FontWeight.w400,
|
||||
color: Color(0xFFAEAEB2),
|
||||
),
|
||||
filled: true,
|
||||
border: OutlineInputBorder(
|
||||
borderRadius: BorderRadiusStyle.circleBorder17,
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
borderSide: BorderSide(
|
||||
color: Color(0xFFD1D1D6),
|
||||
width: 1,
|
||||
),
|
||||
),
|
||||
enabledBorder: OutlineInputBorder(
|
||||
borderRadius: BorderRadiusStyle.circleBorder17,
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
borderSide: BorderSide(
|
||||
color: Color(0xFFD1D1D6),
|
||||
width: 1,
|
||||
),
|
||||
),
|
||||
focusedBorder: OutlineInputBorder(
|
||||
borderRadius: BorderRadiusStyle.circleBorder17,
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
borderSide: BorderSide(
|
||||
color: Color(0xFFD1D1D6),
|
||||
width: 1,
|
||||
@@ -183,8 +211,19 @@ class _ChatScreenState extends State<ChatScreen> {
|
||||
),
|
||||
SizedBox(width: 8),
|
||||
InkWell(
|
||||
borderRadius: BorderRadiusStyle.circleBorder17,
|
||||
onTap: () {},
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
onTap: () {
|
||||
if (textEditingController.text.isNotEmpty) {
|
||||
context.read<ChatRoomCubit>().sendMessage(
|
||||
chatId: widget.chatId,
|
||||
data: textEditingController.text.trim(),
|
||||
filesList: [],
|
||||
);
|
||||
setState(() {
|
||||
textEditingController.clear();
|
||||
});
|
||||
}
|
||||
},
|
||||
child: Ink(
|
||||
height: 32,
|
||||
width: 32,
|
||||
|
||||
@@ -1,16 +1,17 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:eatvio_app/app_router.dart';
|
||||
import 'package:eatvio_app/features/chat/presentation/pages/chat_select_screen/models/chat_entry.dart';
|
||||
import 'package:eatvio_app/features/chat/presentation/pages/chat_select_screen/models/chat_select_model.dart';
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:hive/hive.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:flutter_dotenv/flutter_dotenv.dart';
|
||||
import 'dart:convert';
|
||||
|
||||
import '/core/app_export.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
|
||||
part 'chat_select_event.dart';
|
||||
part 'chat_select_state.dart';
|
||||
@@ -26,20 +27,21 @@ class ChatSelectBloc extends Bloc<ChatSelectEvent, ChatSelectState> {
|
||||
List<ChatItemModel> fillChatEntryList(List<dynamic> chatRooms) {
|
||||
List<ChatItemModel> chats = [];
|
||||
for (int i = 0; i < chatRooms.length; i++) {
|
||||
String text = chatRooms[i]['last_message']['data'];
|
||||
if (chatRooms[i]['last_message']['is_author_message_auth_user'] != null) {
|
||||
String text = chatRooms[i]['last_message'] is List ? '' : chatRooms[i]['last_message']['data'];
|
||||
if (chatRooms[i]['last_message'] is! List && chatRooms[i]['last_message']['is_author_message_auth_user'] != null) {
|
||||
text = "Вы: " + text;
|
||||
}
|
||||
chats.add(
|
||||
ChatItemModel(
|
||||
id: chatRooms[i]['id'],
|
||||
userImage: chatRooms[i]['users']['to_chat_user']['profile_photo_path'],
|
||||
username: chatRooms[i]['users']['to_chat_user']['name'],
|
||||
dateText: DateFormat('dd.MM').format(
|
||||
DateTime.parse(
|
||||
chatRooms[i]['last_message']['updated_at'],
|
||||
),
|
||||
),
|
||||
dateText: chatRooms[i]['last_message'] is List
|
||||
? ''
|
||||
: DateFormat('dd.MM').format(
|
||||
DateTime.parse(
|
||||
chatRooms[i]['last_message']['updated_at'],
|
||||
),
|
||||
),
|
||||
greetingText: text,
|
||||
),
|
||||
);
|
||||
@@ -58,7 +60,7 @@ class ChatSelectBloc extends Bloc<ChatSelectEvent, ChatSelectState> {
|
||||
AppRouter.navigatorKey.currentContext?.goNamed('authScreen');
|
||||
}
|
||||
final response = await http.get(
|
||||
Uri.parse(dotenv.env['SERVER_ROOT']! + '/chat/index'),
|
||||
Uri.parse(baseUrl + '/api/chat/index'),
|
||||
headers: {
|
||||
'Authorization': 'Bearer $token',
|
||||
},
|
||||
@@ -68,15 +70,19 @@ class ChatSelectBloc extends Bloc<ChatSelectEvent, ChatSelectState> {
|
||||
if (data is Map<String, dynamic> && data.containsKey('chatRooms')) {
|
||||
if (state is ChatSelectLoadedState) {
|
||||
var currentState = state as ChatSelectLoadedState;
|
||||
emit(currentState.copyWith(
|
||||
chatSelectModelObj: currentState.chatSelectModelObj,
|
||||
chatRooms: currentState.chatRooms,
|
||||
),);
|
||||
emit(
|
||||
currentState.copyWith(
|
||||
chatSelectModelObj: currentState.chatSelectModelObj,
|
||||
chatRooms: currentState.chatRooms,
|
||||
),
|
||||
);
|
||||
} else {
|
||||
emit(ChatSelectLoadedState(
|
||||
chatRooms: fillChatEntryList(data['chatRooms']),
|
||||
//chatRooms: [],
|
||||
),);
|
||||
emit(
|
||||
ChatSelectLoadedState(
|
||||
chatRooms: fillChatEntryList(data['chatRooms']),
|
||||
//chatRooms: [],
|
||||
),
|
||||
);
|
||||
}
|
||||
} else {
|
||||
// Один или несколько ключевых полей отсутствуют, обрабатываем ошибку
|
||||
|
||||
@@ -12,6 +12,7 @@ class ChatSelectState extends Equatable {
|
||||
|
||||
@override
|
||||
List<Object?> get props => [chatSelectModelObj];
|
||||
|
||||
ChatSelectState copyWith({ChatSelectModel? chatSelectModelObj}) {
|
||||
return ChatSelectState(
|
||||
chatSelectModelObj: chatSelectModelObj ?? this.chatSelectModelObj,
|
||||
@@ -20,8 +21,7 @@ class ChatSelectState extends Equatable {
|
||||
}
|
||||
|
||||
class ChatSelectInitialState extends ChatSelectState {
|
||||
ChatSelectInitialState({required ChatSelectModel chatSelectModelObj})
|
||||
: super(chatSelectModelObj: chatSelectModelObj);
|
||||
ChatSelectInitialState({required ChatSelectModel chatSelectModelObj}) : super(chatSelectModelObj: chatSelectModelObj);
|
||||
}
|
||||
|
||||
class ChatSelectLoadedState extends ChatSelectState {
|
||||
@@ -30,11 +30,14 @@ class ChatSelectLoadedState extends ChatSelectState {
|
||||
this.searchController,
|
||||
this.chatSelectModelObj,
|
||||
}) : super(chatSelectModelObj: null);
|
||||
|
||||
List<dynamic>? chatRooms;
|
||||
TextEditingController? searchController;
|
||||
ChatSelectModel? chatSelectModelObj;
|
||||
|
||||
@override
|
||||
List<Object?> get props => [chatSelectModelObj, chatRooms, searchController];
|
||||
|
||||
ChatSelectLoadedState copyWith({
|
||||
ChatSelectModel? chatSelectModelObj,
|
||||
TextEditingController? searchController,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:eatvio_app/core/app_export.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class CustomSearchView extends StatelessWidget {
|
||||
CustomSearchView({
|
||||
@@ -103,7 +103,7 @@ class CustomSearchView extends StatelessWidget {
|
||||
hintStyle: hintStyle ?? CustomTextStyles.bodySmallMulishBluegray800,
|
||||
prefixIcon: prefix ??
|
||||
Padding(
|
||||
padding: EdgeInsets.only(left: 10),
|
||||
padding: EdgeInsets.only(left: 12),
|
||||
child: Icon(
|
||||
Icons.search,
|
||||
color: Color(0xFF7B8794),
|
||||
@@ -127,17 +127,17 @@ class CustomSearchView extends StatelessWidget {
|
||||
filled: filled,
|
||||
border: borderDecoration ??
|
||||
OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(8.h),
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
borderSide: BorderSide.none,
|
||||
),
|
||||
enabledBorder: borderDecoration ??
|
||||
OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(8.h),
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
borderSide: BorderSide.none,
|
||||
),
|
||||
focusedBorder: borderDecoration ??
|
||||
OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(8.h),
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
borderSide: BorderSide.none,
|
||||
),
|
||||
);
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user