forked from eatvio/eatvio_app
Merge remote-tracking branch 'refs/remotes/origin/diary_refactor'
# Conflicts: # lib/app_router.dart # lib/features/blog_post_create/presentation/pages/blog_post_create_screen.dart # lib/features/blog_post_create/services/blog_service.dart # lib/features/calendar/services/calendar_service.g.dart # lib/features/diary/presentation/bloc/diary_cubit.dart # lib/features/diary/presentation/bloc/diary_event.dart # lib/features/diary/presentation/bloc/diary_state.dart # lib/features/diary/presentation/pages/diary_screen.dart # lib/features/diary/repositories/diary_repository.dart # lib/features/diary/services/diary_service.dart # lib/locator_service.dart # lib/presentation/diary/diary_edit_screen/bloc/diary_edit_bloc.dart # lib/presentation/diary/diary_edit_screen/diary_edit_screen.dart # lib/presentation/feed/blog_post_create_screen/models/blog_post_create_credentials_model.freezed.dart # lib/presentation/feed/blog_post_create_screen/models/blog_post_create_credentials_model.g.dart # pubspec.yaml
This commit is contained in:
@@ -1,25 +1,37 @@
|
||||
import 'package:eatvio_app/core/initialization_cubit/initialization_cubit.dart';
|
||||
import 'package:eatvio_app/core/token_storage.dart';
|
||||
import 'package:eatvio_app/features/blog_post/presentation/pages/blog_post_screen.dart';
|
||||
import 'package:eatvio_app/features/blog_post_create/presentation/pages/blog_post_create_screen.dart';
|
||||
import 'package:eatvio_app/features/bottom_navigation_bar/presentation/widgets/bottom_navigation_bar_widget.dart';
|
||||
import 'package:eatvio_app/features/chat/presentation/pages/chat_screen.dart';
|
||||
import 'package:eatvio_app/features/chat/presentation/pages/chat_select_screen/chat_select_screen.dart';
|
||||
import 'package:eatvio_app/features/chat/presentation/pages/photo_view_screen.dart';
|
||||
import 'package:eatvio_app/features/feed/presentation/pages/feed_screen.dart';
|
||||
import 'package:eatvio_app/features/registration/presentation/pages/registration_screen.dart';
|
||||
import 'package:eatvio_app/presentation/auth/auth_screen/auth_screen.dart';
|
||||
import 'package:eatvio_app/presentation/diary/diary_edit_screen/diary_edit_screen.dart';
|
||||
import 'package:eatvio_app/presentation/diets/diet_create_screen/diet_create_screen.dart';
|
||||
import 'package:eatvio_app/presentation/diets/diet_select_screen/diet_select_screen.dart';
|
||||
import 'package:eatvio_app/features/blog_post_create/presentation/pages/blog_post_create_screen.dart';
|
||||
import 'package:eatvio_app/presentation/feed/blog_post_edit_screen/blog_post_edit_screen.dart';
|
||||
import 'package:eatvio_app/features/blog_post/presentation/pages/blog_post_screen.dart';
|
||||
import 'package:eatvio_app/features/feed/presentation/pages/feed_screen.dart';
|
||||
import 'package:eatvio_app/presentation/glossary/glossary_screen/glossary_screen.dart';
|
||||
import 'package:eatvio_app/presentation/plans/plan_select_screen/plan_select_screen.dart';
|
||||
import 'package:eatvio_app/presentation/profile/my_profile_screen/my_profile_screen.dart';
|
||||
import 'package:eatvio_app/presentation/profile/my_profile_screen/my_settings_screen.dart';
|
||||
import 'package:eatvio_app/presentation/recipe/recipe_select_screen/recipe_select_screen.dart';
|
||||
import 'package:eatvio_app/presentation/registration/additional_information_screen/additional_information_screen.dart';
|
||||
import 'package:eatvio_app/presentation/registration/allergies_screen/allergies_screen.dart';
|
||||
import 'package:eatvio_app/presentation/registration/blood_pressure_screen/blood_pressure_screen.dart';
|
||||
import 'package:eatvio_app/presentation/registration/body_circumferences_screen/body_circumferences_screen.dart';
|
||||
import 'package:eatvio_app/presentation/registration/city_of_living_screen/city_of_living_screen.dart';
|
||||
import 'package:eatvio_app/presentation/registration/credentials_screen/credentials_screen.dart';
|
||||
import 'package:eatvio_app/presentation/registration/date_of_birth_screen/date_of_birth_screen.dart';
|
||||
import 'package:eatvio_app/presentation/registration/favorite_foods_screen/favorite_foods_screen.dart';
|
||||
import 'package:eatvio_app/presentation/registration/favorite_sports_screen/favorite_sports_screen.dart';
|
||||
import 'package:eatvio_app/presentation/registration/gender_screen/gender_screen.dart';
|
||||
import 'package:eatvio_app/presentation/registration/height_screen/height_screen.dart';
|
||||
import 'package:eatvio_app/presentation/registration/language_select_screen/language_select_screen.dart';
|
||||
import 'package:eatvio_app/presentation/registration/medicine_intake_screen/medicine_intake_screen.dart';
|
||||
import 'package:eatvio_app/presentation/registration/name_screen/name_screen.dart';
|
||||
import 'package:eatvio_app/presentation/registration/weight_screen/weight_screen.dart';
|
||||
import 'package:eatvio_app/widgets/bottom_navigation_bar_widget.dart';
|
||||
import 'package:eatvio_app/features/chat/presentation/pages/photo_view_screen.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
|
||||
class AppRouter {
|
||||
@@ -91,7 +103,7 @@ class AppRouter {
|
||||
GoRoute(
|
||||
path: '/diary-screen',
|
||||
name: 'diaryScreen',
|
||||
builder: (context, state) => DiaryEditScreen(),
|
||||
builder: (context, state) => DiaryScreen(),
|
||||
),
|
||||
GoRoute(
|
||||
path: '/chat-select-screen',
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
/*
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
||||
part '../../../presentation/feed/blog_post_create_screen/models/blog_post_create_credentials_model.freezed.dart';
|
||||
@@ -14,3 +15,4 @@ class BlogPostCreateCredentialsModel with _$BlogPostCreateCredentialsModel {
|
||||
|
||||
factory BlogPostCreateCredentialsModel.fromJson(Map<String, Object?> json) => _$BlogPostCreateCredentialsModelFromJson(json);
|
||||
}
|
||||
*/
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:eatvio_app/core/app_export.dart';
|
||||
import 'package:eatvio_app/widgets/custom_outlined_button.dart';
|
||||
import 'package:eatvio_app/widgets/custom_text_form_field.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:image_picker/image_picker.dart';
|
||||
|
||||
/*
|
||||
import '../../../../presentation/feed/blog_post_create_screen/bloc/blog_post_create_bloc.dart';
|
||||
import '../../../../presentation/feed/blog_post_create_screen/models/blog_post_create_model.dart';
|
||||
import 'package:eatvio_app/core/app_export.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:image_picker/image_picker.dart';
|
||||
import 'package:eatvio_app/widgets/custom_text_form_field.dart';
|
||||
import 'package:eatvio_app/widgets/custom_outlined_button.dart';
|
||||
import 'dart:io';
|
||||
|
||||
class BlogPostCreateScreen extends StatelessWidget {
|
||||
const BlogPostCreateScreen({Key? key}) : super(key: key);
|
||||
@@ -15,7 +14,9 @@ class BlogPostCreateScreen extends StatelessWidget {
|
||||
static Widget builder(BuildContext context) {
|
||||
final blog_postID = ModalRoute.of(context)!.settings.arguments;
|
||||
return BlocProvider<BlogPostCreateBloc>(
|
||||
create: (context) => BlogPostCreateBloc(BlogPostCreateState(blog_postModelObj: BlogPostCreateModel(blog_postID: blog_postID.toString())))
|
||||
create: (context) => BlogPostCreateBloc(BlogPostCreateState(
|
||||
blog_postModelObj:
|
||||
BlogPostCreateModel(blog_postID: blog_postID.toString())))
|
||||
..add(BlogPostCreateInitialEvent()),
|
||||
child: BlogPostCreateScreen(),
|
||||
);
|
||||
@@ -77,13 +78,15 @@ class BlogPostCreateScreen extends StatelessWidget {
|
||||
children: [
|
||||
Column(
|
||||
children: <Widget>[
|
||||
Text("Заголовок новости", style: theme.textTheme.bodyLarge),
|
||||
Text("Заголовок новости",
|
||||
style: theme.textTheme.bodyLarge),
|
||||
CustomTextFormField(
|
||||
controller: state.title,
|
||||
validator: _validateTitle,
|
||||
),
|
||||
SizedBox(height: 8.0),
|
||||
Text("Ссылка на YouTube", style: theme.textTheme.bodyLarge),
|
||||
Text("Ссылка на YouTube",
|
||||
style: theme.textTheme.bodyLarge),
|
||||
CustomTextFormField(
|
||||
controller: state.youtubeURL,
|
||||
validator: _validateYouTubeLink,
|
||||
@@ -100,7 +103,8 @@ class BlogPostCreateScreen extends StatelessWidget {
|
||||
SizedBox(height: 16.0),
|
||||
// Add widget for image upload here
|
||||
CustomOutlinedButton(
|
||||
onPressed: () => _submitForm(context, state.title!.text, state.description!.text, state.youtubeURL!.text),
|
||||
onPressed: () => _submitForm(context, state.title!.text,
|
||||
state.description!.text, state.youtubeURL!.text),
|
||||
buttonStyle: CustomButtonStyles.outlinePrimaryTL15,
|
||||
text: 'Создать',
|
||||
),
|
||||
@@ -116,16 +120,20 @@ class BlogPostCreateScreen extends StatelessWidget {
|
||||
}
|
||||
}
|
||||
|
||||
_submitForm(BuildContext context, String title, String description, String youtubeURL) {
|
||||
_submitForm(
|
||||
BuildContext context, String title, String description, String youtubeURL) {
|
||||
String? titleError = _validateTitle(title);
|
||||
String? descriptionError = _validateDescription(description);
|
||||
String? youtubeURLError = _validateYouTubeLink(youtubeURL);
|
||||
|
||||
if (titleError != null || descriptionError != null || youtubeURLError != null) {
|
||||
if (titleError != null ||
|
||||
descriptionError != null ||
|
||||
youtubeURLError != null) {
|
||||
// Display error messages or handle invalid input as needed
|
||||
// For example, show a snackbar with the error message
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(content: Text(titleError ?? descriptionError ?? youtubeURLError!)),
|
||||
SnackBar(
|
||||
content: Text(titleError ?? descriptionError ?? youtubeURLError!)),
|
||||
);
|
||||
} else {
|
||||
// Proceed with form submission
|
||||
@@ -226,6 +234,8 @@ String? _validateYouTubeLink(value) {
|
||||
}
|
||||
|
||||
bool _isValidUrl(String url) {
|
||||
final RegExp urlRegExp = new RegExp(r"^(http|https):\/\/([\w-]+\.)+[\w-]+(\/[\w-./?%&=]*)?$");
|
||||
final RegExp urlRegExp =
|
||||
new RegExp(r"^(http|https):\/\/([\w-]+\.)+[\w-]+(\/[\w-./?%&=]*)?$");
|
||||
return urlRegExp.hasMatch(url);
|
||||
}
|
||||
*/
|
||||
@@ -1,3 +1,4 @@
|
||||
/*
|
||||
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';
|
||||
|
||||
@@ -17,3 +18,4 @@ class BlogRepository {
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
@@ -1,5 +1,6 @@
|
||||
import 'package:dio/dio.dart';
|
||||
/*
|
||||
import 'package:eatvio_app/features/blog_post_create/models/blog_post_create_credentials_model.dart';
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:retrofit/retrofit.dart';
|
||||
|
||||
part 'blog_service.g.dart';
|
||||
@@ -8,6 +9,8 @@ part 'blog_service.g.dart';
|
||||
abstract class BlogService {
|
||||
factory BlogService(Dio dio, {String baseUrl}) = _BlogService;
|
||||
|
||||
@POST('/api/blog_post/create')
|
||||
Future<BlogPostCreateCredentialsModel> createBlogPost(BlogPostCreateCredentialsModel model);
|
||||
@POST('/blog_post/create')
|
||||
Future<BlogPostCreateCredentialsModel> createBlogPost(
|
||||
BlogPostCreateCredentialsModel model);
|
||||
}
|
||||
*/
|
||||
21
lib/features/calendar/models/calendar_model.dart
Normal file
21
lib/features/calendar/models/calendar_model.dart
Normal file
@@ -0,0 +1,21 @@
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
||||
part 'calendar_model.freezed.dart';
|
||||
part 'calendar_model.g.dart';
|
||||
|
||||
@freezed
|
||||
class CalendarModel with _$CalendarModel {
|
||||
const factory CalendarModel({
|
||||
required int id,
|
||||
required String state,
|
||||
required String image,
|
||||
required String description,
|
||||
@JsonKey(name: "youtube_url") required String youtubeUrl,
|
||||
@JsonKey(name: "created_at") required DateTime createdAt,
|
||||
@JsonKey(name: "updated_at") required DateTime updatedAt,
|
||||
required String title,
|
||||
}) = _CalendarModel;
|
||||
|
||||
factory CalendarModel.fromJson(Map<String, Object?> json) =>
|
||||
_$CalendarModelFromJson(json);
|
||||
}
|
||||
309
lib/features/calendar/models/calendar_model.freezed.dart
Normal file
309
lib/features/calendar/models/calendar_model.freezed.dart
Normal file
@@ -0,0 +1,309 @@
|
||||
// coverage:ignore-file
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
// ignore_for_file: type=lint
|
||||
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark
|
||||
|
||||
part of 'calendar_model.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// FreezedGenerator
|
||||
// **************************************************************************
|
||||
|
||||
T _$identity<T>(T value) => value;
|
||||
|
||||
final _privateConstructorUsedError = UnsupportedError(
|
||||
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models');
|
||||
|
||||
CalendarModel _$CalendarModelFromJson(Map<String, dynamic> json) {
|
||||
return _CalendarModel.fromJson(json);
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
mixin _$CalendarModel {
|
||||
int get id => throw _privateConstructorUsedError;
|
||||
String get state => throw _privateConstructorUsedError;
|
||||
String get image => throw _privateConstructorUsedError;
|
||||
String get description => throw _privateConstructorUsedError;
|
||||
@JsonKey(name: "youtube_url")
|
||||
String get youtubeUrl => throw _privateConstructorUsedError;
|
||||
@JsonKey(name: "created_at")
|
||||
DateTime get createdAt => throw _privateConstructorUsedError;
|
||||
@JsonKey(name: "updated_at")
|
||||
DateTime get updatedAt => throw _privateConstructorUsedError;
|
||||
String get title => throw _privateConstructorUsedError;
|
||||
|
||||
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
|
||||
@JsonKey(ignore: true)
|
||||
$CalendarModelCopyWith<CalendarModel> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class $CalendarModelCopyWith<$Res> {
|
||||
factory $CalendarModelCopyWith(
|
||||
CalendarModel value, $Res Function(CalendarModel) then) =
|
||||
_$CalendarModelCopyWithImpl<$Res, CalendarModel>;
|
||||
@useResult
|
||||
$Res call(
|
||||
{int id,
|
||||
String state,
|
||||
String image,
|
||||
String description,
|
||||
@JsonKey(name: "youtube_url") String youtubeUrl,
|
||||
@JsonKey(name: "created_at") DateTime createdAt,
|
||||
@JsonKey(name: "updated_at") DateTime updatedAt,
|
||||
String title});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class _$CalendarModelCopyWithImpl<$Res, $Val extends CalendarModel>
|
||||
implements $CalendarModelCopyWith<$Res> {
|
||||
_$CalendarModelCopyWithImpl(this._value, this._then);
|
||||
|
||||
// ignore: unused_field
|
||||
final $Val _value;
|
||||
// ignore: unused_field
|
||||
final $Res Function($Val) _then;
|
||||
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? id = null,
|
||||
Object? state = null,
|
||||
Object? image = null,
|
||||
Object? description = null,
|
||||
Object? youtubeUrl = null,
|
||||
Object? createdAt = null,
|
||||
Object? updatedAt = null,
|
||||
Object? title = null,
|
||||
}) {
|
||||
return _then(_value.copyWith(
|
||||
id: null == id
|
||||
? _value.id
|
||||
: id // ignore: cast_nullable_to_non_nullable
|
||||
as int,
|
||||
state: null == state
|
||||
? _value.state
|
||||
: state // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
image: null == image
|
||||
? _value.image
|
||||
: image // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
description: null == description
|
||||
? _value.description
|
||||
: description // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
youtubeUrl: null == youtubeUrl
|
||||
? _value.youtubeUrl
|
||||
: youtubeUrl // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
createdAt: null == createdAt
|
||||
? _value.createdAt
|
||||
: createdAt // ignore: cast_nullable_to_non_nullable
|
||||
as DateTime,
|
||||
updatedAt: null == updatedAt
|
||||
? _value.updatedAt
|
||||
: updatedAt // ignore: cast_nullable_to_non_nullable
|
||||
as DateTime,
|
||||
title: null == title
|
||||
? _value.title
|
||||
: title // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
) as $Val);
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$CalendarModelImplCopyWith<$Res>
|
||||
implements $CalendarModelCopyWith<$Res> {
|
||||
factory _$$CalendarModelImplCopyWith(
|
||||
_$CalendarModelImpl value, $Res Function(_$CalendarModelImpl) then) =
|
||||
__$$CalendarModelImplCopyWithImpl<$Res>;
|
||||
@override
|
||||
@useResult
|
||||
$Res call(
|
||||
{int id,
|
||||
String state,
|
||||
String image,
|
||||
String description,
|
||||
@JsonKey(name: "youtube_url") String youtubeUrl,
|
||||
@JsonKey(name: "created_at") DateTime createdAt,
|
||||
@JsonKey(name: "updated_at") DateTime updatedAt,
|
||||
String title});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$CalendarModelImplCopyWithImpl<$Res>
|
||||
extends _$CalendarModelCopyWithImpl<$Res, _$CalendarModelImpl>
|
||||
implements _$$CalendarModelImplCopyWith<$Res> {
|
||||
__$$CalendarModelImplCopyWithImpl(
|
||||
_$CalendarModelImpl _value, $Res Function(_$CalendarModelImpl) _then)
|
||||
: super(_value, _then);
|
||||
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? id = null,
|
||||
Object? state = null,
|
||||
Object? image = null,
|
||||
Object? description = null,
|
||||
Object? youtubeUrl = null,
|
||||
Object? createdAt = null,
|
||||
Object? updatedAt = null,
|
||||
Object? title = null,
|
||||
}) {
|
||||
return _then(_$CalendarModelImpl(
|
||||
id: null == id
|
||||
? _value.id
|
||||
: id // ignore: cast_nullable_to_non_nullable
|
||||
as int,
|
||||
state: null == state
|
||||
? _value.state
|
||||
: state // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
image: null == image
|
||||
? _value.image
|
||||
: image // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
description: null == description
|
||||
? _value.description
|
||||
: description // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
youtubeUrl: null == youtubeUrl
|
||||
? _value.youtubeUrl
|
||||
: youtubeUrl // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
createdAt: null == createdAt
|
||||
? _value.createdAt
|
||||
: createdAt // ignore: cast_nullable_to_non_nullable
|
||||
as DateTime,
|
||||
updatedAt: null == updatedAt
|
||||
? _value.updatedAt
|
||||
: updatedAt // ignore: cast_nullable_to_non_nullable
|
||||
as DateTime,
|
||||
title: null == title
|
||||
? _value.title
|
||||
: title // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@JsonSerializable()
|
||||
class _$CalendarModelImpl implements _CalendarModel {
|
||||
const _$CalendarModelImpl(
|
||||
{required this.id,
|
||||
required this.state,
|
||||
required this.image,
|
||||
required this.description,
|
||||
@JsonKey(name: "youtube_url") required this.youtubeUrl,
|
||||
@JsonKey(name: "created_at") required this.createdAt,
|
||||
@JsonKey(name: "updated_at") required this.updatedAt,
|
||||
required this.title});
|
||||
|
||||
factory _$CalendarModelImpl.fromJson(Map<String, dynamic> json) =>
|
||||
_$$CalendarModelImplFromJson(json);
|
||||
|
||||
@override
|
||||
final int id;
|
||||
@override
|
||||
final String state;
|
||||
@override
|
||||
final String image;
|
||||
@override
|
||||
final String description;
|
||||
@override
|
||||
@JsonKey(name: "youtube_url")
|
||||
final String youtubeUrl;
|
||||
@override
|
||||
@JsonKey(name: "created_at")
|
||||
final DateTime createdAt;
|
||||
@override
|
||||
@JsonKey(name: "updated_at")
|
||||
final DateTime updatedAt;
|
||||
@override
|
||||
final String title;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'CalendarModel(id: $id, state: $state, image: $image, description: $description, youtubeUrl: $youtubeUrl, createdAt: $createdAt, updatedAt: $updatedAt, title: $title)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$CalendarModelImpl &&
|
||||
(identical(other.id, id) || other.id == id) &&
|
||||
(identical(other.state, state) || other.state == state) &&
|
||||
(identical(other.image, image) || other.image == image) &&
|
||||
(identical(other.description, description) ||
|
||||
other.description == description) &&
|
||||
(identical(other.youtubeUrl, youtubeUrl) ||
|
||||
other.youtubeUrl == youtubeUrl) &&
|
||||
(identical(other.createdAt, createdAt) ||
|
||||
other.createdAt == createdAt) &&
|
||||
(identical(other.updatedAt, updatedAt) ||
|
||||
other.updatedAt == updatedAt) &&
|
||||
(identical(other.title, title) || other.title == title));
|
||||
}
|
||||
|
||||
@JsonKey(ignore: true)
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType, id, state, image, description,
|
||||
youtubeUrl, createdAt, updatedAt, title);
|
||||
|
||||
@JsonKey(ignore: true)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$CalendarModelImplCopyWith<_$CalendarModelImpl> get copyWith =>
|
||||
__$$CalendarModelImplCopyWithImpl<_$CalendarModelImpl>(this, _$identity);
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
return _$$CalendarModelImplToJson(
|
||||
this,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
abstract class _CalendarModel implements CalendarModel {
|
||||
const factory _CalendarModel(
|
||||
{required final int id,
|
||||
required final String state,
|
||||
required final String image,
|
||||
required final String description,
|
||||
@JsonKey(name: "youtube_url") required final String youtubeUrl,
|
||||
@JsonKey(name: "created_at") required final DateTime createdAt,
|
||||
@JsonKey(name: "updated_at") required final DateTime updatedAt,
|
||||
required final String title}) = _$CalendarModelImpl;
|
||||
|
||||
factory _CalendarModel.fromJson(Map<String, dynamic> json) =
|
||||
_$CalendarModelImpl.fromJson;
|
||||
|
||||
@override
|
||||
int get id;
|
||||
@override
|
||||
String get state;
|
||||
@override
|
||||
String get image;
|
||||
@override
|
||||
String get description;
|
||||
@override
|
||||
@JsonKey(name: "youtube_url")
|
||||
String get youtubeUrl;
|
||||
@override
|
||||
@JsonKey(name: "created_at")
|
||||
DateTime get createdAt;
|
||||
@override
|
||||
@JsonKey(name: "updated_at")
|
||||
DateTime get updatedAt;
|
||||
@override
|
||||
String get title;
|
||||
@override
|
||||
@JsonKey(ignore: true)
|
||||
_$$CalendarModelImplCopyWith<_$CalendarModelImpl> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
31
lib/features/calendar/models/calendar_model.g.dart
Normal file
31
lib/features/calendar/models/calendar_model.g.dart
Normal file
@@ -0,0 +1,31 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'calendar_model.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
_$CalendarModelImpl _$$CalendarModelImplFromJson(Map<String, dynamic> json) =>
|
||||
_$CalendarModelImpl(
|
||||
id: (json['id'] as num).toInt(),
|
||||
state: json['state'] as String,
|
||||
image: json['image'] as String,
|
||||
description: json['description'] as String,
|
||||
youtubeUrl: json['youtube_url'] as String,
|
||||
createdAt: DateTime.parse(json['created_at'] as String),
|
||||
updatedAt: DateTime.parse(json['updated_at'] as String),
|
||||
title: json['title'] as String,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$$CalendarModelImplToJson(_$CalendarModelImpl instance) =>
|
||||
<String, dynamic>{
|
||||
'id': instance.id,
|
||||
'state': instance.state,
|
||||
'image': instance.image,
|
||||
'description': instance.description,
|
||||
'youtube_url': instance.youtubeUrl,
|
||||
'created_at': instance.createdAt.toIso8601String(),
|
||||
'updated_at': instance.updatedAt.toIso8601String(),
|
||||
'title': instance.title,
|
||||
};
|
||||
20
lib/features/calendar/presentation/bloc/calendar_cubit.dart
Normal file
20
lib/features/calendar/presentation/bloc/calendar_cubit.dart
Normal file
@@ -0,0 +1,20 @@
|
||||
import 'package:eatvio_app/core/app_export.dart';
|
||||
import 'package:eatvio_app/features/calendar/presentation/bloc/calendar_state.dart';
|
||||
import 'package:eatvio_app/features/calendar/repositories/calendar_repository.dart';
|
||||
|
||||
class CalendarCubit extends Cubit<CalendarState> {
|
||||
final CalendarRepository calendarRepository;
|
||||
|
||||
CalendarCubit({required this.calendarRepository})
|
||||
: super(const CalendarState.loading());
|
||||
|
||||
loadCalendarList() async {
|
||||
emit(const CalendarState.loading());
|
||||
try {
|
||||
final calendarList = await calendarRepository.getCalendar();
|
||||
emit(CalendarState.loaded(calendarList: calendarList));
|
||||
} catch (e) {
|
||||
emit(CalendarState.error(errorMessage: e.toString()));
|
||||
}
|
||||
}
|
||||
}
|
||||
19
lib/features/calendar/presentation/bloc/calendar_state.dart
Normal file
19
lib/features/calendar/presentation/bloc/calendar_state.dart
Normal file
@@ -0,0 +1,19 @@
|
||||
import 'package:eatvio_app/features/calendar/models/calendar_model.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
||||
part 'calendar_state.freezed.dart';
|
||||
|
||||
@freezed
|
||||
abstract class CalendarState with _$CalendarState {
|
||||
const factory CalendarState() = _CalendarState;
|
||||
|
||||
const factory CalendarState.loading() = CalendarStateLoading;
|
||||
|
||||
const factory CalendarState.loaded({
|
||||
required List<CalendarModel> calendarList,
|
||||
}) = CalendarStateLoaded;
|
||||
|
||||
const factory CalendarState.error({
|
||||
required String errorMessage,
|
||||
}) = CalendarStateError;
|
||||
}
|
||||
@@ -0,0 +1,621 @@
|
||||
// coverage:ignore-file
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
// ignore_for_file: type=lint
|
||||
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark
|
||||
|
||||
part of 'calendar_state.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// FreezedGenerator
|
||||
// **************************************************************************
|
||||
|
||||
T _$identity<T>(T value) => value;
|
||||
|
||||
final _privateConstructorUsedError = UnsupportedError(
|
||||
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models');
|
||||
|
||||
/// @nodoc
|
||||
mixin _$CalendarState {
|
||||
@optionalTypeArgs
|
||||
TResult when<TResult extends Object?>(
|
||||
TResult Function() $default, {
|
||||
required TResult Function() loading,
|
||||
required TResult Function(List<CalendarModel> calendarList) loaded,
|
||||
required TResult Function(String errorMessage) error,
|
||||
}) =>
|
||||
throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult? whenOrNull<TResult extends Object?>(
|
||||
TResult? Function()? $default, {
|
||||
TResult? Function()? loading,
|
||||
TResult? Function(List<CalendarModel> calendarList)? loaded,
|
||||
TResult? Function(String errorMessage)? error,
|
||||
}) =>
|
||||
throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult maybeWhen<TResult extends Object?>(
|
||||
TResult Function()? $default, {
|
||||
TResult Function()? loading,
|
||||
TResult Function(List<CalendarModel> calendarList)? loaded,
|
||||
TResult Function(String errorMessage)? error,
|
||||
required TResult orElse(),
|
||||
}) =>
|
||||
throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult map<TResult extends Object?>(
|
||||
TResult Function(_CalendarState value) $default, {
|
||||
required TResult Function(CalendarStateLoading value) loading,
|
||||
required TResult Function(CalendarStateLoaded value) loaded,
|
||||
required TResult Function(CalendarStateError value) error,
|
||||
}) =>
|
||||
throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult? mapOrNull<TResult extends Object?>(
|
||||
TResult? Function(_CalendarState value)? $default, {
|
||||
TResult? Function(CalendarStateLoading value)? loading,
|
||||
TResult? Function(CalendarStateLoaded value)? loaded,
|
||||
TResult? Function(CalendarStateError value)? error,
|
||||
}) =>
|
||||
throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult maybeMap<TResult extends Object?>(
|
||||
TResult Function(_CalendarState value)? $default, {
|
||||
TResult Function(CalendarStateLoading value)? loading,
|
||||
TResult Function(CalendarStateLoaded value)? loaded,
|
||||
TResult Function(CalendarStateError value)? error,
|
||||
required TResult orElse(),
|
||||
}) =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class $CalendarStateCopyWith<$Res> {
|
||||
factory $CalendarStateCopyWith(
|
||||
CalendarState value, $Res Function(CalendarState) then) =
|
||||
_$CalendarStateCopyWithImpl<$Res, CalendarState>;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class _$CalendarStateCopyWithImpl<$Res, $Val extends CalendarState>
|
||||
implements $CalendarStateCopyWith<$Res> {
|
||||
_$CalendarStateCopyWithImpl(this._value, this._then);
|
||||
|
||||
// ignore: unused_field
|
||||
final $Val _value;
|
||||
// ignore: unused_field
|
||||
final $Res Function($Val) _then;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$CalendarStateImplCopyWith<$Res> {
|
||||
factory _$$CalendarStateImplCopyWith(
|
||||
_$CalendarStateImpl value, $Res Function(_$CalendarStateImpl) then) =
|
||||
__$$CalendarStateImplCopyWithImpl<$Res>;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$CalendarStateImplCopyWithImpl<$Res>
|
||||
extends _$CalendarStateCopyWithImpl<$Res, _$CalendarStateImpl>
|
||||
implements _$$CalendarStateImplCopyWith<$Res> {
|
||||
__$$CalendarStateImplCopyWithImpl(
|
||||
_$CalendarStateImpl _value, $Res Function(_$CalendarStateImpl) _then)
|
||||
: super(_value, _then);
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
class _$CalendarStateImpl implements _CalendarState {
|
||||
const _$CalendarStateImpl();
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'CalendarState()';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType && other is _$CalendarStateImpl);
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => runtimeType.hashCode;
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult when<TResult extends Object?>(
|
||||
TResult Function() $default, {
|
||||
required TResult Function() loading,
|
||||
required TResult Function(List<CalendarModel> calendarList) loaded,
|
||||
required TResult Function(String errorMessage) error,
|
||||
}) {
|
||||
return $default();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? whenOrNull<TResult extends Object?>(
|
||||
TResult? Function()? $default, {
|
||||
TResult? Function()? loading,
|
||||
TResult? Function(List<CalendarModel> calendarList)? loaded,
|
||||
TResult? Function(String errorMessage)? error,
|
||||
}) {
|
||||
return $default?.call();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeWhen<TResult extends Object?>(
|
||||
TResult Function()? $default, {
|
||||
TResult Function()? loading,
|
||||
TResult Function(List<CalendarModel> calendarList)? loaded,
|
||||
TResult Function(String errorMessage)? error,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if ($default != null) {
|
||||
return $default();
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult map<TResult extends Object?>(
|
||||
TResult Function(_CalendarState value) $default, {
|
||||
required TResult Function(CalendarStateLoading value) loading,
|
||||
required TResult Function(CalendarStateLoaded value) loaded,
|
||||
required TResult Function(CalendarStateError value) error,
|
||||
}) {
|
||||
return $default(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? mapOrNull<TResult extends Object?>(
|
||||
TResult? Function(_CalendarState value)? $default, {
|
||||
TResult? Function(CalendarStateLoading value)? loading,
|
||||
TResult? Function(CalendarStateLoaded value)? loaded,
|
||||
TResult? Function(CalendarStateError value)? error,
|
||||
}) {
|
||||
return $default?.call(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeMap<TResult extends Object?>(
|
||||
TResult Function(_CalendarState value)? $default, {
|
||||
TResult Function(CalendarStateLoading value)? loading,
|
||||
TResult Function(CalendarStateLoaded value)? loaded,
|
||||
TResult Function(CalendarStateError value)? error,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if ($default != null) {
|
||||
return $default(this);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
}
|
||||
|
||||
abstract class _CalendarState implements CalendarState {
|
||||
const factory _CalendarState() = _$CalendarStateImpl;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$CalendarStateLoadingImplCopyWith<$Res> {
|
||||
factory _$$CalendarStateLoadingImplCopyWith(_$CalendarStateLoadingImpl value,
|
||||
$Res Function(_$CalendarStateLoadingImpl) then) =
|
||||
__$$CalendarStateLoadingImplCopyWithImpl<$Res>;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$CalendarStateLoadingImplCopyWithImpl<$Res>
|
||||
extends _$CalendarStateCopyWithImpl<$Res, _$CalendarStateLoadingImpl>
|
||||
implements _$$CalendarStateLoadingImplCopyWith<$Res> {
|
||||
__$$CalendarStateLoadingImplCopyWithImpl(_$CalendarStateLoadingImpl _value,
|
||||
$Res Function(_$CalendarStateLoadingImpl) _then)
|
||||
: super(_value, _then);
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
class _$CalendarStateLoadingImpl implements CalendarStateLoading {
|
||||
const _$CalendarStateLoadingImpl();
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'CalendarState.loading()';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$CalendarStateLoadingImpl);
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => runtimeType.hashCode;
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult when<TResult extends Object?>(
|
||||
TResult Function() $default, {
|
||||
required TResult Function() loading,
|
||||
required TResult Function(List<CalendarModel> calendarList) loaded,
|
||||
required TResult Function(String errorMessage) error,
|
||||
}) {
|
||||
return loading();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? whenOrNull<TResult extends Object?>(
|
||||
TResult? Function()? $default, {
|
||||
TResult? Function()? loading,
|
||||
TResult? Function(List<CalendarModel> calendarList)? loaded,
|
||||
TResult? Function(String errorMessage)? error,
|
||||
}) {
|
||||
return loading?.call();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeWhen<TResult extends Object?>(
|
||||
TResult Function()? $default, {
|
||||
TResult Function()? loading,
|
||||
TResult Function(List<CalendarModel> calendarList)? loaded,
|
||||
TResult Function(String errorMessage)? error,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (loading != null) {
|
||||
return loading();
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult map<TResult extends Object?>(
|
||||
TResult Function(_CalendarState value) $default, {
|
||||
required TResult Function(CalendarStateLoading value) loading,
|
||||
required TResult Function(CalendarStateLoaded value) loaded,
|
||||
required TResult Function(CalendarStateError value) error,
|
||||
}) {
|
||||
return loading(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? mapOrNull<TResult extends Object?>(
|
||||
TResult? Function(_CalendarState value)? $default, {
|
||||
TResult? Function(CalendarStateLoading value)? loading,
|
||||
TResult? Function(CalendarStateLoaded value)? loaded,
|
||||
TResult? Function(CalendarStateError value)? error,
|
||||
}) {
|
||||
return loading?.call(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeMap<TResult extends Object?>(
|
||||
TResult Function(_CalendarState value)? $default, {
|
||||
TResult Function(CalendarStateLoading value)? loading,
|
||||
TResult Function(CalendarStateLoaded value)? loaded,
|
||||
TResult Function(CalendarStateError value)? error,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (loading != null) {
|
||||
return loading(this);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
}
|
||||
|
||||
abstract class CalendarStateLoading implements CalendarState {
|
||||
const factory CalendarStateLoading() = _$CalendarStateLoadingImpl;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$CalendarStateLoadedImplCopyWith<$Res> {
|
||||
factory _$$CalendarStateLoadedImplCopyWith(_$CalendarStateLoadedImpl value,
|
||||
$Res Function(_$CalendarStateLoadedImpl) then) =
|
||||
__$$CalendarStateLoadedImplCopyWithImpl<$Res>;
|
||||
@useResult
|
||||
$Res call({List<CalendarModel> calendarList});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$CalendarStateLoadedImplCopyWithImpl<$Res>
|
||||
extends _$CalendarStateCopyWithImpl<$Res, _$CalendarStateLoadedImpl>
|
||||
implements _$$CalendarStateLoadedImplCopyWith<$Res> {
|
||||
__$$CalendarStateLoadedImplCopyWithImpl(_$CalendarStateLoadedImpl _value,
|
||||
$Res Function(_$CalendarStateLoadedImpl) _then)
|
||||
: super(_value, _then);
|
||||
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? calendarList = null,
|
||||
}) {
|
||||
return _then(_$CalendarStateLoadedImpl(
|
||||
calendarList: null == calendarList
|
||||
? _value._calendarList
|
||||
: calendarList // ignore: cast_nullable_to_non_nullable
|
||||
as List<CalendarModel>,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
class _$CalendarStateLoadedImpl implements CalendarStateLoaded {
|
||||
const _$CalendarStateLoadedImpl(
|
||||
{required final List<CalendarModel> calendarList})
|
||||
: _calendarList = calendarList;
|
||||
|
||||
final List<CalendarModel> _calendarList;
|
||||
@override
|
||||
List<CalendarModel> get calendarList {
|
||||
if (_calendarList is EqualUnmodifiableListView) return _calendarList;
|
||||
// ignore: implicit_dynamic_type
|
||||
return EqualUnmodifiableListView(_calendarList);
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'CalendarState.loaded(calendarList: $calendarList)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$CalendarStateLoadedImpl &&
|
||||
const DeepCollectionEquality()
|
||||
.equals(other._calendarList, _calendarList));
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(
|
||||
runtimeType, const DeepCollectionEquality().hash(_calendarList));
|
||||
|
||||
@JsonKey(ignore: true)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$CalendarStateLoadedImplCopyWith<_$CalendarStateLoadedImpl> get copyWith =>
|
||||
__$$CalendarStateLoadedImplCopyWithImpl<_$CalendarStateLoadedImpl>(
|
||||
this, _$identity);
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult when<TResult extends Object?>(
|
||||
TResult Function() $default, {
|
||||
required TResult Function() loading,
|
||||
required TResult Function(List<CalendarModel> calendarList) loaded,
|
||||
required TResult Function(String errorMessage) error,
|
||||
}) {
|
||||
return loaded(calendarList);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? whenOrNull<TResult extends Object?>(
|
||||
TResult? Function()? $default, {
|
||||
TResult? Function()? loading,
|
||||
TResult? Function(List<CalendarModel> calendarList)? loaded,
|
||||
TResult? Function(String errorMessage)? error,
|
||||
}) {
|
||||
return loaded?.call(calendarList);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeWhen<TResult extends Object?>(
|
||||
TResult Function()? $default, {
|
||||
TResult Function()? loading,
|
||||
TResult Function(List<CalendarModel> calendarList)? loaded,
|
||||
TResult Function(String errorMessage)? error,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (loaded != null) {
|
||||
return loaded(calendarList);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult map<TResult extends Object?>(
|
||||
TResult Function(_CalendarState value) $default, {
|
||||
required TResult Function(CalendarStateLoading value) loading,
|
||||
required TResult Function(CalendarStateLoaded value) loaded,
|
||||
required TResult Function(CalendarStateError value) error,
|
||||
}) {
|
||||
return loaded(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? mapOrNull<TResult extends Object?>(
|
||||
TResult? Function(_CalendarState value)? $default, {
|
||||
TResult? Function(CalendarStateLoading value)? loading,
|
||||
TResult? Function(CalendarStateLoaded value)? loaded,
|
||||
TResult? Function(CalendarStateError value)? error,
|
||||
}) {
|
||||
return loaded?.call(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeMap<TResult extends Object?>(
|
||||
TResult Function(_CalendarState value)? $default, {
|
||||
TResult Function(CalendarStateLoading value)? loading,
|
||||
TResult Function(CalendarStateLoaded value)? loaded,
|
||||
TResult Function(CalendarStateError value)? error,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (loaded != null) {
|
||||
return loaded(this);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
}
|
||||
|
||||
abstract class CalendarStateLoaded implements CalendarState {
|
||||
const factory CalendarStateLoaded(
|
||||
{required final List<CalendarModel> calendarList}) =
|
||||
_$CalendarStateLoadedImpl;
|
||||
|
||||
List<CalendarModel> get calendarList;
|
||||
@JsonKey(ignore: true)
|
||||
_$$CalendarStateLoadedImplCopyWith<_$CalendarStateLoadedImpl> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$CalendarStateErrorImplCopyWith<$Res> {
|
||||
factory _$$CalendarStateErrorImplCopyWith(_$CalendarStateErrorImpl value,
|
||||
$Res Function(_$CalendarStateErrorImpl) then) =
|
||||
__$$CalendarStateErrorImplCopyWithImpl<$Res>;
|
||||
@useResult
|
||||
$Res call({String errorMessage});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$CalendarStateErrorImplCopyWithImpl<$Res>
|
||||
extends _$CalendarStateCopyWithImpl<$Res, _$CalendarStateErrorImpl>
|
||||
implements _$$CalendarStateErrorImplCopyWith<$Res> {
|
||||
__$$CalendarStateErrorImplCopyWithImpl(_$CalendarStateErrorImpl _value,
|
||||
$Res Function(_$CalendarStateErrorImpl) _then)
|
||||
: super(_value, _then);
|
||||
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? errorMessage = null,
|
||||
}) {
|
||||
return _then(_$CalendarStateErrorImpl(
|
||||
errorMessage: null == errorMessage
|
||||
? _value.errorMessage
|
||||
: errorMessage // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
class _$CalendarStateErrorImpl implements CalendarStateError {
|
||||
const _$CalendarStateErrorImpl({required this.errorMessage});
|
||||
|
||||
@override
|
||||
final String errorMessage;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'CalendarState.error(errorMessage: $errorMessage)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$CalendarStateErrorImpl &&
|
||||
(identical(other.errorMessage, errorMessage) ||
|
||||
other.errorMessage == errorMessage));
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType, errorMessage);
|
||||
|
||||
@JsonKey(ignore: true)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$CalendarStateErrorImplCopyWith<_$CalendarStateErrorImpl> get copyWith =>
|
||||
__$$CalendarStateErrorImplCopyWithImpl<_$CalendarStateErrorImpl>(
|
||||
this, _$identity);
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult when<TResult extends Object?>(
|
||||
TResult Function() $default, {
|
||||
required TResult Function() loading,
|
||||
required TResult Function(List<CalendarModel> calendarList) loaded,
|
||||
required TResult Function(String errorMessage) error,
|
||||
}) {
|
||||
return error(errorMessage);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? whenOrNull<TResult extends Object?>(
|
||||
TResult? Function()? $default, {
|
||||
TResult? Function()? loading,
|
||||
TResult? Function(List<CalendarModel> calendarList)? loaded,
|
||||
TResult? Function(String errorMessage)? error,
|
||||
}) {
|
||||
return error?.call(errorMessage);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeWhen<TResult extends Object?>(
|
||||
TResult Function()? $default, {
|
||||
TResult Function()? loading,
|
||||
TResult Function(List<CalendarModel> calendarList)? loaded,
|
||||
TResult Function(String errorMessage)? error,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (error != null) {
|
||||
return error(errorMessage);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult map<TResult extends Object?>(
|
||||
TResult Function(_CalendarState value) $default, {
|
||||
required TResult Function(CalendarStateLoading value) loading,
|
||||
required TResult Function(CalendarStateLoaded value) loaded,
|
||||
required TResult Function(CalendarStateError value) error,
|
||||
}) {
|
||||
return error(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? mapOrNull<TResult extends Object?>(
|
||||
TResult? Function(_CalendarState value)? $default, {
|
||||
TResult? Function(CalendarStateLoading value)? loading,
|
||||
TResult? Function(CalendarStateLoaded value)? loaded,
|
||||
TResult? Function(CalendarStateError value)? error,
|
||||
}) {
|
||||
return error?.call(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeMap<TResult extends Object?>(
|
||||
TResult Function(_CalendarState value)? $default, {
|
||||
TResult Function(CalendarStateLoading value)? loading,
|
||||
TResult Function(CalendarStateLoaded value)? loaded,
|
||||
TResult Function(CalendarStateError value)? error,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (error != null) {
|
||||
return error(this);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
}
|
||||
|
||||
abstract class CalendarStateError implements CalendarState {
|
||||
const factory CalendarStateError({required final String errorMessage}) =
|
||||
_$CalendarStateErrorImpl;
|
||||
|
||||
String get errorMessage;
|
||||
@JsonKey(ignore: true)
|
||||
_$$CalendarStateErrorImplCopyWith<_$CalendarStateErrorImpl> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
19
lib/features/calendar/repositories/calendar_repository.dart
Normal file
19
lib/features/calendar/repositories/calendar_repository.dart
Normal file
@@ -0,0 +1,19 @@
|
||||
import 'package:eatvio_app/features/calendar/models/calendar_model.dart';
|
||||
import 'package:eatvio_app/features/calendar/services/calendar_service.dart';
|
||||
|
||||
class CalendarRepository {
|
||||
final CalendarService calendarService;
|
||||
|
||||
CalendarRepository({required this.calendarService});
|
||||
|
||||
Future<List<CalendarModel>> getCalendar() async {
|
||||
try {
|
||||
return (await calendarService.getCalendar())
|
||||
.entries
|
||||
.map((entry) => entry.value)
|
||||
.toList();
|
||||
} catch (e) {
|
||||
rethrow;
|
||||
}
|
||||
}
|
||||
}
|
||||
13
lib/features/calendar/services/calendar_service.dart
Normal file
13
lib/features/calendar/services/calendar_service.dart
Normal file
@@ -0,0 +1,13 @@
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:eatvio_app/features/calendar/models/calendar_model.dart';
|
||||
import 'package:retrofit/retrofit.dart';
|
||||
|
||||
part 'calendar_service.g.dart';
|
||||
|
||||
@RestApi()
|
||||
abstract class CalendarService {
|
||||
factory CalendarService(Dio dio, {String baseUrl}) = _CalendarService;
|
||||
|
||||
@GET('/calendar/index')
|
||||
Future<Map<String, CalendarModel>> getCalendar();
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'blog_service.dart';
|
||||
part of 'calendar_service.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// RetrofitGenerator
|
||||
@@ -8,8 +8,8 @@ part of 'blog_service.dart';
|
||||
|
||||
// ignore_for_file: unnecessary_brace_in_string_interps,no_leading_underscores_for_local_identifiers,unused_element
|
||||
|
||||
class _BlogService implements BlogService {
|
||||
_BlogService(
|
||||
class _CalendarService implements CalendarService {
|
||||
_CalendarService(
|
||||
this._dio, {
|
||||
this.baseUrl,
|
||||
});
|
||||
@@ -19,21 +19,20 @@ class _BlogService implements BlogService {
|
||||
String? baseUrl;
|
||||
|
||||
@override
|
||||
Future<BlogPostCreateCredentialsModel> createBlogPost(
|
||||
BlogPostCreateCredentialsModel model) async {
|
||||
Future<Map<String, CalendarModel>> getCalendar() async {
|
||||
final _extra = <String, dynamic>{};
|
||||
final queryParameters = <String, dynamic>{};
|
||||
final _headers = <String, dynamic>{};
|
||||
const Map<String, dynamic>? _data = null;
|
||||
final _result = await _dio.fetch<Map<String, dynamic>>(
|
||||
_setStreamType<BlogPostCreateCredentialsModel>(Options(
|
||||
method: 'POST',
|
||||
_setStreamType<Map<String, CalendarModel>>(Options(
|
||||
method: 'GET',
|
||||
headers: _headers,
|
||||
extra: _extra,
|
||||
)
|
||||
.compose(
|
||||
_dio.options,
|
||||
'/api/blog_post/create',
|
||||
'/calendar/index',
|
||||
queryParameters: queryParameters,
|
||||
data: _data,
|
||||
)
|
||||
@@ -42,7 +41,8 @@ class _BlogService implements BlogService {
|
||||
_dio.options.baseUrl,
|
||||
baseUrl,
|
||||
))));
|
||||
final _value = BlogPostCreateCredentialsModel.fromJson(_result.data!);
|
||||
var _value = _result.data!.map((k, dynamic v) =>
|
||||
MapEntry(k, CalendarModel.fromJson(v as Map<String, dynamic>)));
|
||||
return _value;
|
||||
}
|
||||
|
||||
@@ -1,116 +1,21 @@
|
||||
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 DateTime wakeup,
|
||||
required DateTime retire,
|
||||
required int closed,
|
||||
required String comment,
|
||||
required List<Meals> meals}) = _DiaryModel;
|
||||
const factory DiaryModel({
|
||||
required int id,
|
||||
required DateTime date,
|
||||
required int closed,
|
||||
required List<Meal> meals,
|
||||
String? comment,
|
||||
DateTime? wakeup,
|
||||
DateTime? retire,
|
||||
}) = _DiaryModel;
|
||||
|
||||
factory DiaryModel.fromJson(Map<String, Object?> json) => _$DiaryModelFromJson(json);
|
||||
}
|
||||
|
||||
class Meals {
|
||||
int? id;
|
||||
String? time;
|
||||
int? type;
|
||||
int? satiety;
|
||||
int? mood;
|
||||
List<Portions>? portions;
|
||||
List<Photos>? photos;
|
||||
|
||||
Meals({this.id, this.time, this.type, this.satiety, this.mood, this.portions, this.photos});
|
||||
|
||||
Meals.fromJson(Map<String, dynamic> json) {
|
||||
List<Portions> portions = [];
|
||||
List<Photos> photos = [];
|
||||
id = json['id'];
|
||||
time = json['time'];
|
||||
type = json['type'];
|
||||
satiety = json['satiety'];
|
||||
mood = json['mood'];
|
||||
if (json['portions'] != null) {
|
||||
json['portions'].forEach((v) {
|
||||
portions.add(new Portions.fromJson(v));
|
||||
});
|
||||
}
|
||||
if (json['photos'] != null) {
|
||||
json['photos'].forEach((v) {
|
||||
photos.add(new Photos.fromJson(v));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||
data['id'] = this.id;
|
||||
data['time'] = this.time;
|
||||
data['type'] = this.type;
|
||||
data['satiety'] = this.satiety;
|
||||
data['mood'] = this.mood;
|
||||
if (this.portions != null) {
|
||||
data['portions'] = this.portions?.map((v) => v.toJson()).toList();
|
||||
}
|
||||
if (this.photos != null) {
|
||||
data['photos'] = this.photos?.map((v) => v.toJson()).toList();
|
||||
}
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
class Portions {
|
||||
int? id;
|
||||
String? productName;
|
||||
int? quantity;
|
||||
String? portion;
|
||||
|
||||
Portions({this.id, this.productName, this.quantity, this.portion});
|
||||
|
||||
Portions.fromJson(Map<String, dynamic> json) {
|
||||
id = json['id'];
|
||||
productName = json['product_name'];
|
||||
quantity = json['quantity'];
|
||||
portion = json['portion'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||
data['id'] = this.id;
|
||||
data['product_name'] = this.productName;
|
||||
data['quantity'] = this.quantity;
|
||||
data['portion'] = this.portion;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
class Photos {
|
||||
int? id;
|
||||
String? originalName;
|
||||
String? path;
|
||||
int? size;
|
||||
|
||||
Photos({this.id, this.originalName, this.path, this.size});
|
||||
|
||||
Photos.fromJson(Map<String, dynamic> json) {
|
||||
id = json['id'];
|
||||
originalName = json['original_name'];
|
||||
path = json['path'];
|
||||
size = json['size'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||
data['id'] = this.id;
|
||||
data['original_name'] = this.originalName;
|
||||
data['path'] = this.path;
|
||||
data['size'] = this.size;
|
||||
return data;
|
||||
}
|
||||
factory DiaryModel.fromJson(Map<String, Object?> json) =>
|
||||
_$DiaryModelFromJson(json);
|
||||
}
|
||||
|
||||
@@ -22,11 +22,11 @@ DiaryModel _$DiaryModelFromJson(Map<String, dynamic> json) {
|
||||
mixin _$DiaryModel {
|
||||
int get id => throw _privateConstructorUsedError;
|
||||
DateTime get date => throw _privateConstructorUsedError;
|
||||
DateTime get wakeup => throw _privateConstructorUsedError;
|
||||
DateTime get retire => throw _privateConstructorUsedError;
|
||||
int get closed => throw _privateConstructorUsedError;
|
||||
String get comment => throw _privateConstructorUsedError;
|
||||
List<Meals> get meals => throw _privateConstructorUsedError;
|
||||
List<Meal> get meals => throw _privateConstructorUsedError;
|
||||
String? get comment => throw _privateConstructorUsedError;
|
||||
DateTime? get wakeup => throw _privateConstructorUsedError;
|
||||
DateTime? get retire => throw _privateConstructorUsedError;
|
||||
|
||||
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
|
||||
@JsonKey(ignore: true)
|
||||
@@ -43,11 +43,11 @@ abstract class $DiaryModelCopyWith<$Res> {
|
||||
$Res call(
|
||||
{int id,
|
||||
DateTime date,
|
||||
DateTime wakeup,
|
||||
DateTime retire,
|
||||
int closed,
|
||||
String comment,
|
||||
List<Meals> meals});
|
||||
List<Meal> meals,
|
||||
String? comment,
|
||||
DateTime? wakeup,
|
||||
DateTime? retire});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@@ -65,11 +65,11 @@ class _$DiaryModelCopyWithImpl<$Res, $Val extends DiaryModel>
|
||||
$Res call({
|
||||
Object? id = null,
|
||||
Object? date = null,
|
||||
Object? wakeup = null,
|
||||
Object? retire = null,
|
||||
Object? closed = null,
|
||||
Object? comment = null,
|
||||
Object? meals = null,
|
||||
Object? comment = freezed,
|
||||
Object? wakeup = freezed,
|
||||
Object? retire = freezed,
|
||||
}) {
|
||||
return _then(_value.copyWith(
|
||||
id: null == id
|
||||
@@ -80,26 +80,26 @@ class _$DiaryModelCopyWithImpl<$Res, $Val extends DiaryModel>
|
||||
? _value.date
|
||||
: date // ignore: cast_nullable_to_non_nullable
|
||||
as DateTime,
|
||||
wakeup: null == wakeup
|
||||
? _value.wakeup
|
||||
: wakeup // ignore: cast_nullable_to_non_nullable
|
||||
as DateTime,
|
||||
retire: null == retire
|
||||
? _value.retire
|
||||
: retire // ignore: cast_nullable_to_non_nullable
|
||||
as DateTime,
|
||||
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,
|
||||
meals: null == meals
|
||||
? _value.meals
|
||||
: meals // ignore: cast_nullable_to_non_nullable
|
||||
as List<Meals>,
|
||||
as List<Meal>,
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -115,11 +115,11 @@ abstract class _$$DiaryModelImplCopyWith<$Res>
|
||||
$Res call(
|
||||
{int id,
|
||||
DateTime date,
|
||||
DateTime wakeup,
|
||||
DateTime retire,
|
||||
int closed,
|
||||
String comment,
|
||||
List<Meals> meals});
|
||||
List<Meal> meals,
|
||||
String? comment,
|
||||
DateTime? wakeup,
|
||||
DateTime? retire});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@@ -135,11 +135,11 @@ class __$$DiaryModelImplCopyWithImpl<$Res>
|
||||
$Res call({
|
||||
Object? id = null,
|
||||
Object? date = null,
|
||||
Object? wakeup = null,
|
||||
Object? retire = null,
|
||||
Object? closed = null,
|
||||
Object? comment = null,
|
||||
Object? meals = null,
|
||||
Object? comment = freezed,
|
||||
Object? wakeup = freezed,
|
||||
Object? retire = freezed,
|
||||
}) {
|
||||
return _then(_$DiaryModelImpl(
|
||||
id: null == id
|
||||
@@ -150,26 +150,26 @@ class __$$DiaryModelImplCopyWithImpl<$Res>
|
||||
? _value.date
|
||||
: date // ignore: cast_nullable_to_non_nullable
|
||||
as DateTime,
|
||||
wakeup: null == wakeup
|
||||
? _value.wakeup
|
||||
: wakeup // ignore: cast_nullable_to_non_nullable
|
||||
as DateTime,
|
||||
retire: null == retire
|
||||
? _value.retire
|
||||
: retire // ignore: cast_nullable_to_non_nullable
|
||||
as DateTime,
|
||||
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,
|
||||
meals: null == meals
|
||||
? _value._meals
|
||||
: meals // ignore: cast_nullable_to_non_nullable
|
||||
as List<Meals>,
|
||||
as List<Meal>,
|
||||
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?,
|
||||
));
|
||||
}
|
||||
}
|
||||
@@ -180,11 +180,11 @@ class _$DiaryModelImpl implements _DiaryModel {
|
||||
const _$DiaryModelImpl(
|
||||
{required this.id,
|
||||
required this.date,
|
||||
required this.wakeup,
|
||||
required this.retire,
|
||||
required this.closed,
|
||||
required this.comment,
|
||||
required final List<Meals> meals})
|
||||
required final List<Meal> meals,
|
||||
this.comment,
|
||||
this.wakeup,
|
||||
this.retire})
|
||||
: _meals = meals;
|
||||
|
||||
factory _$DiaryModelImpl.fromJson(Map<String, dynamic> json) =>
|
||||
@@ -195,24 +195,25 @@ class _$DiaryModelImpl implements _DiaryModel {
|
||||
@override
|
||||
final DateTime date;
|
||||
@override
|
||||
final DateTime wakeup;
|
||||
@override
|
||||
final DateTime retire;
|
||||
@override
|
||||
final int closed;
|
||||
final List<Meal> _meals;
|
||||
@override
|
||||
final String comment;
|
||||
final List<Meals> _meals;
|
||||
@override
|
||||
List<Meals> get meals {
|
||||
List<Meal> get meals {
|
||||
if (_meals is EqualUnmodifiableListView) return _meals;
|
||||
// ignore: implicit_dynamic_type
|
||||
return EqualUnmodifiableListView(_meals);
|
||||
}
|
||||
|
||||
@override
|
||||
final String? comment;
|
||||
@override
|
||||
final DateTime? wakeup;
|
||||
@override
|
||||
final DateTime? retire;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'DiaryModel(id: $id, date: $date, wakeup: $wakeup, retire: $retire, closed: $closed, comment: $comment, meals: $meals)';
|
||||
return 'DiaryModel(id: $id, date: $date, closed: $closed, meals: $meals, comment: $comment, wakeup: $wakeup, retire: $retire)';
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -222,17 +223,17 @@ class _$DiaryModelImpl implements _DiaryModel {
|
||||
other is _$DiaryModelImpl &&
|
||||
(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) &&
|
||||
const DeepCollectionEquality().equals(other._meals, _meals) &&
|
||||
(identical(other.comment, comment) || other.comment == comment) &&
|
||||
const DeepCollectionEquality().equals(other._meals, _meals));
|
||||
(identical(other.wakeup, wakeup) || other.wakeup == wakeup) &&
|
||||
(identical(other.retire, retire) || other.retire == retire));
|
||||
}
|
||||
|
||||
@JsonKey(ignore: true)
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType, id, date, wakeup, retire, closed,
|
||||
comment, const DeepCollectionEquality().hash(_meals));
|
||||
int get hashCode => Object.hash(runtimeType, id, date, closed,
|
||||
const DeepCollectionEquality().hash(_meals), comment, wakeup, retire);
|
||||
|
||||
@JsonKey(ignore: true)
|
||||
@override
|
||||
@@ -252,11 +253,11 @@ abstract class _DiaryModel implements DiaryModel {
|
||||
const factory _DiaryModel(
|
||||
{required final int id,
|
||||
required final DateTime date,
|
||||
required final DateTime wakeup,
|
||||
required final DateTime retire,
|
||||
required final int closed,
|
||||
required final String comment,
|
||||
required final List<Meals> meals}) = _$DiaryModelImpl;
|
||||
required final List<Meal> meals,
|
||||
final String? comment,
|
||||
final DateTime? wakeup,
|
||||
final DateTime? retire}) = _$DiaryModelImpl;
|
||||
|
||||
factory _DiaryModel.fromJson(Map<String, dynamic> json) =
|
||||
_$DiaryModelImpl.fromJson;
|
||||
@@ -266,15 +267,15 @@ abstract class _DiaryModel implements DiaryModel {
|
||||
@override
|
||||
DateTime get date;
|
||||
@override
|
||||
DateTime get wakeup;
|
||||
@override
|
||||
DateTime get retire;
|
||||
@override
|
||||
int get closed;
|
||||
@override
|
||||
String get comment;
|
||||
List<Meal> get meals;
|
||||
@override
|
||||
List<Meals> get meals;
|
||||
String? get comment;
|
||||
@override
|
||||
DateTime? get wakeup;
|
||||
@override
|
||||
DateTime? get retire;
|
||||
@override
|
||||
@JsonKey(ignore: true)
|
||||
_$$DiaryModelImplCopyWith<_$DiaryModelImpl> get copyWith =>
|
||||
|
||||
@@ -10,22 +10,26 @@ _$DiaryModelImpl _$$DiaryModelImplFromJson(Map<String, dynamic> json) =>
|
||||
_$DiaryModelImpl(
|
||||
id: (json['id'] as num).toInt(),
|
||||
date: DateTime.parse(json['date'] as String),
|
||||
wakeup: DateTime.parse(json['wakeup'] as String),
|
||||
retire: DateTime.parse(json['retire'] as String),
|
||||
closed: (json['closed'] as num).toInt(),
|
||||
comment: json['comment'] as String,
|
||||
meals: (json['meals'] as List<dynamic>)
|
||||
.map((e) => Meals.fromJson(e as Map<String, dynamic>))
|
||||
.map((e) => Meal.fromJson(e as Map<String, dynamic>))
|
||||
.toList(),
|
||||
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<String, dynamic> _$$DiaryModelImplToJson(_$DiaryModelImpl instance) =>
|
||||
<String, dynamic>{
|
||||
'id': instance.id,
|
||||
'date': instance.date.toIso8601String(),
|
||||
'wakeup': instance.wakeup.toIso8601String(),
|
||||
'retire': instance.retire.toIso8601String(),
|
||||
'closed': instance.closed,
|
||||
'comment': instance.comment,
|
||||
'meals': instance.meals,
|
||||
'comment': instance.comment,
|
||||
'wakeup': instance.wakeup?.toIso8601String(),
|
||||
'retire': instance.retire?.toIso8601String(),
|
||||
};
|
||||
|
||||
21
lib/features/diary/models/meal.dart
Normal file
21
lib/features/diary/models/meal.dart
Normal file
@@ -0,0 +1,21 @@
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
import './portion.dart';
|
||||
import './photo.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<Portion> portions,
|
||||
required List<Photo> photos,
|
||||
}) = _Meal;
|
||||
|
||||
factory Meal.fromJson(Map<String, Object?> json) => _$MealFromJson(json);
|
||||
}
|
||||
291
lib/features/diary/models/meal.freezed.dart
Normal file
291
lib/features/diary/models/meal.freezed.dart
Normal file
@@ -0,0 +1,291 @@
|
||||
// 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>(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<String, dynamic> 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<Portion> get portions => throw _privateConstructorUsedError;
|
||||
List<Photo> get photos => throw _privateConstructorUsedError;
|
||||
|
||||
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
|
||||
@JsonKey(ignore: true)
|
||||
$MealCopyWith<Meal> 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<Portion> portions,
|
||||
List<Photo> 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;
|
||||
|
||||
@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<Portion>,
|
||||
photos: null == photos
|
||||
? _value.photos
|
||||
: photos // ignore: cast_nullable_to_non_nullable
|
||||
as List<Photo>,
|
||||
) 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<Portion> portions,
|
||||
List<Photo> photos});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$MealImplCopyWithImpl<$Res>
|
||||
extends _$MealCopyWithImpl<$Res, _$MealImpl>
|
||||
implements _$$MealImplCopyWith<$Res> {
|
||||
__$$MealImplCopyWithImpl(_$MealImpl _value, $Res Function(_$MealImpl) _then)
|
||||
: super(_value, _then);
|
||||
|
||||
@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<Portion>,
|
||||
photos: null == photos
|
||||
? _value._photos
|
||||
: photos // ignore: cast_nullable_to_non_nullable
|
||||
as List<Photo>,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
/// @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<Portion> portions,
|
||||
required final List<Photo> photos})
|
||||
: _portions = portions,
|
||||
_photos = photos;
|
||||
|
||||
factory _$MealImpl.fromJson(Map<String, dynamic> 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<Portion> _portions;
|
||||
@override
|
||||
List<Portion> get portions {
|
||||
if (_portions is EqualUnmodifiableListView) return _portions;
|
||||
// ignore: implicit_dynamic_type
|
||||
return EqualUnmodifiableListView(_portions);
|
||||
}
|
||||
|
||||
final List<Photo> _photos;
|
||||
@override
|
||||
List<Photo> 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(ignore: true)
|
||||
@override
|
||||
int get hashCode => Object.hash(
|
||||
runtimeType,
|
||||
id,
|
||||
time,
|
||||
type,
|
||||
satiety,
|
||||
mood,
|
||||
const DeepCollectionEquality().hash(_portions),
|
||||
const DeepCollectionEquality().hash(_photos));
|
||||
|
||||
@JsonKey(ignore: true)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$MealImplCopyWith<_$MealImpl> get copyWith =>
|
||||
__$$MealImplCopyWithImpl<_$MealImpl>(this, _$identity);
|
||||
|
||||
@override
|
||||
Map<String, dynamic> 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<Portion> portions,
|
||||
required final List<Photo> photos}) = _$MealImpl;
|
||||
|
||||
factory _Meal.fromJson(Map<String, dynamic> 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<Portion> get portions;
|
||||
@override
|
||||
List<Photo> get photos;
|
||||
@override
|
||||
@JsonKey(ignore: true)
|
||||
_$$MealImplCopyWith<_$MealImpl> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
32
lib/features/diary/models/meal.g.dart
Normal file
32
lib/features/diary/models/meal.g.dart
Normal file
@@ -0,0 +1,32 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'meal.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
_$MealImpl _$$MealImplFromJson(Map<String, dynamic> 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<dynamic>)
|
||||
.map((e) => Portion.fromJson(e as Map<String, dynamic>))
|
||||
.toList(),
|
||||
photos: (json['photos'] as List<dynamic>)
|
||||
.map((e) => Photo.fromJson(e as Map<String, dynamic>))
|
||||
.toList(),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$$MealImplToJson(_$MealImpl instance) =>
|
||||
<String, dynamic>{
|
||||
'id': instance.id,
|
||||
'time': instance.time,
|
||||
'type': instance.type,
|
||||
'satiety': instance.satiety,
|
||||
'mood': instance.mood,
|
||||
'portions': instance.portions,
|
||||
'photos': instance.photos,
|
||||
};
|
||||
15
lib/features/diary/models/photo.dart
Normal file
15
lib/features/diary/models/photo.dart
Normal file
@@ -0,0 +1,15 @@
|
||||
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,
|
||||
required String original_name,
|
||||
required String path,
|
||||
}) = _Photo;
|
||||
|
||||
factory Photo.fromJson(Map<String, Object?> json) => _$PhotoFromJson(json);
|
||||
}
|
||||
184
lib/features/diary/models/photo.freezed.dart
Normal file
184
lib/features/diary/models/photo.freezed.dart
Normal file
@@ -0,0 +1,184 @@
|
||||
// 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>(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<String, dynamic> json) {
|
||||
return _Photo.fromJson(json);
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
mixin _$Photo {
|
||||
int get id => throw _privateConstructorUsedError;
|
||||
String get original_name => throw _privateConstructorUsedError;
|
||||
String get path => throw _privateConstructorUsedError;
|
||||
|
||||
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
|
||||
@JsonKey(ignore: true)
|
||||
$PhotoCopyWith<Photo> 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, String original_name, 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;
|
||||
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? id = null,
|
||||
Object? original_name = null,
|
||||
Object? path = null,
|
||||
}) {
|
||||
return _then(_value.copyWith(
|
||||
id: null == id
|
||||
? _value.id
|
||||
: id // ignore: cast_nullable_to_non_nullable
|
||||
as int,
|
||||
original_name: null == original_name
|
||||
? _value.original_name
|
||||
: original_name // 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, String original_name, String path});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$PhotoImplCopyWithImpl<$Res>
|
||||
extends _$PhotoCopyWithImpl<$Res, _$PhotoImpl>
|
||||
implements _$$PhotoImplCopyWith<$Res> {
|
||||
__$$PhotoImplCopyWithImpl(
|
||||
_$PhotoImpl _value, $Res Function(_$PhotoImpl) _then)
|
||||
: super(_value, _then);
|
||||
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? id = null,
|
||||
Object? original_name = null,
|
||||
Object? path = null,
|
||||
}) {
|
||||
return _then(_$PhotoImpl(
|
||||
id: null == id
|
||||
? _value.id
|
||||
: id // ignore: cast_nullable_to_non_nullable
|
||||
as int,
|
||||
original_name: null == original_name
|
||||
? _value.original_name
|
||||
: original_name // 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, required this.original_name, required this.path});
|
||||
|
||||
factory _$PhotoImpl.fromJson(Map<String, dynamic> json) =>
|
||||
_$$PhotoImplFromJson(json);
|
||||
|
||||
@override
|
||||
final int id;
|
||||
@override
|
||||
final String original_name;
|
||||
@override
|
||||
final String path;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'Photo(id: $id, original_name: $original_name, 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.original_name, original_name) ||
|
||||
other.original_name == original_name) &&
|
||||
(identical(other.path, path) || other.path == path));
|
||||
}
|
||||
|
||||
@JsonKey(ignore: true)
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType, id, original_name, path);
|
||||
|
||||
@JsonKey(ignore: true)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$PhotoImplCopyWith<_$PhotoImpl> get copyWith =>
|
||||
__$$PhotoImplCopyWithImpl<_$PhotoImpl>(this, _$identity);
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
return _$$PhotoImplToJson(
|
||||
this,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
abstract class _Photo implements Photo {
|
||||
const factory _Photo(
|
||||
{required final int id,
|
||||
required final String original_name,
|
||||
required final String path}) = _$PhotoImpl;
|
||||
|
||||
factory _Photo.fromJson(Map<String, dynamic> json) = _$PhotoImpl.fromJson;
|
||||
|
||||
@override
|
||||
int get id;
|
||||
@override
|
||||
String get original_name;
|
||||
@override
|
||||
String get path;
|
||||
@override
|
||||
@JsonKey(ignore: true)
|
||||
_$$PhotoImplCopyWith<_$PhotoImpl> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
20
lib/features/diary/models/photo.g.dart
Normal file
20
lib/features/diary/models/photo.g.dart
Normal file
@@ -0,0 +1,20 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'photo.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
_$PhotoImpl _$$PhotoImplFromJson(Map<String, dynamic> json) => _$PhotoImpl(
|
||||
id: (json['id'] as num).toInt(),
|
||||
original_name: json['original_name'] as String,
|
||||
path: json['path'] as String,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$$PhotoImplToJson(_$PhotoImpl instance) =>
|
||||
<String, dynamic>{
|
||||
'id': instance.id,
|
||||
'original_name': instance.original_name,
|
||||
'path': instance.path,
|
||||
};
|
||||
17
lib/features/diary/models/portion.dart
Normal file
17
lib/features/diary/models/portion.dart
Normal file
@@ -0,0 +1,17 @@
|
||||
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,
|
||||
}) = _Portion;
|
||||
|
||||
factory Portion.fromJson(Map<String, Object?> json) =>
|
||||
_$PortionFromJson(json);
|
||||
}
|
||||
206
lib/features/diary/models/portion.freezed.dart
Normal file
206
lib/features/diary/models/portion.freezed.dart
Normal file
@@ -0,0 +1,206 @@
|
||||
// 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>(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<String, dynamic> 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;
|
||||
|
||||
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
|
||||
@JsonKey(ignore: true)
|
||||
$PortionCopyWith<Portion> 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});
|
||||
}
|
||||
|
||||
/// @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;
|
||||
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? id = null,
|
||||
Object? product_name = null,
|
||||
Object? quantity = null,
|
||||
Object? portion = 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,
|
||||
) 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});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$PortionImplCopyWithImpl<$Res>
|
||||
extends _$PortionCopyWithImpl<$Res, _$PortionImpl>
|
||||
implements _$$PortionImplCopyWith<$Res> {
|
||||
__$$PortionImplCopyWithImpl(
|
||||
_$PortionImpl _value, $Res Function(_$PortionImpl) _then)
|
||||
: super(_value, _then);
|
||||
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? id = null,
|
||||
Object? product_name = null,
|
||||
Object? quantity = null,
|
||||
Object? portion = 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,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@JsonSerializable()
|
||||
class _$PortionImpl implements _Portion {
|
||||
const _$PortionImpl(
|
||||
{required this.id,
|
||||
required this.product_name,
|
||||
required this.quantity,
|
||||
required this.portion});
|
||||
|
||||
factory _$PortionImpl.fromJson(Map<String, dynamic> json) =>
|
||||
_$$PortionImplFromJson(json);
|
||||
|
||||
@override
|
||||
final int id;
|
||||
@override
|
||||
final String product_name;
|
||||
@override
|
||||
final int quantity;
|
||||
@override
|
||||
final String portion;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'Portion(id: $id, product_name: $product_name, quantity: $quantity, portion: $portion)';
|
||||
}
|
||||
|
||||
@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));
|
||||
}
|
||||
|
||||
@JsonKey(ignore: true)
|
||||
@override
|
||||
int get hashCode =>
|
||||
Object.hash(runtimeType, id, product_name, quantity, portion);
|
||||
|
||||
@JsonKey(ignore: true)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$PortionImplCopyWith<_$PortionImpl> get copyWith =>
|
||||
__$$PortionImplCopyWithImpl<_$PortionImpl>(this, _$identity);
|
||||
|
||||
@override
|
||||
Map<String, dynamic> 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}) = _$PortionImpl;
|
||||
|
||||
factory _Portion.fromJson(Map<String, dynamic> json) = _$PortionImpl.fromJson;
|
||||
|
||||
@override
|
||||
int get id;
|
||||
@override
|
||||
String get product_name;
|
||||
@override
|
||||
int get quantity;
|
||||
@override
|
||||
String get portion;
|
||||
@override
|
||||
@JsonKey(ignore: true)
|
||||
_$$PortionImplCopyWith<_$PortionImpl> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
23
lib/features/diary/models/portion.g.dart
Normal file
23
lib/features/diary/models/portion.g.dart
Normal file
@@ -0,0 +1,23 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'portion.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
_$PortionImpl _$$PortionImplFromJson(Map<String, dynamic> 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,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$$PortionImplToJson(_$PortionImpl instance) =>
|
||||
<String, dynamic>{
|
||||
'id': instance.id,
|
||||
'product_name': instance.product_name,
|
||||
'quantity': instance.quantity,
|
||||
'portion': instance.portion,
|
||||
};
|
||||
15
lib/features/diary/models/product.dart
Normal file
15
lib/features/diary/models/product.dart
Normal file
@@ -0,0 +1,15 @@
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
||||
part 'product.freezed.dart';
|
||||
part 'product.g.dart';
|
||||
|
||||
@freezed
|
||||
class Product with _$Product {
|
||||
const factory Product({
|
||||
required int id,
|
||||
required String name,
|
||||
}) = _Product;
|
||||
|
||||
factory Product.fromJson(Map<String, Object?> json) =>
|
||||
_$ProductFromJson(json);
|
||||
}
|
||||
164
lib/features/diary/models/product.freezed.dart
Normal file
164
lib/features/diary/models/product.freezed.dart
Normal file
@@ -0,0 +1,164 @@
|
||||
// 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 'product.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// FreezedGenerator
|
||||
// **************************************************************************
|
||||
|
||||
T _$identity<T>(T value) => value;
|
||||
|
||||
final _privateConstructorUsedError = UnsupportedError(
|
||||
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models');
|
||||
|
||||
Product _$ProductFromJson(Map<String, dynamic> json) {
|
||||
return _Product.fromJson(json);
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
mixin _$Product {
|
||||
int get id => throw _privateConstructorUsedError;
|
||||
String get name => throw _privateConstructorUsedError;
|
||||
|
||||
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
|
||||
@JsonKey(ignore: true)
|
||||
$ProductCopyWith<Product> get copyWith => throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class $ProductCopyWith<$Res> {
|
||||
factory $ProductCopyWith(Product value, $Res Function(Product) then) =
|
||||
_$ProductCopyWithImpl<$Res, Product>;
|
||||
@useResult
|
||||
$Res call({int id, String name});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class _$ProductCopyWithImpl<$Res, $Val extends Product>
|
||||
implements $ProductCopyWith<$Res> {
|
||||
_$ProductCopyWithImpl(this._value, this._then);
|
||||
|
||||
// ignore: unused_field
|
||||
final $Val _value;
|
||||
// ignore: unused_field
|
||||
final $Res Function($Val) _then;
|
||||
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? id = null,
|
||||
Object? name = null,
|
||||
}) {
|
||||
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,
|
||||
) as $Val);
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$ProductImplCopyWith<$Res> implements $ProductCopyWith<$Res> {
|
||||
factory _$$ProductImplCopyWith(
|
||||
_$ProductImpl value, $Res Function(_$ProductImpl) then) =
|
||||
__$$ProductImplCopyWithImpl<$Res>;
|
||||
@override
|
||||
@useResult
|
||||
$Res call({int id, String name});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$ProductImplCopyWithImpl<$Res>
|
||||
extends _$ProductCopyWithImpl<$Res, _$ProductImpl>
|
||||
implements _$$ProductImplCopyWith<$Res> {
|
||||
__$$ProductImplCopyWithImpl(
|
||||
_$ProductImpl _value, $Res Function(_$ProductImpl) _then)
|
||||
: super(_value, _then);
|
||||
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? id = null,
|
||||
Object? name = null,
|
||||
}) {
|
||||
return _then(_$ProductImpl(
|
||||
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,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@JsonSerializable()
|
||||
class _$ProductImpl implements _Product {
|
||||
const _$ProductImpl({required this.id, required this.name});
|
||||
|
||||
factory _$ProductImpl.fromJson(Map<String, dynamic> json) =>
|
||||
_$$ProductImplFromJson(json);
|
||||
|
||||
@override
|
||||
final int id;
|
||||
@override
|
||||
final String name;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'Product(id: $id, name: $name)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$ProductImpl &&
|
||||
(identical(other.id, id) || other.id == id) &&
|
||||
(identical(other.name, name) || other.name == name));
|
||||
}
|
||||
|
||||
@JsonKey(ignore: true)
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType, id, name);
|
||||
|
||||
@JsonKey(ignore: true)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$ProductImplCopyWith<_$ProductImpl> get copyWith =>
|
||||
__$$ProductImplCopyWithImpl<_$ProductImpl>(this, _$identity);
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
return _$$ProductImplToJson(
|
||||
this,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
abstract class _Product implements Product {
|
||||
const factory _Product({required final int id, required final String name}) =
|
||||
_$ProductImpl;
|
||||
|
||||
factory _Product.fromJson(Map<String, dynamic> json) = _$ProductImpl.fromJson;
|
||||
|
||||
@override
|
||||
int get id;
|
||||
@override
|
||||
String get name;
|
||||
@override
|
||||
@JsonKey(ignore: true)
|
||||
_$$ProductImplCopyWith<_$ProductImpl> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
19
lib/features/diary/models/product.g.dart
Normal file
19
lib/features/diary/models/product.g.dart
Normal file
@@ -0,0 +1,19 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'product.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
_$ProductImpl _$$ProductImplFromJson(Map<String, dynamic> json) =>
|
||||
_$ProductImpl(
|
||||
id: (json['id'] as num).toInt(),
|
||||
name: json['name'] as String,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$$ProductImplToJson(_$ProductImpl instance) =>
|
||||
<String, dynamic>{
|
||||
'id': instance.id,
|
||||
'name': instance.name,
|
||||
};
|
||||
489
lib/features/diary/presentation/bloc/diary_bloc.dart
Normal file
489
lib/features/diary/presentation/bloc/diary_bloc.dart
Normal file
@@ -0,0 +1,489 @@
|
||||
import 'dart:async';
|
||||
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/repositories/diary_repository.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import '/core/app_export.dart';
|
||||
import 'package:image_picker/image_picker.dart';
|
||||
import 'package:eatvio_app/features/diary/presentation/bloc/diary_state.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'dart:convert';
|
||||
import 'package:flutter_dotenv/flutter_dotenv.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<DiaryEvent, DiaryState> {
|
||||
final DiaryRepository diaryRepository;
|
||||
|
||||
DiaryBloc({required this.diaryRepository})
|
||||
: super(const DiaryState.loading()) {
|
||||
on<LoadDiary>(loadDiary);
|
||||
on<ChangeSatiety>(_changeSatiety); // пользователь нажимает на шкалу сытости
|
||||
on<ChangeMood>(_changeMood); // пользователь нажимает на шкалу настроения
|
||||
on<ChangeMealTime>(_changeMealTime); // пользовательяет времяа пиши
|
||||
on<ChangeMeal>(_changeMeal);
|
||||
on<ChangePortion>(_changePortion);
|
||||
on<WakeupEvent>(_changeWakeup); // пользователь выбирает время пробуждения
|
||||
on<RetireEvent>(_changeRetire); // пользователь выбирает время отхода ко сну
|
||||
on<ToggleMoodExpandedEvent>(_toggleMood);
|
||||
on<ToggleWakeupExpandedEvent>(_toggleWakeup);
|
||||
on<AddPortionEvent>(_addPortion); //пользователь нажимает "Добавить продукт"
|
||||
on<RemovePortionEvent>(_removePortion);
|
||||
on<RemoveImageEvent>(
|
||||
_removeImage,
|
||||
); // пользователь нажимает на крестик около продукта
|
||||
on<UploadImages>(_uploadImages); //пользователь нажимает "Добавить фото"
|
||||
on<ProductInput>(
|
||||
_inputProduct,
|
||||
);
|
||||
on<FinishDay>(_finishDay);
|
||||
on<SendModeration>(_sendModeration);
|
||||
on<ClearInput>(_clearInput);
|
||||
}
|
||||
|
||||
loadDiary(
|
||||
LoadDiary event,
|
||||
Emitter<DiaryState> emit,
|
||||
) async {
|
||||
emit(const DiaryState.loading());
|
||||
try {
|
||||
Map<String, int> data = await diaryRepository.getDiaryID();
|
||||
|
||||
final int? diaryID = data['id'];
|
||||
final DiaryModel diary = await diaryRepository.getDiary(diaryID ?? 45);
|
||||
final Meal currentMeal = diary.meals[0];
|
||||
|
||||
List<SelectionPopupModel> portionList = [
|
||||
SelectionPopupModel(title: "gr"),
|
||||
SelectionPopupModel(title: "pcs")
|
||||
];
|
||||
|
||||
final Map<String, dynamic> chartData =
|
||||
await diaryRepository.getChartData(diaryID ?? 45);
|
||||
final Map<String, dynamic> dailyNutritionIntake =
|
||||
chartData['dailyNutritionIntake']!;
|
||||
final Map<String, dynamic> dailyNutritionRecommendations =
|
||||
chartData['dailyNutritionRecommendation']!;
|
||||
final double ccal = dailyNutritionIntake['energy']! /
|
||||
dailyNutritionRecommendations['energy']! *
|
||||
100;
|
||||
final double proteins = dailyNutritionIntake['proteins']! /
|
||||
dailyNutritionRecommendations['proteins']! *
|
||||
100;
|
||||
final double fats = dailyNutritionIntake['fats']! /
|
||||
dailyNutritionRecommendations['fats']! *
|
||||
100;
|
||||
final double carbs = dailyNutritionIntake['carbohydrates']! /
|
||||
dailyNutritionRecommendations['carbohydrates']! *
|
||||
100;
|
||||
|
||||
Color getColor(double value) {
|
||||
if (value >= 99.1) {
|
||||
return Colors.red;
|
||||
} else {
|
||||
return Colors.blue;
|
||||
}
|
||||
}
|
||||
|
||||
final List<NutritionData> chartDataCounted = [
|
||||
NutritionData('Калории', ccal, getColor(ccal)),
|
||||
NutritionData('Белки', proteins, getColor(proteins)),
|
||||
NutritionData('Жиры', fats, getColor(fats)),
|
||||
NutritionData('Углеводы', carbs, getColor(carbs)),
|
||||
];
|
||||
|
||||
List<SelectionPopupModel> 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),
|
||||
];
|
||||
|
||||
print(dailyNutritionRecommendations);
|
||||
print(dailyNutritionIntake);
|
||||
emit(DiaryState.loaded(
|
||||
diary: diary,
|
||||
currentMeal: currentMeal,
|
||||
portions: currentMeal.portions,
|
||||
portionList: portionList,
|
||||
portionController: portionList[0],
|
||||
mealList: mealList,
|
||||
chartData: chartDataCounted,
|
||||
selectedMood: currentMeal.mood,
|
||||
selectedSatiety: currentMeal.satiety,
|
||||
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()));
|
||||
}
|
||||
}
|
||||
|
||||
fetchChartValues(
|
||||
String token,
|
||||
int diaryID,
|
||||
Emitter<DiaryState> emit,
|
||||
) async {
|
||||
final responseChart = await http.get(
|
||||
Uri.parse(
|
||||
dotenv.env['SERVER_ROOT']! + '/diary/$diaryID/dailyNutritionData/',
|
||||
),
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Authorization': 'Bearer $token',
|
||||
},
|
||||
);
|
||||
|
||||
if (responseChart.statusCode == 200) {
|
||||
final responseBody = jsonDecode(responseChart.body);
|
||||
print(responseBody);
|
||||
final recommendedChartValues =
|
||||
responseBody['dailyNutritionRecommendation']
|
||||
.values
|
||||
.map<int>((value) => convertToInt(value))
|
||||
.toList();
|
||||
|
||||
final consumedChartValues = responseBody['dailyNutritionIntake']
|
||||
.values
|
||||
.map<int>((value) => convertToInt(value))
|
||||
.toList();
|
||||
|
||||
print([
|
||||
recommendedChartValues,
|
||||
consumedChartValues,
|
||||
]);
|
||||
return [
|
||||
recommendedChartValues,
|
||||
consumedChartValues,
|
||||
];
|
||||
} else {
|
||||
emit(DiaryStateError(
|
||||
errorMessage: 'Ошибка при декодировании данных КБЖУ'));
|
||||
print('fail');
|
||||
return [
|
||||
[],
|
||||
[],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _changeSatiety(
|
||||
ChangeSatiety event,
|
||||
Emitter<DiaryState> 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<void> _changeMood(
|
||||
ChangeMood event,
|
||||
Emitter<DiaryState> 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<void> _changeWakeup(
|
||||
WakeupEvent event,
|
||||
Emitter<DiaryState> 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<void> _changeRetire(
|
||||
RetireEvent event,
|
||||
Emitter<DiaryState> 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<void> _changeMealTime(
|
||||
ChangeMealTime event,
|
||||
Emitter<DiaryState> emit,
|
||||
) async {
|
||||
if (state is DiaryStateLoaded) {
|
||||
var currentState = state as DiaryStateLoaded;
|
||||
var updatedState = currentState.copyWith(mealTimeController: event.time);
|
||||
emit(updatedState);
|
||||
}
|
||||
}
|
||||
|
||||
FutureOr<void> _changeMeal(
|
||||
ChangeMeal event,
|
||||
Emitter<DiaryState> 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<void> _inputProduct(
|
||||
ProductInput event,
|
||||
Emitter<DiaryState> emit,
|
||||
) async {
|
||||
if (state is DiaryStateLoaded) {
|
||||
var currentState = state as DiaryStateLoaded;
|
||||
|
||||
final Map<String, List<Product>> 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<void> _addPortion(
|
||||
AddPortionEvent event,
|
||||
Emitter<DiaryState> 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.title,
|
||||
int.parse(currentState.productQuantityController.text),
|
||||
);
|
||||
add(LoadDiary());
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _removePortion(
|
||||
RemovePortionEvent event,
|
||||
Emitter<DiaryState> 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<void> _uploadImages(
|
||||
UploadImages event,
|
||||
Emitter<DiaryState> 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<void> _sendModeration(
|
||||
SendModeration event,
|
||||
Emitter<DiaryState> emit,
|
||||
) async {
|
||||
if (state is DiaryStateLoaded) {
|
||||
await diaryRepository.sendModeration(
|
||||
event.name,
|
||||
event.energyOn100gr,
|
||||
event.proteinsOn100gr,
|
||||
event.fatsOn100gr,
|
||||
event.carbohydratesOn100gr,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
FutureOr<void> _clearInput(
|
||||
ClearInput event,
|
||||
Emitter<DiaryState> emit,
|
||||
) {
|
||||
if (state is DiaryStateLoaded) {
|
||||
var currentState = state as DiaryStateLoaded;
|
||||
DiaryStateLoaded updatedState = currentState.copyWith();
|
||||
emit(updatedState);
|
||||
}
|
||||
}
|
||||
|
||||
FutureOr<void> _changePortion(
|
||||
ChangePortion event,
|
||||
Emitter<DiaryState> emit,
|
||||
) {
|
||||
if (state is DiaryStateLoaded) {
|
||||
var currentState = state as DiaryStateLoaded;
|
||||
DiaryStateLoaded updatedState = currentState.copyWith(
|
||||
portionController: event.value,
|
||||
);
|
||||
emit(updatedState);
|
||||
}
|
||||
}
|
||||
|
||||
FutureOr<void> _toggleMood(
|
||||
ToggleMoodExpandedEvent event,
|
||||
Emitter<DiaryState> emit,
|
||||
) {
|
||||
if (state is DiaryStateLoaded) {
|
||||
var currentState = state as DiaryStateLoaded;
|
||||
|
||||
emit(currentState.copyWith(moodExpanded: !currentState.moodExpanded));
|
||||
}
|
||||
}
|
||||
|
||||
FutureOr<void> _toggleWakeup(
|
||||
ToggleWakeupExpandedEvent event,
|
||||
Emitter<DiaryState> emit,
|
||||
) {
|
||||
if (state is DiaryStateLoaded) {
|
||||
var currentState = state as DiaryStateLoaded;
|
||||
|
||||
emit(currentState.copyWith(wakeupExpanded: !currentState.wakeupExpanded));
|
||||
}
|
||||
}
|
||||
|
||||
FutureOr<void> _removeImage(
|
||||
RemoveImageEvent event,
|
||||
Emitter<DiaryState> 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<void> _finishDay(FinishDay event, Emitter<DiaryState> 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<String> 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<SelectionPopupModel> fillPortion() {
|
||||
return [
|
||||
SelectionPopupModel(id: 0, title: "порций", isSelected: true),
|
||||
SelectionPopupModel(id: 1, title: "грамм"),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
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}');
|
||||
}
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
/*import 'package:eatvio_app/core/app_export.dart';
|
||||
import 'package:eatvio_app/features/diary/presentation/bloc/diary_state.dart';
|
||||
import 'package:eatvio_app/features/diary/repositories/diary_repository.dart';
|
||||
|
||||
class DiaryCubit extends Cubit<DiaryState> {
|
||||
final DiaryRepository blogPostRepository;
|
||||
|
||||
DiaryCubit({required this.blogPostRepository})
|
||||
: super(const DiaryState.loading());
|
||||
|
||||
loadDiary(String blogPostID) async {
|
||||
emit(const DiaryState.loading());
|
||||
try {
|
||||
final blogPost = await blogPostRepository.getDiary(blogPostID);
|
||||
emit(DiaryState.loaded(blogPost: blogPost));
|
||||
} catch (e) {
|
||||
emit(DiaryState.error(errorMessage: e.toString()));
|
||||
print(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
@@ -1,58 +1,54 @@
|
||||
// ignore_for_file: must_be_immutable
|
||||
|
||||
part of 'diary_edit_bloc.dart';
|
||||
part of 'diary_bloc.dart';
|
||||
|
||||
/// Abstract class for all events that can be dispatched from the
|
||||
///DiaryEdit widget.
|
||||
///Diary widget.
|
||||
///
|
||||
/// Events must be immutable and implement the [Equatable] interface.
|
||||
@immutable
|
||||
abstract class DiaryEditEvent extends Equatable {}
|
||||
abstract class DiaryEvent extends Equatable {}
|
||||
|
||||
/// Event that is dispatched when the DiaryEdit widget is first created.
|
||||
class DiaryEditInitialEvent extends DiaryEditEvent {
|
||||
/// Event that is dispatched when the Diary widget is first created.
|
||||
class LoadDiary extends DiaryEvent {
|
||||
@override
|
||||
List<Object?> get props => [];
|
||||
}
|
||||
|
||||
class ChangeSatiety extends DiaryEditEvent {
|
||||
class ChangeSatiety extends DiaryEvent {
|
||||
ChangeSatiety(
|
||||
this.selectedElement,
|
||||
);
|
||||
final int selectedElement;
|
||||
|
||||
@override
|
||||
List<Object> get props => [selectedElement];
|
||||
}
|
||||
|
||||
class ChangeMood extends DiaryEditEvent {
|
||||
class ChangeMood extends DiaryEvent {
|
||||
ChangeMood(
|
||||
this.selectedElement,
|
||||
);
|
||||
final int selectedElement;
|
||||
|
||||
@override
|
||||
List<Object> get props => [selectedElement];
|
||||
}
|
||||
|
||||
class ChangeMealTime extends DiaryEditEvent {
|
||||
class ChangeMealTime extends DiaryEvent {
|
||||
ChangeMealTime(this.time);
|
||||
final TimeOfDay time;
|
||||
|
||||
@override
|
||||
List<Object> get props => [time];
|
||||
}
|
||||
|
||||
class AddComment extends DiaryEditEvent {
|
||||
class AddComment extends DiaryEvent {
|
||||
AddComment(this.diaryId, this.comment);
|
||||
final String comment;
|
||||
final int diaryId;
|
||||
|
||||
@override
|
||||
List<Object> get props => [comment, diaryId];
|
||||
}
|
||||
|
||||
class WakeupEvent extends DiaryEditEvent {
|
||||
class WakeupEvent extends DiaryEvent {
|
||||
WakeupEvent(this.selectedTime);
|
||||
final TimeOfDay selectedTime;
|
||||
|
||||
@@ -60,7 +56,7 @@ class WakeupEvent extends DiaryEditEvent {
|
||||
List<Object> get props => [selectedTime];
|
||||
}
|
||||
|
||||
class RetireEvent extends DiaryEditEvent {
|
||||
class RetireEvent extends DiaryEvent {
|
||||
RetireEvent(this.selectedTime);
|
||||
final TimeOfDay selectedTime;
|
||||
|
||||
@@ -68,37 +64,37 @@ class RetireEvent extends DiaryEditEvent {
|
||||
List<Object> get props => [selectedTime];
|
||||
}
|
||||
|
||||
class ToggleMoodExpandedEvent extends DiaryEditEvent {
|
||||
class ToggleMoodExpandedEvent extends DiaryEvent {
|
||||
@override
|
||||
List<Object?> get props => [];
|
||||
}
|
||||
|
||||
class ToggleWakeupExpandedEvent extends DiaryEditEvent {
|
||||
class ToggleWakeupExpandedEvent extends DiaryEvent {
|
||||
@override
|
||||
List<Object?> get props => [];
|
||||
}
|
||||
|
||||
class AddPortionEvent extends DiaryEditEvent {
|
||||
class AddPortionEvent extends DiaryEvent {
|
||||
AddPortionEvent();
|
||||
@override
|
||||
List<Object> get props => [];
|
||||
}
|
||||
|
||||
class RemovePortionEvent extends DiaryEditEvent {
|
||||
class RemovePortionEvent extends DiaryEvent {
|
||||
RemovePortionEvent(this.portionId);
|
||||
final int portionId;
|
||||
@override
|
||||
List<Object> get props => [portionId];
|
||||
}
|
||||
|
||||
class UploadImages extends DiaryEditEvent {
|
||||
class UploadImages extends DiaryEvent {
|
||||
UploadImages(this.image);
|
||||
final XFile image;
|
||||
@override
|
||||
List<Object> get props => [image];
|
||||
}
|
||||
|
||||
class RemoveImageEvent extends DiaryEditEvent {
|
||||
class RemoveImageEvent extends DiaryEvent {
|
||||
RemoveImageEvent(this.photoID, this.path);
|
||||
final String photoID;
|
||||
final String path;
|
||||
@@ -106,53 +102,48 @@ class RemoveImageEvent extends DiaryEditEvent {
|
||||
List<Object> get props => [photoID, path];
|
||||
}
|
||||
|
||||
class ProductInput extends DiaryEditEvent {
|
||||
class ProductInput extends DiaryEvent {
|
||||
ProductInput(this.input);
|
||||
final String input;
|
||||
@override
|
||||
List<Object> get props => [input];
|
||||
}
|
||||
|
||||
class ChangeMeal extends DiaryEditEvent {
|
||||
ChangeMeal({required this.value, required this.meals});
|
||||
|
||||
class ChangeMeal extends DiaryEvent {
|
||||
ChangeMeal({required this.value});
|
||||
SelectionPopupModel value;
|
||||
List<dynamic>? meals;
|
||||
@override
|
||||
List<Object?> get props => [value, meals];
|
||||
List<Object?> get props => [value];
|
||||
}
|
||||
|
||||
class ClearInput extends DiaryEditEvent {
|
||||
class ClearInput extends DiaryEvent {
|
||||
ClearInput({required this.value});
|
||||
|
||||
TextEditingController value;
|
||||
@override
|
||||
List<Object?> get props => [value];
|
||||
}
|
||||
|
||||
class ChangePortion extends DiaryEditEvent {
|
||||
class ChangePortion extends DiaryEvent {
|
||||
ChangePortion({required this.value});
|
||||
|
||||
SelectionPopupModel value;
|
||||
@override
|
||||
List<Object?> get props => [value];
|
||||
}
|
||||
|
||||
class FinishDay extends DiaryEditEvent {
|
||||
class FinishDay extends DiaryEvent {
|
||||
FinishDay();
|
||||
|
||||
@override
|
||||
List<Object?> get props => [];
|
||||
}
|
||||
|
||||
class RefreshEvent extends DiaryEditEvent {
|
||||
class RefreshEvent extends DiaryEvent {
|
||||
RefreshEvent();
|
||||
|
||||
@override
|
||||
List<Object?> get props => [];
|
||||
}
|
||||
|
||||
class SendModeration extends DiaryEditEvent {
|
||||
class SendModeration extends DiaryEvent {
|
||||
SendModeration({
|
||||
required this.name,
|
||||
required this.energyOn100gr,
|
||||
@@ -166,5 +157,6 @@ class SendModeration extends DiaryEditEvent {
|
||||
String fatsOn100gr;
|
||||
String carbohydratesOn100gr;
|
||||
@override
|
||||
List<Object?> get props => [name, energyOn100gr, proteinsOn100gr, fatsOn100gr, carbohydratesOn100gr];
|
||||
List<Object?> get props =>
|
||||
[name, energyOn100gr, proteinsOn100gr, fatsOn100gr, carbohydratesOn100gr];
|
||||
}
|
||||
@@ -1,6 +1,12 @@
|
||||
/*import 'package:eatvio_app/features/diary/models/diary_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/portion.dart';
|
||||
import 'package:eatvio_app/features/diary/models/product.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
||||
import '../../../../data/models/selectionPopupModel/selection_popup_model.dart';
|
||||
|
||||
part 'diary_state.freezed.dart';
|
||||
|
||||
@freezed
|
||||
@@ -10,11 +16,45 @@ abstract class DiaryState with _$DiaryState {
|
||||
const factory DiaryState.loading() = DiaryStateLoading;
|
||||
|
||||
const factory DiaryState.loaded({
|
||||
required DiaryModel blogPost,
|
||||
required DiaryModel diary,
|
||||
String? diaryDate,
|
||||
required List<int> recommendedChartValues,
|
||||
required List<int> consumedChartValues,
|
||||
required List<Portion> portions,
|
||||
required List<SelectionPopupModel> mealList,
|
||||
required List<SelectionPopupModel> portionList,
|
||||
required List<Product> autocompleteList,
|
||||
required Meal currentMeal,
|
||||
required SelectionPopupModel portionController,
|
||||
TimeOfDay? wakeupController,
|
||||
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<NutritionData>? chartData,
|
||||
}) = DiaryStateLoaded;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
1582
lib/features/diary/presentation/bloc/diary_state.freezed.dart
Normal file
1582
lib/features/diary/presentation/bloc/diary_state.freezed.dart
Normal file
File diff suppressed because it is too large
Load Diff
@@ -1,57 +1,64 @@
|
||||
// ignore_for_file: unused_local_variable
|
||||
|
||||
/*import 'bloc/diary_edit_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: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/presentation/bloc/diary_state.dart';
|
||||
import 'package:eatvio_app/core/app_export.dart';
|
||||
import 'package:eatvio_app/widgets/custom_edit_text_form_field.dart';
|
||||
import 'package:eatvio_app/widgets/custom_edit_drop_down.dart';
|
||||
import 'package:eatvio_app/widgets/custom_outlined_button.dart';
|
||||
import 'package:eatvio_app/widgets/custom_scale_element.dart';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter_form_builder/flutter_form_builder.dart';
|
||||
import 'package:flutter_dotenv/flutter_dotenv.dart';
|
||||
import 'package:image_picker/image_picker.dart';
|
||||
import 'package:carousel_slider/carousel_slider.dart';
|
||||
import 'package:syncfusion_flutter_charts/charts.dart';
|
||||
|
||||
// ignore: must_be_immutable
|
||||
class DiaryEditScreen extends StatelessWidget {
|
||||
DiaryEditScreen({Key? key}) : super(key: key);
|
||||
|
||||
static Widget builder(BuildContext context) {
|
||||
return BlocProvider<DiaryEditBloc>(
|
||||
create: (context) =>
|
||||
DiaryEditBloc(DiaryEditState(diaryEditModelObj: DiaryEditModel()))
|
||||
..add(DiaryEditInitialEvent()),
|
||||
child: DiaryEditScreen(),
|
||||
);
|
||||
}
|
||||
|
||||
class DiaryScreen extends StatelessWidget {
|
||||
DiaryScreen({Key? key}) : super(key: key);
|
||||
Widget build(BuildContext context) {
|
||||
return BlocBuilder<DiaryEditBloc, DiaryEditState>(
|
||||
return BlocBuilder<DiaryBloc, DiaryState>(
|
||||
builder: (context, state) {
|
||||
if (state is DiaryEditInitialState) {
|
||||
// Это начальное состояние, данные ещё не загружены.
|
||||
return Container(
|
||||
color: Colors.white,
|
||||
if (state is DiaryStateLoaded) {
|
||||
return _buildDiary(context, state);
|
||||
} else if (state is DiaryStateLoading) {
|
||||
return Scaffold(
|
||||
body: Center(
|
||||
child: CupertinoActivityIndicator(),
|
||||
),
|
||||
);
|
||||
} else if (state is DiaryStateError) {
|
||||
return Scaffold(
|
||||
body: Padding(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Center(
|
||||
child: Text(state.errorMessage),
|
||||
),
|
||||
),
|
||||
);
|
||||
} else
|
||||
return Scaffold(
|
||||
body: Padding(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Center(
|
||||
child: Text("Неопределенная ошибка"),
|
||||
),
|
||||
),
|
||||
);
|
||||
} 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) {
|
||||
Widget _buildDiary(BuildContext context, DiaryStateLoaded state) {
|
||||
return RefreshIndicator(
|
||||
onRefresh: refreshPage(context),
|
||||
child: Stack(
|
||||
@@ -82,7 +89,7 @@ class DiaryEditScreen extends StatelessWidget {
|
||||
_buildMeal(context, state),
|
||||
SizedBox(height: 20.v),
|
||||
_buildMood(context, state),
|
||||
SizedBox(height: 30.v),
|
||||
SizedBox(height: 20.v),
|
||||
_buildNutritionChart(context, state),
|
||||
SizedBox(height: 30.v),
|
||||
_buildComment(context, state),
|
||||
@@ -102,6 +109,39 @@ class DiaryEditScreen extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
_buildNutritionChart(BuildContext context, DiaryStateLoaded state) {
|
||||
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: SfCircularChart(
|
||||
title: ChartTitle(text: 'График КБЖУ'),
|
||||
legend: Legend(isVisible: true),
|
||||
series: <CircularSeries>[
|
||||
RadialBarSeries<NutritionData, String>(
|
||||
dataSource: state.chartData,
|
||||
xValueMapper: (NutritionData data, _) => data.category,
|
||||
yValueMapper: (NutritionData data, _) => data.nutrition,
|
||||
pointColorMapper: (NutritionData data, _) => data.color,
|
||||
)
|
||||
],
|
||||
));
|
||||
}
|
||||
|
||||
_buildEndDay(BuildContext context) {
|
||||
return CustomOutlinedButton(
|
||||
text: "Закончить день",
|
||||
@@ -115,19 +155,18 @@ class DiaryEditScreen extends StatelessWidget {
|
||||
color: Colors.transparent,
|
||||
),
|
||||
onPressed: onFinishDayPressed(context),
|
||||
// Установите прозрачный фон
|
||||
);
|
||||
}
|
||||
|
||||
refreshPage(BuildContext context) {
|
||||
return () async {
|
||||
context.read<DiaryEditBloc>().add(RefreshEvent());
|
||||
context.read<DiaryBloc>().add(RefreshEvent());
|
||||
};
|
||||
}
|
||||
|
||||
/// Section Widget
|
||||
_buildHeaderRow(BuildContext context, DiaryEditLoadedState state) {
|
||||
final day = state.diaryId;
|
||||
_buildHeaderRow(BuildContext context, DiaryStateLoaded state) {
|
||||
final day = state.diary.id;
|
||||
return Container(
|
||||
margin: EdgeInsets.symmetric(horizontal: 16.h, vertical: 16.h),
|
||||
padding: EdgeInsets.symmetric(
|
||||
@@ -162,7 +201,7 @@ class DiaryEditScreen extends StatelessWidget {
|
||||
),
|
||||
SizedBox(height: 2.v),
|
||||
Text(
|
||||
state.diaryDate.toString(),
|
||||
state.diary.date.toString(),
|
||||
style: CustomTextStyles.bodyMediumBluegray800,
|
||||
),
|
||||
],
|
||||
@@ -174,7 +213,7 @@ class DiaryEditScreen extends StatelessWidget {
|
||||
}
|
||||
|
||||
/// Section Widget
|
||||
_buildAddProduct(BuildContext context, DiaryEditLoadedState state) {
|
||||
_buildAddProduct(BuildContext context, DiaryState state) {
|
||||
return CustomOutlinedButton(
|
||||
text: "Добавить продукт",
|
||||
margin: EdgeInsets.symmetric(horizontal: 10.h),
|
||||
@@ -185,12 +224,12 @@ class DiaryEditScreen extends StatelessWidget {
|
||||
|
||||
addProduct(BuildContext context) {
|
||||
return () {
|
||||
context.read<DiaryEditBloc>().add(AddPortionEvent());
|
||||
context.read<DiaryBloc>().add(AddPortionEvent());
|
||||
};
|
||||
}
|
||||
|
||||
/// Section Widget
|
||||
_buildAddPhoto(BuildContext context, DiaryEditLoadedState state) {
|
||||
_buildAddPhoto(BuildContext context, DiaryStateLoaded state) {
|
||||
bool isLoading = state.isLoading;
|
||||
return GestureDetector(
|
||||
onTap: addImage(context, isLoading),
|
||||
@@ -210,8 +249,6 @@ class DiaryEditScreen extends StatelessWidget {
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
// Показывайте прелоадер, если загрузка активна
|
||||
|
||||
Padding(
|
||||
padding: EdgeInsets.only(
|
||||
left: 7.h,
|
||||
@@ -258,18 +295,17 @@ class DiaryEditScreen extends StatelessWidget {
|
||||
List<XFile>? images = await picker.pickMultiImage();
|
||||
if (images.isNotEmpty) {
|
||||
for (var image in images) {
|
||||
context.read<DiaryEditBloc>().add(UploadImages(image));
|
||||
context.read<DiaryBloc>().add(UploadImages(image));
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
_buildMeal(BuildContext context, DiaryEditLoadedState state) {
|
||||
_buildMeal(BuildContext context, DiaryStateLoaded state) {
|
||||
final digitsOnly = FilteringTextInputFormatter.digitsOnly;
|
||||
List<String> _options =
|
||||
state.autocompleteList!.map((dynamic item) => item as String).toList();
|
||||
//print(_options);
|
||||
state.autocompleteList.map((Product item) => item.name).toList();
|
||||
FocusNode focusNodeName = FocusNode();
|
||||
return Container(
|
||||
margin: EdgeInsets.symmetric(horizontal: 16.h),
|
||||
@@ -329,17 +365,21 @@ class DiaryEditScreen extends StatelessWidget {
|
||||
SizedBox(height: 20.v),
|
||||
Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 10.h),
|
||||
child: BlocSelector<DiaryEditBloc, DiaryEditState, DiaryEditModel?>(
|
||||
selector: (state) => state.diaryEditModelObj,
|
||||
builder: (context, diaryEditModelObj) {
|
||||
child: BlocSelector<DiaryBloc, DiaryState, DiaryModel?>(
|
||||
selector: (state) {
|
||||
if (state is DiaryStateLoaded)
|
||||
return state.diary;
|
||||
else
|
||||
return null;
|
||||
},
|
||||
builder: (context, diary) {
|
||||
return CustomDropDown(
|
||||
hintText: "Прием пищи",
|
||||
items: diaryEditModelObj?.mealList,
|
||||
items: state.mealList,
|
||||
contentPadding: EdgeInsets.symmetric(
|
||||
horizontal: 10.h,
|
||||
vertical: 9.v,
|
||||
),
|
||||
defaultValue: diaryEditModelObj?.mealList[0],
|
||||
defaultValue: state.mealList[0],
|
||||
onChanged: changeMeal(context, state),
|
||||
);
|
||||
},
|
||||
@@ -424,13 +464,17 @@ class DiaryEditScreen extends StatelessWidget {
|
||||
),
|
||||
Padding(
|
||||
padding: EdgeInsets.only(left: 30.h),
|
||||
child: BlocSelector<DiaryEditBloc, DiaryEditState,
|
||||
DiaryEditModel?>(
|
||||
selector: (state) => state.diaryEditModelObj,
|
||||
builder: (context, diaryEditModelObj) {
|
||||
child: BlocSelector<DiaryBloc, DiaryState, DiaryModel?>(
|
||||
selector: (state) {
|
||||
if (state is DiaryStateLoaded) {
|
||||
return state.diary;
|
||||
} else
|
||||
return null;
|
||||
},
|
||||
builder: (context, diary) {
|
||||
return CustomDropDown(
|
||||
items: diaryEditModelObj?.portionList,
|
||||
defaultValue: diaryEditModelObj?.portionList?[0],
|
||||
items: state.portionList,
|
||||
defaultValue: state.portionController,
|
||||
onChanged: changePortion(context, state),
|
||||
);
|
||||
},
|
||||
@@ -443,17 +487,10 @@ class DiaryEditScreen extends StatelessWidget {
|
||||
SizedBox(height: 30.v),
|
||||
_buildAddProduct(context, state),
|
||||
SizedBox(height: 30.v),
|
||||
...state.portions!
|
||||
...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),
|
||||
@@ -463,9 +500,9 @@ class DiaryEditScreen extends StatelessWidget {
|
||||
style: CustomTextStyles.bodyMediumBlack900,
|
||||
),
|
||||
SizedBox(height: 15.v),
|
||||
BlocBuilder<DiaryEditBloc, DiaryEditState>(
|
||||
BlocBuilder<DiaryBloc, DiaryState>(
|
||||
builder: (context, state) {
|
||||
if (state is DiaryEditLoadedState) {
|
||||
if (state is DiaryStateLoaded) {
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
@@ -505,7 +542,7 @@ class DiaryEditScreen extends StatelessWidget {
|
||||
],
|
||||
);
|
||||
} else {
|
||||
return Container(); // Возвращаем пустой контейнер, если состояние не является DiaryEditLoadedState
|
||||
return Container(); // Возвращаем пустой контейнер, если состояние не является DiaryState
|
||||
}
|
||||
},
|
||||
),
|
||||
@@ -514,7 +551,7 @@ class DiaryEditScreen extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
openCaloriesDialog(BuildContext context, DiaryEditLoadedState state) {
|
||||
openCaloriesDialog(BuildContext context, DiaryStateLoaded state) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext dialogContext) {
|
||||
@@ -525,7 +562,7 @@ class DiaryEditScreen extends StatelessWidget {
|
||||
children: [
|
||||
CustomTextFormField(
|
||||
hintText: "Название",
|
||||
controller: state.productNameController,
|
||||
controller: state.product_nameController,
|
||||
),
|
||||
SizedBox(height: 10.v),
|
||||
CustomTextFormField(
|
||||
@@ -561,11 +598,11 @@ class DiaryEditScreen extends StatelessWidget {
|
||||
TextButton(
|
||||
onPressed: triggerModeration(
|
||||
context,
|
||||
state.productNameController!.text,
|
||||
state.caloriesController!.text,
|
||||
state.proteinsController!.text,
|
||||
state.fatsController!.text,
|
||||
state.carbsController!.text,
|
||||
state.product_nameController.text,
|
||||
state.caloriesController.text,
|
||||
state.proteinsController.text,
|
||||
state.fatsController.text,
|
||||
state.carbsController.text,
|
||||
dialogContext,
|
||||
),
|
||||
child: Text('Отправить'),
|
||||
@@ -586,8 +623,7 @@ class DiaryEditScreen extends StatelessWidget {
|
||||
BuildContext dialogContext,
|
||||
) {
|
||||
return () {
|
||||
// Call function to send moderation with the entered values
|
||||
context.read<DiaryEditBloc>().add(
|
||||
context.read<DiaryBloc>().add(
|
||||
SendModeration(
|
||||
name: name,
|
||||
energyOn100gr: energyOn100gr,
|
||||
@@ -596,7 +632,7 @@ class DiaryEditScreen extends StatelessWidget {
|
||||
carbohydratesOn100gr: carbohydratesOn100gr,
|
||||
),
|
||||
);
|
||||
Navigator.of(dialogContext).pop(); // Dismiss the dialog
|
||||
Navigator.of(dialogContext).pop();
|
||||
};
|
||||
}
|
||||
|
||||
@@ -609,13 +645,13 @@ class DiaryEditScreen extends StatelessWidget {
|
||||
|
||||
changeSatiety(BuildContext context, int satiety) {
|
||||
return () {
|
||||
context.read<DiaryEditBloc>().add(ChangeSatiety(satiety));
|
||||
context.read<DiaryBloc>().add(ChangeSatiety(satiety));
|
||||
};
|
||||
}
|
||||
|
||||
selectProduct(AutocompleteOnSelected<String> onSelected, String option,
|
||||
DiaryEditLoadedState state) {
|
||||
state.productNameController?.text = option;
|
||||
DiaryStateLoaded state) {
|
||||
state.product_nameController.text = option;
|
||||
return () {
|
||||
onSelected(option);
|
||||
};
|
||||
@@ -623,11 +659,8 @@ class DiaryEditScreen extends StatelessWidget {
|
||||
|
||||
getAutocomplete(BuildContext context, FocusNode focusNode) {
|
||||
return (value) {
|
||||
/*print(state.autocompleteList
|
||||
?.map((dynamic item) => item as String)
|
||||
.toList());*/
|
||||
if (value.length > 2) {
|
||||
context.read<DiaryEditBloc>().add(ProductInput(value));
|
||||
context.read<DiaryBloc>().add(ProductInput(value));
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -640,35 +673,32 @@ class DiaryEditScreen extends StatelessWidget {
|
||||
};
|
||||
}
|
||||
|
||||
changeMeal(BuildContext context, DiaryEditLoadedState state) {
|
||||
changeMeal(BuildContext context, DiaryStateLoaded state) {
|
||||
return (value) {
|
||||
context
|
||||
.read<DiaryEditBloc>()
|
||||
.add(ChangeMeal(meals: state.meals, value: value));
|
||||
context.read<DiaryBloc>().add(ChangeMeal(value: value));
|
||||
};
|
||||
}
|
||||
|
||||
changePortion(BuildContext context, DiaryEditLoadedState state) {
|
||||
changePortion(BuildContext context, DiaryStateLoaded state) {
|
||||
return (value) {
|
||||
context.read<DiaryEditBloc>().add(ChangePortion(value: value));
|
||||
context.read<DiaryBloc>().add(ChangePortion(value: value));
|
||||
};
|
||||
}
|
||||
|
||||
_buildCarousel(BuildContext context, DiaryEditLoadedState state) {
|
||||
if (state.photos!.isEmpty) {
|
||||
_buildCarousel(BuildContext context, DiaryStateLoaded state) {
|
||||
if (state.currentMeal.photos.isEmpty) {
|
||||
return Text("Фото нет");
|
||||
} else {
|
||||
return CarouselSlider(
|
||||
options: CarouselOptions(height: 340.0),
|
||||
items: state.photos!.map<Widget>((photo) {
|
||||
return _buildPhoto(
|
||||
context, photo); // Assuming photos are stored as strings
|
||||
items: state.currentMeal.photos.map<Widget>((photo) {
|
||||
return _buildPhoto(context, photo);
|
||||
}).toList(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
_buildProduct(BuildContext context, Map<String, dynamic> portion) {
|
||||
_buildProduct(BuildContext context, Portion portion) {
|
||||
return Container(
|
||||
margin: EdgeInsets.symmetric(horizontal: 10.h),
|
||||
padding: EdgeInsets.symmetric(
|
||||
@@ -688,9 +718,9 @@ class DiaryEditScreen extends StatelessWidget {
|
||||
top: 5.v,
|
||||
),
|
||||
child: Text(
|
||||
portion['product_name'].length > 8
|
||||
? portion['product_name'].substring(0, 8)
|
||||
: portion['product_name'],
|
||||
portion.product_name.length > 8
|
||||
? portion.product_name.substring(0, 8)
|
||||
: portion.product_name,
|
||||
style: CustomTextStyles.titleMedium16,
|
||||
),
|
||||
),
|
||||
@@ -701,9 +731,7 @@ class DiaryEditScreen extends StatelessWidget {
|
||||
bottom: 3.v,
|
||||
),
|
||||
child: Text(
|
||||
portion['quantity'].toString() +
|
||||
' ' +
|
||||
portion['portion'].toString().tr,
|
||||
portion.quantity.toString() + ' ' + portion.portion.toString().tr,
|
||||
),
|
||||
),
|
||||
Spacer(),
|
||||
@@ -722,7 +750,7 @@ class DiaryEditScreen extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
_buildPhoto(BuildContext context, Map<String, dynamic> photo) {
|
||||
_buildPhoto(BuildContext context, Photo photo) {
|
||||
return Stack(
|
||||
children: [
|
||||
Container(
|
||||
@@ -731,7 +759,7 @@ class DiaryEditScreen extends StatelessWidget {
|
||||
borderRadius: BorderRadiusStyle.roundedBorder5,
|
||||
),
|
||||
child: Image.network(
|
||||
baseUrl + '/storage/' + photo['path'],
|
||||
dotenv.env['STORAGE_URL']! + photo.path,
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
@@ -756,21 +784,21 @@ class DiaryEditScreen extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
removePortion(BuildContext context, Map<String, dynamic> portion) {
|
||||
removePortion(BuildContext context, Portion portion) {
|
||||
return () {
|
||||
context.read<DiaryEditBloc>().add(RemovePortionEvent(portion['id']));
|
||||
context.read<DiaryBloc>().add(RemovePortionEvent(portion.id));
|
||||
};
|
||||
}
|
||||
|
||||
removePhoto(BuildContext context, Map<String, dynamic> photo) {
|
||||
removePhoto(BuildContext context, Photo photo) {
|
||||
return () {
|
||||
context
|
||||
.read<DiaryEditBloc>()
|
||||
.add(RemoveImageEvent(photo['id'].toString(), photo['path']));
|
||||
.read<DiaryBloc>()
|
||||
.add(RemoveImageEvent(photo.id.toString(), photo.path));
|
||||
};
|
||||
}
|
||||
|
||||
_buildNutritionChart(BuildContext context, DiaryEditLoadedState state) {
|
||||
/*_buildNutritionChart(BuildContext context, DiaryStateLoaded state) {
|
||||
final List<int> recommendedValues = state
|
||||
.recommendedChartValues; // Рекомендуемые значения: калории, жиры, белки, углеводы
|
||||
final List<int> consumedValues = state.consumedChartValues; //
|
||||
@@ -989,10 +1017,10 @@ class DiaryEditScreen extends StatelessWidget {
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}*/
|
||||
|
||||
/// Section Widget
|
||||
_buildComment(BuildContext context, DiaryEditLoadedState state) {
|
||||
_buildComment(BuildContext context, DiaryStateLoaded state) {
|
||||
return Container(
|
||||
margin: EdgeInsets.symmetric(horizontal: 16.h),
|
||||
padding: EdgeInsets.symmetric(
|
||||
@@ -1036,7 +1064,7 @@ class DiaryEditScreen extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
_buildWakupRetire(BuildContext context, DiaryEditLoadedState state) {
|
||||
_buildWakupRetire(BuildContext context, DiaryStateLoaded state) {
|
||||
return Container(
|
||||
margin: EdgeInsets.symmetric(horizontal: 16.h),
|
||||
padding: EdgeInsets.symmetric(
|
||||
@@ -1112,7 +1140,7 @@ class DiaryEditScreen extends StatelessWidget {
|
||||
|
||||
toggleWakeup(BuildContext context) {
|
||||
return () {
|
||||
BlocProvider.of<DiaryEditBloc>(context).add(ToggleWakeupExpandedEvent());
|
||||
BlocProvider.of<DiaryBloc>(context).add(ToggleWakeupExpandedEvent());
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1146,7 +1174,7 @@ class DiaryEditScreen extends StatelessWidget {
|
||||
BuildContext dialogContext, BuildContext context) {
|
||||
return () {
|
||||
closeDialog(dialogContext);
|
||||
context.read<DiaryEditBloc>().add(FinishDay());
|
||||
context.read<DiaryBloc>().add(FinishDay());
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1156,7 +1184,7 @@ class DiaryEditScreen extends StatelessWidget {
|
||||
};
|
||||
}
|
||||
|
||||
_buildMood(BuildContext context, DiaryEditLoadedState state) {
|
||||
_buildMood(BuildContext context, DiaryStateLoaded state) {
|
||||
return Container(
|
||||
margin: EdgeInsets.symmetric(horizontal: 16.h),
|
||||
padding: EdgeInsets.symmetric(
|
||||
@@ -1238,49 +1266,46 @@ class DiaryEditScreen extends StatelessWidget {
|
||||
|
||||
changeMood(BuildContext context, int satiety) {
|
||||
return () {
|
||||
context.read<DiaryEditBloc>().add(ChangeMood(satiety));
|
||||
context.read<DiaryBloc>().add(ChangeMood(satiety));
|
||||
};
|
||||
}
|
||||
|
||||
toggleMood(BuildContext context) {
|
||||
return () {
|
||||
BlocProvider.of<DiaryEditBloc>(context).add(ToggleMoodExpandedEvent());
|
||||
BlocProvider.of<DiaryBloc>(context).add(ToggleMoodExpandedEvent());
|
||||
};
|
||||
}
|
||||
|
||||
Future<void> _selectWakeupTime(
|
||||
BuildContext context, DiaryEditLoadedState state) async {
|
||||
BuildContext context, DiaryStateLoaded 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<DiaryEditBloc>().add(WakeupEvent(pickedTime));
|
||||
context.read<DiaryBloc>().add(WakeupEvent(pickedTime));
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _selectRetireTime(
|
||||
BuildContext context, DiaryEditLoadedState state) async {
|
||||
BuildContext context, DiaryStateLoaded 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<DiaryEditBloc>().add(RetireEvent(pickedTime));
|
||||
context.read<DiaryBloc>().add(RetireEvent(pickedTime));
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _selectMealTime(
|
||||
BuildContext context, DiaryEditLoadedState state) async {
|
||||
BuildContext context, DiaryStateLoaded 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<DiaryEditBloc>().add(ChangeMealTime(pickedTime));
|
||||
context.read<DiaryBloc>().add(ChangeMealTime(pickedTime));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1296,4 +1321,13 @@ bool checkConsumedValues(
|
||||
// Если ни одно потребленное значение не превышает рекомендованное с соответствующим индексом
|
||||
return false; // Возвращаем true
|
||||
}
|
||||
*/
|
||||
|
||||
List<SelectionPopupModel> mealsToDropdown(List<Meal>? meals) {
|
||||
return meals!
|
||||
.map((meal) => SelectionPopupModel(
|
||||
id: meal.id,
|
||||
title: "Прием пищи ${meal.type}",
|
||||
isSelected: false,
|
||||
))
|
||||
.toList();
|
||||
}
|
||||
|
||||
@@ -1,17 +1,212 @@
|
||||
/*import 'package:eatvio_app/features/diary/models/diary_model.dart';
|
||||
import 'dart:io';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:intl/intl.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/services/diary_service.dart';
|
||||
|
||||
class DiaryRepository {
|
||||
final DiaryService blogPostService;
|
||||
final DiaryService diaryService;
|
||||
|
||||
DiaryRepository({required this.blogPostService});
|
||||
DiaryRepository({required this.diaryService});
|
||||
|
||||
Future<DiaryModel> getDiary(String blogPostID) async {
|
||||
Future<Map<String, int>> getDiaryID() async {
|
||||
try {
|
||||
return await blogPostService.getDiary(blogPostID);
|
||||
return await diaryService.getDiaryID();
|
||||
} catch (e) {
|
||||
rethrow;
|
||||
}
|
||||
}
|
||||
|
||||
Future<DiaryModel> getDiary(int diaryID) async {
|
||||
try {
|
||||
return (await diaryService.getDiary(diaryID))['diary']!;
|
||||
} catch (e) {
|
||||
rethrow;
|
||||
}
|
||||
}
|
||||
|
||||
Future<Map<String, dynamic>> getChartData(int diaryID) async {
|
||||
try {
|
||||
return (await diaryService.getChart(diaryID));
|
||||
} catch (e) {
|
||||
rethrow;
|
||||
}
|
||||
}
|
||||
|
||||
Future<Map<String, List<Product>>> inputProduct(String name) async {
|
||||
try {
|
||||
return await diaryService.getInputProduct(name);
|
||||
} catch (e) {
|
||||
rethrow;
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> changeSatiety(int satiety, int mealID, int diaryID) async {
|
||||
try {
|
||||
await diaryService.sendSatietyData(
|
||||
diaryID,
|
||||
mealID,
|
||||
satiety,
|
||||
);
|
||||
} catch (e) {
|
||||
rethrow;
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> changeMood(int mood, int mealID, int diaryID) async {
|
||||
try {
|
||||
await diaryService.sendMoodData(
|
||||
diaryID,
|
||||
mealID,
|
||||
mood,
|
||||
);
|
||||
} catch (e) {
|
||||
rethrow;
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> changeWakeup(
|
||||
int diaryID,
|
||||
String wakeup,
|
||||
) async {
|
||||
try {
|
||||
await diaryService.sendWakeupData(
|
||||
diaryID,
|
||||
wakeup,
|
||||
);
|
||||
} catch (e) {
|
||||
rethrow;
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> changeRetire(
|
||||
int diaryID,
|
||||
String retire,
|
||||
) async {
|
||||
try {
|
||||
await diaryService.sendWakeupData(
|
||||
diaryID,
|
||||
retire,
|
||||
);
|
||||
} catch (e) {
|
||||
rethrow;
|
||||
}
|
||||
}
|
||||
|
||||
Future<Map<String, Portion>> 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<Map<String, String>> 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<void> removePortion(
|
||||
int diaryID,
|
||||
int mealID,
|
||||
int portionID,
|
||||
) async {
|
||||
try {
|
||||
await diaryService.sendRemovePortionData(
|
||||
diaryID,
|
||||
mealID,
|
||||
portionID,
|
||||
);
|
||||
} catch (e) {
|
||||
rethrow;
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> uploadImage(
|
||||
String path,
|
||||
int diaryID,
|
||||
int mealID,
|
||||
) async {
|
||||
try {
|
||||
File file = File(path);
|
||||
await diaryService.uploadImage(
|
||||
diaryID,
|
||||
mealID,
|
||||
file,
|
||||
);
|
||||
} catch (e) {
|
||||
rethrow;
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> removeImage(
|
||||
int diaryID,
|
||||
int mealID,
|
||||
int photoID,
|
||||
String path,
|
||||
) async {
|
||||
try {
|
||||
await diaryService.sendRemovePhotoData(
|
||||
diaryID,
|
||||
mealID,
|
||||
path,
|
||||
photoID,
|
||||
);
|
||||
} catch (e) {
|
||||
rethrow;
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> finishDay(
|
||||
int diaryID,
|
||||
TimeOfDay? wakeup,
|
||||
TimeOfDay? retire,
|
||||
String? comment,
|
||||
) 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,
|
||||
wakeupString,
|
||||
retireString,
|
||||
comment ?? " ",
|
||||
);
|
||||
} catch (e) {
|
||||
rethrow;
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
/*import 'package:dio/dio.dart';
|
||||
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:retrofit/retrofit.dart';
|
||||
|
||||
part 'diary_service.g.dart';
|
||||
@@ -8,7 +12,90 @@ part 'diary_service.g.dart';
|
||||
abstract class DiaryService {
|
||||
factory DiaryService(Dio dio, {String baseUrl}) = _DiaryService;
|
||||
|
||||
@GET('/api/feed/show/{id}')
|
||||
Future<DiaryModel> getDiary(@Path() String id);
|
||||
@GET('/diary/index')
|
||||
Future<Map<String, int>> getDiaryID();
|
||||
|
||||
@GET('/diary/{id}/show/')
|
||||
Future<Map<String, DiaryModel>> getDiary(@Path() int id);
|
||||
|
||||
@GET('/diary/{id}/dailyNutritionData/')
|
||||
Future<dynamic> getChart(@Path() int id);
|
||||
|
||||
@GET('/diary/product_nutritional_values/filter')
|
||||
Future<Map<String, List<Product>>> getInputProduct(
|
||||
@Query('name') String name);
|
||||
|
||||
@POST('/diary/{diary_id}/meal/{meal_id}/satiety/fill')
|
||||
Future<Map<String, int>> sendSatietyData(
|
||||
@Path() int diary_id,
|
||||
@Path() int meal_id,
|
||||
@Query('satiety') int satiety,
|
||||
);
|
||||
|
||||
@POST('/diary/{diary_id}/meal/{meal_id}/mood/fill')
|
||||
Future<Map<String, int>> sendMoodData(
|
||||
@Path() int diary_id,
|
||||
@Path() int meal_id,
|
||||
@Query('mood') int mood,
|
||||
);
|
||||
|
||||
@POST('/diary/{diary_id}/wakeup/fill')
|
||||
Future<DiaryModel> sendWakeupData(
|
||||
@Path() int diary_id,
|
||||
@Query('wakeup') String wakeup,
|
||||
);
|
||||
|
||||
@POST('/diary/{diary_id}/retire/fill')
|
||||
Future<DiaryModel> sendRetireData(
|
||||
@Path() int diary_id,
|
||||
@Query('retire') String retire,
|
||||
);
|
||||
|
||||
@POST('/diary/{diary_id}/meal/{meal_id}/portions/create')
|
||||
Future<Map<String, Portion>> sendPortionData(
|
||||
@Path() int diary_id,
|
||||
@Path() int meal_id,
|
||||
@Query('product_name') String product_name,
|
||||
@Query('portion') String portion,
|
||||
@Query('quantity') int quantity,
|
||||
);
|
||||
|
||||
@POST('/diary/{diary_id}/meal/{meal_id}/photo/upload')
|
||||
Future<void> uploadImage(
|
||||
@Path() int diary_id,
|
||||
@Path() int meal_id,
|
||||
@Part() File photo,
|
||||
);
|
||||
|
||||
@POST('/diary/product_nutritional_values/sendToModeration')
|
||||
Future<Map<String, String>> 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('/diary/{diary_id}/finishDay')
|
||||
Future<void> sendFinishDay(
|
||||
@Path() int diary_id,
|
||||
@Query('wakeUp') String wakeup,
|
||||
@Query('retire') String retire,
|
||||
@Query('comment') String comment,
|
||||
);
|
||||
|
||||
@DELETE('/diary/{diary_id}/meal/{meal_id}/portions/{portion_id}/delete')
|
||||
Future<void> sendRemovePortionData(
|
||||
@Path() int diary_id,
|
||||
@Path() int meal_id,
|
||||
@Path() int portion_id,
|
||||
);
|
||||
|
||||
@DELETE('/diary/{diary_id}/meal/{meal_id}/photo/delete')
|
||||
Future<void> sendRemovePhotoData(
|
||||
@Path() int diary_id,
|
||||
@Path() int meal_id,
|
||||
@Query('path') String path,
|
||||
@Query('id') int photo_id,
|
||||
);
|
||||
}
|
||||
*/
|
||||
|
||||
489
lib/features/diary/services/diary_service.g.dart
Normal file
489
lib/features/diary/services/diary_service.g.dart
Normal file
@@ -0,0 +1,489 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'diary_service.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// RetrofitGenerator
|
||||
// **************************************************************************
|
||||
|
||||
// ignore_for_file: unnecessary_brace_in_string_interps,no_leading_underscores_for_local_identifiers,unused_element
|
||||
|
||||
class _DiaryService implements DiaryService {
|
||||
_DiaryService(
|
||||
this._dio, {
|
||||
this.baseUrl,
|
||||
});
|
||||
|
||||
final Dio _dio;
|
||||
|
||||
String? baseUrl;
|
||||
|
||||
@override
|
||||
Future<Map<String, int>> getDiaryID() async {
|
||||
final _extra = <String, dynamic>{};
|
||||
final queryParameters = <String, dynamic>{};
|
||||
final _headers = <String, dynamic>{};
|
||||
const Map<String, dynamic>? _data = null;
|
||||
final _result = await _dio
|
||||
.fetch<Map<String, dynamic>>(_setStreamType<Map<String, int>>(Options(
|
||||
method: 'GET',
|
||||
headers: _headers,
|
||||
extra: _extra,
|
||||
)
|
||||
.compose(
|
||||
_dio.options,
|
||||
'/diary/index',
|
||||
queryParameters: queryParameters,
|
||||
data: _data,
|
||||
)
|
||||
.copyWith(
|
||||
baseUrl: _combineBaseUrls(
|
||||
_dio.options.baseUrl,
|
||||
baseUrl,
|
||||
))));
|
||||
final _value = _result.data!.cast<String, int>();
|
||||
return _value;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<Map<String, DiaryModel>> getDiary(int id) async {
|
||||
final _extra = <String, dynamic>{};
|
||||
final queryParameters = <String, dynamic>{};
|
||||
final _headers = <String, dynamic>{};
|
||||
const Map<String, dynamic>? _data = null;
|
||||
final _result = await _dio.fetch<Map<String, dynamic>>(
|
||||
_setStreamType<Map<String, DiaryModel>>(Options(
|
||||
method: 'GET',
|
||||
headers: _headers,
|
||||
extra: _extra,
|
||||
)
|
||||
.compose(
|
||||
_dio.options,
|
||||
'/diary/${id}/show/',
|
||||
queryParameters: queryParameters,
|
||||
data: _data,
|
||||
)
|
||||
.copyWith(
|
||||
baseUrl: _combineBaseUrls(
|
||||
_dio.options.baseUrl,
|
||||
baseUrl,
|
||||
))));
|
||||
var _value = _result.data!.map((k, dynamic v) =>
|
||||
MapEntry(k, DiaryModel.fromJson(v as Map<String, dynamic>)));
|
||||
return _value;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<dynamic> getChart(int id) async {
|
||||
final _extra = <String, dynamic>{};
|
||||
final queryParameters = <String, dynamic>{};
|
||||
final _headers = <String, dynamic>{};
|
||||
const Map<String, dynamic>? _data = null;
|
||||
final _result = await _dio.fetch(_setStreamType<dynamic>(Options(
|
||||
method: 'GET',
|
||||
headers: _headers,
|
||||
extra: _extra,
|
||||
)
|
||||
.compose(
|
||||
_dio.options,
|
||||
'/diary/${id}/dailyNutritionData/',
|
||||
queryParameters: queryParameters,
|
||||
data: _data,
|
||||
)
|
||||
.copyWith(
|
||||
baseUrl: _combineBaseUrls(
|
||||
_dio.options.baseUrl,
|
||||
baseUrl,
|
||||
))));
|
||||
final _value = _result.data;
|
||||
return _value;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<Map<String, List<Product>>> getInputProduct(String name) async {
|
||||
final _extra = <String, dynamic>{};
|
||||
final queryParameters = <String, dynamic>{r'name': name};
|
||||
final _headers = <String, dynamic>{};
|
||||
const Map<String, dynamic>? _data = null;
|
||||
final _result = await _dio.fetch<Map<String, dynamic>>(
|
||||
_setStreamType<Map<String, List<Product>>>(Options(
|
||||
method: 'GET',
|
||||
headers: _headers,
|
||||
extra: _extra,
|
||||
)
|
||||
.compose(
|
||||
_dio.options,
|
||||
'/diary/product_nutritional_values/filter',
|
||||
queryParameters: queryParameters,
|
||||
data: _data,
|
||||
)
|
||||
.copyWith(
|
||||
baseUrl: _combineBaseUrls(
|
||||
_dio.options.baseUrl,
|
||||
baseUrl,
|
||||
))));
|
||||
var _value = _result.data!.map((k, dynamic v) => MapEntry(
|
||||
k,
|
||||
(v as List)
|
||||
.map((i) => Product.fromJson(i as Map<String, dynamic>))
|
||||
.toList()));
|
||||
return _value;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<Map<String, int>> sendSatietyData(
|
||||
int diary_id,
|
||||
int meal_id,
|
||||
int satiety,
|
||||
) async {
|
||||
final _extra = <String, dynamic>{};
|
||||
final queryParameters = <String, dynamic>{r'satiety': satiety};
|
||||
final _headers = <String, dynamic>{};
|
||||
const Map<String, dynamic>? _data = null;
|
||||
final _result = await _dio
|
||||
.fetch<Map<String, dynamic>>(_setStreamType<Map<String, int>>(Options(
|
||||
method: 'POST',
|
||||
headers: _headers,
|
||||
extra: _extra,
|
||||
)
|
||||
.compose(
|
||||
_dio.options,
|
||||
'/diary/${diary_id}/meal/${meal_id}/satiety/fill',
|
||||
queryParameters: queryParameters,
|
||||
data: _data,
|
||||
)
|
||||
.copyWith(
|
||||
baseUrl: _combineBaseUrls(
|
||||
_dio.options.baseUrl,
|
||||
baseUrl,
|
||||
))));
|
||||
final _value = _result.data!.cast<String, int>();
|
||||
return _value;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<Map<String, int>> sendMoodData(
|
||||
int diary_id,
|
||||
int meal_id,
|
||||
int mood,
|
||||
) async {
|
||||
final _extra = <String, dynamic>{};
|
||||
final queryParameters = <String, dynamic>{r'mood': mood};
|
||||
final _headers = <String, dynamic>{};
|
||||
const Map<String, dynamic>? _data = null;
|
||||
final _result = await _dio
|
||||
.fetch<Map<String, dynamic>>(_setStreamType<Map<String, int>>(Options(
|
||||
method: 'POST',
|
||||
headers: _headers,
|
||||
extra: _extra,
|
||||
)
|
||||
.compose(
|
||||
_dio.options,
|
||||
'/diary/${diary_id}/meal/${meal_id}/mood/fill',
|
||||
queryParameters: queryParameters,
|
||||
data: _data,
|
||||
)
|
||||
.copyWith(
|
||||
baseUrl: _combineBaseUrls(
|
||||
_dio.options.baseUrl,
|
||||
baseUrl,
|
||||
))));
|
||||
final _value = _result.data!.cast<String, int>();
|
||||
return _value;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<DiaryModel> sendWakeupData(
|
||||
int diary_id,
|
||||
String wakeup,
|
||||
) async {
|
||||
final _extra = <String, dynamic>{};
|
||||
final queryParameters = <String, dynamic>{r'wakeup': wakeup};
|
||||
final _headers = <String, dynamic>{};
|
||||
const Map<String, dynamic>? _data = null;
|
||||
final _result = await _dio
|
||||
.fetch<Map<String, dynamic>>(_setStreamType<DiaryModel>(Options(
|
||||
method: 'POST',
|
||||
headers: _headers,
|
||||
extra: _extra,
|
||||
)
|
||||
.compose(
|
||||
_dio.options,
|
||||
'/diary/${diary_id}/wakeup/fill',
|
||||
queryParameters: queryParameters,
|
||||
data: _data,
|
||||
)
|
||||
.copyWith(
|
||||
baseUrl: _combineBaseUrls(
|
||||
_dio.options.baseUrl,
|
||||
baseUrl,
|
||||
))));
|
||||
final _value = DiaryModel.fromJson(_result.data!);
|
||||
return _value;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<DiaryModel> sendRetireData(
|
||||
int diary_id,
|
||||
String retire,
|
||||
) async {
|
||||
final _extra = <String, dynamic>{};
|
||||
final queryParameters = <String, dynamic>{r'retire': retire};
|
||||
final _headers = <String, dynamic>{};
|
||||
const Map<String, dynamic>? _data = null;
|
||||
final _result = await _dio
|
||||
.fetch<Map<String, dynamic>>(_setStreamType<DiaryModel>(Options(
|
||||
method: 'POST',
|
||||
headers: _headers,
|
||||
extra: _extra,
|
||||
)
|
||||
.compose(
|
||||
_dio.options,
|
||||
'/diary/${diary_id}/retire/fill',
|
||||
queryParameters: queryParameters,
|
||||
data: _data,
|
||||
)
|
||||
.copyWith(
|
||||
baseUrl: _combineBaseUrls(
|
||||
_dio.options.baseUrl,
|
||||
baseUrl,
|
||||
))));
|
||||
final _value = DiaryModel.fromJson(_result.data!);
|
||||
return _value;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<Map<String, Portion>> sendPortionData(
|
||||
int diary_id,
|
||||
int meal_id,
|
||||
String product_name,
|
||||
String portion,
|
||||
int quantity,
|
||||
) async {
|
||||
final _extra = <String, dynamic>{};
|
||||
final queryParameters = <String, dynamic>{
|
||||
r'product_name': product_name,
|
||||
r'portion': portion,
|
||||
r'quantity': quantity,
|
||||
};
|
||||
final _headers = <String, dynamic>{};
|
||||
const Map<String, dynamic>? _data = null;
|
||||
final _result = await _dio.fetch<Map<String, dynamic>>(
|
||||
_setStreamType<Map<String, Portion>>(Options(
|
||||
method: 'POST',
|
||||
headers: _headers,
|
||||
extra: _extra,
|
||||
)
|
||||
.compose(
|
||||
_dio.options,
|
||||
'/diary/${diary_id}/meal/${meal_id}/portions/create',
|
||||
queryParameters: queryParameters,
|
||||
data: _data,
|
||||
)
|
||||
.copyWith(
|
||||
baseUrl: _combineBaseUrls(
|
||||
_dio.options.baseUrl,
|
||||
baseUrl,
|
||||
))));
|
||||
var _value = _result.data!.map((k, dynamic v) =>
|
||||
MapEntry(k, Portion.fromJson(v as Map<String, dynamic>)));
|
||||
return _value;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> uploadImage(
|
||||
int diary_id,
|
||||
int meal_id,
|
||||
File photo,
|
||||
) async {
|
||||
final _extra = <String, dynamic>{};
|
||||
final queryParameters = <String, dynamic>{};
|
||||
final _headers = <String, dynamic>{};
|
||||
final _data = FormData();
|
||||
_data.files.add(MapEntry(
|
||||
'photo',
|
||||
MultipartFile.fromFileSync(
|
||||
photo.path,
|
||||
filename: photo.path.split(Platform.pathSeparator).last,
|
||||
),
|
||||
));
|
||||
await _dio.fetch<void>(_setStreamType<void>(Options(
|
||||
method: 'POST',
|
||||
headers: _headers,
|
||||
extra: _extra,
|
||||
)
|
||||
.compose(
|
||||
_dio.options,
|
||||
'/diary/${diary_id}/meal/${meal_id}/photo/upload',
|
||||
queryParameters: queryParameters,
|
||||
data: _data,
|
||||
)
|
||||
.copyWith(
|
||||
baseUrl: _combineBaseUrls(
|
||||
_dio.options.baseUrl,
|
||||
baseUrl,
|
||||
))));
|
||||
}
|
||||
|
||||
@override
|
||||
Future<Map<String, String>> sendModerationData(
|
||||
String product_name,
|
||||
double energy_on_100gr,
|
||||
double proteins_on_100gr,
|
||||
double fats_on_100gr,
|
||||
double carbohydrates_on_100gr,
|
||||
) async {
|
||||
final _extra = <String, dynamic>{};
|
||||
final queryParameters = <String, dynamic>{
|
||||
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 = <String, dynamic>{};
|
||||
const Map<String, dynamic>? _data = null;
|
||||
final _result = await _dio.fetch<Map<String, dynamic>>(
|
||||
_setStreamType<Map<String, String>>(Options(
|
||||
method: 'POST',
|
||||
headers: _headers,
|
||||
extra: _extra,
|
||||
)
|
||||
.compose(
|
||||
_dio.options,
|
||||
'/diary/product_nutritional_values/sendToModeration',
|
||||
queryParameters: queryParameters,
|
||||
data: _data,
|
||||
)
|
||||
.copyWith(
|
||||
baseUrl: _combineBaseUrls(
|
||||
_dio.options.baseUrl,
|
||||
baseUrl,
|
||||
))));
|
||||
final _value = _result.data!.cast<String, String>();
|
||||
return _value;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> sendFinishDay(
|
||||
int diary_id,
|
||||
String wakeup,
|
||||
String retire,
|
||||
String comment,
|
||||
) async {
|
||||
final _extra = <String, dynamic>{};
|
||||
final queryParameters = <String, dynamic>{
|
||||
r'wakeUp': wakeup,
|
||||
r'retire': retire,
|
||||
r'comment': comment,
|
||||
};
|
||||
final _headers = <String, dynamic>{};
|
||||
const Map<String, dynamic>? _data = null;
|
||||
await _dio.fetch<void>(_setStreamType<void>(Options(
|
||||
method: 'POST',
|
||||
headers: _headers,
|
||||
extra: _extra,
|
||||
)
|
||||
.compose(
|
||||
_dio.options,
|
||||
'/diary/${diary_id}/finishDay',
|
||||
queryParameters: queryParameters,
|
||||
data: _data,
|
||||
)
|
||||
.copyWith(
|
||||
baseUrl: _combineBaseUrls(
|
||||
_dio.options.baseUrl,
|
||||
baseUrl,
|
||||
))));
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> sendRemovePortionData(
|
||||
int diary_id,
|
||||
int meal_id,
|
||||
int portion_id,
|
||||
) async {
|
||||
final _extra = <String, dynamic>{};
|
||||
final queryParameters = <String, dynamic>{};
|
||||
final _headers = <String, dynamic>{};
|
||||
const Map<String, dynamic>? _data = null;
|
||||
await _dio.fetch<void>(_setStreamType<void>(Options(
|
||||
method: 'DELETE',
|
||||
headers: _headers,
|
||||
extra: _extra,
|
||||
)
|
||||
.compose(
|
||||
_dio.options,
|
||||
'/diary/${diary_id}/meal/${meal_id}/portions/${portion_id}/delete',
|
||||
queryParameters: queryParameters,
|
||||
data: _data,
|
||||
)
|
||||
.copyWith(
|
||||
baseUrl: _combineBaseUrls(
|
||||
_dio.options.baseUrl,
|
||||
baseUrl,
|
||||
))));
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> sendRemovePhotoData(
|
||||
int diary_id,
|
||||
int meal_id,
|
||||
String path,
|
||||
int photo_id,
|
||||
) async {
|
||||
final _extra = <String, dynamic>{};
|
||||
final queryParameters = <String, dynamic>{
|
||||
r'path': path,
|
||||
r'id': photo_id,
|
||||
};
|
||||
final _headers = <String, dynamic>{};
|
||||
const Map<String, dynamic>? _data = null;
|
||||
await _dio.fetch<void>(_setStreamType<void>(Options(
|
||||
method: 'DELETE',
|
||||
headers: _headers,
|
||||
extra: _extra,
|
||||
)
|
||||
.compose(
|
||||
_dio.options,
|
||||
'/diary/${diary_id}/meal/${meal_id}/photo/delete',
|
||||
queryParameters: queryParameters,
|
||||
data: _data,
|
||||
)
|
||||
.copyWith(
|
||||
baseUrl: _combineBaseUrls(
|
||||
_dio.options.baseUrl,
|
||||
baseUrl,
|
||||
))));
|
||||
}
|
||||
|
||||
RequestOptions _setStreamType<T>(RequestOptions requestOptions) {
|
||||
if (T != dynamic &&
|
||||
!(requestOptions.responseType == ResponseType.bytes ||
|
||||
requestOptions.responseType == ResponseType.stream)) {
|
||||
if (T == String) {
|
||||
requestOptions.responseType = ResponseType.plain;
|
||||
} else {
|
||||
requestOptions.responseType = ResponseType.json;
|
||||
}
|
||||
}
|
||||
return requestOptions;
|
||||
}
|
||||
|
||||
String _combineBaseUrls(
|
||||
String dioBaseUrl,
|
||||
String? baseUrl,
|
||||
) {
|
||||
if (baseUrl == null || baseUrl.trim().isEmpty) {
|
||||
return dioBaseUrl;
|
||||
}
|
||||
|
||||
final url = Uri.parse(baseUrl);
|
||||
|
||||
if (url.isAbsolute) {
|
||||
return url.toString();
|
||||
}
|
||||
|
||||
return Uri.parse(dioBaseUrl).resolveUri(url).toString();
|
||||
}
|
||||
}
|
||||
@@ -1,20 +1,15 @@
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:eatvio_app/core/constants/constants.dart';
|
||||
import 'package:eatvio_app/core/initialization_cubit/initialization_cubit.dart';
|
||||
import 'package:eatvio_app/features/blog_post/presentation/bloc/blog_post_cubit.dart';
|
||||
import 'package:eatvio_app/features/blog_post/repositories/blog_post_repository.dart';
|
||||
import 'package:eatvio_app/features/blog_post/services/blog_post_service.dart';
|
||||
import 'package:eatvio_app/features/bottom_navigation_bar/presentation/bloc/new_messages_cubit/new_messages_cubit.dart';
|
||||
import 'package:eatvio_app/features/bottom_navigation_bar/presentation/bloc/notifications_cubit/notifications_cubit.dart';
|
||||
import 'package:eatvio_app/features/chat/presentation/bloc/chat_room_cubit/chat_room_cubit.dart';
|
||||
import 'package:eatvio_app/features/chat/repositories/chat_repository.dart';
|
||||
import 'package:eatvio_app/features/chat/services/chat_service.dart';
|
||||
import 'package:eatvio_app/features/feed/presentation/bloc/feed_cubit/feed_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/registration/presentation/bloc/registration_cubit/registration_cubit.dart';
|
||||
import 'package:eatvio_app/features/registration/repositories/registration_repository.dart';
|
||||
import 'package:eatvio_app/features/registration/services/registration_service.dart';
|
||||
import 'package:flutter_dotenv/flutter_dotenv.dart';
|
||||
import 'package:get_it/get_it.dart';
|
||||
|
||||
final sl = GetIt.instance;
|
||||
@@ -28,19 +23,24 @@ Future<void> init() async {
|
||||
sl.registerFactory<RegistrationCubit>(() => RegistrationCubit(registrationRepository: sl()));
|
||||
sl.registerFactory<ChatRoomCubit>(() => ChatRoomCubit(chatRepository: sl(), initializationCubit: sl()));
|
||||
sl.registerFactory<FeedCubit>(() => FeedCubit(feedRepository: sl()));
|
||||
sl.registerFactory<BlogPostCubit>(() => BlogPostCubit(blogPostRepository: sl()));
|
||||
sl.registerFactory<BlogPostCubit>(
|
||||
() => BlogPostCubit(blogPostRepository: sl()));
|
||||
sl.registerFactory<DiaryBloc>(() => DiaryBloc(diaryRepository: sl()));
|
||||
|
||||
// Repository
|
||||
sl.registerLazySingleton<ChatRepository>(() => ChatRepository(chatService: sl()));
|
||||
sl.registerLazySingleton<FeedRepository>(() => FeedRepository(feedService: sl()));
|
||||
sl.registerLazySingleton<BlogPostRepository>(() => BlogPostRepository(blogPostService: sl()));
|
||||
sl.registerLazySingleton<RegistrationRepository>(() => RegistrationRepository(registrationService: sl()));
|
||||
sl.registerLazySingleton<DiaryRepository>(
|
||||
() => DiaryRepository(diaryService: sl()));
|
||||
|
||||
// Services
|
||||
sl.registerLazySingleton<ChatService>(() => ChatService(sl()));
|
||||
sl.registerLazySingleton<FeedService>(() => FeedService(sl()));
|
||||
sl.registerLazySingleton<BlogPostService>(() => BlogPostService(sl()));
|
||||
sl.registerLazySingleton<RegistrationService>(() => RegistrationService(sl()));
|
||||
sl.registerLazySingleton<DiaryService>(() => DiaryService(sl()));
|
||||
|
||||
// External
|
||||
sl.registerLazySingleton(
|
||||
|
||||
@@ -8,8 +8,7 @@ import 'package:eatvio_app/features/chat/presentation/pages/chat_select_screen/m
|
||||
import 'package:eatvio_app/features/feed/presentation/bloc/feed_cubit/feed_cubit.dart';
|
||||
import 'package:eatvio_app/locator_service.dart' as di;
|
||||
import 'package:eatvio_app/locator_service.dart';
|
||||
import 'package:eatvio_app/presentation/diary/diary_edit_screen/bloc/diary_edit_bloc.dart';
|
||||
import 'package:eatvio_app/presentation/diary/diary_edit_screen/models/diary_edit_model.dart';
|
||||
import 'package:eatvio_app/features/diary/presentation/bloc/diary_bloc.dart';
|
||||
import 'package:eatvio_app/presentation/profile/my_profile_screen/bloc/my_profile_bloc.dart';
|
||||
import 'package:eatvio_app/presentation/profile/my_profile_screen/models/my_profile_model.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
@@ -49,7 +48,7 @@ class MyApp extends StatelessWidget {
|
||||
BlocProvider<ThemeBloc>(create: (context) => ThemeBloc(ThemeState(themeType: PrefUtils().getThemeData()))),
|
||||
BlocProvider<FeedCubit>(create: (context) => sl<FeedCubit>()..loadFeedBlogPostList()),
|
||||
BlocProvider<MyProfileBloc>(create: (context) => MyProfileBloc(MyProfileState(myProfileModelObj: MyProfileModel()))..add(MyProfileInitialEvent())),
|
||||
BlocProvider<DiaryEditBloc>(create: (context) => DiaryEditBloc(DiaryEditState(diaryEditModelObj: DiaryEditModel()))..add(DiaryEditInitialEvent())),
|
||||
BlocProvider<DiaryBloc>(create: (context) => sl<DiaryBloc>()..add(LoadDiary())),
|
||||
BlocProvider<ChatSelectBloc>(
|
||||
create: (context) => ChatSelectBloc(ChatSelectState(chatSelectModelObj: ChatSelectModel()))..add(ChatSelectInitialEvent()),
|
||||
),
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,6 @@
|
||||
// ignore_for_file: must_be_immutable
|
||||
|
||||
part of 'diary_edit_bloc.dart';
|
||||
/*part of '../../../../features/diary/presentation/bloc/diary_bloc.dart';
|
||||
|
||||
class DiaryEditState extends Equatable {
|
||||
const DiaryEditState({this.diaryEditModelObj});
|
||||
@@ -182,4 +182,4 @@ class DiaryEditErrorState extends DiaryEditState {
|
||||
|
||||
@override
|
||||
List<Object> get props => [errorMessage];
|
||||
}
|
||||
}*/
|
||||
@@ -1,19 +1,19 @@
|
||||
// ignore_for_file: unused_local_variable
|
||||
|
||||
import 'package:carousel_slider/carousel_slider.dart';
|
||||
import 'package:eatvio_app/core/app_export.dart';
|
||||
import 'package:eatvio_app/widgets/custom_edit_drop_down.dart';
|
||||
import 'package:eatvio_app/widgets/custom_edit_text_form_field.dart';
|
||||
import 'package:eatvio_app/widgets/custom_outlined_button.dart';
|
||||
import 'package:eatvio_app/widgets/custom_scale_element.dart';
|
||||
import 'package:fl_chart/fl_chart.dart';
|
||||
/*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 'bloc/diary_edit_bloc.dart';
|
||||
import 'models/diary_edit_model.dart';
|
||||
import 'package:flutter_dotenv/flutter_dotenv.dart';
|
||||
import 'package:eatvio_app/core/app_export.dart';
|
||||
import 'package:eatvio_app/widgets/custom_edit_text_form_field.dart';
|
||||
import 'package:eatvio_app/widgets/custom_edit_drop_down.dart';
|
||||
import 'package:eatvio_app/widgets/custom_outlined_button.dart';
|
||||
import 'package:eatvio_app/widgets/custom_scale_element.dart';
|
||||
import 'package:carousel_slider/carousel_slider.dart';
|
||||
|
||||
// ignore: must_be_immutable
|
||||
class DiaryEditScreen extends StatelessWidget {
|
||||
@@ -711,7 +711,7 @@ class DiaryEditScreen extends StatelessWidget {
|
||||
borderRadius: BorderRadiusStyle.roundedBorder5,
|
||||
),
|
||||
child: Image.network(
|
||||
baseUrl + '/storage/' + photo['path'],
|
||||
dotenv.env['STORAGE_URL']! + photo['path'],
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
@@ -1250,3 +1250,4 @@ bool checkConsumedValues(List<int> recommendedValues, List<int> consumedValues)
|
||||
// Если ни одно потребленное значение не превышает рекомендованное с соответствующим индексом
|
||||
return false; // Возвращаем true
|
||||
}
|
||||
*/
|
||||
@@ -1,198 +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 '../../../../features/blog_post_create/models/blog_post_create_credentials_model.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// FreezedGenerator
|
||||
// **************************************************************************
|
||||
|
||||
T _$identity<T>(T value) => value;
|
||||
|
||||
final _privateConstructorUsedError = UnsupportedError(
|
||||
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models');
|
||||
|
||||
BlogPostCreateCredentialsModel _$BlogPostCreateCredentialsModelFromJson(Map<String, dynamic> json) {
|
||||
return _BlogPostCreateCredentialsModel.fromJson(json);
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
mixin _$BlogPostCreateCredentialsModel {
|
||||
String get title => throw _privateConstructorUsedError;
|
||||
String get description => throw _privateConstructorUsedError;
|
||||
@JsonKey(name: 'youtube_url')
|
||||
String get youtubeUrl => throw _privateConstructorUsedError;
|
||||
String get status => throw _privateConstructorUsedError;
|
||||
|
||||
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
|
||||
@JsonKey(ignore: true)
|
||||
$BlogPostCreateCredentialsModelCopyWith<BlogPostCreateCredentialsModel> get copyWith => throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class $BlogPostCreateCredentialsModelCopyWith<$Res> {
|
||||
factory $BlogPostCreateCredentialsModelCopyWith(BlogPostCreateCredentialsModel value, $Res Function(BlogPostCreateCredentialsModel) then) =
|
||||
_$BlogPostCreateCredentialsModelCopyWithImpl<$Res, BlogPostCreateCredentialsModel>;
|
||||
@useResult
|
||||
$Res call({String title, String description, @JsonKey(name: 'youtube_url') String youtubeUrl, String status});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class _$BlogPostCreateCredentialsModelCopyWithImpl<$Res, $Val extends BlogPostCreateCredentialsModel> implements $BlogPostCreateCredentialsModelCopyWith<$Res> {
|
||||
_$BlogPostCreateCredentialsModelCopyWithImpl(this._value, this._then);
|
||||
|
||||
// ignore: unused_field
|
||||
final $Val _value;
|
||||
// ignore: unused_field
|
||||
final $Res Function($Val) _then;
|
||||
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? title = null,
|
||||
Object? description = null,
|
||||
Object? youtubeUrl = null,
|
||||
Object? status = null,
|
||||
}) {
|
||||
return _then(_value.copyWith(
|
||||
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,
|
||||
youtubeUrl: null == youtubeUrl
|
||||
? _value.youtubeUrl
|
||||
: youtubeUrl // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
status: null == status
|
||||
? _value.status
|
||||
: status // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
) as $Val);
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$BlogPostCreateCredentialsModelImplCopyWith<$Res> implements $BlogPostCreateCredentialsModelCopyWith<$Res> {
|
||||
factory _$$BlogPostCreateCredentialsModelImplCopyWith(_$BlogPostCreateCredentialsModelImpl value, $Res Function(_$BlogPostCreateCredentialsModelImpl) then) =
|
||||
__$$BlogPostCreateCredentialsModelImplCopyWithImpl<$Res>;
|
||||
@override
|
||||
@useResult
|
||||
$Res call({String title, String description, @JsonKey(name: 'youtube_url') String youtubeUrl, String status});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$BlogPostCreateCredentialsModelImplCopyWithImpl<$Res> extends _$BlogPostCreateCredentialsModelCopyWithImpl<$Res, _$BlogPostCreateCredentialsModelImpl>
|
||||
implements _$$BlogPostCreateCredentialsModelImplCopyWith<$Res> {
|
||||
__$$BlogPostCreateCredentialsModelImplCopyWithImpl(_$BlogPostCreateCredentialsModelImpl _value, $Res Function(_$BlogPostCreateCredentialsModelImpl) _then)
|
||||
: super(_value, _then);
|
||||
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? title = null,
|
||||
Object? description = null,
|
||||
Object? youtubeUrl = null,
|
||||
Object? status = null,
|
||||
}) {
|
||||
return _then(_$BlogPostCreateCredentialsModelImpl(
|
||||
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,
|
||||
youtubeUrl: null == youtubeUrl
|
||||
? _value.youtubeUrl
|
||||
: youtubeUrl // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
status: null == status
|
||||
? _value.status
|
||||
: status // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@JsonSerializable()
|
||||
class _$BlogPostCreateCredentialsModelImpl implements _BlogPostCreateCredentialsModel {
|
||||
const _$BlogPostCreateCredentialsModelImpl(
|
||||
{required this.title, required this.description, @JsonKey(name: 'youtube_url') required this.youtubeUrl, this.status = 'active'});
|
||||
|
||||
factory _$BlogPostCreateCredentialsModelImpl.fromJson(Map<String, dynamic> json) => _$$BlogPostCreateCredentialsModelImplFromJson(json);
|
||||
|
||||
@override
|
||||
final String title;
|
||||
@override
|
||||
final String description;
|
||||
@override
|
||||
@JsonKey(name: 'youtube_url')
|
||||
final String youtubeUrl;
|
||||
@override
|
||||
@JsonKey()
|
||||
final String status;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'BlogPostCreateCredentialsModel(title: $title, description: $description, youtubeUrl: $youtubeUrl, status: $status)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$BlogPostCreateCredentialsModelImpl &&
|
||||
(identical(other.title, title) || other.title == title) &&
|
||||
(identical(other.description, description) || other.description == description) &&
|
||||
(identical(other.youtubeUrl, youtubeUrl) || other.youtubeUrl == youtubeUrl) &&
|
||||
(identical(other.status, status) || other.status == status));
|
||||
}
|
||||
|
||||
@JsonKey(ignore: true)
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType, title, description, youtubeUrl, status);
|
||||
|
||||
@JsonKey(ignore: true)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$BlogPostCreateCredentialsModelImplCopyWith<_$BlogPostCreateCredentialsModelImpl> get copyWith =>
|
||||
__$$BlogPostCreateCredentialsModelImplCopyWithImpl<_$BlogPostCreateCredentialsModelImpl>(this, _$identity);
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
return _$$BlogPostCreateCredentialsModelImplToJson(
|
||||
this,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
abstract class _BlogPostCreateCredentialsModel implements BlogPostCreateCredentialsModel {
|
||||
const factory _BlogPostCreateCredentialsModel(
|
||||
{required final String title,
|
||||
required final String description,
|
||||
@JsonKey(name: 'youtube_url') required final String youtubeUrl,
|
||||
final String status}) = _$BlogPostCreateCredentialsModelImpl;
|
||||
|
||||
factory _BlogPostCreateCredentialsModel.fromJson(Map<String, dynamic> json) = _$BlogPostCreateCredentialsModelImpl.fromJson;
|
||||
|
||||
@override
|
||||
String get title;
|
||||
@override
|
||||
String get description;
|
||||
@override
|
||||
@JsonKey(name: 'youtube_url')
|
||||
String get youtubeUrl;
|
||||
@override
|
||||
String get status;
|
||||
@override
|
||||
@JsonKey(ignore: true)
|
||||
_$$BlogPostCreateCredentialsModelImplCopyWith<_$BlogPostCreateCredentialsModelImpl> get copyWith => throw _privateConstructorUsedError;
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of '../../../../features/blog_post_create/models/blog_post_create_credentials_model.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
_$BlogPostCreateCredentialsModelImpl _$$BlogPostCreateCredentialsModelImplFromJson(Map<String, dynamic> json) => _$BlogPostCreateCredentialsModelImpl(
|
||||
title: json['title'] as String,
|
||||
description: json['description'] as String,
|
||||
youtubeUrl: json['youtube_url'] as String,
|
||||
status: json['status'] as String? ?? 'active',
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$$BlogPostCreateCredentialsModelImplToJson(_$BlogPostCreateCredentialsModelImpl instance) => <String, dynamic>{
|
||||
'title': instance.title,
|
||||
'description': instance.description,
|
||||
'youtube_url': instance.youtubeUrl,
|
||||
'status': instance.status,
|
||||
};
|
||||
@@ -1,16 +0,0 @@
|
||||
// ignore_for_file: must_be_immutable
|
||||
|
||||
import 'package:equatable/equatable.dart';
|
||||
|
||||
/// This class defines the variables used in the [k0_page],
|
||||
/// and is typically used to hold data that is passed between different parts of the application.
|
||||
class FeedModel extends Equatable {
|
||||
FeedModel();
|
||||
|
||||
FeedModel copyWith() {
|
||||
return FeedModel();
|
||||
}
|
||||
|
||||
@override
|
||||
List<Object?> get props => [];
|
||||
}
|
||||
Reference in New Issue
Block a user