diff --git a/android/.kotlin/errors/errors-1729261970802.log b/android/.kotlin/errors/errors-1729261970802.log new file mode 100644 index 00000000..7cd151b6 --- /dev/null +++ b/android/.kotlin/errors/errors-1729261970802.log @@ -0,0 +1,4 @@ +kotlin version: 2.0.20 +error message: The daemon has terminated unexpectedly on startup attempt #1 with error code: 0. The daemon process output: + 1. Kotlin compile daemon is ready + diff --git a/android/app/build.gradle b/android/app/build.gradle index 46a74368..8a009c79 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -10,12 +10,12 @@ android { ndkVersion = "25.1.8937393" compileOptions { - sourceCompatibility = JavaVersion.VERSION_1_8 - targetCompatibility = JavaVersion.VERSION_1_8 + sourceCompatibility JavaVersion.VERSION_17 + targetCompatibility JavaVersion.VERSION_17 } kotlinOptions { - jvmTarget = JavaVersion.VERSION_1_8 + jvmTarget = 17 } defaultConfig { diff --git a/android/build.gradle b/android/build.gradle index bc157bd1..002c6222 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -1,4 +1,7 @@ allprojects { + tasks.withType(JavaCompile) { + options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation" + } repositories { google() mavenCentral() diff --git a/android/gradle/wrapper/gradle-wrapper.properties b/android/gradle/wrapper/gradle-wrapper.properties index e6b38c2d..db18181a 100644 --- a/android/gradle/wrapper/gradle-wrapper.properties +++ b/android/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-all.zip diff --git a/android/settings.gradle b/android/settings.gradle index ff583230..b5e1b3f5 100644 --- a/android/settings.gradle +++ b/android/settings.gradle @@ -18,7 +18,7 @@ pluginManagement { plugins { id "dev.flutter.flutter-plugin-loader" version "1.0.0" - id "com.android.application" version "8.1.4" apply false + id "com.android.application" version "8.3.2" apply false id "org.jetbrains.kotlin.android" version "2.0.20" apply false } diff --git a/lib/app_router.dart b/lib/app_router.dart index 2f1f53e4..d88156f1 100644 --- a/lib/app_router.dart +++ b/lib/app_router.dart @@ -75,43 +75,38 @@ class AppRouter { }, routes: [ GoRoute( - pageBuilder: (context, state) => NoTransitionPage(child: ProfileScreen()), path: '/my-profile-screen', name: 'myProfileScreen', redirect: (context, state) async { await context.read().runInitialization(); return null; }, + builder: (context, state) => ProfileScreen(), ), GoRoute( - pageBuilder: (context, state) => NoTransitionPage(child: FeedScreen()), path: '/feed-screen', name: 'feedScreen', + builder: (context, state) => FeedScreen(), ), GoRoute( - pageBuilder: (context, state) { - if (state.extra != null) - return NoTransitionPage(child: DiaryScreen(diaryID: state.extra as String)); - else - return NoTransitionPage(child: DiaryScreen(diaryID: '0')); - }, path: '/diary-screen', name: 'diaryScreen', + builder: (context, state) => DiaryScreen(), ), GoRoute( - pageBuilder: (context, state) => NoTransitionPage(child: ChatSelectScreen()), path: '/chat-select-screen', name: 'chatSelectScreen', + builder: (context, state) => ChatSelectScreen(), ), GoRoute( - pageBuilder: (context, state) => NoTransitionPage(child: NotificationsScreen()), path: '/notifications-screen', name: 'notificationsScreen', + builder: (context, state) => NotificationsScreen(), ), GoRoute( - pageBuilder: (context, state) => NoTransitionPage(child: MenuScreen()), path: '/menu-screen', name: 'menuScreen', + builder: (context, state) => MenuScreen(), ), ], ), diff --git a/lib/features/blog_post_create/repositories/blog_repository.dart b/lib/features/blog_post_create/repositories/blog_repository.dart index 3d1846a4..e69de29b 100644 --- a/lib/features/blog_post_create/repositories/blog_repository.dart +++ b/lib/features/blog_post_create/repositories/blog_repository.dart @@ -1,21 +0,0 @@ -/* -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 createBlogPost(BlogPostCreateCredentialsModel model) async { - try { - return (await blogService.createBlogPost(model)); - } catch (e) { - print(e); - throw (e); - } - } -} -*/ diff --git a/lib/features/blog_post_create/services/blog_post_service.g.dart b/lib/features/blog_post_create/services/blog_post_service.g.dart index fab2c34d..b104b16e 100644 --- a/lib/features/blog_post_create/services/blog_post_service.g.dart +++ b/lib/features/blog_post_create/services/blog_post_service.g.dart @@ -6,7 +6,7 @@ part of 'blog_post_service.dart'; // RetrofitGenerator // ************************************************************************** -// ignore_for_file: unnecessary_brace_in_string_interps,no_leading_underscores_for_local_identifiers,unused_element +// ignore_for_file: unnecessary_brace_in_string_interps,no_leading_underscores_for_local_identifiers,unused_element,unnecessary_string_interpolations class _BlogPostService implements BlogPostService { _BlogPostService( diff --git a/lib/features/bottom_navigation_bar/presentation/bloc/profile_avatar_cubit/profile_avatar_cubit.dart b/lib/features/bottom_navigation_bar/presentation/bloc/profile_avatar_cubit/profile_avatar_cubit.dart index c6d83825..629e3d26 100644 --- a/lib/features/bottom_navigation_bar/presentation/bloc/profile_avatar_cubit/profile_avatar_cubit.dart +++ b/lib/features/bottom_navigation_bar/presentation/bloc/profile_avatar_cubit/profile_avatar_cubit.dart @@ -16,7 +16,6 @@ class ProfileAvatarCubit extends Cubit { )); } catch (e) { emit(ProfileAvatarState.error(errorMessage: e.toString())); - print(e); } } } diff --git a/lib/features/calendar/presentation/pages/calendar_screen.dart b/lib/features/calendar/presentation/pages/calendar_screen.dart index be3f22ed..cf9ca83e 100644 --- a/lib/features/calendar/presentation/pages/calendar_screen.dart +++ b/lib/features/calendar/presentation/pages/calendar_screen.dart @@ -163,7 +163,6 @@ class CalendarScreen extends StatelessWidget { ); } else { diary = state.calendarList[index].diary as Map; - print(state.calendarList[index]); return InkWell( borderRadius: BorderRadiusStyle.circleBorder8, onTap: () => GoRouter.of(context).go( diff --git a/lib/features/calendar/services/calendar_service.g.dart b/lib/features/calendar/services/calendar_service.g.dart index 903145dc..787983c8 100644 --- a/lib/features/calendar/services/calendar_service.g.dart +++ b/lib/features/calendar/services/calendar_service.g.dart @@ -6,7 +6,7 @@ part of 'calendar_service.dart'; // RetrofitGenerator // ************************************************************************** -// ignore_for_file: unnecessary_brace_in_string_interps,no_leading_underscores_for_local_identifiers,unused_element +// ignore_for_file: unnecessary_brace_in_string_interps,no_leading_underscores_for_local_identifiers,unused_element,unnecessary_string_interpolations class _CalendarService implements CalendarService { _CalendarService( diff --git a/lib/features/chat/presentation/bloc/chat_room_cubit/chat_room_cubit.dart b/lib/features/chat/presentation/bloc/chat_room_cubit/chat_room_cubit.dart index 413ff885..ef4a3f3a 100644 --- a/lib/features/chat/presentation/bloc/chat_room_cubit/chat_room_cubit.dart +++ b/lib/features/chat/presentation/bloc/chat_room_cubit/chat_room_cubit.dart @@ -53,7 +53,6 @@ class ChatRoomCubit extends Cubit { currentPage++; } catch (e) { - print(e); emit(ChatRoomState.error(errorMessage: 'Ошибка получеия данных')); } } @@ -75,7 +74,6 @@ class ChatRoomCubit extends Cubit { isLoading: isLoading, )); } catch (e) { - print(e); emit(ChatRoomState.error(errorMessage: 'Ошибка получеия данных')); } } diff --git a/lib/features/chat/presentation/bloc/chat_select_cubit/chat_select_cubit.dart b/lib/features/chat/presentation/bloc/chat_select_cubit/chat_select_cubit.dart index d3edddc8..6c119f19 100644 --- a/lib/features/chat/presentation/bloc/chat_select_cubit/chat_select_cubit.dart +++ b/lib/features/chat/presentation/bloc/chat_select_cubit/chat_select_cubit.dart @@ -13,7 +13,7 @@ class ChatSelectCubit extends Cubit { emit(ChatSelectState.loading()); try { emit(ChatSelectState.loaded( - chatRooms: (await chatRepository.getChatRoomPreiews(query: query)), + chatRooms: (await chatRepository.getChatRoomPreviews(query: query)), )); } catch (e) { emit( diff --git a/lib/features/chat/presentation/pages/photo_view_screen.dart b/lib/features/chat/presentation/pages/photo_view_screen.dart index b7fce0c5..6148c52c 100644 --- a/lib/features/chat/presentation/pages/photo_view_screen.dart +++ b/lib/features/chat/presentation/pages/photo_view_screen.dart @@ -70,9 +70,9 @@ class _PhotoViewScreenState extends State { body: SafeArea( child: Column( children: [ - SizedBox(height: 32), + const SizedBox(height: 32), Text('Файл'), - SizedBox(height: 8), + const SizedBox(height: 8), ListTile( shape: RoundedRectangleBorder( borderRadius: BorderRadiusStyle.circleBorder17, diff --git a/lib/features/chat/presentation/widgets/chat_entry_widget.dart b/lib/features/chat/presentation/widgets/chat_entry_widget.dart index e8150dc1..19c69160 100644 --- a/lib/features/chat/presentation/widgets/chat_entry_widget.dart +++ b/lib/features/chat/presentation/widgets/chat_entry_widget.dart @@ -55,7 +55,7 @@ class _ChatEntryWidgetState extends State { ), backgroundColor: Colors.white, ), - SizedBox(width: 12), + const SizedBox(width: 12), Expanded( child: Column( crossAxisAlignment: CrossAxisAlignment.start, diff --git a/lib/features/chat/repositories/chat_repository.dart b/lib/features/chat/repositories/chat_repository.dart index f83fa563..228709f6 100644 --- a/lib/features/chat/repositories/chat_repository.dart +++ b/lib/features/chat/repositories/chat_repository.dart @@ -41,7 +41,6 @@ class ChatRepository { media_data: multipartFiles.isEmpty ? null : multipartFiles, ); } catch (e) { - print(e); rethrow; } } @@ -50,16 +49,14 @@ class ChatRepository { try { return (await chatService.getChatRoom(id: chatId))['chatRoom']!; } catch (e) { - print(e); rethrow; } } - Future> getChatRoomPreiews({String? query}) async { + Future> getChatRoomPreviews({String? query}) async { try { return (await chatService.getChatRoomPreviews(query: query)).chatRooms; } catch (e) { - print(e); rethrow; } } @@ -68,7 +65,6 @@ class ChatRepository { try { return (await chatService.getChatMessages(id: chatId, page: page)); } catch (e) { - print(e); rethrow; } } @@ -77,7 +73,14 @@ class ChatRepository { try { return (await chatService.getWebsocket()); } catch (e) { - print(e); + rethrow; + } + } + + Future getChatRoomIdByUserSlug({required String slug}) async { + try { + return (await chatService.getChatRoomIdByUserSlug(user: slug)); + } catch (e) { rethrow; } } diff --git a/lib/features/chat/services/chat_service.g.dart b/lib/features/chat/services/chat_service.g.dart index 77366053..978a0e43 100644 --- a/lib/features/chat/services/chat_service.g.dart +++ b/lib/features/chat/services/chat_service.g.dart @@ -6,7 +6,7 @@ part of 'chat_service.dart'; // RetrofitGenerator // ************************************************************************** -// ignore_for_file: unnecessary_brace_in_string_interps,no_leading_underscores_for_local_identifiers,unused_element +// ignore_for_file: unnecessary_brace_in_string_interps,no_leading_underscores_for_local_identifiers,unused_element,unnecessary_string_interpolations class _ChatService implements ChatService { _ChatService( diff --git a/lib/features/consultant/become_consultant/repositories/consultant_repository.dart b/lib/features/consultant/become_consultant/repositories/consultant_repository.dart index f0ea7897..3abdc799 100644 --- a/lib/features/consultant/become_consultant/repositories/consultant_repository.dart +++ b/lib/features/consultant/become_consultant/repositories/consultant_repository.dart @@ -19,7 +19,6 @@ class ConsultantRepository { consultantModel: consultant, ); } catch (e) { - print(e); rethrow; } } @@ -44,7 +43,6 @@ class ConsultantRepository { photos: multipartFiles.isEmpty ? null : multipartFiles, ); } catch (e) { - print(e); rethrow; } } diff --git a/lib/features/consultant/become_consultant/services/consultant_service.g.dart b/lib/features/consultant/become_consultant/services/consultant_service.g.dart index 870c1d5d..d895b861 100644 --- a/lib/features/consultant/become_consultant/services/consultant_service.g.dart +++ b/lib/features/consultant/become_consultant/services/consultant_service.g.dart @@ -6,7 +6,7 @@ part of 'consultant_service.dart'; // RetrofitGenerator // ************************************************************************** -// ignore_for_file: unnecessary_brace_in_string_interps,no_leading_underscores_for_local_identifiers,unused_element +// ignore_for_file: unnecessary_brace_in_string_interps,no_leading_underscores_for_local_identifiers,unused_element,unnecessary_string_interpolations class _ConsultantService implements ConsultantService { _ConsultantService( diff --git a/lib/features/diary/models/diary_day_model.dart b/lib/features/diary/models/diary_day_model.dart new file mode 100644 index 00000000..773920dc --- /dev/null +++ b/lib/features/diary/models/diary_day_model.dart @@ -0,0 +1,80 @@ +import 'package:freezed_annotation/freezed_annotation.dart'; + +part 'diary_day_model.freezed.dart'; + +part 'diary_day_model.g.dart'; + +@freezed +class DiaryDayWrapperModel with _$DiaryDayWrapperModel { + const factory DiaryDayWrapperModel({ + @JsonKey(name: "diary") required DiaryDayModel diary, + }) = _DiaryDayWrapperModel; + + factory DiaryDayWrapperModel.fromJson(Map json) => _$DiaryDayWrapperModelFromJson(json); +} + +@freezed +class DiaryDayModel with _$DiaryDayModel { + const factory DiaryDayModel({ + @JsonKey(name: "id") required int id, + @JsonKey(name: "date") required String date, + @JsonKey(name: "wakeup") String? wakeup, + @JsonKey(name: "retire") String? retire, + @JsonKey(name: "closed") required int closed, + @JsonKey(name: "comment") required String comment, + @JsonKey(name: "state") required TypeOfDiaryModel typeOfDiary, + @JsonKey(name: "meals") required List meals, + }) = _DiaryDayModel; + + factory DiaryDayModel.fromJson(Map json) => _$DiaryDayModelFromJson(json); +} + +@freezed +class MealModel with _$MealModel { + const factory MealModel({ + @JsonKey(name: "id") required int id, + @JsonKey(name: "time") required String time, + @JsonKey(name: "type") required int type, + @JsonKey(name: "satiety") required int satiety, + @JsonKey(name: "mood") required int mood, + @JsonKey(name: "portions") required List portions, + @JsonKey(name: "photos") required List photos, + }) = _MealModel; + + factory MealModel.fromJson(Map json) => _$MealModelFromJson(json); +} + +@freezed +class DiaryPhotoModel with _$DiaryPhotoModel { + const factory DiaryPhotoModel({ + @JsonKey(name: "id") required String id, + @JsonKey(name: "original_name") required String originalName, + @JsonKey(name: "path") required String path, + @JsonKey(name: "size") required String size, + }) = _DiaryPhotoModel; + + factory DiaryPhotoModel.fromJson(Map json) => _$DiaryPhotoModelFromJson(json); +} + +@freezed +class Portion with _$Portion { + const factory Portion({ + @JsonKey(name: "id") required int id, + @JsonKey(name: "product_name") required String productName, + @JsonKey(name: "quantity") required int quantity, + @JsonKey(name: "portion") required String portion, + @JsonKey(name: "from_diet") required bool fromDiet, + }) = _Portion; + + factory Portion.fromJson(Map json) => _$PortionFromJson(json); +} + +@freezed +class TypeOfDiaryModel with _$TypeOfDiaryModel { + const factory TypeOfDiaryModel({ + @JsonKey(name: "has_chosen_diet") required bool hasChosenDiet, + @JsonKey(name: "has_chosen_plan") required bool hasChosenPlan, + }) = _TypeOfDiaryModel; + + factory TypeOfDiaryModel.fromJson(Map json) => _$TypeOfDiaryModelFromJson(json); +} diff --git a/lib/features/diary/models/diary_day_model.freezed.dart b/lib/features/diary/models/diary_day_model.freezed.dart new file mode 100644 index 00000000..dc780145 --- /dev/null +++ b/lib/features/diary/models/diary_day_model.freezed.dart @@ -0,0 +1,1504 @@ +// 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 'diary_day_model.dart'; + +// ************************************************************************** +// FreezedGenerator +// ************************************************************************** + +T _$identity(T value) => value; + +final _privateConstructorUsedError = UnsupportedError( + 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models'); + +DiaryDayWrapperModel _$DiaryDayWrapperModelFromJson(Map json) { + return _DiaryDayWrapperModel.fromJson(json); +} + +/// @nodoc +mixin _$DiaryDayWrapperModel { + @JsonKey(name: "diary") + DiaryDayModel get diary => throw _privateConstructorUsedError; + + /// Serializes this DiaryDayWrapperModel to a JSON map. + Map toJson() => throw _privateConstructorUsedError; + + /// Create a copy of DiaryDayWrapperModel + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $DiaryDayWrapperModelCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $DiaryDayWrapperModelCopyWith<$Res> { + factory $DiaryDayWrapperModelCopyWith(DiaryDayWrapperModel value, + $Res Function(DiaryDayWrapperModel) then) = + _$DiaryDayWrapperModelCopyWithImpl<$Res, DiaryDayWrapperModel>; + @useResult + $Res call({@JsonKey(name: "diary") DiaryDayModel diary}); + + $DiaryDayModelCopyWith<$Res> get diary; +} + +/// @nodoc +class _$DiaryDayWrapperModelCopyWithImpl<$Res, + $Val extends DiaryDayWrapperModel> + implements $DiaryDayWrapperModelCopyWith<$Res> { + _$DiaryDayWrapperModelCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of DiaryDayWrapperModel + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? diary = null, + }) { + return _then(_value.copyWith( + diary: null == diary + ? _value.diary + : diary // ignore: cast_nullable_to_non_nullable + as DiaryDayModel, + ) as $Val); + } + + /// Create a copy of DiaryDayWrapperModel + /// with the given fields replaced by the non-null parameter values. + @override + @pragma('vm:prefer-inline') + $DiaryDayModelCopyWith<$Res> get diary { + return $DiaryDayModelCopyWith<$Res>(_value.diary, (value) { + return _then(_value.copyWith(diary: value) as $Val); + }); + } +} + +/// @nodoc +abstract class _$$DiaryDayWrapperModelImplCopyWith<$Res> + implements $DiaryDayWrapperModelCopyWith<$Res> { + factory _$$DiaryDayWrapperModelImplCopyWith(_$DiaryDayWrapperModelImpl value, + $Res Function(_$DiaryDayWrapperModelImpl) then) = + __$$DiaryDayWrapperModelImplCopyWithImpl<$Res>; + @override + @useResult + $Res call({@JsonKey(name: "diary") DiaryDayModel diary}); + + @override + $DiaryDayModelCopyWith<$Res> get diary; +} + +/// @nodoc +class __$$DiaryDayWrapperModelImplCopyWithImpl<$Res> + extends _$DiaryDayWrapperModelCopyWithImpl<$Res, _$DiaryDayWrapperModelImpl> + implements _$$DiaryDayWrapperModelImplCopyWith<$Res> { + __$$DiaryDayWrapperModelImplCopyWithImpl(_$DiaryDayWrapperModelImpl _value, + $Res Function(_$DiaryDayWrapperModelImpl) _then) + : super(_value, _then); + + /// Create a copy of DiaryDayWrapperModel + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? diary = null, + }) { + return _then(_$DiaryDayWrapperModelImpl( + diary: null == diary + ? _value.diary + : diary // ignore: cast_nullable_to_non_nullable + as DiaryDayModel, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$DiaryDayWrapperModelImpl implements _DiaryDayWrapperModel { + const _$DiaryDayWrapperModelImpl( + {@JsonKey(name: "diary") required this.diary}); + + factory _$DiaryDayWrapperModelImpl.fromJson(Map json) => + _$$DiaryDayWrapperModelImplFromJson(json); + + @override + @JsonKey(name: "diary") + final DiaryDayModel diary; + + @override + String toString() { + return 'DiaryDayWrapperModel(diary: $diary)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$DiaryDayWrapperModelImpl && + (identical(other.diary, diary) || other.diary == diary)); + } + + @JsonKey(includeFromJson: false, includeToJson: false) + @override + int get hashCode => Object.hash(runtimeType, diary); + + /// Create a copy of DiaryDayWrapperModel + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$DiaryDayWrapperModelImplCopyWith<_$DiaryDayWrapperModelImpl> + get copyWith => + __$$DiaryDayWrapperModelImplCopyWithImpl<_$DiaryDayWrapperModelImpl>( + this, _$identity); + + @override + Map toJson() { + return _$$DiaryDayWrapperModelImplToJson( + this, + ); + } +} + +abstract class _DiaryDayWrapperModel implements DiaryDayWrapperModel { + const factory _DiaryDayWrapperModel( + {@JsonKey(name: "diary") required final DiaryDayModel diary}) = + _$DiaryDayWrapperModelImpl; + + factory _DiaryDayWrapperModel.fromJson(Map json) = + _$DiaryDayWrapperModelImpl.fromJson; + + @override + @JsonKey(name: "diary") + DiaryDayModel get diary; + + /// Create a copy of DiaryDayWrapperModel + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + _$$DiaryDayWrapperModelImplCopyWith<_$DiaryDayWrapperModelImpl> + get copyWith => throw _privateConstructorUsedError; +} + +DiaryDayModel _$DiaryDayModelFromJson(Map json) { + return _DiaryDayModel.fromJson(json); +} + +/// @nodoc +mixin _$DiaryDayModel { + @JsonKey(name: "id") + int get id => throw _privateConstructorUsedError; + @JsonKey(name: "date") + String get date => throw _privateConstructorUsedError; + @JsonKey(name: "wakeup") + String? get wakeup => throw _privateConstructorUsedError; + @JsonKey(name: "retire") + String? get retire => throw _privateConstructorUsedError; + @JsonKey(name: "closed") + int get closed => throw _privateConstructorUsedError; + @JsonKey(name: "comment") + String get comment => throw _privateConstructorUsedError; + @JsonKey(name: "state") + TypeOfDiaryModel get typeOfDiary => throw _privateConstructorUsedError; + @JsonKey(name: "meals") + List get meals => throw _privateConstructorUsedError; + + /// Serializes this DiaryDayModel to a JSON map. + Map toJson() => throw _privateConstructorUsedError; + + /// Create a copy of DiaryDayModel + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $DiaryDayModelCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $DiaryDayModelCopyWith<$Res> { + factory $DiaryDayModelCopyWith( + DiaryDayModel value, $Res Function(DiaryDayModel) then) = + _$DiaryDayModelCopyWithImpl<$Res, DiaryDayModel>; + @useResult + $Res call( + {@JsonKey(name: "id") int id, + @JsonKey(name: "date") String date, + @JsonKey(name: "wakeup") String? wakeup, + @JsonKey(name: "retire") String? retire, + @JsonKey(name: "closed") int closed, + @JsonKey(name: "comment") String comment, + @JsonKey(name: "state") TypeOfDiaryModel typeOfDiary, + @JsonKey(name: "meals") List meals}); + + $TypeOfDiaryModelCopyWith<$Res> get typeOfDiary; +} + +/// @nodoc +class _$DiaryDayModelCopyWithImpl<$Res, $Val extends DiaryDayModel> + implements $DiaryDayModelCopyWith<$Res> { + _$DiaryDayModelCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of DiaryDayModel + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? id = null, + Object? date = null, + Object? wakeup = freezed, + Object? retire = freezed, + Object? closed = null, + Object? comment = null, + Object? typeOfDiary = null, + Object? meals = null, + }) { + return _then(_value.copyWith( + id: null == id + ? _value.id + : id // ignore: cast_nullable_to_non_nullable + as int, + date: null == date + ? _value.date + : date // ignore: cast_nullable_to_non_nullable + as String, + wakeup: freezed == wakeup + ? _value.wakeup + : wakeup // ignore: cast_nullable_to_non_nullable + as String?, + retire: freezed == retire + ? _value.retire + : retire // ignore: cast_nullable_to_non_nullable + as String?, + closed: null == closed + ? _value.closed + : closed // ignore: cast_nullable_to_non_nullable + as int, + comment: null == comment + ? _value.comment + : comment // ignore: cast_nullable_to_non_nullable + as String, + typeOfDiary: null == typeOfDiary + ? _value.typeOfDiary + : typeOfDiary // ignore: cast_nullable_to_non_nullable + as TypeOfDiaryModel, + meals: null == meals + ? _value.meals + : meals // ignore: cast_nullable_to_non_nullable + as List, + ) as $Val); + } + + /// Create a copy of DiaryDayModel + /// with the given fields replaced by the non-null parameter values. + @override + @pragma('vm:prefer-inline') + $TypeOfDiaryModelCopyWith<$Res> get typeOfDiary { + return $TypeOfDiaryModelCopyWith<$Res>(_value.typeOfDiary, (value) { + return _then(_value.copyWith(typeOfDiary: value) as $Val); + }); + } +} + +/// @nodoc +abstract class _$$DiaryDayModelImplCopyWith<$Res> + implements $DiaryDayModelCopyWith<$Res> { + factory _$$DiaryDayModelImplCopyWith( + _$DiaryDayModelImpl value, $Res Function(_$DiaryDayModelImpl) then) = + __$$DiaryDayModelImplCopyWithImpl<$Res>; + @override + @useResult + $Res call( + {@JsonKey(name: "id") int id, + @JsonKey(name: "date") String date, + @JsonKey(name: "wakeup") String? wakeup, + @JsonKey(name: "retire") String? retire, + @JsonKey(name: "closed") int closed, + @JsonKey(name: "comment") String comment, + @JsonKey(name: "state") TypeOfDiaryModel typeOfDiary, + @JsonKey(name: "meals") List meals}); + + @override + $TypeOfDiaryModelCopyWith<$Res> get typeOfDiary; +} + +/// @nodoc +class __$$DiaryDayModelImplCopyWithImpl<$Res> + extends _$DiaryDayModelCopyWithImpl<$Res, _$DiaryDayModelImpl> + implements _$$DiaryDayModelImplCopyWith<$Res> { + __$$DiaryDayModelImplCopyWithImpl( + _$DiaryDayModelImpl _value, $Res Function(_$DiaryDayModelImpl) _then) + : super(_value, _then); + + /// Create a copy of DiaryDayModel + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? id = null, + Object? date = null, + Object? wakeup = freezed, + Object? retire = freezed, + Object? closed = null, + Object? comment = null, + Object? typeOfDiary = null, + Object? meals = null, + }) { + return _then(_$DiaryDayModelImpl( + id: null == id + ? _value.id + : id // ignore: cast_nullable_to_non_nullable + as int, + date: null == date + ? _value.date + : date // ignore: cast_nullable_to_non_nullable + as String, + wakeup: freezed == wakeup + ? _value.wakeup + : wakeup // ignore: cast_nullable_to_non_nullable + as String?, + retire: freezed == retire + ? _value.retire + : retire // ignore: cast_nullable_to_non_nullable + as String?, + closed: null == closed + ? _value.closed + : closed // ignore: cast_nullable_to_non_nullable + as int, + comment: null == comment + ? _value.comment + : comment // ignore: cast_nullable_to_non_nullable + as String, + typeOfDiary: null == typeOfDiary + ? _value.typeOfDiary + : typeOfDiary // ignore: cast_nullable_to_non_nullable + as TypeOfDiaryModel, + meals: null == meals + ? _value._meals + : meals // ignore: cast_nullable_to_non_nullable + as List, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$DiaryDayModelImpl implements _DiaryDayModel { + const _$DiaryDayModelImpl( + {@JsonKey(name: "id") required this.id, + @JsonKey(name: "date") required this.date, + @JsonKey(name: "wakeup") this.wakeup, + @JsonKey(name: "retire") this.retire, + @JsonKey(name: "closed") required this.closed, + @JsonKey(name: "comment") required this.comment, + @JsonKey(name: "state") required this.typeOfDiary, + @JsonKey(name: "meals") required final List meals}) + : _meals = meals; + + factory _$DiaryDayModelImpl.fromJson(Map json) => + _$$DiaryDayModelImplFromJson(json); + + @override + @JsonKey(name: "id") + final int id; + @override + @JsonKey(name: "date") + final String date; + @override + @JsonKey(name: "wakeup") + final String? wakeup; + @override + @JsonKey(name: "retire") + final String? retire; + @override + @JsonKey(name: "closed") + final int closed; + @override + @JsonKey(name: "comment") + final String comment; + @override + @JsonKey(name: "state") + final TypeOfDiaryModel typeOfDiary; + final List _meals; + @override + @JsonKey(name: "meals") + List get meals { + if (_meals is EqualUnmodifiableListView) return _meals; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(_meals); + } + + @override + String toString() { + return 'DiaryDayModel(id: $id, date: $date, wakeup: $wakeup, retire: $retire, closed: $closed, comment: $comment, typeOfDiary: $typeOfDiary, meals: $meals)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$DiaryDayModelImpl && + (identical(other.id, id) || other.id == id) && + (identical(other.date, date) || other.date == date) && + (identical(other.wakeup, wakeup) || other.wakeup == wakeup) && + (identical(other.retire, retire) || other.retire == retire) && + (identical(other.closed, closed) || other.closed == closed) && + (identical(other.comment, comment) || other.comment == comment) && + (identical(other.typeOfDiary, typeOfDiary) || + other.typeOfDiary == typeOfDiary) && + const DeepCollectionEquality().equals(other._meals, _meals)); + } + + @JsonKey(includeFromJson: false, includeToJson: false) + @override + int get hashCode => Object.hash(runtimeType, id, date, wakeup, retire, closed, + comment, typeOfDiary, const DeepCollectionEquality().hash(_meals)); + + /// Create a copy of DiaryDayModel + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$DiaryDayModelImplCopyWith<_$DiaryDayModelImpl> get copyWith => + __$$DiaryDayModelImplCopyWithImpl<_$DiaryDayModelImpl>(this, _$identity); + + @override + Map toJson() { + return _$$DiaryDayModelImplToJson( + this, + ); + } +} + +abstract class _DiaryDayModel implements DiaryDayModel { + const factory _DiaryDayModel( + {@JsonKey(name: "id") required final int id, + @JsonKey(name: "date") required final String date, + @JsonKey(name: "wakeup") final String? wakeup, + @JsonKey(name: "retire") final String? retire, + @JsonKey(name: "closed") required final int closed, + @JsonKey(name: "comment") required final String comment, + @JsonKey(name: "state") required final TypeOfDiaryModel typeOfDiary, + @JsonKey(name: "meals") required final List meals}) = + _$DiaryDayModelImpl; + + factory _DiaryDayModel.fromJson(Map json) = + _$DiaryDayModelImpl.fromJson; + + @override + @JsonKey(name: "id") + int get id; + @override + @JsonKey(name: "date") + String get date; + @override + @JsonKey(name: "wakeup") + String? get wakeup; + @override + @JsonKey(name: "retire") + String? get retire; + @override + @JsonKey(name: "closed") + int get closed; + @override + @JsonKey(name: "comment") + String get comment; + @override + @JsonKey(name: "state") + TypeOfDiaryModel get typeOfDiary; + @override + @JsonKey(name: "meals") + List get meals; + + /// Create a copy of DiaryDayModel + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + _$$DiaryDayModelImplCopyWith<_$DiaryDayModelImpl> get copyWith => + throw _privateConstructorUsedError; +} + +MealModel _$MealModelFromJson(Map json) { + return _MealModel.fromJson(json); +} + +/// @nodoc +mixin _$MealModel { + @JsonKey(name: "id") + int get id => throw _privateConstructorUsedError; + @JsonKey(name: "time") + String get time => throw _privateConstructorUsedError; + @JsonKey(name: "type") + int get type => throw _privateConstructorUsedError; + @JsonKey(name: "satiety") + int get satiety => throw _privateConstructorUsedError; + @JsonKey(name: "mood") + int get mood => throw _privateConstructorUsedError; + @JsonKey(name: "portions") + List get portions => throw _privateConstructorUsedError; + @JsonKey(name: "photos") + List get photos => throw _privateConstructorUsedError; + + /// Serializes this MealModel to a JSON map. + Map toJson() => throw _privateConstructorUsedError; + + /// Create a copy of MealModel + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $MealModelCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $MealModelCopyWith<$Res> { + factory $MealModelCopyWith(MealModel value, $Res Function(MealModel) then) = + _$MealModelCopyWithImpl<$Res, MealModel>; + @useResult + $Res call( + {@JsonKey(name: "id") int id, + @JsonKey(name: "time") String time, + @JsonKey(name: "type") int type, + @JsonKey(name: "satiety") int satiety, + @JsonKey(name: "mood") int mood, + @JsonKey(name: "portions") List portions, + @JsonKey(name: "photos") List photos}); +} + +/// @nodoc +class _$MealModelCopyWithImpl<$Res, $Val extends MealModel> + implements $MealModelCopyWith<$Res> { + _$MealModelCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of MealModel + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? id = null, + Object? time = null, + Object? type = null, + Object? satiety = null, + Object? mood = null, + Object? portions = null, + Object? photos = null, + }) { + return _then(_value.copyWith( + id: null == id + ? _value.id + : id // ignore: cast_nullable_to_non_nullable + as int, + time: null == time + ? _value.time + : time // ignore: cast_nullable_to_non_nullable + as String, + type: null == type + ? _value.type + : type // ignore: cast_nullable_to_non_nullable + as int, + satiety: null == satiety + ? _value.satiety + : satiety // ignore: cast_nullable_to_non_nullable + as int, + mood: null == mood + ? _value.mood + : mood // ignore: cast_nullable_to_non_nullable + as int, + portions: null == portions + ? _value.portions + : portions // ignore: cast_nullable_to_non_nullable + as List, + photos: null == photos + ? _value.photos + : photos // ignore: cast_nullable_to_non_nullable + as List, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$MealModelImplCopyWith<$Res> + implements $MealModelCopyWith<$Res> { + factory _$$MealModelImplCopyWith( + _$MealModelImpl value, $Res Function(_$MealModelImpl) then) = + __$$MealModelImplCopyWithImpl<$Res>; + @override + @useResult + $Res call( + {@JsonKey(name: "id") int id, + @JsonKey(name: "time") String time, + @JsonKey(name: "type") int type, + @JsonKey(name: "satiety") int satiety, + @JsonKey(name: "mood") int mood, + @JsonKey(name: "portions") List portions, + @JsonKey(name: "photos") List photos}); +} + +/// @nodoc +class __$$MealModelImplCopyWithImpl<$Res> + extends _$MealModelCopyWithImpl<$Res, _$MealModelImpl> + implements _$$MealModelImplCopyWith<$Res> { + __$$MealModelImplCopyWithImpl( + _$MealModelImpl _value, $Res Function(_$MealModelImpl) _then) + : super(_value, _then); + + /// Create a copy of MealModel + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? id = null, + Object? time = null, + Object? type = null, + Object? satiety = null, + Object? mood = null, + Object? portions = null, + Object? photos = null, + }) { + return _then(_$MealModelImpl( + id: null == id + ? _value.id + : id // ignore: cast_nullable_to_non_nullable + as int, + time: null == time + ? _value.time + : time // ignore: cast_nullable_to_non_nullable + as String, + type: null == type + ? _value.type + : type // ignore: cast_nullable_to_non_nullable + as int, + satiety: null == satiety + ? _value.satiety + : satiety // ignore: cast_nullable_to_non_nullable + as int, + mood: null == mood + ? _value.mood + : mood // ignore: cast_nullable_to_non_nullable + as int, + portions: null == portions + ? _value._portions + : portions // ignore: cast_nullable_to_non_nullable + as List, + photos: null == photos + ? _value._photos + : photos // ignore: cast_nullable_to_non_nullable + as List, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$MealModelImpl implements _MealModel { + const _$MealModelImpl( + {@JsonKey(name: "id") required this.id, + @JsonKey(name: "time") required this.time, + @JsonKey(name: "type") required this.type, + @JsonKey(name: "satiety") required this.satiety, + @JsonKey(name: "mood") required this.mood, + @JsonKey(name: "portions") required final List portions, + @JsonKey(name: "photos") required final List photos}) + : _portions = portions, + _photos = photos; + + factory _$MealModelImpl.fromJson(Map json) => + _$$MealModelImplFromJson(json); + + @override + @JsonKey(name: "id") + final int id; + @override + @JsonKey(name: "time") + final String time; + @override + @JsonKey(name: "type") + final int type; + @override + @JsonKey(name: "satiety") + final int satiety; + @override + @JsonKey(name: "mood") + final int mood; + final List _portions; + @override + @JsonKey(name: "portions") + List get portions { + if (_portions is EqualUnmodifiableListView) return _portions; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(_portions); + } + + final List _photos; + @override + @JsonKey(name: "photos") + List get photos { + if (_photos is EqualUnmodifiableListView) return _photos; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(_photos); + } + + @override + String toString() { + return 'MealModel(id: $id, time: $time, type: $type, satiety: $satiety, mood: $mood, portions: $portions, photos: $photos)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$MealModelImpl && + (identical(other.id, id) || other.id == id) && + (identical(other.time, time) || other.time == time) && + (identical(other.type, type) || other.type == type) && + (identical(other.satiety, satiety) || other.satiety == satiety) && + (identical(other.mood, mood) || other.mood == mood) && + const DeepCollectionEquality().equals(other._portions, _portions) && + const DeepCollectionEquality().equals(other._photos, _photos)); + } + + @JsonKey(includeFromJson: false, includeToJson: false) + @override + int get hashCode => Object.hash( + runtimeType, + id, + time, + type, + satiety, + mood, + const DeepCollectionEquality().hash(_portions), + const DeepCollectionEquality().hash(_photos)); + + /// Create a copy of MealModel + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$MealModelImplCopyWith<_$MealModelImpl> get copyWith => + __$$MealModelImplCopyWithImpl<_$MealModelImpl>(this, _$identity); + + @override + Map toJson() { + return _$$MealModelImplToJson( + this, + ); + } +} + +abstract class _MealModel implements MealModel { + const factory _MealModel( + {@JsonKey(name: "id") required final int id, + @JsonKey(name: "time") required final String time, + @JsonKey(name: "type") required final int type, + @JsonKey(name: "satiety") required final int satiety, + @JsonKey(name: "mood") required final int mood, + @JsonKey(name: "portions") required final List portions, + @JsonKey(name: "photos") + required final List photos}) = _$MealModelImpl; + + factory _MealModel.fromJson(Map json) = + _$MealModelImpl.fromJson; + + @override + @JsonKey(name: "id") + int get id; + @override + @JsonKey(name: "time") + String get time; + @override + @JsonKey(name: "type") + int get type; + @override + @JsonKey(name: "satiety") + int get satiety; + @override + @JsonKey(name: "mood") + int get mood; + @override + @JsonKey(name: "portions") + List get portions; + @override + @JsonKey(name: "photos") + List get photos; + + /// Create a copy of MealModel + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + _$$MealModelImplCopyWith<_$MealModelImpl> get copyWith => + throw _privateConstructorUsedError; +} + +DiaryPhotoModel _$DiaryPhotoModelFromJson(Map json) { + return _DiaryPhotoModel.fromJson(json); +} + +/// @nodoc +mixin _$DiaryPhotoModel { + @JsonKey(name: "id") + String get id => throw _privateConstructorUsedError; + @JsonKey(name: "original_name") + String get originalName => throw _privateConstructorUsedError; + @JsonKey(name: "path") + String get path => throw _privateConstructorUsedError; + @JsonKey(name: "size") + String get size => throw _privateConstructorUsedError; + + /// Serializes this DiaryPhotoModel to a JSON map. + Map toJson() => throw _privateConstructorUsedError; + + /// Create a copy of DiaryPhotoModel + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $DiaryPhotoModelCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $DiaryPhotoModelCopyWith<$Res> { + factory $DiaryPhotoModelCopyWith( + DiaryPhotoModel value, $Res Function(DiaryPhotoModel) then) = + _$DiaryPhotoModelCopyWithImpl<$Res, DiaryPhotoModel>; + @useResult + $Res call( + {@JsonKey(name: "id") String id, + @JsonKey(name: "original_name") String originalName, + @JsonKey(name: "path") String path, + @JsonKey(name: "size") String size}); +} + +/// @nodoc +class _$DiaryPhotoModelCopyWithImpl<$Res, $Val extends DiaryPhotoModel> + implements $DiaryPhotoModelCopyWith<$Res> { + _$DiaryPhotoModelCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of DiaryPhotoModel + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? id = null, + Object? originalName = null, + Object? path = null, + Object? size = null, + }) { + return _then(_value.copyWith( + id: null == id + ? _value.id + : id // ignore: cast_nullable_to_non_nullable + as String, + originalName: null == originalName + ? _value.originalName + : originalName // ignore: cast_nullable_to_non_nullable + as String, + path: null == path + ? _value.path + : path // ignore: cast_nullable_to_non_nullable + as String, + size: null == size + ? _value.size + : size // ignore: cast_nullable_to_non_nullable + as String, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$DiaryPhotoModelImplCopyWith<$Res> + implements $DiaryPhotoModelCopyWith<$Res> { + factory _$$DiaryPhotoModelImplCopyWith(_$DiaryPhotoModelImpl value, + $Res Function(_$DiaryPhotoModelImpl) then) = + __$$DiaryPhotoModelImplCopyWithImpl<$Res>; + @override + @useResult + $Res call( + {@JsonKey(name: "id") String id, + @JsonKey(name: "original_name") String originalName, + @JsonKey(name: "path") String path, + @JsonKey(name: "size") String size}); +} + +/// @nodoc +class __$$DiaryPhotoModelImplCopyWithImpl<$Res> + extends _$DiaryPhotoModelCopyWithImpl<$Res, _$DiaryPhotoModelImpl> + implements _$$DiaryPhotoModelImplCopyWith<$Res> { + __$$DiaryPhotoModelImplCopyWithImpl( + _$DiaryPhotoModelImpl _value, $Res Function(_$DiaryPhotoModelImpl) _then) + : super(_value, _then); + + /// Create a copy of DiaryPhotoModel + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? id = null, + Object? originalName = null, + Object? path = null, + Object? size = null, + }) { + return _then(_$DiaryPhotoModelImpl( + id: null == id + ? _value.id + : id // ignore: cast_nullable_to_non_nullable + as String, + originalName: null == originalName + ? _value.originalName + : originalName // ignore: cast_nullable_to_non_nullable + as String, + path: null == path + ? _value.path + : path // ignore: cast_nullable_to_non_nullable + as String, + size: null == size + ? _value.size + : size // ignore: cast_nullable_to_non_nullable + as String, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$DiaryPhotoModelImpl implements _DiaryPhotoModel { + const _$DiaryPhotoModelImpl( + {@JsonKey(name: "id") required this.id, + @JsonKey(name: "original_name") required this.originalName, + @JsonKey(name: "path") required this.path, + @JsonKey(name: "size") required this.size}); + + factory _$DiaryPhotoModelImpl.fromJson(Map json) => + _$$DiaryPhotoModelImplFromJson(json); + + @override + @JsonKey(name: "id") + final String id; + @override + @JsonKey(name: "original_name") + final String originalName; + @override + @JsonKey(name: "path") + final String path; + @override + @JsonKey(name: "size") + final String size; + + @override + String toString() { + return 'DiaryPhotoModel(id: $id, originalName: $originalName, path: $path, size: $size)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$DiaryPhotoModelImpl && + (identical(other.id, id) || other.id == id) && + (identical(other.originalName, originalName) || + other.originalName == originalName) && + (identical(other.path, path) || other.path == path) && + (identical(other.size, size) || other.size == size)); + } + + @JsonKey(includeFromJson: false, includeToJson: false) + @override + int get hashCode => Object.hash(runtimeType, id, originalName, path, size); + + /// Create a copy of DiaryPhotoModel + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$DiaryPhotoModelImplCopyWith<_$DiaryPhotoModelImpl> get copyWith => + __$$DiaryPhotoModelImplCopyWithImpl<_$DiaryPhotoModelImpl>( + this, _$identity); + + @override + Map toJson() { + return _$$DiaryPhotoModelImplToJson( + this, + ); + } +} + +abstract class _DiaryPhotoModel implements DiaryPhotoModel { + const factory _DiaryPhotoModel( + {@JsonKey(name: "id") required final String id, + @JsonKey(name: "original_name") required final String originalName, + @JsonKey(name: "path") required final String path, + @JsonKey(name: "size") required final String size}) = + _$DiaryPhotoModelImpl; + + factory _DiaryPhotoModel.fromJson(Map json) = + _$DiaryPhotoModelImpl.fromJson; + + @override + @JsonKey(name: "id") + String get id; + @override + @JsonKey(name: "original_name") + String get originalName; + @override + @JsonKey(name: "path") + String get path; + @override + @JsonKey(name: "size") + String get size; + + /// Create a copy of DiaryPhotoModel + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + _$$DiaryPhotoModelImplCopyWith<_$DiaryPhotoModelImpl> get copyWith => + throw _privateConstructorUsedError; +} + +Portion _$PortionFromJson(Map json) { + return _Portion.fromJson(json); +} + +/// @nodoc +mixin _$Portion { + @JsonKey(name: "id") + int get id => throw _privateConstructorUsedError; + @JsonKey(name: "product_name") + String get productName => throw _privateConstructorUsedError; + @JsonKey(name: "quantity") + int get quantity => throw _privateConstructorUsedError; + @JsonKey(name: "portion") + String get portion => throw _privateConstructorUsedError; + @JsonKey(name: "from_diet") + bool get fromDiet => throw _privateConstructorUsedError; + + /// Serializes this Portion to a JSON map. + Map toJson() => throw _privateConstructorUsedError; + + /// Create a copy of Portion + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $PortionCopyWith get copyWith => throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $PortionCopyWith<$Res> { + factory $PortionCopyWith(Portion value, $Res Function(Portion) then) = + _$PortionCopyWithImpl<$Res, Portion>; + @useResult + $Res call( + {@JsonKey(name: "id") int id, + @JsonKey(name: "product_name") String productName, + @JsonKey(name: "quantity") int quantity, + @JsonKey(name: "portion") String portion, + @JsonKey(name: "from_diet") bool fromDiet}); +} + +/// @nodoc +class _$PortionCopyWithImpl<$Res, $Val extends Portion> + implements $PortionCopyWith<$Res> { + _$PortionCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of Portion + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? id = null, + Object? productName = null, + Object? quantity = null, + Object? portion = null, + Object? fromDiet = null, + }) { + return _then(_value.copyWith( + id: null == id + ? _value.id + : id // ignore: cast_nullable_to_non_nullable + as int, + productName: null == productName + ? _value.productName + : productName // ignore: cast_nullable_to_non_nullable + as String, + quantity: null == quantity + ? _value.quantity + : quantity // ignore: cast_nullable_to_non_nullable + as int, + portion: null == portion + ? _value.portion + : portion // ignore: cast_nullable_to_non_nullable + as String, + fromDiet: null == fromDiet + ? _value.fromDiet + : fromDiet // ignore: cast_nullable_to_non_nullable + as bool, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$PortionImplCopyWith<$Res> implements $PortionCopyWith<$Res> { + factory _$$PortionImplCopyWith( + _$PortionImpl value, $Res Function(_$PortionImpl) then) = + __$$PortionImplCopyWithImpl<$Res>; + @override + @useResult + $Res call( + {@JsonKey(name: "id") int id, + @JsonKey(name: "product_name") String productName, + @JsonKey(name: "quantity") int quantity, + @JsonKey(name: "portion") String portion, + @JsonKey(name: "from_diet") bool fromDiet}); +} + +/// @nodoc +class __$$PortionImplCopyWithImpl<$Res> + extends _$PortionCopyWithImpl<$Res, _$PortionImpl> + implements _$$PortionImplCopyWith<$Res> { + __$$PortionImplCopyWithImpl( + _$PortionImpl _value, $Res Function(_$PortionImpl) _then) + : super(_value, _then); + + /// Create a copy of Portion + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? id = null, + Object? productName = null, + Object? quantity = null, + Object? portion = null, + Object? fromDiet = null, + }) { + return _then(_$PortionImpl( + id: null == id + ? _value.id + : id // ignore: cast_nullable_to_non_nullable + as int, + productName: null == productName + ? _value.productName + : productName // ignore: cast_nullable_to_non_nullable + as String, + quantity: null == quantity + ? _value.quantity + : quantity // ignore: cast_nullable_to_non_nullable + as int, + portion: null == portion + ? _value.portion + : portion // ignore: cast_nullable_to_non_nullable + as String, + fromDiet: null == fromDiet + ? _value.fromDiet + : fromDiet // ignore: cast_nullable_to_non_nullable + as bool, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$PortionImpl implements _Portion { + const _$PortionImpl( + {@JsonKey(name: "id") required this.id, + @JsonKey(name: "product_name") required this.productName, + @JsonKey(name: "quantity") required this.quantity, + @JsonKey(name: "portion") required this.portion, + @JsonKey(name: "from_diet") required this.fromDiet}); + + factory _$PortionImpl.fromJson(Map json) => + _$$PortionImplFromJson(json); + + @override + @JsonKey(name: "id") + final int id; + @override + @JsonKey(name: "product_name") + final String productName; + @override + @JsonKey(name: "quantity") + final int quantity; + @override + @JsonKey(name: "portion") + final String portion; + @override + @JsonKey(name: "from_diet") + final bool fromDiet; + + @override + String toString() { + return 'Portion(id: $id, productName: $productName, quantity: $quantity, portion: $portion, fromDiet: $fromDiet)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$PortionImpl && + (identical(other.id, id) || other.id == id) && + (identical(other.productName, productName) || + other.productName == productName) && + (identical(other.quantity, quantity) || + other.quantity == quantity) && + (identical(other.portion, portion) || other.portion == portion) && + (identical(other.fromDiet, fromDiet) || + other.fromDiet == fromDiet)); + } + + @JsonKey(includeFromJson: false, includeToJson: false) + @override + int get hashCode => + Object.hash(runtimeType, id, productName, quantity, portion, fromDiet); + + /// Create a copy of Portion + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$PortionImplCopyWith<_$PortionImpl> get copyWith => + __$$PortionImplCopyWithImpl<_$PortionImpl>(this, _$identity); + + @override + Map toJson() { + return _$$PortionImplToJson( + this, + ); + } +} + +abstract class _Portion implements Portion { + const factory _Portion( + {@JsonKey(name: "id") required final int id, + @JsonKey(name: "product_name") required final String productName, + @JsonKey(name: "quantity") required final int quantity, + @JsonKey(name: "portion") required final String portion, + @JsonKey(name: "from_diet") required final bool fromDiet}) = + _$PortionImpl; + + factory _Portion.fromJson(Map json) = _$PortionImpl.fromJson; + + @override + @JsonKey(name: "id") + int get id; + @override + @JsonKey(name: "product_name") + String get productName; + @override + @JsonKey(name: "quantity") + int get quantity; + @override + @JsonKey(name: "portion") + String get portion; + @override + @JsonKey(name: "from_diet") + bool get fromDiet; + + /// Create a copy of Portion + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + _$$PortionImplCopyWith<_$PortionImpl> get copyWith => + throw _privateConstructorUsedError; +} + +TypeOfDiaryModel _$TypeOfDiaryModelFromJson(Map json) { + return _TypeOfDiaryModel.fromJson(json); +} + +/// @nodoc +mixin _$TypeOfDiaryModel { + @JsonKey(name: "has_chosen_diet") + bool get hasChosenDiet => throw _privateConstructorUsedError; + @JsonKey(name: "has_chosen_plan") + bool get hasChosenPlan => throw _privateConstructorUsedError; + + /// Serializes this TypeOfDiaryModel to a JSON map. + Map toJson() => throw _privateConstructorUsedError; + + /// Create a copy of TypeOfDiaryModel + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $TypeOfDiaryModelCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $TypeOfDiaryModelCopyWith<$Res> { + factory $TypeOfDiaryModelCopyWith( + TypeOfDiaryModel value, $Res Function(TypeOfDiaryModel) then) = + _$TypeOfDiaryModelCopyWithImpl<$Res, TypeOfDiaryModel>; + @useResult + $Res call( + {@JsonKey(name: "has_chosen_diet") bool hasChosenDiet, + @JsonKey(name: "has_chosen_plan") bool hasChosenPlan}); +} + +/// @nodoc +class _$TypeOfDiaryModelCopyWithImpl<$Res, $Val extends TypeOfDiaryModel> + implements $TypeOfDiaryModelCopyWith<$Res> { + _$TypeOfDiaryModelCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of TypeOfDiaryModel + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? hasChosenDiet = null, + Object? hasChosenPlan = null, + }) { + return _then(_value.copyWith( + hasChosenDiet: null == hasChosenDiet + ? _value.hasChosenDiet + : hasChosenDiet // ignore: cast_nullable_to_non_nullable + as bool, + hasChosenPlan: null == hasChosenPlan + ? _value.hasChosenPlan + : hasChosenPlan // ignore: cast_nullable_to_non_nullable + as bool, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$TypeOfDiaryModelImplCopyWith<$Res> + implements $TypeOfDiaryModelCopyWith<$Res> { + factory _$$TypeOfDiaryModelImplCopyWith(_$TypeOfDiaryModelImpl value, + $Res Function(_$TypeOfDiaryModelImpl) then) = + __$$TypeOfDiaryModelImplCopyWithImpl<$Res>; + @override + @useResult + $Res call( + {@JsonKey(name: "has_chosen_diet") bool hasChosenDiet, + @JsonKey(name: "has_chosen_plan") bool hasChosenPlan}); +} + +/// @nodoc +class __$$TypeOfDiaryModelImplCopyWithImpl<$Res> + extends _$TypeOfDiaryModelCopyWithImpl<$Res, _$TypeOfDiaryModelImpl> + implements _$$TypeOfDiaryModelImplCopyWith<$Res> { + __$$TypeOfDiaryModelImplCopyWithImpl(_$TypeOfDiaryModelImpl _value, + $Res Function(_$TypeOfDiaryModelImpl) _then) + : super(_value, _then); + + /// Create a copy of TypeOfDiaryModel + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? hasChosenDiet = null, + Object? hasChosenPlan = null, + }) { + return _then(_$TypeOfDiaryModelImpl( + hasChosenDiet: null == hasChosenDiet + ? _value.hasChosenDiet + : hasChosenDiet // ignore: cast_nullable_to_non_nullable + as bool, + hasChosenPlan: null == hasChosenPlan + ? _value.hasChosenPlan + : hasChosenPlan // ignore: cast_nullable_to_non_nullable + as bool, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$TypeOfDiaryModelImpl implements _TypeOfDiaryModel { + const _$TypeOfDiaryModelImpl( + {@JsonKey(name: "has_chosen_diet") required this.hasChosenDiet, + @JsonKey(name: "has_chosen_plan") required this.hasChosenPlan}); + + factory _$TypeOfDiaryModelImpl.fromJson(Map json) => + _$$TypeOfDiaryModelImplFromJson(json); + + @override + @JsonKey(name: "has_chosen_diet") + final bool hasChosenDiet; + @override + @JsonKey(name: "has_chosen_plan") + final bool hasChosenPlan; + + @override + String toString() { + return 'TypeOfDiaryModel(hasChosenDiet: $hasChosenDiet, hasChosenPlan: $hasChosenPlan)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$TypeOfDiaryModelImpl && + (identical(other.hasChosenDiet, hasChosenDiet) || + other.hasChosenDiet == hasChosenDiet) && + (identical(other.hasChosenPlan, hasChosenPlan) || + other.hasChosenPlan == hasChosenPlan)); + } + + @JsonKey(includeFromJson: false, includeToJson: false) + @override + int get hashCode => Object.hash(runtimeType, hasChosenDiet, hasChosenPlan); + + /// Create a copy of TypeOfDiaryModel + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$TypeOfDiaryModelImplCopyWith<_$TypeOfDiaryModelImpl> get copyWith => + __$$TypeOfDiaryModelImplCopyWithImpl<_$TypeOfDiaryModelImpl>( + this, _$identity); + + @override + Map toJson() { + return _$$TypeOfDiaryModelImplToJson( + this, + ); + } +} + +abstract class _TypeOfDiaryModel implements TypeOfDiaryModel { + const factory _TypeOfDiaryModel( + {@JsonKey(name: "has_chosen_diet") required final bool hasChosenDiet, + @JsonKey(name: "has_chosen_plan") + required final bool hasChosenPlan}) = _$TypeOfDiaryModelImpl; + + factory _TypeOfDiaryModel.fromJson(Map json) = + _$TypeOfDiaryModelImpl.fromJson; + + @override + @JsonKey(name: "has_chosen_diet") + bool get hasChosenDiet; + @override + @JsonKey(name: "has_chosen_plan") + bool get hasChosenPlan; + + /// Create a copy of TypeOfDiaryModel + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + _$$TypeOfDiaryModelImplCopyWith<_$TypeOfDiaryModelImpl> get copyWith => + throw _privateConstructorUsedError; +} diff --git a/lib/features/diary/models/diary_day_model.g.dart b/lib/features/diary/models/diary_day_model.g.dart new file mode 100644 index 00000000..05d36efa --- /dev/null +++ b/lib/features/diary/models/diary_day_model.g.dart @@ -0,0 +1,122 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'diary_day_model.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +_$DiaryDayWrapperModelImpl _$$DiaryDayWrapperModelImplFromJson( + Map json) => + _$DiaryDayWrapperModelImpl( + diary: DiaryDayModel.fromJson(json['diary'] as Map), + ); + +Map _$$DiaryDayWrapperModelImplToJson( + _$DiaryDayWrapperModelImpl instance) => + { + 'diary': instance.diary, + }; + +_$DiaryDayModelImpl _$$DiaryDayModelImplFromJson(Map json) => + _$DiaryDayModelImpl( + id: (json['id'] as num).toInt(), + date: json['date'] as String, + wakeup: json['wakeup'] as String?, + retire: json['retire'] as String?, + closed: (json['closed'] as num).toInt(), + comment: json['comment'] as String, + typeOfDiary: + TypeOfDiaryModel.fromJson(json['state'] as Map), + meals: (json['meals'] as List) + .map((e) => MealModel.fromJson(e as Map)) + .toList(), + ); + +Map _$$DiaryDayModelImplToJson(_$DiaryDayModelImpl instance) => + { + 'id': instance.id, + 'date': instance.date, + 'wakeup': instance.wakeup, + 'retire': instance.retire, + 'closed': instance.closed, + 'comment': instance.comment, + 'state': instance.typeOfDiary, + 'meals': instance.meals, + }; + +_$MealModelImpl _$$MealModelImplFromJson(Map json) => + _$MealModelImpl( + id: (json['id'] as num).toInt(), + time: json['time'] as String, + type: (json['type'] as num).toInt(), + satiety: (json['satiety'] as num).toInt(), + mood: (json['mood'] as num).toInt(), + portions: (json['portions'] as List) + .map((e) => Portion.fromJson(e as Map)) + .toList(), + photos: (json['photos'] as List) + .map((e) => DiaryPhotoModel.fromJson(e as Map)) + .toList(), + ); + +Map _$$MealModelImplToJson(_$MealModelImpl instance) => + { + 'id': instance.id, + 'time': instance.time, + 'type': instance.type, + 'satiety': instance.satiety, + 'mood': instance.mood, + 'portions': instance.portions, + 'photos': instance.photos, + }; + +_$DiaryPhotoModelImpl _$$DiaryPhotoModelImplFromJson( + Map json) => + _$DiaryPhotoModelImpl( + id: json['id'] as String, + originalName: json['original_name'] as String, + path: json['path'] as String, + size: json['size'] as String, + ); + +Map _$$DiaryPhotoModelImplToJson( + _$DiaryPhotoModelImpl instance) => + { + 'id': instance.id, + 'original_name': instance.originalName, + 'path': instance.path, + 'size': instance.size, + }; + +_$PortionImpl _$$PortionImplFromJson(Map json) => + _$PortionImpl( + id: (json['id'] as num).toInt(), + productName: json['product_name'] as String, + quantity: (json['quantity'] as num).toInt(), + portion: json['portion'] as String, + fromDiet: json['from_diet'] as bool, + ); + +Map _$$PortionImplToJson(_$PortionImpl instance) => + { + 'id': instance.id, + 'product_name': instance.productName, + 'quantity': instance.quantity, + 'portion': instance.portion, + 'from_diet': instance.fromDiet, + }; + +_$TypeOfDiaryModelImpl _$$TypeOfDiaryModelImplFromJson( + Map json) => + _$TypeOfDiaryModelImpl( + hasChosenDiet: json['has_chosen_diet'] as bool, + hasChosenPlan: json['has_chosen_plan'] as bool, + ); + +Map _$$TypeOfDiaryModelImplToJson( + _$TypeOfDiaryModelImpl instance) => + { + 'has_chosen_diet': instance.hasChosenDiet, + 'has_chosen_plan': instance.hasChosenPlan, + }; diff --git a/lib/features/diary/models/diary_index_model.dart b/lib/features/diary/models/diary_index_model.dart new file mode 100644 index 00000000..6b895e96 --- /dev/null +++ b/lib/features/diary/models/diary_index_model.dart @@ -0,0 +1,14 @@ +import 'package:freezed_annotation/freezed_annotation.dart'; + +part 'diary_index_model.freezed.dart'; + +part 'diary_index_model.g.dart'; + +@freezed +class DiaryIndexModel with _$DiaryIndexModel { + const factory DiaryIndexModel({ + required int id, + }) = _DiaryIndexModel; + + factory DiaryIndexModel.fromJson(Map json) => _$DiaryIndexModelFromJson(json); +} diff --git a/lib/features/diary/models/diary_index_model.freezed.dart b/lib/features/diary/models/diary_index_model.freezed.dart new file mode 100644 index 00000000..9b78696c --- /dev/null +++ b/lib/features/diary/models/diary_index_model.freezed.dart @@ -0,0 +1,166 @@ +// 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 'diary_index_model.dart'; + +// ************************************************************************** +// FreezedGenerator +// ************************************************************************** + +T _$identity(T value) => value; + +final _privateConstructorUsedError = UnsupportedError( + 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models'); + +DiaryIndexModel _$DiaryIndexModelFromJson(Map json) { + return _DiaryIndexModel.fromJson(json); +} + +/// @nodoc +mixin _$DiaryIndexModel { + int get id => throw _privateConstructorUsedError; + + /// Serializes this DiaryIndexModel to a JSON map. + Map toJson() => throw _privateConstructorUsedError; + + /// Create a copy of DiaryIndexModel + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $DiaryIndexModelCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $DiaryIndexModelCopyWith<$Res> { + factory $DiaryIndexModelCopyWith( + DiaryIndexModel value, $Res Function(DiaryIndexModel) then) = + _$DiaryIndexModelCopyWithImpl<$Res, DiaryIndexModel>; + @useResult + $Res call({int id}); +} + +/// @nodoc +class _$DiaryIndexModelCopyWithImpl<$Res, $Val extends DiaryIndexModel> + implements $DiaryIndexModelCopyWith<$Res> { + _$DiaryIndexModelCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of DiaryIndexModel + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? id = null, + }) { + return _then(_value.copyWith( + id: null == id + ? _value.id + : id // ignore: cast_nullable_to_non_nullable + as int, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$DiaryIndexModelImplCopyWith<$Res> + implements $DiaryIndexModelCopyWith<$Res> { + factory _$$DiaryIndexModelImplCopyWith(_$DiaryIndexModelImpl value, + $Res Function(_$DiaryIndexModelImpl) then) = + __$$DiaryIndexModelImplCopyWithImpl<$Res>; + @override + @useResult + $Res call({int id}); +} + +/// @nodoc +class __$$DiaryIndexModelImplCopyWithImpl<$Res> + extends _$DiaryIndexModelCopyWithImpl<$Res, _$DiaryIndexModelImpl> + implements _$$DiaryIndexModelImplCopyWith<$Res> { + __$$DiaryIndexModelImplCopyWithImpl( + _$DiaryIndexModelImpl _value, $Res Function(_$DiaryIndexModelImpl) _then) + : super(_value, _then); + + /// Create a copy of DiaryIndexModel + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? id = null, + }) { + return _then(_$DiaryIndexModelImpl( + id: null == id + ? _value.id + : id // ignore: cast_nullable_to_non_nullable + as int, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$DiaryIndexModelImpl implements _DiaryIndexModel { + const _$DiaryIndexModelImpl({required this.id}); + + factory _$DiaryIndexModelImpl.fromJson(Map json) => + _$$DiaryIndexModelImplFromJson(json); + + @override + final int id; + + @override + String toString() { + return 'DiaryIndexModel(id: $id)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$DiaryIndexModelImpl && + (identical(other.id, id) || other.id == id)); + } + + @JsonKey(includeFromJson: false, includeToJson: false) + @override + int get hashCode => Object.hash(runtimeType, id); + + /// Create a copy of DiaryIndexModel + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$DiaryIndexModelImplCopyWith<_$DiaryIndexModelImpl> get copyWith => + __$$DiaryIndexModelImplCopyWithImpl<_$DiaryIndexModelImpl>( + this, _$identity); + + @override + Map toJson() { + return _$$DiaryIndexModelImplToJson( + this, + ); + } +} + +abstract class _DiaryIndexModel implements DiaryIndexModel { + const factory _DiaryIndexModel({required final int id}) = + _$DiaryIndexModelImpl; + + factory _DiaryIndexModel.fromJson(Map json) = + _$DiaryIndexModelImpl.fromJson; + + @override + int get id; + + /// Create a copy of DiaryIndexModel + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + _$$DiaryIndexModelImplCopyWith<_$DiaryIndexModelImpl> get copyWith => + throw _privateConstructorUsedError; +} diff --git a/lib/features/diary/models/photo.g.dart b/lib/features/diary/models/diary_index_model.g.dart similarity index 50% rename from lib/features/diary/models/photo.g.dart rename to lib/features/diary/models/diary_index_model.g.dart index cacf65ac..268132fa 100644 --- a/lib/features/diary/models/photo.g.dart +++ b/lib/features/diary/models/diary_index_model.g.dart @@ -1,20 +1,19 @@ // GENERATED CODE - DO NOT MODIFY BY HAND -part of 'photo.dart'; +part of 'diary_index_model.dart'; // ************************************************************************** // JsonSerializableGenerator // ************************************************************************** -_$PhotoImpl _$$PhotoImplFromJson(Map json) => _$PhotoImpl( +_$DiaryIndexModelImpl _$$DiaryIndexModelImplFromJson( + Map json) => + _$DiaryIndexModelImpl( id: (json['id'] as num).toInt(), - originalName: json['original_name'] as String, - path: json['path'] as String, ); -Map _$$PhotoImplToJson(_$PhotoImpl instance) => +Map _$$DiaryIndexModelImplToJson( + _$DiaryIndexModelImpl instance) => { 'id': instance.id, - 'original_name': instance.originalName, - 'path': instance.path, }; diff --git a/lib/features/diary/models/diary_model.dart b/lib/features/diary/models/diary_model.dart deleted file mode 100644 index 8c152997..00000000 --- a/lib/features/diary/models/diary_model.dart +++ /dev/null @@ -1,24 +0,0 @@ -import 'package:eatvio_app/features/diary/models/state.dart'; -import 'package:freezed_annotation/freezed_annotation.dart'; - -import './meal.dart'; - -part 'diary_model.freezed.dart'; - -part 'diary_model.g.dart'; - -@freezed -class DiaryModel with _$DiaryModel { - const factory DiaryModel({ - required int id, - required DateTime date, - required int closed, - required List meals, - required State state, - String? comment, - DateTime? wakeup, - DateTime? retire, - }) = _DiaryModel; - - factory DiaryModel.fromJson(Map json) => _$DiaryModelFromJson(json); -} diff --git a/lib/features/diary/models/diary_model.freezed.dart b/lib/features/diary/models/diary_model.freezed.dart deleted file mode 100644 index ceabd5db..00000000 --- a/lib/features/diary/models/diary_model.freezed.dart +++ /dev/null @@ -1,339 +0,0 @@ -// 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 'diary_model.dart'; - -// ************************************************************************** -// FreezedGenerator -// ************************************************************************** - -T _$identity(T value) => value; - -final _privateConstructorUsedError = UnsupportedError( - 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models'); - -DiaryModel _$DiaryModelFromJson(Map json) { - return _DiaryModel.fromJson(json); -} - -/// @nodoc -mixin _$DiaryModel { - int get id => throw _privateConstructorUsedError; - DateTime get date => throw _privateConstructorUsedError; - int get closed => throw _privateConstructorUsedError; - List get meals => throw _privateConstructorUsedError; - State get state => throw _privateConstructorUsedError; - String? get comment => throw _privateConstructorUsedError; - DateTime? get wakeup => throw _privateConstructorUsedError; - DateTime? get retire => throw _privateConstructorUsedError; - - /// Serializes this DiaryModel to a JSON map. - Map toJson() => throw _privateConstructorUsedError; - - /// Create a copy of DiaryModel - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - $DiaryModelCopyWith get copyWith => - throw _privateConstructorUsedError; -} - -/// @nodoc -abstract class $DiaryModelCopyWith<$Res> { - factory $DiaryModelCopyWith( - DiaryModel value, $Res Function(DiaryModel) then) = - _$DiaryModelCopyWithImpl<$Res, DiaryModel>; - @useResult - $Res call( - {int id, - DateTime date, - int closed, - List meals, - State state, - String? comment, - DateTime? wakeup, - DateTime? retire}); - - $StateCopyWith<$Res> get state; -} - -/// @nodoc -class _$DiaryModelCopyWithImpl<$Res, $Val extends DiaryModel> - implements $DiaryModelCopyWith<$Res> { - _$DiaryModelCopyWithImpl(this._value, this._then); - - // ignore: unused_field - final $Val _value; - // ignore: unused_field - final $Res Function($Val) _then; - - /// Create a copy of DiaryModel - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? id = null, - Object? date = null, - Object? closed = null, - Object? meals = null, - Object? state = null, - Object? comment = freezed, - Object? wakeup = freezed, - Object? retire = freezed, - }) { - return _then(_value.copyWith( - id: null == id - ? _value.id - : id // ignore: cast_nullable_to_non_nullable - as int, - date: null == date - ? _value.date - : date // ignore: cast_nullable_to_non_nullable - as DateTime, - closed: null == closed - ? _value.closed - : closed // ignore: cast_nullable_to_non_nullable - as int, - meals: null == meals - ? _value.meals - : meals // ignore: cast_nullable_to_non_nullable - as List, - state: null == state - ? _value.state - : state // ignore: cast_nullable_to_non_nullable - as State, - comment: freezed == comment - ? _value.comment - : comment // ignore: cast_nullable_to_non_nullable - as String?, - wakeup: freezed == wakeup - ? _value.wakeup - : wakeup // ignore: cast_nullable_to_non_nullable - as DateTime?, - retire: freezed == retire - ? _value.retire - : retire // ignore: cast_nullable_to_non_nullable - as DateTime?, - ) as $Val); - } - - /// Create a copy of DiaryModel - /// with the given fields replaced by the non-null parameter values. - @override - @pragma('vm:prefer-inline') - $StateCopyWith<$Res> get state { - return $StateCopyWith<$Res>(_value.state, (value) { - return _then(_value.copyWith(state: value) as $Val); - }); - } -} - -/// @nodoc -abstract class _$$DiaryModelImplCopyWith<$Res> - implements $DiaryModelCopyWith<$Res> { - factory _$$DiaryModelImplCopyWith( - _$DiaryModelImpl value, $Res Function(_$DiaryModelImpl) then) = - __$$DiaryModelImplCopyWithImpl<$Res>; - @override - @useResult - $Res call( - {int id, - DateTime date, - int closed, - List meals, - State state, - String? comment, - DateTime? wakeup, - DateTime? retire}); - - @override - $StateCopyWith<$Res> get state; -} - -/// @nodoc -class __$$DiaryModelImplCopyWithImpl<$Res> - extends _$DiaryModelCopyWithImpl<$Res, _$DiaryModelImpl> - implements _$$DiaryModelImplCopyWith<$Res> { - __$$DiaryModelImplCopyWithImpl( - _$DiaryModelImpl _value, $Res Function(_$DiaryModelImpl) _then) - : super(_value, _then); - - /// Create a copy of DiaryModel - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? id = null, - Object? date = null, - Object? closed = null, - Object? meals = null, - Object? state = null, - Object? comment = freezed, - Object? wakeup = freezed, - Object? retire = freezed, - }) { - return _then(_$DiaryModelImpl( - id: null == id - ? _value.id - : id // ignore: cast_nullable_to_non_nullable - as int, - date: null == date - ? _value.date - : date // ignore: cast_nullable_to_non_nullable - as DateTime, - closed: null == closed - ? _value.closed - : closed // ignore: cast_nullable_to_non_nullable - as int, - meals: null == meals - ? _value._meals - : meals // ignore: cast_nullable_to_non_nullable - as List, - state: null == state - ? _value.state - : state // ignore: cast_nullable_to_non_nullable - as State, - comment: freezed == comment - ? _value.comment - : comment // ignore: cast_nullable_to_non_nullable - as String?, - wakeup: freezed == wakeup - ? _value.wakeup - : wakeup // ignore: cast_nullable_to_non_nullable - as DateTime?, - retire: freezed == retire - ? _value.retire - : retire // ignore: cast_nullable_to_non_nullable - as DateTime?, - )); - } -} - -/// @nodoc -@JsonSerializable() -class _$DiaryModelImpl implements _DiaryModel { - const _$DiaryModelImpl( - {required this.id, - required this.date, - required this.closed, - required final List meals, - required this.state, - this.comment, - this.wakeup, - this.retire}) - : _meals = meals; - - factory _$DiaryModelImpl.fromJson(Map json) => - _$$DiaryModelImplFromJson(json); - - @override - final int id; - @override - final DateTime date; - @override - final int closed; - final List _meals; - @override - List get meals { - if (_meals is EqualUnmodifiableListView) return _meals; - // ignore: implicit_dynamic_type - return EqualUnmodifiableListView(_meals); - } - - @override - final State state; - @override - final String? comment; - @override - final DateTime? wakeup; - @override - final DateTime? retire; - - @override - String toString() { - return 'DiaryModel(id: $id, date: $date, closed: $closed, meals: $meals, state: $state, comment: $comment, wakeup: $wakeup, retire: $retire)'; - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _$DiaryModelImpl && - (identical(other.id, id) || other.id == id) && - (identical(other.date, date) || other.date == date) && - (identical(other.closed, closed) || other.closed == closed) && - const DeepCollectionEquality().equals(other._meals, _meals) && - (identical(other.state, state) || other.state == state) && - (identical(other.comment, comment) || other.comment == comment) && - (identical(other.wakeup, wakeup) || other.wakeup == wakeup) && - (identical(other.retire, retire) || other.retire == retire)); - } - - @JsonKey(includeFromJson: false, includeToJson: false) - @override - int get hashCode => Object.hash( - runtimeType, - id, - date, - closed, - const DeepCollectionEquality().hash(_meals), - state, - comment, - wakeup, - retire); - - /// Create a copy of DiaryModel - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - @override - @pragma('vm:prefer-inline') - _$$DiaryModelImplCopyWith<_$DiaryModelImpl> get copyWith => - __$$DiaryModelImplCopyWithImpl<_$DiaryModelImpl>(this, _$identity); - - @override - Map toJson() { - return _$$DiaryModelImplToJson( - this, - ); - } -} - -abstract class _DiaryModel implements DiaryModel { - const factory _DiaryModel( - {required final int id, - required final DateTime date, - required final int closed, - required final List meals, - required final State state, - final String? comment, - final DateTime? wakeup, - final DateTime? retire}) = _$DiaryModelImpl; - - factory _DiaryModel.fromJson(Map json) = - _$DiaryModelImpl.fromJson; - - @override - int get id; - @override - DateTime get date; - @override - int get closed; - @override - List get meals; - @override - State get state; - @override - String? get comment; - @override - DateTime? get wakeup; - @override - DateTime? get retire; - - /// Create a copy of DiaryModel - /// with the given fields replaced by the non-null parameter values. - @override - @JsonKey(includeFromJson: false, includeToJson: false) - _$$DiaryModelImplCopyWith<_$DiaryModelImpl> get copyWith => - throw _privateConstructorUsedError; -} diff --git a/lib/features/diary/models/diary_model.g.dart b/lib/features/diary/models/diary_model.g.dart deleted file mode 100644 index 29f98caa..00000000 --- a/lib/features/diary/models/diary_model.g.dart +++ /dev/null @@ -1,37 +0,0 @@ -// GENERATED CODE - DO NOT MODIFY BY HAND - -part of 'diary_model.dart'; - -// ************************************************************************** -// JsonSerializableGenerator -// ************************************************************************** - -_$DiaryModelImpl _$$DiaryModelImplFromJson(Map json) => - _$DiaryModelImpl( - id: (json['id'] as num).toInt(), - date: DateTime.parse(json['date'] as String), - closed: (json['closed'] as num).toInt(), - meals: (json['meals'] as List) - .map((e) => Meal.fromJson(e as Map)) - .toList(), - state: State.fromJson(json['state'] as Map), - comment: json['comment'] as String?, - wakeup: json['wakeup'] == null - ? null - : DateTime.parse(json['wakeup'] as String), - retire: json['retire'] == null - ? null - : DateTime.parse(json['retire'] as String), - ); - -Map _$$DiaryModelImplToJson(_$DiaryModelImpl instance) => - { - 'id': instance.id, - 'date': instance.date.toIso8601String(), - 'closed': instance.closed, - 'meals': instance.meals, - 'state': instance.state, - 'comment': instance.comment, - 'wakeup': instance.wakeup?.toIso8601String(), - 'retire': instance.retire?.toIso8601String(), - }; diff --git a/lib/features/diary/models/meal.dart b/lib/features/diary/models/meal.dart deleted file mode 100644 index b5e12d83..00000000 --- a/lib/features/diary/models/meal.dart +++ /dev/null @@ -1,23 +0,0 @@ -import 'package:freezed_annotation/freezed_annotation.dart'; - -import './photo.dart'; -import './portion.dart'; - -part 'meal.freezed.dart'; - -part 'meal.g.dart'; - -@freezed -class Meal with _$Meal { - const factory Meal({ - required int id, - required String time, - required int type, - required int satiety, - required int mood, - required List portions, - required List photos, - }) = _Meal; - - factory Meal.fromJson(Map json) => _$MealFromJson(json); -} diff --git a/lib/features/diary/models/meal.freezed.dart b/lib/features/diary/models/meal.freezed.dart deleted file mode 100644 index 2bd6c478..00000000 --- a/lib/features/diary/models/meal.freezed.dart +++ /dev/null @@ -1,304 +0,0 @@ -// 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 'meal.dart'; - -// ************************************************************************** -// FreezedGenerator -// ************************************************************************** - -T _$identity(T value) => value; - -final _privateConstructorUsedError = UnsupportedError( - 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models'); - -Meal _$MealFromJson(Map json) { - return _Meal.fromJson(json); -} - -/// @nodoc -mixin _$Meal { - int get id => throw _privateConstructorUsedError; - String get time => throw _privateConstructorUsedError; - int get type => throw _privateConstructorUsedError; - int get satiety => throw _privateConstructorUsedError; - int get mood => throw _privateConstructorUsedError; - List get portions => throw _privateConstructorUsedError; - List get photos => throw _privateConstructorUsedError; - - /// Serializes this Meal to a JSON map. - Map toJson() => throw _privateConstructorUsedError; - - /// Create a copy of Meal - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - $MealCopyWith get copyWith => throw _privateConstructorUsedError; -} - -/// @nodoc -abstract class $MealCopyWith<$Res> { - factory $MealCopyWith(Meal value, $Res Function(Meal) then) = - _$MealCopyWithImpl<$Res, Meal>; - @useResult - $Res call( - {int id, - String time, - int type, - int satiety, - int mood, - List portions, - List photos}); -} - -/// @nodoc -class _$MealCopyWithImpl<$Res, $Val extends Meal> - implements $MealCopyWith<$Res> { - _$MealCopyWithImpl(this._value, this._then); - - // ignore: unused_field - final $Val _value; - // ignore: unused_field - final $Res Function($Val) _then; - - /// Create a copy of Meal - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? id = null, - Object? time = null, - Object? type = null, - Object? satiety = null, - Object? mood = null, - Object? portions = null, - Object? photos = null, - }) { - return _then(_value.copyWith( - id: null == id - ? _value.id - : id // ignore: cast_nullable_to_non_nullable - as int, - time: null == time - ? _value.time - : time // ignore: cast_nullable_to_non_nullable - as String, - type: null == type - ? _value.type - : type // ignore: cast_nullable_to_non_nullable - as int, - satiety: null == satiety - ? _value.satiety - : satiety // ignore: cast_nullable_to_non_nullable - as int, - mood: null == mood - ? _value.mood - : mood // ignore: cast_nullable_to_non_nullable - as int, - portions: null == portions - ? _value.portions - : portions // ignore: cast_nullable_to_non_nullable - as List, - photos: null == photos - ? _value.photos - : photos // ignore: cast_nullable_to_non_nullable - as List, - ) as $Val); - } -} - -/// @nodoc -abstract class _$$MealImplCopyWith<$Res> implements $MealCopyWith<$Res> { - factory _$$MealImplCopyWith( - _$MealImpl value, $Res Function(_$MealImpl) then) = - __$$MealImplCopyWithImpl<$Res>; - @override - @useResult - $Res call( - {int id, - String time, - int type, - int satiety, - int mood, - List portions, - List photos}); -} - -/// @nodoc -class __$$MealImplCopyWithImpl<$Res> - extends _$MealCopyWithImpl<$Res, _$MealImpl> - implements _$$MealImplCopyWith<$Res> { - __$$MealImplCopyWithImpl(_$MealImpl _value, $Res Function(_$MealImpl) _then) - : super(_value, _then); - - /// Create a copy of Meal - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? id = null, - Object? time = null, - Object? type = null, - Object? satiety = null, - Object? mood = null, - Object? portions = null, - Object? photos = null, - }) { - return _then(_$MealImpl( - id: null == id - ? _value.id - : id // ignore: cast_nullable_to_non_nullable - as int, - time: null == time - ? _value.time - : time // ignore: cast_nullable_to_non_nullable - as String, - type: null == type - ? _value.type - : type // ignore: cast_nullable_to_non_nullable - as int, - satiety: null == satiety - ? _value.satiety - : satiety // ignore: cast_nullable_to_non_nullable - as int, - mood: null == mood - ? _value.mood - : mood // ignore: cast_nullable_to_non_nullable - as int, - portions: null == portions - ? _value._portions - : portions // ignore: cast_nullable_to_non_nullable - as List, - photos: null == photos - ? _value._photos - : photos // ignore: cast_nullable_to_non_nullable - as List, - )); - } -} - -/// @nodoc -@JsonSerializable() -class _$MealImpl implements _Meal { - const _$MealImpl( - {required this.id, - required this.time, - required this.type, - required this.satiety, - required this.mood, - required final List portions, - required final List photos}) - : _portions = portions, - _photos = photos; - - factory _$MealImpl.fromJson(Map json) => - _$$MealImplFromJson(json); - - @override - final int id; - @override - final String time; - @override - final int type; - @override - final int satiety; - @override - final int mood; - final List _portions; - @override - List get portions { - if (_portions is EqualUnmodifiableListView) return _portions; - // ignore: implicit_dynamic_type - return EqualUnmodifiableListView(_portions); - } - - final List _photos; - @override - List get photos { - if (_photos is EqualUnmodifiableListView) return _photos; - // ignore: implicit_dynamic_type - return EqualUnmodifiableListView(_photos); - } - - @override - String toString() { - return 'Meal(id: $id, time: $time, type: $type, satiety: $satiety, mood: $mood, portions: $portions, photos: $photos)'; - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _$MealImpl && - (identical(other.id, id) || other.id == id) && - (identical(other.time, time) || other.time == time) && - (identical(other.type, type) || other.type == type) && - (identical(other.satiety, satiety) || other.satiety == satiety) && - (identical(other.mood, mood) || other.mood == mood) && - const DeepCollectionEquality().equals(other._portions, _portions) && - const DeepCollectionEquality().equals(other._photos, _photos)); - } - - @JsonKey(includeFromJson: false, includeToJson: false) - @override - int get hashCode => Object.hash( - runtimeType, - id, - time, - type, - satiety, - mood, - const DeepCollectionEquality().hash(_portions), - const DeepCollectionEquality().hash(_photos)); - - /// Create a copy of Meal - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - @override - @pragma('vm:prefer-inline') - _$$MealImplCopyWith<_$MealImpl> get copyWith => - __$$MealImplCopyWithImpl<_$MealImpl>(this, _$identity); - - @override - Map toJson() { - return _$$MealImplToJson( - this, - ); - } -} - -abstract class _Meal implements Meal { - const factory _Meal( - {required final int id, - required final String time, - required final int type, - required final int satiety, - required final int mood, - required final List portions, - required final List photos}) = _$MealImpl; - - factory _Meal.fromJson(Map json) = _$MealImpl.fromJson; - - @override - int get id; - @override - String get time; - @override - int get type; - @override - int get satiety; - @override - int get mood; - @override - List get portions; - @override - List get photos; - - /// Create a copy of Meal - /// with the given fields replaced by the non-null parameter values. - @override - @JsonKey(includeFromJson: false, includeToJson: false) - _$$MealImplCopyWith<_$MealImpl> get copyWith => - throw _privateConstructorUsedError; -} diff --git a/lib/features/diary/models/meal.g.dart b/lib/features/diary/models/meal.g.dart deleted file mode 100644 index 5536ed92..00000000 --- a/lib/features/diary/models/meal.g.dart +++ /dev/null @@ -1,32 +0,0 @@ -// GENERATED CODE - DO NOT MODIFY BY HAND - -part of 'meal.dart'; - -// ************************************************************************** -// JsonSerializableGenerator -// ************************************************************************** - -_$MealImpl _$$MealImplFromJson(Map json) => _$MealImpl( - id: (json['id'] as num).toInt(), - time: json['time'] as String, - type: (json['type'] as num).toInt(), - satiety: (json['satiety'] as num).toInt(), - mood: (json['mood'] as num).toInt(), - portions: (json['portions'] as List) - .map((e) => Portion.fromJson(e as Map)) - .toList(), - photos: (json['photos'] as List) - .map((e) => Photo.fromJson(e as Map)) - .toList(), - ); - -Map _$$MealImplToJson(_$MealImpl instance) => - { - 'id': instance.id, - 'time': instance.time, - 'type': instance.type, - 'satiety': instance.satiety, - 'mood': instance.mood, - 'portions': instance.portions, - 'photos': instance.photos, - }; diff --git a/lib/features/diary/models/photo.dart b/lib/features/diary/models/photo.dart deleted file mode 100644 index d3e4f695..00000000 --- a/lib/features/diary/models/photo.dart +++ /dev/null @@ -1,16 +0,0 @@ -import 'package:freezed_annotation/freezed_annotation.dart'; - -part 'photo.freezed.dart'; - -part 'photo.g.dart'; - -@freezed -class Photo with _$Photo { - const factory Photo({ - required int id, - @JsonKey(name: 'original_name') required String originalName, - required String path, - }) = _Photo; - - factory Photo.fromJson(Map json) => _$PhotoFromJson(json); -} diff --git a/lib/features/diary/models/photo.freezed.dart b/lib/features/diary/models/photo.freezed.dart deleted file mode 100644 index 8f5e0152..00000000 --- a/lib/features/diary/models/photo.freezed.dart +++ /dev/null @@ -1,208 +0,0 @@ -// 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 'photo.dart'; - -// ************************************************************************** -// FreezedGenerator -// ************************************************************************** - -T _$identity(T value) => value; - -final _privateConstructorUsedError = UnsupportedError( - 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models'); - -Photo _$PhotoFromJson(Map json) { - return _Photo.fromJson(json); -} - -/// @nodoc -mixin _$Photo { - int get id => throw _privateConstructorUsedError; - @JsonKey(name: 'original_name') - String get originalName => throw _privateConstructorUsedError; - String get path => throw _privateConstructorUsedError; - - /// Serializes this Photo to a JSON map. - Map toJson() => throw _privateConstructorUsedError; - - /// Create a copy of Photo - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - $PhotoCopyWith get copyWith => throw _privateConstructorUsedError; -} - -/// @nodoc -abstract class $PhotoCopyWith<$Res> { - factory $PhotoCopyWith(Photo value, $Res Function(Photo) then) = - _$PhotoCopyWithImpl<$Res, Photo>; - @useResult - $Res call( - {int id, - @JsonKey(name: 'original_name') String originalName, - String path}); -} - -/// @nodoc -class _$PhotoCopyWithImpl<$Res, $Val extends Photo> - implements $PhotoCopyWith<$Res> { - _$PhotoCopyWithImpl(this._value, this._then); - - // ignore: unused_field - final $Val _value; - // ignore: unused_field - final $Res Function($Val) _then; - - /// Create a copy of Photo - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? id = null, - Object? originalName = null, - Object? path = null, - }) { - return _then(_value.copyWith( - id: null == id - ? _value.id - : id // ignore: cast_nullable_to_non_nullable - as int, - originalName: null == originalName - ? _value.originalName - : originalName // ignore: cast_nullable_to_non_nullable - as String, - path: null == path - ? _value.path - : path // ignore: cast_nullable_to_non_nullable - as String, - ) as $Val); - } -} - -/// @nodoc -abstract class _$$PhotoImplCopyWith<$Res> implements $PhotoCopyWith<$Res> { - factory _$$PhotoImplCopyWith( - _$PhotoImpl value, $Res Function(_$PhotoImpl) then) = - __$$PhotoImplCopyWithImpl<$Res>; - @override - @useResult - $Res call( - {int id, - @JsonKey(name: 'original_name') String originalName, - String path}); -} - -/// @nodoc -class __$$PhotoImplCopyWithImpl<$Res> - extends _$PhotoCopyWithImpl<$Res, _$PhotoImpl> - implements _$$PhotoImplCopyWith<$Res> { - __$$PhotoImplCopyWithImpl( - _$PhotoImpl _value, $Res Function(_$PhotoImpl) _then) - : super(_value, _then); - - /// Create a copy of Photo - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? id = null, - Object? originalName = null, - Object? path = null, - }) { - return _then(_$PhotoImpl( - id: null == id - ? _value.id - : id // ignore: cast_nullable_to_non_nullable - as int, - originalName: null == originalName - ? _value.originalName - : originalName // ignore: cast_nullable_to_non_nullable - as String, - path: null == path - ? _value.path - : path // ignore: cast_nullable_to_non_nullable - as String, - )); - } -} - -/// @nodoc -@JsonSerializable() -class _$PhotoImpl implements _Photo { - const _$PhotoImpl( - {required this.id, - @JsonKey(name: 'original_name') required this.originalName, - required this.path}); - - factory _$PhotoImpl.fromJson(Map json) => - _$$PhotoImplFromJson(json); - - @override - final int id; - @override - @JsonKey(name: 'original_name') - final String originalName; - @override - final String path; - - @override - String toString() { - return 'Photo(id: $id, originalName: $originalName, path: $path)'; - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _$PhotoImpl && - (identical(other.id, id) || other.id == id) && - (identical(other.originalName, originalName) || - other.originalName == originalName) && - (identical(other.path, path) || other.path == path)); - } - - @JsonKey(includeFromJson: false, includeToJson: false) - @override - int get hashCode => Object.hash(runtimeType, id, originalName, path); - - /// Create a copy of Photo - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - @override - @pragma('vm:prefer-inline') - _$$PhotoImplCopyWith<_$PhotoImpl> get copyWith => - __$$PhotoImplCopyWithImpl<_$PhotoImpl>(this, _$identity); - - @override - Map toJson() { - return _$$PhotoImplToJson( - this, - ); - } -} - -abstract class _Photo implements Photo { - const factory _Photo( - {required final int id, - @JsonKey(name: 'original_name') required final String originalName, - required final String path}) = _$PhotoImpl; - - factory _Photo.fromJson(Map json) = _$PhotoImpl.fromJson; - - @override - int get id; - @override - @JsonKey(name: 'original_name') - String get originalName; - @override - String get path; - - /// Create a copy of Photo - /// with the given fields replaced by the non-null parameter values. - @override - @JsonKey(includeFromJson: false, includeToJson: false) - _$$PhotoImplCopyWith<_$PhotoImpl> get copyWith => - throw _privateConstructorUsedError; -} diff --git a/lib/features/diary/models/portion.dart b/lib/features/diary/models/portion.dart deleted file mode 100644 index f829dcf9..00000000 --- a/lib/features/diary/models/portion.dart +++ /dev/null @@ -1,18 +0,0 @@ -import 'package:freezed_annotation/freezed_annotation.dart'; - -part 'portion.freezed.dart'; - -part 'portion.g.dart'; - -@freezed -class Portion with _$Portion { - const factory Portion({ - required int id, - required String product_name, - required int quantity, - required String portion, - required bool from_diet, - }) = _Portion; - - factory Portion.fromJson(Map json) => _$PortionFromJson(json); -} diff --git a/lib/features/diary/models/portion.freezed.dart b/lib/features/diary/models/portion.freezed.dart deleted file mode 100644 index 4bef02d4..00000000 --- a/lib/features/diary/models/portion.freezed.dart +++ /dev/null @@ -1,248 +0,0 @@ -// 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 'portion.dart'; - -// ************************************************************************** -// FreezedGenerator -// ************************************************************************** - -T _$identity(T value) => value; - -final _privateConstructorUsedError = UnsupportedError( - 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models'); - -Portion _$PortionFromJson(Map json) { - return _Portion.fromJson(json); -} - -/// @nodoc -mixin _$Portion { - int get id => throw _privateConstructorUsedError; - String get product_name => throw _privateConstructorUsedError; - int get quantity => throw _privateConstructorUsedError; - String get portion => throw _privateConstructorUsedError; - bool get from_diet => throw _privateConstructorUsedError; - - /// Serializes this Portion to a JSON map. - Map toJson() => throw _privateConstructorUsedError; - - /// Create a copy of Portion - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - $PortionCopyWith get copyWith => throw _privateConstructorUsedError; -} - -/// @nodoc -abstract class $PortionCopyWith<$Res> { - factory $PortionCopyWith(Portion value, $Res Function(Portion) then) = - _$PortionCopyWithImpl<$Res, Portion>; - @useResult - $Res call( - {int id, - String product_name, - int quantity, - String portion, - bool from_diet}); -} - -/// @nodoc -class _$PortionCopyWithImpl<$Res, $Val extends Portion> - implements $PortionCopyWith<$Res> { - _$PortionCopyWithImpl(this._value, this._then); - - // ignore: unused_field - final $Val _value; - // ignore: unused_field - final $Res Function($Val) _then; - - /// Create a copy of Portion - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? id = null, - Object? product_name = null, - Object? quantity = null, - Object? portion = null, - Object? from_diet = null, - }) { - return _then(_value.copyWith( - id: null == id - ? _value.id - : id // ignore: cast_nullable_to_non_nullable - as int, - product_name: null == product_name - ? _value.product_name - : product_name // ignore: cast_nullable_to_non_nullable - as String, - quantity: null == quantity - ? _value.quantity - : quantity // ignore: cast_nullable_to_non_nullable - as int, - portion: null == portion - ? _value.portion - : portion // ignore: cast_nullable_to_non_nullable - as String, - from_diet: null == from_diet - ? _value.from_diet - : from_diet // ignore: cast_nullable_to_non_nullable - as bool, - ) as $Val); - } -} - -/// @nodoc -abstract class _$$PortionImplCopyWith<$Res> implements $PortionCopyWith<$Res> { - factory _$$PortionImplCopyWith( - _$PortionImpl value, $Res Function(_$PortionImpl) then) = - __$$PortionImplCopyWithImpl<$Res>; - @override - @useResult - $Res call( - {int id, - String product_name, - int quantity, - String portion, - bool from_diet}); -} - -/// @nodoc -class __$$PortionImplCopyWithImpl<$Res> - extends _$PortionCopyWithImpl<$Res, _$PortionImpl> - implements _$$PortionImplCopyWith<$Res> { - __$$PortionImplCopyWithImpl( - _$PortionImpl _value, $Res Function(_$PortionImpl) _then) - : super(_value, _then); - - /// Create a copy of Portion - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? id = null, - Object? product_name = null, - Object? quantity = null, - Object? portion = null, - Object? from_diet = null, - }) { - return _then(_$PortionImpl( - id: null == id - ? _value.id - : id // ignore: cast_nullable_to_non_nullable - as int, - product_name: null == product_name - ? _value.product_name - : product_name // ignore: cast_nullable_to_non_nullable - as String, - quantity: null == quantity - ? _value.quantity - : quantity // ignore: cast_nullable_to_non_nullable - as int, - portion: null == portion - ? _value.portion - : portion // ignore: cast_nullable_to_non_nullable - as String, - from_diet: null == from_diet - ? _value.from_diet - : from_diet // ignore: cast_nullable_to_non_nullable - as bool, - )); - } -} - -/// @nodoc -@JsonSerializable() -class _$PortionImpl implements _Portion { - const _$PortionImpl( - {required this.id, - required this.product_name, - required this.quantity, - required this.portion, - required this.from_diet}); - - factory _$PortionImpl.fromJson(Map json) => - _$$PortionImplFromJson(json); - - @override - final int id; - @override - final String product_name; - @override - final int quantity; - @override - final String portion; - @override - final bool from_diet; - - @override - String toString() { - return 'Portion(id: $id, product_name: $product_name, quantity: $quantity, portion: $portion, from_diet: $from_diet)'; - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _$PortionImpl && - (identical(other.id, id) || other.id == id) && - (identical(other.product_name, product_name) || - other.product_name == product_name) && - (identical(other.quantity, quantity) || - other.quantity == quantity) && - (identical(other.portion, portion) || other.portion == portion) && - (identical(other.from_diet, from_diet) || - other.from_diet == from_diet)); - } - - @JsonKey(includeFromJson: false, includeToJson: false) - @override - int get hashCode => - Object.hash(runtimeType, id, product_name, quantity, portion, from_diet); - - /// Create a copy of Portion - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - @override - @pragma('vm:prefer-inline') - _$$PortionImplCopyWith<_$PortionImpl> get copyWith => - __$$PortionImplCopyWithImpl<_$PortionImpl>(this, _$identity); - - @override - Map toJson() { - return _$$PortionImplToJson( - this, - ); - } -} - -abstract class _Portion implements Portion { - const factory _Portion( - {required final int id, - required final String product_name, - required final int quantity, - required final String portion, - required final bool from_diet}) = _$PortionImpl; - - factory _Portion.fromJson(Map json) = _$PortionImpl.fromJson; - - @override - int get id; - @override - String get product_name; - @override - int get quantity; - @override - String get portion; - @override - bool get from_diet; - - /// Create a copy of Portion - /// with the given fields replaced by the non-null parameter values. - @override - @JsonKey(includeFromJson: false, includeToJson: false) - _$$PortionImplCopyWith<_$PortionImpl> get copyWith => - throw _privateConstructorUsedError; -} diff --git a/lib/features/diary/models/portion.g.dart b/lib/features/diary/models/portion.g.dart deleted file mode 100644 index f3503e5c..00000000 --- a/lib/features/diary/models/portion.g.dart +++ /dev/null @@ -1,25 +0,0 @@ -// GENERATED CODE - DO NOT MODIFY BY HAND - -part of 'portion.dart'; - -// ************************************************************************** -// JsonSerializableGenerator -// ************************************************************************** - -_$PortionImpl _$$PortionImplFromJson(Map json) => - _$PortionImpl( - id: (json['id'] as num).toInt(), - product_name: json['product_name'] as String, - quantity: (json['quantity'] as num).toInt(), - portion: json['portion'] as String, - from_diet: json['from_diet'] as bool, - ); - -Map _$$PortionImplToJson(_$PortionImpl instance) => - { - 'id': instance.id, - 'product_name': instance.product_name, - 'quantity': instance.quantity, - 'portion': instance.portion, - 'from_diet': instance.from_diet, - }; diff --git a/lib/features/diary/models/state.dart b/lib/features/diary/models/state.dart deleted file mode 100644 index b1da05c4..00000000 --- a/lib/features/diary/models/state.dart +++ /dev/null @@ -1,15 +0,0 @@ -import 'package:freezed_annotation/freezed_annotation.dart'; - -part 'state.freezed.dart'; - -part 'state.g.dart'; - -@freezed -class State with _$State { - const factory State({ - required bool has_chosen_diet, - required bool has_chosen_plan, - }) = _State; - - factory State.fromJson(Map json) => _$StateFromJson(json); -} diff --git a/lib/features/diary/models/state.freezed.dart b/lib/features/diary/models/state.freezed.dart deleted file mode 100644 index 6b9c50fb..00000000 --- a/lib/features/diary/models/state.freezed.dart +++ /dev/null @@ -1,182 +0,0 @@ -// 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 'state.dart'; - -// ************************************************************************** -// FreezedGenerator -// ************************************************************************** - -T _$identity(T value) => value; - -final _privateConstructorUsedError = UnsupportedError( - 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models'); - -State _$StateFromJson(Map json) { - return _State.fromJson(json); -} - -/// @nodoc -mixin _$State { - bool get has_chosen_diet => throw _privateConstructorUsedError; - bool get has_chosen_plan => throw _privateConstructorUsedError; - - /// Serializes this State to a JSON map. - Map toJson() => throw _privateConstructorUsedError; - - /// Create a copy of State - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - $StateCopyWith get copyWith => throw _privateConstructorUsedError; -} - -/// @nodoc -abstract class $StateCopyWith<$Res> { - factory $StateCopyWith(State value, $Res Function(State) then) = - _$StateCopyWithImpl<$Res, State>; - @useResult - $Res call({bool has_chosen_diet, bool has_chosen_plan}); -} - -/// @nodoc -class _$StateCopyWithImpl<$Res, $Val extends State> - implements $StateCopyWith<$Res> { - _$StateCopyWithImpl(this._value, this._then); - - // ignore: unused_field - final $Val _value; - // ignore: unused_field - final $Res Function($Val) _then; - - /// Create a copy of State - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? has_chosen_diet = null, - Object? has_chosen_plan = null, - }) { - return _then(_value.copyWith( - has_chosen_diet: null == has_chosen_diet - ? _value.has_chosen_diet - : has_chosen_diet // ignore: cast_nullable_to_non_nullable - as bool, - has_chosen_plan: null == has_chosen_plan - ? _value.has_chosen_plan - : has_chosen_plan // ignore: cast_nullable_to_non_nullable - as bool, - ) as $Val); - } -} - -/// @nodoc -abstract class _$$StateImplCopyWith<$Res> implements $StateCopyWith<$Res> { - factory _$$StateImplCopyWith( - _$StateImpl value, $Res Function(_$StateImpl) then) = - __$$StateImplCopyWithImpl<$Res>; - @override - @useResult - $Res call({bool has_chosen_diet, bool has_chosen_plan}); -} - -/// @nodoc -class __$$StateImplCopyWithImpl<$Res> - extends _$StateCopyWithImpl<$Res, _$StateImpl> - implements _$$StateImplCopyWith<$Res> { - __$$StateImplCopyWithImpl( - _$StateImpl _value, $Res Function(_$StateImpl) _then) - : super(_value, _then); - - /// Create a copy of State - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? has_chosen_diet = null, - Object? has_chosen_plan = null, - }) { - return _then(_$StateImpl( - has_chosen_diet: null == has_chosen_diet - ? _value.has_chosen_diet - : has_chosen_diet // ignore: cast_nullable_to_non_nullable - as bool, - has_chosen_plan: null == has_chosen_plan - ? _value.has_chosen_plan - : has_chosen_plan // ignore: cast_nullable_to_non_nullable - as bool, - )); - } -} - -/// @nodoc -@JsonSerializable() -class _$StateImpl implements _State { - const _$StateImpl( - {required this.has_chosen_diet, required this.has_chosen_plan}); - - factory _$StateImpl.fromJson(Map json) => - _$$StateImplFromJson(json); - - @override - final bool has_chosen_diet; - @override - final bool has_chosen_plan; - - @override - String toString() { - return 'State(has_chosen_diet: $has_chosen_diet, has_chosen_plan: $has_chosen_plan)'; - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _$StateImpl && - (identical(other.has_chosen_diet, has_chosen_diet) || - other.has_chosen_diet == has_chosen_diet) && - (identical(other.has_chosen_plan, has_chosen_plan) || - other.has_chosen_plan == has_chosen_plan)); - } - - @JsonKey(includeFromJson: false, includeToJson: false) - @override - int get hashCode => - Object.hash(runtimeType, has_chosen_diet, has_chosen_plan); - - /// Create a copy of State - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - @override - @pragma('vm:prefer-inline') - _$$StateImplCopyWith<_$StateImpl> get copyWith => - __$$StateImplCopyWithImpl<_$StateImpl>(this, _$identity); - - @override - Map toJson() { - return _$$StateImplToJson( - this, - ); - } -} - -abstract class _State implements State { - const factory _State( - {required final bool has_chosen_diet, - required final bool has_chosen_plan}) = _$StateImpl; - - factory _State.fromJson(Map json) = _$StateImpl.fromJson; - - @override - bool get has_chosen_diet; - @override - bool get has_chosen_plan; - - /// Create a copy of State - /// with the given fields replaced by the non-null parameter values. - @override - @JsonKey(includeFromJson: false, includeToJson: false) - _$$StateImplCopyWith<_$StateImpl> get copyWith => - throw _privateConstructorUsedError; -} diff --git a/lib/features/diary/models/state.g.dart b/lib/features/diary/models/state.g.dart deleted file mode 100644 index 1b0da8f4..00000000 --- a/lib/features/diary/models/state.g.dart +++ /dev/null @@ -1,18 +0,0 @@ -// GENERATED CODE - DO NOT MODIFY BY HAND - -part of 'state.dart'; - -// ************************************************************************** -// JsonSerializableGenerator -// ************************************************************************** - -_$StateImpl _$$StateImplFromJson(Map json) => _$StateImpl( - has_chosen_diet: json['has_chosen_diet'] as bool, - has_chosen_plan: json['has_chosen_plan'] as bool, - ); - -Map _$$StateImplToJson(_$StateImpl instance) => - { - 'has_chosen_diet': instance.has_chosen_diet, - 'has_chosen_plan': instance.has_chosen_plan, - }; diff --git a/lib/features/diary/presentation/bloc/diary_bloc.dart b/lib/features/diary/presentation/bloc/diary_bloc.dart deleted file mode 100644 index cee99a34..00000000 --- a/lib/features/diary/presentation/bloc/diary_bloc.dart +++ /dev/null @@ -1,517 +0,0 @@ -import 'dart:async'; - -import 'package:eatvio_app/data/models/selectionPopupModel/selection_popup_model.dart'; -import 'package:eatvio_app/features/diary/models/diary_model.dart'; -import 'package:eatvio_app/features/diary/models/meal.dart'; -import 'package:eatvio_app/features/diary/models/product.dart'; -import 'package:eatvio_app/features/diary/presentation/bloc/diary_state.dart'; -import 'package:eatvio_app/features/diary/repositories/diary_repository.dart'; -import 'package:equatable/equatable.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter_bloc/flutter_bloc.dart'; -import 'package:image_picker/image_picker.dart'; -import 'package:intl/intl.dart'; - -part 'diary_event.dart'; - -/// A bloc that manages the state of a Diary according to the event that is dispatched to it. -class DiaryBloc extends Bloc { - final DiaryRepository diaryRepository; - - DiaryBloc({required this.diaryRepository}) : super(const DiaryState.loading()) { - on(loadDiary); - on(loadDiaryById); - on(_changeSatiety); // пользователь нажимает на шкалу сытости - on(_changeMood); // пользователь нажимает на шкалу настроения - on(_changeMealTime); // пользовательяет времяа пиши - on(_changeMeal); - on(_changePortion); - on(_changeWakeup); // пользователь выбирает время пробуждения - on(_changeRetire); // пользователь выбирает время отхода ко сну - on(_toggleMood); - on(_toggleWakeup); - on(_addPortion); //пользователь нажимает "Добавить продукт" - on(_removePortion); - on( - _removeImage, - ); // пользователь нажимает на крестик около продукта - on(_uploadImages); //пользователь нажимает "Добавить фото" - on( - _inputProduct, - ); - on(_finishDay); - on(_sendModeration); - on(_clearInput); - on(_confirmPortion); - } - - loadDiary( - LoadDiary event, - Emitter emit, - ) async { - emit(const DiaryState.loading()); - try { - Map data = await diaryRepository.getDiaryID(); - - final int? diaryID = data['id']; - final DiaryModel diary = await diaryRepository.getDiary(diaryID ?? 45); - final Meal currentMeal = diary.meals[0]; - - List portionList = [SelectionPopupModel(title: "грамм", value: "gr"), SelectionPopupModel(title: "порций", value: "pcs")]; - - final Map chartData = await diaryRepository.getChartData(diaryID ?? 45); - final Map dailyNutritionIntake = chartData['dailyNutritionIntake']!; - final Map dailyNutritionRecommendations = chartData['dailyNutritionRecommendation']!; - final double ccal = dailyNutritionIntake['energy']! / dailyNutritionRecommendations['energy']! * 50; - final double proteins = dailyNutritionIntake['proteins']! / dailyNutritionRecommendations['proteins']! * 50; - final double fats = dailyNutritionIntake['fats']! / dailyNutritionRecommendations['fats']! * 50; - final double carbs = dailyNutritionIntake['carbohydrates']! / dailyNutritionRecommendations['carbohydrates']! * 50; - - Color getColor(double value) { - if (value >= 99.1) { - return Colors.red; - } else { - return Colors.blue; - } - } - - final List chartDataCounted = [ - NutritionData('Калории', ccal, getColor(ccal)), - NutritionData('Белки', proteins, getColor(proteins)), - NutritionData('Жиры', fats, getColor(fats)), - NutritionData('Углеводы', carbs, getColor(carbs)), - ]; - - List mealList = [ - SelectionPopupModel(title: "Прием пищи 1", id: 1), - SelectionPopupModel(title: "Прием пищи 2", id: 2), - SelectionPopupModel(title: "Прием пищи 3", id: 3), - SelectionPopupModel(title: "Прием пищи 4", id: 4), - SelectionPopupModel(title: "Прием пищи 5", id: 5), - SelectionPopupModel(title: "Прием пищи 6", id: 6), - ]; - - emit(DiaryState.loaded( - diary: diary, - currentMeal: currentMeal, - portions: currentMeal.portions, - portionList: portionList, - portionController: portionList[0], - mealList: mealList, - chartData: chartData, - chartDataCounted: chartDataCounted, - selectedMood: currentMeal.mood, - selectedSatiety: currentMeal.satiety, - wakeupController: TimeOfDay.now(), - retireController: TimeOfDay.now(), - commentController: TextEditingController(), - product_nameController: TextEditingController(), - productQuantityController: TextEditingController(), - caloriesController: TextEditingController(), - fatsController: TextEditingController(), - proteinsController: TextEditingController(), - carbsController: TextEditingController(), - wakeupExpanded: false, - moderationExpanded: false, - moodExpanded: false, - isLoading: false, - isAdded: false, - autocompleteList: [], - recommendedChartValues: [1, 1, 1, 1], - consumedChartValues: [1, 1, 1, 1])); - } catch (e) { - emit(DiaryState.error(errorMessage: e.toString())); - } - } - - loadDiaryById( - LoadDiaryById event, - Emitter emit, - ) async { - emit(const DiaryState.loading()); - try { - final int diaryID = int.parse(event.id ?? "0"); - final DiaryModel diary = await diaryRepository.getDiary(diaryID); - final Meal currentMeal = diary.meals[0]; - - List portionList = [SelectionPopupModel(title: "gr"), SelectionPopupModel(title: "pcs")]; - - final Map chartData = await diaryRepository.getChartData(diaryID); - final Map dailyNutritionIntake = chartData['dailyNutritionIntake']!; - final Map dailyNutritionRecommendations = chartData['dailyNutritionRecommendation']!; - final double ccal = dailyNutritionIntake['energy']! / dailyNutritionRecommendations['energy']! * 50; - final double proteins = dailyNutritionIntake['proteins']! / dailyNutritionRecommendations['proteins']! * 50; - final double fats = dailyNutritionIntake['fats']! / dailyNutritionRecommendations['fats']! * 50; - final double carbs = dailyNutritionIntake['carbohydrates']! / dailyNutritionRecommendations['carbohydrates']! * 50; - - Color getColor(double value) { - if (value >= 99.1) { - return Colors.red; - } else { - return Colors.blue; - } - } - - final List chartDataCounted = [ - NutritionData('Калории', ccal, getColor(ccal)), - NutritionData('Белки', proteins, getColor(proteins)), - NutritionData('Жиры', fats, getColor(fats)), - NutritionData('Углеводы', carbs, getColor(carbs)), - ]; - - List mealList = [ - SelectionPopupModel(title: "Прием пищи 1", id: 1), - SelectionPopupModel(title: "Прием пищи 2", id: 2), - SelectionPopupModel(title: "Прием пищи 3", id: 3), - SelectionPopupModel(title: "Прием пищи 4", id: 4), - SelectionPopupModel(title: "Прием пищи 5", id: 5), - SelectionPopupModel(title: "Прием пищи 6", id: 6), - ]; - - emit(DiaryState.loaded( - diary: diary, - currentMeal: currentMeal, - portions: currentMeal.portions, - portionList: portionList, - portionController: portionList[0], - mealList: mealList, - chartData: chartData, - chartDataCounted: chartDataCounted, - selectedMood: currentMeal.mood, - selectedSatiety: currentMeal.satiety, - wakeupController: TimeOfDay.now(), - retireController: TimeOfDay.now(), - commentController: TextEditingController(), - product_nameController: TextEditingController(), - productQuantityController: TextEditingController(), - caloriesController: TextEditingController(), - fatsController: TextEditingController(), - proteinsController: TextEditingController(), - carbsController: TextEditingController(), - wakeupExpanded: false, - moderationExpanded: false, - moodExpanded: false, - isLoading: false, - isAdded: false, - autocompleteList: [], - recommendedChartValues: [1, 1, 1, 1], - consumedChartValues: [1, 1, 1, 1])); - } catch (e) { - emit(DiaryState.error(errorMessage: e.toString())); - } - } - - Future _changeSatiety( - ChangeSatiety event, - Emitter emit, - ) async { - if (state is DiaryStateLoaded) { - var currentState = state as DiaryStateLoaded; - var updatedState = currentState.copyWith( - selectedSatiety: event.selectedElement, - ); - diaryRepository.changeSatiety( - event.selectedElement, - currentState.currentMeal.id, - currentState.diary.id, - ); - emit(updatedState); - } - } - - Future _changeMood( - ChangeMood event, - Emitter emit, - ) async { - if (state is DiaryStateLoaded) { - var currentState = state as DiaryStateLoaded; - var updatedState = currentState.copyWith( - selectedMood: event.selectedElement, - ); - - diaryRepository.changeMood( - event.selectedElement, - currentState.currentMeal.id, - currentState.diary.id, - ); - - emit(updatedState); // Передаем обновленное состояние в emit - } - } - - FutureOr _changeWakeup( - WakeupEvent event, - Emitter emit, - ) async { - if (state is DiaryStateLoaded) { - var currentState = state as DiaryStateLoaded; - var updatedState = currentState.copyWith(wakeupController: event.selectedTime); - final DateFormat formatter = DateFormat('HH:mm'); - final String wakeupString = formatter.format(DateTime(2022, 1, 1, event.selectedTime.hour, event.selectedTime.minute)); - await diaryRepository.changeWakeup( - currentState.diary.id, - wakeupString, - ); - emit(updatedState); - } - } - - FutureOr _changeRetire( - RetireEvent event, - Emitter emit, - ) async { - if (state is DiaryStateLoaded) { - var currentState = state as DiaryStateLoaded; - var updatedState = currentState.copyWith(retireController: event.selectedTime); - final DateFormat formatter = DateFormat('HH:mm'); - final String retireString = formatter.format(DateTime(2022, 1, 1, event.selectedTime.hour, event.selectedTime.minute)); - await diaryRepository.changeRetire( - currentState.diary.id, - retireString, - ); - emit(updatedState); - } - } - - FutureOr _changeMealTime( - ChangeMealTime event, - Emitter emit, - ) async { - if (state is DiaryStateLoaded) { - var currentState = state as DiaryStateLoaded; - var updatedState = currentState.copyWith(mealTimeController: event.time); - emit(updatedState); - } - } - - FutureOr _changeMeal( - ChangeMeal event, - Emitter emit, - ) async { - if (state is DiaryStateLoaded) { - final currentState = state as DiaryStateLoaded; - final Meal meal = currentState.diary.meals.firstWhere((meal) => meal.type == event.value.id); - DiaryStateLoaded updatedState = currentState.copyWith( - currentMeal: meal, - portions: meal.portions, - mealTimeController: toTime(meal.time), - selectedMood: meal.mood, - selectedSatiety: meal.satiety, - ); - emit(updatedState); - } - } - - Future _inputProduct( - ProductInput event, - Emitter emit, - ) async { - if (state is DiaryStateLoaded) { - var currentState = state as DiaryStateLoaded; - - final Map> productNutritionalValues = await diaryRepository.inputProduct(event.input); - var updatedState = currentState.copyWith( - product_nameController: TextEditingController(text: event.input), - autocompleteList: productNutritionalValues['product_nutritional_value'] ?? [], - ); - if (event.input.length > 3) { - updatedState = updatedState.copyWith(moderationExpanded: true); - } else { - updatedState = updatedState.copyWith(moderationExpanded: false); - } - - emit(updatedState); - } - } - - FutureOr _addPortion( - AddPortionEvent event, - Emitter emit, - ) async { - if (state is DiaryStateLoaded) { - var currentState = state as DiaryStateLoaded; - await diaryRepository.addPortion( - currentState.diary.id, - currentState.currentMeal.id, - currentState.product_nameController.text, - currentState.portionController.value, - int.parse(currentState.productQuantityController.text), - ); - add(LoadDiary()); - } - } - - Future _removePortion( - RemovePortionEvent event, - Emitter emit, - ) async { - if (state is DiaryStateLoaded) { - var currentState = state as DiaryStateLoaded; - await diaryRepository.removePortion( - currentState.diary.id, - currentState.currentMeal.id, - event.portionId, - ); - } - add(LoadDiary()); - } - - Future _uploadImages( - UploadImages event, - Emitter emit, - ) async { - if (state is DiaryStateLoaded) { - var currentState = state as DiaryStateLoaded; - - emit(currentState.copyWith(isLoading: true)); - await diaryRepository.uploadImage( - event.image.path, - currentState.diary.id, - currentState.currentMeal.id, - ); - add(LoadDiary()); - } - } - - FutureOr _sendModeration( - SendModeration event, - Emitter emit, - ) async { - if (state is DiaryStateLoaded) { - await diaryRepository.sendModeration( - event.name, - event.energyOn100gr, - event.proteinsOn100gr, - event.fatsOn100gr, - event.carbohydratesOn100gr, - ); - } - } - - FutureOr _clearInput( - ClearInput event, - Emitter emit, - ) { - if (state is DiaryStateLoaded) { - var currentState = state as DiaryStateLoaded; - DiaryStateLoaded updatedState = currentState.copyWith(); - emit(updatedState); - } - } - - FutureOr _changePortion( - ChangePortion event, - Emitter emit, - ) { - if (state is DiaryStateLoaded) { - var currentState = state as DiaryStateLoaded; - DiaryStateLoaded updatedState = currentState.copyWith( - portionController: event.value, - ); - emit(updatedState); - } - } - - FutureOr _toggleMood( - ToggleMoodExpandedEvent event, - Emitter emit, - ) { - if (state is DiaryStateLoaded) { - var currentState = state as DiaryStateLoaded; - - emit(currentState.copyWith(moodExpanded: !currentState.moodExpanded)); - } - } - - FutureOr _toggleWakeup( - ToggleWakeupExpandedEvent event, - Emitter emit, - ) { - if (state is DiaryStateLoaded) { - var currentState = state as DiaryStateLoaded; - - emit(currentState.copyWith(wakeupExpanded: !currentState.wakeupExpanded)); - } - } - - FutureOr _removeImage( - RemoveImageEvent event, - Emitter emit, - ) async { - if (state is DiaryStateLoaded) { - var currentState = state as DiaryStateLoaded; - - await diaryRepository.removeImage( - currentState.diary.id, - currentState.currentMeal.id, - int.parse(event.photoID), - event.path, - ); - add(LoadDiary()); - } - } - - Future _finishDay(FinishDay event, Emitter emit) async { - if (state is DiaryStateLoaded) { - var currentState = state as DiaryStateLoaded; - - await diaryRepository.finishDay( - currentState.diary.id, - // currentState.wakeupController, - // currentState.retireController, - // currentState.commentController.text, - ); - add(LoadDiary()); - } - } - - TimeOfDay toTime(String timeStr) { - List timeParts = timeStr.split(":"); - int hour = int.parse(timeParts[0]); - int minute = int.parse(timeParts[1]); - - TimeOfDay timeOfDay = TimeOfDay(hour: hour, minute: minute); - return timeOfDay; - } - - int compareTypes(a, b) { - return a['type'].compareTo(b['type']); - } - - List fillPortion() { - return [ - SelectionPopupModel(id: 0, title: "порций", isSelected: true), - SelectionPopupModel(id: 1, title: "грамм"), - ]; - } - - FutureOr _confirmPortion(ConfirmPortion event, Emitter emit) { - if (state is DiaryStateLoaded) { - var currentState = state as DiaryStateLoaded; - - final updatedPortions = currentState.portions.map((portion) { - if (portion.id == event.id) { - return portion.copyWith(from_diet: !portion.from_diet); - } - if (!portion.from_diet) add(RemovePortionEvent(portion.id)); - return portion; - }).toList(); - - final updatedState = currentState.copyWith(portions: updatedPortions); - - emit(updatedState); - - add(LoadDiary()); - } - } -} - -int convertToInt(dynamic value) { - if (value is int) { - return value; - } else if (value is double) { - return value.toInt(); - } else { - throw FormatException('Unexpected value type: ${value.runtimeType}'); - } -} diff --git a/lib/features/diary/presentation/bloc/diary_cubit.dart b/lib/features/diary/presentation/bloc/diary_cubit.dart new file mode 100644 index 00000000..d5b4fede --- /dev/null +++ b/lib/features/diary/presentation/bloc/diary_cubit.dart @@ -0,0 +1,47 @@ +import 'package:eatvio_app/features/diary/presentation/bloc/diary_state.dart'; +import 'package:eatvio_app/features/diary/repositories/diary_repository.dart'; +import 'package:eatvio_app/features/glossary/models/glossary_model.dart'; +import 'package:eatvio_app/features/glossary/repositories/glossary_repository.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; + +class DiaryCubit extends Cubit { + final DiaryRepository diaryRepository; + final GlossaryRepository glossaryRepository; + + DiaryCubit({ + required this.diaryRepository, + required this.glossaryRepository, + }) : super(const DiaryState.loading()); + + getDiaryDay(String date, [bool needLoading = true]) async { + if (needLoading) emit(const DiaryState.loading()); + try { + emit(DiaryState.loaded(diary: await diaryRepository.getDiaryByDate(date))); + } catch (e) { + emit(DiaryState.error(errorMessage: e.toString())); + throw e; + } + } + + addProductToMeal({ + required int diaryId, + required int mealId, + required String productName, + required String portion, + required int quantity, + required String date, + }) async { + await diaryRepository.addPortionToMeal( + diaryId: diaryId, + mealId: mealId, + productName: productName, + portion: portion, + quantity: quantity, + ); + await getDiaryDay(date, false); + } + + Future> getGlossaryListByQuery(String query) async { + return await glossaryRepository.getGlossaryListByQuery(query); + } +} diff --git a/lib/features/diary/presentation/bloc/diary_event.dart b/lib/features/diary/presentation/bloc/diary_event.dart deleted file mode 100644 index 33c168d7..00000000 --- a/lib/features/diary/presentation/bloc/diary_event.dart +++ /dev/null @@ -1,209 +0,0 @@ -// ignore_for_file: must_be_immutable - -part of 'diary_bloc.dart'; - -/// Abstract class for all events that can be dispatched from the -///Diary widget. -/// -/// Events must be immutable and implement the [Equatable] interface. -@immutable -abstract class DiaryEvent extends Equatable {} - -/// Event that is dispatched when the Diary widget is first created. -class LoadDiary extends DiaryEvent { - @override - List get props => []; -} - -class LoadDiaryById extends DiaryEvent { - LoadDiaryById( - this.id, - ); - - final String? id; - - @override - List get props => []; -} - -class ChangeSatiety extends DiaryEvent { - ChangeSatiety( - this.selectedElement, - ); - - final int selectedElement; - - @override - List get props => [selectedElement]; -} - -class ChangeMood extends DiaryEvent { - ChangeMood( - this.selectedElement, - ); - - final int selectedElement; - - @override - List get props => [selectedElement]; -} - -class ChangeMealTime extends DiaryEvent { - ChangeMealTime(this.time); - - final TimeOfDay time; - - @override - List get props => [time]; -} - -class AddComment extends DiaryEvent { - AddComment(this.diaryId, this.comment); - - final String comment; - final int diaryId; - - @override - List get props => [comment, diaryId]; -} - -class WakeupEvent extends DiaryEvent { - WakeupEvent(this.selectedTime); - - final TimeOfDay selectedTime; - - @override - List get props => [selectedTime]; -} - -class RetireEvent extends DiaryEvent { - RetireEvent(this.selectedTime); - - final TimeOfDay selectedTime; - - @override - List get props => [selectedTime]; -} - -class ToggleMoodExpandedEvent extends DiaryEvent { - @override - List get props => []; -} - -class ToggleWakeupExpandedEvent extends DiaryEvent { - @override - List get props => []; -} - -class AddPortionEvent extends DiaryEvent { - AddPortionEvent(); - - @override - List get props => []; -} - -class RemovePortionEvent extends DiaryEvent { - RemovePortionEvent(this.portionId); - - final int portionId; - - @override - List get props => [portionId]; -} - -class UploadImages extends DiaryEvent { - UploadImages(this.image); - - final XFile image; - - @override - List get props => [image]; -} - -class RemoveImageEvent extends DiaryEvent { - RemoveImageEvent(this.photoID, this.path); - - final String photoID; - final String path; - - @override - List get props => [photoID, path]; -} - -class ProductInput extends DiaryEvent { - ProductInput(this.input); - - final String input; - - @override - List get props => [input]; -} - -class ChangeMeal extends DiaryEvent { - ChangeMeal({required this.value}); - - SelectionPopupModel value; - - @override - List get props => [value]; -} - -class ClearInput extends DiaryEvent { - ClearInput({required this.value}); - - TextEditingController value; - - @override - List get props => [value]; -} - -class ChangePortion extends DiaryEvent { - ChangePortion({required this.value}); - - SelectionPopupModel value; - - @override - List get props => [value]; -} - -class FinishDay extends DiaryEvent { - FinishDay(); - - @override - List get props => []; -} - -class RefreshEvent extends DiaryEvent { - RefreshEvent(); - - @override - List get props => []; -} - -class ConfirmPortion extends DiaryEvent { - ConfirmPortion(this.id); - - int id; - - @override - List get props => [id]; -} - -class SendModeration extends DiaryEvent { - SendModeration({ - required this.name, - required this.energyOn100gr, - required this.proteinsOn100gr, - required this.fatsOn100gr, - required this.carbohydratesOn100gr, - }); - - String name; - String energyOn100gr; - String proteinsOn100gr; - String fatsOn100gr; - String carbohydratesOn100gr; - - @override - List get props => [name, energyOn100gr, proteinsOn100gr, fatsOn100gr, carbohydratesOn100gr]; -} diff --git a/lib/features/diary/presentation/bloc/diary_state.dart b/lib/features/diary/presentation/bloc/diary_state.dart index b0aebfb2..c9b58a8d 100644 --- a/lib/features/diary/presentation/bloc/diary_state.dart +++ b/lib/features/diary/presentation/bloc/diary_state.dart @@ -1,63 +1,19 @@ -import 'package:eatvio_app/features/diary/models/diary_model.dart'; -import 'package:eatvio_app/features/diary/models/meal.dart'; -import 'package:eatvio_app/features/diary/models/portion.dart'; -import 'package:eatvio_app/features/diary/models/product.dart'; -import 'package:flutter/material.dart'; +import 'package:eatvio_app/features/diary/models/diary_day_model.dart'; import 'package:freezed_annotation/freezed_annotation.dart'; -import '../../../../data/models/selectionPopupModel/selection_popup_model.dart'; - part 'diary_state.freezed.dart'; @freezed -abstract class DiaryState with _$DiaryState { +class DiaryState with _$DiaryState { const factory DiaryState() = _DiaryState; - const factory DiaryState.loading({ - int? id, - }) = DiaryStateLoading; - - const factory DiaryState.loaded({ - required DiaryModel diary, - String? diaryDate, - required List recommendedChartValues, - required List consumedChartValues, - required List portions, - required List mealList, - required List portionList, - required List autocompleteList, - required Map chartData, - required Meal currentMeal, - required SelectionPopupModel portionController, - required TimeOfDay wakeupController, - required TimeOfDay retireController, - TimeOfDay? mealTimeController, - required TextEditingController commentController, - required TextEditingController product_nameController, - required TextEditingController productQuantityController, - required TextEditingController caloriesController, - required TextEditingController fatsController, - required TextEditingController proteinsController, - required TextEditingController carbsController, - required int selectedMood, - required int selectedSatiety, - required bool wakeupExpanded, - required bool moderationExpanded, - required bool moodExpanded, - required bool isLoading, - required bool isAdded, - List? chartDataCounted, - }) = DiaryStateLoaded; + const factory DiaryState.loading() = DiaryStateLoading; const factory DiaryState.error({ required String errorMessage, }) = DiaryStateError; -} -class NutritionData { - NutritionData(this.category, this.nutrition, this.color); - - final String category; - final double nutrition; - final Color color; + const factory DiaryState.loaded({ + required DiaryDayModel diary, + }) = DiaryStateLoaded; } diff --git a/lib/features/diary/presentation/bloc/diary_state.freezed.dart b/lib/features/diary/presentation/bloc/diary_state.freezed.dart index 98d7019f..513d217d 100644 --- a/lib/features/diary/presentation/bloc/diary_state.freezed.dart +++ b/lib/features/diary/presentation/bloc/diary_state.freezed.dart @@ -19,115 +19,25 @@ mixin _$DiaryState { @optionalTypeArgs TResult when( TResult Function() $default, { - required TResult Function(int? id) loading, - required TResult Function( - DiaryModel diary, - String? diaryDate, - List recommendedChartValues, - List consumedChartValues, - List portions, - List mealList, - List portionList, - List autocompleteList, - Map chartData, - Meal currentMeal, - SelectionPopupModel portionController, - TimeOfDay wakeupController, - TimeOfDay retireController, - TimeOfDay? mealTimeController, - TextEditingController commentController, - TextEditingController product_nameController, - TextEditingController productQuantityController, - TextEditingController caloriesController, - TextEditingController fatsController, - TextEditingController proteinsController, - TextEditingController carbsController, - int selectedMood, - int selectedSatiety, - bool wakeupExpanded, - bool moderationExpanded, - bool moodExpanded, - bool isLoading, - bool isAdded, - List? chartDataCounted) - loaded, + required TResult Function() loading, required TResult Function(String errorMessage) error, + required TResult Function(DiaryDayModel diary) loaded, }) => throw _privateConstructorUsedError; @optionalTypeArgs TResult? whenOrNull( TResult? Function()? $default, { - TResult? Function(int? id)? loading, - TResult? Function( - DiaryModel diary, - String? diaryDate, - List recommendedChartValues, - List consumedChartValues, - List portions, - List mealList, - List portionList, - List autocompleteList, - Map chartData, - Meal currentMeal, - SelectionPopupModel portionController, - TimeOfDay wakeupController, - TimeOfDay retireController, - TimeOfDay? mealTimeController, - TextEditingController commentController, - TextEditingController product_nameController, - TextEditingController productQuantityController, - TextEditingController caloriesController, - TextEditingController fatsController, - TextEditingController proteinsController, - TextEditingController carbsController, - int selectedMood, - int selectedSatiety, - bool wakeupExpanded, - bool moderationExpanded, - bool moodExpanded, - bool isLoading, - bool isAdded, - List? chartDataCounted)? - loaded, + TResult? Function()? loading, TResult? Function(String errorMessage)? error, + TResult? Function(DiaryDayModel diary)? loaded, }) => throw _privateConstructorUsedError; @optionalTypeArgs TResult maybeWhen( TResult Function()? $default, { - TResult Function(int? id)? loading, - TResult Function( - DiaryModel diary, - String? diaryDate, - List recommendedChartValues, - List consumedChartValues, - List portions, - List mealList, - List portionList, - List autocompleteList, - Map chartData, - Meal currentMeal, - SelectionPopupModel portionController, - TimeOfDay wakeupController, - TimeOfDay retireController, - TimeOfDay? mealTimeController, - TextEditingController commentController, - TextEditingController product_nameController, - TextEditingController productQuantityController, - TextEditingController caloriesController, - TextEditingController fatsController, - TextEditingController proteinsController, - TextEditingController carbsController, - int selectedMood, - int selectedSatiety, - bool wakeupExpanded, - bool moderationExpanded, - bool moodExpanded, - bool isLoading, - bool isAdded, - List? chartDataCounted)? - loaded, + TResult Function()? loading, TResult Function(String errorMessage)? error, + TResult Function(DiaryDayModel diary)? loaded, required TResult orElse(), }) => throw _privateConstructorUsedError; @@ -135,24 +45,24 @@ mixin _$DiaryState { TResult map( TResult Function(_DiaryState value) $default, { required TResult Function(DiaryStateLoading value) loading, - required TResult Function(DiaryStateLoaded value) loaded, required TResult Function(DiaryStateError value) error, + required TResult Function(DiaryStateLoaded value) loaded, }) => throw _privateConstructorUsedError; @optionalTypeArgs TResult? mapOrNull( TResult? Function(_DiaryState value)? $default, { TResult? Function(DiaryStateLoading value)? loading, - TResult? Function(DiaryStateLoaded value)? loaded, TResult? Function(DiaryStateError value)? error, + TResult? Function(DiaryStateLoaded value)? loaded, }) => throw _privateConstructorUsedError; @optionalTypeArgs TResult maybeMap( TResult Function(_DiaryState value)? $default, { TResult Function(DiaryStateLoading value)? loading, - TResult Function(DiaryStateLoaded value)? loaded, TResult Function(DiaryStateError value)? error, + TResult Function(DiaryStateLoaded value)? loaded, required TResult orElse(), }) => throw _privateConstructorUsedError; @@ -221,39 +131,9 @@ class _$DiaryStateImpl implements _DiaryState { @optionalTypeArgs TResult when( TResult Function() $default, { - required TResult Function(int? id) loading, - required TResult Function( - DiaryModel diary, - String? diaryDate, - List recommendedChartValues, - List consumedChartValues, - List portions, - List mealList, - List portionList, - List autocompleteList, - Map chartData, - Meal currentMeal, - SelectionPopupModel portionController, - TimeOfDay wakeupController, - TimeOfDay retireController, - TimeOfDay? mealTimeController, - TextEditingController commentController, - TextEditingController product_nameController, - TextEditingController productQuantityController, - TextEditingController caloriesController, - TextEditingController fatsController, - TextEditingController proteinsController, - TextEditingController carbsController, - int selectedMood, - int selectedSatiety, - bool wakeupExpanded, - bool moderationExpanded, - bool moodExpanded, - bool isLoading, - bool isAdded, - List? chartDataCounted) - loaded, + required TResult Function() loading, required TResult Function(String errorMessage) error, + required TResult Function(DiaryDayModel diary) loaded, }) { return $default(); } @@ -262,39 +142,9 @@ class _$DiaryStateImpl implements _DiaryState { @optionalTypeArgs TResult? whenOrNull( TResult? Function()? $default, { - TResult? Function(int? id)? loading, - TResult? Function( - DiaryModel diary, - String? diaryDate, - List recommendedChartValues, - List consumedChartValues, - List portions, - List mealList, - List portionList, - List autocompleteList, - Map chartData, - Meal currentMeal, - SelectionPopupModel portionController, - TimeOfDay wakeupController, - TimeOfDay retireController, - TimeOfDay? mealTimeController, - TextEditingController commentController, - TextEditingController product_nameController, - TextEditingController productQuantityController, - TextEditingController caloriesController, - TextEditingController fatsController, - TextEditingController proteinsController, - TextEditingController carbsController, - int selectedMood, - int selectedSatiety, - bool wakeupExpanded, - bool moderationExpanded, - bool moodExpanded, - bool isLoading, - bool isAdded, - List? chartDataCounted)? - loaded, + TResult? Function()? loading, TResult? Function(String errorMessage)? error, + TResult? Function(DiaryDayModel diary)? loaded, }) { return $default?.call(); } @@ -303,39 +153,9 @@ class _$DiaryStateImpl implements _DiaryState { @optionalTypeArgs TResult maybeWhen( TResult Function()? $default, { - TResult Function(int? id)? loading, - TResult Function( - DiaryModel diary, - String? diaryDate, - List recommendedChartValues, - List consumedChartValues, - List portions, - List mealList, - List portionList, - List autocompleteList, - Map chartData, - Meal currentMeal, - SelectionPopupModel portionController, - TimeOfDay wakeupController, - TimeOfDay retireController, - TimeOfDay? mealTimeController, - TextEditingController commentController, - TextEditingController product_nameController, - TextEditingController productQuantityController, - TextEditingController caloriesController, - TextEditingController fatsController, - TextEditingController proteinsController, - TextEditingController carbsController, - int selectedMood, - int selectedSatiety, - bool wakeupExpanded, - bool moderationExpanded, - bool moodExpanded, - bool isLoading, - bool isAdded, - List? chartDataCounted)? - loaded, + TResult Function()? loading, TResult Function(String errorMessage)? error, + TResult Function(DiaryDayModel diary)? loaded, required TResult orElse(), }) { if ($default != null) { @@ -349,8 +169,8 @@ class _$DiaryStateImpl implements _DiaryState { TResult map( TResult Function(_DiaryState value) $default, { required TResult Function(DiaryStateLoading value) loading, - required TResult Function(DiaryStateLoaded value) loaded, required TResult Function(DiaryStateError value) error, + required TResult Function(DiaryStateLoaded value) loaded, }) { return $default(this); } @@ -360,8 +180,8 @@ class _$DiaryStateImpl implements _DiaryState { TResult? mapOrNull( TResult? Function(_DiaryState value)? $default, { TResult? Function(DiaryStateLoading value)? loading, - TResult? Function(DiaryStateLoaded value)? loaded, TResult? Function(DiaryStateError value)? error, + TResult? Function(DiaryStateLoaded value)? loaded, }) { return $default?.call(this); } @@ -371,8 +191,8 @@ class _$DiaryStateImpl implements _DiaryState { TResult maybeMap( TResult Function(_DiaryState value)? $default, { TResult Function(DiaryStateLoading value)? loading, - TResult Function(DiaryStateLoaded value)? loaded, TResult Function(DiaryStateError value)? error, + TResult Function(DiaryStateLoaded value)? loaded, required TResult orElse(), }) { if ($default != null) { @@ -391,8 +211,6 @@ abstract class _$$DiaryStateLoadingImplCopyWith<$Res> { factory _$$DiaryStateLoadingImplCopyWith(_$DiaryStateLoadingImpl value, $Res Function(_$DiaryStateLoadingImpl) then) = __$$DiaryStateLoadingImplCopyWithImpl<$Res>; - @useResult - $Res call({int? id}); } /// @nodoc @@ -405,176 +223,60 @@ class __$$DiaryStateLoadingImplCopyWithImpl<$Res> /// Create a copy of DiaryState /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? id = freezed, - }) { - return _then(_$DiaryStateLoadingImpl( - id: freezed == id - ? _value.id - : id // ignore: cast_nullable_to_non_nullable - as int?, - )); - } } /// @nodoc class _$DiaryStateLoadingImpl implements DiaryStateLoading { - const _$DiaryStateLoadingImpl({this.id}); - - @override - final int? id; + const _$DiaryStateLoadingImpl(); @override String toString() { - return 'DiaryState.loading(id: $id)'; + return 'DiaryState.loading()'; } @override bool operator ==(Object other) { return identical(this, other) || - (other.runtimeType == runtimeType && - other is _$DiaryStateLoadingImpl && - (identical(other.id, id) || other.id == id)); + (other.runtimeType == runtimeType && other is _$DiaryStateLoadingImpl); } @override - int get hashCode => Object.hash(runtimeType, id); - - /// Create a copy of DiaryState - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - @override - @pragma('vm:prefer-inline') - _$$DiaryStateLoadingImplCopyWith<_$DiaryStateLoadingImpl> get copyWith => - __$$DiaryStateLoadingImplCopyWithImpl<_$DiaryStateLoadingImpl>( - this, _$identity); + int get hashCode => runtimeType.hashCode; @override @optionalTypeArgs TResult when( TResult Function() $default, { - required TResult Function(int? id) loading, - required TResult Function( - DiaryModel diary, - String? diaryDate, - List recommendedChartValues, - List consumedChartValues, - List portions, - List mealList, - List portionList, - List autocompleteList, - Map chartData, - Meal currentMeal, - SelectionPopupModel portionController, - TimeOfDay wakeupController, - TimeOfDay retireController, - TimeOfDay? mealTimeController, - TextEditingController commentController, - TextEditingController product_nameController, - TextEditingController productQuantityController, - TextEditingController caloriesController, - TextEditingController fatsController, - TextEditingController proteinsController, - TextEditingController carbsController, - int selectedMood, - int selectedSatiety, - bool wakeupExpanded, - bool moderationExpanded, - bool moodExpanded, - bool isLoading, - bool isAdded, - List? chartDataCounted) - loaded, + required TResult Function() loading, required TResult Function(String errorMessage) error, + required TResult Function(DiaryDayModel diary) loaded, }) { - return loading(id); + return loading(); } @override @optionalTypeArgs TResult? whenOrNull( TResult? Function()? $default, { - TResult? Function(int? id)? loading, - TResult? Function( - DiaryModel diary, - String? diaryDate, - List recommendedChartValues, - List consumedChartValues, - List portions, - List mealList, - List portionList, - List autocompleteList, - Map chartData, - Meal currentMeal, - SelectionPopupModel portionController, - TimeOfDay wakeupController, - TimeOfDay retireController, - TimeOfDay? mealTimeController, - TextEditingController commentController, - TextEditingController product_nameController, - TextEditingController productQuantityController, - TextEditingController caloriesController, - TextEditingController fatsController, - TextEditingController proteinsController, - TextEditingController carbsController, - int selectedMood, - int selectedSatiety, - bool wakeupExpanded, - bool moderationExpanded, - bool moodExpanded, - bool isLoading, - bool isAdded, - List? chartDataCounted)? - loaded, + TResult? Function()? loading, TResult? Function(String errorMessage)? error, + TResult? Function(DiaryDayModel diary)? loaded, }) { - return loading?.call(id); + return loading?.call(); } @override @optionalTypeArgs TResult maybeWhen( TResult Function()? $default, { - TResult Function(int? id)? loading, - TResult Function( - DiaryModel diary, - String? diaryDate, - List recommendedChartValues, - List consumedChartValues, - List portions, - List mealList, - List portionList, - List autocompleteList, - Map chartData, - Meal currentMeal, - SelectionPopupModel portionController, - TimeOfDay wakeupController, - TimeOfDay retireController, - TimeOfDay? mealTimeController, - TextEditingController commentController, - TextEditingController product_nameController, - TextEditingController productQuantityController, - TextEditingController caloriesController, - TextEditingController fatsController, - TextEditingController proteinsController, - TextEditingController carbsController, - int selectedMood, - int selectedSatiety, - bool wakeupExpanded, - bool moderationExpanded, - bool moodExpanded, - bool isLoading, - bool isAdded, - List? chartDataCounted)? - loaded, + TResult Function()? loading, TResult Function(String errorMessage)? error, + TResult Function(DiaryDayModel diary)? loaded, required TResult orElse(), }) { if (loading != null) { - return loading(id); + return loading(); } return orElse(); } @@ -584,8 +286,8 @@ class _$DiaryStateLoadingImpl implements DiaryStateLoading { TResult map( TResult Function(_DiaryState value) $default, { required TResult Function(DiaryStateLoading value) loading, - required TResult Function(DiaryStateLoaded value) loaded, required TResult Function(DiaryStateError value) error, + required TResult Function(DiaryStateLoaded value) loaded, }) { return loading(this); } @@ -595,8 +297,8 @@ class _$DiaryStateLoadingImpl implements DiaryStateLoading { TResult? mapOrNull( TResult? Function(_DiaryState value)? $default, { TResult? Function(DiaryStateLoading value)? loading, - TResult? Function(DiaryStateLoaded value)? loaded, TResult? Function(DiaryStateError value)? error, + TResult? Function(DiaryStateLoaded value)? loaded, }) { return loading?.call(this); } @@ -606,8 +308,8 @@ class _$DiaryStateLoadingImpl implements DiaryStateLoading { TResult maybeMap( TResult Function(_DiaryState value)? $default, { TResult Function(DiaryStateLoading value)? loading, - TResult Function(DiaryStateLoaded value)? loaded, TResult Function(DiaryStateError value)? error, + TResult Function(DiaryStateLoaded value)? loaded, required TResult orElse(), }) { if (loading != null) { @@ -618,837 +320,7 @@ class _$DiaryStateLoadingImpl implements DiaryStateLoading { } abstract class DiaryStateLoading implements DiaryState { - const factory DiaryStateLoading({final int? id}) = _$DiaryStateLoadingImpl; - - int? get id; - - /// Create a copy of DiaryState - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - _$$DiaryStateLoadingImplCopyWith<_$DiaryStateLoadingImpl> get copyWith => - throw _privateConstructorUsedError; -} - -/// @nodoc -abstract class _$$DiaryStateLoadedImplCopyWith<$Res> { - factory _$$DiaryStateLoadedImplCopyWith(_$DiaryStateLoadedImpl value, - $Res Function(_$DiaryStateLoadedImpl) then) = - __$$DiaryStateLoadedImplCopyWithImpl<$Res>; - @useResult - $Res call( - {DiaryModel diary, - String? diaryDate, - List recommendedChartValues, - List consumedChartValues, - List portions, - List mealList, - List portionList, - List autocompleteList, - Map chartData, - Meal currentMeal, - SelectionPopupModel portionController, - TimeOfDay wakeupController, - TimeOfDay retireController, - TimeOfDay? mealTimeController, - TextEditingController commentController, - TextEditingController product_nameController, - TextEditingController productQuantityController, - TextEditingController caloriesController, - TextEditingController fatsController, - TextEditingController proteinsController, - TextEditingController carbsController, - int selectedMood, - int selectedSatiety, - bool wakeupExpanded, - bool moderationExpanded, - bool moodExpanded, - bool isLoading, - bool isAdded, - List? chartDataCounted}); - - $DiaryModelCopyWith<$Res> get diary; - $MealCopyWith<$Res> get currentMeal; - $SelectionPopupModelCopyWith<$Res> get portionController; -} - -/// @nodoc -class __$$DiaryStateLoadedImplCopyWithImpl<$Res> - extends _$DiaryStateCopyWithImpl<$Res, _$DiaryStateLoadedImpl> - implements _$$DiaryStateLoadedImplCopyWith<$Res> { - __$$DiaryStateLoadedImplCopyWithImpl(_$DiaryStateLoadedImpl _value, - $Res Function(_$DiaryStateLoadedImpl) _then) - : super(_value, _then); - - /// Create a copy of DiaryState - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? diary = null, - Object? diaryDate = freezed, - Object? recommendedChartValues = null, - Object? consumedChartValues = null, - Object? portions = null, - Object? mealList = null, - Object? portionList = null, - Object? autocompleteList = null, - Object? chartData = null, - Object? currentMeal = null, - Object? portionController = null, - Object? wakeupController = null, - Object? retireController = null, - Object? mealTimeController = freezed, - Object? commentController = null, - Object? product_nameController = null, - Object? productQuantityController = null, - Object? caloriesController = null, - Object? fatsController = null, - Object? proteinsController = null, - Object? carbsController = null, - Object? selectedMood = null, - Object? selectedSatiety = null, - Object? wakeupExpanded = null, - Object? moderationExpanded = null, - Object? moodExpanded = null, - Object? isLoading = null, - Object? isAdded = null, - Object? chartDataCounted = freezed, - }) { - return _then(_$DiaryStateLoadedImpl( - diary: null == diary - ? _value.diary - : diary // ignore: cast_nullable_to_non_nullable - as DiaryModel, - diaryDate: freezed == diaryDate - ? _value.diaryDate - : diaryDate // ignore: cast_nullable_to_non_nullable - as String?, - recommendedChartValues: null == recommendedChartValues - ? _value._recommendedChartValues - : recommendedChartValues // ignore: cast_nullable_to_non_nullable - as List, - consumedChartValues: null == consumedChartValues - ? _value._consumedChartValues - : consumedChartValues // ignore: cast_nullable_to_non_nullable - as List, - portions: null == portions - ? _value._portions - : portions // ignore: cast_nullable_to_non_nullable - as List, - mealList: null == mealList - ? _value._mealList - : mealList // ignore: cast_nullable_to_non_nullable - as List, - portionList: null == portionList - ? _value._portionList - : portionList // ignore: cast_nullable_to_non_nullable - as List, - autocompleteList: null == autocompleteList - ? _value._autocompleteList - : autocompleteList // ignore: cast_nullable_to_non_nullable - as List, - chartData: null == chartData - ? _value._chartData - : chartData // ignore: cast_nullable_to_non_nullable - as Map, - currentMeal: null == currentMeal - ? _value.currentMeal - : currentMeal // ignore: cast_nullable_to_non_nullable - as Meal, - portionController: null == portionController - ? _value.portionController - : portionController // ignore: cast_nullable_to_non_nullable - as SelectionPopupModel, - wakeupController: null == wakeupController - ? _value.wakeupController - : wakeupController // ignore: cast_nullable_to_non_nullable - as TimeOfDay, - retireController: null == retireController - ? _value.retireController - : retireController // ignore: cast_nullable_to_non_nullable - as TimeOfDay, - mealTimeController: freezed == mealTimeController - ? _value.mealTimeController - : mealTimeController // ignore: cast_nullable_to_non_nullable - as TimeOfDay?, - commentController: null == commentController - ? _value.commentController - : commentController // ignore: cast_nullable_to_non_nullable - as TextEditingController, - product_nameController: null == product_nameController - ? _value.product_nameController - : product_nameController // ignore: cast_nullable_to_non_nullable - as TextEditingController, - productQuantityController: null == productQuantityController - ? _value.productQuantityController - : productQuantityController // ignore: cast_nullable_to_non_nullable - as TextEditingController, - caloriesController: null == caloriesController - ? _value.caloriesController - : caloriesController // ignore: cast_nullable_to_non_nullable - as TextEditingController, - fatsController: null == fatsController - ? _value.fatsController - : fatsController // ignore: cast_nullable_to_non_nullable - as TextEditingController, - proteinsController: null == proteinsController - ? _value.proteinsController - : proteinsController // ignore: cast_nullable_to_non_nullable - as TextEditingController, - carbsController: null == carbsController - ? _value.carbsController - : carbsController // ignore: cast_nullable_to_non_nullable - as TextEditingController, - selectedMood: null == selectedMood - ? _value.selectedMood - : selectedMood // ignore: cast_nullable_to_non_nullable - as int, - selectedSatiety: null == selectedSatiety - ? _value.selectedSatiety - : selectedSatiety // ignore: cast_nullable_to_non_nullable - as int, - wakeupExpanded: null == wakeupExpanded - ? _value.wakeupExpanded - : wakeupExpanded // ignore: cast_nullable_to_non_nullable - as bool, - moderationExpanded: null == moderationExpanded - ? _value.moderationExpanded - : moderationExpanded // ignore: cast_nullable_to_non_nullable - as bool, - moodExpanded: null == moodExpanded - ? _value.moodExpanded - : moodExpanded // ignore: cast_nullable_to_non_nullable - as bool, - isLoading: null == isLoading - ? _value.isLoading - : isLoading // ignore: cast_nullable_to_non_nullable - as bool, - isAdded: null == isAdded - ? _value.isAdded - : isAdded // ignore: cast_nullable_to_non_nullable - as bool, - chartDataCounted: freezed == chartDataCounted - ? _value._chartDataCounted - : chartDataCounted // ignore: cast_nullable_to_non_nullable - as List?, - )); - } - - /// Create a copy of DiaryState - /// with the given fields replaced by the non-null parameter values. - @override - @pragma('vm:prefer-inline') - $DiaryModelCopyWith<$Res> get diary { - return $DiaryModelCopyWith<$Res>(_value.diary, (value) { - return _then(_value.copyWith(diary: value)); - }); - } - - /// Create a copy of DiaryState - /// with the given fields replaced by the non-null parameter values. - @override - @pragma('vm:prefer-inline') - $MealCopyWith<$Res> get currentMeal { - return $MealCopyWith<$Res>(_value.currentMeal, (value) { - return _then(_value.copyWith(currentMeal: value)); - }); - } - - /// Create a copy of DiaryState - /// with the given fields replaced by the non-null parameter values. - @override - @pragma('vm:prefer-inline') - $SelectionPopupModelCopyWith<$Res> get portionController { - return $SelectionPopupModelCopyWith<$Res>(_value.portionController, - (value) { - return _then(_value.copyWith(portionController: value)); - }); - } -} - -/// @nodoc - -class _$DiaryStateLoadedImpl implements DiaryStateLoaded { - const _$DiaryStateLoadedImpl( - {required this.diary, - this.diaryDate, - required final List recommendedChartValues, - required final List consumedChartValues, - required final List portions, - required final List mealList, - required final List portionList, - required final List autocompleteList, - required final Map chartData, - required this.currentMeal, - required this.portionController, - required this.wakeupController, - required this.retireController, - this.mealTimeController, - required this.commentController, - required this.product_nameController, - required this.productQuantityController, - required this.caloriesController, - required this.fatsController, - required this.proteinsController, - required this.carbsController, - required this.selectedMood, - required this.selectedSatiety, - required this.wakeupExpanded, - required this.moderationExpanded, - required this.moodExpanded, - required this.isLoading, - required this.isAdded, - final List? chartDataCounted}) - : _recommendedChartValues = recommendedChartValues, - _consumedChartValues = consumedChartValues, - _portions = portions, - _mealList = mealList, - _portionList = portionList, - _autocompleteList = autocompleteList, - _chartData = chartData, - _chartDataCounted = chartDataCounted; - - @override - final DiaryModel diary; - @override - final String? diaryDate; - final List _recommendedChartValues; - @override - List get recommendedChartValues { - if (_recommendedChartValues is EqualUnmodifiableListView) - return _recommendedChartValues; - // ignore: implicit_dynamic_type - return EqualUnmodifiableListView(_recommendedChartValues); - } - - final List _consumedChartValues; - @override - List get consumedChartValues { - if (_consumedChartValues is EqualUnmodifiableListView) - return _consumedChartValues; - // ignore: implicit_dynamic_type - return EqualUnmodifiableListView(_consumedChartValues); - } - - final List _portions; - @override - List get portions { - if (_portions is EqualUnmodifiableListView) return _portions; - // ignore: implicit_dynamic_type - return EqualUnmodifiableListView(_portions); - } - - final List _mealList; - @override - List get mealList { - if (_mealList is EqualUnmodifiableListView) return _mealList; - // ignore: implicit_dynamic_type - return EqualUnmodifiableListView(_mealList); - } - - final List _portionList; - @override - List get portionList { - if (_portionList is EqualUnmodifiableListView) return _portionList; - // ignore: implicit_dynamic_type - return EqualUnmodifiableListView(_portionList); - } - - final List _autocompleteList; - @override - List get autocompleteList { - if (_autocompleteList is EqualUnmodifiableListView) - return _autocompleteList; - // ignore: implicit_dynamic_type - return EqualUnmodifiableListView(_autocompleteList); - } - - final Map _chartData; - @override - Map get chartData { - if (_chartData is EqualUnmodifiableMapView) return _chartData; - // ignore: implicit_dynamic_type - return EqualUnmodifiableMapView(_chartData); - } - - @override - final Meal currentMeal; - @override - final SelectionPopupModel portionController; - @override - final TimeOfDay wakeupController; - @override - final TimeOfDay retireController; - @override - final TimeOfDay? mealTimeController; - @override - final TextEditingController commentController; - @override - final TextEditingController product_nameController; - @override - final TextEditingController productQuantityController; - @override - final TextEditingController caloriesController; - @override - final TextEditingController fatsController; - @override - final TextEditingController proteinsController; - @override - final TextEditingController carbsController; - @override - final int selectedMood; - @override - final int selectedSatiety; - @override - final bool wakeupExpanded; - @override - final bool moderationExpanded; - @override - final bool moodExpanded; - @override - final bool isLoading; - @override - final bool isAdded; - final List? _chartDataCounted; - @override - List? get chartDataCounted { - final value = _chartDataCounted; - if (value == null) return null; - if (_chartDataCounted is EqualUnmodifiableListView) - return _chartDataCounted; - // ignore: implicit_dynamic_type - return EqualUnmodifiableListView(value); - } - - @override - String toString() { - return 'DiaryState.loaded(diary: $diary, diaryDate: $diaryDate, recommendedChartValues: $recommendedChartValues, consumedChartValues: $consumedChartValues, portions: $portions, mealList: $mealList, portionList: $portionList, autocompleteList: $autocompleteList, chartData: $chartData, currentMeal: $currentMeal, portionController: $portionController, wakeupController: $wakeupController, retireController: $retireController, mealTimeController: $mealTimeController, commentController: $commentController, product_nameController: $product_nameController, productQuantityController: $productQuantityController, caloriesController: $caloriesController, fatsController: $fatsController, proteinsController: $proteinsController, carbsController: $carbsController, selectedMood: $selectedMood, selectedSatiety: $selectedSatiety, wakeupExpanded: $wakeupExpanded, moderationExpanded: $moderationExpanded, moodExpanded: $moodExpanded, isLoading: $isLoading, isAdded: $isAdded, chartDataCounted: $chartDataCounted)'; - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _$DiaryStateLoadedImpl && - (identical(other.diary, diary) || other.diary == diary) && - (identical(other.diaryDate, diaryDate) || - other.diaryDate == diaryDate) && - const DeepCollectionEquality().equals( - other._recommendedChartValues, _recommendedChartValues) && - const DeepCollectionEquality() - .equals(other._consumedChartValues, _consumedChartValues) && - const DeepCollectionEquality().equals(other._portions, _portions) && - const DeepCollectionEquality().equals(other._mealList, _mealList) && - const DeepCollectionEquality() - .equals(other._portionList, _portionList) && - const DeepCollectionEquality() - .equals(other._autocompleteList, _autocompleteList) && - const DeepCollectionEquality() - .equals(other._chartData, _chartData) && - (identical(other.currentMeal, currentMeal) || - other.currentMeal == currentMeal) && - (identical(other.portionController, portionController) || - other.portionController == portionController) && - (identical(other.wakeupController, wakeupController) || - other.wakeupController == wakeupController) && - (identical(other.retireController, retireController) || - other.retireController == retireController) && - (identical(other.mealTimeController, mealTimeController) || - other.mealTimeController == mealTimeController) && - (identical(other.commentController, commentController) || - other.commentController == commentController) && - (identical(other.product_nameController, product_nameController) || - other.product_nameController == product_nameController) && - (identical(other.productQuantityController, - productQuantityController) || - other.productQuantityController == productQuantityController) && - (identical(other.caloriesController, caloriesController) || - other.caloriesController == caloriesController) && - (identical(other.fatsController, fatsController) || - other.fatsController == fatsController) && - (identical(other.proteinsController, proteinsController) || - other.proteinsController == proteinsController) && - (identical(other.carbsController, carbsController) || - other.carbsController == carbsController) && - (identical(other.selectedMood, selectedMood) || - other.selectedMood == selectedMood) && - (identical(other.selectedSatiety, selectedSatiety) || - other.selectedSatiety == selectedSatiety) && - (identical(other.wakeupExpanded, wakeupExpanded) || - other.wakeupExpanded == wakeupExpanded) && - (identical(other.moderationExpanded, moderationExpanded) || - other.moderationExpanded == moderationExpanded) && - (identical(other.moodExpanded, moodExpanded) || - other.moodExpanded == moodExpanded) && - (identical(other.isLoading, isLoading) || - other.isLoading == isLoading) && - (identical(other.isAdded, isAdded) || other.isAdded == isAdded) && - const DeepCollectionEquality() - .equals(other._chartDataCounted, _chartDataCounted)); - } - - @override - int get hashCode => Object.hashAll([ - runtimeType, - diary, - diaryDate, - const DeepCollectionEquality().hash(_recommendedChartValues), - const DeepCollectionEquality().hash(_consumedChartValues), - const DeepCollectionEquality().hash(_portions), - const DeepCollectionEquality().hash(_mealList), - const DeepCollectionEquality().hash(_portionList), - const DeepCollectionEquality().hash(_autocompleteList), - const DeepCollectionEquality().hash(_chartData), - currentMeal, - portionController, - wakeupController, - retireController, - mealTimeController, - commentController, - product_nameController, - productQuantityController, - caloriesController, - fatsController, - proteinsController, - carbsController, - selectedMood, - selectedSatiety, - wakeupExpanded, - moderationExpanded, - moodExpanded, - isLoading, - isAdded, - const DeepCollectionEquality().hash(_chartDataCounted) - ]); - - /// Create a copy of DiaryState - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - @override - @pragma('vm:prefer-inline') - _$$DiaryStateLoadedImplCopyWith<_$DiaryStateLoadedImpl> get copyWith => - __$$DiaryStateLoadedImplCopyWithImpl<_$DiaryStateLoadedImpl>( - this, _$identity); - - @override - @optionalTypeArgs - TResult when( - TResult Function() $default, { - required TResult Function(int? id) loading, - required TResult Function( - DiaryModel diary, - String? diaryDate, - List recommendedChartValues, - List consumedChartValues, - List portions, - List mealList, - List portionList, - List autocompleteList, - Map chartData, - Meal currentMeal, - SelectionPopupModel portionController, - TimeOfDay wakeupController, - TimeOfDay retireController, - TimeOfDay? mealTimeController, - TextEditingController commentController, - TextEditingController product_nameController, - TextEditingController productQuantityController, - TextEditingController caloriesController, - TextEditingController fatsController, - TextEditingController proteinsController, - TextEditingController carbsController, - int selectedMood, - int selectedSatiety, - bool wakeupExpanded, - bool moderationExpanded, - bool moodExpanded, - bool isLoading, - bool isAdded, - List? chartDataCounted) - loaded, - required TResult Function(String errorMessage) error, - }) { - return loaded( - diary, - diaryDate, - recommendedChartValues, - consumedChartValues, - portions, - mealList, - portionList, - autocompleteList, - chartData, - currentMeal, - portionController, - wakeupController, - retireController, - mealTimeController, - commentController, - product_nameController, - productQuantityController, - caloriesController, - fatsController, - proteinsController, - carbsController, - selectedMood, - selectedSatiety, - wakeupExpanded, - moderationExpanded, - moodExpanded, - isLoading, - isAdded, - chartDataCounted); - } - - @override - @optionalTypeArgs - TResult? whenOrNull( - TResult? Function()? $default, { - TResult? Function(int? id)? loading, - TResult? Function( - DiaryModel diary, - String? diaryDate, - List recommendedChartValues, - List consumedChartValues, - List portions, - List mealList, - List portionList, - List autocompleteList, - Map chartData, - Meal currentMeal, - SelectionPopupModel portionController, - TimeOfDay wakeupController, - TimeOfDay retireController, - TimeOfDay? mealTimeController, - TextEditingController commentController, - TextEditingController product_nameController, - TextEditingController productQuantityController, - TextEditingController caloriesController, - TextEditingController fatsController, - TextEditingController proteinsController, - TextEditingController carbsController, - int selectedMood, - int selectedSatiety, - bool wakeupExpanded, - bool moderationExpanded, - bool moodExpanded, - bool isLoading, - bool isAdded, - List? chartDataCounted)? - loaded, - TResult? Function(String errorMessage)? error, - }) { - return loaded?.call( - diary, - diaryDate, - recommendedChartValues, - consumedChartValues, - portions, - mealList, - portionList, - autocompleteList, - chartData, - currentMeal, - portionController, - wakeupController, - retireController, - mealTimeController, - commentController, - product_nameController, - productQuantityController, - caloriesController, - fatsController, - proteinsController, - carbsController, - selectedMood, - selectedSatiety, - wakeupExpanded, - moderationExpanded, - moodExpanded, - isLoading, - isAdded, - chartDataCounted); - } - - @override - @optionalTypeArgs - TResult maybeWhen( - TResult Function()? $default, { - TResult Function(int? id)? loading, - TResult Function( - DiaryModel diary, - String? diaryDate, - List recommendedChartValues, - List consumedChartValues, - List portions, - List mealList, - List portionList, - List autocompleteList, - Map chartData, - Meal currentMeal, - SelectionPopupModel portionController, - TimeOfDay wakeupController, - TimeOfDay retireController, - TimeOfDay? mealTimeController, - TextEditingController commentController, - TextEditingController product_nameController, - TextEditingController productQuantityController, - TextEditingController caloriesController, - TextEditingController fatsController, - TextEditingController proteinsController, - TextEditingController carbsController, - int selectedMood, - int selectedSatiety, - bool wakeupExpanded, - bool moderationExpanded, - bool moodExpanded, - bool isLoading, - bool isAdded, - List? chartDataCounted)? - loaded, - TResult Function(String errorMessage)? error, - required TResult orElse(), - }) { - if (loaded != null) { - return loaded( - diary, - diaryDate, - recommendedChartValues, - consumedChartValues, - portions, - mealList, - portionList, - autocompleteList, - chartData, - currentMeal, - portionController, - wakeupController, - retireController, - mealTimeController, - commentController, - product_nameController, - productQuantityController, - caloriesController, - fatsController, - proteinsController, - carbsController, - selectedMood, - selectedSatiety, - wakeupExpanded, - moderationExpanded, - moodExpanded, - isLoading, - isAdded, - chartDataCounted); - } - return orElse(); - } - - @override - @optionalTypeArgs - TResult map( - TResult Function(_DiaryState value) $default, { - required TResult Function(DiaryStateLoading value) loading, - required TResult Function(DiaryStateLoaded value) loaded, - required TResult Function(DiaryStateError value) error, - }) { - return loaded(this); - } - - @override - @optionalTypeArgs - TResult? mapOrNull( - TResult? Function(_DiaryState value)? $default, { - TResult? Function(DiaryStateLoading value)? loading, - TResult? Function(DiaryStateLoaded value)? loaded, - TResult? Function(DiaryStateError value)? error, - }) { - return loaded?.call(this); - } - - @override - @optionalTypeArgs - TResult maybeMap( - TResult Function(_DiaryState value)? $default, { - TResult Function(DiaryStateLoading value)? loading, - TResult Function(DiaryStateLoaded value)? loaded, - TResult Function(DiaryStateError value)? error, - required TResult orElse(), - }) { - if (loaded != null) { - return loaded(this); - } - return orElse(); - } -} - -abstract class DiaryStateLoaded implements DiaryState { - const factory DiaryStateLoaded( - {required final DiaryModel diary, - final String? diaryDate, - required final List recommendedChartValues, - required final List consumedChartValues, - required final List portions, - required final List mealList, - required final List portionList, - required final List autocompleteList, - required final Map chartData, - required final Meal currentMeal, - required final SelectionPopupModel portionController, - required final TimeOfDay wakeupController, - required final TimeOfDay retireController, - final TimeOfDay? mealTimeController, - required final TextEditingController commentController, - required final TextEditingController product_nameController, - required final TextEditingController productQuantityController, - required final TextEditingController caloriesController, - required final TextEditingController fatsController, - required final TextEditingController proteinsController, - required final TextEditingController carbsController, - required final int selectedMood, - required final int selectedSatiety, - required final bool wakeupExpanded, - required final bool moderationExpanded, - required final bool moodExpanded, - required final bool isLoading, - required final bool isAdded, - final List? chartDataCounted}) = _$DiaryStateLoadedImpl; - - DiaryModel get diary; - String? get diaryDate; - List get recommendedChartValues; - List get consumedChartValues; - List get portions; - List get mealList; - List get portionList; - List get autocompleteList; - Map get chartData; - Meal get currentMeal; - SelectionPopupModel get portionController; - TimeOfDay get wakeupController; - TimeOfDay get retireController; - TimeOfDay? get mealTimeController; - TextEditingController get commentController; - TextEditingController get product_nameController; - TextEditingController get productQuantityController; - TextEditingController get caloriesController; - TextEditingController get fatsController; - TextEditingController get proteinsController; - TextEditingController get carbsController; - int get selectedMood; - int get selectedSatiety; - bool get wakeupExpanded; - bool get moderationExpanded; - bool get moodExpanded; - bool get isLoading; - bool get isAdded; - List? get chartDataCounted; - - /// Create a copy of DiaryState - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - _$$DiaryStateLoadedImplCopyWith<_$DiaryStateLoadedImpl> get copyWith => - throw _privateConstructorUsedError; + const factory DiaryStateLoading() = _$DiaryStateLoadingImpl; } /// @nodoc @@ -1522,39 +394,9 @@ class _$DiaryStateErrorImpl implements DiaryStateError { @optionalTypeArgs TResult when( TResult Function() $default, { - required TResult Function(int? id) loading, - required TResult Function( - DiaryModel diary, - String? diaryDate, - List recommendedChartValues, - List consumedChartValues, - List portions, - List mealList, - List portionList, - List autocompleteList, - Map chartData, - Meal currentMeal, - SelectionPopupModel portionController, - TimeOfDay wakeupController, - TimeOfDay retireController, - TimeOfDay? mealTimeController, - TextEditingController commentController, - TextEditingController product_nameController, - TextEditingController productQuantityController, - TextEditingController caloriesController, - TextEditingController fatsController, - TextEditingController proteinsController, - TextEditingController carbsController, - int selectedMood, - int selectedSatiety, - bool wakeupExpanded, - bool moderationExpanded, - bool moodExpanded, - bool isLoading, - bool isAdded, - List? chartDataCounted) - loaded, + required TResult Function() loading, required TResult Function(String errorMessage) error, + required TResult Function(DiaryDayModel diary) loaded, }) { return error(errorMessage); } @@ -1563,39 +405,9 @@ class _$DiaryStateErrorImpl implements DiaryStateError { @optionalTypeArgs TResult? whenOrNull( TResult? Function()? $default, { - TResult? Function(int? id)? loading, - TResult? Function( - DiaryModel diary, - String? diaryDate, - List recommendedChartValues, - List consumedChartValues, - List portions, - List mealList, - List portionList, - List autocompleteList, - Map chartData, - Meal currentMeal, - SelectionPopupModel portionController, - TimeOfDay wakeupController, - TimeOfDay retireController, - TimeOfDay? mealTimeController, - TextEditingController commentController, - TextEditingController product_nameController, - TextEditingController productQuantityController, - TextEditingController caloriesController, - TextEditingController fatsController, - TextEditingController proteinsController, - TextEditingController carbsController, - int selectedMood, - int selectedSatiety, - bool wakeupExpanded, - bool moderationExpanded, - bool moodExpanded, - bool isLoading, - bool isAdded, - List? chartDataCounted)? - loaded, + TResult? Function()? loading, TResult? Function(String errorMessage)? error, + TResult? Function(DiaryDayModel diary)? loaded, }) { return error?.call(errorMessage); } @@ -1604,39 +416,9 @@ class _$DiaryStateErrorImpl implements DiaryStateError { @optionalTypeArgs TResult maybeWhen( TResult Function()? $default, { - TResult Function(int? id)? loading, - TResult Function( - DiaryModel diary, - String? diaryDate, - List recommendedChartValues, - List consumedChartValues, - List portions, - List mealList, - List portionList, - List autocompleteList, - Map chartData, - Meal currentMeal, - SelectionPopupModel portionController, - TimeOfDay wakeupController, - TimeOfDay retireController, - TimeOfDay? mealTimeController, - TextEditingController commentController, - TextEditingController product_nameController, - TextEditingController productQuantityController, - TextEditingController caloriesController, - TextEditingController fatsController, - TextEditingController proteinsController, - TextEditingController carbsController, - int selectedMood, - int selectedSatiety, - bool wakeupExpanded, - bool moderationExpanded, - bool moodExpanded, - bool isLoading, - bool isAdded, - List? chartDataCounted)? - loaded, + TResult Function()? loading, TResult Function(String errorMessage)? error, + TResult Function(DiaryDayModel diary)? loaded, required TResult orElse(), }) { if (error != null) { @@ -1650,8 +432,8 @@ class _$DiaryStateErrorImpl implements DiaryStateError { TResult map( TResult Function(_DiaryState value) $default, { required TResult Function(DiaryStateLoading value) loading, - required TResult Function(DiaryStateLoaded value) loaded, required TResult Function(DiaryStateError value) error, + required TResult Function(DiaryStateLoaded value) loaded, }) { return error(this); } @@ -1661,8 +443,8 @@ class _$DiaryStateErrorImpl implements DiaryStateError { TResult? mapOrNull( TResult? Function(_DiaryState value)? $default, { TResult? Function(DiaryStateLoading value)? loading, - TResult? Function(DiaryStateLoaded value)? loaded, TResult? Function(DiaryStateError value)? error, + TResult? Function(DiaryStateLoaded value)? loaded, }) { return error?.call(this); } @@ -1672,8 +454,8 @@ class _$DiaryStateErrorImpl implements DiaryStateError { TResult maybeMap( TResult Function(_DiaryState value)? $default, { TResult Function(DiaryStateLoading value)? loading, - TResult Function(DiaryStateLoaded value)? loaded, TResult Function(DiaryStateError value)? error, + TResult Function(DiaryStateLoaded value)? loaded, required TResult orElse(), }) { if (error != null) { @@ -1695,3 +477,169 @@ abstract class DiaryStateError implements DiaryState { _$$DiaryStateErrorImplCopyWith<_$DiaryStateErrorImpl> get copyWith => throw _privateConstructorUsedError; } + +/// @nodoc +abstract class _$$DiaryStateLoadedImplCopyWith<$Res> { + factory _$$DiaryStateLoadedImplCopyWith(_$DiaryStateLoadedImpl value, + $Res Function(_$DiaryStateLoadedImpl) then) = + __$$DiaryStateLoadedImplCopyWithImpl<$Res>; + @useResult + $Res call({DiaryDayModel diary}); + + $DiaryDayModelCopyWith<$Res> get diary; +} + +/// @nodoc +class __$$DiaryStateLoadedImplCopyWithImpl<$Res> + extends _$DiaryStateCopyWithImpl<$Res, _$DiaryStateLoadedImpl> + implements _$$DiaryStateLoadedImplCopyWith<$Res> { + __$$DiaryStateLoadedImplCopyWithImpl(_$DiaryStateLoadedImpl _value, + $Res Function(_$DiaryStateLoadedImpl) _then) + : super(_value, _then); + + /// Create a copy of DiaryState + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? diary = null, + }) { + return _then(_$DiaryStateLoadedImpl( + diary: null == diary + ? _value.diary + : diary // ignore: cast_nullable_to_non_nullable + as DiaryDayModel, + )); + } + + /// Create a copy of DiaryState + /// with the given fields replaced by the non-null parameter values. + @override + @pragma('vm:prefer-inline') + $DiaryDayModelCopyWith<$Res> get diary { + return $DiaryDayModelCopyWith<$Res>(_value.diary, (value) { + return _then(_value.copyWith(diary: value)); + }); + } +} + +/// @nodoc + +class _$DiaryStateLoadedImpl implements DiaryStateLoaded { + const _$DiaryStateLoadedImpl({required this.diary}); + + @override + final DiaryDayModel diary; + + @override + String toString() { + return 'DiaryState.loaded(diary: $diary)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$DiaryStateLoadedImpl && + (identical(other.diary, diary) || other.diary == diary)); + } + + @override + int get hashCode => Object.hash(runtimeType, diary); + + /// Create a copy of DiaryState + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$DiaryStateLoadedImplCopyWith<_$DiaryStateLoadedImpl> get copyWith => + __$$DiaryStateLoadedImplCopyWithImpl<_$DiaryStateLoadedImpl>( + this, _$identity); + + @override + @optionalTypeArgs + TResult when( + TResult Function() $default, { + required TResult Function() loading, + required TResult Function(String errorMessage) error, + required TResult Function(DiaryDayModel diary) loaded, + }) { + return loaded(diary); + } + + @override + @optionalTypeArgs + TResult? whenOrNull( + TResult? Function()? $default, { + TResult? Function()? loading, + TResult? Function(String errorMessage)? error, + TResult? Function(DiaryDayModel diary)? loaded, + }) { + return loaded?.call(diary); + } + + @override + @optionalTypeArgs + TResult maybeWhen( + TResult Function()? $default, { + TResult Function()? loading, + TResult Function(String errorMessage)? error, + TResult Function(DiaryDayModel diary)? loaded, + required TResult orElse(), + }) { + if (loaded != null) { + return loaded(diary); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map( + TResult Function(_DiaryState value) $default, { + required TResult Function(DiaryStateLoading value) loading, + required TResult Function(DiaryStateError value) error, + required TResult Function(DiaryStateLoaded value) loaded, + }) { + return loaded(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull( + TResult? Function(_DiaryState value)? $default, { + TResult? Function(DiaryStateLoading value)? loading, + TResult? Function(DiaryStateError value)? error, + TResult? Function(DiaryStateLoaded value)? loaded, + }) { + return loaded?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap( + TResult Function(_DiaryState value)? $default, { + TResult Function(DiaryStateLoading value)? loading, + TResult Function(DiaryStateError value)? error, + TResult Function(DiaryStateLoaded value)? loaded, + required TResult orElse(), + }) { + if (loaded != null) { + return loaded(this); + } + return orElse(); + } +} + +abstract class DiaryStateLoaded implements DiaryState { + const factory DiaryStateLoaded({required final DiaryDayModel diary}) = + _$DiaryStateLoadedImpl; + + DiaryDayModel get diary; + + /// Create a copy of DiaryState + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + _$$DiaryStateLoadedImplCopyWith<_$DiaryStateLoadedImpl> get copyWith => + throw _privateConstructorUsedError; +} diff --git a/lib/features/diary/presentation/pages/diary_recommendations_scree.dart b/lib/features/diary/presentation/pages/diary_recommendations_scree.dart deleted file mode 100644 index 53b20dee..00000000 --- a/lib/features/diary/presentation/pages/diary_recommendations_scree.dart +++ /dev/null @@ -1,115 +0,0 @@ -// ignore_for_file: unused_local_variable - -import 'package:eatvio_app/features/diary/models/portion.dart'; -import 'package:eatvio_app/features/diary/presentation/bloc/diary_bloc.dart'; -import 'package:eatvio_app/features/diary/presentation/bloc/diary_state.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter_bloc/flutter_bloc.dart'; -import 'package:flutter_form_builder/flutter_form_builder.dart'; -import 'package:rive/rive.dart'; - -// ignore: must_be_immutable -class DiaryRecommendationsScreen extends StatelessWidget { - final String? diary_recommendationsID; - - const DiaryRecommendationsScreen({ - this.diary_recommendationsID, - super.key, - }); - - Widget build(BuildContext context) { - if (diary_recommendationsID != "0") { - context.read().add(LoadDiaryById(diary_recommendationsID)); - } - return BlocBuilder( - builder: (context, state) { - if (state is DiaryStateLoaded) { - return _buildDiaryRecommendations(context, state); - } else if (state is DiaryStateLoading) { - return Scaffold( - body: Center( - child: SizedBox( - height: 32, - width: 32, - child: RiveAnimation.asset( - 'assets/rive_animations/loading.riv', - ), - ), - ), - ); - } else if (state is DiaryStateError) { - return Scaffold( - body: Padding( - padding: const EdgeInsets.all(16), - child: Center( - child: Text(state.errorMessage), - ), - ), - ); - } else - return Scaffold( - body: Padding( - padding: const EdgeInsets.all(16), - child: Center( - child: Text("Неопределенная ошибка"), - ), - ), - ); - }, - ); - } - - Widget _buildDiaryRecommendations(BuildContext context, DiaryStateLoaded state) { - final Portion product = new Portion(id: 1, product_name: "", quantity: 1, portion: "", from_diet: true); - return Stack( - alignment: Alignment.bottomCenter, - children: [ - FormBuilder( - child: Scaffold( - appBar: AppBar( - toolbarHeight: 0, - automaticallyImplyLeading: false, - ), - backgroundColor: Color.fromARGB(255, 240, 242, 245), - resizeToAvoidBottomInset: true, - body: SizedBox( - width: double.maxFinite, - child: Column( - children: [ - Expanded( - child: SingleChildScrollView( - child: Padding( - padding: EdgeInsets.only(bottom: 9), - child: Column( - children: [ - Scaffold( - appBar: AppBar( - title: Text(product.product_name), - ), - body: Padding( - padding: const EdgeInsets.all(16.0), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text('Название продукта: ${product.product_name}', style: TextStyle(fontSize: 24)), - SizedBox(height: 16), - Text('Количество: ${product.quantity} ${product.portion}', style: TextStyle(fontSize: 18)), - // Добавьте другие детали о продукте по необходимости - ], - ), - ), - ) - ], - ), - ), - ), - ), - ], - ), - ), - ), - ), - ], - ); - } -} diff --git a/lib/features/diary/presentation/pages/diary_screen.dart b/lib/features/diary/presentation/pages/diary_screen.dart index aaa06ad8..32b70516 100644 --- a/lib/features/diary/presentation/pages/diary_screen.dart +++ b/lib/features/diary/presentation/pages/diary_screen.dart @@ -1,1193 +1,439 @@ -import 'package:carousel_slider_plus/carousel_slider_plus.dart'; -import 'package:eatvio_app/core/const.dart'; -import 'package:eatvio_app/data/models/selectionPopupModel/selection_popup_model.dart'; -import 'package:eatvio_app/features/diary/models/diary_model.dart'; -import 'package:eatvio_app/features/diary/models/meal.dart'; -import 'package:eatvio_app/features/diary/models/photo.dart'; -import 'package:eatvio_app/features/diary/models/portion.dart'; -import 'package:eatvio_app/features/diary/models/product.dart'; -import 'package:eatvio_app/features/diary/presentation/bloc/diary_bloc.dart'; +import 'package:eatvio_app/features/diary/models/diary_day_model.dart'; +import 'package:eatvio_app/features/diary/presentation/bloc/diary_cubit.dart'; import 'package:eatvio_app/features/diary/presentation/bloc/diary_state.dart'; +import 'package:eatvio_app/features/glossary/models/glossary_model.dart'; import 'package:eatvio_app/locator_service.dart'; -import 'package:eatvio_app/theme/app_decoration.dart'; -import 'package:eatvio_app/theme/custom_text_style.dart'; import 'package:eatvio_app/theme/theme_helper.dart'; -import 'package:eatvio_app/widgets/custom_drop_down.dart'; -import 'package:eatvio_app/widgets/custom_scale_element.dart'; import 'package:eatvio_app/widgets/custom_text_form_field.dart'; import 'package:flutter/material.dart'; -import 'package:flutter/services.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; -import 'package:flutter_form_builder/flutter_form_builder.dart'; -import 'package:image_picker/image_picker.dart'; -import 'package:rive/rive.dart' as rive; -import 'package:syncfusion_flutter_charts/charts.dart'; +import 'package:flutter_typeahead/flutter_typeahead.dart'; +import 'package:rive/rive.dart'; +import 'package:table_calendar/table_calendar.dart'; -class DiaryScreen extends StatelessWidget { - final String? diaryID; +class DiaryScreen extends StatefulWidget { + const DiaryScreen({super.key}); - const DiaryScreen({ - this.diaryID, - super.key, - }); + @override + State createState() => _DiaryScreenState(); +} +class _DiaryScreenState extends State { + final DiaryCubit diaryCubit = sl(); + CalendarFormat _calendarFormat = CalendarFormat.month; + DateTime _focusedDay = DateTime.now(); + DateTime? _selectedDay = DateTime.now(); + int currentSelectedMealNumber = 1; + GlossaryModel? selectedGlossary; + final productNameController = TextEditingController(); + final quantityController = TextEditingController(); + + @override Widget build(BuildContext context) { - if (diaryID != "0") { - context.read().add(LoadDiaryById(diaryID)); - } - return BlocProvider( - create: (context) => sl()..add(LoadDiary()), - child: BlocBuilder( - builder: (context, state) { + return BlocProvider( + create: (BuildContext context) => diaryCubit..getDiaryDay(_selectedDay!.toString()), + child: BlocConsumer( + listener: (BuildContext context, DiaryState state) { if (state is DiaryStateLoaded) { - return _buildDiary(context, state); - } else if (state is DiaryStateLoading) { - return Scaffold( - body: Center( - child: SizedBox( - height: 32, - width: 32, - child: rive.RiveAnimation.asset( - 'assets/rive_animations/loading.riv', - ), - ), + setState(() { + _calendarFormat = CalendarFormat.week; + }); + } + }, + builder: (BuildContext context, DiaryState state) { + return Scaffold( + backgroundColor: Colors.grey.shade200, + appBar: AppBar( + toolbarHeight: 0, + ), + body: SingleChildScrollView( + physics: const BouncingScrollPhysics(), + child: Column( + children: [ + _calendar(state), + if (state is DiaryStateLoading) _loader(), + if (state is DiaryStateLoaded) _meals(state.diary), + const SizedBox(height: 32), + ], ), - ); - } else if (state is DiaryStateError) { - return Scaffold( - body: Padding( - padding: const EdgeInsets.all(16), - child: Center( - child: Text(state.errorMessage), - ), - ), - ); - } else - return Scaffold( - body: Padding( - padding: const EdgeInsets.all(16), - child: Center( - child: Text("Неопределенная ошибка"), - ), - ), - ); + ), + ); }, ), ); } - Widget _buildDiary(BuildContext context, DiaryStateLoaded state) { - return RefreshIndicator( - onRefresh: refreshPage(context), - child: Stack( - alignment: Alignment.bottomCenter, - children: [ - FormBuilder( - child: Scaffold( - appBar: AppBar( - toolbarHeight: 0, - automaticallyImplyLeading: false, - ), - backgroundColor: Color.fromARGB(255, 240, 242, 245), - resizeToAvoidBottomInset: true, - body: SizedBox( - width: double.maxFinite, - child: Column( - children: [ - Expanded( - child: SingleChildScrollView( - child: Padding( - padding: EdgeInsets.only(bottom: 8), - child: Column( - children: [ - _buildHeaderRow(context, state), - SizedBox(height: 8), - _buildWakupRetire(context, state), - SizedBox(height: 8), - _buildMeal(context, state), - SizedBox(height: 8), - _buildMood(context, state), - SizedBox(height: 8), - _buildNutritionChart(context, state), - SizedBox(height: 8), - // _buildComment(context, state), - // SizedBox(height: 8.v), - _buildEndDay(context), - ], - ), - ), - ), - ), - ], - ), - ), - ), - ), - ], + _arrowDown() { + return Container( + padding: const EdgeInsets.only(top: 8, bottom: 16), + width: double.infinity, + child: Icon( + _calendarFormat == CalendarFormat.month ? Icons.keyboard_arrow_up_rounded : Icons.keyboard_arrow_down_rounded, + color: Colors.grey.shade600, ), ); } - _buildNutritionChart(BuildContext context, DiaryStateLoaded state) { + _divider(BuildContext context) { return Container( - padding: EdgeInsets.symmetric( - horizontal: 24, - vertical: 12, - ), + height: 0.4, + width: MediaQuery.of(context).size.width - 32, decoration: BoxDecoration( - color: Colors.white, - borderRadius: const BorderRadius.all(Radius.circular(8)), - ), - child: Column( - children: [ - Text( - "Ваш КБЖУ", - style: theme.textTheme.titleMedium, - textAlign: TextAlign.center, - ), - Text( - "от дневной суточной нормы", - ), - Transform.rotate( - angle: -1.5708, - child: ClipRect( - child: Align( - alignment: Alignment.centerRight, - widthFactor: 0.5, - child: SfCircularChart( - series: [ - RadialBarSeries( - dataSource: state.chartDataCounted, - xValueMapper: (NutritionData data, _) => data.category, - yValueMapper: (NutritionData data, _) => data.nutrition, - pointColorMapper: (NutritionData data, _) => data.color, - trackColor: Color.fromRGBO(59, 130, 246, 1), - trackOpacity: 0.1, - gap: "8%", - radius: "110%", - innerRadius: '20%', // Измените значение по вашему усмотрению - ) - ], - ), - ), - ), - ), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text(style: theme.textTheme.titleMedium, 'Углеводы'), - Text(style: theme.textTheme.titleMedium, 'Жиры'), - Text(style: theme.textTheme.titleMedium, 'Белки'), - Text(style: theme.textTheme.titleMedium, 'Калории'), - ], - ), - Column( - crossAxisAlignment: CrossAxisAlignment.end, - children: [ - Text( - '${state.chartData['dailyNutritionIntake']['carbohydrates'].toStringAsFixed(1)} из ${state.chartData['dailyNutritionRecommendation']['carbohydrates'].toStringAsFixed(1)} грамм'), - SizedBox(height: 8), - Text( - '${state.chartData['dailyNutritionIntake']['fats'].toStringAsFixed(1)} из ${state.chartData['dailyNutritionRecommendation']['fats'].toStringAsFixed(1)} грамм'), - SizedBox(height: 8), - Text( - '${state.chartData['dailyNutritionIntake']['proteins'].toStringAsFixed(1)} из ${state.chartData['dailyNutritionRecommendation']['proteins'].toStringAsFixed(1)} грамм'), - SizedBox(height: 8), - Text( - '${state.chartData['dailyNutritionIntake']['energy'].toStringAsFixed(1)} из ${state.chartData['dailyNutritionRecommendation']['energy'].toStringAsFixed(1)} Ккал'), - ], - ), - ], - ), - ], + color: Colors.black26, + borderRadius: BorderRadius.circular(16), ), ); } - _buildEndDay(BuildContext context) { - return Container( - height: 48, - width: MediaQuery.of(context).size.width, - padding: EdgeInsets.only(left: 4, right: 4), - child: FloatingActionButton.extended( - heroTag: 'endDayButton', - highlightElevation: 0, - elevation: 0, - focusElevation: 0, - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(16), - ), - backgroundColor: appTheme.blueA400, - onPressed: () => onFinishDayPressed, - label: Text( - 'Закончить день', - style: theme.textTheme.titleSmall, - ), - ), - ); - } - - refreshPage(BuildContext context) { - return () async { - context.read().add(RefreshEvent()); - }; - } - - /// Section Widget - _buildHeaderRow(BuildContext context, DiaryStateLoaded state) { - final day = state.diary.id; - return Container( - padding: EdgeInsets.symmetric( - horizontal: 24, - vertical: 12, - ), - decoration: BoxDecoration( - color: Colors.white, - borderRadius: const BorderRadius.all(Radius.circular(8)), - ), - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Padding( - padding: EdgeInsets.only(top: 4), - child: Column( - children: [ - Align( - alignment: Alignment.centerRight, - child: Text( - "$day день", - style: CustomTextStyles.titleMediumBlack, - ), - ), - ], - ), - ), - ], - ), - ); - } - - /// Section Widget - _buildAddProduct(BuildContext context, DiaryState state) { - return Container( - height: 48, - width: MediaQuery.of(context).size.width, - padding: EdgeInsets.only(left: 4, right: 4), - child: FloatingActionButton.extended( - heroTag: 'addProduct', - highlightElevation: 0, - elevation: 0, - focusElevation: 0, - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(16), - ), - backgroundColor: appTheme.blueA400, - onPressed: () => addProduct(context), - label: Text( - 'Добавить продукт', - style: theme.textTheme.titleSmall, - ), - ), - ); - } - - addProduct(BuildContext context) { - context.read().add(AddPortionEvent()); - } - - /// Section Widget - _buildAddPhoto(BuildContext context, DiaryStateLoaded state) { - bool isLoading = state.isLoading; - if (state.currentMeal.photos.isEmpty) - return GestureDetector( - onTap: addImage(context, isLoading), - child: Stack( - children: [ - if (!isLoading) - Container( - margin: EdgeInsets.symmetric(horizontal: 12), - padding: EdgeInsets.symmetric( - horizontal: 32, - vertical: 64, - ), - decoration: AppDecoration.fillGray.copyWith( - borderRadius: BorderRadiusStyle.roundedBorder5, - ), - child: Row( - mainAxisAlignment: MainAxisAlignment.end, - mainAxisSize: MainAxisSize.min, - children: [ - Padding( - padding: EdgeInsets.only( - left: 8, - top: 8, - ), - child: Text( - "Добавить фото", - selectionColor: appTheme.blueA400, - ), - ), - Spacer(), - Icon( - Icons.photo_library, - color: appTheme.blueGray300, - ), - ], - ), - ), - if (isLoading) - Container( - margin: EdgeInsets.symmetric(horizontal: 12), - padding: EdgeInsets.symmetric( - horizontal: 32, - vertical: 64, - ), - decoration: AppDecoration.fillGray.copyWith( - borderRadius: BorderRadiusStyle.roundedBorder5, - ), - child: Center( - child: SizedBox( - height: 32, - width: 32, - child: rive.RiveAnimation.asset( - 'assets/rive_animations/loading.riv', - ), - ), - ), - ), - ], - ), - ); - else - return Container(); - } - - addImage(BuildContext context, bool isLoading) { - if (!isLoading) { - return () async { - final picker = ImagePicker(); - List? images = await picker.pickMultiImage(); - if (images.isNotEmpty) { - for (var image in images) { - context.read().add(UploadImages(image)); - } - } - }; - } - } - - _buildMeal(BuildContext context, DiaryStateLoaded state) { - final digitsOnly = FilteringTextInputFormatter.digitsOnly; - List _options = state.autocompleteList.map((Product item) => item.name).toList(); - return Container( - padding: EdgeInsets.symmetric( - horizontal: 24, - vertical: 12, - ), - decoration: BoxDecoration( - color: Colors.white, - borderRadius: const BorderRadius.all(Radius.circular(8)), - ), - child: Column( - mainAxisSize: MainAxisSize.min, - children: [ - Padding( - padding: EdgeInsets.symmetric(horizontal: 12), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Text( - "Время приема пищи", - style: CustomTextStyles.bodyMediumBlack900, - ), - Expanded( - // Adding Expanded widget - child: Padding( - padding: EdgeInsets.symmetric(horizontal: 12), - child: ConstrainedBox( - constraints: BoxConstraints( - maxWidth: MediaQuery.of(context).size.width - 260, - ), - child: GestureDetector( - onTap: () => _selectMealTime(context, state), - child: AbsorbPointer( - child: CustomTextFormField( - hintText: state.mealTimeController?.format(context).toString(), - autofocus: false, - ), - ), - ), - ), - ), - ), - ], - ), - ), - SizedBox(height: 24), - Padding( - padding: EdgeInsets.symmetric(horizontal: 12), - child: BlocSelector( - selector: (state) { - if (state is DiaryStateLoaded) - return state.diary; - else - return null; - }, - builder: (context, diary) { - return CustomDropDown( - items: state.mealList, - contentPadding: EdgeInsets.symmetric( - horizontal: 12, - vertical: 12, - ), - // defaultValue: state.mealList[0], - onChanged: changeMeal(context, state), - ); - }, - ), - ), - SizedBox(height: 24), - Padding( - padding: EdgeInsets.symmetric(horizontal: 12), - child: RawAutocomplete( - optionsBuilder: buildOptions(_options), - fieldViewBuilder: ( - BuildContext context, - TextEditingController productEditingController, - FocusNode focusNodeName, - VoidCallback onFieldSubmitted, - ) { - if (state.isAdded) { - print("Clear"); - } - return CustomTextFormField( - hintText: "Введите название продукта", - controller: productEditingController, - focusNode: focusNodeName, - onChanged: getAutocomplete(context, focusNodeName), - ); - }, - optionsViewBuilder: ( - BuildContext context, - AutocompleteOnSelected onSelected, - Iterable options, - ) { - return Align( - alignment: Alignment.topLeft, - child: Material( - elevation: 4.0, - child: SizedBox( - height: 200.0, - child: ListView.builder( - padding: const EdgeInsets.all(8.0), - itemCount: options.length, - itemBuilder: (BuildContext context, int index) { - final String option = options.elementAt(index); - return GestureDetector( - onTap: selectProduct(onSelected, option, state), - child: ListTile( - title: Text(option), - ), - ); - }, - ), - ), - ), - ); - }, - ), - ), - SizedBox(height: 24), - if (state.moderationExpanded) - Padding( - padding: EdgeInsets.symmetric(horizontal: 12), - child: GestureDetector( - onTap: () => openCaloriesDialog(context, state), - child: Text("Отправить на модерацию"), - ), - ), - SizedBox(height: 24), - Padding( - padding: EdgeInsets.symmetric(horizontal: 12), - child: SingleChildScrollView( - scrollDirection: Axis.horizontal, - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - CustomTextFormField( - width: 128, - hintText: "Кол-во", - textInputAction: TextInputAction.done, - // focusNode: focusNodeQuantity, - controller: state.productQuantityController, - keyboardType: TextInputType.number, - inputFormatters: [digitsOnly], - ), - Padding( - padding: EdgeInsets.only(left: 32), - child: BlocSelector( - selector: (state) { - if (state is DiaryStateLoaded) { - return state.diary; - } else - return null; - }, - builder: (context, diary) { - return CustomDropDown( - items: state.portionList, - // defaultValue: state.portionController, - onChanged: changePortion(context, state), - ); - }, - ), - ), - ], - ), - ), - ), - SizedBox(height: 24), - _buildAddProduct(context, state), - SizedBox(height: 24), - if (!state.diary.state.has_chosen_diet) ...state.portions.map((portion) => _buildProduct(context, portion)).toList(), - if (state.diary.state.has_chosen_diet) ...state.portions.map((portion) => _buildProductDiet(context, portion)).toList(), - SizedBox(height: 24), - _buildCarousel(context, state), - SizedBox(height: 24), - _buildAddPhoto(context, state), - SizedBox(height: 24), - Text( - "Ваша сытость после приёма пищи", - style: CustomTextStyles.bodyMediumBlack900, - ), - SizedBox(height: 16), - BlocBuilder( - builder: (context, state) { - if (state is DiaryStateLoaded) { - return Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Text("😭"), - ScaleElement( - color: Colors.red, - isSelected: state.selectedSatiety == 0, - onTap: changeSatiety(context, 0), - ), - ScaleElement( - color: Colors.orange, - isSelected: state.selectedSatiety == 1, - onTap: changeSatiety(context, 1), - ), - ScaleElement( - color: Colors.yellow, - isSelected: state.selectedSatiety == 2, - onTap: changeSatiety(context, 2), - ), - ScaleElement( - color: Colors.lime, - isSelected: state.selectedSatiety == 3, - onTap: changeSatiety(context, 3), - ), - ScaleElement( - color: Colors.lightGreen, - isSelected: state.selectedSatiety == 4, - onTap: changeSatiety(context, 4), - ), - ScaleElement( - color: Colors.green, - isSelected: state.selectedSatiety == 5, - onTap: changeSatiety(context, 5), - ), - Text("😊"), - // Остальные элементы шкалы - ], - ); - } else { - return Container(); // Возвращаем пустой контейнер, если состояние не является DiaryState - } - }, - ), - ], - ), - ); - } - - openCaloriesDialog(BuildContext context, DiaryStateLoaded state) { - showDialog( - context: context, - builder: (BuildContext dialogContext) { - return AlertDialog( - title: Text('Введите информацию о продукте'), - content: Column( - mainAxisSize: MainAxisSize.min, - children: [ - CustomTextFormField( - hintText: "Название", - controller: state.product_nameController, - ), - SizedBox(height: 12), - CustomTextFormField( - hintText: "Энергетическая ценность на 100", - keyboardType: TextInputType.number, - controller: state.caloriesController, - ), - SizedBox(height: 12), - CustomTextFormField( - hintText: "Белки на 100г", - keyboardType: TextInputType.number, - controller: state.proteinsController, - ), - SizedBox(height: 12), - CustomTextFormField( - hintText: "Жиры на 100г", - keyboardType: TextInputType.number, - controller: state.fatsController, - ), - SizedBox(height: 12), - CustomTextFormField( - hintText: "Углеводы на 100г", - keyboardType: TextInputType.number, - controller: state.carbsController, - ), - ], - ), - actions: [ - TextButton( - onPressed: popDialog(context), - child: Text('Отмена'), - ), - TextButton( - onPressed: triggerModeration( - context, - state.product_nameController.text, - state.caloriesController.text, - state.proteinsController.text, - state.fatsController.text, - state.carbsController.text, - dialogContext, - ), - child: Text('Отправить'), - ), - ], - ); - }, - ); - } - - triggerModeration( - BuildContext context, - String name, - String energyOn100gr, - String proteinsOn100gr, - String fatsOn100gr, - String carbohydratesOn100gr, - BuildContext dialogContext, - ) { - return () { - context.read().add( - SendModeration( - name: name, - energyOn100gr: energyOn100gr, - proteinsOn100gr: proteinsOn100gr, - fatsOn100gr: fatsOn100gr, - carbohydratesOn100gr: carbohydratesOn100gr, - ), - ); - Navigator.of(dialogContext).pop(); - }; - } - - popDialog(BuildContext dialogContext) { - return () { - Navigator.of(dialogContext).pop(); // Dismiss the dialog on Cancel button press - }; - } - - changeSatiety(BuildContext context, int satiety) { - return () { - context.read().add(ChangeSatiety(satiety)); - }; - } - - selectProduct(AutocompleteOnSelected onSelected, String option, DiaryStateLoaded state) { - state.product_nameController.text = option; - return () { - onSelected(option); - }; - } - - getAutocomplete(BuildContext context, FocusNode focusNode) { - return (value) { - if (value.length > 2) { - context.read().add(ProductInput(value)); - } - }; - } - - buildOptions(List _options) { - return (TextEditingValue textEditingValue) { - return _options.where((String option) { - return true; - }); - }; - } - - changeMeal(BuildContext context, DiaryStateLoaded state) { - return (value) { - context.read().add(ChangeMeal(value: value)); - }; - } - - changePortion(BuildContext context, DiaryStateLoaded state) { - return (value) { - context.read().add(ChangePortion(value: value)); - }; - } - - _buildCarousel(BuildContext context, DiaryStateLoaded state) { - if (state.currentMeal.photos.isEmpty) { - return Text("Фото нет"); - } else { - return CarouselSlider( - options: CarouselOptions(height: 200.0), - items: state.currentMeal.photos.map((photo) { - return _buildPhoto(context, photo, state); - }).toList(), - ); - } - } - - _buildProduct(BuildContext context, Portion portion) { - return Container( - margin: EdgeInsets.symmetric(horizontal: 12), - padding: EdgeInsets.symmetric( - horizontal: 8, - vertical: 8, - ), - decoration: AppDecoration.fillGray.copyWith( - borderRadius: BorderRadiusStyle.roundedBorder5, - ), - child: Row( - mainAxisAlignment: MainAxisAlignment.end, - mainAxisSize: MainAxisSize.min, - children: [ - Padding( - padding: EdgeInsets.only( - left: 8, - top: 8, - ), - child: Text( - portion.product_name.length > 8 ? portion.product_name.substring(0, 8) : portion.product_name, - style: CustomTextStyles.titleMedium16, - ), - ), - Padding( - padding: EdgeInsets.only( - left: 24, - top: 4, - bottom: 4, - ), - child: Text( - portion.quantity.toString() + ' ' + portion.portion.toString(), - ), - ), - Spacer(), - GestureDetector( - onTap: () => removePortion(context, portion), - child: Padding( - padding: const EdgeInsets.only(right: 10), - child: Icon( - Icons.close, - color: appTheme.blueGray300, - ), - ), - ), - ], - ), - ); - } - - _buildProductDiet(BuildContext context, Portion portion) { - return Container( - margin: EdgeInsets.symmetric( - horizontal: 12, - vertical: 4, - ), - padding: EdgeInsets.symmetric( - horizontal: 8, - vertical: 8, - ), - decoration: AppDecoration.fillGray.copyWith( - borderRadius: BorderRadiusStyle.roundedBorder5, - ), - child: Row( - mainAxisAlignment: MainAxisAlignment.end, - mainAxisSize: MainAxisSize.min, - children: [ - Checkbox( - value: !portion.from_diet, - onChanged: (bool? value) => context.read().add(ConfirmPortion(portion.id)), - ), - Padding( - padding: EdgeInsets.only( - left: 8, - top: 8, - ), - child: Text( - portion.product_name.length > 18 ? portion.product_name.substring(0, 18) : portion.product_name, - style: CustomTextStyles.titleMedium16, - ), - ), - Spacer(), - Padding( - padding: EdgeInsets.only( - left: 24, - top: 4, - bottom: 4, - ), - child: Text( - portion.quantity.toString() + ' ' + portion.portion.toString(), - ), - ), - ], - ), - ); - } - - _buildPhoto(BuildContext context, Photo photo, DiaryStateLoaded state) { - return Stack( + _products(List portions) { + return Column( + mainAxisSize: MainAxisSize.min, children: [ - Container( - margin: EdgeInsets.symmetric(horizontal: 12, vertical: 12), - decoration: AppDecoration.fillGray.copyWith( - borderRadius: BorderRadiusStyle.roundedBorder5, + for (int i = 0; i < portions.length; i++) ...[ + _product( + portions[i].productName, + portions[i].quantity, + portions[i].portion, ), - child: Image.network( - baseUrl + '/storage/' + photo.path, - fit: BoxFit.cover, // Чтобы изображение занимало весь контейнер - ), - ), - Positioned( - bottom: 0, - left: 0, - right: 0, - child: Container( - height: 64, // Высота затемненной области - decoration: BoxDecoration( - gradient: LinearGradient( - colors: [ - Colors.black.withOpacity(0.7), // Цвет затемнения - Colors.transparent, - ], - begin: Alignment.bottomCenter, - end: Alignment.topCenter, - ), - ), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - children: [ - IconButton( - icon: Icon(Icons.photo_outlined), - color: Colors.white, - onPressed: addImage(context, state.isLoading), - ), - IconButton( - icon: Icon(Icons.delete_outlined), - color: Colors.white, - onPressed: removePhoto(context, photo), - ), - ], - ), - ), - ), + i < portions.length - 1 ? const SizedBox(height: 8) : const SizedBox.shrink(), + ], ], ); } - removePortion(BuildContext context, Portion portion) { - return () { - context.read().add(RemovePortionEvent(portion.id)); - }; - } - - removePhoto(BuildContext context, Photo photo) { - return () { - context.read().add(RemoveImageEvent(photo.id.toString(), photo.path)); - }; - } - - /* _buildComment(BuildContext context, DiaryStateLoaded state) { - return Container( - padding: EdgeInsets.symmetric( - horizontal: 24.h, - vertical: 12.v, - ), - decoration: BoxDecoration( - color: Colors.white, - borderRadius: const BorderRadius.all(Radius.circular(8)), - ), - child: Column( - mainAxisSize: MainAxisSize.min, - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Text( - "Дополнительная информация для консультанта", - style: theme.textTheme.titleMedium, - textAlign: TextAlign.center, - ), - SizedBox(height: 20.v), - Container( - width: 320.h, - child: CustomTextFormField( - autofocus: false, - hintText: "Введите информацию для консультанта", - maxLines: 7, - borderDecoration: InputBorder.none, - controller: state.commentController, - ), - ), - ], - ), - ); - } */ - - _buildWakupRetire(BuildContext context, DiaryStateLoaded state) { - return Container( - padding: EdgeInsets.symmetric( - horizontal: 24, - vertical: 12, - ), - decoration: BoxDecoration( - color: Colors.white, - borderRadius: const BorderRadius.all(Radius.circular(8)), - ), - child: Column( - children: [ - GestureDetector( - onTap: toggleWakeup(context), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Text( - r"Подъем \ отход ко сну", - style: CustomTextStyles.bodyMediumBlack900, - ), - Icon(state.wakeupExpanded ? Icons.arrow_drop_up : Icons.arrow_drop_down), - ], - ), - ), - if (state.wakeupExpanded) - Padding( - padding: const EdgeInsets.only(left: 16.0), - child: Column( - children: [ - SizedBox(height: 24), - GestureDetector( - onTap: () => _selectWakeupTime(context, state), - child: AbsorbPointer( - child: CustomTextFormField( - hintText: state.wakeupController.format(context).toString(), - prefix: Icon(Icons.sunny), - autofocus: false, - ), - ), - ), - SizedBox(height: 24), - GestureDetector( - onTap: () => _selectRetireTime(context, state), - child: AbsorbPointer( - child: CustomTextFormField( - hintText: state.retireController.format(context).toString(), - prefix: Icon(Icons.bed), - autofocus: false, - ), - ), - ), - SizedBox(height: 24), - ], - ), - ), - ], + _product(String product, int quantity, String portion) { + portion == 'gr' ? portion = 'г' : portion = 'шт'; + return ListTile( + onTap: () {}, + trailing: Icon(Icons.more_vert_rounded), + title: Text(product), + subtitle: Text('$quantity $portion'), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(20), ), + tileColor: Color(0xFFF6FAFF), ); } - toggleWakeup(BuildContext context) { - return () { - BlocProvider.of(context).add(ToggleWakeupExpandedEvent()); - }; - } - - /// Section Widget - - Function() onFinishDayPressed(BuildContext context) { - return () { - showDialog( - context: context, - builder: (BuildContext dialogContext) { - return AlertDialog( - title: Text("Подтвердите действие"), - content: Text("Вы уверены, что хотите завершить день?"), - actions: [ - TextButton( - child: Text("Отмена"), - onPressed: closeDialog(dialogContext), + _meals(DiaryDayModel diaryDay) { + return Material( + borderRadius: BorderRadius.circular(20), + color: Colors.white, + child: Padding( + padding: const EdgeInsets.all(16), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + 'Прием пищи', + style: TextStyle( + color: Color(0xFF323F4B), + fontSize: 18, + fontWeight: FontWeight.w500, ), - TextButton( - child: Text("Подтвердить"), - onPressed: sendFinishDayData(dialogContext, context), - ), - ], - ); - }, - ); - }; - } - - Function() sendFinishDayData(BuildContext dialogContext, BuildContext context) { - return () { - closeDialog(dialogContext); - context.read().add(FinishDay()); - }; - } - - Function() closeDialog(BuildContext dialogContext) { - return () { - Navigator.of(dialogContext).pop(); - }; - } - - _buildMood(BuildContext context, DiaryStateLoaded state) { - return Container( - padding: EdgeInsets.symmetric( - horizontal: 24, - vertical: 12, - ), - decoration: BoxDecoration( - color: Colors.white, - borderRadius: const BorderRadius.all(Radius.circular(8)), - ), - child: Column( - children: [ - GestureDetector( - onTap: toggleMood(context), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Text( - "Ваше настроение после приема пищи", - style: CustomTextStyles.bodyMediumBlack900, - ), - Icon(state.moodExpanded ? Icons.arrow_drop_up : Icons.arrow_drop_down), - ], ), - ), - if (state.moodExpanded) + const SizedBox(height: 16), Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - Text("😭"), - ScaleElement( - color: Colors.red, - isSelected: state.selectedMood == 0, - onTap: changeMood(context, 0), - ), - ScaleElement( - color: Colors.orange, - isSelected: state.selectedMood == 1, - onTap: changeMood(context, 1), - ), - ScaleElement( - color: Colors.yellow, - isSelected: state.selectedMood == 2, - onTap: changeMood(context, 2), - ), - ScaleElement( - color: Colors.lime, - isSelected: state.selectedMood == 3, - onTap: changeMood(context, 3), - ), - ScaleElement( - color: Colors.lightGreen, - isSelected: state.selectedMood == 4, - onTap: changeMood(context, 4), - ), - ScaleElement( - color: Colors.green, - isSelected: state.selectedMood == 5, - onTap: changeMood(context, 5), - ), - Text("😊"), - // Остальные элементы шкалы + _mealButton(1), + _mealButton(2), + _mealButton(3), + _mealButton(4), + _mealButton(5), ], ), - ], + const SizedBox(height: 12), + _divider(context), + const SizedBox(height: 12), + Text( + 'Время приема пищи', + style: TextStyle( + color: Color(0xFF323F4B), + fontSize: 16, + fontWeight: FontWeight.w500, + ), + ), + const SizedBox(height: 12), + _divider(context), + const SizedBox(height: 12), + _products(diaryDay.meals[currentSelectedMealNumber - 1].portions), + const SizedBox(height: 16), + _addProductButton(diaryDay), + ], + ), ), ); } - changeMood(BuildContext context, int satiety) { - return () { - context.read().add(ChangeMood(satiety)); - }; - } + _mealButton(int mealNumber) { + bool isActive = currentSelectedMealNumber == mealNumber; - toggleMood(BuildContext context) { - return () { - BlocProvider.of(context).add(ToggleMoodExpandedEvent()); - }; - } - - Future _selectWakeupTime(BuildContext context, DiaryStateLoaded state) async { - final TimeOfDay? pickedTime = await showTimePicker( - context: context, - initialTime: state.wakeupController, + return InkWell( + onTap: () { + setState(() { + if (currentSelectedMealNumber == mealNumber) return; + currentSelectedMealNumber = mealNumber; + }); + }, + borderRadius: BorderRadius.circular(100), + child: Ink( + width: MediaQuery.of(context).size.width / 5 - (96 / 5), + height: 32, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(100), + color: isActive ? appTheme.blueA400 : Color(0xFFF1F2F6), + ), + child: Center( + child: Text( + '$mealNumber', + style: TextStyle( + color: isActive ? Colors.white : Colors.black, + fontSize: 16, + fontWeight: FontWeight.w600, + ), + ), + ), + ), ); - if (pickedTime != null && pickedTime != state.wakeupController) { - context.read().add(WakeupEvent(pickedTime)); - } } - Future _selectRetireTime(BuildContext context, DiaryStateLoaded state) async { - final TimeOfDay? pickedTime = await showTimePicker( - context: context, - initialTime: state.retireController, + _loader() { + return Center( + child: SizedBox( + height: 32, + width: 32, + child: RiveAnimation.asset( + 'assets/rive_animations/loading.riv', + ), + ), ); - if (pickedTime != null && pickedTime != state.retireController) { - context.read().add(RetireEvent(pickedTime)); - } } - Future _selectMealTime(BuildContext context, DiaryStateLoaded state) async { - final TimeOfDay? pickedTime = await showTimePicker( - context: context, - initialTime: state.mealTimeController ?? TimeOfDay.now(), + _calendar(DiaryState state) { + return Column( + mainAxisSize: MainAxisSize.min, + children: [ + Padding( + padding: const EdgeInsets.only(top: 16), + child: TableCalendar( + firstDay: DateTime.utc(2010, 10, 16), + lastDay: DateTime.utc(2030, 3, 14), + locale: 'ru_RU', + startingDayOfWeek: StartingDayOfWeek.monday, + focusedDay: _focusedDay, + calendarFormat: _calendarFormat, + headerStyle: HeaderStyle( + titleCentered: true, + formatButtonVisible: false, + leftChevronVisible: false, + rightChevronVisible: false, + ), + selectedDayPredicate: (day) { + return isSameDay(_selectedDay, day); + }, + onDaySelected: (selectedDay, focusedDay) { + if (state is! DiaryStateLoaded) return; + if (!isSameDay(_selectedDay, selectedDay)) { + setState(() { + _selectedDay = selectedDay; + _focusedDay = focusedDay; + currentSelectedMealNumber = 1; + }); + diaryCubit.getDiaryDay(_selectedDay!.toString()); + } + }, + onFormatChanged: (format) { + if (_calendarFormat != format) { + setState(() { + _calendarFormat = format; + }); + } + }, + onPageChanged: (focusedDay) { + _focusedDay = focusedDay; + }, + calendarStyle: CalendarStyle( + weekendDecoration: BoxDecoration( + color: Colors.white, + shape: BoxShape.circle, + ), + defaultDecoration: BoxDecoration( + color: Colors.white, + shape: BoxShape.circle, + ), + selectedDecoration: BoxDecoration( + color: appTheme.blueA400, + shape: BoxShape.circle, + ), + todayTextStyle: TextStyle( + color: Colors.black, + ), + todayDecoration: BoxDecoration( + border: Border.all( + color: appTheme.blueA400, + width: 2, + ), + color: Colors.white, + shape: BoxShape.circle, + ), + ), + ), + ), + _arrowDown(), + ], + ); + } + + _addProductButton(DiaryDayModel diaryDay) { + return InkWell( + onTap: () { + setState(() { + selectedGlossary = null; + productNameController.clear(); + quantityController.clear(); + }); + showModalBottomSheet( + useRootNavigator: true, + context: context, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.vertical(top: Radius.circular(12)), + ), + isScrollControlled: true, + builder: (context) { + return StatefulBuilder( + builder: (BuildContext context, void Function(void Function()) setState) { + return Padding( + padding: const EdgeInsets.all(16) + EdgeInsets.only(bottom: MediaQuery.of(context).viewInsets.bottom), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisSize: MainAxisSize.min, + children: [ + Text( + 'Добавление блюда', + style: TextStyle( + fontSize: 20, + fontWeight: FontWeight.w600, + color: Color(0xFF323F4B), + ), + ), + const SizedBox(height: 16), + TypeAheadField( + controller: productNameController, + itemBuilder: (context, glossary) { + return Padding( + padding: const EdgeInsets.all(8.0), + child: Text( + glossary.name, + style: TextStyle( + height: 1, + fontSize: 16, + ), + ), + ); + }, + itemSeparatorBuilder: (context, index) => _divider(context), + onSelected: (newSelectedGlossary) { + setState(() { + selectedGlossary = newSelectedGlossary; + productNameController.text = selectedGlossary!.name; + }); + }, + suggestionsCallback: (query) async { + if (query.length < 1) return []; + return await diaryCubit.getGlossaryListByQuery(query); + }, + builder: (context, controller, focusNode) { + return CustomTextFormField( + controller: controller, + focusNode: focusNode, + autofocus: true, + hintText: 'Введите название продукта/блюда', + ); + }, + emptyBuilder: (context) => const SizedBox.shrink(), + errorBuilder: (context, object) => Padding( + padding: const EdgeInsets.all(8.0), + child: Text('Нет подходящих вариантов'), + ), + ), + if (selectedGlossary != null) + Padding( + padding: const EdgeInsets.only(top: 8), + child: CustomTextFormField( + controller: quantityController, + keyboardType: TextInputType.number, + hintText: selectedGlossary!.grInPortion == 0 ? '100' : '1', + suffixText: selectedGlossary != null + ? selectedGlossary!.grInPortion == 0 + ? 'гр' + : 'шт' + : null, + ), + ), + const SizedBox(height: 16), + InkWell( + onTap: () { + diaryCubit.addProductToMeal( + diaryId: diaryDay.id, + mealId: diaryDay.meals[currentSelectedMealNumber - 1].id, + productName: productNameController.text, + portion: selectedGlossary!.grInPortion == 0 ? 'gr' : 'pcs', + quantity: int.parse(quantityController.text), + date: _selectedDay.toString(), + ); + Navigator.of(context).pop(); + }, + borderRadius: BorderRadius.circular(20), + child: Ink( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(20), + color: appTheme.blueA400, + ), + child: Container( + width: MediaQuery.of(context).size.width - 32, + padding: const EdgeInsets.all(16), + alignment: Alignment.center, + child: Text( + 'Добавить', + style: TextStyle( + fontSize: 18, + fontWeight: FontWeight.w600, + color: Colors.white, + ), + ), + ), + ), + ), + ], + ), + ); + }, + ); + }, + ); + }, + borderRadius: BorderRadius.circular(20), + child: Ink( + padding: EdgeInsets.symmetric(horizontal: 16), + width: MediaQuery.of(context).size.width - 32, + decoration: BoxDecoration( + color: appTheme.blueA400, + borderRadius: BorderRadius.circular(20), + ), + child: Container( + padding: EdgeInsets.all(16), + alignment: Alignment.center, + child: Text( + 'Добавить', + style: TextStyle( + color: Colors.white, + fontSize: 18, + fontWeight: FontWeight.w600, + ), + ), + ), + ), ); - if (pickedTime != null && pickedTime != state.mealTimeController) { - context.read().add(ChangeMealTime(pickedTime)); - } } } - -bool checkConsumedValues(List recommendedValues, List consumedValues) { - for (int i = 0; i < recommendedValues.length; i++) { - if (consumedValues[i] > recommendedValues[i]) { - // Если хотя бы одно потребленное значение превышает рекомендованное - return true; // Возвращаем false - } - } - // Если ни одно потребленное значение не превышает рекомендованное с соответствующим индексом - return false; // Возвращаем true -} - -List mealsToDropdown(List? meals) { - return meals! - .map((meal) => SelectionPopupModel( - id: meal.id, - title: "Прием пищи ${meal.type}", - isSelected: false, - )) - .toList(); -} diff --git a/lib/features/diary/repositories/diary_repository.dart b/lib/features/diary/repositories/diary_repository.dart index 04a8cad0..dde8a702 100644 --- a/lib/features/diary/repositories/diary_repository.dart +++ b/lib/features/diary/repositories/diary_repository.dart @@ -1,200 +1,37 @@ -import 'dart:io'; - -import 'package:eatvio_app/features/diary/models/diary_model.dart'; -import 'package:eatvio_app/features/diary/models/portion.dart'; -import 'package:eatvio_app/features/diary/models/product.dart'; +import 'package:eatvio_app/features/diary/models/diary_day_model.dart'; import 'package:eatvio_app/features/diary/services/diary_service.dart'; class DiaryRepository { final DiaryService diaryService; - DiaryRepository({required this.diaryService}); + DiaryRepository({ + required this.diaryService, + }); - Future> getDiaryID() async { - try { - return await diaryService.getDiaryID(); - } catch (e) { - rethrow; - } + Future getDiaryByDate(String date) async { + return (await diaryService.getDiaryDay( + index: await _getDiaryIndexByDate(date), + )) + .diary; } - Future getDiary(int diaryID) async { - try { - return (await diaryService.getDiary(diaryID))['diary']!; - } catch (e) { - rethrow; - } + Future _getDiaryIndexByDate(String date) async { + return (await diaryService.getDiaryIndexByDate(date: date)).id; } - Future> getChartData(int diaryID) async { - try { - return (await diaryService.getChart(diaryID)); - } catch (e) { - rethrow; - } - } - - Future>> inputProduct(String name) async { - try { - return await diaryService.getInputProduct(name); - } catch (e) { - rethrow; - } - } - - Future changeSatiety(int satiety, int mealID, int diaryID) async { - try { - await diaryService.sendSatietyData( - diaryID, - mealID, - satiety, - ); - } catch (e) { - rethrow; - } - } - - Future changeMood(int mood, int mealID, int diaryID) async { - try { - await diaryService.sendMoodData( - diaryID, - mealID, - mood, - ); - } catch (e) { - rethrow; - } - } - - Future changeWakeup( - int diaryID, - String wakeup, - ) async { - try { - await diaryService.sendWakeupData( - diaryID, - wakeup, - ); - } catch (e) { - rethrow; - } - } - - Future changeRetire( - int diaryID, - String retire, - ) async { - try { - await diaryService.sendWakeupData( - diaryID, - retire, - ); - } catch (e) { - rethrow; - } - } - - Future> addPortion( - int diaryID, - int mealID, - String name, - String product, - int quantity, - ) async { - try { - return await diaryService.sendPortionData( - diaryID, - mealID, - name, - product, - quantity, - ); - } catch (e) { - rethrow; - } - } - - Future> sendModeration( - String name, - String energy_on_100gr, - String proteins_on_100gr, - String fats_on_100gr, - String carbohydrates_on_100gr, - ) async { - try { - return await diaryService.sendModerationData( - name, - double.parse(energy_on_100gr + ".0"), - double.parse(proteins_on_100gr + ".0"), - double.parse(fats_on_100gr + ".0"), - double.parse(carbohydrates_on_100gr + ".0"), - ); - } catch (e) { - rethrow; - } - } - - Future removePortion( - int diaryID, - int mealID, - int portionID, - ) async { - try { - await diaryService.sendRemovePortionData( - diaryID, - mealID, - portionID, - ); - } catch (e) { - rethrow; - } - } - - Future uploadImage( - String path, - int diaryID, - int mealID, - ) async { - try { - File file = File(path); - await diaryService.uploadImage( - diaryID, - mealID, - file, - ); - } catch (e) { - rethrow; - } - } - - Future removeImage( - int diaryID, - int mealID, - int photoID, - String path, - ) async { - try { - await diaryService.sendRemovePhotoData( - diaryID, - mealID, - path, - photoID, - ); - } catch (e) { - rethrow; - } - } - - Future finishDay( - int diaryID, - ) async { - try { - /*final formatter = DateFormat('HH:mm'); - final wakeupString = formatter.format(DateTime(2022, 1, 1, wakeup.hour, wakeup.minute)); - final retireString = formatter.format(DateTime(2022, 1, 1, retire.hour, retire.minute));*/ - await diaryService.sendFinishDay(diaryID); - } catch (e) { - rethrow; - } + Future addPortionToMeal({ + required int diaryId, + required int mealId, + required String productName, + required String portion, + required int quantity, + }) async { + return await diaryService.addProductToMeal( + diaryId: diaryId, + mealId: mealId, + productName: productName, + portion: portion, + quantity: quantity, + ); } } diff --git a/lib/features/diary/services/diary_service.dart b/lib/features/diary/services/diary_service.dart index d7fa9a0c..cdce2dd4 100644 --- a/lib/features/diary/services/diary_service.dart +++ b/lib/features/diary/services/diary_service.dart @@ -1,9 +1,6 @@ -import 'dart:io'; - import 'package:dio/dio.dart'; -import 'package:eatvio_app/features/diary/models/diary_model.dart'; -import 'package:eatvio_app/features/diary/models/portion.dart'; -import 'package:eatvio_app/features/diary/models/product.dart'; +import 'package:eatvio_app/features/diary/models/diary_day_model.dart'; +import 'package:eatvio_app/features/diary/models/diary_index_model.dart'; import 'package:retrofit/retrofit.dart'; part 'diary_service.g.dart'; @@ -12,89 +9,22 @@ part 'diary_service.g.dart'; abstract class DiaryService { factory DiaryService(Dio dio, {String baseUrl}) = _DiaryService; - @GET('/api/diary/index') - Future> getDiaryID(); + @GET('/api/diary/index/{date}') + Future getDiaryIndexByDate({ + @Path('date') required String date, // yyyy-mm-dd + }); - @GET('/api/diary/{id}/show/') - Future> getDiary(@Path() int id); - - @GET('/api/diary/{id}/dailyNutritionData/') - Future getChart(@Path() int id); - - @GET('/api/diary/product_nutritional_values/filter') - Future>> getInputProduct(@Query('name') String name); - - @POST('/api/diary/{diary_id}/meal/{meal_id}/satiety/fill') - Future> sendSatietyData( - @Path() int diary_id, - @Path() int meal_id, - @Query('satiety') int satiety, - ); - - @POST('/api/diary/{diary_id}/meal/{meal_id}/mood/fill') - Future> sendMoodData( - @Path() int diary_id, - @Path() int meal_id, - @Query('mood') int mood, - ); - - @POST('/api/diary/{diary_id}/wakeup/fill') - Future sendWakeupData( - @Path() int diary_id, - @Query('wakeup') String wakeup, - ); - - @POST('/api/diary/{diary_id}/retire/fill') - Future sendRetireData( - @Path() int diary_id, - @Query('retire') String retire, - ); + @GET('/api/diary/{diary_id}/show') + Future getDiaryDay({ + @Path('diary_id') required int index, + }); @POST('/api/diary/{diary_id}/meal/{meal_id}/portions/create') - Future> sendPortionData( - @Path() int diary_id, - @Path() int meal_id, - @Query('product_name') String product_name, - @Query('portion') String portion, - @Query('quantity') int quantity, - ); - - @POST('/api/diary/{diary_id}/meal/{meal_id}/photo/upload') - Future uploadImage( - @Path() int diary_id, - @Path() int meal_id, - @Part() File photo, - ); - - @POST('/api/diary/product_nutritional_values/sendToModeration') - Future> sendModerationData( - @Query('name') String product_name, - @Query('energy_on_100gr') double energy_on_100gr, - @Query('proteins_on_100gr') double proteins_on_100gr, - @Query('fats_on_100gr') double fats_on_100gr, - @Query('carbohydrates_on_100gr') double carbohydrates_on_100gr, - ); - - @POST('/api/diary/{diary_id}/finishDay') - Future sendFinishDay( - @Path() int diary_id, - //@Query('wakeUp') String wakeup, - //@Query('retire') String retire, - //@Query('comment') String comment, - ); - - @DELETE('/api/diary/{diary_id}/meal/{meal_id}/portions/{portion_id}/delete') - Future sendRemovePortionData( - @Path() int diary_id, - @Path() int meal_id, - @Path() int portion_id, - ); - - @DELETE('/api/diary/{diary_id}/meal/{meal_id}/photo/delete') - Future sendRemovePhotoData( - @Path() int diary_id, - @Path() int meal_id, - @Query('path') String path, - @Query('id') int photo_id, - ); + Future addProductToMeal({ + @Path('diary_id') required int diaryId, + @Path('meal_id') required int mealId, + @Part(name: 'product_name') required String productName, + @Part(name: 'portion') required String portion, + @Part(name: 'quantity') required int quantity, + }); } diff --git a/lib/features/diary/services/diary_service.g.dart b/lib/features/diary/services/diary_service.g.dart index 8c1039c0..b145757c 100644 --- a/lib/features/diary/services/diary_service.g.dart +++ b/lib/features/diary/services/diary_service.g.dart @@ -6,7 +6,7 @@ part of 'diary_service.dart'; // RetrofitGenerator // ************************************************************************** -// ignore_for_file: unnecessary_brace_in_string_interps,no_leading_underscores_for_local_identifiers,unused_element +// ignore_for_file: unnecessary_brace_in_string_interps,no_leading_underscores_for_local_identifiers,unused_element,unnecessary_string_interpolations class _DiaryService implements DiaryService { _DiaryService( @@ -22,19 +22,19 @@ class _DiaryService implements DiaryService { final ParseErrorLogger? errorLogger; @override - Future> getDiaryID() async { + Future getDiaryIndexByDate({required String date}) async { final _extra = {}; final queryParameters = {}; final _headers = {}; const Map? _data = null; - final _options = _setStreamType>(Options( + final _options = _setStreamType(Options( method: 'GET', headers: _headers, extra: _extra, ) .compose( _dio.options, - '/api/diary/index', + '/api/diary/index/${date}', queryParameters: queryParameters, data: _data, ) @@ -44,9 +44,9 @@ class _DiaryService implements DiaryService { baseUrl, ))); final _result = await _dio.fetch>(_options); - late Map _value; + late DiaryIndexModel _value; try { - _value = _result.data!.cast(); + _value = DiaryIndexModel.fromJson(_result.data!); } on Object catch (e, s) { errorLogger?.logError(e, s, _options); rethrow; @@ -55,19 +55,19 @@ class _DiaryService implements DiaryService { } @override - Future> getDiary(int id) async { + Future getDiaryDay({required int index}) async { final _extra = {}; final queryParameters = {}; final _headers = {}; const Map? _data = null; - final _options = _setStreamType>(Options( + final _options = _setStreamType(Options( method: 'GET', headers: _headers, extra: _extra, ) .compose( _dio.options, - '/api/diary/${id}/show/', + '/api/diary/${index}/show', queryParameters: queryParameters, data: _data, ) @@ -77,10 +77,9 @@ class _DiaryService implements DiaryService { baseUrl, ))); final _result = await _dio.fetch>(_options); - late Map _value; + late DiaryDayWrapperModel _value; try { - _value = _result.data!.map((k, dynamic v) => - MapEntry(k, DiaryModel.fromJson(v as Map))); + _value = DiaryDayWrapperModel.fromJson(_result.data!); } on Object catch (e, s) { errorLogger?.logError(e, s, _options); rethrow; @@ -89,275 +88,28 @@ class _DiaryService implements DiaryService { } @override - Future getChart(int id) async { - final _extra = {}; - final queryParameters = {}; - final _headers = {}; - const Map? _data = null; - final _options = _setStreamType(Options( - method: 'GET', - headers: _headers, - extra: _extra, - ) - .compose( - _dio.options, - '/api/diary/${id}/dailyNutritionData/', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - ))); - final _result = await _dio.fetch(_options); - final _value = _result.data; - return _value; - } - - @override - Future>> getInputProduct(String name) async { - final _extra = {}; - final queryParameters = {r'name': name}; - final _headers = {}; - const Map? _data = null; - final _options = _setStreamType>>(Options( - method: 'GET', - headers: _headers, - extra: _extra, - ) - .compose( - _dio.options, - '/api/diary/product_nutritional_values/filter', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - ))); - final _result = await _dio.fetch>(_options); - late Map> _value; - try { - _value = _result.data!.map((k, dynamic v) => MapEntry( - k, - (v as List) - .map((i) => Product.fromJson(i as Map)) - .toList())); - } on Object catch (e, s) { - errorLogger?.logError(e, s, _options); - rethrow; - } - return _value; - } - - @override - Future> sendSatietyData( - int diary_id, - int meal_id, - int satiety, - ) async { - final _extra = {}; - final queryParameters = {r'satiety': satiety}; - final _headers = {}; - const Map? _data = null; - final _options = _setStreamType>(Options( - method: 'POST', - headers: _headers, - extra: _extra, - ) - .compose( - _dio.options, - '/api/diary/${diary_id}/meal/${meal_id}/satiety/fill', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - ))); - final _result = await _dio.fetch>(_options); - late Map _value; - try { - _value = _result.data!.cast(); - } on Object catch (e, s) { - errorLogger?.logError(e, s, _options); - rethrow; - } - return _value; - } - - @override - Future> sendMoodData( - int diary_id, - int meal_id, - int mood, - ) async { - final _extra = {}; - final queryParameters = {r'mood': mood}; - final _headers = {}; - const Map? _data = null; - final _options = _setStreamType>(Options( - method: 'POST', - headers: _headers, - extra: _extra, - ) - .compose( - _dio.options, - '/api/diary/${diary_id}/meal/${meal_id}/mood/fill', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - ))); - final _result = await _dio.fetch>(_options); - late Map _value; - try { - _value = _result.data!.cast(); - } on Object catch (e, s) { - errorLogger?.logError(e, s, _options); - rethrow; - } - return _value; - } - - @override - Future sendWakeupData( - int diary_id, - String wakeup, - ) async { - final _extra = {}; - final queryParameters = {r'wakeup': wakeup}; - final _headers = {}; - const Map? _data = null; - final _options = _setStreamType(Options( - method: 'POST', - headers: _headers, - extra: _extra, - ) - .compose( - _dio.options, - '/api/diary/${diary_id}/wakeup/fill', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - ))); - final _result = await _dio.fetch>(_options); - late DiaryModel _value; - try { - _value = DiaryModel.fromJson(_result.data!); - } on Object catch (e, s) { - errorLogger?.logError(e, s, _options); - rethrow; - } - return _value; - } - - @override - Future sendRetireData( - int diary_id, - String retire, - ) async { - final _extra = {}; - final queryParameters = {r'retire': retire}; - final _headers = {}; - const Map? _data = null; - final _options = _setStreamType(Options( - method: 'POST', - headers: _headers, - extra: _extra, - ) - .compose( - _dio.options, - '/api/diary/${diary_id}/retire/fill', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - ))); - final _result = await _dio.fetch>(_options); - late DiaryModel _value; - try { - _value = DiaryModel.fromJson(_result.data!); - } on Object catch (e, s) { - errorLogger?.logError(e, s, _options); - rethrow; - } - return _value; - } - - @override - Future> sendPortionData( - int diary_id, - int meal_id, - String product_name, - String portion, - int quantity, - ) async { - final _extra = {}; - final queryParameters = { - r'product_name': product_name, - r'portion': portion, - r'quantity': quantity, - }; - final _headers = {}; - const Map? _data = null; - final _options = _setStreamType>(Options( - method: 'POST', - headers: _headers, - extra: _extra, - ) - .compose( - _dio.options, - '/api/diary/${diary_id}/meal/${meal_id}/portions/create', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - ))); - final _result = await _dio.fetch>(_options); - late Map _value; - try { - _value = _result.data!.map((k, dynamic v) => - MapEntry(k, Portion.fromJson(v as Map))); - } on Object catch (e, s) { - errorLogger?.logError(e, s, _options); - rethrow; - } - return _value; - } - - @override - Future uploadImage( - int diary_id, - int meal_id, - File photo, - ) async { + Future addProductToMeal({ + required int diaryId, + required int mealId, + required String productName, + required String portion, + required int quantity, + }) async { final _extra = {}; final queryParameters = {}; final _headers = {}; final _data = FormData(); - _data.files.add(MapEntry( - 'photo', - MultipartFile.fromFileSync( - photo.path, - filename: photo.path.split(Platform.pathSeparator).last, - ), + _data.fields.add(MapEntry( + 'product_name', + productName, + )); + _data.fields.add(MapEntry( + 'portion', + portion, + )); + _data.fields.add(MapEntry( + 'quantity', + quantity.toString(), )); final _options = _setStreamType(Options( method: 'POST', @@ -366,139 +118,7 @@ class _DiaryService implements DiaryService { ) .compose( _dio.options, - '/api/diary/${diary_id}/meal/${meal_id}/photo/upload', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - ))); - await _dio.fetch(_options); - } - - @override - Future> sendModerationData( - String product_name, - double energy_on_100gr, - double proteins_on_100gr, - double fats_on_100gr, - double carbohydrates_on_100gr, - ) async { - final _extra = {}; - final queryParameters = { - r'name': product_name, - r'energy_on_100gr': energy_on_100gr, - r'proteins_on_100gr': proteins_on_100gr, - r'fats_on_100gr': fats_on_100gr, - r'carbohydrates_on_100gr': carbohydrates_on_100gr, - }; - final _headers = {}; - const Map? _data = null; - final _options = _setStreamType>(Options( - method: 'POST', - headers: _headers, - extra: _extra, - ) - .compose( - _dio.options, - '/api/diary/product_nutritional_values/sendToModeration', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - ))); - final _result = await _dio.fetch>(_options); - late Map _value; - try { - _value = _result.data!.cast(); - } on Object catch (e, s) { - errorLogger?.logError(e, s, _options); - rethrow; - } - return _value; - } - - @override - Future sendFinishDay(int diary_id) async { - final _extra = {}; - final queryParameters = {}; - final _headers = {}; - const Map? _data = null; - final _options = _setStreamType(Options( - method: 'POST', - headers: _headers, - extra: _extra, - ) - .compose( - _dio.options, - '/api/diary/${diary_id}/finishDay', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - ))); - await _dio.fetch(_options); - } - - @override - Future sendRemovePortionData( - int diary_id, - int meal_id, - int portion_id, - ) async { - final _extra = {}; - final queryParameters = {}; - final _headers = {}; - const Map? _data = null; - final _options = _setStreamType(Options( - method: 'DELETE', - headers: _headers, - extra: _extra, - ) - .compose( - _dio.options, - '/api/diary/${diary_id}/meal/${meal_id}/portions/${portion_id}/delete', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - ))); - await _dio.fetch(_options); - } - - @override - Future sendRemovePhotoData( - int diary_id, - int meal_id, - String path, - int photo_id, - ) async { - final _extra = {}; - final queryParameters = { - r'path': path, - r'id': photo_id, - }; - final _headers = {}; - const Map? _data = null; - final _options = _setStreamType(Options( - method: 'DELETE', - headers: _headers, - extra: _extra, - ) - .compose( - _dio.options, - '/api/diary/${diary_id}/meal/${meal_id}/photo/delete', + '/api/diary/${diaryId}/meal/${mealId}/portions/create', queryParameters: queryParameters, data: _data, ) diff --git a/lib/features/feed/presentation/bloc/feed_cubit/feed_cubit.dart b/lib/features/feed/presentation/bloc/feed_cubit/feed_cubit.dart index f387a4eb..83df5eb0 100644 --- a/lib/features/feed/presentation/bloc/feed_cubit/feed_cubit.dart +++ b/lib/features/feed/presentation/bloc/feed_cubit/feed_cubit.dart @@ -37,9 +37,7 @@ class FeedCubit extends Cubit { try { if (currentPage < lastPage) { - print('before: $currentPage'); currentPage++; - print('after: $currentPage'); final feedBlogPosts = await feedRepository.getFeedBlogPosts( page: currentPage, query: _query, diff --git a/lib/features/feed/services/feed_service.g.dart b/lib/features/feed/services/feed_service.g.dart index 31b022c4..952b5416 100644 --- a/lib/features/feed/services/feed_service.g.dart +++ b/lib/features/feed/services/feed_service.g.dart @@ -6,7 +6,7 @@ part of 'feed_service.dart'; // RetrofitGenerator // ************************************************************************** -// ignore_for_file: unnecessary_brace_in_string_interps,no_leading_underscores_for_local_identifiers,unused_element +// ignore_for_file: unnecessary_brace_in_string_interps,no_leading_underscores_for_local_identifiers,unused_element,unnecessary_string_interpolations class _FeedService implements FeedService { _FeedService( diff --git a/lib/features/glossary/models/glossary_model.dart b/lib/features/glossary/models/glossary_model.dart new file mode 100644 index 00000000..8e437d95 --- /dev/null +++ b/lib/features/glossary/models/glossary_model.dart @@ -0,0 +1,24 @@ +import 'package:freezed_annotation/freezed_annotation.dart'; + +part 'glossary_model.freezed.dart'; +part 'glossary_model.g.dart'; + +@freezed +class GlossaryPaginationModel with _$GlossaryPaginationModel { + const factory GlossaryPaginationModel({ + @JsonKey(name: 'data') required List glossariesList, + }) = _GlossaryPaginationModel; + + factory GlossaryPaginationModel.fromJson(Map json) => _$GlossaryPaginationModelFromJson(json); +} + +@freezed +class GlossaryModel with _$GlossaryModel { + const factory GlossaryModel({ + required int id, + required String name, + @JsonKey(name: 'portion_mass_gr') required int grInPortion, + }) = _GlossaryModel; + + factory GlossaryModel.fromJson(Map json) => _$GlossaryModelFromJson(json); +} diff --git a/lib/features/glossary/models/glossary_model.freezed.dart b/lib/features/glossary/models/glossary_model.freezed.dart new file mode 100644 index 00000000..d5e1556f --- /dev/null +++ b/lib/features/glossary/models/glossary_model.freezed.dart @@ -0,0 +1,380 @@ +// 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 'glossary_model.dart'; + +// ************************************************************************** +// FreezedGenerator +// ************************************************************************** + +T _$identity(T value) => value; + +final _privateConstructorUsedError = UnsupportedError( + 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models'); + +GlossaryPaginationModel _$GlossaryPaginationModelFromJson( + Map json) { + return _GlossaryPaginationModel.fromJson(json); +} + +/// @nodoc +mixin _$GlossaryPaginationModel { + @JsonKey(name: 'data') + List get glossariesList => throw _privateConstructorUsedError; + + /// Serializes this GlossaryPaginationModel to a JSON map. + Map toJson() => throw _privateConstructorUsedError; + + /// Create a copy of GlossaryPaginationModel + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $GlossaryPaginationModelCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $GlossaryPaginationModelCopyWith<$Res> { + factory $GlossaryPaginationModelCopyWith(GlossaryPaginationModel value, + $Res Function(GlossaryPaginationModel) then) = + _$GlossaryPaginationModelCopyWithImpl<$Res, GlossaryPaginationModel>; + @useResult + $Res call({@JsonKey(name: 'data') List glossariesList}); +} + +/// @nodoc +class _$GlossaryPaginationModelCopyWithImpl<$Res, + $Val extends GlossaryPaginationModel> + implements $GlossaryPaginationModelCopyWith<$Res> { + _$GlossaryPaginationModelCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of GlossaryPaginationModel + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? glossariesList = null, + }) { + return _then(_value.copyWith( + glossariesList: null == glossariesList + ? _value.glossariesList + : glossariesList // ignore: cast_nullable_to_non_nullable + as List, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$GlossaryPaginationModelImplCopyWith<$Res> + implements $GlossaryPaginationModelCopyWith<$Res> { + factory _$$GlossaryPaginationModelImplCopyWith( + _$GlossaryPaginationModelImpl value, + $Res Function(_$GlossaryPaginationModelImpl) then) = + __$$GlossaryPaginationModelImplCopyWithImpl<$Res>; + @override + @useResult + $Res call({@JsonKey(name: 'data') List glossariesList}); +} + +/// @nodoc +class __$$GlossaryPaginationModelImplCopyWithImpl<$Res> + extends _$GlossaryPaginationModelCopyWithImpl<$Res, + _$GlossaryPaginationModelImpl> + implements _$$GlossaryPaginationModelImplCopyWith<$Res> { + __$$GlossaryPaginationModelImplCopyWithImpl( + _$GlossaryPaginationModelImpl _value, + $Res Function(_$GlossaryPaginationModelImpl) _then) + : super(_value, _then); + + /// Create a copy of GlossaryPaginationModel + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? glossariesList = null, + }) { + return _then(_$GlossaryPaginationModelImpl( + glossariesList: null == glossariesList + ? _value._glossariesList + : glossariesList // ignore: cast_nullable_to_non_nullable + as List, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$GlossaryPaginationModelImpl implements _GlossaryPaginationModel { + const _$GlossaryPaginationModelImpl( + {@JsonKey(name: 'data') + required final List glossariesList}) + : _glossariesList = glossariesList; + + factory _$GlossaryPaginationModelImpl.fromJson(Map json) => + _$$GlossaryPaginationModelImplFromJson(json); + + final List _glossariesList; + @override + @JsonKey(name: 'data') + List get glossariesList { + if (_glossariesList is EqualUnmodifiableListView) return _glossariesList; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(_glossariesList); + } + + @override + String toString() { + return 'GlossaryPaginationModel(glossariesList: $glossariesList)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$GlossaryPaginationModelImpl && + const DeepCollectionEquality() + .equals(other._glossariesList, _glossariesList)); + } + + @JsonKey(includeFromJson: false, includeToJson: false) + @override + int get hashCode => Object.hash( + runtimeType, const DeepCollectionEquality().hash(_glossariesList)); + + /// Create a copy of GlossaryPaginationModel + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$GlossaryPaginationModelImplCopyWith<_$GlossaryPaginationModelImpl> + get copyWith => __$$GlossaryPaginationModelImplCopyWithImpl< + _$GlossaryPaginationModelImpl>(this, _$identity); + + @override + Map toJson() { + return _$$GlossaryPaginationModelImplToJson( + this, + ); + } +} + +abstract class _GlossaryPaginationModel implements GlossaryPaginationModel { + const factory _GlossaryPaginationModel( + {@JsonKey(name: 'data') + required final List glossariesList}) = + _$GlossaryPaginationModelImpl; + + factory _GlossaryPaginationModel.fromJson(Map json) = + _$GlossaryPaginationModelImpl.fromJson; + + @override + @JsonKey(name: 'data') + List get glossariesList; + + /// Create a copy of GlossaryPaginationModel + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + _$$GlossaryPaginationModelImplCopyWith<_$GlossaryPaginationModelImpl> + get copyWith => throw _privateConstructorUsedError; +} + +GlossaryModel _$GlossaryModelFromJson(Map json) { + return _GlossaryModel.fromJson(json); +} + +/// @nodoc +mixin _$GlossaryModel { + int get id => throw _privateConstructorUsedError; + String get name => throw _privateConstructorUsedError; + @JsonKey(name: 'portion_mass_gr') + int get grInPortion => throw _privateConstructorUsedError; + + /// Serializes this GlossaryModel to a JSON map. + Map toJson() => throw _privateConstructorUsedError; + + /// Create a copy of GlossaryModel + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $GlossaryModelCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $GlossaryModelCopyWith<$Res> { + factory $GlossaryModelCopyWith( + GlossaryModel value, $Res Function(GlossaryModel) then) = + _$GlossaryModelCopyWithImpl<$Res, GlossaryModel>; + @useResult + $Res call( + {int id, String name, @JsonKey(name: 'portion_mass_gr') int grInPortion}); +} + +/// @nodoc +class _$GlossaryModelCopyWithImpl<$Res, $Val extends GlossaryModel> + implements $GlossaryModelCopyWith<$Res> { + _$GlossaryModelCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of GlossaryModel + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? id = null, + Object? name = null, + Object? grInPortion = null, + }) { + return _then(_value.copyWith( + id: null == id + ? _value.id + : id // ignore: cast_nullable_to_non_nullable + as int, + name: null == name + ? _value.name + : name // ignore: cast_nullable_to_non_nullable + as String, + grInPortion: null == grInPortion + ? _value.grInPortion + : grInPortion // ignore: cast_nullable_to_non_nullable + as int, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$GlossaryModelImplCopyWith<$Res> + implements $GlossaryModelCopyWith<$Res> { + factory _$$GlossaryModelImplCopyWith( + _$GlossaryModelImpl value, $Res Function(_$GlossaryModelImpl) then) = + __$$GlossaryModelImplCopyWithImpl<$Res>; + @override + @useResult + $Res call( + {int id, String name, @JsonKey(name: 'portion_mass_gr') int grInPortion}); +} + +/// @nodoc +class __$$GlossaryModelImplCopyWithImpl<$Res> + extends _$GlossaryModelCopyWithImpl<$Res, _$GlossaryModelImpl> + implements _$$GlossaryModelImplCopyWith<$Res> { + __$$GlossaryModelImplCopyWithImpl( + _$GlossaryModelImpl _value, $Res Function(_$GlossaryModelImpl) _then) + : super(_value, _then); + + /// Create a copy of GlossaryModel + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? id = null, + Object? name = null, + Object? grInPortion = null, + }) { + return _then(_$GlossaryModelImpl( + id: null == id + ? _value.id + : id // ignore: cast_nullable_to_non_nullable + as int, + name: null == name + ? _value.name + : name // ignore: cast_nullable_to_non_nullable + as String, + grInPortion: null == grInPortion + ? _value.grInPortion + : grInPortion // ignore: cast_nullable_to_non_nullable + as int, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$GlossaryModelImpl implements _GlossaryModel { + const _$GlossaryModelImpl( + {required this.id, + required this.name, + @JsonKey(name: 'portion_mass_gr') required this.grInPortion}); + + factory _$GlossaryModelImpl.fromJson(Map json) => + _$$GlossaryModelImplFromJson(json); + + @override + final int id; + @override + final String name; + @override + @JsonKey(name: 'portion_mass_gr') + final int grInPortion; + + @override + String toString() { + return 'GlossaryModel(id: $id, name: $name, grInPortion: $grInPortion)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$GlossaryModelImpl && + (identical(other.id, id) || other.id == id) && + (identical(other.name, name) || other.name == name) && + (identical(other.grInPortion, grInPortion) || + other.grInPortion == grInPortion)); + } + + @JsonKey(includeFromJson: false, includeToJson: false) + @override + int get hashCode => Object.hash(runtimeType, id, name, grInPortion); + + /// Create a copy of GlossaryModel + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$GlossaryModelImplCopyWith<_$GlossaryModelImpl> get copyWith => + __$$GlossaryModelImplCopyWithImpl<_$GlossaryModelImpl>(this, _$identity); + + @override + Map toJson() { + return _$$GlossaryModelImplToJson( + this, + ); + } +} + +abstract class _GlossaryModel implements GlossaryModel { + const factory _GlossaryModel( + {required final int id, + required final String name, + @JsonKey(name: 'portion_mass_gr') required final int grInPortion}) = + _$GlossaryModelImpl; + + factory _GlossaryModel.fromJson(Map json) = + _$GlossaryModelImpl.fromJson; + + @override + int get id; + @override + String get name; + @override + @JsonKey(name: 'portion_mass_gr') + int get grInPortion; + + /// Create a copy of GlossaryModel + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + _$$GlossaryModelImplCopyWith<_$GlossaryModelImpl> get copyWith => + throw _privateConstructorUsedError; +} diff --git a/lib/features/glossary/models/glossary_model.g.dart b/lib/features/glossary/models/glossary_model.g.dart new file mode 100644 index 00000000..7fbd6b30 --- /dev/null +++ b/lib/features/glossary/models/glossary_model.g.dart @@ -0,0 +1,35 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'glossary_model.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +_$GlossaryPaginationModelImpl _$$GlossaryPaginationModelImplFromJson( + Map json) => + _$GlossaryPaginationModelImpl( + glossariesList: (json['data'] as List) + .map((e) => GlossaryModel.fromJson(e as Map)) + .toList(), + ); + +Map _$$GlossaryPaginationModelImplToJson( + _$GlossaryPaginationModelImpl instance) => + { + 'data': instance.glossariesList, + }; + +_$GlossaryModelImpl _$$GlossaryModelImplFromJson(Map json) => + _$GlossaryModelImpl( + id: (json['id'] as num).toInt(), + name: json['name'] as String, + grInPortion: (json['portion_mass_gr'] as num).toInt(), + ); + +Map _$$GlossaryModelImplToJson(_$GlossaryModelImpl instance) => + { + 'id': instance.id, + 'name': instance.name, + 'portion_mass_gr': instance.grInPortion, + }; diff --git a/lib/features/glossary/repositories/glossary_repository.dart b/lib/features/glossary/repositories/glossary_repository.dart new file mode 100644 index 00000000..c0c3233e --- /dev/null +++ b/lib/features/glossary/repositories/glossary_repository.dart @@ -0,0 +1,18 @@ +import 'package:eatvio_app/features/glossary/models/glossary_model.dart'; +import 'package:eatvio_app/features/glossary/services/glossary_service.dart'; + +class GlossaryRepository { + final GlossaryService glossaryService; + + GlossaryRepository({ + required this.glossaryService, + }); + + Future> getGlossaryListByQuery(String query) async { + try { + return (await glossaryService.getGlossaryByQuery(query: query)).glossariesList; + } catch (e) { + rethrow; + } + } +} diff --git a/lib/features/glossary/services/glossary_service.dart b/lib/features/glossary/services/glossary_service.dart new file mode 100644 index 00000000..8c28bb16 --- /dev/null +++ b/lib/features/glossary/services/glossary_service.dart @@ -0,0 +1,15 @@ +import 'package:dio/dio.dart'; +import 'package:eatvio_app/features/glossary/models/glossary_model.dart'; +import 'package:retrofit/retrofit.dart'; + +part 'glossary_service.g.dart'; + +@RestApi() +abstract class GlossaryService { + factory GlossaryService(Dio dio, {String baseUrl}) = _GlossaryService; + + @GET('/api/glossaries/search') + Future getGlossaryByQuery({ + @Query('search') required String query, + }); +} diff --git a/lib/features/glossary/services/glossary_service.g.dart b/lib/features/glossary/services/glossary_service.g.dart new file mode 100644 index 00000000..bd3a1137 --- /dev/null +++ b/lib/features/glossary/services/glossary_service.g.dart @@ -0,0 +1,87 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'glossary_service.dart'; + +// ************************************************************************** +// RetrofitGenerator +// ************************************************************************** + +// ignore_for_file: unnecessary_brace_in_string_interps,no_leading_underscores_for_local_identifiers,unused_element,unnecessary_string_interpolations + +class _GlossaryService implements GlossaryService { + _GlossaryService( + this._dio, { + this.baseUrl, + this.errorLogger, + }); + + final Dio _dio; + + String? baseUrl; + + final ParseErrorLogger? errorLogger; + + @override + Future getGlossaryByQuery( + {required String query}) async { + final _extra = {}; + final queryParameters = {r'search': query}; + final _headers = {}; + const Map? _data = null; + final _options = _setStreamType(Options( + method: 'GET', + headers: _headers, + extra: _extra, + ) + .compose( + _dio.options, + '/api/glossaries/search', + queryParameters: queryParameters, + data: _data, + ) + .copyWith( + baseUrl: _combineBaseUrls( + _dio.options.baseUrl, + baseUrl, + ))); + final _result = await _dio.fetch>(_options); + late GlossaryPaginationModel _value; + try { + _value = GlossaryPaginationModel.fromJson(_result.data!); + } on Object catch (e, s) { + errorLogger?.logError(e, s, _options); + rethrow; + } + return _value; + } + + RequestOptions _setStreamType(RequestOptions requestOptions) { + if (T != dynamic && + !(requestOptions.responseType == ResponseType.bytes || + requestOptions.responseType == ResponseType.stream)) { + if (T == String) { + requestOptions.responseType = ResponseType.plain; + } else { + requestOptions.responseType = ResponseType.json; + } + } + return requestOptions; + } + + String _combineBaseUrls( + String dioBaseUrl, + String? baseUrl, + ) { + if (baseUrl == null || baseUrl.trim().isEmpty) { + return dioBaseUrl; + } + + final url = Uri.parse(baseUrl); + + if (url.isAbsolute) { + return url.toString(); + } + + return Uri.parse(dioBaseUrl).resolveUri(url).toString(); + } +} diff --git a/lib/features/plans/services/plans_service.g.dart b/lib/features/plans/services/plans_service.g.dart index bce687f0..b0e19fb9 100644 --- a/lib/features/plans/services/plans_service.g.dart +++ b/lib/features/plans/services/plans_service.g.dart @@ -6,7 +6,7 @@ part of 'plans_service.dart'; // RetrofitGenerator // ************************************************************************** -// ignore_for_file: unnecessary_brace_in_string_interps,no_leading_underscores_for_local_identifiers,unused_element +// ignore_for_file: unnecessary_brace_in_string_interps,no_leading_underscores_for_local_identifiers,unused_element,unnecessary_string_interpolations class _PlansService implements PlansService { _PlansService( diff --git a/lib/features/profile/models/badge_model.dart b/lib/features/profile/models/badge_model.dart new file mode 100644 index 00000000..7ede65cc --- /dev/null +++ b/lib/features/profile/models/badge_model.dart @@ -0,0 +1,18 @@ +import 'package:freezed_annotation/freezed_annotation.dart'; + +part 'badge_model.freezed.dart'; + +part 'badge_model.g.dart'; + +@freezed +class BadgeModel with _$BadgeModel { + const factory BadgeModel({ + required int id, + required String title, + required String description, + required String image, + required String type, + }) = _BadgeModel; + + factory BadgeModel.fromJson(Map json) => _$BadgeModelFromJson(json); +} diff --git a/lib/features/profile/models/badge_model.freezed.dart b/lib/features/profile/models/badge_model.freezed.dart new file mode 100644 index 00000000..e71a7072 --- /dev/null +++ b/lib/features/profile/models/badge_model.freezed.dart @@ -0,0 +1,242 @@ +// 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 'badge_model.dart'; + +// ************************************************************************** +// FreezedGenerator +// ************************************************************************** + +T _$identity(T value) => value; + +final _privateConstructorUsedError = UnsupportedError( + 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models'); + +BadgeModel _$BadgeModelFromJson(Map json) { + return _BadgeModel.fromJson(json); +} + +/// @nodoc +mixin _$BadgeModel { + int get id => throw _privateConstructorUsedError; + String get title => throw _privateConstructorUsedError; + String get description => throw _privateConstructorUsedError; + String get image => throw _privateConstructorUsedError; + String get type => throw _privateConstructorUsedError; + + /// Serializes this BadgeModel to a JSON map. + Map toJson() => throw _privateConstructorUsedError; + + /// Create a copy of BadgeModel + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $BadgeModelCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $BadgeModelCopyWith<$Res> { + factory $BadgeModelCopyWith( + BadgeModel value, $Res Function(BadgeModel) then) = + _$BadgeModelCopyWithImpl<$Res, BadgeModel>; + @useResult + $Res call( + {int id, String title, String description, String image, String type}); +} + +/// @nodoc +class _$BadgeModelCopyWithImpl<$Res, $Val extends BadgeModel> + implements $BadgeModelCopyWith<$Res> { + _$BadgeModelCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of BadgeModel + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? id = null, + Object? title = null, + Object? description = null, + Object? image = null, + Object? type = null, + }) { + return _then(_value.copyWith( + id: null == 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, + description: null == description + ? _value.description + : description // ignore: cast_nullable_to_non_nullable + as String, + image: null == image + ? _value.image + : image // ignore: cast_nullable_to_non_nullable + as String, + type: null == type + ? _value.type + : type // ignore: cast_nullable_to_non_nullable + as String, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$BadgeModelImplCopyWith<$Res> + implements $BadgeModelCopyWith<$Res> { + factory _$$BadgeModelImplCopyWith( + _$BadgeModelImpl value, $Res Function(_$BadgeModelImpl) then) = + __$$BadgeModelImplCopyWithImpl<$Res>; + @override + @useResult + $Res call( + {int id, String title, String description, String image, String type}); +} + +/// @nodoc +class __$$BadgeModelImplCopyWithImpl<$Res> + extends _$BadgeModelCopyWithImpl<$Res, _$BadgeModelImpl> + implements _$$BadgeModelImplCopyWith<$Res> { + __$$BadgeModelImplCopyWithImpl( + _$BadgeModelImpl _value, $Res Function(_$BadgeModelImpl) _then) + : super(_value, _then); + + /// Create a copy of BadgeModel + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? id = null, + Object? title = null, + Object? description = null, + Object? image = null, + Object? type = null, + }) { + return _then(_$BadgeModelImpl( + id: null == 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, + description: null == description + ? _value.description + : description // ignore: cast_nullable_to_non_nullable + as String, + image: null == image + ? _value.image + : image // ignore: cast_nullable_to_non_nullable + as String, + type: null == type + ? _value.type + : type // ignore: cast_nullable_to_non_nullable + as String, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$BadgeModelImpl implements _BadgeModel { + const _$BadgeModelImpl( + {required this.id, + required this.title, + required this.description, + required this.image, + required this.type}); + + factory _$BadgeModelImpl.fromJson(Map json) => + _$$BadgeModelImplFromJson(json); + + @override + final int id; + @override + final String title; + @override + final String description; + @override + final String image; + @override + final String type; + + @override + String toString() { + return 'BadgeModel(id: $id, title: $title, description: $description, image: $image, type: $type)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$BadgeModelImpl && + (identical(other.id, id) || other.id == id) && + (identical(other.title, title) || other.title == title) && + (identical(other.description, description) || + other.description == description) && + (identical(other.image, image) || other.image == image) && + (identical(other.type, type) || other.type == type)); + } + + @JsonKey(includeFromJson: false, includeToJson: false) + @override + int get hashCode => + Object.hash(runtimeType, id, title, description, image, type); + + /// Create a copy of BadgeModel + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$BadgeModelImplCopyWith<_$BadgeModelImpl> get copyWith => + __$$BadgeModelImplCopyWithImpl<_$BadgeModelImpl>(this, _$identity); + + @override + Map toJson() { + return _$$BadgeModelImplToJson( + this, + ); + } +} + +abstract class _BadgeModel implements BadgeModel { + const factory _BadgeModel( + {required final int id, + required final String title, + required final String description, + required final String image, + required final String type}) = _$BadgeModelImpl; + + factory _BadgeModel.fromJson(Map json) = + _$BadgeModelImpl.fromJson; + + @override + int get id; + @override + String get title; + @override + String get description; + @override + String get image; + @override + String get type; + + /// Create a copy of BadgeModel + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + _$$BadgeModelImplCopyWith<_$BadgeModelImpl> get copyWith => + throw _privateConstructorUsedError; +} diff --git a/lib/features/profile/models/badge_model.g.dart b/lib/features/profile/models/badge_model.g.dart new file mode 100644 index 00000000..364faea5 --- /dev/null +++ b/lib/features/profile/models/badge_model.g.dart @@ -0,0 +1,25 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'badge_model.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +_$BadgeModelImpl _$$BadgeModelImplFromJson(Map json) => + _$BadgeModelImpl( + id: (json['id'] as num).toInt(), + title: json['title'] as String, + description: json['description'] as String, + image: json['image'] as String, + type: json['type'] as String, + ); + +Map _$$BadgeModelImplToJson(_$BadgeModelImpl instance) => + { + 'id': instance.id, + 'title': instance.title, + 'description': instance.description, + 'image': instance.image, + 'type': instance.type, + }; diff --git a/lib/features/profile/models/profile_model.dart b/lib/features/profile/models/profile_model.dart index 12580fea..075604fc 100644 --- a/lib/features/profile/models/profile_model.dart +++ b/lib/features/profile/models/profile_model.dart @@ -1,3 +1,4 @@ +import 'package:eatvio_app/features/profile/models/badge_model.dart'; import 'package:freezed_annotation/freezed_annotation.dart'; part 'profile_model.freezed.dart'; @@ -16,7 +17,10 @@ class ProfileModel with _$ProfileModel { @JsonKey(name: "is_public_profile") required bool isPublicProfile, @JsonKey(name: "slug") required String slug, @JsonKey(name: "profile_photo_url") required String profilePhotoUrl, - required String role, + @JsonKey(name: "role") required String role, + @JsonKey(name: "badges") required List badges, + @JsonKey(name: "subscriptions") required List subscriptions, + @JsonKey(name: "subscribers") required List subscribers, }) = _ProfileModel; factory ProfileModel.fromJson(Map json) => _$ProfileModelFromJson(json); @@ -56,3 +60,12 @@ class ProfileDetailsModel with _$ProfileDetailsModel { factory ProfileDetailsModel.fromJson(Map json) => _$ProfileDetailsModelFromJson(json); } + +@freezed +class ProfilePreviewModel with _$ProfilePreviewModel { + const factory ProfilePreviewModel({ + @JsonKey(name: "profile_photo_url") required String profilePhotoUrl, + }) = _ProfilePreviewModel; + + factory ProfilePreviewModel.fromJson(Map json) => _$ProfilePreviewModelFromJson(json); +} diff --git a/lib/features/profile/models/profile_model.freezed.dart b/lib/features/profile/models/profile_model.freezed.dart index 844e51af..862e19e6 100644 --- a/lib/features/profile/models/profile_model.freezed.dart +++ b/lib/features/profile/models/profile_model.freezed.dart @@ -38,7 +38,16 @@ mixin _$ProfileModel { String get slug => throw _privateConstructorUsedError; @JsonKey(name: "profile_photo_url") String get profilePhotoUrl => throw _privateConstructorUsedError; + @JsonKey(name: "role") String get role => throw _privateConstructorUsedError; + @JsonKey(name: "badges") + List get badges => throw _privateConstructorUsedError; + @JsonKey(name: "subscriptions") + List get subscriptions => + throw _privateConstructorUsedError; + @JsonKey(name: "subscribers") + List get subscribers => + throw _privateConstructorUsedError; /// Serializes this ProfileModel to a JSON map. Map toJson() => throw _privateConstructorUsedError; @@ -66,7 +75,10 @@ abstract class $ProfileModelCopyWith<$Res> { @JsonKey(name: "is_public_profile") bool isPublicProfile, @JsonKey(name: "slug") String slug, @JsonKey(name: "profile_photo_url") String profilePhotoUrl, - String role}); + @JsonKey(name: "role") String role, + @JsonKey(name: "badges") List badges, + @JsonKey(name: "subscriptions") List subscriptions, + @JsonKey(name: "subscribers") List subscribers}); } /// @nodoc @@ -94,6 +106,9 @@ class _$ProfileModelCopyWithImpl<$Res, $Val extends ProfileModel> Object? slug = null, Object? profilePhotoUrl = null, Object? role = null, + Object? badges = null, + Object? subscriptions = null, + Object? subscribers = null, }) { return _then(_value.copyWith( id: null == id @@ -136,6 +151,18 @@ class _$ProfileModelCopyWithImpl<$Res, $Val extends ProfileModel> ? _value.role : role // ignore: cast_nullable_to_non_nullable as String, + badges: null == badges + ? _value.badges + : badges // ignore: cast_nullable_to_non_nullable + as List, + subscriptions: null == subscriptions + ? _value.subscriptions + : subscriptions // ignore: cast_nullable_to_non_nullable + as List, + subscribers: null == subscribers + ? _value.subscribers + : subscribers // ignore: cast_nullable_to_non_nullable + as List, ) as $Val); } } @@ -158,7 +185,10 @@ abstract class _$$ProfileModelImplCopyWith<$Res> @JsonKey(name: "is_public_profile") bool isPublicProfile, @JsonKey(name: "slug") String slug, @JsonKey(name: "profile_photo_url") String profilePhotoUrl, - String role}); + @JsonKey(name: "role") String role, + @JsonKey(name: "badges") List badges, + @JsonKey(name: "subscriptions") List subscriptions, + @JsonKey(name: "subscribers") List subscribers}); } /// @nodoc @@ -184,6 +214,9 @@ class __$$ProfileModelImplCopyWithImpl<$Res> Object? slug = null, Object? profilePhotoUrl = null, Object? role = null, + Object? badges = null, + Object? subscriptions = null, + Object? subscribers = null, }) { return _then(_$ProfileModelImpl( id: null == id @@ -226,6 +259,18 @@ class __$$ProfileModelImplCopyWithImpl<$Res> ? _value.role : role // ignore: cast_nullable_to_non_nullable as String, + badges: null == badges + ? _value._badges + : badges // ignore: cast_nullable_to_non_nullable + as List, + subscriptions: null == subscriptions + ? _value._subscriptions + : subscriptions // ignore: cast_nullable_to_non_nullable + as List, + subscribers: null == subscribers + ? _value._subscribers + : subscribers // ignore: cast_nullable_to_non_nullable + as List, )); } } @@ -243,7 +288,15 @@ class _$ProfileModelImpl implements _ProfileModel { @JsonKey(name: "is_public_profile") required this.isPublicProfile, @JsonKey(name: "slug") required this.slug, @JsonKey(name: "profile_photo_url") required this.profilePhotoUrl, - required this.role}); + @JsonKey(name: "role") required this.role, + @JsonKey(name: "badges") required final List badges, + @JsonKey(name: "subscriptions") + required final List subscriptions, + @JsonKey(name: "subscribers") + required final List subscribers}) + : _badges = badges, + _subscriptions = subscriptions, + _subscribers = subscribers; factory _$ProfileModelImpl.fromJson(Map json) => _$$ProfileModelImplFromJson(json); @@ -276,11 +329,38 @@ class _$ProfileModelImpl implements _ProfileModel { @JsonKey(name: "profile_photo_url") final String profilePhotoUrl; @override + @JsonKey(name: "role") final String role; + final List _badges; + @override + @JsonKey(name: "badges") + List get badges { + if (_badges is EqualUnmodifiableListView) return _badges; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(_badges); + } + + final List _subscriptions; + @override + @JsonKey(name: "subscriptions") + List get subscriptions { + if (_subscriptions is EqualUnmodifiableListView) return _subscriptions; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(_subscriptions); + } + + final List _subscribers; + @override + @JsonKey(name: "subscribers") + List get subscribers { + if (_subscribers is EqualUnmodifiableListView) return _subscribers; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(_subscribers); + } @override String toString() { - return 'ProfileModel(id: $id, name: $name, email: $email, emailVerifiedAt: $emailVerifiedAt, createdAt: $createdAt, updatedAt: $updatedAt, isPublicProfile: $isPublicProfile, slug: $slug, profilePhotoUrl: $profilePhotoUrl, role: $role)'; + return 'ProfileModel(id: $id, name: $name, email: $email, emailVerifiedAt: $emailVerifiedAt, createdAt: $createdAt, updatedAt: $updatedAt, isPublicProfile: $isPublicProfile, slug: $slug, profilePhotoUrl: $profilePhotoUrl, role: $role, badges: $badges, subscriptions: $subscriptions, subscribers: $subscribers)'; } @override @@ -302,13 +382,31 @@ class _$ProfileModelImpl implements _ProfileModel { (identical(other.slug, slug) || other.slug == slug) && (identical(other.profilePhotoUrl, profilePhotoUrl) || other.profilePhotoUrl == profilePhotoUrl) && - (identical(other.role, role) || other.role == role)); + (identical(other.role, role) || other.role == role) && + const DeepCollectionEquality().equals(other._badges, _badges) && + const DeepCollectionEquality() + .equals(other._subscriptions, _subscriptions) && + const DeepCollectionEquality() + .equals(other._subscribers, _subscribers)); } @JsonKey(includeFromJson: false, includeToJson: false) @override - int get hashCode => Object.hash(runtimeType, id, name, email, emailVerifiedAt, - createdAt, updatedAt, isPublicProfile, slug, profilePhotoUrl, role); + int get hashCode => Object.hash( + runtimeType, + id, + name, + email, + emailVerifiedAt, + createdAt, + updatedAt, + isPublicProfile, + slug, + profilePhotoUrl, + role, + const DeepCollectionEquality().hash(_badges), + const DeepCollectionEquality().hash(_subscriptions), + const DeepCollectionEquality().hash(_subscribers)); /// Create a copy of ProfileModel /// with the given fields replaced by the non-null parameter values. @@ -337,7 +435,13 @@ abstract class _ProfileModel implements ProfileModel { @JsonKey(name: "is_public_profile") required final bool isPublicProfile, @JsonKey(name: "slug") required final String slug, @JsonKey(name: "profile_photo_url") required final String profilePhotoUrl, - required final String role}) = _$ProfileModelImpl; + @JsonKey(name: "role") required final String role, + @JsonKey(name: "badges") required final List badges, + @JsonKey(name: "subscriptions") + required final List subscriptions, + @JsonKey(name: "subscribers") + required final List + subscribers}) = _$ProfileModelImpl; factory _ProfileModel.fromJson(Map json) = _$ProfileModelImpl.fromJson; @@ -370,7 +474,17 @@ abstract class _ProfileModel implements ProfileModel { @JsonKey(name: "profile_photo_url") String get profilePhotoUrl; @override + @JsonKey(name: "role") String get role; + @override + @JsonKey(name: "badges") + List get badges; + @override + @JsonKey(name: "subscriptions") + List get subscriptions; + @override + @JsonKey(name: "subscribers") + List get subscribers; /// Create a copy of ProfileModel /// with the given fields replaced by the non-null parameter values. @@ -1190,3 +1304,160 @@ abstract class _ProfileDetailsModel implements ProfileDetailsModel { _$$ProfileDetailsModelImplCopyWith<_$ProfileDetailsModelImpl> get copyWith => throw _privateConstructorUsedError; } + +ProfilePreviewModel _$ProfilePreviewModelFromJson(Map json) { + return _ProfilePreviewModel.fromJson(json); +} + +/// @nodoc +mixin _$ProfilePreviewModel { + @JsonKey(name: "profile_photo_url") + String get profilePhotoUrl => throw _privateConstructorUsedError; + + /// Serializes this ProfilePreviewModel to a JSON map. + Map toJson() => throw _privateConstructorUsedError; + + /// Create a copy of ProfilePreviewModel + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $ProfilePreviewModelCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $ProfilePreviewModelCopyWith<$Res> { + factory $ProfilePreviewModelCopyWith( + ProfilePreviewModel value, $Res Function(ProfilePreviewModel) then) = + _$ProfilePreviewModelCopyWithImpl<$Res, ProfilePreviewModel>; + @useResult + $Res call({@JsonKey(name: "profile_photo_url") String profilePhotoUrl}); +} + +/// @nodoc +class _$ProfilePreviewModelCopyWithImpl<$Res, $Val extends ProfilePreviewModel> + implements $ProfilePreviewModelCopyWith<$Res> { + _$ProfilePreviewModelCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of ProfilePreviewModel + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? profilePhotoUrl = null, + }) { + return _then(_value.copyWith( + profilePhotoUrl: null == profilePhotoUrl + ? _value.profilePhotoUrl + : profilePhotoUrl // ignore: cast_nullable_to_non_nullable + as String, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$ProfilePreviewModelImplCopyWith<$Res> + implements $ProfilePreviewModelCopyWith<$Res> { + factory _$$ProfilePreviewModelImplCopyWith(_$ProfilePreviewModelImpl value, + $Res Function(_$ProfilePreviewModelImpl) then) = + __$$ProfilePreviewModelImplCopyWithImpl<$Res>; + @override + @useResult + $Res call({@JsonKey(name: "profile_photo_url") String profilePhotoUrl}); +} + +/// @nodoc +class __$$ProfilePreviewModelImplCopyWithImpl<$Res> + extends _$ProfilePreviewModelCopyWithImpl<$Res, _$ProfilePreviewModelImpl> + implements _$$ProfilePreviewModelImplCopyWith<$Res> { + __$$ProfilePreviewModelImplCopyWithImpl(_$ProfilePreviewModelImpl _value, + $Res Function(_$ProfilePreviewModelImpl) _then) + : super(_value, _then); + + /// Create a copy of ProfilePreviewModel + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? profilePhotoUrl = null, + }) { + return _then(_$ProfilePreviewModelImpl( + profilePhotoUrl: null == profilePhotoUrl + ? _value.profilePhotoUrl + : profilePhotoUrl // ignore: cast_nullable_to_non_nullable + as String, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$ProfilePreviewModelImpl implements _ProfilePreviewModel { + const _$ProfilePreviewModelImpl( + {@JsonKey(name: "profile_photo_url") required this.profilePhotoUrl}); + + factory _$ProfilePreviewModelImpl.fromJson(Map json) => + _$$ProfilePreviewModelImplFromJson(json); + + @override + @JsonKey(name: "profile_photo_url") + final String profilePhotoUrl; + + @override + String toString() { + return 'ProfilePreviewModel(profilePhotoUrl: $profilePhotoUrl)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$ProfilePreviewModelImpl && + (identical(other.profilePhotoUrl, profilePhotoUrl) || + other.profilePhotoUrl == profilePhotoUrl)); + } + + @JsonKey(includeFromJson: false, includeToJson: false) + @override + int get hashCode => Object.hash(runtimeType, profilePhotoUrl); + + /// Create a copy of ProfilePreviewModel + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$ProfilePreviewModelImplCopyWith<_$ProfilePreviewModelImpl> get copyWith => + __$$ProfilePreviewModelImplCopyWithImpl<_$ProfilePreviewModelImpl>( + this, _$identity); + + @override + Map toJson() { + return _$$ProfilePreviewModelImplToJson( + this, + ); + } +} + +abstract class _ProfilePreviewModel implements ProfilePreviewModel { + const factory _ProfilePreviewModel( + {@JsonKey(name: "profile_photo_url") + required final String profilePhotoUrl}) = _$ProfilePreviewModelImpl; + + factory _ProfilePreviewModel.fromJson(Map json) = + _$ProfilePreviewModelImpl.fromJson; + + @override + @JsonKey(name: "profile_photo_url") + String get profilePhotoUrl; + + /// Create a copy of ProfilePreviewModel + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + _$$ProfilePreviewModelImplCopyWith<_$ProfilePreviewModelImpl> get copyWith => + throw _privateConstructorUsedError; +} diff --git a/lib/features/profile/models/profile_model.g.dart b/lib/features/profile/models/profile_model.g.dart index 7a0c1876..aa2431ca 100644 --- a/lib/features/profile/models/profile_model.g.dart +++ b/lib/features/profile/models/profile_model.g.dart @@ -24,6 +24,15 @@ _$ProfileModelImpl _$$ProfileModelImplFromJson(Map json) => slug: json['slug'] as String, profilePhotoUrl: json['profile_photo_url'] as String, role: json['role'] as String, + badges: (json['badges'] as List) + .map((e) => BadgeModel.fromJson(e as Map)) + .toList(), + subscriptions: (json['subscriptions'] as List) + .map((e) => ProfilePreviewModel.fromJson(e as Map)) + .toList(), + subscribers: (json['subscribers'] as List) + .map((e) => ProfilePreviewModel.fromJson(e as Map)) + .toList(), ); Map _$$ProfileModelImplToJson(_$ProfileModelImpl instance) => @@ -38,6 +47,9 @@ Map _$$ProfileModelImplToJson(_$ProfileModelImpl instance) => 'slug': instance.slug, 'profile_photo_url': instance.profilePhotoUrl, 'role': instance.role, + 'badges': instance.badges, + 'subscriptions': instance.subscriptions, + 'subscribers': instance.subscribers, }; _$ProfileDetailsModelImpl _$$ProfileDetailsModelImplFromJson( @@ -107,3 +119,15 @@ Map _$$ProfileDetailsModelImplToJson( 'is_bedtime_fillable': instance.isBedtimeFillable, 'activity_coefficient': instance.activityCoefficient, }; + +_$ProfilePreviewModelImpl _$$ProfilePreviewModelImplFromJson( + Map json) => + _$ProfilePreviewModelImpl( + profilePhotoUrl: json['profile_photo_url'] as String, + ); + +Map _$$ProfilePreviewModelImplToJson( + _$ProfilePreviewModelImpl instance) => + { + 'profile_photo_url': instance.profilePhotoUrl, + }; diff --git a/lib/features/profile/presentation/bloc/profile_cubit/profile_cubit.dart b/lib/features/profile/presentation/bloc/profile_cubit/profile_cubit.dart index f6052a4b..409225e1 100644 --- a/lib/features/profile/presentation/bloc/profile_cubit/profile_cubit.dart +++ b/lib/features/profile/presentation/bloc/profile_cubit/profile_cubit.dart @@ -1,13 +1,16 @@ +import 'package:eatvio_app/features/chat/repositories/chat_repository.dart'; import 'package:eatvio_app/features/profile/presentation/bloc/profile_cubit/profile_state.dart'; import 'package:eatvio_app/features/profile/repositories/profile_repository.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; class ProfileCubit extends Cubit { final ProfileRepository profileRepository; + final ChatRepository chatRepository; String _currentPeriod = '1'; ProfileCubit({ required this.profileRepository, + required this.chatRepository, }) : super(const ProfileState.loading()); getProfileBySlug(String slug) async { @@ -19,7 +22,6 @@ class ProfileCubit extends Cubit { )); } catch (e) { emit(ProfileState.error(errorMessage: e.toString())); - print(e); } } @@ -38,7 +40,6 @@ class ProfileCubit extends Cubit { )); } catch (e) { emit(ProfileState.error(errorMessage: e.toString())); - print(e); } } @@ -56,7 +57,6 @@ class ProfileCubit extends Cubit { await getMyProfile(period: _currentPeriod); } catch (e) { emit(ProfileState.error(errorMessage: e.toString())); - print(e); } } @@ -68,7 +68,16 @@ class ProfileCubit extends Cubit { await getMyProfile(period: _currentPeriod); } catch (e) { emit(ProfileState.error(errorMessage: e.toString())); - print(e); + } + } + + Future getChatRoomIdBySlug({ + required String slug, + }) async { + try { + return (await chatRepository.getChatRoomIdByUserSlug(slug: slug)).id; + } catch (e) { + rethrow; } } } diff --git a/lib/features/profile/presentation/pages/profile_screen.dart b/lib/features/profile/presentation/pages/profile_screen.dart index b62c2ec4..b94f2f71 100644 --- a/lib/features/profile/presentation/pages/profile_screen.dart +++ b/lib/features/profile/presentation/pages/profile_screen.dart @@ -1,3 +1,4 @@ +import 'package:cached_network_image/cached_network_image.dart'; import 'package:eatvio_app/core/const.dart'; import 'package:eatvio_app/features/feed/models/diets_pagination_model.dart'; import 'package:eatvio_app/features/feed/presentation/widgets/blog_post_widget.dart'; @@ -12,29 +13,32 @@ import 'package:eatvio_app/locator_service.dart'; import 'package:eatvio_app/theme/theme_helper.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; -import 'package:flutter_svg/flutter_svg.dart'; import 'package:go_router/go_router.dart'; import 'package:rive/rive.dart'; -import 'package:share_plus/share_plus.dart'; +import 'package:flutter_svg/flutter_svg.dart'; class ProfileScreen extends StatefulWidget { final Author? author; - const ProfileScreen({super.key, this.author}); + const ProfileScreen({ + super.key, + this.author, + }); @override State createState() => _ProfileScreenState(); } class _ProfileScreenState extends State { - List circumferencePoints = []; - List weightPoints = []; + final ProfileCubit profileCubit = sl(); final List chipsLabelList = ['Вес', 'Замеры', 'ИМТ']; final List chipsIntervalLabelList = ['1М', '3М', '6М', '1Г', 'ВСЁ ВРЕМЯ']; final List chipsIntervalList = ['1', '3', '6', '12', 'all']; + + List weightPoints = []; + List circumferencePoints = []; int _selectedChipIndex = 0; int _selectedIntervalChipIndex = 0; - final ProfileCubit profileCubit = sl(); @override void initState() { @@ -52,228 +56,7 @@ class _ProfileScreenState extends State { circumferencePoints = state.circumferencePoints!; weightPoints = state.weightPoints!; } - return Scaffold( - backgroundColor: Colors.grey.shade200, - appBar: widget.author == null ? AppBar(toolbarHeight: 0) : AppBar(), - body: SingleChildScrollView( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Container( - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.vertical( - bottom: Radius.circular(16), - ), - ), - child: Column( - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Padding( - padding: const EdgeInsets.all(16), - child: Row( - children: [ - CircleAvatar( - radius: 32, - backgroundImage: NetworkImage(state.profile.profilePhotoUrl), - ), - const SizedBox(width: 12), - Text( - state.profile.name, - style: TextStyle( - color: Colors.black, - fontWeight: FontWeight.w500, - height: 1, - ), - ), - const Spacer(), - Row( - mainAxisAlignment: MainAxisAlignment.end, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Container( - child: SvgPicture.asset( - height: 28, - width: 28, - 'assets/icons/subscribers.svg', - colorFilter: ColorFilter.mode(appTheme.blueA400, BlendMode.srcIn), - ), - ), - SizedBox(width: 8), - Column( - children: [ - Text( - '123', - style: TextStyle( - height: 1, - fontSize: 18, - fontWeight: FontWeight.w500, - color: Colors.black87, - ), - ), - Text( - 'Подписчика', - style: TextStyle( - height: 1, - fontSize: 12, - fontWeight: FontWeight.w400, - color: Colors.black38, - ), - ), - ], - ), - ], - ), - GestureDetector( - onTap: () => Share.shareUri( - Uri.parse( - baseUrl + '/ru/profile/' + state.profile.slug, - ), - ), - child: Container( - padding: EdgeInsets.only(left: 16), - child: SvgPicture.asset( - height: 24, - width: 24, - 'assets/icons/share.svg', - colorFilter: ColorFilter.mode(appTheme.blueA400, BlendMode.srcIn), - ), - ), - ), - ], - ), - ), - if (state.profileDetails.additionalInfo.isNotEmpty) - Container( - alignment: Alignment.centerLeft, - padding: const EdgeInsets.all(16), - child: Text( - state.profileDetails.additionalInfo, - style: TextStyle( - color: Colors.black.withOpacity(0.4), - height: 1, - ), - ), - ), - if (widget.author != null) const SizedBox(height: 8), - if (widget.author != null) - Row( - children: [ - SizedBox(width: 16), - GestureDetector( - onTap: () => GoRouter.of(context).pushNamed( - 'chatScreen', - ), - child: Container( - alignment: Alignment.center, - padding: EdgeInsets.all(8), - width: (MediaQuery.of(context).size.width - 40) / 2, - decoration: BoxDecoration( - color: appTheme.blueA400.withOpacity(0.1), - borderRadius: BorderRadius.circular(16), - ), - child: Text( - 'Сообщение', - style: TextStyle( - color: appTheme.blueA400, - ), - ), - ), - ), - SizedBox(width: 8), - Container( - alignment: Alignment.center, - padding: EdgeInsets.all(8), - width: (MediaQuery.of(context).size.width - 40) / 2, - decoration: BoxDecoration( - color: appTheme.blueA400, - borderRadius: BorderRadius.circular(16), - ), - child: Text( - 'Подписаться', - style: TextStyle( - color: Colors.white, - ), - ), - ), - SizedBox(width: 16), - ], - ), - if (widget.author != null) SizedBox(height: 16), - if (widget.author == null) _divider(context), - if (widget.author == null) - Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - const SizedBox(height: 8), - SingleChildScrollView( - padding: EdgeInsets.symmetric(horizontal: 16), - scrollDirection: Axis.horizontal, - child: Row( - children: [ - _choiceChipWidget(0), - SizedBox(width: 8), - _choiceChipWidget(1), - SizedBox(width: 8), - _choiceChipWidget(2), - ], - ), - ), - Builder( - builder: (context) { - switch (_selectedChipIndex) { - case 0: - return WeightChartWidget( - weightPoints: weightPoints, - profileCubit: profileCubit, - ); - case 1: - return CircumferenceChartWidget( - circumferencePoints: circumferencePoints, - profileCubit: profileCubit, - ); - case 2: - return ImtChartWidget( - weightPoints: weightPoints, - ); - } - return SizedBox.shrink(); - }, - ), - SizedBox(height: 8), - Row( - children: [ - SizedBox(width: 16), - _choiceIntervalChipWidget(0), - SizedBox(width: 8), - _choiceIntervalChipWidget(1), - SizedBox(width: 8), - _choiceIntervalChipWidget(2), - SizedBox(width: 8), - _choiceIntervalChipWidget(3), - SizedBox(width: 8), - _choiceIntervalChipWidget(4), - ], - ), - SizedBox(height: 8), - ], - ), - ], - ), - ), - SizedBox(height: 16), - ListView.separated( - shrinkWrap: true, - physics: const NeverScrollableScrollPhysics(), - itemBuilder: (context, index) => BlogPostWidget(feedBlogPostModel: state.blogPosts[index]), - separatorBuilder: (context, index) => SizedBox(height: 8), - itemCount: state.blogPosts.length, - ), - SizedBox(height: 16), - ], - ), - ), - ); + return _profileScreen(state); } else if (state is ProfileStateError) { return Scaffold( appBar: AppBar(), @@ -302,13 +85,733 @@ class _ProfileScreenState extends State { ); } - _divider(BuildContext context) { + _profileScreen(ProfileStateLoaded state) { + return Scaffold( + backgroundColor: Colors.grey.shade200, + appBar: widget.author == null ? AppBar(toolbarHeight: 0) : AppBar(), + body: SingleChildScrollView( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.vertical( + bottom: Radius.circular(16), + ), + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + _header(state), + if (state.profileDetails.additionalInfo.isNotEmpty) _additionalInfo(state), + if (widget.author != null) const SizedBox(height: 8), + if (widget.author != null) _messageAndSubscribe(), + if (widget.author != null) const SizedBox(height: 16), + ], + ), + ), + _subscriptionsAndSubscribers(state), + _badges(state), + if (widget.author == null) const SizedBox(height: 16), + _socialLinks(state), + if (widget.author == null) const SizedBox(height: 16), + _education(state), + if (widget.author == null) const SizedBox(height: 16), + _diplomasAndCertificates(state), + if (widget.author == null) const SizedBox(height: 16), + if (widget.author == null) _charts(), + if (widget.author == null) const SizedBox(height: 16), + _activePlans(state), + if (widget.author == null) const SizedBox(height: 16), + _newBlogPostButton(), + _blogPosts(state), + ], + ), + ), + ); + } + + _activePlans(ProfileStateLoaded state) { + if (state.profile.role != 'consultant') { + return const SizedBox.shrink(); + } + return Column( + children: [ + Padding( + padding: const EdgeInsets.symmetric(horizontal: 16), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + 'Активные планы', + style: TextStyle( + color: Color(0xFF323F4B), + fontSize: 24, + height: 1, + fontWeight: FontWeight.w600, + ), + ), + Text( + widget.author == null ? 'Редактировать' : 'Показать все', + style: TextStyle( + color: Color(0xFF2F80ED), + fontSize: 16, + fontWeight: FontWeight.w500, + ), + ), + ], + ), + ), + const SizedBox(height: 8), + _bullets(0, 4), + ], + ); + } + + _bullets(int currentBullet, int bulletCount) { return Container( - height: 0.4, - width: MediaQuery.of(context).size.width - 32, + padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 8), decoration: BoxDecoration( - color: Colors.black26, - borderRadius: BorderRadius.circular(16), + color: Colors.white, + borderRadius: BorderRadius.circular(20), + ), + child: Row( + mainAxisSize: MainAxisSize.min, + children: [ + for (int i = 0; i < bulletCount; i++) ...[ + _bullet(i == currentBullet), + i < bulletCount - 1 ? const SizedBox(width: 4) : const SizedBox.shrink(), + ], + ], + ), + ); + } + + _bullet(bool isActive) { + return AnimatedContainer( + width: isActive ? 10 : 8, + height: isActive ? 10 : 8, + duration: Duration(milliseconds: 150), + decoration: BoxDecoration( + color: isActive ? appTheme.blueA400 : Color(0xFFD7D9DC), + shape: BoxShape.circle, + ), + ); + } + + _newBlogPostButton() { + return Padding( + padding: const EdgeInsets.symmetric(horizontal: 4), + child: Material( + color: Colors.white, + borderRadius: BorderRadius.circular(12), + child: Padding( + padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8), + child: InkWell( + onTap: () { + GoRouter.of(context).pushNamed('blogPostCreateScreen'); + }, + borderRadius: BorderRadius.circular(8), + child: Ink( + padding: EdgeInsets.all(12), + decoration: BoxDecoration( + color: Color(0xFFF6FAFF), + borderRadius: BorderRadius.circular(8), + ), + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Icon( + Icons.add_circle_outline_rounded, + color: Color(0xFF2F80ED), + ), + const SizedBox(width: 12), + Text( + 'Новая запись', + style: TextStyle( + fontSize: 18, + fontWeight: FontWeight.w600, + color: Color(0xFF2F80ED), + ), + ), + ], + ), + ), + ), + ), + ), + ); + } + + _diplomasAndCertificates(ProfileStateLoaded state) { + if (state.profile.role != 'consultant') { + return const SizedBox.shrink(); + } + return Column( + children: [ + Padding( + padding: const EdgeInsets.symmetric(horizontal: 16), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + 'Дипломы\nи сертификаты', + style: TextStyle( + color: Color(0xFF323F4B), + fontSize: 24, + height: 1, + fontWeight: FontWeight.w600, + ), + ), + Text( + widget.author == null ? 'Редактировать' : 'Показать все', + style: TextStyle( + color: Color(0xFF2F80ED), + fontSize: 16, + fontWeight: FontWeight.w500, + ), + ), + ], + ), + ), + const SizedBox(height: 8), + Container( + width: MediaQuery.of(context).size.width - 2, + padding: const EdgeInsets.symmetric(horizontal: 4), + child: Material( + color: Colors.white, + borderRadius: BorderRadius.circular(12), + child: SingleChildScrollView( + physics: const BouncingScrollPhysics(), + scrollDirection: Axis.horizontal, + padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12), + child: Row( + children: [ + _diplomaImage( + state.profile.profilePhotoUrl, + ), + const SizedBox(width: 8), + _diplomaImage( + state.profile.profilePhotoUrl, + ), + const SizedBox(width: 8), + _diplomaImage( + state.profile.profilePhotoUrl, + ), + const SizedBox(width: 8), + _diplomaImage( + state.profile.profilePhotoUrl, + ), + ], + ), + ), + ), + ), + ], + ); + } + + _diplomaImage(String url) { + return ClipRRect( + borderRadius: BorderRadius.circular(8), + child: CachedNetworkImage( + imageUrl: url, + fit: BoxFit.fitHeight, + width: MediaQuery.of(context).size.width / 3 - (60 / 3), + height: 160, + ), + ); + } + + _education(ProfileStateLoaded state) { + if (state.profile.role != 'consultant') { + return const SizedBox.shrink(); + } + return Column( + children: [ + Padding( + padding: const EdgeInsets.symmetric(horizontal: 16), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + 'Образование', + style: TextStyle( + color: Color(0xFF323F4B), + fontSize: 24, + fontWeight: FontWeight.w600, + ), + ), + Text( + widget.author == null ? 'Редактировать' : 'Показать все', + style: TextStyle( + color: Color(0xFF2F80ED), + fontSize: 16, + fontWeight: FontWeight.w500, + ), + ), + ], + ), + ), + const SizedBox(height: 8), + Padding( + padding: const EdgeInsets.symmetric(horizontal: 4), + child: Material( + color: Colors.white, + borderRadius: BorderRadius.circular(12), + child: Padding( + padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12), + child: Column( + children: [ + _educationBlock( + 'Наименование диплома или сертификата в 2 строки', + '30.01.2020', + ), + ], + ), + ), + ), + ), + ], + ); + } + + _educationBlock(String title, String date) { + return Material( + color: Color(0xFFF6FAFF), + borderRadius: BorderRadius.circular(12), + child: Padding( + padding: const EdgeInsets.all(12), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + title, + style: TextStyle( + height: 1, + color: Color(0xFF323F4B), + fontWeight: FontWeight.w500, + fontSize: 16, + ), + ), + const SizedBox(height: 4), + Text( + date, + style: TextStyle( + height: 1, + color: Color(0xFF6D6F71), + fontWeight: FontWeight.w500, + fontSize: 14, + ), + ), + ], + ), + ), + ); + } + + _socialLinks(ProfileStateLoaded state) { + if (state.profile.role != 'consultant') { + return const SizedBox.shrink(); + } + return Padding( + padding: const EdgeInsets.symmetric(horizontal: 4), + child: Material( + color: Colors.white, + borderRadius: BorderRadius.circular(12), + child: Padding( + padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 8), + child: Row( + children: [ + _socialLinkButton(() {}, 'assets/icons/vk.svg'), + const SizedBox(width: 12), + _socialLinkButton(() {}, 'assets/icons/telegram.svg'), + const SizedBox(width: 12), + _socialLinkButton(() {}, 'assets/icons/web.svg'), + ], + ), + ), + ), + ); + } + + _socialLinkButton(Function() onTap, String icon) { + return InkWell( + onTap: onTap, + borderRadius: BorderRadius.circular(20), + child: Ink( + width: MediaQuery.of(context).size.width / 3 - (56 / 3), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(20), + color: Color(0xFFF6F6F6), + ), + child: Padding( + padding: const EdgeInsets.symmetric(horizontal: 40, vertical: 16), + child: SvgPicture.asset( + icon, + width: 24, + ), + ), + ), + ); + } + + _badges(ProfileStateLoaded state) { + return Padding( + padding: const EdgeInsets.symmetric(horizontal: 4), + child: InkWell( + onTap: () {}, + borderRadius: BorderRadius.circular(12), + child: Ink( + padding: const EdgeInsets.all(8), + width: MediaQuery.of(context).size.width, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + 'Достижения', + style: TextStyle( + color: Color(0xFF6D6F71), + fontSize: 14, + fontWeight: FontWeight.w600, + ), + ), + const SizedBox(height: 8), + SingleChildScrollView( + scrollDirection: Axis.horizontal, + child: Row( + children: [ + for (int i = 0; i < state.profile.badges.length; i++) ...[ + state.profile.badges[i].image.contains('svg') + ? SvgPicture.network( + baseUrl + '/storage/' + state.profile.badges[i].image, + width: 40, + height: 40, + ) + : CachedNetworkImage( + imageUrl: baseUrl + '/storage/' + state.profile.badges[i].image, + ), + i < state.profile.badges.length - 1 ? const SizedBox(width: 8) : const SizedBox.shrink(), + ], + ], + ), + ), + ], + ), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(12), + color: Colors.white, + ), + ), + ), + ); + } + + _subscriptionsAndSubscribers(ProfileStateLoaded state) { + return Padding( + padding: const EdgeInsets.all(4), + child: Row( + children: [ + InkWell( + onTap: () {}, + borderRadius: BorderRadius.circular(12), + child: Ink( + padding: const EdgeInsets.all(8), + width: MediaQuery.of(context).size.width / 2 - 6, + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.end, + children: [ + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + 'Подписки', + style: TextStyle( + color: Color(0xFF6D6F71), + fontSize: 14, + fontWeight: FontWeight.w600, + ), + ), + Text( + '${state.profile.subscriptions.length}', + style: TextStyle( + color: Color(0xFF323F4B), + fontSize: 22, + fontWeight: FontWeight.w700, + ), + ), + ], + ), + Padding( + padding: EdgeInsets.only(right: 8), + child: _miniAvatars(state.profile.subscriptions.map((e) => e.profilePhotoUrl).toList()), + ), + ], + ), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(12), + color: Colors.white, + ), + ), + ), + SizedBox(width: 4), + InkWell( + onTap: () {}, + borderRadius: BorderRadius.circular(12), + child: Ink( + padding: const EdgeInsets.all(8), + width: MediaQuery.of(context).size.width / 2 - 6, + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.end, + children: [ + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + 'Подписчики', + style: TextStyle( + color: Color(0xFF6D6F71), + fontSize: 14, + fontWeight: FontWeight.w600, + ), + ), + Text( + '${state.profile.subscribers.length}', + style: TextStyle( + color: Color(0xFF323F4B), + fontSize: 22, + fontWeight: FontWeight.w700, + ), + ), + ], + ), + Padding( + padding: EdgeInsets.only(right: 8), + child: _miniAvatars(state.profile.subscribers.map((e) => e.profilePhotoUrl).toList()), + ), + ], + ), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(12), + color: Colors.white, + ), + ), + ), + ], + ), + ); + } + + _miniAvatars(List urls) { + int maxLength = urls.length > 2 ? 3 : urls.length; + return Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + for (int i = 0; i < maxLength; i++) + Align( + widthFactor: 0.8, + child: CircleAvatar( + radius: 14, + backgroundImage: NetworkImage( + urls[i], + ), + ), + ), + ], + ); + } + + _blogPosts(ProfileStateLoaded state) { + return ListView.separated( + padding: EdgeInsets.symmetric(vertical: 16), + shrinkWrap: true, + physics: const NeverScrollableScrollPhysics(), + itemBuilder: (context, index) => BlogPostWidget( + feedBlogPostModel: state.blogPosts[index], + ), + separatorBuilder: (context, index) => SizedBox(height: 8), + itemCount: state.blogPosts.length, + ); + } + + _additionalInfo(ProfileStateLoaded state) { + String text = state.profileDetails.additionalInfo; + if (state.profileDetails.additionalInfo.length > 250) { + text = state.profileDetails.additionalInfo.substring(0, 250); + } + return Container( + alignment: Alignment.centerLeft, + padding: const EdgeInsets.all(16), + child: Text( + text, + style: TextStyle( + color: Colors.black.withOpacity(0.4), + height: 1, + ), + ), + ); + } + + _header(ProfileStateLoaded state) { + return Padding( + padding: const EdgeInsets.all(16), + child: Row( + children: [ + CircleAvatar( + radius: 32, + backgroundImage: NetworkImage(state.profile.profilePhotoUrl), + ), + const SizedBox(width: 12), + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + state.profile.name, + style: TextStyle( + color: Colors.black, + fontWeight: FontWeight.w500, + height: 1, + ), + ), + const SizedBox(height: 8), + Row( + children: [ + Icon( + Icons.info_outline, + size: 20, + color: Color(0xFF6D6F71), + ), + const SizedBox(width: 4), + Text( + 'Дополнительно', + style: TextStyle( + color: Color(0xFF6D6F71), + ), + ), + ], + ), + ], + ), + const Spacer(), + IconButton( + onPressed: () {}, + icon: Icon(Icons.more_horiz_rounded), + ), + ], + ), + ); + } + + _messageAndSubscribe() { + return Row( + children: [ + SizedBox(width: 16), + GestureDetector( + onTap: () async { + GoRouter.of(context).pushNamed( + 'chatScreen', + extra: await profileCubit.getChatRoomIdBySlug(slug: widget.author!.authorSlug), + ); + }, + child: Container( + alignment: Alignment.center, + padding: EdgeInsets.all(8), + width: (MediaQuery.of(context).size.width - 40) / 2, + decoration: BoxDecoration( + color: appTheme.blueA400.withOpacity(0.1), + borderRadius: BorderRadius.circular(16), + ), + child: Text( + 'Сообщение', + style: TextStyle( + color: appTheme.blueA400, + ), + ), + ), + ), + SizedBox(width: 8), + Container( + alignment: Alignment.center, + padding: EdgeInsets.all(8), + width: (MediaQuery.of(context).size.width - 40) / 2, + decoration: BoxDecoration( + color: appTheme.blueA400, + borderRadius: BorderRadius.circular(16), + ), + child: Text( + 'Подписаться', + style: TextStyle( + color: Colors.white, + ), + ), + ), + SizedBox(width: 16), + ], + ); + } + + _charts() { + return Material( + color: Colors.white, + borderRadius: BorderRadius.circular(16), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + const SizedBox(height: 8), + SingleChildScrollView( + padding: EdgeInsets.symmetric(horizontal: 16), + scrollDirection: Axis.horizontal, + child: Row( + children: [ + _choiceChipWidget(0), + SizedBox(width: 8), + _choiceChipWidget(1), + SizedBox(width: 8), + _choiceChipWidget(2), + ], + ), + ), + Builder( + builder: (context) { + switch (_selectedChipIndex) { + case 0: + return WeightChartWidget( + weightPoints: weightPoints, + profileCubit: profileCubit, + ); + case 1: + return CircumferenceChartWidget( + circumferencePoints: circumferencePoints, + profileCubit: profileCubit, + ); + case 2: + return ImtChartWidget( + weightPoints: weightPoints, + ); + } + return SizedBox.shrink(); + }, + ), + SizedBox(height: 8), + Row( + children: [ + SizedBox(width: 16), + _choiceIntervalChipWidget(0), + SizedBox(width: 8), + _choiceIntervalChipWidget(1), + SizedBox(width: 8), + _choiceIntervalChipWidget(2), + SizedBox(width: 8), + _choiceIntervalChipWidget(3), + SizedBox(width: 8), + _choiceIntervalChipWidget(4), + ], + ), + SizedBox(height: 8), + ], ), ); } diff --git a/lib/features/profile/repositories/profile_repository.dart b/lib/features/profile/repositories/profile_repository.dart index 2e927ca0..58b31442 100644 --- a/lib/features/profile/repositories/profile_repository.dart +++ b/lib/features/profile/repositories/profile_repository.dart @@ -65,8 +65,7 @@ class ProfileRepository { try { return (await profileService.getBlogPostByAuthorSlug( slug: slug, - )) - .feedBlogPostList; + )); } catch (e) { rethrow; } diff --git a/lib/features/profile/services/profile_service.dart b/lib/features/profile/services/profile_service.dart index f5490213..f092cc4f 100644 --- a/lib/features/profile/services/profile_service.dart +++ b/lib/features/profile/services/profile_service.dart @@ -1,10 +1,9 @@ import 'package:dio/dio.dart'; -import 'package:eatvio_app/features/feed/models/feed_blog_post_settings_model.dart'; +import 'package:eatvio_app/features/feed/models/feed_blog_post_model.dart'; import 'package:eatvio_app/features/profile/models/circumference_model.dart'; import 'package:eatvio_app/features/profile/models/profile_model.dart'; import 'package:eatvio_app/features/profile/models/weight_model.dart'; import 'package:retrofit/retrofit.dart'; - part 'profile_service.g.dart'; @RestApi() @@ -35,7 +34,7 @@ abstract class ProfileService { }); @GET('/api/blogPosts/search_by_author/{slug}') - Future getBlogPostByAuthorSlug({ + Future> getBlogPostByAuthorSlug({ @Path() required String slug, }); diff --git a/lib/features/profile/services/profile_service.g.dart b/lib/features/profile/services/profile_service.g.dart index 36b64eb3..274c84b8 100644 --- a/lib/features/profile/services/profile_service.g.dart +++ b/lib/features/profile/services/profile_service.g.dart @@ -6,7 +6,7 @@ part of 'profile_service.dart'; // RetrofitGenerator // ************************************************************************** -// ignore_for_file: unnecessary_brace_in_string_interps,no_leading_underscores_for_local_identifiers,unused_element +// ignore_for_file: unnecessary_brace_in_string_interps,no_leading_underscores_for_local_identifiers,unused_element,unnecessary_string_interpolations class _ProfileService implements ProfileService { _ProfileService( @@ -191,13 +191,13 @@ class _ProfileService implements ProfileService { } @override - Future getBlogPostByAuthorSlug( + Future> getBlogPostByAuthorSlug( {required String slug}) async { final _extra = {}; final queryParameters = {}; final _headers = {}; const Map? _data = null; - final _options = _setStreamType(Options( + final _options = _setStreamType>(Options( method: 'GET', headers: _headers, extra: _extra, @@ -213,10 +213,13 @@ class _ProfileService implements ProfileService { _dio.options.baseUrl, baseUrl, ))); - final _result = await _dio.fetch>(_options); - late FeedBlogPostSettingsModel _value; + final _result = await _dio.fetch>(_options); + late List _value; try { - _value = FeedBlogPostSettingsModel.fromJson(_result.data!); + _value = _result.data! + .map((dynamic i) => + FeedBlogPostModel.fromJson(i as Map)) + .toList(); } on Object catch (e, s) { errorLogger?.logError(e, s, _options); rethrow; diff --git a/lib/features/diary/models/product.dart b/lib/features/recipes/models/product.dart similarity index 100% rename from lib/features/diary/models/product.dart rename to lib/features/recipes/models/product.dart diff --git a/lib/features/diary/models/product.freezed.dart b/lib/features/recipes/models/product.freezed.dart similarity index 100% rename from lib/features/diary/models/product.freezed.dart rename to lib/features/recipes/models/product.freezed.dart diff --git a/lib/features/diary/models/product.g.dart b/lib/features/recipes/models/product.g.dart similarity index 100% rename from lib/features/diary/models/product.g.dart rename to lib/features/recipes/models/product.g.dart diff --git a/lib/features/recipes/presentation/bloc/recipe_create_cubit.dart b/lib/features/recipes/presentation/bloc/recipe_create_cubit.dart index 727317bc..aad1afb4 100644 --- a/lib/features/recipes/presentation/bloc/recipe_create_cubit.dart +++ b/lib/features/recipes/presentation/bloc/recipe_create_cubit.dart @@ -3,7 +3,7 @@ import 'package:eatvio_app/features/recipes/models/ingredient.dart'; import 'package:eatvio_app/features/recipes/models/recipe_model.dart'; import 'package:eatvio_app/features/recipes/presentation/bloc/recipe_create_state.dart'; import 'package:eatvio_app/features/recipes/reporitories/recipe_repository.dart'; -import 'package:eatvio_app/features/diary/models/product.dart'; +import 'package:eatvio_app/features/recipes/models/product.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:image_picker/image_picker.dart'; @@ -258,7 +258,7 @@ class RecipeCreateCubit extends Cubit { var currentState = state as RecipeCreateStateLoaded; final Map> productNutritionalValues = await recipeRepository.inputProduct(input); - print(productNutritionalValues); + var updatedState = currentState.copyWith( productNameController: TextEditingController(text: input), autocompleteList: productNutritionalValues['product_nutritional_value'] ?? [], diff --git a/lib/features/recipes/presentation/bloc/recipe_create_state.dart b/lib/features/recipes/presentation/bloc/recipe_create_state.dart index 8bb6051a..76f9aba0 100644 --- a/lib/features/recipes/presentation/bloc/recipe_create_state.dart +++ b/lib/features/recipes/presentation/bloc/recipe_create_state.dart @@ -1,6 +1,6 @@ import 'package:eatvio_app/features/recipes/models/recipe_model.dart'; import 'package:eatvio_app/features/recipes/models/ingredient.dart'; -import 'package:eatvio_app/features/diary/models/product.dart'; +import 'package:eatvio_app/features/recipes/models/product.dart'; import 'package:flutter/material.dart'; import 'package:freezed_annotation/freezed_annotation.dart'; import 'package:image_picker/image_picker.dart'; diff --git a/lib/features/recipes/presentation/pages/recipe_create_screen.dart b/lib/features/recipes/presentation/pages/recipe_create_screen.dart index eb1339b4..2398edc9 100644 --- a/lib/features/recipes/presentation/pages/recipe_create_screen.dart +++ b/lib/features/recipes/presentation/pages/recipe_create_screen.dart @@ -1,7 +1,5 @@ -import 'dart:convert'; import 'dart:io'; - -import 'package:eatvio_app/features/diary/models/product.dart'; +import 'package:eatvio_app/features/recipes/models/product.dart'; import 'package:eatvio_app/features/recipes/models/ingredient.dart'; import 'package:eatvio_app/features/recipes/models/recipe_model.dart'; import 'package:eatvio_app/features/recipes/models/step.dart' as step; @@ -512,7 +510,7 @@ class RecipeCreateScreen extends StatelessWidget { image: state.recipeImage?.path, video_url: state.youtubeLinkController.text.isNotEmpty ? state.youtubeLinkController.text : null, ); - print(jsonDecode(jsonEncode(recipe))); + return recipe; } } diff --git a/lib/features/recipes/presentation/pages/recipe_edit_screen.dart b/lib/features/recipes/presentation/pages/recipe_edit_screen.dart index dc435059..d1f1c7fc 100644 --- a/lib/features/recipes/presentation/pages/recipe_edit_screen.dart +++ b/lib/features/recipes/presentation/pages/recipe_edit_screen.dart @@ -1,5 +1,5 @@ import 'package:eatvio_app/core/const.dart'; -import 'package:eatvio_app/features/diary/models/product.dart'; +import 'package:eatvio_app/features/recipes/models/product.dart'; import 'package:eatvio_app/features/recipes/models/ingredient.dart'; import 'package:eatvio_app/features/recipes/models/recipe_model.dart'; import 'package:eatvio_app/features/recipes/models/step.dart' as step; @@ -354,7 +354,6 @@ class RecipeEditScreen extends StatelessWidget { } _buildStep(BuildContext context, int stepNumber, RecipeCreateStateLoaded state) { - print(baseUrl + '/storage/' + state.stepImages[stepNumber]!.path); return Column( children: [ Row(children: [Text('Шаг ${stepNumber + 1}'), Spacer(), Text('Всего шагов: ${state.numberOfSteps}')]), diff --git a/lib/features/recipes/reporitories/recipe_repository.dart b/lib/features/recipes/reporitories/recipe_repository.dart index cf9a355e..bea4d06d 100644 --- a/lib/features/recipes/reporitories/recipe_repository.dart +++ b/lib/features/recipes/reporitories/recipe_repository.dart @@ -4,7 +4,7 @@ import 'dart:io'; import 'package:eatvio_app/features/recipes/models/recipe_model.dart'; import 'package:eatvio_app/features/recipes/models/recipe_tag_model.dart'; import 'package:eatvio_app/features/recipes/services/recipe_service.dart'; -import 'package:eatvio_app/features/diary/models/product.dart'; +import 'package:eatvio_app/features/recipes/models/product.dart'; class RecipeRepository { final RecipeService recipeService; @@ -39,8 +39,7 @@ class RecipeRepository { }; }).toList() ?? []; - print(ingredientsMap); - print(stepsMap); + return await recipeService.publishRecipe( recipe.type, recipe.state, diff --git a/lib/features/recipes/services/recipe_service.dart b/lib/features/recipes/services/recipe_service.dart index f0a5e200..54703dc5 100644 --- a/lib/features/recipes/services/recipe_service.dart +++ b/lib/features/recipes/services/recipe_service.dart @@ -5,7 +5,7 @@ import 'package:dio/dio.dart'; import 'package:eatvio_app/features/recipes/models/recipe_model.dart'; import 'package:eatvio_app/features/recipes/models/recipe_tag_model.dart'; import 'package:retrofit/retrofit.dart'; -import 'package:eatvio_app/features/diary/models/product.dart'; +import 'package:eatvio_app/features/recipes/models/product.dart'; part 'recipe_service.g.dart'; diff --git a/lib/features/recipes/services/recipe_service.g.dart b/lib/features/recipes/services/recipe_service.g.dart index c32c9e8a..20e02b55 100644 --- a/lib/features/recipes/services/recipe_service.g.dart +++ b/lib/features/recipes/services/recipe_service.g.dart @@ -6,7 +6,7 @@ part of 'recipe_service.dart'; // RetrofitGenerator // ************************************************************************** -// ignore_for_file: unnecessary_brace_in_string_interps,no_leading_underscores_for_local_identifiers,unused_element +// ignore_for_file: unnecessary_brace_in_string_interps,no_leading_underscores_for_local_identifiers,unused_element,unnecessary_string_interpolations class _RecipeService implements RecipeService { _RecipeService( diff --git a/lib/features/registration/presentation/pages/additional_information_screen.dart b/lib/features/registration/presentation/pages/additional_information_screen.dart index 01ce3ffa..c3d70fc4 100644 --- a/lib/features/registration/presentation/pages/additional_information_screen.dart +++ b/lib/features/registration/presentation/pages/additional_information_screen.dart @@ -2,6 +2,7 @@ import 'package:eatvio_app/features/registration/models/user_registration_model. import 'package:eatvio_app/features/registration/presentation/bloc/registration_cubit/registration_cubit.dart'; import 'package:eatvio_app/widgets/custom_text_form_field.dart'; import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; class AdditionalInformationScreen extends StatefulWidget { @@ -43,6 +44,9 @@ class _AdditionalInformationScreenState extends State { profileDetailsModel: profileDetailsModel, ); } catch (e) { - print(e); rethrow; } finally { await init(); @@ -49,7 +48,6 @@ class SettingsCubit extends Cubit { profileSettingsModel: profileSettingsModel, ); } catch (e) { - print(e); rethrow; } finally { await init(); diff --git a/lib/features/settings/presentation/pages/other_info_screen.dart b/lib/features/settings/presentation/pages/other_info_screen.dart index f9dfc9e1..b786a746 100644 --- a/lib/features/settings/presentation/pages/other_info_screen.dart +++ b/lib/features/settings/presentation/pages/other_info_screen.dart @@ -4,6 +4,7 @@ import 'package:eatvio_app/generated/l10n.dart'; import 'package:eatvio_app/theme/theme_helper.dart'; import 'package:eatvio_app/widgets/custom_text_form_field.dart'; import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; import 'package:go_router/go_router.dart'; class OtherInfoScreen extends StatefulWidget { @@ -113,6 +114,9 @@ class _OtherInfoScreenState extends State { SizedBox(height: 4), CustomTextFormField( controller: additionalInfoController, + inputFormatters: [ + new LengthLimitingTextInputFormatter(250), + ], hintText: "У меня крепкое здоровье, но последнее время часто утомляюсь, однако, это мне не мешает радоваться жизни", maxLines: 8, onChanged: (newValue) {}, diff --git a/lib/features/settings/services/settings_service.g.dart b/lib/features/settings/services/settings_service.g.dart index f1d38de5..53d31175 100644 --- a/lib/features/settings/services/settings_service.g.dart +++ b/lib/features/settings/services/settings_service.g.dart @@ -6,7 +6,7 @@ part of 'settings_service.dart'; // RetrofitGenerator // ************************************************************************** -// ignore_for_file: unnecessary_brace_in_string_interps,no_leading_underscores_for_local_identifiers,unused_element +// ignore_for_file: unnecessary_brace_in_string_interps,no_leading_underscores_for_local_identifiers,unused_element,unnecessary_string_interpolations class _SettingsService implements SettingsService { _SettingsService( diff --git a/lib/locator_service.dart b/lib/locator_service.dart index e64ee309..43d3082d 100644 --- a/lib/locator_service.dart +++ b/lib/locator_service.dart @@ -14,7 +14,7 @@ import 'package:eatvio_app/features/chat/services/chat_service.dart'; import 'package:eatvio_app/features/consultant/become_consultant/presentation/bloc/register_consultant_cubit/register_consultant_cubit.dart'; import 'package:eatvio_app/features/consultant/become_consultant/repositories/consultant_repository.dart'; import 'package:eatvio_app/features/consultant/become_consultant/services/consultant_service.dart'; -import 'package:eatvio_app/features/diary/presentation/bloc/diary_bloc.dart'; +import 'package:eatvio_app/features/diary/presentation/bloc/diary_cubit.dart'; import 'package:eatvio_app/features/diary/repositories/diary_repository.dart'; import 'package:eatvio_app/features/diary/services/diary_service.dart'; import 'package:eatvio_app/features/feed/presentation/bloc/comments_cubit/comments_cubit.dart'; @@ -23,6 +23,8 @@ import 'package:eatvio_app/features/feed/presentation/bloc/feed_cubit/feed_cubit import 'package:eatvio_app/features/feed/presentation/bloc/recipes_cubit/recipes_cubit.dart'; import 'package:eatvio_app/features/feed/repositories/feed_repository.dart'; import 'package:eatvio_app/features/feed/services/feed_service.dart'; +import 'package:eatvio_app/features/glossary/repositories/glossary_repository.dart'; +import 'package:eatvio_app/features/glossary/services/glossary_service.dart'; import 'package:eatvio_app/features/plans/presentation/bloc/plans_cubit/plans_cubit.dart'; import 'package:eatvio_app/features/plans/repositories/plans_repository.dart'; import 'package:eatvio_app/features/plans/services/plans_service.dart'; @@ -53,9 +55,8 @@ Future init() async { sl.registerFactory(() => ChatRoomCubit(chatRepository: sl(), initializationCubit: sl())); sl.registerFactory(() => FeedCubit(feedRepository: sl())); sl.registerFactory(() => RecipesCubit(feedRepository: sl(), recipeRepository: sl())); - sl.registerFactory(() => DiaryBloc(diaryRepository: sl())); sl.registerFactory(() => CalendarCubit(calendarRepository: sl())); - sl.registerFactory(() => ProfileCubit(profileRepository: sl())); + sl.registerFactory(() => ProfileCubit(profileRepository: sl(), chatRepository: sl())); sl.registerFactory(() => ProfileAvatarCubit(profileRepository: sl())); sl.registerFactory(() => RecipeCreateCubit(recipeRepository: sl())); sl.registerFactory(() => DietsCubit(feedRepository: sl())); @@ -64,30 +65,33 @@ Future init() async { sl.registerFactory(() => PlansCubit(plansRepository: sl())); sl.registerFactory(() => SettingsCubit(profileRepository: sl(), settingsRepository: sl())); sl.registerFactory(() => RegisterConsultantCubit(consultantRepository: sl())); + sl.registerFactory(() => DiaryCubit(diaryRepository: sl(), glossaryRepository: sl())); // Repository sl.registerLazySingleton(() => ChatRepository(chatService: sl())); sl.registerLazySingleton(() => FeedRepository(feedService: sl())); sl.registerLazySingleton(() => RegistrationRepository(registrationService: sl())); - sl.registerLazySingleton(() => DiaryRepository(diaryService: sl())); sl.registerLazySingleton(() => CalendarRepository(calendarService: sl())); sl.registerLazySingleton(() => ProfileRepository(profileService: sl())); sl.registerLazySingleton(() => RecipeRepository(recipeService: sl())); sl.registerLazySingleton(() => PlansRepository(plansService: sl())); sl.registerLazySingleton(() => SettingsRepository(settingsService: sl())); sl.registerLazySingleton(() => ConsultantRepository(consultantService: sl())); + sl.registerLazySingleton(() => DiaryRepository(diaryService: sl())); + sl.registerLazySingleton(() => GlossaryRepository(glossaryService: sl())); // Services sl.registerLazySingleton(() => ChatService(sl())); sl.registerLazySingleton(() => FeedService(sl())); sl.registerLazySingleton(() => RegistrationService(sl())); - sl.registerLazySingleton(() => DiaryService(sl())); sl.registerLazySingleton(() => CalendarService(sl())); sl.registerLazySingleton(() => ProfileService(sl())); sl.registerLazySingleton(() => RecipeService(sl())); sl.registerLazySingleton(() => PlansService(sl())); sl.registerLazySingleton(() => SettingsService(sl())); sl.registerLazySingleton(() => ConsultantService(sl())); + sl.registerLazySingleton(() => DiaryService(sl())); + sl.registerLazySingleton(() => GlossaryService(sl())); // External sl.registerLazySingleton( diff --git a/lib/old/auth/auth_screen/auth_screen.dart b/lib/old/auth/auth_screen/auth_screen.dart index 3850cacf..da510bd8 100644 --- a/lib/old/auth/auth_screen/auth_screen.dart +++ b/lib/old/auth/auth_screen/auth_screen.dart @@ -54,7 +54,7 @@ class _AuthScreenState extends State { crossAxisAlignment: CrossAxisAlignment.start, children: [ Text(s.email), - SizedBox(height: 4), + const SizedBox(height: 4), BlocSelector( selector: (state) => state.emailController, builder: (context, emailController) { @@ -67,9 +67,9 @@ class _AuthScreenState extends State { ); }, ), - SizedBox(height: 16), + const SizedBox(height: 16), Text(s.password), - SizedBox(height: 4), + const SizedBox(height: 4), BlocSelector( selector: (state) => state.passwordController, builder: (context, passwordController) { @@ -91,7 +91,7 @@ class _AuthScreenState extends State { ); }, ), - SizedBox(height: 16), + const SizedBox(height: 16), Row( mainAxisAlignment: MainAxisAlignment.center, children: [ @@ -135,7 +135,7 @@ class _AuthScreenState extends State { ), ], ), - SizedBox(height: 16), + const SizedBox(height: 16), BlocBuilder( builder: (context, state) { return Container( @@ -181,7 +181,7 @@ class _AuthScreenState extends State { body: json.encode(credentials), encoding: utf8, ); - print(response.statusCode); + if (response.statusCode == 200) { var res = await jsonDecode(response.body); final token = res['token']; diff --git a/lib/old/diary/diary_edit_screen/diary_edit_screen.dart b/lib/old/diary/diary_edit_screen/diary_edit_screen.dart index 57e167d7..e69de29b 100644 --- a/lib/old/diary/diary_edit_screen/diary_edit_screen.dart +++ b/lib/old/diary/diary_edit_screen/diary_edit_screen.dart @@ -1,1253 +0,0 @@ -// ignore_for_file: unused_local_variable - -/*import '../../../features/diary/presentation/bloc/diary_bloc.dart'; -import 'models/diary_edit_model.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter/services.dart'; -import 'package:flutter_form_builder/flutter_form_builder.dart'; -import 'package:fl_chart/fl_chart.dart'; -import 'package:image_picker/image_picker.dart'; -import 'package:flutter_dotenv/flutter_dotenv.dart'; - -import 'package:eatvio_app/widgets/custom_edit_text_form_field.dart'; -import 'package:eatvio_app/widgets/custom_edit_drop_down.dart'; -import 'package:eatvio_app/widgets/custom_outlined_button.dart'; -import 'package:eatvio_app/widgets/custom_scale_element.dart'; -import 'package:carousel_slider/carousel_slider.dart'; - -// ignore: must_be_immutable -class DiaryEditScreen extends StatelessWidget { - DiaryEditScreen({Key? key}) : super(key: key); - - static Widget builder(BuildContext context) { - return BlocProvider( - create: (context) => DiaryEditBloc(DiaryEditState(diaryEditModelObj: DiaryEditModel()))..add(DiaryEditInitialEvent()), - child: DiaryEditScreen(), - ); - } - - Widget build(BuildContext context) { - return BlocBuilder( - builder: (context, state) { - if (state is DiaryEditInitialState) { - // Это начальное состояние, данные ещё не загружены. - return Container( - color: Colors.white, - ); - } else if (state is DiaryEditLoadedState) { - // Данные загружены, можно строить экран. - return _buildDiaryEditScreen(context, state); - } else if (state is DiaryEditErrorState) { - // Произошла ошибка при загрузке данных. - return Center(child: Text(state.errorMessage)); - } else { - // Другие состояния, если они есть. - return Container(); // Пустой контейнер для необработанных состояний. - } - }, - ); - } - - Widget _buildDiaryEditScreen(BuildContext context, DiaryEditLoadedState state) { - return RefreshIndicator( - onRefresh: refreshPage(context), - child: Stack( - alignment: Alignment.bottomCenter, - children: [ - FormBuilder( - child: Scaffold( - appBar: AppBar( - toolbarHeight: 0, - automaticallyImplyLeading: false, - ), - backgroundColor: Color.fromARGB(255, 240, 242, 245), - resizeToAvoidBottomInset: true, - body: SizedBox( - width: double.maxFinite, - child: Column( - children: [ - Expanded( - child: SingleChildScrollView( - child: Padding( - padding: EdgeInsets.only(bottom: 5.v), - child: Column( - children: [ - _buildHeaderRow(context, state), - SizedBox(height: 30.v), - _buildWakupRetire(context, state), - SizedBox(height: 30.v), - _buildMeal(context, state), - SizedBox(height: 20.v), - _buildMood(context, state), - SizedBox(height: 30.v), - _buildNutritionChart(context, state), - SizedBox(height: 30.v), - _buildComment(context, state), - ], - ), - ), - ), - ), - ], - ), - ), - ), - ), - _buildEndDay(context), - ], - ), - ); - } - - _buildEndDay(BuildContext context) { - return CustomOutlinedButton( - text: "Закончить день", - margin: EdgeInsets.only( - left: 16.h, - right: 16.h, - bottom: 16.v, - ), - buttonStyle: CustomButtonStyles.outlinePrimaryTL15, - decoration: BoxDecoration( - color: Colors.transparent, - ), - onPressed: onFinishDayPressed(context), - // Установите прозрачный фон - ); - } - - refreshPage(BuildContext context) { - return () async { - context.read().add(RefreshEvent()); - }; - } - - /// Section Widget - _buildHeaderRow(BuildContext context, DiaryEditLoadedState state) { - final day = state.diaryId; - return Container( - margin: EdgeInsets.symmetric(horizontal: 16.h, vertical: 16.h), - padding: EdgeInsets.symmetric( - horizontal: 24.h, - vertical: 12.v, - ), - decoration: BoxDecoration( - color: Colors.white, - borderRadius: const BorderRadius.all(Radius.circular(12)), - boxShadow: [ - BoxShadow( - color: Colors.grey.withOpacity(0.5), - spreadRadius: 2, - blurRadius: 5, - offset: Offset(0, 3), - ), - ], - ), - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Padding( - padding: EdgeInsets.only(top: 1.v), - child: Column( - children: [ - Align( - alignment: Alignment.centerRight, - child: Text( - "$day день", - style: CustomTextStyles.titleMediumBlack, - ), - ), - SizedBox(height: 2.v), - Text( - state.diaryDate.toString(), - style: CustomTextStyles.bodyMediumBluegray800, - ), - ], - ), - ), - ], - ), - ); - } - - /// Section Widget - _buildAddProduct(BuildContext context, DiaryEditLoadedState state) { - return CustomOutlinedButton( - text: "Добавить продукт", - margin: EdgeInsets.symmetric(horizontal: 10.h), - buttonStyle: CustomButtonStyles.outlinePrimaryTL15, - onPressed: addProduct(context), - ); - } - - addProduct(BuildContext context) { - return () { - context.read().add(AddPortionEvent()); - }; - } - - /// Section Widget - _buildAddPhoto(BuildContext context, DiaryEditLoadedState state) { - bool isLoading = state.isLoading; - return GestureDetector( - onTap: addImage(context, isLoading), - child: Stack( - children: [ - if (!isLoading) - Container( - margin: EdgeInsets.symmetric(horizontal: 10.h), - padding: EdgeInsets.symmetric( - horizontal: 40.h, - vertical: 80.v, - ), - decoration: AppDecoration.fillGray.copyWith( - borderRadius: BorderRadiusStyle.roundedBorder5, - ), - child: Row( - mainAxisAlignment: MainAxisAlignment.end, - mainAxisSize: MainAxisSize.min, - children: [ - // Показывайте прелоадер, если загрузка активна - - Padding( - padding: EdgeInsets.only( - left: 7.h, - top: 5.v, - ), - child: Text( - "Добавить фото", - selectionColor: appTheme.blueA400, - ), - ), - Spacer(), - Icon( - Icons.photo_library, - color: appTheme.blueGray300, - ), - ], - ), - ), - if (isLoading) - Container( - margin: EdgeInsets.symmetric(horizontal: 10.h), - padding: EdgeInsets.symmetric( - horizontal: 40.h, - vertical: 80.v, - ), - decoration: AppDecoration.fillGray.copyWith( - borderRadius: BorderRadiusStyle.roundedBorder5, - ), - child: Center( - child: CircularProgressIndicator(color: appTheme.blueGray300), // Замените на свой прелоадер при необходимости - ), - ), - ], - ), - ); - } - - addImage(BuildContext context, bool isLoading) { - if (!isLoading) { - return () async { - final picker = ImagePicker(); - List? images = await picker.pickMultiImage(); - if (images.isNotEmpty) { - for (var image in images) { - context.read().add(UploadImages(image)); - } - } - }; - } - } - - _buildMeal(BuildContext context, DiaryEditLoadedState state) { - final digitsOnly = FilteringTextInputFormatter.digitsOnly; - List _options = state.autocompleteList!.map((dynamic item) => item as String).toList(); - //print(_options); - FocusNode focusNodeName = FocusNode(); - return Container( - margin: EdgeInsets.symmetric(horizontal: 16.h), - padding: EdgeInsets.symmetric( - horizontal: 24.h, - vertical: 12.v, - ), - decoration: BoxDecoration( - color: Colors.white, - borderRadius: const BorderRadius.all(Radius.circular(12)), - boxShadow: [ - BoxShadow( - color: Colors.grey.withOpacity(0.5), - spreadRadius: 2, - blurRadius: 5, - offset: Offset(0, 3), - ), - ], - ), - child: Column( - mainAxisSize: MainAxisSize.min, - children: [ - Padding( - padding: EdgeInsets.symmetric(horizontal: 10.h), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Text( - "Время приема пищи", - style: CustomTextStyles.bodyMediumBlack900, - ), - Expanded( - // Adding Expanded widget - child: Padding( - padding: EdgeInsets.symmetric(horizontal: 10.h), - child: ConstrainedBox( - constraints: BoxConstraints( - maxWidth: MediaQuery.of(context).size.width - 260, - ), - child: GestureDetector( - onTap: () => _selectMealTime(context, state), - child: AbsorbPointer( - child: CustomTextFormField( - hintText: state.mealTimeController?.format(context).toString(), - autofocus: false, - ), - ), - ), - ), - ), - ), - ], - ), - ), - SizedBox(height: 20.v), - Padding( - padding: EdgeInsets.symmetric(horizontal: 10.h), - child: BlocSelector( - selector: (state) => state.diaryEditModelObj, - builder: (context, diaryEditModelObj) { - return CustomDropDown( - hintText: "Прием пищи", - items: diaryEditModelObj?.mealList, - contentPadding: EdgeInsets.symmetric( - horizontal: 10.h, - vertical: 9.v, - ), - defaultValue: diaryEditModelObj?.mealList[0], - onChanged: changeMeal(context, state), - ); - }, - ), - ), - SizedBox(height: 20.v), - Padding( - padding: EdgeInsets.symmetric(horizontal: 10.h), - child: RawAutocomplete( - optionsBuilder: buildOptions(_options), - fieldViewBuilder: ( - BuildContext context, - TextEditingController productEditingController, - FocusNode focusNodeName, - VoidCallback onFieldSubmitted, - ) { - if (state.isAdded) { - print("Clear"); - } - return CustomTextFormField( - hintText: "Введите название продукта", - controller: productEditingController, - focusNode: focusNodeName, - onChanged: getAutocomplete(context, focusNodeName), - ); - }, - optionsViewBuilder: ( - BuildContext context, - AutocompleteOnSelected onSelected, - Iterable options, - ) { - return Align( - alignment: Alignment.topLeft, - child: Material( - elevation: 4.0, - child: SizedBox( - height: 200.0, - child: ListView.builder( - padding: const EdgeInsets.all(8.0), - itemCount: options.length, - itemBuilder: (BuildContext context, int index) { - final String option = options.elementAt(index); - return GestureDetector( - onTap: selectProduct(onSelected, option, state), - child: ListTile( - title: Text(option), - ), - ); - }, - ), - ), - ), - ); - }, - ), - ), - SizedBox(height: 20.v), - if (state.moderationExpanded) - Padding( - padding: EdgeInsets.symmetric(horizontal: 10.h), - child: GestureDetector( - onTap: () => openCaloriesDialog(context, state), - child: Text("Отправить на модерацию"), - ), - ), - SizedBox(height: 20.v), - Padding( - padding: EdgeInsets.symmetric(horizontal: 10.h), - child: SingleChildScrollView( - scrollDirection: Axis.horizontal, - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - CustomTextFormField( - width: 150.h, - hintText: "Кол-во", - textInputAction: TextInputAction.done, - // focusNode: focusNodeQuantity, - controller: state.productQuantityController, - keyboardType: TextInputType.number, - inputFormatters: [digitsOnly], - ), - Padding( - padding: EdgeInsets.only(left: 30.h), - child: BlocSelector( - selector: (state) => state.diaryEditModelObj, - builder: (context, diaryEditModelObj) { - return CustomDropDown( - items: diaryEditModelObj?.portionList, - defaultValue: diaryEditModelObj?.portionList?[0], - onChanged: changePortion(context, state), - ); - }, - ), - ), - ], - ), - ), - ), - SizedBox(height: 30.v), - _buildAddProduct(context, state), - SizedBox(height: 30.v), - ...state.portions!.map((portion) => _buildProduct(context, portion)).toList(), - SizedBox(height: 30.v), - /*...state.photos != null - ? state.photos!.isEmpty - ? [Text('Фото пока нет')] - : state.photos! - .map((photo) => _buildPhoto(context, photo)) - .toList() - : [Text('Фото нет')],*/ - _buildCarousel(context, state), - SizedBox(height: 20.v), - _buildAddPhoto(context, state), - SizedBox(height: 30.v), - Text( - "Ваша сытость после приёма пищи", - style: CustomTextStyles.bodyMediumBlack900, - ), - SizedBox(height: 15.v), - BlocBuilder( - builder: (context, state) { - if (state is DiaryEditLoadedState) { - return Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Text("😭"), - ScaleElement( - color: Colors.red, - isSelected: state.selectedSatiety == 0, - onTap: changeSatiety(context, 0), - ), - ScaleElement( - color: Colors.orange, - isSelected: state.selectedSatiety == 1, - onTap: changeSatiety(context, 1), - ), - ScaleElement( - color: Colors.yellow, - isSelected: state.selectedSatiety == 2, - onTap: changeSatiety(context, 2), - ), - ScaleElement( - color: Colors.lime, - isSelected: state.selectedSatiety == 3, - onTap: changeSatiety(context, 3), - ), - ScaleElement( - color: Colors.lightGreen, - isSelected: state.selectedSatiety == 4, - onTap: changeSatiety(context, 4), - ), - ScaleElement( - color: Colors.green, - isSelected: state.selectedSatiety == 5, - onTap: changeSatiety(context, 5), - ), - Text("😊"), - // Остальные элементы шкалы - ], - ); - } else { - return Container(); // Возвращаем пустой контейнер, если состояние не является DiaryEditLoadedState - } - }, - ), - ], - ), - ); - } - - openCaloriesDialog(BuildContext context, DiaryEditLoadedState state) { - showDialog( - context: context, - builder: (BuildContext dialogContext) { - return AlertDialog( - title: Text('Введите информацию о продукте'), - content: Column( - mainAxisSize: MainAxisSize.min, - children: [ - CustomTextFormField( - hintText: "Название", - controller: state.productNameController, - ), - SizedBox(height: 10.v), - CustomTextFormField( - hintText: "Энергетическая ценность на 100", - keyboardType: TextInputType.number, - controller: state.caloriesController, - ), - SizedBox(height: 10.v), - CustomTextFormField( - hintText: "Белки на 100г", - keyboardType: TextInputType.number, - controller: state.proteinsController, - ), - SizedBox(height: 10.v), - CustomTextFormField( - hintText: "Жиры на 100г", - keyboardType: TextInputType.number, - controller: state.fatsController, - ), - SizedBox(height: 10.v), - CustomTextFormField( - hintText: "Углеводы на 100г", - keyboardType: TextInputType.number, - controller: state.carbsController, - ), - ], - ), - actions: [ - TextButton( - onPressed: popDialog(context), - child: Text('Отмена'), - ), - TextButton( - onPressed: triggerModeration( - context, - state.productNameController!.text, - state.caloriesController!.text, - state.proteinsController!.text, - state.fatsController!.text, - state.carbsController!.text, - dialogContext, - ), - child: Text('Отправить'), - ), - ], - ); - }, - ); - } - - triggerModeration( - BuildContext context, - String name, - String energyOn100gr, - String proteinsOn100gr, - String fatsOn100gr, - String carbohydratesOn100gr, - BuildContext dialogContext, - ) { - return () { - // Call function to send moderation with the entered values - context.read().add( - SendModeration( - name: name, - energyOn100gr: energyOn100gr, - proteinsOn100gr: proteinsOn100gr, - fatsOn100gr: fatsOn100gr, - carbohydratesOn100gr: carbohydratesOn100gr, - ), - ); - Navigator.of(dialogContext).pop(); // Dismiss the dialog - }; - } - - popDialog(BuildContext dialogContext) { - return () { - Navigator.of(dialogContext).pop(); // Dismiss the dialog on Cancel button press - }; - } - - changeSatiety(BuildContext context, int satiety) { - return () { - context.read().add(ChangeSatiety(satiety)); - }; - } - - selectProduct(AutocompleteOnSelected onSelected, String option, DiaryEditLoadedState state) { - state.productNameController?.text = option; - return () { - onSelected(option); - }; - } - - getAutocomplete(BuildContext context, FocusNode focusNode) { - return (value) { - /*print(state.autocompleteList - ?.map((dynamic item) => item as String) - .toList());*/ - if (value.length > 2) { - context.read().add(ProductInput(value)); - } - }; - } - - buildOptions(List _options) { - return (TextEditingValue textEditingValue) { - return _options.where((String option) { - return true; - }); - }; - } - - changeMeal(BuildContext context, DiaryEditLoadedState state) { - return (value) { - context.read().add(ChangeMeal(meals: state.meals, value: value)); - }; - } - - changePortion(BuildContext context, DiaryEditLoadedState state) { - return (value) { - context.read().add(ChangePortion(value: value)); - }; - } - - _buildCarousel(BuildContext context, DiaryEditLoadedState state) { - if (state.photos!.isEmpty) { - return Text("Фото нет"); - } else { - return CarouselSlider( - options: CarouselOptions(height: 340.0), - items: state.photos!.map((photo) { - return _buildPhoto(context, photo); // Assuming photos are stored as strings - }).toList(), - ); - } - } - - _buildProduct(BuildContext context, Map portion) { - return Container( - margin: EdgeInsets.symmetric(horizontal: 10.h), - padding: EdgeInsets.symmetric( - horizontal: 8.h, - vertical: 6.v, - ), - decoration: AppDecoration.fillGray.copyWith( - borderRadius: BorderRadiusStyle.roundedBorder5, - ), - child: Row( - mainAxisAlignment: MainAxisAlignment.end, - mainAxisSize: MainAxisSize.min, - children: [ - Padding( - padding: EdgeInsets.only( - left: 7.h, - top: 5.v, - ), - child: Text( - portion['product_name'].length > 8 ? portion['product_name'].substring(0, 8) : portion['product_name'], - style: CustomTextStyles.titleMedium16, - ), - ), - Padding( - padding: EdgeInsets.only( - left: 20.h, - top: 3.v, - bottom: 3.v, - ), - child: Text( - portion['quantity'].toString() + ' ' + portion['portion'].toString().tr, - ), - ), - Spacer(), - GestureDetector( - onTap: removePortion(context, portion), - child: Padding( - padding: const EdgeInsets.only(right: 10), - child: Icon( - Icons.close, - color: appTheme.blueGray300, - ), - ), - ), - ], - ), - ); - } - - _buildPhoto(BuildContext context, Map photo) { - return Stack( - children: [ - Container( - margin: EdgeInsets.symmetric(horizontal: 10.h, vertical: 10.h), - decoration: AppDecoration.fillGray.copyWith( - borderRadius: BorderRadiusStyle.roundedBorder5, - ), - child: Image.network( - dotenv.env['STORAGE_URL']! + photo['path'], - ), - ), - Positioned( - top: 5, - right: 5, - child: GestureDetector( - onTap: removePhoto(context, photo), - child: Container( - padding: EdgeInsets.all(5), - decoration: BoxDecoration( - shape: BoxShape.circle, - color: Colors.transparent, - ), - child: Icon( - Icons.close, - color: appTheme.blueGray300, - ), - ), - ), - ), - ], - ); - } - - removePortion(BuildContext context, Map portion) { - return () { - context.read().add(RemovePortionEvent(portion['id'])); - }; - } - - removePhoto(BuildContext context, Map photo) { - return () { - context.read().add(RemoveImageEvent(photo['id'].toString(), photo['path'])); - }; - } - - _buildNutritionChart(BuildContext context, DiaryEditLoadedState state) { - final List recommendedValues = state.recommendedChartValues; // Рекомендуемые значения: калории, жиры, белки, углеводы - final List consumedValues = state.consumedChartValues; // - return Container( - margin: EdgeInsets.symmetric(horizontal: 16.h), - padding: EdgeInsets.symmetric( - horizontal: 10.h, - vertical: 16.v, - ), - decoration: BoxDecoration( - color: Colors.white, - borderRadius: const BorderRadius.all(Radius.circular(12)), - boxShadow: [ - BoxShadow( - color: Colors.grey.withOpacity(0.5), - spreadRadius: 2, - blurRadius: 5, - offset: Offset(0, 3), - ), - ], - ), - child: Column( - mainAxisSize: MainAxisSize.min, - mainAxisAlignment: MainAxisAlignment.center, - children: [ - SizedBox(height: 3.v), - Text( - "Ваш КБЖУ", - style: theme.textTheme.titleMedium, - ), - SizedBox(height: 8.v), - Text( - "От дневной суточной нормы", - style: CustomTextStyles.bodyMediumBluegray800, - ), - SizedBox(height: 19.v), - Align( - alignment: Alignment.centerRight, - child: Padding( - padding: EdgeInsets.only( - left: 30.h, - right: 12.h, - ), - child: AspectRatio( - aspectRatio: 1.5, - child: BarChart( - BarChartData( - alignment: BarChartAlignment.spaceAround, - barTouchData: BarTouchData(enabled: false), - titlesData: FlTitlesData( - show: true, - bottomTitles: AxisTitles( - sideTitles: SideTitles( - showTitles: true, - //getTitlesWidget: (value, meta) => newMethod(value), - ), - ), - ), - borderData: FlBorderData(show: false), - barGroups: [ - BarChartGroupData( - x: 0, - barRods: [ - BarChartRodData( - toY: consumedValues[0] / recommendedValues[0] * 100, - color: checkConsumedValues([recommendedValues[0]], [consumedValues[1]]) ? Colors.red : Colors.blue, - ), - ], - ), - BarChartGroupData( - x: 1, - barRods: [ - BarChartRodData( - toY: consumedValues[1] / recommendedValues[1] * 100, - color: checkConsumedValues([recommendedValues[1]], [consumedValues[1]]) ? Colors.red : Colors.blue, - ), - ], - ), - BarChartGroupData( - x: 2, - barRods: [ - BarChartRodData( - toY: consumedValues[2] / recommendedValues[2] * 100, - color: checkConsumedValues([recommendedValues[2]], [consumedValues[2]]) ? Colors.red : Colors.blue, - ), - ], - ), - BarChartGroupData( - x: 3, - barRods: [ - BarChartRodData( - toY: consumedValues[3] / recommendedValues[3] * 100, - color: checkConsumedValues([recommendedValues[3]], [consumedValues[3]]) ? Colors.red : Colors.blue, - ), - ], - ), - ], - ), - ), - ), - ), - ), - SizedBox(height: 8.v), - SizedBox(height: 2.v), - Padding( - padding: EdgeInsets.only( - left: 10.h, - right: 2.h, - ), - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - "Калорий", - style: theme.textTheme.bodySmall, - ), - Padding( - padding: EdgeInsets.only( - left: 25.h, - bottom: 11.v, - ), - child: Text( - "Белков", - style: theme.textTheme.bodySmall, - ), - ), - Padding( - padding: EdgeInsets.only( - left: 19.h, - bottom: 11.v, - ), - child: Text( - "Жиров", - style: theme.textTheme.bodySmall, - ), - ), - Padding( - padding: EdgeInsets.only( - left: 14.h, - bottom: 11.v, - ), - child: Text( - "Углеводов", - style: theme.textTheme.bodySmall, - ), - ), - ], - ), - ), - SizedBox(height: 2.v), - Padding( - padding: EdgeInsets.only( - left: 10.h, - right: 2.h, - ), - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - "${consumedValues[0].toInt()} из ${recommendedValues[0].toInt()}", - style: theme.textTheme.bodySmall, - ), - Padding( - padding: EdgeInsets.only( - left: 25.h, - bottom: 11.v, - ), - child: Text( - "${consumedValues[1].toInt()} из ${recommendedValues[1].toInt()}", - style: theme.textTheme.bodySmall, - ), - ), - Padding( - padding: EdgeInsets.only( - left: 19.h, - bottom: 11.v, - ), - child: Text( - "${consumedValues[2].toInt()} из ${recommendedValues[2].toInt()}", - style: theme.textTheme.bodySmall, - ), - ), - Padding( - padding: EdgeInsets.only( - left: 14.h, - bottom: 11.v, - ), - child: Text( - "${consumedValues[3].toInt()} из ${recommendedValues[3].toInt()}", - style: theme.textTheme.bodySmall, - ), - ), - ], - ), - ), - SizedBox(height: 19.v), - if (checkConsumedValues(recommendedValues, consumedValues)) - Text( - "*Превышенная суточная норма", - style: theme.textTheme.labelLarge, - ), - ], - ), - ); - } - - /// Section Widget - _buildComment(BuildContext context, DiaryEditLoadedState state) { - return Container( - margin: EdgeInsets.symmetric(horizontal: 16.h), - padding: EdgeInsets.symmetric( - horizontal: 24.h, - vertical: 12.v, - ), - decoration: BoxDecoration( - color: Colors.white, - borderRadius: const BorderRadius.all(Radius.circular(12)), - boxShadow: [ - BoxShadow( - color: Colors.grey.withOpacity(0.5), - spreadRadius: 2, - blurRadius: 5, - offset: Offset(0, 3), - ), - ], - ), - child: Column( - mainAxisSize: MainAxisSize.min, - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Text( - "Дополнительная информация для консультанта", - style: theme.textTheme.titleMedium, - textAlign: TextAlign.center, - ), - SizedBox(height: 20.v), - Container( - width: 320.h, - child: CustomTextFormField( - autofocus: false, - hintText: "Введите информацию для консультанта", - maxLines: 7, - borderDecoration: InputBorder.none, - controller: state.commentController, - ), - ), - ], - ), - ); - } - - _buildWakupRetire(BuildContext context, DiaryEditLoadedState state) { - return Container( - margin: EdgeInsets.symmetric(horizontal: 16.h), - padding: EdgeInsets.symmetric( - horizontal: 24.h, - vertical: 12.v, - ), - decoration: BoxDecoration( - color: Colors.white, - borderRadius: const BorderRadius.all(Radius.circular(12)), - boxShadow: [ - BoxShadow( - color: Colors.grey.withOpacity(0.5), - spreadRadius: 2, - blurRadius: 5, - offset: Offset(0, 3), - ), - ], - ), - child: Column( - children: [ - GestureDetector( - onTap: toggleWakeup(context), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Text( - r"Подъем \ отход ко сну", - style: CustomTextStyles.bodyMediumBlack900, - ), - Icon(state.wakeupExpanded ? Icons.arrow_drop_up : Icons.arrow_drop_down), - ], - ), - ), - if (state.wakeupExpanded) - Padding( - padding: const EdgeInsets.only(left: 16.0), - child: Column( - children: [ - SizedBox(height: 20.v), - GestureDetector( - onTap: () => _selectWakeupTime(context, state), - child: AbsorbPointer( - child: CustomTextFormField( - hintText: state.wakeupController?.format(context).toString(), - prefix: Icon(Icons.sunny), - autofocus: false, - ), - ), - ), - SizedBox(height: 20.v), - GestureDetector( - onTap: () => _selectRetireTime(context, state), - child: AbsorbPointer( - child: CustomTextFormField( - hintText: state.retireController?.format(context).toString(), - prefix: Icon(Icons.bed), - autofocus: false, - ), - ), - ), - SizedBox(height: 20.v), - ], - ), - ), - ], - ), - ); - } - - toggleWakeup(BuildContext context) { - return () { - BlocProvider.of(context).add(ToggleWakeupExpandedEvent()); - }; - } - - /// Section Widget - - Function() onFinishDayPressed(BuildContext context) { - return () { - showDialog( - context: context, - builder: (BuildContext dialogContext) { - return AlertDialog( - title: Text("Подтвердите действие"), - content: Text("Вы уверены, что хотите завершить день?"), - actions: [ - TextButton( - child: Text("Отмена"), - onPressed: closeDialog(dialogContext), - ), - TextButton( - child: Text("Подтвердить"), - onPressed: sendFinishDayData(dialogContext, context), - ), - ], - ); - }, - ); - }; - } - - Function() sendFinishDayData(BuildContext dialogContext, BuildContext context) { - return () { - closeDialog(dialogContext); - context.read().add(FinishDay()); - }; - } - - Function() closeDialog(BuildContext dialogContext) { - return () { - Navigator.of(dialogContext).pop(); - }; - } - - _buildMood(BuildContext context, DiaryEditLoadedState state) { - return Container( - margin: EdgeInsets.symmetric(horizontal: 16.h), - padding: EdgeInsets.symmetric( - horizontal: 24.h, - vertical: 12.v, - ), - decoration: BoxDecoration( - color: Colors.white, - borderRadius: const BorderRadius.all(Radius.circular(12)), - boxShadow: [ - BoxShadow( - color: Colors.grey.withOpacity(0.5), - spreadRadius: 2, - blurRadius: 5, - offset: Offset(0, 3), - ), - ], - ), - child: Column( - children: [ - GestureDetector( - onTap: toggleMood(context), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Text( - "Ваше настроение после приема пищи", - style: CustomTextStyles.bodyMediumBlack900, - ), - Icon(state.moodExpanded ? Icons.arrow_drop_up : Icons.arrow_drop_down), - ], - ), - ), - if (state.moodExpanded) - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Text("😭"), - ScaleElement( - color: Colors.red, - isSelected: state.selectedMood == 0, - onTap: changeMood(context, 0), - ), - ScaleElement( - color: Colors.orange, - isSelected: state.selectedMood == 1, - onTap: changeMood(context, 1), - ), - ScaleElement( - color: Colors.yellow, - isSelected: state.selectedMood == 2, - onTap: changeMood(context, 2), - ), - ScaleElement( - color: Colors.lime, - isSelected: state.selectedMood == 3, - onTap: changeMood(context, 3), - ), - ScaleElement( - color: Colors.lightGreen, - isSelected: state.selectedMood == 4, - onTap: changeMood(context, 4), - ), - ScaleElement( - color: Colors.green, - isSelected: state.selectedMood == 5, - onTap: changeMood(context, 5), - ), - Text("😊"), - // Остальные элементы шкалы - ], - ), - ], - ), - ); - } - - changeMood(BuildContext context, int satiety) { - return () { - context.read().add(ChangeMood(satiety)); - }; - } - - toggleMood(BuildContext context) { - return () { - BlocProvider.of(context).add(ToggleMoodExpandedEvent()); - }; - } - - Future _selectWakeupTime(BuildContext context, DiaryEditLoadedState state) async { - final TimeOfDay? pickedTime = await showTimePicker( - context: context, - initialTime: state.wakeupController ?? TimeOfDay.now(), - ); - if (pickedTime != null && pickedTime != state.wakeupController) { - state.wakeupController = pickedTime; - context.read().add(WakeupEvent(pickedTime)); - } - } - - Future _selectRetireTime(BuildContext context, DiaryEditLoadedState state) async { - final TimeOfDay? pickedTime = await showTimePicker( - context: context, - initialTime: state.retireController ?? TimeOfDay.now(), - ); - if (pickedTime != null && pickedTime != state.retireController) { - state.retireController = pickedTime; - context.read().add(RetireEvent(pickedTime)); - } - } - - Future _selectMealTime(BuildContext context, DiaryEditLoadedState state) async { - final TimeOfDay? pickedTime = await showTimePicker( - context: context, - initialTime: state.mealTimeController ?? TimeOfDay.now(), - ); - if (pickedTime != null && pickedTime != state.mealTimeController) { - state.mealTimeController = pickedTime; - context.read().add(ChangeMealTime(pickedTime)); - } - } -} - -bool checkConsumedValues(List recommendedValues, List consumedValues) { - for (int i = 0; i < recommendedValues.length; i++) { - if (consumedValues[i] > recommendedValues[i]) { - // Если хотя бы одно потребленное значение превышает рекомендованное - return true; // Возвращаем false - } - } - // Если ни одно потребленное значение не превышает рекомендованное с соответствующим индексом - return false; // Возвращаем true -} -*/ diff --git a/lib/old/diets/diet_create_screen/bloc/diet_create_bloc.dart b/lib/old/diets/diet_create_screen/bloc/diet_create_bloc.dart index 3491e60f..e574c5bc 100644 --- a/lib/old/diets/diet_create_screen/bloc/diet_create_bloc.dart +++ b/lib/old/diets/diet_create_screen/bloc/diet_create_bloc.dart @@ -61,10 +61,6 @@ class DietCreateBloc extends Bloc { if (response.statusCode == 200) { AppRouter.navigatorKey.currentContext?.goNamed('dietSelectScreen'); - } else { - print( - 'Failed to create blog post. Status Code: ${response.statusCode} ${response.body}', - ); } } } diff --git a/lib/old/diets/diet_create_screen/diet_create_screen.dart b/lib/old/diets/diet_create_screen/diet_create_screen.dart index bad75b05..d04fff59 100644 --- a/lib/old/diets/diet_create_screen/diet_create_screen.dart +++ b/lib/old/diets/diet_create_screen/diet_create_screen.dart @@ -47,7 +47,7 @@ class DietCreateScreen extends StatelessWidget { decoration: AppDecoration.fillGray, child: ListView( children: [ - SizedBox(height: 30), + const SizedBox(height: 30), Container( margin: EdgeInsets.only( left: 16, @@ -70,17 +70,17 @@ class DietCreateScreen extends StatelessWidget { child: Column( mainAxisSize: MainAxisSize.min, children: [ - SizedBox(height: 16.0), + const SizedBox(height: 16.0), TextFormField( controller: state.name, decoration: InputDecoration(labelText: 'Заголовок'), ), - SizedBox(height: 16.0), + const SizedBox(height: 16.0), TextFormField( controller: state.details, decoration: InputDecoration(labelText: 'Описание'), ), - SizedBox(height: 16.0), + const SizedBox(height: 16.0), // Здесь нужно добавить виджет для загрузки картинки ElevatedButton( onPressed: () => context.read().add(CreateDiet()), diff --git a/lib/old/diets/diet_edit_screen/bloc/diet_edit_bloc.dart b/lib/old/diets/diet_edit_screen/bloc/diet_edit_bloc.dart index 1fd4610a..84fe86c8 100644 --- a/lib/old/diets/diet_edit_screen/bloc/diet_edit_bloc.dart +++ b/lib/old/diets/diet_edit_screen/bloc/diet_edit_bloc.dart @@ -78,7 +78,7 @@ class DietEditBloc extends Bloc { if (state is DietEditLoadedState) { var currentState = state as DietEditLoadedState; int duration = int.parse(currentState.duration!.text) * 7; - print(duration); + var response = await sendDiet(currentState.diet, currentState.name?.text, currentState.details?.text, duration.toString()); if (response.statusCode == 200) { @@ -86,9 +86,7 @@ class DietEditBloc extends Bloc { 'dietScreen', extra: currentState.diet?['id'].toString(), ); - } else { - print('Failed to edit blog post. Status Code: ${response.statusCode} ${response.body}'); - } + } else {} } } diff --git a/lib/old/diets/diet_select_screen/bloc/diet_select_bloc.dart b/lib/old/diets/diet_select_screen/bloc/diet_select_bloc.dart index 69bd3d7b..6ce9ec1b 100644 --- a/lib/old/diets/diet_select_screen/bloc/diet_select_bloc.dart +++ b/lib/old/diets/diet_select_screen/bloc/diet_select_bloc.dart @@ -36,14 +36,11 @@ class DietSelectBloc extends Bloc { 'Authorization': 'Bearer ${await TokenStorage.getTokenFromStorage()}', }, ); - print('Got response'); + if (response.statusCode == 200) { - print('Got 200'); final data = jsonDecode(response.body); if (data is List) { - print('Got List'); if (state is DietSelectLoadedState) { - print('Got loaded'); var currentState = state as DietSelectLoadedState; emit( (currentState).copyWith( @@ -52,7 +49,6 @@ class DietSelectBloc extends Bloc { ), ); } else { - print('Got unloaded'); emit( DietSelectLoadedState( posts: data, diff --git a/lib/old/feed/blog_post_create_screen/bloc/blog_post_create_bloc.dart b/lib/old/feed/blog_post_create_screen/bloc/blog_post_create_bloc.dart index 05c02fbc..269a2e9e 100644 --- a/lib/old/feed/blog_post_create_screen/bloc/blog_post_create_bloc.dart +++ b/lib/old/feed/blog_post_create_screen/bloc/blog_post_create_bloc.dart @@ -69,9 +69,7 @@ class BlogPostCreateBloc extends Bloc if (response.statusCode == 200 || response.statusCode == 201) { AppRouter.navigatorKey.currentContext?.goNamed('feedScreen'); - } else { - print('Failed to create blog post. Status Code: ${response.statusCode} ${response.data}'); - } + } else {} } } diff --git a/lib/old/feed/blog_post_edit_screen/bloc/blog_post_edit_bloc.dart b/lib/old/feed/blog_post_edit_screen/bloc/blog_post_edit_bloc.dart index 553e301d..613fe6ec 100644 --- a/lib/old/feed/blog_post_edit_screen/bloc/blog_post_edit_bloc.dart +++ b/lib/old/feed/blog_post_edit_screen/bloc/blog_post_edit_bloc.dart @@ -11,7 +11,8 @@ import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:go_router/go_router.dart'; import 'package:http/http.dart' as http; -part 'blog_post_edit_event.dart';part 'blog_post_edit_state.dart'; +part 'blog_post_edit_event.dart'; +part 'blog_post_edit_state.dart'; /// A bloc that manages the state of a BlogPostEdit according to the event that is dispatched to it. class BlogPostEditBloc extends Bloc { @@ -86,9 +87,7 @@ class BlogPostEditBloc extends Bloc { if (response.statusCode == 200) { AppRouter.navigatorKey.currentContext?.goNamed('blogPostScreen', extra: currentState.blog_post?['id'].toString()); - } else { - print('Failed to edit blog post. Status Code: ${response.statusCode} ${response.body}'); - } + } else {} } } diff --git a/lib/old/plans/plan_create_screen/bloc/plan_create_bloc.dart b/lib/old/plans/plan_create_screen/bloc/plan_create_bloc.dart index fa446a7c..00fd741a 100644 --- a/lib/old/plans/plan_create_screen/bloc/plan_create_bloc.dart +++ b/lib/old/plans/plan_create_screen/bloc/plan_create_bloc.dart @@ -61,10 +61,6 @@ class PlanCreateBloc extends Bloc { if (response.statusCode == 200) { AppRouter.navigatorKey.currentContext?.goNamed('planSelectScreen'); - } else { - print( - 'Failed to create blog post. Status Code: ${response.statusCode} ${response.body}', - ); } } } diff --git a/lib/old/plans/plan_edit_screen/bloc/plan_edit_bloc.dart b/lib/old/plans/plan_edit_screen/bloc/plan_edit_bloc.dart index ca78a970..c98331e9 100644 --- a/lib/old/plans/plan_edit_screen/bloc/plan_edit_bloc.dart +++ b/lib/old/plans/plan_edit_screen/bloc/plan_edit_bloc.dart @@ -78,7 +78,7 @@ class PlanEditBloc extends Bloc { if (state is PlanEditLoadedState) { var currentState = state as PlanEditLoadedState; int duration = int.parse(currentState.duration!.text) * 7; - print(duration); + var response = await sendPlan(currentState.plan, currentState.name?.text, currentState.details?.text, duration.toString()); if (response.statusCode == 200) { @@ -86,9 +86,7 @@ class PlanEditBloc extends Bloc { 'planScreen', extra: currentState.plan?['id'].toString(), ); - } else { - print('Failed to edit blog post. Status Code: ${response.statusCode} ${response.body}'); - } + } else {} } } diff --git a/lib/old/plans/plan_select_screen/bloc/plan_select_bloc.dart b/lib/old/plans/plan_select_screen/bloc/plan_select_bloc.dart index a08a00f2..4f2d6bf7 100644 --- a/lib/old/plans/plan_select_screen/bloc/plan_select_bloc.dart +++ b/lib/old/plans/plan_select_screen/bloc/plan_select_bloc.dart @@ -33,14 +33,11 @@ class PlanSelectBloc extends Bloc { final response = await http.get( Uri.parse(baseUrl + '/api/plans/index'), ); - print('Got response'); + if (response.statusCode == 200) { - print('Got 200'); final data = jsonDecode(response.body); if (data is List) { - print('Got List'); if (state is PlanSelectLoadedState) { - print('Got loaded'); var currentState = state as PlanSelectLoadedState; emit( (currentState).copyWith( @@ -49,7 +46,6 @@ class PlanSelectBloc extends Bloc { ), ); } else { - print('Got unloaded'); emit( PlanSelectLoadedState( posts: data, diff --git a/lib/old/profile/my_profile_screen/bloc/my_profile_bloc.dart b/lib/old/profile/my_profile_screen/bloc/my_profile_bloc.dart index 7d08ecfe..5f17e43c 100644 --- a/lib/old/profile/my_profile_screen/bloc/my_profile_bloc.dart +++ b/lib/old/profile/my_profile_screen/bloc/my_profile_bloc.dart @@ -26,7 +26,6 @@ class MyProfileBloc extends Bloc { MyProfileInitialEvent event, Emitter emit, ) async { - print('1'); try { if (!await TokenStorage.haveTokenInStorage()) { AppRouter.navigatorKey.currentContext?.goNamed('authScreen'); @@ -37,7 +36,7 @@ class MyProfileBloc extends Bloc { 'Authorization': 'Bearer ${await TokenStorage.getTokenFromStorage()}', }, ); - print('2'); + if (response.statusCode == 200) { final data = jsonDecode(response.body); if (data is Map && @@ -101,10 +100,10 @@ class MyProfileBloc extends Bloc { ..addAll(data["requestedPlan"]) ..addAll(data["initedPlan"]); - /*print(data["chartPoints"].length); - print(data["chartPoints"].runtimeType); - print(data["circumferences"].length); - print(data["circumferences"].runtimeType);*/ + /* + + + */ if (data["chartPoints"].length == 1) { data["chartPoints"] = []; } @@ -272,7 +271,7 @@ class MyProfileBloc extends Bloc { Future uploadImageToServer(String imagePath, String? token) async { String url = '${baseUrl}/api/profile/photo/upload'; - print(url); + var request = http.MultipartRequest('POST', Uri.parse(url)); request.headers['Authorization'] = 'Bearer $token'; @@ -284,7 +283,7 @@ class MyProfileBloc extends Bloc { if (streamedResponse.statusCode == 200) { var response = await http.Response.fromStream(streamedResponse); var imageUrl = response.body; - print('Image successfully uploaded'); + return imageUrl; } else { throw Exception( diff --git a/lib/old/recipe/recipe_edit_screen/bloc/recipe_edit_bloc.dart b/lib/old/recipe/recipe_edit_screen/bloc/recipe_edit_bloc.dart index 77866907..da258c37 100644 --- a/lib/old/recipe/recipe_edit_screen/bloc/recipe_edit_bloc.dart +++ b/lib/old/recipe/recipe_edit_screen/bloc/recipe_edit_bloc.dart @@ -119,9 +119,7 @@ class RecipeEditBloc extends Bloc { 'recipeScreen', extra: currentState.recipe?['id'].toString(), ); - } else { - print('Failed to edit blog post. Status Code: ${response.statusCode} ${response.body}'); - } + } else {} } } @@ -204,7 +202,6 @@ class RecipeEditBloc extends Bloc { } FutureOr _reloadScreen(RecipeEditEvent? event, Emitter emit) async { - print('Reloading..'); if (!await TokenStorage.haveTokenInStorage()) { AppRouter.navigatorKey.currentContext?.goNamed('authScreen'); } diff --git a/lib/old/recipe/recipe_edit_screen/recipe_edit_screen.dart b/lib/old/recipe/recipe_edit_screen/recipe_edit_screen.dart index 1318211a..28e34909 100644 --- a/lib/old/recipe/recipe_edit_screen/recipe_edit_screen.dart +++ b/lib/old/recipe/recipe_edit_screen/recipe_edit_screen.dart @@ -445,8 +445,7 @@ class RecipeEditScreen extends StatelessWidget { void _trimTags(newValue) { List newTagNames = newValue!.split(',').map((tag) => tag.trim()).toList(); - List> newTags = newTagNames.map((tagName) => {'name': tagName}).toList(); - print(newTags); + newTagNames.map((tagName) => {'name': tagName}).toList(); } Function onTapBack(BuildContext context) { diff --git a/lib/old/recipe/recipe_select_screen/bloc/recipe_select_bloc.dart b/lib/old/recipe/recipe_select_screen/bloc/recipe_select_bloc.dart index 43cad165..6353c7a7 100644 --- a/lib/old/recipe/recipe_select_screen/bloc/recipe_select_bloc.dart +++ b/lib/old/recipe/recipe_select_screen/bloc/recipe_select_bloc.dart @@ -30,14 +30,11 @@ class RecipeSelectBloc extends Bloc { AppRouter.navigatorKey.currentContext?.goNamed('authScreen'); } final response = await sl().get(baseUrl + '/api/recipes/index'); - print('Got response'); + if (response.statusCode == 200) { - print('Got 200'); final data = response.data['data']; if (data is List) { - print('Got List'); if (state is RecipeSelectLoadedState) { - print('Got loaded'); var currentState = state as RecipeSelectLoadedState; emit( (currentState).copyWith( @@ -46,7 +43,6 @@ class RecipeSelectBloc extends Bloc { ), ); } else { - print('Got unloaded'); emit( RecipeSelectLoadedState( posts: data, diff --git a/lib/old/users/subscribers_screen/bloc/subscribers_bloc.dart b/lib/old/users/subscribers_screen/bloc/subscribers_bloc.dart index a72d6554..aec562b0 100644 --- a/lib/old/users/subscribers_screen/bloc/subscribers_bloc.dart +++ b/lib/old/users/subscribers_screen/bloc/subscribers_bloc.dart @@ -35,23 +35,17 @@ class SubscribersBloc extends Bloc { 'Authorization': 'Bearer ${await TokenStorage.getTokenFromStorage()}', }, ); - print('Got response'); - print(response.statusCode); - print(response.body); + if (response.statusCode == 200) { - print('Got 200'); final data = jsonDecode(response.body); if (data is List) { - print('Got List'); if (state is SubscribersLoadedState) { - print('Got loaded'); var currentState = state as SubscribersLoadedState; emit((currentState).copyWith( subscribers: data, myProfileModelObj: currentState.myProfileModelObj, )); } else { - print('Got unloaded'); emit(SubscribersLoadedState( subscribers: data, )); diff --git a/lib/widgets/custom_text_form_field.dart b/lib/widgets/custom_text_form_field.dart index 4c0b0005..b493f9c9 100644 --- a/lib/widgets/custom_text_form_field.dart +++ b/lib/widgets/custom_text_form_field.dart @@ -19,6 +19,7 @@ class CustomTextFormField extends StatelessWidget { this.prefix, this.prefixConstraints, this.suffix, + this.suffixText, this.suffixConstraints, this.contentPadding, this.inputFormatters, @@ -53,6 +54,7 @@ class CustomTextFormField extends StatelessWidget { final Widget? prefix; final BoxConstraints? prefixConstraints; final Widget? suffix; + final String? suffixText; final BoxConstraints? suffixConstraints; final EdgeInsets? contentPadding; final InputBorder? borderDecoration; @@ -87,6 +89,7 @@ class CustomTextFormField extends StatelessWidget { initialValue: initialValue, cursorColor: appTheme.blueA400, decoration: InputDecoration( + suffixText: suffixText, hintText: hintText ?? "", hintStyle: TextStyle( fontSize: 16, @@ -96,6 +99,11 @@ class CustomTextFormField extends StatelessWidget { prefixIcon: prefix, prefixIconConstraints: prefixConstraints, suffixIcon: suffix, + suffixStyle: TextStyle( + fontSize: 16, + fontWeight: FontWeight.w500, + color: Color(0xFF323F4B), + ), suffixIconConstraints: suffixConstraints, isDense: false, contentPadding: EdgeInsets.symmetric(vertical: 16, horizontal: 12), diff --git a/pubspec.yaml b/pubspec.yaml index 9383ed5a..b589dd00 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -23,31 +23,31 @@ dependencies: validators: ^3.0.0 path_provider: ^2.1.4 carousel_slider_plus: ^7.0.1 - flutter_form_builder: ^9.4.1 + flutter_form_builder: ^9.5.0 image_picker: ^1.1.2 flutter_typeahead: ^5.2.0 - go_router: ^14.2.9 + go_router: ^14.3.0 keyboard_dismisser: ^3.0.0 retrofit: ^4.4.1 - get_it: ^8.0.0 + get_it: ^8.0.1 dio: ^5.7.0 dart_pusher_channels: ^1.2.3 photo_view: ^0.15.0 dismissible_page: ^1.0.2 - url_launcher: ^6.3.0 + url_launcher: ^6.3.1 easy_debounce: ^2.0.3 badges: ^3.1.2 google_fonts: ^6.2.1 - location: ^6.0.2 - syncfusion_flutter_charts: ^27.1.51 + location: ^7.0.1 + syncfusion_flutter_charts: ^27.1.55 table_calendar: ^3.1.2 flutter_keyboard_visibility: ^6.0.0 - share_plus: ^10.0.2 + share_plus: ^10.1.0 flutter_html: ^3.0.0-beta.2 - file_picker: ^8.1.2 + file_picker: ^8.1.3 audioplayers: ^6.1.0 intl: ^0.19.0 - rive: ^0.13.14 + rive: ^0.13.15 mask_text_input_formatter: ^2.9.0 lottie: ^3.1.3 @@ -55,7 +55,7 @@ dev_dependencies: build_runner: ^2.4.13 freezed: ^2.5.7 json_serializable: ^6.8.0 - retrofit_generator: ^9.1.2 + retrofit_generator: ^9.1.3 flutter_test: sdk: flutter