forked from eatvio/eatvio_app
feat(diary): add diary page, calendar, meals
This commit is contained in:
@@ -1,4 +1,7 @@
|
||||
allprojects {
|
||||
tasks.withType(JavaCompile) {
|
||||
options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation"
|
||||
}
|
||||
repositories {
|
||||
google()
|
||||
mavenCentral()
|
||||
|
||||
@@ -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(),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
80
lib/features/diary/models/diary_day_model.dart
Normal file
80
lib/features/diary/models/diary_day_model.dart
Normal 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);
|
||||
}
|
||||
1504
lib/features/diary/models/diary_day_model.freezed.dart
Normal file
1504
lib/features/diary/models/diary_day_model.freezed.dart
Normal file
File diff suppressed because it is too large
Load Diff
122
lib/features/diary/models/diary_day_model.g.dart
Normal file
122
lib/features/diary/models/diary_day_model.g.dart
Normal 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,
|
||||
};
|
||||
14
lib/features/diary/models/diary_index_model.dart
Normal file
14
lib/features/diary/models/diary_index_model.dart
Normal 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);
|
||||
}
|
||||
166
lib/features/diary/models/diary_index_model.freezed.dart
Normal file
166
lib/features/diary/models/diary_index_model.freezed.dart
Normal 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;
|
||||
}
|
||||
@@ -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,
|
||||
};
|
||||
@@ -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);
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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(),
|
||||
};
|
||||
@@ -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);
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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,
|
||||
};
|
||||
@@ -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);
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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,
|
||||
};
|
||||
@@ -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);
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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,
|
||||
};
|
||||
@@ -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}');
|
||||
}
|
||||
}
|
||||
22
lib/features/diary/presentation/bloc/diary_cubit.dart
Normal file
22
lib/features/diary/presentation/bloc/diary_cubit.dart
Normal file
@@ -0,0 +1,22 @@
|
||||
import 'package:eatvio_app/features/diary/presentation/bloc/diary_state.dart';
|
||||
import 'package:eatvio_app/features/diary/repositories/diary_repository.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
|
||||
class DiaryCubit extends Cubit<DiaryState> {
|
||||
final DiaryRepository diaryRepository;
|
||||
|
||||
DiaryCubit({
|
||||
required this.diaryRepository,
|
||||
}) : super(const DiaryState.loading());
|
||||
|
||||
getDiaryDay(String date) async {
|
||||
print(date);
|
||||
emit(const DiaryState.loading());
|
||||
try {
|
||||
emit(DiaryState.loaded(diary: await diaryRepository.getDiaryByDate(date)));
|
||||
} catch (e) {
|
||||
emit(DiaryState.error(errorMessage: e.toString()));
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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];
|
||||
}
|
||||
@@ -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
@@ -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
@@ -1,200 +1,21 @@
|
||||
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 {
|
||||
print(await _getDiaryIndexByDate(date));
|
||||
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<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<int> _getDiaryIndexByDate(String date) async {
|
||||
return (await diaryService.getDiaryIndexByDate(date: date)).id;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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,13 @@ 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,
|
||||
);
|
||||
|
||||
@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,
|
||||
);
|
||||
@GET('/api/diary/{diary_id}/show')
|
||||
Future<DiaryDayWrapperModel> getDiaryDay({
|
||||
@Path('diary_id') required int index,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
@@ -88,428 +87,6 @@ class _DiaryService implements DiaryService {
|
||||
return _value;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<dynamic> getChart(int id) async {
|
||||
final _extra = <String, dynamic>{};
|
||||
final queryParameters = <String, dynamic>{};
|
||||
final _headers = <String, dynamic>{};
|
||||
const Map<String, dynamic>? _data = null;
|
||||
final _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 {
|
||||
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,
|
||||
),
|
||||
));
|
||||
final _options = _setStreamType<void>(Options(
|
||||
method: 'POST',
|
||||
headers: _headers,
|
||||
extra: _extra,
|
||||
)
|
||||
.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',
|
||||
queryParameters: queryParameters,
|
||||
data: _data,
|
||||
)
|
||||
.copyWith(
|
||||
baseUrl: _combineBaseUrls(
|
||||
_dio.options.baseUrl,
|
||||
baseUrl,
|
||||
)));
|
||||
await _dio.fetch<void>(_options);
|
||||
}
|
||||
|
||||
RequestOptions _setStreamType<T>(RequestOptions requestOptions) {
|
||||
if (T != dynamic &&
|
||||
!(requestOptions.responseType == ResponseType.bytes ||
|
||||
|
||||
@@ -12,7 +12,6 @@ class BadgeModel with _$BadgeModel {
|
||||
required String description,
|
||||
required String image,
|
||||
required String type,
|
||||
required List<String> parameters,
|
||||
}) = _BadgeModel;
|
||||
|
||||
factory BadgeModel.fromJson(Map<String, Object?> json) => _$BadgeModelFromJson(json);
|
||||
|
||||
@@ -25,7 +25,6 @@ mixin _$BadgeModel {
|
||||
String get description => throw _privateConstructorUsedError;
|
||||
String get image => throw _privateConstructorUsedError;
|
||||
String get type => throw _privateConstructorUsedError;
|
||||
List<String> get parameters => throw _privateConstructorUsedError;
|
||||
|
||||
/// Serializes this BadgeModel to a JSON map.
|
||||
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
|
||||
@@ -44,12 +43,7 @@ abstract class $BadgeModelCopyWith<$Res> {
|
||||
_$BadgeModelCopyWithImpl<$Res, BadgeModel>;
|
||||
@useResult
|
||||
$Res call(
|
||||
{int id,
|
||||
String title,
|
||||
String description,
|
||||
String image,
|
||||
String type,
|
||||
List<String> parameters});
|
||||
{int id, String title, String description, String image, String type});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@@ -72,7 +66,6 @@ class _$BadgeModelCopyWithImpl<$Res, $Val extends BadgeModel>
|
||||
Object? description = null,
|
||||
Object? image = null,
|
||||
Object? type = null,
|
||||
Object? parameters = null,
|
||||
}) {
|
||||
return _then(_value.copyWith(
|
||||
id: null == id
|
||||
@@ -95,10 +88,6 @@ class _$BadgeModelCopyWithImpl<$Res, $Val extends BadgeModel>
|
||||
? _value.type
|
||||
: type // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
parameters: null == parameters
|
||||
? _value.parameters
|
||||
: parameters // ignore: cast_nullable_to_non_nullable
|
||||
as List<String>,
|
||||
) as $Val);
|
||||
}
|
||||
}
|
||||
@@ -112,12 +101,7 @@ abstract class _$$BadgeModelImplCopyWith<$Res>
|
||||
@override
|
||||
@useResult
|
||||
$Res call(
|
||||
{int id,
|
||||
String title,
|
||||
String description,
|
||||
String image,
|
||||
String type,
|
||||
List<String> parameters});
|
||||
{int id, String title, String description, String image, String type});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@@ -138,7 +122,6 @@ class __$$BadgeModelImplCopyWithImpl<$Res>
|
||||
Object? description = null,
|
||||
Object? image = null,
|
||||
Object? type = null,
|
||||
Object? parameters = null,
|
||||
}) {
|
||||
return _then(_$BadgeModelImpl(
|
||||
id: null == id
|
||||
@@ -161,10 +144,6 @@ class __$$BadgeModelImplCopyWithImpl<$Res>
|
||||
? _value.type
|
||||
: type // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
parameters: null == parameters
|
||||
? _value._parameters
|
||||
: parameters // ignore: cast_nullable_to_non_nullable
|
||||
as List<String>,
|
||||
));
|
||||
}
|
||||
}
|
||||
@@ -177,9 +156,7 @@ class _$BadgeModelImpl implements _BadgeModel {
|
||||
required this.title,
|
||||
required this.description,
|
||||
required this.image,
|
||||
required this.type,
|
||||
required final List<String> parameters})
|
||||
: _parameters = parameters;
|
||||
required this.type});
|
||||
|
||||
factory _$BadgeModelImpl.fromJson(Map<String, dynamic> json) =>
|
||||
_$$BadgeModelImplFromJson(json);
|
||||
@@ -194,17 +171,10 @@ class _$BadgeModelImpl implements _BadgeModel {
|
||||
final String image;
|
||||
@override
|
||||
final String type;
|
||||
final List<String> _parameters;
|
||||
@override
|
||||
List<String> get parameters {
|
||||
if (_parameters is EqualUnmodifiableListView) return _parameters;
|
||||
// ignore: implicit_dynamic_type
|
||||
return EqualUnmodifiableListView(_parameters);
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'BadgeModel(id: $id, title: $title, description: $description, image: $image, type: $type, parameters: $parameters)';
|
||||
return 'BadgeModel(id: $id, title: $title, description: $description, image: $image, type: $type)';
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -217,15 +187,13 @@ class _$BadgeModelImpl implements _BadgeModel {
|
||||
(identical(other.description, description) ||
|
||||
other.description == description) &&
|
||||
(identical(other.image, image) || other.image == image) &&
|
||||
(identical(other.type, type) || other.type == type) &&
|
||||
const DeepCollectionEquality()
|
||||
.equals(other._parameters, _parameters));
|
||||
(identical(other.type, type) || other.type == type));
|
||||
}
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType, id, title, description, image,
|
||||
type, const DeepCollectionEquality().hash(_parameters));
|
||||
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.
|
||||
@@ -249,8 +217,7 @@ abstract class _BadgeModel implements BadgeModel {
|
||||
required final String title,
|
||||
required final String description,
|
||||
required final String image,
|
||||
required final String type,
|
||||
required final List<String> parameters}) = _$BadgeModelImpl;
|
||||
required final String type}) = _$BadgeModelImpl;
|
||||
|
||||
factory _BadgeModel.fromJson(Map<String, dynamic> json) =
|
||||
_$BadgeModelImpl.fromJson;
|
||||
@@ -265,8 +232,6 @@ abstract class _BadgeModel implements BadgeModel {
|
||||
String get image;
|
||||
@override
|
||||
String get type;
|
||||
@override
|
||||
List<String> get parameters;
|
||||
|
||||
/// Create a copy of BadgeModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
|
||||
@@ -13,9 +13,6 @@ _$BadgeModelImpl _$$BadgeModelImplFromJson(Map<String, dynamic> json) =>
|
||||
description: json['description'] as String,
|
||||
image: json['image'] as String,
|
||||
type: json['type'] as String,
|
||||
parameters: (json['parameters'] as List<dynamic>)
|
||||
.map((e) => e as String)
|
||||
.toList(),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$$BadgeModelImplToJson(_$BadgeModelImpl instance) =>
|
||||
@@ -25,5 +22,4 @@ Map<String, dynamic> _$$BadgeModelImplToJson(_$BadgeModelImpl instance) =>
|
||||
'description': instance.description,
|
||||
'image': instance.image,
|
||||
'type': instance.type,
|
||||
'parameters': instance.parameters,
|
||||
};
|
||||
|
||||
@@ -483,11 +483,15 @@ class _ProfileScreenState extends State<ProfileScreen> {
|
||||
child: Row(
|
||||
children: [
|
||||
for (int i = 0; i < state.profile.badges.length; i++) ...[
|
||||
SvgPicture.network(
|
||||
baseUrl + '/storage/' + state.profile.badges[i].image,
|
||||
width: 40,
|
||||
height: 40,
|
||||
),
|
||||
state.profile.badges[i].image.contains('svg')
|
||||
? SvgPicture.network(
|
||||
baseUrl + '/storage/' + state.profile.badges[i].image,
|
||||
width: 40,
|
||||
height: 40,
|
||||
)
|
||||
: CachedNetworkImage(
|
||||
imageUrl: baseUrl + '/storage/' + state.profile.badges[i].image,
|
||||
),
|
||||
i < state.profile.badges.length - 1 ? const SizedBox(width: 8) : const SizedBox.shrink(),
|
||||
],
|
||||
],
|
||||
@@ -634,11 +638,15 @@ class _ProfileScreenState extends State<ProfileScreen> {
|
||||
}
|
||||
|
||||
_additionalInfo(ProfileStateLoaded state) {
|
||||
String text = state.profileDetails.additionalInfo;
|
||||
if (state.profileDetails.additionalInfo.length > 250) {
|
||||
text = state.profileDetails.additionalInfo.substring(0, 250);
|
||||
}
|
||||
return Container(
|
||||
alignment: Alignment.centerLeft,
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Text(
|
||||
state.profileDetails.additionalInfo,
|
||||
text,
|
||||
style: TextStyle(
|
||||
color: Colors.black.withOpacity(0.4),
|
||||
height: 1,
|
||||
|
||||
@@ -65,8 +65,7 @@ class ProfileRepository {
|
||||
try {
|
||||
return (await profileService.getBlogPostByAuthorSlug(
|
||||
slug: slug,
|
||||
))
|
||||
.feedBlogPostList;
|
||||
));
|
||||
} catch (e) {
|
||||
rethrow;
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
});
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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';
|
||||
|
||||
@@ -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';
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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';
|
||||
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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) {},
|
||||
|
||||
@@ -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';
|
||||
@@ -53,7 +53,6 @@ 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(), chatRepository: sl()));
|
||||
sl.registerFactory<ProfileAvatarCubit>(() => ProfileAvatarCubit(profileRepository: sl()));
|
||||
@@ -64,30 +63,31 @@ 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()));
|
||||
|
||||
// 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()));
|
||||
|
||||
// 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()));
|
||||
|
||||
// External
|
||||
sl.registerLazySingleton(
|
||||
|
||||
20
pubspec.yaml
20
pubspec.yaml
@@ -23,31 +23,31 @@ dependencies:
|
||||
validators: ^3.0.0
|
||||
path_provider: ^2.1.4
|
||||
carousel_slider_plus: ^7.0.1
|
||||
flutter_form_builder: ^9.4.1
|
||||
flutter_form_builder: ^9.5.0
|
||||
image_picker: ^1.1.2
|
||||
flutter_typeahead: ^5.2.0
|
||||
go_router: ^14.2.9
|
||||
go_router: ^14.3.0
|
||||
keyboard_dismisser: ^3.0.0
|
||||
retrofit: ^4.4.1
|
||||
get_it: ^8.0.0
|
||||
get_it: ^8.0.1
|
||||
dio: ^5.7.0
|
||||
dart_pusher_channels: ^1.2.3
|
||||
photo_view: ^0.15.0
|
||||
dismissible_page: ^1.0.2
|
||||
url_launcher: ^6.3.0
|
||||
url_launcher: ^6.3.1
|
||||
easy_debounce: ^2.0.3
|
||||
badges: ^3.1.2
|
||||
google_fonts: ^6.2.1
|
||||
location: ^6.0.2
|
||||
syncfusion_flutter_charts: ^27.1.51
|
||||
location: ^7.0.1
|
||||
syncfusion_flutter_charts: ^27.1.55
|
||||
table_calendar: ^3.1.2
|
||||
flutter_keyboard_visibility: ^6.0.0
|
||||
share_plus: ^10.0.2
|
||||
share_plus: ^10.1.0
|
||||
flutter_html: ^3.0.0-beta.2
|
||||
file_picker: ^8.1.2
|
||||
file_picker: ^8.1.3
|
||||
audioplayers: ^6.1.0
|
||||
intl: ^0.19.0
|
||||
rive: ^0.13.14
|
||||
rive: ^0.13.15
|
||||
mask_text_input_formatter: ^2.9.0
|
||||
lottie: ^3.1.3
|
||||
|
||||
@@ -55,7 +55,7 @@ dev_dependencies:
|
||||
build_runner: ^2.4.13
|
||||
freezed: ^2.5.7
|
||||
json_serializable: ^6.8.0
|
||||
retrofit_generator: ^9.1.2
|
||||
retrofit_generator: ^9.1.3
|
||||
|
||||
flutter_test:
|
||||
sdk: flutter
|
||||
|
||||
Reference in New Issue
Block a user