Merge pull request 'feature/profile' (#137) from mso7nueh/eatvio_app:main into main

Reviewed-on: eatvio/eatvio_app#137
This commit is contained in:
mso7nueh
2024-10-30 08:45:23 +00:00
103 changed files with 4645 additions and 7142 deletions

View File

@@ -0,0 +1,4 @@
kotlin version: 2.0.20
error message: The daemon has terminated unexpectedly on startup attempt #1 with error code: 0. The daemon process output:
1. Kotlin compile daemon is ready

View File

@@ -10,12 +10,12 @@ android {
ndkVersion = "25.1.8937393"
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}
kotlinOptions {
jvmTarget = JavaVersion.VERSION_1_8
jvmTarget = 17
}
defaultConfig {

View File

@@ -1,4 +1,7 @@
allprojects {
tasks.withType(JavaCompile) {
options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation"
}
repositories {
google()
mavenCentral()

View File

@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-all.zip

View File

@@ -18,7 +18,7 @@ pluginManagement {
plugins {
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
id "com.android.application" version "8.1.4" apply false
id "com.android.application" version "8.3.2" apply false
id "org.jetbrains.kotlin.android" version "2.0.20" apply false
}

View File

@@ -75,43 +75,38 @@ class AppRouter {
},
routes: [
GoRoute(
pageBuilder: (context, state) => NoTransitionPage(child: ProfileScreen()),
path: '/my-profile-screen',
name: 'myProfileScreen',
redirect: (context, state) async {
await context.read<InitializationCubit>().runInitialization();
return null;
},
builder: (context, state) => ProfileScreen(),
),
GoRoute(
pageBuilder: (context, state) => NoTransitionPage(child: FeedScreen()),
path: '/feed-screen',
name: 'feedScreen',
builder: (context, state) => FeedScreen(),
),
GoRoute(
pageBuilder: (context, state) {
if (state.extra != null)
return NoTransitionPage(child: DiaryScreen(diaryID: state.extra as String));
else
return NoTransitionPage(child: DiaryScreen(diaryID: '0'));
},
path: '/diary-screen',
name: 'diaryScreen',
builder: (context, state) => DiaryScreen(),
),
GoRoute(
pageBuilder: (context, state) => NoTransitionPage(child: ChatSelectScreen()),
path: '/chat-select-screen',
name: 'chatSelectScreen',
builder: (context, state) => ChatSelectScreen(),
),
GoRoute(
pageBuilder: (context, state) => NoTransitionPage(child: NotificationsScreen()),
path: '/notifications-screen',
name: 'notificationsScreen',
builder: (context, state) => NotificationsScreen(),
),
GoRoute(
pageBuilder: (context, state) => NoTransitionPage(child: MenuScreen()),
path: '/menu-screen',
name: 'menuScreen',
builder: (context, state) => MenuScreen(),
),
],
),

View File

@@ -1,21 +0,0 @@
/*
import 'package:eatvio_app/features/blog_post_create/models/blog_post_create_credentials_model.dart';
import 'package:eatvio_app/features/blog_post_create/services/blog_service.dart';
class BlogRepository {
final BlogService blogService;
BlogRepository({
required this.blogService,
});
Future<BlogPostCreateCredentialsModel> createBlogPost(BlogPostCreateCredentialsModel model) async {
try {
return (await blogService.createBlogPost(model));
} catch (e) {
print(e);
throw (e);
}
}
}
*/

View File

@@ -6,7 +6,7 @@ part of 'blog_post_service.dart';
// RetrofitGenerator
// **************************************************************************
// ignore_for_file: unnecessary_brace_in_string_interps,no_leading_underscores_for_local_identifiers,unused_element
// ignore_for_file: unnecessary_brace_in_string_interps,no_leading_underscores_for_local_identifiers,unused_element,unnecessary_string_interpolations
class _BlogPostService implements BlogPostService {
_BlogPostService(

View File

@@ -16,7 +16,6 @@ class ProfileAvatarCubit extends Cubit<ProfileAvatarState> {
));
} catch (e) {
emit(ProfileAvatarState.error(errorMessage: e.toString()));
print(e);
}
}
}

View File

@@ -163,7 +163,6 @@ class CalendarScreen extends StatelessWidget {
);
} else {
diary = state.calendarList[index].diary as Map<String, dynamic>;
print(state.calendarList[index]);
return InkWell(
borderRadius: BorderRadiusStyle.circleBorder8,
onTap: () => GoRouter.of(context).go(

View File

@@ -6,7 +6,7 @@ part of 'calendar_service.dart';
// RetrofitGenerator
// **************************************************************************
// ignore_for_file: unnecessary_brace_in_string_interps,no_leading_underscores_for_local_identifiers,unused_element
// ignore_for_file: unnecessary_brace_in_string_interps,no_leading_underscores_for_local_identifiers,unused_element,unnecessary_string_interpolations
class _CalendarService implements CalendarService {
_CalendarService(

View File

@@ -53,7 +53,6 @@ class ChatRoomCubit extends Cubit<ChatRoomState> {
currentPage++;
} catch (e) {
print(e);
emit(ChatRoomState.error(errorMessage: 'Ошибка получеия данных'));
}
}
@@ -75,7 +74,6 @@ class ChatRoomCubit extends Cubit<ChatRoomState> {
isLoading: isLoading,
));
} catch (e) {
print(e);
emit(ChatRoomState.error(errorMessage: 'Ошибка получеия данных'));
}
}

View File

@@ -13,7 +13,7 @@ class ChatSelectCubit extends Cubit<ChatSelectState> {
emit(ChatSelectState.loading());
try {
emit(ChatSelectState.loaded(
chatRooms: (await chatRepository.getChatRoomPreiews(query: query)),
chatRooms: (await chatRepository.getChatRoomPreviews(query: query)),
));
} catch (e) {
emit(

View File

@@ -70,9 +70,9 @@ class _PhotoViewScreenState extends State<PhotoViewScreen> {
body: SafeArea(
child: Column(
children: [
SizedBox(height: 32),
const SizedBox(height: 32),
Text('Файл'),
SizedBox(height: 8),
const SizedBox(height: 8),
ListTile(
shape: RoundedRectangleBorder(
borderRadius: BorderRadiusStyle.circleBorder17,

View File

@@ -55,7 +55,7 @@ class _ChatEntryWidgetState extends State<ChatEntryWidget> {
),
backgroundColor: Colors.white,
),
SizedBox(width: 12),
const SizedBox(width: 12),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,

View File

@@ -41,7 +41,6 @@ class ChatRepository {
media_data: multipartFiles.isEmpty ? null : multipartFiles,
);
} catch (e) {
print(e);
rethrow;
}
}
@@ -50,16 +49,14 @@ class ChatRepository {
try {
return (await chatService.getChatRoom(id: chatId))['chatRoom']!;
} catch (e) {
print(e);
rethrow;
}
}
Future<List<ChatRoom>> getChatRoomPreiews({String? query}) async {
Future<List<ChatRoom>> getChatRoomPreviews({String? query}) async {
try {
return (await chatService.getChatRoomPreviews(query: query)).chatRooms;
} catch (e) {
print(e);
rethrow;
}
}
@@ -68,7 +65,6 @@ class ChatRepository {
try {
return (await chatService.getChatMessages(id: chatId, page: page));
} catch (e) {
print(e);
rethrow;
}
}
@@ -77,7 +73,14 @@ class ChatRepository {
try {
return (await chatService.getWebsocket());
} catch (e) {
print(e);
rethrow;
}
}
Future<ChatRoomModel> getChatRoomIdByUserSlug({required String slug}) async {
try {
return (await chatService.getChatRoomIdByUserSlug(user: slug));
} catch (e) {
rethrow;
}
}

View File

@@ -6,7 +6,7 @@ part of 'chat_service.dart';
// RetrofitGenerator
// **************************************************************************
// ignore_for_file: unnecessary_brace_in_string_interps,no_leading_underscores_for_local_identifiers,unused_element
// ignore_for_file: unnecessary_brace_in_string_interps,no_leading_underscores_for_local_identifiers,unused_element,unnecessary_string_interpolations
class _ChatService implements ChatService {
_ChatService(

View File

@@ -19,7 +19,6 @@ class ConsultantRepository {
consultantModel: consultant,
);
} catch (e) {
print(e);
rethrow;
}
}
@@ -44,7 +43,6 @@ class ConsultantRepository {
photos: multipartFiles.isEmpty ? null : multipartFiles,
);
} catch (e) {
print(e);
rethrow;
}
}

View File

@@ -6,7 +6,7 @@ part of 'consultant_service.dart';
// RetrofitGenerator
// **************************************************************************
// ignore_for_file: unnecessary_brace_in_string_interps,no_leading_underscores_for_local_identifiers,unused_element
// ignore_for_file: unnecessary_brace_in_string_interps,no_leading_underscores_for_local_identifiers,unused_element,unnecessary_string_interpolations
class _ConsultantService implements ConsultantService {
_ConsultantService(

View File

@@ -0,0 +1,80 @@
import 'package:freezed_annotation/freezed_annotation.dart';
part 'diary_day_model.freezed.dart';
part 'diary_day_model.g.dart';
@freezed
class DiaryDayWrapperModel with _$DiaryDayWrapperModel {
const factory DiaryDayWrapperModel({
@JsonKey(name: "diary") required DiaryDayModel diary,
}) = _DiaryDayWrapperModel;
factory DiaryDayWrapperModel.fromJson(Map<String, dynamic> json) => _$DiaryDayWrapperModelFromJson(json);
}
@freezed
class DiaryDayModel with _$DiaryDayModel {
const factory DiaryDayModel({
@JsonKey(name: "id") required int id,
@JsonKey(name: "date") required String date,
@JsonKey(name: "wakeup") String? wakeup,
@JsonKey(name: "retire") String? retire,
@JsonKey(name: "closed") required int closed,
@JsonKey(name: "comment") required String comment,
@JsonKey(name: "state") required TypeOfDiaryModel typeOfDiary,
@JsonKey(name: "meals") required List<MealModel> meals,
}) = _DiaryDayModel;
factory DiaryDayModel.fromJson(Map<String, dynamic> json) => _$DiaryDayModelFromJson(json);
}
@freezed
class MealModel with _$MealModel {
const factory MealModel({
@JsonKey(name: "id") required int id,
@JsonKey(name: "time") required String time,
@JsonKey(name: "type") required int type,
@JsonKey(name: "satiety") required int satiety,
@JsonKey(name: "mood") required int mood,
@JsonKey(name: "portions") required List<Portion> portions,
@JsonKey(name: "photos") required List<DiaryPhotoModel> photos,
}) = _MealModel;
factory MealModel.fromJson(Map<String, dynamic> json) => _$MealModelFromJson(json);
}
@freezed
class DiaryPhotoModel with _$DiaryPhotoModel {
const factory DiaryPhotoModel({
@JsonKey(name: "id") required String id,
@JsonKey(name: "original_name") required String originalName,
@JsonKey(name: "path") required String path,
@JsonKey(name: "size") required String size,
}) = _DiaryPhotoModel;
factory DiaryPhotoModel.fromJson(Map<String, dynamic> json) => _$DiaryPhotoModelFromJson(json);
}
@freezed
class Portion with _$Portion {
const factory Portion({
@JsonKey(name: "id") required int id,
@JsonKey(name: "product_name") required String productName,
@JsonKey(name: "quantity") required int quantity,
@JsonKey(name: "portion") required String portion,
@JsonKey(name: "from_diet") required bool fromDiet,
}) = _Portion;
factory Portion.fromJson(Map<String, dynamic> json) => _$PortionFromJson(json);
}
@freezed
class TypeOfDiaryModel with _$TypeOfDiaryModel {
const factory TypeOfDiaryModel({
@JsonKey(name: "has_chosen_diet") required bool hasChosenDiet,
@JsonKey(name: "has_chosen_plan") required bool hasChosenPlan,
}) = _TypeOfDiaryModel;
factory TypeOfDiaryModel.fromJson(Map<String, dynamic> json) => _$TypeOfDiaryModelFromJson(json);
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,122 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'diary_day_model.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
_$DiaryDayWrapperModelImpl _$$DiaryDayWrapperModelImplFromJson(
Map<String, dynamic> json) =>
_$DiaryDayWrapperModelImpl(
diary: DiaryDayModel.fromJson(json['diary'] as Map<String, dynamic>),
);
Map<String, dynamic> _$$DiaryDayWrapperModelImplToJson(
_$DiaryDayWrapperModelImpl instance) =>
<String, dynamic>{
'diary': instance.diary,
};
_$DiaryDayModelImpl _$$DiaryDayModelImplFromJson(Map<String, dynamic> json) =>
_$DiaryDayModelImpl(
id: (json['id'] as num).toInt(),
date: json['date'] as String,
wakeup: json['wakeup'] as String?,
retire: json['retire'] as String?,
closed: (json['closed'] as num).toInt(),
comment: json['comment'] as String,
typeOfDiary:
TypeOfDiaryModel.fromJson(json['state'] as Map<String, dynamic>),
meals: (json['meals'] as List<dynamic>)
.map((e) => MealModel.fromJson(e as Map<String, dynamic>))
.toList(),
);
Map<String, dynamic> _$$DiaryDayModelImplToJson(_$DiaryDayModelImpl instance) =>
<String, dynamic>{
'id': instance.id,
'date': instance.date,
'wakeup': instance.wakeup,
'retire': instance.retire,
'closed': instance.closed,
'comment': instance.comment,
'state': instance.typeOfDiary,
'meals': instance.meals,
};
_$MealModelImpl _$$MealModelImplFromJson(Map<String, dynamic> json) =>
_$MealModelImpl(
id: (json['id'] as num).toInt(),
time: json['time'] as String,
type: (json['type'] as num).toInt(),
satiety: (json['satiety'] as num).toInt(),
mood: (json['mood'] as num).toInt(),
portions: (json['portions'] as List<dynamic>)
.map((e) => Portion.fromJson(e as Map<String, dynamic>))
.toList(),
photos: (json['photos'] as List<dynamic>)
.map((e) => DiaryPhotoModel.fromJson(e as Map<String, dynamic>))
.toList(),
);
Map<String, dynamic> _$$MealModelImplToJson(_$MealModelImpl instance) =>
<String, dynamic>{
'id': instance.id,
'time': instance.time,
'type': instance.type,
'satiety': instance.satiety,
'mood': instance.mood,
'portions': instance.portions,
'photos': instance.photos,
};
_$DiaryPhotoModelImpl _$$DiaryPhotoModelImplFromJson(
Map<String, dynamic> json) =>
_$DiaryPhotoModelImpl(
id: json['id'] as String,
originalName: json['original_name'] as String,
path: json['path'] as String,
size: json['size'] as String,
);
Map<String, dynamic> _$$DiaryPhotoModelImplToJson(
_$DiaryPhotoModelImpl instance) =>
<String, dynamic>{
'id': instance.id,
'original_name': instance.originalName,
'path': instance.path,
'size': instance.size,
};
_$PortionImpl _$$PortionImplFromJson(Map<String, dynamic> json) =>
_$PortionImpl(
id: (json['id'] as num).toInt(),
productName: json['product_name'] as String,
quantity: (json['quantity'] as num).toInt(),
portion: json['portion'] as String,
fromDiet: json['from_diet'] as bool,
);
Map<String, dynamic> _$$PortionImplToJson(_$PortionImpl instance) =>
<String, dynamic>{
'id': instance.id,
'product_name': instance.productName,
'quantity': instance.quantity,
'portion': instance.portion,
'from_diet': instance.fromDiet,
};
_$TypeOfDiaryModelImpl _$$TypeOfDiaryModelImplFromJson(
Map<String, dynamic> json) =>
_$TypeOfDiaryModelImpl(
hasChosenDiet: json['has_chosen_diet'] as bool,
hasChosenPlan: json['has_chosen_plan'] as bool,
);
Map<String, dynamic> _$$TypeOfDiaryModelImplToJson(
_$TypeOfDiaryModelImpl instance) =>
<String, dynamic>{
'has_chosen_diet': instance.hasChosenDiet,
'has_chosen_plan': instance.hasChosenPlan,
};

View File

@@ -0,0 +1,14 @@
import 'package:freezed_annotation/freezed_annotation.dart';
part 'diary_index_model.freezed.dart';
part 'diary_index_model.g.dart';
@freezed
class DiaryIndexModel with _$DiaryIndexModel {
const factory DiaryIndexModel({
required int id,
}) = _DiaryIndexModel;
factory DiaryIndexModel.fromJson(Map<String, Object?> json) => _$DiaryIndexModelFromJson(json);
}

View File

@@ -0,0 +1,166 @@
// coverage:ignore-file
// GENERATED CODE - DO NOT MODIFY BY HAND
// ignore_for_file: type=lint
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark
part of 'diary_index_model.dart';
// **************************************************************************
// FreezedGenerator
// **************************************************************************
T _$identity<T>(T value) => value;
final _privateConstructorUsedError = UnsupportedError(
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models');
DiaryIndexModel _$DiaryIndexModelFromJson(Map<String, dynamic> json) {
return _DiaryIndexModel.fromJson(json);
}
/// @nodoc
mixin _$DiaryIndexModel {
int get id => throw _privateConstructorUsedError;
/// Serializes this DiaryIndexModel to a JSON map.
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
/// Create a copy of DiaryIndexModel
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
$DiaryIndexModelCopyWith<DiaryIndexModel> get copyWith =>
throw _privateConstructorUsedError;
}
/// @nodoc
abstract class $DiaryIndexModelCopyWith<$Res> {
factory $DiaryIndexModelCopyWith(
DiaryIndexModel value, $Res Function(DiaryIndexModel) then) =
_$DiaryIndexModelCopyWithImpl<$Res, DiaryIndexModel>;
@useResult
$Res call({int id});
}
/// @nodoc
class _$DiaryIndexModelCopyWithImpl<$Res, $Val extends DiaryIndexModel>
implements $DiaryIndexModelCopyWith<$Res> {
_$DiaryIndexModelCopyWithImpl(this._value, this._then);
// ignore: unused_field
final $Val _value;
// ignore: unused_field
final $Res Function($Val) _then;
/// Create a copy of DiaryIndexModel
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? id = null,
}) {
return _then(_value.copyWith(
id: null == id
? _value.id
: id // ignore: cast_nullable_to_non_nullable
as int,
) as $Val);
}
}
/// @nodoc
abstract class _$$DiaryIndexModelImplCopyWith<$Res>
implements $DiaryIndexModelCopyWith<$Res> {
factory _$$DiaryIndexModelImplCopyWith(_$DiaryIndexModelImpl value,
$Res Function(_$DiaryIndexModelImpl) then) =
__$$DiaryIndexModelImplCopyWithImpl<$Res>;
@override
@useResult
$Res call({int id});
}
/// @nodoc
class __$$DiaryIndexModelImplCopyWithImpl<$Res>
extends _$DiaryIndexModelCopyWithImpl<$Res, _$DiaryIndexModelImpl>
implements _$$DiaryIndexModelImplCopyWith<$Res> {
__$$DiaryIndexModelImplCopyWithImpl(
_$DiaryIndexModelImpl _value, $Res Function(_$DiaryIndexModelImpl) _then)
: super(_value, _then);
/// Create a copy of DiaryIndexModel
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? id = null,
}) {
return _then(_$DiaryIndexModelImpl(
id: null == id
? _value.id
: id // ignore: cast_nullable_to_non_nullable
as int,
));
}
}
/// @nodoc
@JsonSerializable()
class _$DiaryIndexModelImpl implements _DiaryIndexModel {
const _$DiaryIndexModelImpl({required this.id});
factory _$DiaryIndexModelImpl.fromJson(Map<String, dynamic> json) =>
_$$DiaryIndexModelImplFromJson(json);
@override
final int id;
@override
String toString() {
return 'DiaryIndexModel(id: $id)';
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$DiaryIndexModelImpl &&
(identical(other.id, id) || other.id == id));
}
@JsonKey(includeFromJson: false, includeToJson: false)
@override
int get hashCode => Object.hash(runtimeType, id);
/// Create a copy of DiaryIndexModel
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@override
@pragma('vm:prefer-inline')
_$$DiaryIndexModelImplCopyWith<_$DiaryIndexModelImpl> get copyWith =>
__$$DiaryIndexModelImplCopyWithImpl<_$DiaryIndexModelImpl>(
this, _$identity);
@override
Map<String, dynamic> toJson() {
return _$$DiaryIndexModelImplToJson(
this,
);
}
}
abstract class _DiaryIndexModel implements DiaryIndexModel {
const factory _DiaryIndexModel({required final int id}) =
_$DiaryIndexModelImpl;
factory _DiaryIndexModel.fromJson(Map<String, dynamic> json) =
_$DiaryIndexModelImpl.fromJson;
@override
int get id;
/// Create a copy of DiaryIndexModel
/// with the given fields replaced by the non-null parameter values.
@override
@JsonKey(includeFromJson: false, includeToJson: false)
_$$DiaryIndexModelImplCopyWith<_$DiaryIndexModelImpl> get copyWith =>
throw _privateConstructorUsedError;
}

View File

@@ -1,20 +1,19 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'photo.dart';
part of 'diary_index_model.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
_$PhotoImpl _$$PhotoImplFromJson(Map<String, dynamic> json) => _$PhotoImpl(
_$DiaryIndexModelImpl _$$DiaryIndexModelImplFromJson(
Map<String, dynamic> json) =>
_$DiaryIndexModelImpl(
id: (json['id'] as num).toInt(),
originalName: json['original_name'] as String,
path: json['path'] as String,
);
Map<String, dynamic> _$$PhotoImplToJson(_$PhotoImpl instance) =>
Map<String, dynamic> _$$DiaryIndexModelImplToJson(
_$DiaryIndexModelImpl instance) =>
<String, dynamic>{
'id': instance.id,
'original_name': instance.originalName,
'path': instance.path,
};

View File

@@ -1,24 +0,0 @@
import 'package:eatvio_app/features/diary/models/state.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
import './meal.dart';
part 'diary_model.freezed.dart';
part 'diary_model.g.dart';
@freezed
class DiaryModel with _$DiaryModel {
const factory DiaryModel({
required int id,
required DateTime date,
required int closed,
required List<Meal> meals,
required State state,
String? comment,
DateTime? wakeup,
DateTime? retire,
}) = _DiaryModel;
factory DiaryModel.fromJson(Map<String, Object?> json) => _$DiaryModelFromJson(json);
}

View File

@@ -1,339 +0,0 @@
// coverage:ignore-file
// GENERATED CODE - DO NOT MODIFY BY HAND
// ignore_for_file: type=lint
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark
part of 'diary_model.dart';
// **************************************************************************
// FreezedGenerator
// **************************************************************************
T _$identity<T>(T value) => value;
final _privateConstructorUsedError = UnsupportedError(
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models');
DiaryModel _$DiaryModelFromJson(Map<String, dynamic> json) {
return _DiaryModel.fromJson(json);
}
/// @nodoc
mixin _$DiaryModel {
int get id => throw _privateConstructorUsedError;
DateTime get date => throw _privateConstructorUsedError;
int get closed => throw _privateConstructorUsedError;
List<Meal> get meals => throw _privateConstructorUsedError;
State get state => throw _privateConstructorUsedError;
String? get comment => throw _privateConstructorUsedError;
DateTime? get wakeup => throw _privateConstructorUsedError;
DateTime? get retire => throw _privateConstructorUsedError;
/// Serializes this DiaryModel to a JSON map.
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
/// Create a copy of DiaryModel
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
$DiaryModelCopyWith<DiaryModel> get copyWith =>
throw _privateConstructorUsedError;
}
/// @nodoc
abstract class $DiaryModelCopyWith<$Res> {
factory $DiaryModelCopyWith(
DiaryModel value, $Res Function(DiaryModel) then) =
_$DiaryModelCopyWithImpl<$Res, DiaryModel>;
@useResult
$Res call(
{int id,
DateTime date,
int closed,
List<Meal> meals,
State state,
String? comment,
DateTime? wakeup,
DateTime? retire});
$StateCopyWith<$Res> get state;
}
/// @nodoc
class _$DiaryModelCopyWithImpl<$Res, $Val extends DiaryModel>
implements $DiaryModelCopyWith<$Res> {
_$DiaryModelCopyWithImpl(this._value, this._then);
// ignore: unused_field
final $Val _value;
// ignore: unused_field
final $Res Function($Val) _then;
/// Create a copy of DiaryModel
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? id = null,
Object? date = null,
Object? closed = null,
Object? meals = null,
Object? state = null,
Object? comment = freezed,
Object? wakeup = freezed,
Object? retire = freezed,
}) {
return _then(_value.copyWith(
id: null == id
? _value.id
: id // ignore: cast_nullable_to_non_nullable
as int,
date: null == date
? _value.date
: date // ignore: cast_nullable_to_non_nullable
as DateTime,
closed: null == closed
? _value.closed
: closed // ignore: cast_nullable_to_non_nullable
as int,
meals: null == meals
? _value.meals
: meals // ignore: cast_nullable_to_non_nullable
as List<Meal>,
state: null == state
? _value.state
: state // ignore: cast_nullable_to_non_nullable
as State,
comment: freezed == comment
? _value.comment
: comment // ignore: cast_nullable_to_non_nullable
as String?,
wakeup: freezed == wakeup
? _value.wakeup
: wakeup // ignore: cast_nullable_to_non_nullable
as DateTime?,
retire: freezed == retire
? _value.retire
: retire // ignore: cast_nullable_to_non_nullable
as DateTime?,
) as $Val);
}
/// Create a copy of DiaryModel
/// with the given fields replaced by the non-null parameter values.
@override
@pragma('vm:prefer-inline')
$StateCopyWith<$Res> get state {
return $StateCopyWith<$Res>(_value.state, (value) {
return _then(_value.copyWith(state: value) as $Val);
});
}
}
/// @nodoc
abstract class _$$DiaryModelImplCopyWith<$Res>
implements $DiaryModelCopyWith<$Res> {
factory _$$DiaryModelImplCopyWith(
_$DiaryModelImpl value, $Res Function(_$DiaryModelImpl) then) =
__$$DiaryModelImplCopyWithImpl<$Res>;
@override
@useResult
$Res call(
{int id,
DateTime date,
int closed,
List<Meal> meals,
State state,
String? comment,
DateTime? wakeup,
DateTime? retire});
@override
$StateCopyWith<$Res> get state;
}
/// @nodoc
class __$$DiaryModelImplCopyWithImpl<$Res>
extends _$DiaryModelCopyWithImpl<$Res, _$DiaryModelImpl>
implements _$$DiaryModelImplCopyWith<$Res> {
__$$DiaryModelImplCopyWithImpl(
_$DiaryModelImpl _value, $Res Function(_$DiaryModelImpl) _then)
: super(_value, _then);
/// Create a copy of DiaryModel
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? id = null,
Object? date = null,
Object? closed = null,
Object? meals = null,
Object? state = null,
Object? comment = freezed,
Object? wakeup = freezed,
Object? retire = freezed,
}) {
return _then(_$DiaryModelImpl(
id: null == id
? _value.id
: id // ignore: cast_nullable_to_non_nullable
as int,
date: null == date
? _value.date
: date // ignore: cast_nullable_to_non_nullable
as DateTime,
closed: null == closed
? _value.closed
: closed // ignore: cast_nullable_to_non_nullable
as int,
meals: null == meals
? _value._meals
: meals // ignore: cast_nullable_to_non_nullable
as List<Meal>,
state: null == state
? _value.state
: state // ignore: cast_nullable_to_non_nullable
as State,
comment: freezed == comment
? _value.comment
: comment // ignore: cast_nullable_to_non_nullable
as String?,
wakeup: freezed == wakeup
? _value.wakeup
: wakeup // ignore: cast_nullable_to_non_nullable
as DateTime?,
retire: freezed == retire
? _value.retire
: retire // ignore: cast_nullable_to_non_nullable
as DateTime?,
));
}
}
/// @nodoc
@JsonSerializable()
class _$DiaryModelImpl implements _DiaryModel {
const _$DiaryModelImpl(
{required this.id,
required this.date,
required this.closed,
required final List<Meal> meals,
required this.state,
this.comment,
this.wakeup,
this.retire})
: _meals = meals;
factory _$DiaryModelImpl.fromJson(Map<String, dynamic> json) =>
_$$DiaryModelImplFromJson(json);
@override
final int id;
@override
final DateTime date;
@override
final int closed;
final List<Meal> _meals;
@override
List<Meal> get meals {
if (_meals is EqualUnmodifiableListView) return _meals;
// ignore: implicit_dynamic_type
return EqualUnmodifiableListView(_meals);
}
@override
final State state;
@override
final String? comment;
@override
final DateTime? wakeup;
@override
final DateTime? retire;
@override
String toString() {
return 'DiaryModel(id: $id, date: $date, closed: $closed, meals: $meals, state: $state, comment: $comment, wakeup: $wakeup, retire: $retire)';
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$DiaryModelImpl &&
(identical(other.id, id) || other.id == id) &&
(identical(other.date, date) || other.date == date) &&
(identical(other.closed, closed) || other.closed == closed) &&
const DeepCollectionEquality().equals(other._meals, _meals) &&
(identical(other.state, state) || other.state == state) &&
(identical(other.comment, comment) || other.comment == comment) &&
(identical(other.wakeup, wakeup) || other.wakeup == wakeup) &&
(identical(other.retire, retire) || other.retire == retire));
}
@JsonKey(includeFromJson: false, includeToJson: false)
@override
int get hashCode => Object.hash(
runtimeType,
id,
date,
closed,
const DeepCollectionEquality().hash(_meals),
state,
comment,
wakeup,
retire);
/// Create a copy of DiaryModel
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@override
@pragma('vm:prefer-inline')
_$$DiaryModelImplCopyWith<_$DiaryModelImpl> get copyWith =>
__$$DiaryModelImplCopyWithImpl<_$DiaryModelImpl>(this, _$identity);
@override
Map<String, dynamic> toJson() {
return _$$DiaryModelImplToJson(
this,
);
}
}
abstract class _DiaryModel implements DiaryModel {
const factory _DiaryModel(
{required final int id,
required final DateTime date,
required final int closed,
required final List<Meal> meals,
required final State state,
final String? comment,
final DateTime? wakeup,
final DateTime? retire}) = _$DiaryModelImpl;
factory _DiaryModel.fromJson(Map<String, dynamic> json) =
_$DiaryModelImpl.fromJson;
@override
int get id;
@override
DateTime get date;
@override
int get closed;
@override
List<Meal> get meals;
@override
State get state;
@override
String? get comment;
@override
DateTime? get wakeup;
@override
DateTime? get retire;
/// Create a copy of DiaryModel
/// with the given fields replaced by the non-null parameter values.
@override
@JsonKey(includeFromJson: false, includeToJson: false)
_$$DiaryModelImplCopyWith<_$DiaryModelImpl> get copyWith =>
throw _privateConstructorUsedError;
}

View File

@@ -1,37 +0,0 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'diary_model.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
_$DiaryModelImpl _$$DiaryModelImplFromJson(Map<String, dynamic> json) =>
_$DiaryModelImpl(
id: (json['id'] as num).toInt(),
date: DateTime.parse(json['date'] as String),
closed: (json['closed'] as num).toInt(),
meals: (json['meals'] as List<dynamic>)
.map((e) => Meal.fromJson(e as Map<String, dynamic>))
.toList(),
state: State.fromJson(json['state'] as Map<String, dynamic>),
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(),
'closed': instance.closed,
'meals': instance.meals,
'state': instance.state,
'comment': instance.comment,
'wakeup': instance.wakeup?.toIso8601String(),
'retire': instance.retire?.toIso8601String(),
};

View File

@@ -1,23 +0,0 @@
import 'package:freezed_annotation/freezed_annotation.dart';
import './photo.dart';
import './portion.dart';
part 'meal.freezed.dart';
part 'meal.g.dart';
@freezed
class Meal with _$Meal {
const factory Meal({
required int id,
required String time,
required int type,
required int satiety,
required int mood,
required List<Portion> portions,
required List<Photo> photos,
}) = _Meal;
factory Meal.fromJson(Map<String, Object?> json) => _$MealFromJson(json);
}

View File

@@ -1,304 +0,0 @@
// coverage:ignore-file
// GENERATED CODE - DO NOT MODIFY BY HAND
// ignore_for_file: type=lint
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark
part of 'meal.dart';
// **************************************************************************
// FreezedGenerator
// **************************************************************************
T _$identity<T>(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;
/// Serializes this Meal to a JSON map.
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
/// Create a copy of Meal
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
$MealCopyWith<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;
/// Create a copy of Meal
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? id = null,
Object? time = null,
Object? type = null,
Object? satiety = null,
Object? mood = null,
Object? portions = null,
Object? photos = null,
}) {
return _then(_value.copyWith(
id: null == id
? _value.id
: id // ignore: cast_nullable_to_non_nullable
as int,
time: null == time
? _value.time
: time // ignore: cast_nullable_to_non_nullable
as String,
type: null == type
? _value.type
: type // ignore: cast_nullable_to_non_nullable
as int,
satiety: null == satiety
? _value.satiety
: satiety // ignore: cast_nullable_to_non_nullable
as int,
mood: null == mood
? _value.mood
: mood // ignore: cast_nullable_to_non_nullable
as int,
portions: null == portions
? _value.portions
: portions // ignore: cast_nullable_to_non_nullable
as List<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);
/// Create a copy of Meal
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? id = null,
Object? time = null,
Object? type = null,
Object? satiety = null,
Object? mood = null,
Object? portions = null,
Object? photos = null,
}) {
return _then(_$MealImpl(
id: null == id
? _value.id
: id // ignore: cast_nullable_to_non_nullable
as int,
time: null == time
? _value.time
: time // ignore: cast_nullable_to_non_nullable
as String,
type: null == type
? _value.type
: type // ignore: cast_nullable_to_non_nullable
as int,
satiety: null == satiety
? _value.satiety
: satiety // ignore: cast_nullable_to_non_nullable
as int,
mood: null == mood
? _value.mood
: mood // ignore: cast_nullable_to_non_nullable
as int,
portions: null == portions
? _value._portions
: portions // ignore: cast_nullable_to_non_nullable
as List<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(includeFromJson: false, includeToJson: false)
@override
int get hashCode => Object.hash(
runtimeType,
id,
time,
type,
satiety,
mood,
const DeepCollectionEquality().hash(_portions),
const DeepCollectionEquality().hash(_photos));
/// Create a copy of Meal
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@override
@pragma('vm:prefer-inline')
_$$MealImplCopyWith<_$MealImpl> get copyWith =>
__$$MealImplCopyWithImpl<_$MealImpl>(this, _$identity);
@override
Map<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;
/// Create a copy of Meal
/// with the given fields replaced by the non-null parameter values.
@override
@JsonKey(includeFromJson: false, includeToJson: false)
_$$MealImplCopyWith<_$MealImpl> get copyWith =>
throw _privateConstructorUsedError;
}

View File

@@ -1,32 +0,0 @@
// 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,
};

View File

@@ -1,16 +0,0 @@
import 'package:freezed_annotation/freezed_annotation.dart';
part 'photo.freezed.dart';
part 'photo.g.dart';
@freezed
class Photo with _$Photo {
const factory Photo({
required int id,
@JsonKey(name: 'original_name') required String originalName,
required String path,
}) = _Photo;
factory Photo.fromJson(Map<String, Object?> json) => _$PhotoFromJson(json);
}

View File

@@ -1,208 +0,0 @@
// coverage:ignore-file
// GENERATED CODE - DO NOT MODIFY BY HAND
// ignore_for_file: type=lint
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark
part of 'photo.dart';
// **************************************************************************
// FreezedGenerator
// **************************************************************************
T _$identity<T>(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;
@JsonKey(name: 'original_name')
String get originalName => throw _privateConstructorUsedError;
String get path => throw _privateConstructorUsedError;
/// Serializes this Photo to a JSON map.
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
/// Create a copy of Photo
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
$PhotoCopyWith<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,
@JsonKey(name: 'original_name') String originalName,
String path});
}
/// @nodoc
class _$PhotoCopyWithImpl<$Res, $Val extends Photo>
implements $PhotoCopyWith<$Res> {
_$PhotoCopyWithImpl(this._value, this._then);
// ignore: unused_field
final $Val _value;
// ignore: unused_field
final $Res Function($Val) _then;
/// Create a copy of Photo
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? id = null,
Object? originalName = null,
Object? path = null,
}) {
return _then(_value.copyWith(
id: null == id
? _value.id
: id // ignore: cast_nullable_to_non_nullable
as int,
originalName: null == originalName
? _value.originalName
: originalName // ignore: cast_nullable_to_non_nullable
as String,
path: null == path
? _value.path
: path // ignore: cast_nullable_to_non_nullable
as String,
) as $Val);
}
}
/// @nodoc
abstract class _$$PhotoImplCopyWith<$Res> implements $PhotoCopyWith<$Res> {
factory _$$PhotoImplCopyWith(
_$PhotoImpl value, $Res Function(_$PhotoImpl) then) =
__$$PhotoImplCopyWithImpl<$Res>;
@override
@useResult
$Res call(
{int id,
@JsonKey(name: 'original_name') String originalName,
String path});
}
/// @nodoc
class __$$PhotoImplCopyWithImpl<$Res>
extends _$PhotoCopyWithImpl<$Res, _$PhotoImpl>
implements _$$PhotoImplCopyWith<$Res> {
__$$PhotoImplCopyWithImpl(
_$PhotoImpl _value, $Res Function(_$PhotoImpl) _then)
: super(_value, _then);
/// Create a copy of Photo
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? id = null,
Object? originalName = null,
Object? path = null,
}) {
return _then(_$PhotoImpl(
id: null == id
? _value.id
: id // ignore: cast_nullable_to_non_nullable
as int,
originalName: null == originalName
? _value.originalName
: originalName // ignore: cast_nullable_to_non_nullable
as String,
path: null == path
? _value.path
: path // ignore: cast_nullable_to_non_nullable
as String,
));
}
}
/// @nodoc
@JsonSerializable()
class _$PhotoImpl implements _Photo {
const _$PhotoImpl(
{required this.id,
@JsonKey(name: 'original_name') required this.originalName,
required this.path});
factory _$PhotoImpl.fromJson(Map<String, dynamic> json) =>
_$$PhotoImplFromJson(json);
@override
final int id;
@override
@JsonKey(name: 'original_name')
final String originalName;
@override
final String path;
@override
String toString() {
return 'Photo(id: $id, originalName: $originalName, path: $path)';
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$PhotoImpl &&
(identical(other.id, id) || other.id == id) &&
(identical(other.originalName, originalName) ||
other.originalName == originalName) &&
(identical(other.path, path) || other.path == path));
}
@JsonKey(includeFromJson: false, includeToJson: false)
@override
int get hashCode => Object.hash(runtimeType, id, originalName, path);
/// Create a copy of Photo
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@override
@pragma('vm:prefer-inline')
_$$PhotoImplCopyWith<_$PhotoImpl> get copyWith =>
__$$PhotoImplCopyWithImpl<_$PhotoImpl>(this, _$identity);
@override
Map<String, dynamic> toJson() {
return _$$PhotoImplToJson(
this,
);
}
}
abstract class _Photo implements Photo {
const factory _Photo(
{required final int id,
@JsonKey(name: 'original_name') required final String originalName,
required final String path}) = _$PhotoImpl;
factory _Photo.fromJson(Map<String, dynamic> json) = _$PhotoImpl.fromJson;
@override
int get id;
@override
@JsonKey(name: 'original_name')
String get originalName;
@override
String get path;
/// Create a copy of Photo
/// with the given fields replaced by the non-null parameter values.
@override
@JsonKey(includeFromJson: false, includeToJson: false)
_$$PhotoImplCopyWith<_$PhotoImpl> get copyWith =>
throw _privateConstructorUsedError;
}

View File

@@ -1,18 +0,0 @@
import 'package:freezed_annotation/freezed_annotation.dart';
part 'portion.freezed.dart';
part 'portion.g.dart';
@freezed
class Portion with _$Portion {
const factory Portion({
required int id,
required String product_name,
required int quantity,
required String portion,
required bool from_diet,
}) = _Portion;
factory Portion.fromJson(Map<String, Object?> json) => _$PortionFromJson(json);
}

View File

@@ -1,248 +0,0 @@
// coverage:ignore-file
// GENERATED CODE - DO NOT MODIFY BY HAND
// ignore_for_file: type=lint
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark
part of 'portion.dart';
// **************************************************************************
// FreezedGenerator
// **************************************************************************
T _$identity<T>(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;
bool get from_diet => throw _privateConstructorUsedError;
/// Serializes this Portion to a JSON map.
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
/// Create a copy of Portion
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
$PortionCopyWith<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,
bool from_diet});
}
/// @nodoc
class _$PortionCopyWithImpl<$Res, $Val extends Portion>
implements $PortionCopyWith<$Res> {
_$PortionCopyWithImpl(this._value, this._then);
// ignore: unused_field
final $Val _value;
// ignore: unused_field
final $Res Function($Val) _then;
/// Create a copy of Portion
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? id = null,
Object? product_name = null,
Object? quantity = null,
Object? portion = null,
Object? from_diet = null,
}) {
return _then(_value.copyWith(
id: null == id
? _value.id
: id // ignore: cast_nullable_to_non_nullable
as int,
product_name: null == product_name
? _value.product_name
: product_name // ignore: cast_nullable_to_non_nullable
as String,
quantity: null == quantity
? _value.quantity
: quantity // ignore: cast_nullable_to_non_nullable
as int,
portion: null == portion
? _value.portion
: portion // ignore: cast_nullable_to_non_nullable
as String,
from_diet: null == from_diet
? _value.from_diet
: from_diet // ignore: cast_nullable_to_non_nullable
as bool,
) as $Val);
}
}
/// @nodoc
abstract class _$$PortionImplCopyWith<$Res> implements $PortionCopyWith<$Res> {
factory _$$PortionImplCopyWith(
_$PortionImpl value, $Res Function(_$PortionImpl) then) =
__$$PortionImplCopyWithImpl<$Res>;
@override
@useResult
$Res call(
{int id,
String product_name,
int quantity,
String portion,
bool from_diet});
}
/// @nodoc
class __$$PortionImplCopyWithImpl<$Res>
extends _$PortionCopyWithImpl<$Res, _$PortionImpl>
implements _$$PortionImplCopyWith<$Res> {
__$$PortionImplCopyWithImpl(
_$PortionImpl _value, $Res Function(_$PortionImpl) _then)
: super(_value, _then);
/// Create a copy of Portion
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? id = null,
Object? product_name = null,
Object? quantity = null,
Object? portion = null,
Object? from_diet = null,
}) {
return _then(_$PortionImpl(
id: null == id
? _value.id
: id // ignore: cast_nullable_to_non_nullable
as int,
product_name: null == product_name
? _value.product_name
: product_name // ignore: cast_nullable_to_non_nullable
as String,
quantity: null == quantity
? _value.quantity
: quantity // ignore: cast_nullable_to_non_nullable
as int,
portion: null == portion
? _value.portion
: portion // ignore: cast_nullable_to_non_nullable
as String,
from_diet: null == from_diet
? _value.from_diet
: from_diet // ignore: cast_nullable_to_non_nullable
as bool,
));
}
}
/// @nodoc
@JsonSerializable()
class _$PortionImpl implements _Portion {
const _$PortionImpl(
{required this.id,
required this.product_name,
required this.quantity,
required this.portion,
required this.from_diet});
factory _$PortionImpl.fromJson(Map<String, dynamic> json) =>
_$$PortionImplFromJson(json);
@override
final int id;
@override
final String product_name;
@override
final int quantity;
@override
final String portion;
@override
final bool from_diet;
@override
String toString() {
return 'Portion(id: $id, product_name: $product_name, quantity: $quantity, portion: $portion, from_diet: $from_diet)';
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$PortionImpl &&
(identical(other.id, id) || other.id == id) &&
(identical(other.product_name, product_name) ||
other.product_name == product_name) &&
(identical(other.quantity, quantity) ||
other.quantity == quantity) &&
(identical(other.portion, portion) || other.portion == portion) &&
(identical(other.from_diet, from_diet) ||
other.from_diet == from_diet));
}
@JsonKey(includeFromJson: false, includeToJson: false)
@override
int get hashCode =>
Object.hash(runtimeType, id, product_name, quantity, portion, from_diet);
/// Create a copy of Portion
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@override
@pragma('vm:prefer-inline')
_$$PortionImplCopyWith<_$PortionImpl> get copyWith =>
__$$PortionImplCopyWithImpl<_$PortionImpl>(this, _$identity);
@override
Map<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,
required final bool from_diet}) = _$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
bool get from_diet;
/// Create a copy of Portion
/// with the given fields replaced by the non-null parameter values.
@override
@JsonKey(includeFromJson: false, includeToJson: false)
_$$PortionImplCopyWith<_$PortionImpl> get copyWith =>
throw _privateConstructorUsedError;
}

View File

@@ -1,25 +0,0 @@
// 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,
from_diet: json['from_diet'] as bool,
);
Map<String, dynamic> _$$PortionImplToJson(_$PortionImpl instance) =>
<String, dynamic>{
'id': instance.id,
'product_name': instance.product_name,
'quantity': instance.quantity,
'portion': instance.portion,
'from_diet': instance.from_diet,
};

View File

@@ -1,15 +0,0 @@
import 'package:freezed_annotation/freezed_annotation.dart';
part 'state.freezed.dart';
part 'state.g.dart';
@freezed
class State with _$State {
const factory State({
required bool has_chosen_diet,
required bool has_chosen_plan,
}) = _State;
factory State.fromJson(Map<String, Object?> json) => _$StateFromJson(json);
}

View File

@@ -1,182 +0,0 @@
// coverage:ignore-file
// GENERATED CODE - DO NOT MODIFY BY HAND
// ignore_for_file: type=lint
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark
part of 'state.dart';
// **************************************************************************
// FreezedGenerator
// **************************************************************************
T _$identity<T>(T value) => value;
final _privateConstructorUsedError = UnsupportedError(
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models');
State _$StateFromJson(Map<String, dynamic> json) {
return _State.fromJson(json);
}
/// @nodoc
mixin _$State {
bool get has_chosen_diet => throw _privateConstructorUsedError;
bool get has_chosen_plan => throw _privateConstructorUsedError;
/// Serializes this State to a JSON map.
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
/// Create a copy of State
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
$StateCopyWith<State> get copyWith => throw _privateConstructorUsedError;
}
/// @nodoc
abstract class $StateCopyWith<$Res> {
factory $StateCopyWith(State value, $Res Function(State) then) =
_$StateCopyWithImpl<$Res, State>;
@useResult
$Res call({bool has_chosen_diet, bool has_chosen_plan});
}
/// @nodoc
class _$StateCopyWithImpl<$Res, $Val extends State>
implements $StateCopyWith<$Res> {
_$StateCopyWithImpl(this._value, this._then);
// ignore: unused_field
final $Val _value;
// ignore: unused_field
final $Res Function($Val) _then;
/// Create a copy of State
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? has_chosen_diet = null,
Object? has_chosen_plan = null,
}) {
return _then(_value.copyWith(
has_chosen_diet: null == has_chosen_diet
? _value.has_chosen_diet
: has_chosen_diet // ignore: cast_nullable_to_non_nullable
as bool,
has_chosen_plan: null == has_chosen_plan
? _value.has_chosen_plan
: has_chosen_plan // ignore: cast_nullable_to_non_nullable
as bool,
) as $Val);
}
}
/// @nodoc
abstract class _$$StateImplCopyWith<$Res> implements $StateCopyWith<$Res> {
factory _$$StateImplCopyWith(
_$StateImpl value, $Res Function(_$StateImpl) then) =
__$$StateImplCopyWithImpl<$Res>;
@override
@useResult
$Res call({bool has_chosen_diet, bool has_chosen_plan});
}
/// @nodoc
class __$$StateImplCopyWithImpl<$Res>
extends _$StateCopyWithImpl<$Res, _$StateImpl>
implements _$$StateImplCopyWith<$Res> {
__$$StateImplCopyWithImpl(
_$StateImpl _value, $Res Function(_$StateImpl) _then)
: super(_value, _then);
/// Create a copy of State
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? has_chosen_diet = null,
Object? has_chosen_plan = null,
}) {
return _then(_$StateImpl(
has_chosen_diet: null == has_chosen_diet
? _value.has_chosen_diet
: has_chosen_diet // ignore: cast_nullable_to_non_nullable
as bool,
has_chosen_plan: null == has_chosen_plan
? _value.has_chosen_plan
: has_chosen_plan // ignore: cast_nullable_to_non_nullable
as bool,
));
}
}
/// @nodoc
@JsonSerializable()
class _$StateImpl implements _State {
const _$StateImpl(
{required this.has_chosen_diet, required this.has_chosen_plan});
factory _$StateImpl.fromJson(Map<String, dynamic> json) =>
_$$StateImplFromJson(json);
@override
final bool has_chosen_diet;
@override
final bool has_chosen_plan;
@override
String toString() {
return 'State(has_chosen_diet: $has_chosen_diet, has_chosen_plan: $has_chosen_plan)';
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$StateImpl &&
(identical(other.has_chosen_diet, has_chosen_diet) ||
other.has_chosen_diet == has_chosen_diet) &&
(identical(other.has_chosen_plan, has_chosen_plan) ||
other.has_chosen_plan == has_chosen_plan));
}
@JsonKey(includeFromJson: false, includeToJson: false)
@override
int get hashCode =>
Object.hash(runtimeType, has_chosen_diet, has_chosen_plan);
/// Create a copy of State
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@override
@pragma('vm:prefer-inline')
_$$StateImplCopyWith<_$StateImpl> get copyWith =>
__$$StateImplCopyWithImpl<_$StateImpl>(this, _$identity);
@override
Map<String, dynamic> toJson() {
return _$$StateImplToJson(
this,
);
}
}
abstract class _State implements State {
const factory _State(
{required final bool has_chosen_diet,
required final bool has_chosen_plan}) = _$StateImpl;
factory _State.fromJson(Map<String, dynamic> json) = _$StateImpl.fromJson;
@override
bool get has_chosen_diet;
@override
bool get has_chosen_plan;
/// Create a copy of State
/// with the given fields replaced by the non-null parameter values.
@override
@JsonKey(includeFromJson: false, includeToJson: false)
_$$StateImplCopyWith<_$StateImpl> get copyWith =>
throw _privateConstructorUsedError;
}

View File

@@ -1,18 +0,0 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'state.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
_$StateImpl _$$StateImplFromJson(Map<String, dynamic> json) => _$StateImpl(
has_chosen_diet: json['has_chosen_diet'] as bool,
has_chosen_plan: json['has_chosen_plan'] as bool,
);
Map<String, dynamic> _$$StateImplToJson(_$StateImpl instance) =>
<String, dynamic>{
'has_chosen_diet': instance.has_chosen_diet,
'has_chosen_plan': instance.has_chosen_plan,
};

View File

@@ -1,517 +0,0 @@
import 'dart:async';
import 'package:eatvio_app/data/models/selectionPopupModel/selection_popup_model.dart';
import 'package:eatvio_app/features/diary/models/diary_model.dart';
import 'package:eatvio_app/features/diary/models/meal.dart';
import 'package:eatvio_app/features/diary/models/product.dart';
import 'package:eatvio_app/features/diary/presentation/bloc/diary_state.dart';
import 'package:eatvio_app/features/diary/repositories/diary_repository.dart';
import 'package:equatable/equatable.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:image_picker/image_picker.dart';
import 'package:intl/intl.dart';
part 'diary_event.dart';
/// A bloc that manages the state of a Diary according to the event that is dispatched to it.
class DiaryBloc extends Bloc<DiaryEvent, DiaryState> {
final DiaryRepository diaryRepository;
DiaryBloc({required this.diaryRepository}) : super(const DiaryState.loading()) {
on<LoadDiary>(loadDiary);
on<LoadDiaryById>(loadDiaryById);
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);
on<ConfirmPortion>(_confirmPortion);
}
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: "грамм", value: "gr"), SelectionPopupModel(title: "порций", value: "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']! * 50;
final double proteins = dailyNutritionIntake['proteins']! / dailyNutritionRecommendations['proteins']! * 50;
final double fats = dailyNutritionIntake['fats']! / dailyNutritionRecommendations['fats']! * 50;
final double carbs = dailyNutritionIntake['carbohydrates']! / dailyNutritionRecommendations['carbohydrates']! * 50;
Color getColor(double value) {
if (value >= 99.1) {
return Colors.red;
} else {
return Colors.blue;
}
}
final List<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),
];
emit(DiaryState.loaded(
diary: diary,
currentMeal: currentMeal,
portions: currentMeal.portions,
portionList: portionList,
portionController: portionList[0],
mealList: mealList,
chartData: chartData,
chartDataCounted: chartDataCounted,
selectedMood: currentMeal.mood,
selectedSatiety: currentMeal.satiety,
wakeupController: TimeOfDay.now(),
retireController: TimeOfDay.now(),
commentController: TextEditingController(),
product_nameController: TextEditingController(),
productQuantityController: TextEditingController(),
caloriesController: TextEditingController(),
fatsController: TextEditingController(),
proteinsController: TextEditingController(),
carbsController: TextEditingController(),
wakeupExpanded: false,
moderationExpanded: false,
moodExpanded: false,
isLoading: false,
isAdded: false,
autocompleteList: [],
recommendedChartValues: [1, 1, 1, 1],
consumedChartValues: [1, 1, 1, 1]));
} catch (e) {
emit(DiaryState.error(errorMessage: e.toString()));
}
}
loadDiaryById(
LoadDiaryById event,
Emitter<DiaryState> emit,
) async {
emit(const DiaryState.loading());
try {
final int diaryID = int.parse(event.id ?? "0");
final DiaryModel diary = await diaryRepository.getDiary(diaryID);
final Meal currentMeal = diary.meals[0];
List<SelectionPopupModel> portionList = [SelectionPopupModel(title: "gr"), SelectionPopupModel(title: "pcs")];
final Map<String, dynamic> chartData = await diaryRepository.getChartData(diaryID);
final Map<String, dynamic> dailyNutritionIntake = chartData['dailyNutritionIntake']!;
final Map<String, dynamic> dailyNutritionRecommendations = chartData['dailyNutritionRecommendation']!;
final double ccal = dailyNutritionIntake['energy']! / dailyNutritionRecommendations['energy']! * 50;
final double proteins = dailyNutritionIntake['proteins']! / dailyNutritionRecommendations['proteins']! * 50;
final double fats = dailyNutritionIntake['fats']! / dailyNutritionRecommendations['fats']! * 50;
final double carbs = dailyNutritionIntake['carbohydrates']! / dailyNutritionRecommendations['carbohydrates']! * 50;
Color getColor(double value) {
if (value >= 99.1) {
return Colors.red;
} else {
return Colors.blue;
}
}
final List<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),
];
emit(DiaryState.loaded(
diary: diary,
currentMeal: currentMeal,
portions: currentMeal.portions,
portionList: portionList,
portionController: portionList[0],
mealList: mealList,
chartData: chartData,
chartDataCounted: chartDataCounted,
selectedMood: currentMeal.mood,
selectedSatiety: currentMeal.satiety,
wakeupController: TimeOfDay.now(),
retireController: TimeOfDay.now(),
commentController: TextEditingController(),
product_nameController: TextEditingController(),
productQuantityController: TextEditingController(),
caloriesController: TextEditingController(),
fatsController: TextEditingController(),
proteinsController: TextEditingController(),
carbsController: TextEditingController(),
wakeupExpanded: false,
moderationExpanded: false,
moodExpanded: false,
isLoading: false,
isAdded: false,
autocompleteList: [],
recommendedChartValues: [1, 1, 1, 1],
consumedChartValues: [1, 1, 1, 1]));
} catch (e) {
emit(DiaryState.error(errorMessage: e.toString()));
}
}
Future<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.value,
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: "грамм"),
];
}
FutureOr<void> _confirmPortion(ConfirmPortion event, Emitter<DiaryState> emit) {
if (state is DiaryStateLoaded) {
var currentState = state as DiaryStateLoaded;
final updatedPortions = currentState.portions.map((portion) {
if (portion.id == event.id) {
return portion.copyWith(from_diet: !portion.from_diet);
}
if (!portion.from_diet) add(RemovePortionEvent(portion.id));
return portion;
}).toList();
final updatedState = currentState.copyWith(portions: updatedPortions);
emit(updatedState);
add(LoadDiary());
}
}
}
int convertToInt(dynamic value) {
if (value is int) {
return value;
} else if (value is double) {
return value.toInt();
} else {
throw FormatException('Unexpected value type: ${value.runtimeType}');
}
}

View File

@@ -0,0 +1,47 @@
import 'package:eatvio_app/features/diary/presentation/bloc/diary_state.dart';
import 'package:eatvio_app/features/diary/repositories/diary_repository.dart';
import 'package:eatvio_app/features/glossary/models/glossary_model.dart';
import 'package:eatvio_app/features/glossary/repositories/glossary_repository.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
class DiaryCubit extends Cubit<DiaryState> {
final DiaryRepository diaryRepository;
final GlossaryRepository glossaryRepository;
DiaryCubit({
required this.diaryRepository,
required this.glossaryRepository,
}) : super(const DiaryState.loading());
getDiaryDay(String date, [bool needLoading = true]) async {
if (needLoading) emit(const DiaryState.loading());
try {
emit(DiaryState.loaded(diary: await diaryRepository.getDiaryByDate(date)));
} catch (e) {
emit(DiaryState.error(errorMessage: e.toString()));
throw e;
}
}
addProductToMeal({
required int diaryId,
required int mealId,
required String productName,
required String portion,
required int quantity,
required String date,
}) async {
await diaryRepository.addPortionToMeal(
diaryId: diaryId,
mealId: mealId,
productName: productName,
portion: portion,
quantity: quantity,
);
await getDiaryDay(date, false);
}
Future<List<GlossaryModel>> getGlossaryListByQuery(String query) async {
return await glossaryRepository.getGlossaryListByQuery(query);
}
}

View File

@@ -1,209 +0,0 @@
// ignore_for_file: must_be_immutable
part of 'diary_bloc.dart';
/// Abstract class for all events that can be dispatched from the
///Diary widget.
///
/// Events must be immutable and implement the [Equatable] interface.
@immutable
abstract class DiaryEvent extends Equatable {}
/// Event that is dispatched when the Diary widget is first created.
class LoadDiary extends DiaryEvent {
@override
List<Object?> get props => [];
}
class LoadDiaryById extends DiaryEvent {
LoadDiaryById(
this.id,
);
final String? id;
@override
List<Object?> get props => [];
}
class ChangeSatiety extends DiaryEvent {
ChangeSatiety(
this.selectedElement,
);
final int selectedElement;
@override
List<Object> get props => [selectedElement];
}
class ChangeMood extends DiaryEvent {
ChangeMood(
this.selectedElement,
);
final int selectedElement;
@override
List<Object> get props => [selectedElement];
}
class ChangeMealTime extends DiaryEvent {
ChangeMealTime(this.time);
final TimeOfDay time;
@override
List<Object> get props => [time];
}
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 DiaryEvent {
WakeupEvent(this.selectedTime);
final TimeOfDay selectedTime;
@override
List<Object> get props => [selectedTime];
}
class RetireEvent extends DiaryEvent {
RetireEvent(this.selectedTime);
final TimeOfDay selectedTime;
@override
List<Object> get props => [selectedTime];
}
class ToggleMoodExpandedEvent extends DiaryEvent {
@override
List<Object?> get props => [];
}
class ToggleWakeupExpandedEvent extends DiaryEvent {
@override
List<Object?> get props => [];
}
class AddPortionEvent extends DiaryEvent {
AddPortionEvent();
@override
List<Object> get props => [];
}
class RemovePortionEvent extends DiaryEvent {
RemovePortionEvent(this.portionId);
final int portionId;
@override
List<Object> get props => [portionId];
}
class UploadImages extends DiaryEvent {
UploadImages(this.image);
final XFile image;
@override
List<Object> get props => [image];
}
class RemoveImageEvent extends DiaryEvent {
RemoveImageEvent(this.photoID, this.path);
final String photoID;
final String path;
@override
List<Object> get props => [photoID, path];
}
class ProductInput extends DiaryEvent {
ProductInput(this.input);
final String input;
@override
List<Object> get props => [input];
}
class ChangeMeal extends DiaryEvent {
ChangeMeal({required this.value});
SelectionPopupModel value;
@override
List<Object?> get props => [value];
}
class ClearInput extends DiaryEvent {
ClearInput({required this.value});
TextEditingController value;
@override
List<Object?> get props => [value];
}
class ChangePortion extends DiaryEvent {
ChangePortion({required this.value});
SelectionPopupModel value;
@override
List<Object?> get props => [value];
}
class FinishDay extends DiaryEvent {
FinishDay();
@override
List<Object?> get props => [];
}
class RefreshEvent extends DiaryEvent {
RefreshEvent();
@override
List<Object?> get props => [];
}
class ConfirmPortion extends DiaryEvent {
ConfirmPortion(this.id);
int id;
@override
List<Object?> get props => [id];
}
class SendModeration extends DiaryEvent {
SendModeration({
required this.name,
required this.energyOn100gr,
required this.proteinsOn100gr,
required this.fatsOn100gr,
required this.carbohydratesOn100gr,
});
String name;
String energyOn100gr;
String proteinsOn100gr;
String fatsOn100gr;
String carbohydratesOn100gr;
@override
List<Object?> get props => [name, energyOn100gr, proteinsOn100gr, fatsOn100gr, carbohydratesOn100gr];
}

View File

@@ -1,63 +1,19 @@
import 'package:eatvio_app/features/diary/models/diary_model.dart';
import 'package:eatvio_app/features/diary/models/meal.dart';
import 'package:eatvio_app/features/diary/models/portion.dart';
import 'package:eatvio_app/features/diary/models/product.dart';
import 'package:flutter/material.dart';
import 'package:eatvio_app/features/diary/models/diary_day_model.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
import '../../../../data/models/selectionPopupModel/selection_popup_model.dart';
part 'diary_state.freezed.dart';
@freezed
abstract class DiaryState with _$DiaryState {
class DiaryState with _$DiaryState {
const factory DiaryState() = _DiaryState;
const factory DiaryState.loading({
int? id,
}) = DiaryStateLoading;
const factory DiaryState.loaded({
required DiaryModel diary,
String? diaryDate,
required List<int> recommendedChartValues,
required List<int> consumedChartValues,
required List<Portion> portions,
required List<SelectionPopupModel> mealList,
required List<SelectionPopupModel> portionList,
required List<Product> autocompleteList,
required Map<String, dynamic> chartData,
required Meal currentMeal,
required SelectionPopupModel portionController,
required TimeOfDay wakeupController,
required TimeOfDay retireController,
TimeOfDay? mealTimeController,
required TextEditingController commentController,
required TextEditingController product_nameController,
required TextEditingController productQuantityController,
required TextEditingController caloriesController,
required TextEditingController fatsController,
required TextEditingController proteinsController,
required TextEditingController carbsController,
required int selectedMood,
required int selectedSatiety,
required bool wakeupExpanded,
required bool moderationExpanded,
required bool moodExpanded,
required bool isLoading,
required bool isAdded,
List<NutritionData>? chartDataCounted,
}) = DiaryStateLoaded;
const factory DiaryState.loading() = DiaryStateLoading;
const factory DiaryState.error({
required String errorMessage,
}) = DiaryStateError;
}
class NutritionData {
NutritionData(this.category, this.nutrition, this.color);
final String category;
final double nutrition;
final Color color;
const factory DiaryState.loaded({
required DiaryDayModel diary,
}) = DiaryStateLoaded;
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,115 +0,0 @@
// ignore_for_file: unused_local_variable
import 'package:eatvio_app/features/diary/models/portion.dart';
import 'package:eatvio_app/features/diary/presentation/bloc/diary_bloc.dart';
import 'package:eatvio_app/features/diary/presentation/bloc/diary_state.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_form_builder/flutter_form_builder.dart';
import 'package:rive/rive.dart';
// ignore: must_be_immutable
class DiaryRecommendationsScreen extends StatelessWidget {
final String? diary_recommendationsID;
const DiaryRecommendationsScreen({
this.diary_recommendationsID,
super.key,
});
Widget build(BuildContext context) {
if (diary_recommendationsID != "0") {
context.read<DiaryBloc>().add(LoadDiaryById(diary_recommendationsID));
}
return BlocBuilder<DiaryBloc, DiaryState>(
builder: (context, state) {
if (state is DiaryStateLoaded) {
return _buildDiaryRecommendations(context, state);
} else if (state is DiaryStateLoading) {
return Scaffold(
body: Center(
child: SizedBox(
height: 32,
width: 32,
child: RiveAnimation.asset(
'assets/rive_animations/loading.riv',
),
),
),
);
} else if (state is DiaryStateError) {
return Scaffold(
body: Padding(
padding: const EdgeInsets.all(16),
child: Center(
child: Text(state.errorMessage),
),
),
);
} else
return Scaffold(
body: Padding(
padding: const EdgeInsets.all(16),
child: Center(
child: Text("Неопределенная ошибка"),
),
),
);
},
);
}
Widget _buildDiaryRecommendations(BuildContext context, DiaryStateLoaded state) {
final Portion product = new Portion(id: 1, product_name: "", quantity: 1, portion: "", from_diet: true);
return Stack(
alignment: Alignment.bottomCenter,
children: [
FormBuilder(
child: Scaffold(
appBar: AppBar(
toolbarHeight: 0,
automaticallyImplyLeading: false,
),
backgroundColor: Color.fromARGB(255, 240, 242, 245),
resizeToAvoidBottomInset: true,
body: SizedBox(
width: double.maxFinite,
child: Column(
children: [
Expanded(
child: SingleChildScrollView(
child: Padding(
padding: EdgeInsets.only(bottom: 9),
child: Column(
children: [
Scaffold(
appBar: AppBar(
title: Text(product.product_name),
),
body: Padding(
padding: const EdgeInsets.all(16.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text('Название продукта: ${product.product_name}', style: TextStyle(fontSize: 24)),
SizedBox(height: 16),
Text('Количество: ${product.quantity} ${product.portion}', style: TextStyle(fontSize: 18)),
// Добавьте другие детали о продукте по необходимости
],
),
),
)
],
),
),
),
),
],
),
),
),
),
],
);
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,200 +1,37 @@
import 'dart:io';
import 'package:eatvio_app/features/diary/models/diary_model.dart';
import 'package:eatvio_app/features/diary/models/portion.dart';
import 'package:eatvio_app/features/diary/models/product.dart';
import 'package:eatvio_app/features/diary/models/diary_day_model.dart';
import 'package:eatvio_app/features/diary/services/diary_service.dart';
class DiaryRepository {
final DiaryService diaryService;
DiaryRepository({required this.diaryService});
DiaryRepository({
required this.diaryService,
});
Future<Map<String, int>> getDiaryID() async {
try {
return await diaryService.getDiaryID();
} catch (e) {
rethrow;
}
Future<DiaryDayModel> getDiaryByDate(String date) async {
return (await diaryService.getDiaryDay(
index: await _getDiaryIndexByDate(date),
))
.diary;
}
Future<DiaryModel> getDiary(int diaryID) async {
try {
return (await diaryService.getDiary(diaryID))['diary']!;
} catch (e) {
rethrow;
}
Future<int> _getDiaryIndexByDate(String date) async {
return (await diaryService.getDiaryIndexByDate(date: date)).id;
}
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,
) async {
try {
/*final formatter = DateFormat('HH:mm');
final wakeupString = formatter.format(DateTime(2022, 1, 1, wakeup.hour, wakeup.minute));
final retireString = formatter.format(DateTime(2022, 1, 1, retire.hour, retire.minute));*/
await diaryService.sendFinishDay(diaryID);
} catch (e) {
rethrow;
}
Future<void> addPortionToMeal({
required int diaryId,
required int mealId,
required String productName,
required String portion,
required int quantity,
}) async {
return await diaryService.addProductToMeal(
diaryId: diaryId,
mealId: mealId,
productName: productName,
portion: portion,
quantity: quantity,
);
}
}

View File

@@ -1,9 +1,6 @@
import 'dart:io';
import 'package:dio/dio.dart';
import 'package:eatvio_app/features/diary/models/diary_model.dart';
import 'package:eatvio_app/features/diary/models/portion.dart';
import 'package:eatvio_app/features/diary/models/product.dart';
import 'package:eatvio_app/features/diary/models/diary_day_model.dart';
import 'package:eatvio_app/features/diary/models/diary_index_model.dart';
import 'package:retrofit/retrofit.dart';
part 'diary_service.g.dart';
@@ -12,89 +9,22 @@ part 'diary_service.g.dart';
abstract class DiaryService {
factory DiaryService(Dio dio, {String baseUrl}) = _DiaryService;
@GET('/api/diary/index')
Future<Map<String, int>> getDiaryID();
@GET('/api/diary/index/{date}')
Future<DiaryIndexModel> getDiaryIndexByDate({
@Path('date') required String date, // yyyy-mm-dd
});
@GET('/api/diary/{id}/show/')
Future<Map<String, DiaryModel>> getDiary(@Path() int id);
@GET('/api/diary/{id}/dailyNutritionData/')
Future<dynamic> getChart(@Path() int id);
@GET('/api/diary/product_nutritional_values/filter')
Future<Map<String, List<Product>>> getInputProduct(@Query('name') String name);
@POST('/api/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('/api/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('/api/diary/{diary_id}/wakeup/fill')
Future<DiaryModel> sendWakeupData(
@Path() int diary_id,
@Query('wakeup') String wakeup,
);
@POST('/api/diary/{diary_id}/retire/fill')
Future<DiaryModel> sendRetireData(
@Path() int diary_id,
@Query('retire') String retire,
);
@GET('/api/diary/{diary_id}/show')
Future<DiaryDayWrapperModel> getDiaryDay({
@Path('diary_id') required int index,
});
@POST('/api/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('/api/diary/{diary_id}/meal/{meal_id}/photo/upload')
Future<void> uploadImage(
@Path() int diary_id,
@Path() int meal_id,
@Part() File photo,
);
@POST('/api/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('/api/diary/{diary_id}/finishDay')
Future<void> sendFinishDay(
@Path() int diary_id,
//@Query('wakeUp') String wakeup,
//@Query('retire') String retire,
//@Query('comment') String comment,
);
@DELETE('/api/diary/{diary_id}/meal/{meal_id}/portions/{portion_id}/delete')
Future<void> sendRemovePortionData(
@Path() int diary_id,
@Path() int meal_id,
@Path() int portion_id,
);
@DELETE('/api/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,
);
Future<void> addProductToMeal({
@Path('diary_id') required int diaryId,
@Path('meal_id') required int mealId,
@Part(name: 'product_name') required String productName,
@Part(name: 'portion') required String portion,
@Part(name: 'quantity') required int quantity,
});
}

View File

@@ -6,7 +6,7 @@ part of 'diary_service.dart';
// RetrofitGenerator
// **************************************************************************
// ignore_for_file: unnecessary_brace_in_string_interps,no_leading_underscores_for_local_identifiers,unused_element
// ignore_for_file: unnecessary_brace_in_string_interps,no_leading_underscores_for_local_identifiers,unused_element,unnecessary_string_interpolations
class _DiaryService implements DiaryService {
_DiaryService(
@@ -22,19 +22,19 @@ class _DiaryService implements DiaryService {
final ParseErrorLogger? errorLogger;
@override
Future<Map<String, int>> getDiaryID() async {
Future<DiaryIndexModel> getDiaryIndexByDate({required String date}) async {
final _extra = <String, dynamic>{};
final queryParameters = <String, dynamic>{};
final _headers = <String, dynamic>{};
const Map<String, dynamic>? _data = null;
final _options = _setStreamType<Map<String, int>>(Options(
final _options = _setStreamType<DiaryIndexModel>(Options(
method: 'GET',
headers: _headers,
extra: _extra,
)
.compose(
_dio.options,
'/api/diary/index',
'/api/diary/index/${date}',
queryParameters: queryParameters,
data: _data,
)
@@ -44,9 +44,9 @@ class _DiaryService implements DiaryService {
baseUrl,
)));
final _result = await _dio.fetch<Map<String, dynamic>>(_options);
late Map<String, int> _value;
late DiaryIndexModel _value;
try {
_value = _result.data!.cast<String, int>();
_value = DiaryIndexModel.fromJson(_result.data!);
} on Object catch (e, s) {
errorLogger?.logError(e, s, _options);
rethrow;
@@ -55,19 +55,19 @@ class _DiaryService implements DiaryService {
}
@override
Future<Map<String, DiaryModel>> getDiary(int id) async {
Future<DiaryDayWrapperModel> getDiaryDay({required int index}) async {
final _extra = <String, dynamic>{};
final queryParameters = <String, dynamic>{};
final _headers = <String, dynamic>{};
const Map<String, dynamic>? _data = null;
final _options = _setStreamType<Map<String, DiaryModel>>(Options(
final _options = _setStreamType<DiaryDayWrapperModel>(Options(
method: 'GET',
headers: _headers,
extra: _extra,
)
.compose(
_dio.options,
'/api/diary/${id}/show/',
'/api/diary/${index}/show',
queryParameters: queryParameters,
data: _data,
)
@@ -77,10 +77,9 @@ class _DiaryService implements DiaryService {
baseUrl,
)));
final _result = await _dio.fetch<Map<String, dynamic>>(_options);
late Map<String, DiaryModel> _value;
late DiaryDayWrapperModel _value;
try {
_value = _result.data!.map((k, dynamic v) =>
MapEntry(k, DiaryModel.fromJson(v as Map<String, dynamic>)));
_value = DiaryDayWrapperModel.fromJson(_result.data!);
} on Object catch (e, s) {
errorLogger?.logError(e, s, _options);
rethrow;
@@ -89,275 +88,28 @@ class _DiaryService implements DiaryService {
}
@override
Future<dynamic> getChart(int id) async {
final _extra = <String, dynamic>{};
final queryParameters = <String, dynamic>{};
final _headers = <String, dynamic>{};
const Map<String, dynamic>? _data = null;
final _options = _setStreamType<dynamic>(Options(
method: 'GET',
headers: _headers,
extra: _extra,
)
.compose(
_dio.options,
'/api/diary/${id}/dailyNutritionData/',
queryParameters: queryParameters,
data: _data,
)
.copyWith(
baseUrl: _combineBaseUrls(
_dio.options.baseUrl,
baseUrl,
)));
final _result = await _dio.fetch(_options);
final _value = _result.data;
return _value;
}
@override
Future<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 _options = _setStreamType<Map<String, List<Product>>>(Options(
method: 'GET',
headers: _headers,
extra: _extra,
)
.compose(
_dio.options,
'/api/diary/product_nutritional_values/filter',
queryParameters: queryParameters,
data: _data,
)
.copyWith(
baseUrl: _combineBaseUrls(
_dio.options.baseUrl,
baseUrl,
)));
final _result = await _dio.fetch<Map<String, dynamic>>(_options);
late Map<String, List<Product>> _value;
try {
_value = _result.data!.map((k, dynamic v) => MapEntry(
k,
(v as List)
.map((i) => Product.fromJson(i as Map<String, dynamic>))
.toList()));
} on Object catch (e, s) {
errorLogger?.logError(e, s, _options);
rethrow;
}
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 _options = _setStreamType<Map<String, int>>(Options(
method: 'POST',
headers: _headers,
extra: _extra,
)
.compose(
_dio.options,
'/api/diary/${diary_id}/meal/${meal_id}/satiety/fill',
queryParameters: queryParameters,
data: _data,
)
.copyWith(
baseUrl: _combineBaseUrls(
_dio.options.baseUrl,
baseUrl,
)));
final _result = await _dio.fetch<Map<String, dynamic>>(_options);
late Map<String, int> _value;
try {
_value = _result.data!.cast<String, int>();
} on Object catch (e, s) {
errorLogger?.logError(e, s, _options);
rethrow;
}
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 _options = _setStreamType<Map<String, int>>(Options(
method: 'POST',
headers: _headers,
extra: _extra,
)
.compose(
_dio.options,
'/api/diary/${diary_id}/meal/${meal_id}/mood/fill',
queryParameters: queryParameters,
data: _data,
)
.copyWith(
baseUrl: _combineBaseUrls(
_dio.options.baseUrl,
baseUrl,
)));
final _result = await _dio.fetch<Map<String, dynamic>>(_options);
late Map<String, int> _value;
try {
_value = _result.data!.cast<String, int>();
} on Object catch (e, s) {
errorLogger?.logError(e, s, _options);
rethrow;
}
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 _options = _setStreamType<DiaryModel>(Options(
method: 'POST',
headers: _headers,
extra: _extra,
)
.compose(
_dio.options,
'/api/diary/${diary_id}/wakeup/fill',
queryParameters: queryParameters,
data: _data,
)
.copyWith(
baseUrl: _combineBaseUrls(
_dio.options.baseUrl,
baseUrl,
)));
final _result = await _dio.fetch<Map<String, dynamic>>(_options);
late DiaryModel _value;
try {
_value = DiaryModel.fromJson(_result.data!);
} on Object catch (e, s) {
errorLogger?.logError(e, s, _options);
rethrow;
}
return _value;
}
@override
Future<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 _options = _setStreamType<DiaryModel>(Options(
method: 'POST',
headers: _headers,
extra: _extra,
)
.compose(
_dio.options,
'/api/diary/${diary_id}/retire/fill',
queryParameters: queryParameters,
data: _data,
)
.copyWith(
baseUrl: _combineBaseUrls(
_dio.options.baseUrl,
baseUrl,
)));
final _result = await _dio.fetch<Map<String, dynamic>>(_options);
late DiaryModel _value;
try {
_value = DiaryModel.fromJson(_result.data!);
} on Object catch (e, s) {
errorLogger?.logError(e, s, _options);
rethrow;
}
return _value;
}
@override
Future<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 _options = _setStreamType<Map<String, Portion>>(Options(
method: 'POST',
headers: _headers,
extra: _extra,
)
.compose(
_dio.options,
'/api/diary/${diary_id}/meal/${meal_id}/portions/create',
queryParameters: queryParameters,
data: _data,
)
.copyWith(
baseUrl: _combineBaseUrls(
_dio.options.baseUrl,
baseUrl,
)));
final _result = await _dio.fetch<Map<String, dynamic>>(_options);
late Map<String, Portion> _value;
try {
_value = _result.data!.map((k, dynamic v) =>
MapEntry(k, Portion.fromJson(v as Map<String, dynamic>)));
} on Object catch (e, s) {
errorLogger?.logError(e, s, _options);
rethrow;
}
return _value;
}
@override
Future<void> uploadImage(
int diary_id,
int meal_id,
File photo,
) async {
Future<void> addProductToMeal({
required int diaryId,
required int mealId,
required String productName,
required String portion,
required int quantity,
}) 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,
),
_data.fields.add(MapEntry(
'product_name',
productName,
));
_data.fields.add(MapEntry(
'portion',
portion,
));
_data.fields.add(MapEntry(
'quantity',
quantity.toString(),
));
final _options = _setStreamType<void>(Options(
method: 'POST',
@@ -366,139 +118,7 @@ class _DiaryService implements DiaryService {
)
.compose(
_dio.options,
'/api/diary/${diary_id}/meal/${meal_id}/photo/upload',
queryParameters: queryParameters,
data: _data,
)
.copyWith(
baseUrl: _combineBaseUrls(
_dio.options.baseUrl,
baseUrl,
)));
await _dio.fetch<void>(_options);
}
@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 _options = _setStreamType<Map<String, String>>(Options(
method: 'POST',
headers: _headers,
extra: _extra,
)
.compose(
_dio.options,
'/api/diary/product_nutritional_values/sendToModeration',
queryParameters: queryParameters,
data: _data,
)
.copyWith(
baseUrl: _combineBaseUrls(
_dio.options.baseUrl,
baseUrl,
)));
final _result = await _dio.fetch<Map<String, dynamic>>(_options);
late Map<String, String> _value;
try {
_value = _result.data!.cast<String, String>();
} on Object catch (e, s) {
errorLogger?.logError(e, s, _options);
rethrow;
}
return _value;
}
@override
Future<void> sendFinishDay(int diary_id) async {
final _extra = <String, dynamic>{};
final queryParameters = <String, dynamic>{};
final _headers = <String, dynamic>{};
const Map<String, dynamic>? _data = null;
final _options = _setStreamType<void>(Options(
method: 'POST',
headers: _headers,
extra: _extra,
)
.compose(
_dio.options,
'/api/diary/${diary_id}/finishDay',
queryParameters: queryParameters,
data: _data,
)
.copyWith(
baseUrl: _combineBaseUrls(
_dio.options.baseUrl,
baseUrl,
)));
await _dio.fetch<void>(_options);
}
@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;
final _options = _setStreamType<void>(Options(
method: 'DELETE',
headers: _headers,
extra: _extra,
)
.compose(
_dio.options,
'/api/diary/${diary_id}/meal/${meal_id}/portions/${portion_id}/delete',
queryParameters: queryParameters,
data: _data,
)
.copyWith(
baseUrl: _combineBaseUrls(
_dio.options.baseUrl,
baseUrl,
)));
await _dio.fetch<void>(_options);
}
@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;
final _options = _setStreamType<void>(Options(
method: 'DELETE',
headers: _headers,
extra: _extra,
)
.compose(
_dio.options,
'/api/diary/${diary_id}/meal/${meal_id}/photo/delete',
'/api/diary/${diaryId}/meal/${mealId}/portions/create',
queryParameters: queryParameters,
data: _data,
)

View File

@@ -37,9 +37,7 @@ class FeedCubit extends Cubit<FeedState> {
try {
if (currentPage < lastPage) {
print('before: $currentPage');
currentPage++;
print('after: $currentPage');
final feedBlogPosts = await feedRepository.getFeedBlogPosts(
page: currentPage,
query: _query,

View File

@@ -6,7 +6,7 @@ part of 'feed_service.dart';
// RetrofitGenerator
// **************************************************************************
// ignore_for_file: unnecessary_brace_in_string_interps,no_leading_underscores_for_local_identifiers,unused_element
// ignore_for_file: unnecessary_brace_in_string_interps,no_leading_underscores_for_local_identifiers,unused_element,unnecessary_string_interpolations
class _FeedService implements FeedService {
_FeedService(

View File

@@ -0,0 +1,24 @@
import 'package:freezed_annotation/freezed_annotation.dart';
part 'glossary_model.freezed.dart';
part 'glossary_model.g.dart';
@freezed
class GlossaryPaginationModel with _$GlossaryPaginationModel {
const factory GlossaryPaginationModel({
@JsonKey(name: 'data') required List<GlossaryModel> glossariesList,
}) = _GlossaryPaginationModel;
factory GlossaryPaginationModel.fromJson(Map<String, Object?> json) => _$GlossaryPaginationModelFromJson(json);
}
@freezed
class GlossaryModel with _$GlossaryModel {
const factory GlossaryModel({
required int id,
required String name,
@JsonKey(name: 'portion_mass_gr') required int grInPortion,
}) = _GlossaryModel;
factory GlossaryModel.fromJson(Map<String, Object?> json) => _$GlossaryModelFromJson(json);
}

View File

@@ -0,0 +1,380 @@
// coverage:ignore-file
// GENERATED CODE - DO NOT MODIFY BY HAND
// ignore_for_file: type=lint
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark
part of 'glossary_model.dart';
// **************************************************************************
// FreezedGenerator
// **************************************************************************
T _$identity<T>(T value) => value;
final _privateConstructorUsedError = UnsupportedError(
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models');
GlossaryPaginationModel _$GlossaryPaginationModelFromJson(
Map<String, dynamic> json) {
return _GlossaryPaginationModel.fromJson(json);
}
/// @nodoc
mixin _$GlossaryPaginationModel {
@JsonKey(name: 'data')
List<GlossaryModel> get glossariesList => throw _privateConstructorUsedError;
/// Serializes this GlossaryPaginationModel to a JSON map.
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
/// Create a copy of GlossaryPaginationModel
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
$GlossaryPaginationModelCopyWith<GlossaryPaginationModel> get copyWith =>
throw _privateConstructorUsedError;
}
/// @nodoc
abstract class $GlossaryPaginationModelCopyWith<$Res> {
factory $GlossaryPaginationModelCopyWith(GlossaryPaginationModel value,
$Res Function(GlossaryPaginationModel) then) =
_$GlossaryPaginationModelCopyWithImpl<$Res, GlossaryPaginationModel>;
@useResult
$Res call({@JsonKey(name: 'data') List<GlossaryModel> glossariesList});
}
/// @nodoc
class _$GlossaryPaginationModelCopyWithImpl<$Res,
$Val extends GlossaryPaginationModel>
implements $GlossaryPaginationModelCopyWith<$Res> {
_$GlossaryPaginationModelCopyWithImpl(this._value, this._then);
// ignore: unused_field
final $Val _value;
// ignore: unused_field
final $Res Function($Val) _then;
/// Create a copy of GlossaryPaginationModel
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? glossariesList = null,
}) {
return _then(_value.copyWith(
glossariesList: null == glossariesList
? _value.glossariesList
: glossariesList // ignore: cast_nullable_to_non_nullable
as List<GlossaryModel>,
) as $Val);
}
}
/// @nodoc
abstract class _$$GlossaryPaginationModelImplCopyWith<$Res>
implements $GlossaryPaginationModelCopyWith<$Res> {
factory _$$GlossaryPaginationModelImplCopyWith(
_$GlossaryPaginationModelImpl value,
$Res Function(_$GlossaryPaginationModelImpl) then) =
__$$GlossaryPaginationModelImplCopyWithImpl<$Res>;
@override
@useResult
$Res call({@JsonKey(name: 'data') List<GlossaryModel> glossariesList});
}
/// @nodoc
class __$$GlossaryPaginationModelImplCopyWithImpl<$Res>
extends _$GlossaryPaginationModelCopyWithImpl<$Res,
_$GlossaryPaginationModelImpl>
implements _$$GlossaryPaginationModelImplCopyWith<$Res> {
__$$GlossaryPaginationModelImplCopyWithImpl(
_$GlossaryPaginationModelImpl _value,
$Res Function(_$GlossaryPaginationModelImpl) _then)
: super(_value, _then);
/// Create a copy of GlossaryPaginationModel
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? glossariesList = null,
}) {
return _then(_$GlossaryPaginationModelImpl(
glossariesList: null == glossariesList
? _value._glossariesList
: glossariesList // ignore: cast_nullable_to_non_nullable
as List<GlossaryModel>,
));
}
}
/// @nodoc
@JsonSerializable()
class _$GlossaryPaginationModelImpl implements _GlossaryPaginationModel {
const _$GlossaryPaginationModelImpl(
{@JsonKey(name: 'data')
required final List<GlossaryModel> glossariesList})
: _glossariesList = glossariesList;
factory _$GlossaryPaginationModelImpl.fromJson(Map<String, dynamic> json) =>
_$$GlossaryPaginationModelImplFromJson(json);
final List<GlossaryModel> _glossariesList;
@override
@JsonKey(name: 'data')
List<GlossaryModel> get glossariesList {
if (_glossariesList is EqualUnmodifiableListView) return _glossariesList;
// ignore: implicit_dynamic_type
return EqualUnmodifiableListView(_glossariesList);
}
@override
String toString() {
return 'GlossaryPaginationModel(glossariesList: $glossariesList)';
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$GlossaryPaginationModelImpl &&
const DeepCollectionEquality()
.equals(other._glossariesList, _glossariesList));
}
@JsonKey(includeFromJson: false, includeToJson: false)
@override
int get hashCode => Object.hash(
runtimeType, const DeepCollectionEquality().hash(_glossariesList));
/// Create a copy of GlossaryPaginationModel
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@override
@pragma('vm:prefer-inline')
_$$GlossaryPaginationModelImplCopyWith<_$GlossaryPaginationModelImpl>
get copyWith => __$$GlossaryPaginationModelImplCopyWithImpl<
_$GlossaryPaginationModelImpl>(this, _$identity);
@override
Map<String, dynamic> toJson() {
return _$$GlossaryPaginationModelImplToJson(
this,
);
}
}
abstract class _GlossaryPaginationModel implements GlossaryPaginationModel {
const factory _GlossaryPaginationModel(
{@JsonKey(name: 'data')
required final List<GlossaryModel> glossariesList}) =
_$GlossaryPaginationModelImpl;
factory _GlossaryPaginationModel.fromJson(Map<String, dynamic> json) =
_$GlossaryPaginationModelImpl.fromJson;
@override
@JsonKey(name: 'data')
List<GlossaryModel> get glossariesList;
/// Create a copy of GlossaryPaginationModel
/// with the given fields replaced by the non-null parameter values.
@override
@JsonKey(includeFromJson: false, includeToJson: false)
_$$GlossaryPaginationModelImplCopyWith<_$GlossaryPaginationModelImpl>
get copyWith => throw _privateConstructorUsedError;
}
GlossaryModel _$GlossaryModelFromJson(Map<String, dynamic> json) {
return _GlossaryModel.fromJson(json);
}
/// @nodoc
mixin _$GlossaryModel {
int get id => throw _privateConstructorUsedError;
String get name => throw _privateConstructorUsedError;
@JsonKey(name: 'portion_mass_gr')
int get grInPortion => throw _privateConstructorUsedError;
/// Serializes this GlossaryModel to a JSON map.
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
/// Create a copy of GlossaryModel
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
$GlossaryModelCopyWith<GlossaryModel> get copyWith =>
throw _privateConstructorUsedError;
}
/// @nodoc
abstract class $GlossaryModelCopyWith<$Res> {
factory $GlossaryModelCopyWith(
GlossaryModel value, $Res Function(GlossaryModel) then) =
_$GlossaryModelCopyWithImpl<$Res, GlossaryModel>;
@useResult
$Res call(
{int id, String name, @JsonKey(name: 'portion_mass_gr') int grInPortion});
}
/// @nodoc
class _$GlossaryModelCopyWithImpl<$Res, $Val extends GlossaryModel>
implements $GlossaryModelCopyWith<$Res> {
_$GlossaryModelCopyWithImpl(this._value, this._then);
// ignore: unused_field
final $Val _value;
// ignore: unused_field
final $Res Function($Val) _then;
/// Create a copy of GlossaryModel
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? id = null,
Object? name = null,
Object? grInPortion = null,
}) {
return _then(_value.copyWith(
id: null == id
? _value.id
: id // ignore: cast_nullable_to_non_nullable
as int,
name: null == name
? _value.name
: name // ignore: cast_nullable_to_non_nullable
as String,
grInPortion: null == grInPortion
? _value.grInPortion
: grInPortion // ignore: cast_nullable_to_non_nullable
as int,
) as $Val);
}
}
/// @nodoc
abstract class _$$GlossaryModelImplCopyWith<$Res>
implements $GlossaryModelCopyWith<$Res> {
factory _$$GlossaryModelImplCopyWith(
_$GlossaryModelImpl value, $Res Function(_$GlossaryModelImpl) then) =
__$$GlossaryModelImplCopyWithImpl<$Res>;
@override
@useResult
$Res call(
{int id, String name, @JsonKey(name: 'portion_mass_gr') int grInPortion});
}
/// @nodoc
class __$$GlossaryModelImplCopyWithImpl<$Res>
extends _$GlossaryModelCopyWithImpl<$Res, _$GlossaryModelImpl>
implements _$$GlossaryModelImplCopyWith<$Res> {
__$$GlossaryModelImplCopyWithImpl(
_$GlossaryModelImpl _value, $Res Function(_$GlossaryModelImpl) _then)
: super(_value, _then);
/// Create a copy of GlossaryModel
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? id = null,
Object? name = null,
Object? grInPortion = null,
}) {
return _then(_$GlossaryModelImpl(
id: null == id
? _value.id
: id // ignore: cast_nullable_to_non_nullable
as int,
name: null == name
? _value.name
: name // ignore: cast_nullable_to_non_nullable
as String,
grInPortion: null == grInPortion
? _value.grInPortion
: grInPortion // ignore: cast_nullable_to_non_nullable
as int,
));
}
}
/// @nodoc
@JsonSerializable()
class _$GlossaryModelImpl implements _GlossaryModel {
const _$GlossaryModelImpl(
{required this.id,
required this.name,
@JsonKey(name: 'portion_mass_gr') required this.grInPortion});
factory _$GlossaryModelImpl.fromJson(Map<String, dynamic> json) =>
_$$GlossaryModelImplFromJson(json);
@override
final int id;
@override
final String name;
@override
@JsonKey(name: 'portion_mass_gr')
final int grInPortion;
@override
String toString() {
return 'GlossaryModel(id: $id, name: $name, grInPortion: $grInPortion)';
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$GlossaryModelImpl &&
(identical(other.id, id) || other.id == id) &&
(identical(other.name, name) || other.name == name) &&
(identical(other.grInPortion, grInPortion) ||
other.grInPortion == grInPortion));
}
@JsonKey(includeFromJson: false, includeToJson: false)
@override
int get hashCode => Object.hash(runtimeType, id, name, grInPortion);
/// Create a copy of GlossaryModel
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@override
@pragma('vm:prefer-inline')
_$$GlossaryModelImplCopyWith<_$GlossaryModelImpl> get copyWith =>
__$$GlossaryModelImplCopyWithImpl<_$GlossaryModelImpl>(this, _$identity);
@override
Map<String, dynamic> toJson() {
return _$$GlossaryModelImplToJson(
this,
);
}
}
abstract class _GlossaryModel implements GlossaryModel {
const factory _GlossaryModel(
{required final int id,
required final String name,
@JsonKey(name: 'portion_mass_gr') required final int grInPortion}) =
_$GlossaryModelImpl;
factory _GlossaryModel.fromJson(Map<String, dynamic> json) =
_$GlossaryModelImpl.fromJson;
@override
int get id;
@override
String get name;
@override
@JsonKey(name: 'portion_mass_gr')
int get grInPortion;
/// Create a copy of GlossaryModel
/// with the given fields replaced by the non-null parameter values.
@override
@JsonKey(includeFromJson: false, includeToJson: false)
_$$GlossaryModelImplCopyWith<_$GlossaryModelImpl> get copyWith =>
throw _privateConstructorUsedError;
}

View File

@@ -0,0 +1,35 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'glossary_model.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
_$GlossaryPaginationModelImpl _$$GlossaryPaginationModelImplFromJson(
Map<String, dynamic> json) =>
_$GlossaryPaginationModelImpl(
glossariesList: (json['data'] as List<dynamic>)
.map((e) => GlossaryModel.fromJson(e as Map<String, dynamic>))
.toList(),
);
Map<String, dynamic> _$$GlossaryPaginationModelImplToJson(
_$GlossaryPaginationModelImpl instance) =>
<String, dynamic>{
'data': instance.glossariesList,
};
_$GlossaryModelImpl _$$GlossaryModelImplFromJson(Map<String, dynamic> json) =>
_$GlossaryModelImpl(
id: (json['id'] as num).toInt(),
name: json['name'] as String,
grInPortion: (json['portion_mass_gr'] as num).toInt(),
);
Map<String, dynamic> _$$GlossaryModelImplToJson(_$GlossaryModelImpl instance) =>
<String, dynamic>{
'id': instance.id,
'name': instance.name,
'portion_mass_gr': instance.grInPortion,
};

View File

@@ -0,0 +1,18 @@
import 'package:eatvio_app/features/glossary/models/glossary_model.dart';
import 'package:eatvio_app/features/glossary/services/glossary_service.dart';
class GlossaryRepository {
final GlossaryService glossaryService;
GlossaryRepository({
required this.glossaryService,
});
Future<List<GlossaryModel>> getGlossaryListByQuery(String query) async {
try {
return (await glossaryService.getGlossaryByQuery(query: query)).glossariesList;
} catch (e) {
rethrow;
}
}
}

View File

@@ -0,0 +1,15 @@
import 'package:dio/dio.dart';
import 'package:eatvio_app/features/glossary/models/glossary_model.dart';
import 'package:retrofit/retrofit.dart';
part 'glossary_service.g.dart';
@RestApi()
abstract class GlossaryService {
factory GlossaryService(Dio dio, {String baseUrl}) = _GlossaryService;
@GET('/api/glossaries/search')
Future<GlossaryPaginationModel> getGlossaryByQuery({
@Query('search') required String query,
});
}

View File

@@ -0,0 +1,87 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'glossary_service.dart';
// **************************************************************************
// RetrofitGenerator
// **************************************************************************
// ignore_for_file: unnecessary_brace_in_string_interps,no_leading_underscores_for_local_identifiers,unused_element,unnecessary_string_interpolations
class _GlossaryService implements GlossaryService {
_GlossaryService(
this._dio, {
this.baseUrl,
this.errorLogger,
});
final Dio _dio;
String? baseUrl;
final ParseErrorLogger? errorLogger;
@override
Future<GlossaryPaginationModel> getGlossaryByQuery(
{required String query}) async {
final _extra = <String, dynamic>{};
final queryParameters = <String, dynamic>{r'search': query};
final _headers = <String, dynamic>{};
const Map<String, dynamic>? _data = null;
final _options = _setStreamType<GlossaryPaginationModel>(Options(
method: 'GET',
headers: _headers,
extra: _extra,
)
.compose(
_dio.options,
'/api/glossaries/search',
queryParameters: queryParameters,
data: _data,
)
.copyWith(
baseUrl: _combineBaseUrls(
_dio.options.baseUrl,
baseUrl,
)));
final _result = await _dio.fetch<Map<String, dynamic>>(_options);
late GlossaryPaginationModel _value;
try {
_value = GlossaryPaginationModel.fromJson(_result.data!);
} on Object catch (e, s) {
errorLogger?.logError(e, s, _options);
rethrow;
}
return _value;
}
RequestOptions _setStreamType<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();
}
}

View File

@@ -6,7 +6,7 @@ part of 'plans_service.dart';
// RetrofitGenerator
// **************************************************************************
// ignore_for_file: unnecessary_brace_in_string_interps,no_leading_underscores_for_local_identifiers,unused_element
// ignore_for_file: unnecessary_brace_in_string_interps,no_leading_underscores_for_local_identifiers,unused_element,unnecessary_string_interpolations
class _PlansService implements PlansService {
_PlansService(

View File

@@ -0,0 +1,18 @@
import 'package:freezed_annotation/freezed_annotation.dart';
part 'badge_model.freezed.dart';
part 'badge_model.g.dart';
@freezed
class BadgeModel with _$BadgeModel {
const factory BadgeModel({
required int id,
required String title,
required String description,
required String image,
required String type,
}) = _BadgeModel;
factory BadgeModel.fromJson(Map<String, Object?> json) => _$BadgeModelFromJson(json);
}

View File

@@ -0,0 +1,242 @@
// coverage:ignore-file
// GENERATED CODE - DO NOT MODIFY BY HAND
// ignore_for_file: type=lint
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark
part of 'badge_model.dart';
// **************************************************************************
// FreezedGenerator
// **************************************************************************
T _$identity<T>(T value) => value;
final _privateConstructorUsedError = UnsupportedError(
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models');
BadgeModel _$BadgeModelFromJson(Map<String, dynamic> json) {
return _BadgeModel.fromJson(json);
}
/// @nodoc
mixin _$BadgeModel {
int get id => throw _privateConstructorUsedError;
String get title => throw _privateConstructorUsedError;
String get description => throw _privateConstructorUsedError;
String get image => throw _privateConstructorUsedError;
String get type => throw _privateConstructorUsedError;
/// Serializes this BadgeModel to a JSON map.
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
/// Create a copy of BadgeModel
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
$BadgeModelCopyWith<BadgeModel> get copyWith =>
throw _privateConstructorUsedError;
}
/// @nodoc
abstract class $BadgeModelCopyWith<$Res> {
factory $BadgeModelCopyWith(
BadgeModel value, $Res Function(BadgeModel) then) =
_$BadgeModelCopyWithImpl<$Res, BadgeModel>;
@useResult
$Res call(
{int id, String title, String description, String image, String type});
}
/// @nodoc
class _$BadgeModelCopyWithImpl<$Res, $Val extends BadgeModel>
implements $BadgeModelCopyWith<$Res> {
_$BadgeModelCopyWithImpl(this._value, this._then);
// ignore: unused_field
final $Val _value;
// ignore: unused_field
final $Res Function($Val) _then;
/// Create a copy of BadgeModel
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? id = null,
Object? title = null,
Object? description = null,
Object? image = null,
Object? type = null,
}) {
return _then(_value.copyWith(
id: null == id
? _value.id
: id // ignore: cast_nullable_to_non_nullable
as int,
title: null == title
? _value.title
: title // ignore: cast_nullable_to_non_nullable
as String,
description: null == description
? _value.description
: description // ignore: cast_nullable_to_non_nullable
as String,
image: null == image
? _value.image
: image // ignore: cast_nullable_to_non_nullable
as String,
type: null == type
? _value.type
: type // ignore: cast_nullable_to_non_nullable
as String,
) as $Val);
}
}
/// @nodoc
abstract class _$$BadgeModelImplCopyWith<$Res>
implements $BadgeModelCopyWith<$Res> {
factory _$$BadgeModelImplCopyWith(
_$BadgeModelImpl value, $Res Function(_$BadgeModelImpl) then) =
__$$BadgeModelImplCopyWithImpl<$Res>;
@override
@useResult
$Res call(
{int id, String title, String description, String image, String type});
}
/// @nodoc
class __$$BadgeModelImplCopyWithImpl<$Res>
extends _$BadgeModelCopyWithImpl<$Res, _$BadgeModelImpl>
implements _$$BadgeModelImplCopyWith<$Res> {
__$$BadgeModelImplCopyWithImpl(
_$BadgeModelImpl _value, $Res Function(_$BadgeModelImpl) _then)
: super(_value, _then);
/// Create a copy of BadgeModel
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? id = null,
Object? title = null,
Object? description = null,
Object? image = null,
Object? type = null,
}) {
return _then(_$BadgeModelImpl(
id: null == id
? _value.id
: id // ignore: cast_nullable_to_non_nullable
as int,
title: null == title
? _value.title
: title // ignore: cast_nullable_to_non_nullable
as String,
description: null == description
? _value.description
: description // ignore: cast_nullable_to_non_nullable
as String,
image: null == image
? _value.image
: image // ignore: cast_nullable_to_non_nullable
as String,
type: null == type
? _value.type
: type // ignore: cast_nullable_to_non_nullable
as String,
));
}
}
/// @nodoc
@JsonSerializable()
class _$BadgeModelImpl implements _BadgeModel {
const _$BadgeModelImpl(
{required this.id,
required this.title,
required this.description,
required this.image,
required this.type});
factory _$BadgeModelImpl.fromJson(Map<String, dynamic> json) =>
_$$BadgeModelImplFromJson(json);
@override
final int id;
@override
final String title;
@override
final String description;
@override
final String image;
@override
final String type;
@override
String toString() {
return 'BadgeModel(id: $id, title: $title, description: $description, image: $image, type: $type)';
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$BadgeModelImpl &&
(identical(other.id, id) || other.id == id) &&
(identical(other.title, title) || other.title == title) &&
(identical(other.description, description) ||
other.description == description) &&
(identical(other.image, image) || other.image == image) &&
(identical(other.type, type) || other.type == type));
}
@JsonKey(includeFromJson: false, includeToJson: false)
@override
int get hashCode =>
Object.hash(runtimeType, id, title, description, image, type);
/// Create a copy of BadgeModel
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@override
@pragma('vm:prefer-inline')
_$$BadgeModelImplCopyWith<_$BadgeModelImpl> get copyWith =>
__$$BadgeModelImplCopyWithImpl<_$BadgeModelImpl>(this, _$identity);
@override
Map<String, dynamic> toJson() {
return _$$BadgeModelImplToJson(
this,
);
}
}
abstract class _BadgeModel implements BadgeModel {
const factory _BadgeModel(
{required final int id,
required final String title,
required final String description,
required final String image,
required final String type}) = _$BadgeModelImpl;
factory _BadgeModel.fromJson(Map<String, dynamic> json) =
_$BadgeModelImpl.fromJson;
@override
int get id;
@override
String get title;
@override
String get description;
@override
String get image;
@override
String get type;
/// Create a copy of BadgeModel
/// with the given fields replaced by the non-null parameter values.
@override
@JsonKey(includeFromJson: false, includeToJson: false)
_$$BadgeModelImplCopyWith<_$BadgeModelImpl> get copyWith =>
throw _privateConstructorUsedError;
}

View File

@@ -0,0 +1,25 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'badge_model.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
_$BadgeModelImpl _$$BadgeModelImplFromJson(Map<String, dynamic> json) =>
_$BadgeModelImpl(
id: (json['id'] as num).toInt(),
title: json['title'] as String,
description: json['description'] as String,
image: json['image'] as String,
type: json['type'] as String,
);
Map<String, dynamic> _$$BadgeModelImplToJson(_$BadgeModelImpl instance) =>
<String, dynamic>{
'id': instance.id,
'title': instance.title,
'description': instance.description,
'image': instance.image,
'type': instance.type,
};

View File

@@ -1,3 +1,4 @@
import 'package:eatvio_app/features/profile/models/badge_model.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
part 'profile_model.freezed.dart';
@@ -16,7 +17,10 @@ class ProfileModel with _$ProfileModel {
@JsonKey(name: "is_public_profile") required bool isPublicProfile,
@JsonKey(name: "slug") required String slug,
@JsonKey(name: "profile_photo_url") required String profilePhotoUrl,
required String role,
@JsonKey(name: "role") required String role,
@JsonKey(name: "badges") required List<BadgeModel> badges,
@JsonKey(name: "subscriptions") required List<ProfilePreviewModel> subscriptions,
@JsonKey(name: "subscribers") required List<ProfilePreviewModel> subscribers,
}) = _ProfileModel;
factory ProfileModel.fromJson(Map<String, dynamic> json) => _$ProfileModelFromJson(json);
@@ -56,3 +60,12 @@ class ProfileDetailsModel with _$ProfileDetailsModel {
factory ProfileDetailsModel.fromJson(Map<String, dynamic> json) => _$ProfileDetailsModelFromJson(json);
}
@freezed
class ProfilePreviewModel with _$ProfilePreviewModel {
const factory ProfilePreviewModel({
@JsonKey(name: "profile_photo_url") required String profilePhotoUrl,
}) = _ProfilePreviewModel;
factory ProfilePreviewModel.fromJson(Map<String, dynamic> json) => _$ProfilePreviewModelFromJson(json);
}

View File

@@ -38,7 +38,16 @@ mixin _$ProfileModel {
String get slug => throw _privateConstructorUsedError;
@JsonKey(name: "profile_photo_url")
String get profilePhotoUrl => throw _privateConstructorUsedError;
@JsonKey(name: "role")
String get role => throw _privateConstructorUsedError;
@JsonKey(name: "badges")
List<BadgeModel> get badges => throw _privateConstructorUsedError;
@JsonKey(name: "subscriptions")
List<ProfilePreviewModel> get subscriptions =>
throw _privateConstructorUsedError;
@JsonKey(name: "subscribers")
List<ProfilePreviewModel> get subscribers =>
throw _privateConstructorUsedError;
/// Serializes this ProfileModel to a JSON map.
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
@@ -66,7 +75,10 @@ abstract class $ProfileModelCopyWith<$Res> {
@JsonKey(name: "is_public_profile") bool isPublicProfile,
@JsonKey(name: "slug") String slug,
@JsonKey(name: "profile_photo_url") String profilePhotoUrl,
String role});
@JsonKey(name: "role") String role,
@JsonKey(name: "badges") List<BadgeModel> badges,
@JsonKey(name: "subscriptions") List<ProfilePreviewModel> subscriptions,
@JsonKey(name: "subscribers") List<ProfilePreviewModel> subscribers});
}
/// @nodoc
@@ -94,6 +106,9 @@ class _$ProfileModelCopyWithImpl<$Res, $Val extends ProfileModel>
Object? slug = null,
Object? profilePhotoUrl = null,
Object? role = null,
Object? badges = null,
Object? subscriptions = null,
Object? subscribers = null,
}) {
return _then(_value.copyWith(
id: null == id
@@ -136,6 +151,18 @@ class _$ProfileModelCopyWithImpl<$Res, $Val extends ProfileModel>
? _value.role
: role // ignore: cast_nullable_to_non_nullable
as String,
badges: null == badges
? _value.badges
: badges // ignore: cast_nullable_to_non_nullable
as List<BadgeModel>,
subscriptions: null == subscriptions
? _value.subscriptions
: subscriptions // ignore: cast_nullable_to_non_nullable
as List<ProfilePreviewModel>,
subscribers: null == subscribers
? _value.subscribers
: subscribers // ignore: cast_nullable_to_non_nullable
as List<ProfilePreviewModel>,
) as $Val);
}
}
@@ -158,7 +185,10 @@ abstract class _$$ProfileModelImplCopyWith<$Res>
@JsonKey(name: "is_public_profile") bool isPublicProfile,
@JsonKey(name: "slug") String slug,
@JsonKey(name: "profile_photo_url") String profilePhotoUrl,
String role});
@JsonKey(name: "role") String role,
@JsonKey(name: "badges") List<BadgeModel> badges,
@JsonKey(name: "subscriptions") List<ProfilePreviewModel> subscriptions,
@JsonKey(name: "subscribers") List<ProfilePreviewModel> subscribers});
}
/// @nodoc
@@ -184,6 +214,9 @@ class __$$ProfileModelImplCopyWithImpl<$Res>
Object? slug = null,
Object? profilePhotoUrl = null,
Object? role = null,
Object? badges = null,
Object? subscriptions = null,
Object? subscribers = null,
}) {
return _then(_$ProfileModelImpl(
id: null == id
@@ -226,6 +259,18 @@ class __$$ProfileModelImplCopyWithImpl<$Res>
? _value.role
: role // ignore: cast_nullable_to_non_nullable
as String,
badges: null == badges
? _value._badges
: badges // ignore: cast_nullable_to_non_nullable
as List<BadgeModel>,
subscriptions: null == subscriptions
? _value._subscriptions
: subscriptions // ignore: cast_nullable_to_non_nullable
as List<ProfilePreviewModel>,
subscribers: null == subscribers
? _value._subscribers
: subscribers // ignore: cast_nullable_to_non_nullable
as List<ProfilePreviewModel>,
));
}
}
@@ -243,7 +288,15 @@ class _$ProfileModelImpl implements _ProfileModel {
@JsonKey(name: "is_public_profile") required this.isPublicProfile,
@JsonKey(name: "slug") required this.slug,
@JsonKey(name: "profile_photo_url") required this.profilePhotoUrl,
required this.role});
@JsonKey(name: "role") required this.role,
@JsonKey(name: "badges") required final List<BadgeModel> badges,
@JsonKey(name: "subscriptions")
required final List<ProfilePreviewModel> subscriptions,
@JsonKey(name: "subscribers")
required final List<ProfilePreviewModel> subscribers})
: _badges = badges,
_subscriptions = subscriptions,
_subscribers = subscribers;
factory _$ProfileModelImpl.fromJson(Map<String, dynamic> json) =>
_$$ProfileModelImplFromJson(json);
@@ -276,11 +329,38 @@ class _$ProfileModelImpl implements _ProfileModel {
@JsonKey(name: "profile_photo_url")
final String profilePhotoUrl;
@override
@JsonKey(name: "role")
final String role;
final List<BadgeModel> _badges;
@override
@JsonKey(name: "badges")
List<BadgeModel> get badges {
if (_badges is EqualUnmodifiableListView) return _badges;
// ignore: implicit_dynamic_type
return EqualUnmodifiableListView(_badges);
}
final List<ProfilePreviewModel> _subscriptions;
@override
@JsonKey(name: "subscriptions")
List<ProfilePreviewModel> get subscriptions {
if (_subscriptions is EqualUnmodifiableListView) return _subscriptions;
// ignore: implicit_dynamic_type
return EqualUnmodifiableListView(_subscriptions);
}
final List<ProfilePreviewModel> _subscribers;
@override
@JsonKey(name: "subscribers")
List<ProfilePreviewModel> get subscribers {
if (_subscribers is EqualUnmodifiableListView) return _subscribers;
// ignore: implicit_dynamic_type
return EqualUnmodifiableListView(_subscribers);
}
@override
String toString() {
return 'ProfileModel(id: $id, name: $name, email: $email, emailVerifiedAt: $emailVerifiedAt, createdAt: $createdAt, updatedAt: $updatedAt, isPublicProfile: $isPublicProfile, slug: $slug, profilePhotoUrl: $profilePhotoUrl, role: $role)';
return 'ProfileModel(id: $id, name: $name, email: $email, emailVerifiedAt: $emailVerifiedAt, createdAt: $createdAt, updatedAt: $updatedAt, isPublicProfile: $isPublicProfile, slug: $slug, profilePhotoUrl: $profilePhotoUrl, role: $role, badges: $badges, subscriptions: $subscriptions, subscribers: $subscribers)';
}
@override
@@ -302,13 +382,31 @@ class _$ProfileModelImpl implements _ProfileModel {
(identical(other.slug, slug) || other.slug == slug) &&
(identical(other.profilePhotoUrl, profilePhotoUrl) ||
other.profilePhotoUrl == profilePhotoUrl) &&
(identical(other.role, role) || other.role == role));
(identical(other.role, role) || other.role == role) &&
const DeepCollectionEquality().equals(other._badges, _badges) &&
const DeepCollectionEquality()
.equals(other._subscriptions, _subscriptions) &&
const DeepCollectionEquality()
.equals(other._subscribers, _subscribers));
}
@JsonKey(includeFromJson: false, includeToJson: false)
@override
int get hashCode => Object.hash(runtimeType, id, name, email, emailVerifiedAt,
createdAt, updatedAt, isPublicProfile, slug, profilePhotoUrl, role);
int get hashCode => Object.hash(
runtimeType,
id,
name,
email,
emailVerifiedAt,
createdAt,
updatedAt,
isPublicProfile,
slug,
profilePhotoUrl,
role,
const DeepCollectionEquality().hash(_badges),
const DeepCollectionEquality().hash(_subscriptions),
const DeepCollectionEquality().hash(_subscribers));
/// Create a copy of ProfileModel
/// with the given fields replaced by the non-null parameter values.
@@ -337,7 +435,13 @@ abstract class _ProfileModel implements ProfileModel {
@JsonKey(name: "is_public_profile") required final bool isPublicProfile,
@JsonKey(name: "slug") required final String slug,
@JsonKey(name: "profile_photo_url") required final String profilePhotoUrl,
required final String role}) = _$ProfileModelImpl;
@JsonKey(name: "role") required final String role,
@JsonKey(name: "badges") required final List<BadgeModel> badges,
@JsonKey(name: "subscriptions")
required final List<ProfilePreviewModel> subscriptions,
@JsonKey(name: "subscribers")
required final List<ProfilePreviewModel>
subscribers}) = _$ProfileModelImpl;
factory _ProfileModel.fromJson(Map<String, dynamic> json) =
_$ProfileModelImpl.fromJson;
@@ -370,7 +474,17 @@ abstract class _ProfileModel implements ProfileModel {
@JsonKey(name: "profile_photo_url")
String get profilePhotoUrl;
@override
@JsonKey(name: "role")
String get role;
@override
@JsonKey(name: "badges")
List<BadgeModel> get badges;
@override
@JsonKey(name: "subscriptions")
List<ProfilePreviewModel> get subscriptions;
@override
@JsonKey(name: "subscribers")
List<ProfilePreviewModel> get subscribers;
/// Create a copy of ProfileModel
/// with the given fields replaced by the non-null parameter values.
@@ -1190,3 +1304,160 @@ abstract class _ProfileDetailsModel implements ProfileDetailsModel {
_$$ProfileDetailsModelImplCopyWith<_$ProfileDetailsModelImpl> get copyWith =>
throw _privateConstructorUsedError;
}
ProfilePreviewModel _$ProfilePreviewModelFromJson(Map<String, dynamic> json) {
return _ProfilePreviewModel.fromJson(json);
}
/// @nodoc
mixin _$ProfilePreviewModel {
@JsonKey(name: "profile_photo_url")
String get profilePhotoUrl => throw _privateConstructorUsedError;
/// Serializes this ProfilePreviewModel to a JSON map.
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
/// Create a copy of ProfilePreviewModel
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
$ProfilePreviewModelCopyWith<ProfilePreviewModel> get copyWith =>
throw _privateConstructorUsedError;
}
/// @nodoc
abstract class $ProfilePreviewModelCopyWith<$Res> {
factory $ProfilePreviewModelCopyWith(
ProfilePreviewModel value, $Res Function(ProfilePreviewModel) then) =
_$ProfilePreviewModelCopyWithImpl<$Res, ProfilePreviewModel>;
@useResult
$Res call({@JsonKey(name: "profile_photo_url") String profilePhotoUrl});
}
/// @nodoc
class _$ProfilePreviewModelCopyWithImpl<$Res, $Val extends ProfilePreviewModel>
implements $ProfilePreviewModelCopyWith<$Res> {
_$ProfilePreviewModelCopyWithImpl(this._value, this._then);
// ignore: unused_field
final $Val _value;
// ignore: unused_field
final $Res Function($Val) _then;
/// Create a copy of ProfilePreviewModel
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? profilePhotoUrl = null,
}) {
return _then(_value.copyWith(
profilePhotoUrl: null == profilePhotoUrl
? _value.profilePhotoUrl
: profilePhotoUrl // ignore: cast_nullable_to_non_nullable
as String,
) as $Val);
}
}
/// @nodoc
abstract class _$$ProfilePreviewModelImplCopyWith<$Res>
implements $ProfilePreviewModelCopyWith<$Res> {
factory _$$ProfilePreviewModelImplCopyWith(_$ProfilePreviewModelImpl value,
$Res Function(_$ProfilePreviewModelImpl) then) =
__$$ProfilePreviewModelImplCopyWithImpl<$Res>;
@override
@useResult
$Res call({@JsonKey(name: "profile_photo_url") String profilePhotoUrl});
}
/// @nodoc
class __$$ProfilePreviewModelImplCopyWithImpl<$Res>
extends _$ProfilePreviewModelCopyWithImpl<$Res, _$ProfilePreviewModelImpl>
implements _$$ProfilePreviewModelImplCopyWith<$Res> {
__$$ProfilePreviewModelImplCopyWithImpl(_$ProfilePreviewModelImpl _value,
$Res Function(_$ProfilePreviewModelImpl) _then)
: super(_value, _then);
/// Create a copy of ProfilePreviewModel
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? profilePhotoUrl = null,
}) {
return _then(_$ProfilePreviewModelImpl(
profilePhotoUrl: null == profilePhotoUrl
? _value.profilePhotoUrl
: profilePhotoUrl // ignore: cast_nullable_to_non_nullable
as String,
));
}
}
/// @nodoc
@JsonSerializable()
class _$ProfilePreviewModelImpl implements _ProfilePreviewModel {
const _$ProfilePreviewModelImpl(
{@JsonKey(name: "profile_photo_url") required this.profilePhotoUrl});
factory _$ProfilePreviewModelImpl.fromJson(Map<String, dynamic> json) =>
_$$ProfilePreviewModelImplFromJson(json);
@override
@JsonKey(name: "profile_photo_url")
final String profilePhotoUrl;
@override
String toString() {
return 'ProfilePreviewModel(profilePhotoUrl: $profilePhotoUrl)';
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$ProfilePreviewModelImpl &&
(identical(other.profilePhotoUrl, profilePhotoUrl) ||
other.profilePhotoUrl == profilePhotoUrl));
}
@JsonKey(includeFromJson: false, includeToJson: false)
@override
int get hashCode => Object.hash(runtimeType, profilePhotoUrl);
/// Create a copy of ProfilePreviewModel
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@override
@pragma('vm:prefer-inline')
_$$ProfilePreviewModelImplCopyWith<_$ProfilePreviewModelImpl> get copyWith =>
__$$ProfilePreviewModelImplCopyWithImpl<_$ProfilePreviewModelImpl>(
this, _$identity);
@override
Map<String, dynamic> toJson() {
return _$$ProfilePreviewModelImplToJson(
this,
);
}
}
abstract class _ProfilePreviewModel implements ProfilePreviewModel {
const factory _ProfilePreviewModel(
{@JsonKey(name: "profile_photo_url")
required final String profilePhotoUrl}) = _$ProfilePreviewModelImpl;
factory _ProfilePreviewModel.fromJson(Map<String, dynamic> json) =
_$ProfilePreviewModelImpl.fromJson;
@override
@JsonKey(name: "profile_photo_url")
String get profilePhotoUrl;
/// Create a copy of ProfilePreviewModel
/// with the given fields replaced by the non-null parameter values.
@override
@JsonKey(includeFromJson: false, includeToJson: false)
_$$ProfilePreviewModelImplCopyWith<_$ProfilePreviewModelImpl> get copyWith =>
throw _privateConstructorUsedError;
}

View File

@@ -24,6 +24,15 @@ _$ProfileModelImpl _$$ProfileModelImplFromJson(Map<String, dynamic> json) =>
slug: json['slug'] as String,
profilePhotoUrl: json['profile_photo_url'] as String,
role: json['role'] as String,
badges: (json['badges'] as List<dynamic>)
.map((e) => BadgeModel.fromJson(e as Map<String, dynamic>))
.toList(),
subscriptions: (json['subscriptions'] as List<dynamic>)
.map((e) => ProfilePreviewModel.fromJson(e as Map<String, dynamic>))
.toList(),
subscribers: (json['subscribers'] as List<dynamic>)
.map((e) => ProfilePreviewModel.fromJson(e as Map<String, dynamic>))
.toList(),
);
Map<String, dynamic> _$$ProfileModelImplToJson(_$ProfileModelImpl instance) =>
@@ -38,6 +47,9 @@ Map<String, dynamic> _$$ProfileModelImplToJson(_$ProfileModelImpl instance) =>
'slug': instance.slug,
'profile_photo_url': instance.profilePhotoUrl,
'role': instance.role,
'badges': instance.badges,
'subscriptions': instance.subscriptions,
'subscribers': instance.subscribers,
};
_$ProfileDetailsModelImpl _$$ProfileDetailsModelImplFromJson(
@@ -107,3 +119,15 @@ Map<String, dynamic> _$$ProfileDetailsModelImplToJson(
'is_bedtime_fillable': instance.isBedtimeFillable,
'activity_coefficient': instance.activityCoefficient,
};
_$ProfilePreviewModelImpl _$$ProfilePreviewModelImplFromJson(
Map<String, dynamic> json) =>
_$ProfilePreviewModelImpl(
profilePhotoUrl: json['profile_photo_url'] as String,
);
Map<String, dynamic> _$$ProfilePreviewModelImplToJson(
_$ProfilePreviewModelImpl instance) =>
<String, dynamic>{
'profile_photo_url': instance.profilePhotoUrl,
};

View File

@@ -1,13 +1,16 @@
import 'package:eatvio_app/features/chat/repositories/chat_repository.dart';
import 'package:eatvio_app/features/profile/presentation/bloc/profile_cubit/profile_state.dart';
import 'package:eatvio_app/features/profile/repositories/profile_repository.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
class ProfileCubit extends Cubit<ProfileState> {
final ProfileRepository profileRepository;
final ChatRepository chatRepository;
String _currentPeriod = '1';
ProfileCubit({
required this.profileRepository,
required this.chatRepository,
}) : super(const ProfileState.loading());
getProfileBySlug(String slug) async {
@@ -19,7 +22,6 @@ class ProfileCubit extends Cubit<ProfileState> {
));
} catch (e) {
emit(ProfileState.error(errorMessage: e.toString()));
print(e);
}
}
@@ -38,7 +40,6 @@ class ProfileCubit extends Cubit<ProfileState> {
));
} catch (e) {
emit(ProfileState.error(errorMessage: e.toString()));
print(e);
}
}
@@ -56,7 +57,6 @@ class ProfileCubit extends Cubit<ProfileState> {
await getMyProfile(period: _currentPeriod);
} catch (e) {
emit(ProfileState.error(errorMessage: e.toString()));
print(e);
}
}
@@ -68,7 +68,16 @@ class ProfileCubit extends Cubit<ProfileState> {
await getMyProfile(period: _currentPeriod);
} catch (e) {
emit(ProfileState.error(errorMessage: e.toString()));
print(e);
}
}
Future<String> getChatRoomIdBySlug({
required String slug,
}) async {
try {
return (await chatRepository.getChatRoomIdByUserSlug(slug: slug)).id;
} catch (e) {
rethrow;
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -65,8 +65,7 @@ class ProfileRepository {
try {
return (await profileService.getBlogPostByAuthorSlug(
slug: slug,
))
.feedBlogPostList;
));
} catch (e) {
rethrow;
}

View File

@@ -1,10 +1,9 @@
import 'package:dio/dio.dart';
import 'package:eatvio_app/features/feed/models/feed_blog_post_settings_model.dart';
import 'package:eatvio_app/features/feed/models/feed_blog_post_model.dart';
import 'package:eatvio_app/features/profile/models/circumference_model.dart';
import 'package:eatvio_app/features/profile/models/profile_model.dart';
import 'package:eatvio_app/features/profile/models/weight_model.dart';
import 'package:retrofit/retrofit.dart';
part 'profile_service.g.dart';
@RestApi()
@@ -35,7 +34,7 @@ abstract class ProfileService {
});
@GET('/api/blogPosts/search_by_author/{slug}')
Future<FeedBlogPostSettingsModel> getBlogPostByAuthorSlug({
Future<List<FeedBlogPostModel>> getBlogPostByAuthorSlug({
@Path() required String slug,
});

View File

@@ -6,7 +6,7 @@ part of 'profile_service.dart';
// RetrofitGenerator
// **************************************************************************
// ignore_for_file: unnecessary_brace_in_string_interps,no_leading_underscores_for_local_identifiers,unused_element
// ignore_for_file: unnecessary_brace_in_string_interps,no_leading_underscores_for_local_identifiers,unused_element,unnecessary_string_interpolations
class _ProfileService implements ProfileService {
_ProfileService(
@@ -191,13 +191,13 @@ class _ProfileService implements ProfileService {
}
@override
Future<FeedBlogPostSettingsModel> getBlogPostByAuthorSlug(
Future<List<FeedBlogPostModel>> getBlogPostByAuthorSlug(
{required String slug}) async {
final _extra = <String, dynamic>{};
final queryParameters = <String, dynamic>{};
final _headers = <String, dynamic>{};
const Map<String, dynamic>? _data = null;
final _options = _setStreamType<FeedBlogPostSettingsModel>(Options(
final _options = _setStreamType<List<FeedBlogPostModel>>(Options(
method: 'GET',
headers: _headers,
extra: _extra,
@@ -213,10 +213,13 @@ class _ProfileService implements ProfileService {
_dio.options.baseUrl,
baseUrl,
)));
final _result = await _dio.fetch<Map<String, dynamic>>(_options);
late FeedBlogPostSettingsModel _value;
final _result = await _dio.fetch<List<dynamic>>(_options);
late List<FeedBlogPostModel> _value;
try {
_value = FeedBlogPostSettingsModel.fromJson(_result.data!);
_value = _result.data!
.map((dynamic i) =>
FeedBlogPostModel.fromJson(i as Map<String, dynamic>))
.toList();
} on Object catch (e, s) {
errorLogger?.logError(e, s, _options);
rethrow;

View File

@@ -3,7 +3,7 @@ import 'package:eatvio_app/features/recipes/models/ingredient.dart';
import 'package:eatvio_app/features/recipes/models/recipe_model.dart';
import 'package:eatvio_app/features/recipes/presentation/bloc/recipe_create_state.dart';
import 'package:eatvio_app/features/recipes/reporitories/recipe_repository.dart';
import 'package:eatvio_app/features/diary/models/product.dart';
import 'package:eatvio_app/features/recipes/models/product.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:image_picker/image_picker.dart';
@@ -258,7 +258,7 @@ class RecipeCreateCubit extends Cubit<RecipeCreateState> {
var currentState = state as RecipeCreateStateLoaded;
final Map<String, List<Product>> productNutritionalValues = await recipeRepository.inputProduct(input);
print(productNutritionalValues);
var updatedState = currentState.copyWith(
productNameController: TextEditingController(text: input),
autocompleteList: productNutritionalValues['product_nutritional_value'] ?? [],

View File

@@ -1,6 +1,6 @@
import 'package:eatvio_app/features/recipes/models/recipe_model.dart';
import 'package:eatvio_app/features/recipes/models/ingredient.dart';
import 'package:eatvio_app/features/diary/models/product.dart';
import 'package:eatvio_app/features/recipes/models/product.dart';
import 'package:flutter/material.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:image_picker/image_picker.dart';

View File

@@ -1,7 +1,5 @@
import 'dart:convert';
import 'dart:io';
import 'package:eatvio_app/features/diary/models/product.dart';
import 'package:eatvio_app/features/recipes/models/product.dart';
import 'package:eatvio_app/features/recipes/models/ingredient.dart';
import 'package:eatvio_app/features/recipes/models/recipe_model.dart';
import 'package:eatvio_app/features/recipes/models/step.dart' as step;
@@ -512,7 +510,7 @@ class RecipeCreateScreen extends StatelessWidget {
image: state.recipeImage?.path,
video_url: state.youtubeLinkController.text.isNotEmpty ? state.youtubeLinkController.text : null,
);
print(jsonDecode(jsonEncode(recipe)));
return recipe;
}
}

View File

@@ -1,5 +1,5 @@
import 'package:eatvio_app/core/const.dart';
import 'package:eatvio_app/features/diary/models/product.dart';
import 'package:eatvio_app/features/recipes/models/product.dart';
import 'package:eatvio_app/features/recipes/models/ingredient.dart';
import 'package:eatvio_app/features/recipes/models/recipe_model.dart';
import 'package:eatvio_app/features/recipes/models/step.dart' as step;
@@ -354,7 +354,6 @@ class RecipeEditScreen extends StatelessWidget {
}
_buildStep(BuildContext context, int stepNumber, RecipeCreateStateLoaded state) {
print(baseUrl + '/storage/' + state.stepImages[stepNumber]!.path);
return Column(
children: [
Row(children: [Text('Шаг ${stepNumber + 1}'), Spacer(), Text('Всего шагов: ${state.numberOfSteps}')]),

View File

@@ -4,7 +4,7 @@ import 'dart:io';
import 'package:eatvio_app/features/recipes/models/recipe_model.dart';
import 'package:eatvio_app/features/recipes/models/recipe_tag_model.dart';
import 'package:eatvio_app/features/recipes/services/recipe_service.dart';
import 'package:eatvio_app/features/diary/models/product.dart';
import 'package:eatvio_app/features/recipes/models/product.dart';
class RecipeRepository {
final RecipeService recipeService;
@@ -39,8 +39,7 @@ class RecipeRepository {
};
}).toList() ??
[];
print(ingredientsMap);
print(stepsMap);
return await recipeService.publishRecipe(
recipe.type,
recipe.state,

View File

@@ -5,7 +5,7 @@ import 'package:dio/dio.dart';
import 'package:eatvio_app/features/recipes/models/recipe_model.dart';
import 'package:eatvio_app/features/recipes/models/recipe_tag_model.dart';
import 'package:retrofit/retrofit.dart';
import 'package:eatvio_app/features/diary/models/product.dart';
import 'package:eatvio_app/features/recipes/models/product.dart';
part 'recipe_service.g.dart';

View File

@@ -6,7 +6,7 @@ part of 'recipe_service.dart';
// RetrofitGenerator
// **************************************************************************
// ignore_for_file: unnecessary_brace_in_string_interps,no_leading_underscores_for_local_identifiers,unused_element
// ignore_for_file: unnecessary_brace_in_string_interps,no_leading_underscores_for_local_identifiers,unused_element,unnecessary_string_interpolations
class _RecipeService implements RecipeService {
_RecipeService(

View File

@@ -2,6 +2,7 @@ import 'package:eatvio_app/features/registration/models/user_registration_model.
import 'package:eatvio_app/features/registration/presentation/bloc/registration_cubit/registration_cubit.dart';
import 'package:eatvio_app/widgets/custom_text_form_field.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
class AdditionalInformationScreen extends StatefulWidget {
@@ -43,6 +44,9 @@ class _AdditionalInformationScreenState extends State<AdditionalInformationScree
hintText: "У меня крепкое здоровье, но последнее время часто утомляюсь, однако, это мне не мешает радоваться жизни",
textInputAction: TextInputAction.done,
maxLines: 8,
inputFormatters: [
new LengthLimitingTextInputFormatter(250),
],
focusNode: editFocusNode,
autofocus: true,
onChanged: (newValue) {

View File

@@ -6,7 +6,7 @@ part of 'registration_service.dart';
// RetrofitGenerator
// **************************************************************************
// ignore_for_file: unnecessary_brace_in_string_interps,no_leading_underscores_for_local_identifiers,unused_element
// ignore_for_file: unnecessary_brace_in_string_interps,no_leading_underscores_for_local_identifiers,unused_element,unnecessary_string_interpolations
class _RegistrationService implements RegistrationService {
_RegistrationService(

View File

@@ -34,7 +34,6 @@ class SettingsCubit extends Cubit<SettingsState> {
profileDetailsModel: profileDetailsModel,
);
} catch (e) {
print(e);
rethrow;
} finally {
await init();
@@ -49,7 +48,6 @@ class SettingsCubit extends Cubit<SettingsState> {
profileSettingsModel: profileSettingsModel,
);
} catch (e) {
print(e);
rethrow;
} finally {
await init();

View File

@@ -4,6 +4,7 @@ import 'package:eatvio_app/generated/l10n.dart';
import 'package:eatvio_app/theme/theme_helper.dart';
import 'package:eatvio_app/widgets/custom_text_form_field.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:go_router/go_router.dart';
class OtherInfoScreen extends StatefulWidget {
@@ -113,6 +114,9 @@ class _OtherInfoScreenState extends State<OtherInfoScreen> {
SizedBox(height: 4),
CustomTextFormField(
controller: additionalInfoController,
inputFormatters: [
new LengthLimitingTextInputFormatter(250),
],
hintText: "У меня крепкое здоровье, но последнее время часто утомляюсь, однако, это мне не мешает радоваться жизни",
maxLines: 8,
onChanged: (newValue) {},

View File

@@ -6,7 +6,7 @@ part of 'settings_service.dart';
// RetrofitGenerator
// **************************************************************************
// ignore_for_file: unnecessary_brace_in_string_interps,no_leading_underscores_for_local_identifiers,unused_element
// ignore_for_file: unnecessary_brace_in_string_interps,no_leading_underscores_for_local_identifiers,unused_element,unnecessary_string_interpolations
class _SettingsService implements SettingsService {
_SettingsService(

View File

@@ -14,7 +14,7 @@ import 'package:eatvio_app/features/chat/services/chat_service.dart';
import 'package:eatvio_app/features/consultant/become_consultant/presentation/bloc/register_consultant_cubit/register_consultant_cubit.dart';
import 'package:eatvio_app/features/consultant/become_consultant/repositories/consultant_repository.dart';
import 'package:eatvio_app/features/consultant/become_consultant/services/consultant_service.dart';
import 'package:eatvio_app/features/diary/presentation/bloc/diary_bloc.dart';
import 'package:eatvio_app/features/diary/presentation/bloc/diary_cubit.dart';
import 'package:eatvio_app/features/diary/repositories/diary_repository.dart';
import 'package:eatvio_app/features/diary/services/diary_service.dart';
import 'package:eatvio_app/features/feed/presentation/bloc/comments_cubit/comments_cubit.dart';
@@ -23,6 +23,8 @@ import 'package:eatvio_app/features/feed/presentation/bloc/feed_cubit/feed_cubit
import 'package:eatvio_app/features/feed/presentation/bloc/recipes_cubit/recipes_cubit.dart';
import 'package:eatvio_app/features/feed/repositories/feed_repository.dart';
import 'package:eatvio_app/features/feed/services/feed_service.dart';
import 'package:eatvio_app/features/glossary/repositories/glossary_repository.dart';
import 'package:eatvio_app/features/glossary/services/glossary_service.dart';
import 'package:eatvio_app/features/plans/presentation/bloc/plans_cubit/plans_cubit.dart';
import 'package:eatvio_app/features/plans/repositories/plans_repository.dart';
import 'package:eatvio_app/features/plans/services/plans_service.dart';
@@ -53,9 +55,8 @@ Future<void> init() async {
sl.registerFactory<ChatRoomCubit>(() => ChatRoomCubit(chatRepository: sl(), initializationCubit: sl()));
sl.registerFactory<FeedCubit>(() => FeedCubit(feedRepository: sl()));
sl.registerFactory<RecipesCubit>(() => RecipesCubit(feedRepository: sl(), recipeRepository: sl()));
sl.registerFactory<DiaryBloc>(() => DiaryBloc(diaryRepository: sl()));
sl.registerFactory<CalendarCubit>(() => CalendarCubit(calendarRepository: sl()));
sl.registerFactory<ProfileCubit>(() => ProfileCubit(profileRepository: sl()));
sl.registerFactory<ProfileCubit>(() => ProfileCubit(profileRepository: sl(), chatRepository: sl()));
sl.registerFactory<ProfileAvatarCubit>(() => ProfileAvatarCubit(profileRepository: sl()));
sl.registerFactory<RecipeCreateCubit>(() => RecipeCreateCubit(recipeRepository: sl()));
sl.registerFactory<DietsCubit>(() => DietsCubit(feedRepository: sl()));
@@ -64,30 +65,33 @@ Future<void> init() async {
sl.registerFactory<PlansCubit>(() => PlansCubit(plansRepository: sl()));
sl.registerFactory<SettingsCubit>(() => SettingsCubit(profileRepository: sl(), settingsRepository: sl()));
sl.registerFactory<RegisterConsultantCubit>(() => RegisterConsultantCubit(consultantRepository: sl()));
sl.registerFactory<DiaryCubit>(() => DiaryCubit(diaryRepository: sl(), glossaryRepository: sl()));
// Repository
sl.registerLazySingleton<ChatRepository>(() => ChatRepository(chatService: sl()));
sl.registerLazySingleton<FeedRepository>(() => FeedRepository(feedService: sl()));
sl.registerLazySingleton<RegistrationRepository>(() => RegistrationRepository(registrationService: sl()));
sl.registerLazySingleton<DiaryRepository>(() => DiaryRepository(diaryService: sl()));
sl.registerLazySingleton<CalendarRepository>(() => CalendarRepository(calendarService: sl()));
sl.registerLazySingleton<ProfileRepository>(() => ProfileRepository(profileService: sl()));
sl.registerLazySingleton<RecipeRepository>(() => RecipeRepository(recipeService: sl()));
sl.registerLazySingleton<PlansRepository>(() => PlansRepository(plansService: sl()));
sl.registerLazySingleton<SettingsRepository>(() => SettingsRepository(settingsService: sl()));
sl.registerLazySingleton<ConsultantRepository>(() => ConsultantRepository(consultantService: sl()));
sl.registerLazySingleton<DiaryRepository>(() => DiaryRepository(diaryService: sl()));
sl.registerLazySingleton<GlossaryRepository>(() => GlossaryRepository(glossaryService: sl()));
// Services
sl.registerLazySingleton<ChatService>(() => ChatService(sl()));
sl.registerLazySingleton<FeedService>(() => FeedService(sl()));
sl.registerLazySingleton<RegistrationService>(() => RegistrationService(sl()));
sl.registerLazySingleton<DiaryService>(() => DiaryService(sl()));
sl.registerLazySingleton<CalendarService>(() => CalendarService(sl()));
sl.registerLazySingleton<ProfileService>(() => ProfileService(sl()));
sl.registerLazySingleton<RecipeService>(() => RecipeService(sl()));
sl.registerLazySingleton<PlansService>(() => PlansService(sl()));
sl.registerLazySingleton<SettingsService>(() => SettingsService(sl()));
sl.registerLazySingleton<ConsultantService>(() => ConsultantService(sl()));
sl.registerLazySingleton<DiaryService>(() => DiaryService(sl()));
sl.registerLazySingleton<GlossaryService>(() => GlossaryService(sl()));
// External
sl.registerLazySingleton(

View File

@@ -54,7 +54,7 @@ class _AuthScreenState extends State<AuthScreen> {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(s.email),
SizedBox(height: 4),
const SizedBox(height: 4),
BlocSelector<AuthBloc, AuthState, TextEditingController?>(
selector: (state) => state.emailController,
builder: (context, emailController) {
@@ -67,9 +67,9 @@ class _AuthScreenState extends State<AuthScreen> {
);
},
),
SizedBox(height: 16),
const SizedBox(height: 16),
Text(s.password),
SizedBox(height: 4),
const SizedBox(height: 4),
BlocSelector<AuthBloc, AuthState, TextEditingController?>(
selector: (state) => state.passwordController,
builder: (context, passwordController) {
@@ -91,7 +91,7 @@ class _AuthScreenState extends State<AuthScreen> {
);
},
),
SizedBox(height: 16),
const SizedBox(height: 16),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
@@ -135,7 +135,7 @@ class _AuthScreenState extends State<AuthScreen> {
),
],
),
SizedBox(height: 16),
const SizedBox(height: 16),
BlocBuilder<AuthBloc, AuthState>(
builder: (context, state) {
return Container(
@@ -181,7 +181,7 @@ class _AuthScreenState extends State<AuthScreen> {
body: json.encode(credentials),
encoding: utf8,
);
print(response.statusCode);
if (response.statusCode == 200) {
var res = await jsonDecode(response.body);
final token = res['token'];

File diff suppressed because it is too large Load Diff

View File

@@ -61,10 +61,6 @@ class DietCreateBloc extends Bloc<DietCreateEvent, DietCreateState> {
if (response.statusCode == 200) {
AppRouter.navigatorKey.currentContext?.goNamed('dietSelectScreen');
} else {
print(
'Failed to create blog post. Status Code: ${response.statusCode} ${response.body}',
);
}
}
}

View File

@@ -47,7 +47,7 @@ class DietCreateScreen extends StatelessWidget {
decoration: AppDecoration.fillGray,
child: ListView(
children: [
SizedBox(height: 30),
const SizedBox(height: 30),
Container(
margin: EdgeInsets.only(
left: 16,
@@ -70,17 +70,17 @@ class DietCreateScreen extends StatelessWidget {
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
SizedBox(height: 16.0),
const SizedBox(height: 16.0),
TextFormField(
controller: state.name,
decoration: InputDecoration(labelText: 'Заголовок'),
),
SizedBox(height: 16.0),
const SizedBox(height: 16.0),
TextFormField(
controller: state.details,
decoration: InputDecoration(labelText: 'Описание'),
),
SizedBox(height: 16.0),
const SizedBox(height: 16.0),
// Здесь нужно добавить виджет для загрузки картинки
ElevatedButton(
onPressed: () => context.read<DietCreateBloc>().add(CreateDiet()),

View File

@@ -78,7 +78,7 @@ class DietEditBloc extends Bloc<DietEditEvent, DietEditState> {
if (state is DietEditLoadedState) {
var currentState = state as DietEditLoadedState;
int duration = int.parse(currentState.duration!.text) * 7;
print(duration);
var response = await sendDiet(currentState.diet, currentState.name?.text, currentState.details?.text, duration.toString());
if (response.statusCode == 200) {
@@ -86,9 +86,7 @@ class DietEditBloc extends Bloc<DietEditEvent, DietEditState> {
'dietScreen',
extra: currentState.diet?['id'].toString(),
);
} else {
print('Failed to edit blog post. Status Code: ${response.statusCode} ${response.body}');
}
} else {}
}
}

View File

@@ -36,14 +36,11 @@ class DietSelectBloc extends Bloc<DietSelectEvent, DietSelectState> {
'Authorization': 'Bearer ${await TokenStorage.getTokenFromStorage()}',
},
);
print('Got response');
if (response.statusCode == 200) {
print('Got 200');
final data = jsonDecode(response.body);
if (data is List<dynamic>) {
print('Got List');
if (state is DietSelectLoadedState) {
print('Got loaded');
var currentState = state as DietSelectLoadedState;
emit(
(currentState).copyWith(
@@ -52,7 +49,6 @@ class DietSelectBloc extends Bloc<DietSelectEvent, DietSelectState> {
),
);
} else {
print('Got unloaded');
emit(
DietSelectLoadedState(
posts: data,

View File

@@ -69,9 +69,7 @@ class BlogPostCreateBloc extends Bloc<BlogPostCreateEvent, BlogPostCreateState>
if (response.statusCode == 200 || response.statusCode == 201) {
AppRouter.navigatorKey.currentContext?.goNamed('feedScreen');
} else {
print('Failed to create blog post. Status Code: ${response.statusCode} ${response.data}');
}
} else {}
}
}

View File

@@ -11,7 +11,8 @@ import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:go_router/go_router.dart';
import 'package:http/http.dart' as http;
part 'blog_post_edit_event.dart';part 'blog_post_edit_state.dart';
part 'blog_post_edit_event.dart';
part 'blog_post_edit_state.dart';
/// A bloc that manages the state of a BlogPostEdit according to the event that is dispatched to it.
class BlogPostEditBloc extends Bloc<BlogPostEditEvent, BlogPostEditState> {
@@ -86,9 +87,7 @@ class BlogPostEditBloc extends Bloc<BlogPostEditEvent, BlogPostEditState> {
if (response.statusCode == 200) {
AppRouter.navigatorKey.currentContext?.goNamed('blogPostScreen', extra: currentState.blog_post?['id'].toString());
} else {
print('Failed to edit blog post. Status Code: ${response.statusCode} ${response.body}');
}
} else {}
}
}

View File

@@ -61,10 +61,6 @@ class PlanCreateBloc extends Bloc<PlanCreateEvent, PlanCreateState> {
if (response.statusCode == 200) {
AppRouter.navigatorKey.currentContext?.goNamed('planSelectScreen');
} else {
print(
'Failed to create blog post. Status Code: ${response.statusCode} ${response.body}',
);
}
}
}

View File

@@ -78,7 +78,7 @@ class PlanEditBloc extends Bloc<PlanEditEvent, PlanEditState> {
if (state is PlanEditLoadedState) {
var currentState = state as PlanEditLoadedState;
int duration = int.parse(currentState.duration!.text) * 7;
print(duration);
var response = await sendPlan(currentState.plan, currentState.name?.text, currentState.details?.text, duration.toString());
if (response.statusCode == 200) {
@@ -86,9 +86,7 @@ class PlanEditBloc extends Bloc<PlanEditEvent, PlanEditState> {
'planScreen',
extra: currentState.plan?['id'].toString(),
);
} else {
print('Failed to edit blog post. Status Code: ${response.statusCode} ${response.body}');
}
} else {}
}
}

View File

@@ -33,14 +33,11 @@ class PlanSelectBloc extends Bloc<PlanSelectEvent, PlanSelectState> {
final response = await http.get(
Uri.parse(baseUrl + '/api/plans/index'),
);
print('Got response');
if (response.statusCode == 200) {
print('Got 200');
final data = jsonDecode(response.body);
if (data is List<dynamic>) {
print('Got List');
if (state is PlanSelectLoadedState) {
print('Got loaded');
var currentState = state as PlanSelectLoadedState;
emit(
(currentState).copyWith(
@@ -49,7 +46,6 @@ class PlanSelectBloc extends Bloc<PlanSelectEvent, PlanSelectState> {
),
);
} else {
print('Got unloaded');
emit(
PlanSelectLoadedState(
posts: data,

View File

@@ -26,7 +26,6 @@ class MyProfileBloc extends Bloc<MyProfileEvent, MyProfileState> {
MyProfileInitialEvent event,
Emitter<MyProfileState> emit,
) async {
print('1');
try {
if (!await TokenStorage.haveTokenInStorage()) {
AppRouter.navigatorKey.currentContext?.goNamed('authScreen');
@@ -37,7 +36,7 @@ class MyProfileBloc extends Bloc<MyProfileEvent, MyProfileState> {
'Authorization': 'Bearer ${await TokenStorage.getTokenFromStorage()}',
},
);
print('2');
if (response.statusCode == 200) {
final data = jsonDecode(response.body);
if (data is Map<String, dynamic> &&
@@ -101,10 +100,10 @@ class MyProfileBloc extends Bloc<MyProfileEvent, MyProfileState> {
..addAll(data["requestedPlan"])
..addAll(data["initedPlan"]);
/*print(data["chartPoints"].length);
print(data["chartPoints"].runtimeType);
print(data["circumferences"].length);
print(data["circumferences"].runtimeType);*/
/*
*/
if (data["chartPoints"].length == 1) {
data["chartPoints"] = [];
}
@@ -272,7 +271,7 @@ class MyProfileBloc extends Bloc<MyProfileEvent, MyProfileState> {
Future<String> uploadImageToServer(String imagePath, String? token) async {
String url = '${baseUrl}/api/profile/photo/upload';
print(url);
var request = http.MultipartRequest('POST', Uri.parse(url));
request.headers['Authorization'] = 'Bearer $token';
@@ -284,7 +283,7 @@ class MyProfileBloc extends Bloc<MyProfileEvent, MyProfileState> {
if (streamedResponse.statusCode == 200) {
var response = await http.Response.fromStream(streamedResponse);
var imageUrl = response.body;
print('Image successfully uploaded');
return imageUrl;
} else {
throw Exception(

View File

@@ -119,9 +119,7 @@ class RecipeEditBloc extends Bloc<RecipeEditEvent, RecipeEditState> {
'recipeScreen',
extra: currentState.recipe?['id'].toString(),
);
} else {
print('Failed to edit blog post. Status Code: ${response.statusCode} ${response.body}');
}
} else {}
}
}
@@ -204,7 +202,6 @@ class RecipeEditBloc extends Bloc<RecipeEditEvent, RecipeEditState> {
}
FutureOr<void> _reloadScreen(RecipeEditEvent? event, Emitter<RecipeEditState> emit) async {
print('Reloading..');
if (!await TokenStorage.haveTokenInStorage()) {
AppRouter.navigatorKey.currentContext?.goNamed('authScreen');
}

View File

@@ -445,8 +445,7 @@ class RecipeEditScreen extends StatelessWidget {
void _trimTags(newValue) {
List<String> newTagNames = newValue!.split(',').map((tag) => tag.trim()).toList();
List<Map<String, dynamic>> newTags = newTagNames.map((tagName) => {'name': tagName}).toList();
print(newTags);
newTagNames.map((tagName) => {'name': tagName}).toList();
}
Function onTapBack(BuildContext context) {

View File

@@ -30,14 +30,11 @@ class RecipeSelectBloc extends Bloc<RecipeSelectEvent, RecipeSelectState> {
AppRouter.navigatorKey.currentContext?.goNamed('authScreen');
}
final response = await sl<Dio>().get(baseUrl + '/api/recipes/index');
print('Got response');
if (response.statusCode == 200) {
print('Got 200');
final data = response.data['data'];
if (data is List<dynamic>) {
print('Got List');
if (state is RecipeSelectLoadedState) {
print('Got loaded');
var currentState = state as RecipeSelectLoadedState;
emit(
(currentState).copyWith(
@@ -46,7 +43,6 @@ class RecipeSelectBloc extends Bloc<RecipeSelectEvent, RecipeSelectState> {
),
);
} else {
print('Got unloaded');
emit(
RecipeSelectLoadedState(
posts: data,

Some files were not shown because too many files have changed in this diff Show More