feat(diary): add gallery

This commit is contained in:
mso7nueh
2024-11-01 05:24:08 +03:00
parent b0c687e5fe
commit 972ee605be
10 changed files with 555 additions and 299 deletions

View File

@@ -47,10 +47,10 @@ class MealModel with _$MealModel {
@freezed
class DiaryPhotoModel with _$DiaryPhotoModel {
const factory DiaryPhotoModel({
@JsonKey(name: "id") required String id,
@JsonKey(name: "id") required int id,
@JsonKey(name: "original_name") required String originalName,
@JsonKey(name: "path") required String path,
@JsonKey(name: "size") required String size,
@JsonKey(name: "size") required int size,
}) = _DiaryPhotoModel;
factory DiaryPhotoModel.fromJson(Map<String, dynamic> json) => _$DiaryPhotoModelFromJson(json);
@@ -78,3 +78,14 @@ class TypeOfDiaryModel with _$TypeOfDiaryModel {
factory TypeOfDiaryModel.fromJson(Map<String, dynamic> json) => _$TypeOfDiaryModelFromJson(json);
}
@freezed
class ProductInMeal with _$ProductInMeal {
const factory ProductInMeal({
@JsonKey(name: 'product_name') required String productName,
@JsonKey(name: 'portion') required String portion,
@JsonKey(name: 'quantity') required int quantity,
}) = _ProductInMeal;
factory ProductInMeal.fromJson(Map<String, Object?> json) => _$ProductInMealFromJson(json);
}

View File

@@ -850,13 +850,13 @@ DiaryPhotoModel _$DiaryPhotoModelFromJson(Map<String, dynamic> json) {
/// @nodoc
mixin _$DiaryPhotoModel {
@JsonKey(name: "id")
String get id => throw _privateConstructorUsedError;
int get id => throw _privateConstructorUsedError;
@JsonKey(name: "original_name")
String get originalName => throw _privateConstructorUsedError;
@JsonKey(name: "path")
String get path => throw _privateConstructorUsedError;
@JsonKey(name: "size")
String get size => throw _privateConstructorUsedError;
int get size => throw _privateConstructorUsedError;
/// Serializes this DiaryPhotoModel to a JSON map.
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
@@ -875,10 +875,10 @@ abstract class $DiaryPhotoModelCopyWith<$Res> {
_$DiaryPhotoModelCopyWithImpl<$Res, DiaryPhotoModel>;
@useResult
$Res call(
{@JsonKey(name: "id") String id,
{@JsonKey(name: "id") int id,
@JsonKey(name: "original_name") String originalName,
@JsonKey(name: "path") String path,
@JsonKey(name: "size") String size});
@JsonKey(name: "size") int size});
}
/// @nodoc
@@ -905,7 +905,7 @@ class _$DiaryPhotoModelCopyWithImpl<$Res, $Val extends DiaryPhotoModel>
id: null == id
? _value.id
: id // ignore: cast_nullable_to_non_nullable
as String,
as int,
originalName: null == originalName
? _value.originalName
: originalName // ignore: cast_nullable_to_non_nullable
@@ -917,7 +917,7 @@ class _$DiaryPhotoModelCopyWithImpl<$Res, $Val extends DiaryPhotoModel>
size: null == size
? _value.size
: size // ignore: cast_nullable_to_non_nullable
as String,
as int,
) as $Val);
}
}
@@ -931,10 +931,10 @@ abstract class _$$DiaryPhotoModelImplCopyWith<$Res>
@override
@useResult
$Res call(
{@JsonKey(name: "id") String id,
{@JsonKey(name: "id") int id,
@JsonKey(name: "original_name") String originalName,
@JsonKey(name: "path") String path,
@JsonKey(name: "size") String size});
@JsonKey(name: "size") int size});
}
/// @nodoc
@@ -959,7 +959,7 @@ class __$$DiaryPhotoModelImplCopyWithImpl<$Res>
id: null == id
? _value.id
: id // ignore: cast_nullable_to_non_nullable
as String,
as int,
originalName: null == originalName
? _value.originalName
: originalName // ignore: cast_nullable_to_non_nullable
@@ -971,7 +971,7 @@ class __$$DiaryPhotoModelImplCopyWithImpl<$Res>
size: null == size
? _value.size
: size // ignore: cast_nullable_to_non_nullable
as String,
as int,
));
}
}
@@ -990,7 +990,7 @@ class _$DiaryPhotoModelImpl implements _DiaryPhotoModel {
@override
@JsonKey(name: "id")
final String id;
final int id;
@override
@JsonKey(name: "original_name")
final String originalName;
@@ -999,7 +999,7 @@ class _$DiaryPhotoModelImpl implements _DiaryPhotoModel {
final String path;
@override
@JsonKey(name: "size")
final String size;
final int size;
@override
String toString() {
@@ -1041,18 +1041,17 @@ class _$DiaryPhotoModelImpl implements _DiaryPhotoModel {
abstract class _DiaryPhotoModel implements DiaryPhotoModel {
const factory _DiaryPhotoModel(
{@JsonKey(name: "id") required final String id,
@JsonKey(name: "original_name") required final String originalName,
@JsonKey(name: "path") required final String path,
@JsonKey(name: "size") required final String size}) =
_$DiaryPhotoModelImpl;
{@JsonKey(name: "id") required final int id,
@JsonKey(name: "original_name") required final String originalName,
@JsonKey(name: "path") required final String path,
@JsonKey(name: "size") required final int size}) = _$DiaryPhotoModelImpl;
factory _DiaryPhotoModel.fromJson(Map<String, dynamic> json) =
_$DiaryPhotoModelImpl.fromJson;
@override
@JsonKey(name: "id")
String get id;
int get id;
@override
@JsonKey(name: "original_name")
String get originalName;
@@ -1061,7 +1060,7 @@ abstract class _DiaryPhotoModel implements DiaryPhotoModel {
String get path;
@override
@JsonKey(name: "size")
String get size;
int get size;
/// Create a copy of DiaryPhotoModel
/// with the given fields replaced by the non-null parameter values.
@@ -1502,3 +1501,208 @@ abstract class _TypeOfDiaryModel implements TypeOfDiaryModel {
_$$TypeOfDiaryModelImplCopyWith<_$TypeOfDiaryModelImpl> get copyWith =>
throw _privateConstructorUsedError;
}
ProductInMeal _$ProductInMealFromJson(Map<String, dynamic> json) {
return _ProductInMeal.fromJson(json);
}
/// @nodoc
mixin _$ProductInMeal {
@JsonKey(name: 'product_name')
String get productName => throw _privateConstructorUsedError;
@JsonKey(name: 'portion')
String get portion => throw _privateConstructorUsedError;
@JsonKey(name: 'quantity')
int get quantity => throw _privateConstructorUsedError;
/// Serializes this ProductInMeal to a JSON map.
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
/// Create a copy of ProductInMeal
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
$ProductInMealCopyWith<ProductInMeal> get copyWith =>
throw _privateConstructorUsedError;
}
/// @nodoc
abstract class $ProductInMealCopyWith<$Res> {
factory $ProductInMealCopyWith(
ProductInMeal value, $Res Function(ProductInMeal) then) =
_$ProductInMealCopyWithImpl<$Res, ProductInMeal>;
@useResult
$Res call(
{@JsonKey(name: 'product_name') String productName,
@JsonKey(name: 'portion') String portion,
@JsonKey(name: 'quantity') int quantity});
}
/// @nodoc
class _$ProductInMealCopyWithImpl<$Res, $Val extends ProductInMeal>
implements $ProductInMealCopyWith<$Res> {
_$ProductInMealCopyWithImpl(this._value, this._then);
// ignore: unused_field
final $Val _value;
// ignore: unused_field
final $Res Function($Val) _then;
/// Create a copy of ProductInMeal
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? productName = null,
Object? portion = null,
Object? quantity = null,
}) {
return _then(_value.copyWith(
productName: null == productName
? _value.productName
: productName // ignore: cast_nullable_to_non_nullable
as String,
portion: null == portion
? _value.portion
: portion // ignore: cast_nullable_to_non_nullable
as String,
quantity: null == quantity
? _value.quantity
: quantity // ignore: cast_nullable_to_non_nullable
as int,
) as $Val);
}
}
/// @nodoc
abstract class _$$ProductInMealImplCopyWith<$Res>
implements $ProductInMealCopyWith<$Res> {
factory _$$ProductInMealImplCopyWith(
_$ProductInMealImpl value, $Res Function(_$ProductInMealImpl) then) =
__$$ProductInMealImplCopyWithImpl<$Res>;
@override
@useResult
$Res call(
{@JsonKey(name: 'product_name') String productName,
@JsonKey(name: 'portion') String portion,
@JsonKey(name: 'quantity') int quantity});
}
/// @nodoc
class __$$ProductInMealImplCopyWithImpl<$Res>
extends _$ProductInMealCopyWithImpl<$Res, _$ProductInMealImpl>
implements _$$ProductInMealImplCopyWith<$Res> {
__$$ProductInMealImplCopyWithImpl(
_$ProductInMealImpl _value, $Res Function(_$ProductInMealImpl) _then)
: super(_value, _then);
/// Create a copy of ProductInMeal
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? productName = null,
Object? portion = null,
Object? quantity = null,
}) {
return _then(_$ProductInMealImpl(
productName: null == productName
? _value.productName
: productName // ignore: cast_nullable_to_non_nullable
as String,
portion: null == portion
? _value.portion
: portion // ignore: cast_nullable_to_non_nullable
as String,
quantity: null == quantity
? _value.quantity
: quantity // ignore: cast_nullable_to_non_nullable
as int,
));
}
}
/// @nodoc
@JsonSerializable()
class _$ProductInMealImpl implements _ProductInMeal {
const _$ProductInMealImpl(
{@JsonKey(name: 'product_name') required this.productName,
@JsonKey(name: 'portion') required this.portion,
@JsonKey(name: 'quantity') required this.quantity});
factory _$ProductInMealImpl.fromJson(Map<String, dynamic> json) =>
_$$ProductInMealImplFromJson(json);
@override
@JsonKey(name: 'product_name')
final String productName;
@override
@JsonKey(name: 'portion')
final String portion;
@override
@JsonKey(name: 'quantity')
final int quantity;
@override
String toString() {
return 'ProductInMeal(productName: $productName, portion: $portion, quantity: $quantity)';
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$ProductInMealImpl &&
(identical(other.productName, productName) ||
other.productName == productName) &&
(identical(other.portion, portion) || other.portion == portion) &&
(identical(other.quantity, quantity) ||
other.quantity == quantity));
}
@JsonKey(includeFromJson: false, includeToJson: false)
@override
int get hashCode => Object.hash(runtimeType, productName, portion, quantity);
/// Create a copy of ProductInMeal
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@override
@pragma('vm:prefer-inline')
_$$ProductInMealImplCopyWith<_$ProductInMealImpl> get copyWith =>
__$$ProductInMealImplCopyWithImpl<_$ProductInMealImpl>(this, _$identity);
@override
Map<String, dynamic> toJson() {
return _$$ProductInMealImplToJson(
this,
);
}
}
abstract class _ProductInMeal implements ProductInMeal {
const factory _ProductInMeal(
{@JsonKey(name: 'product_name') required final String productName,
@JsonKey(name: 'portion') required final String portion,
@JsonKey(name: 'quantity') required final int quantity}) =
_$ProductInMealImpl;
factory _ProductInMeal.fromJson(Map<String, dynamic> json) =
_$ProductInMealImpl.fromJson;
@override
@JsonKey(name: 'product_name')
String get productName;
@override
@JsonKey(name: 'portion')
String get portion;
@override
@JsonKey(name: 'quantity')
int get quantity;
/// Create a copy of ProductInMeal
/// with the given fields replaced by the non-null parameter values.
@override
@JsonKey(includeFromJson: false, includeToJson: false)
_$$ProductInMealImplCopyWith<_$ProductInMealImpl> get copyWith =>
throw _privateConstructorUsedError;
}

View File

@@ -74,10 +74,10 @@ Map<String, dynamic> _$$MealModelImplToJson(_$MealModelImpl instance) =>
_$DiaryPhotoModelImpl _$$DiaryPhotoModelImplFromJson(
Map<String, dynamic> json) =>
_$DiaryPhotoModelImpl(
id: json['id'] as String,
id: (json['id'] as num).toInt(),
originalName: json['original_name'] as String,
path: json['path'] as String,
size: json['size'] as String,
size: (json['size'] as num).toInt(),
);
Map<String, dynamic> _$$DiaryPhotoModelImplToJson(
@@ -120,3 +120,17 @@ Map<String, dynamic> _$$TypeOfDiaryModelImplToJson(
'has_chosen_diet': instance.hasChosenDiet,
'has_chosen_plan': instance.hasChosenPlan,
};
_$ProductInMealImpl _$$ProductInMealImplFromJson(Map<String, dynamic> json) =>
_$ProductInMealImpl(
productName: json['product_name'] as String,
portion: json['portion'] as String,
quantity: (json['quantity'] as num).toInt(),
);
Map<String, dynamic> _$$ProductInMealImplToJson(_$ProductInMealImpl instance) =>
<String, dynamic>{
'product_name': instance.productName,
'portion': instance.portion,
'quantity': instance.quantity,
};