forked from eatvio/eatvio_app
fixed profile, recipeis and diets
This commit is contained in:
@@ -23,10 +23,10 @@ class Diet with _$Diet {
|
||||
@JsonKey(name: "name") required String name,
|
||||
@JsonKey(name: "image") required String image,
|
||||
@JsonKey(name: "duration") required int duration,
|
||||
@JsonKey(name: "state") required String state,
|
||||
@JsonKey(name: "state") required DietState state,
|
||||
@JsonKey(name: "type") required DietType type,
|
||||
@JsonKey(name: "details") required String details,
|
||||
@JsonKey(name: "daily_schedule") required List<List<List<DailySchedule>>> dailySchedule,
|
||||
@JsonKey(name: "daily_schedule") required Map<int, Map<int, Map<int, DailySchedule>>> dailySchedule,
|
||||
@JsonKey(name: "author") required Author author,
|
||||
@JsonKey(name: "total_likes") required int totalLikes,
|
||||
@JsonKey(name: "total_views") required int totalViews,
|
||||
@@ -39,10 +39,30 @@ class Diet with _$Diet {
|
||||
factory Diet.fromJson(Map<String, dynamic> json) => _$DietFromJson(json);
|
||||
}
|
||||
|
||||
enum DietState {
|
||||
@JsonKey(name: 'active')
|
||||
active,
|
||||
@JsonKey(name: 'draft')
|
||||
draft,
|
||||
@JsonKey(name: 'personal')
|
||||
personal;
|
||||
|
||||
String toString() {
|
||||
switch (this) {
|
||||
case DietState.active:
|
||||
return 'active';
|
||||
case DietState.draft:
|
||||
return 'draft';
|
||||
case DietState.personal:
|
||||
return 'personal';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@freezed
|
||||
class CreatedDiet with _$CreatedDiet {
|
||||
const factory CreatedDiet({
|
||||
@JsonKey(name: "id") required int id,
|
||||
@JsonKey(name: "id") required int id,
|
||||
}) = _CreatedDiet;
|
||||
|
||||
factory CreatedDiet.fromJson(Map<String, dynamic> json) => _$CreatedDietFromJson(json);
|
||||
@@ -51,9 +71,9 @@ class CreatedDiet with _$CreatedDiet {
|
||||
int parseDuration(dynamic duration) {
|
||||
if (duration is String) {
|
||||
return int.parse(duration);
|
||||
}else {
|
||||
} else {
|
||||
return duration;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@freezed
|
||||
@@ -74,9 +94,8 @@ class Author with _$Author {
|
||||
class DailySchedule with _$DailySchedule {
|
||||
const factory DailySchedule({
|
||||
@JsonKey(name: "name") required String name,
|
||||
@JsonKey(name: "uniq", includeToJson: false) required String uniq,
|
||||
@JsonKey(name: "portion") required Portion portion,
|
||||
@JsonKey(name: "quantity") required int quantity,
|
||||
@JsonKey(name: "quantity", fromJson: _parseQuantity) required int quantity,
|
||||
@JsonKey(includeToJson: false, includeFromJson: false) DailyNutrition? dailyNutrition,
|
||||
@JsonKey(name: 'product_nutritional_value_id', includeToJson: true, includeFromJson: false, includeIfNull: false) String? productNutritionalValueId,
|
||||
}) = _DailySchedule;
|
||||
@@ -84,8 +103,16 @@ class DailySchedule with _$DailySchedule {
|
||||
factory DailySchedule.fromJson(Map<String, dynamic> json) => _$DailyScheduleFromJson(json);
|
||||
}
|
||||
|
||||
int _parseQuantity(dynamic quantity) {
|
||||
if (quantity is String) {
|
||||
return int.parse(quantity);
|
||||
} else {
|
||||
return quantity;
|
||||
}
|
||||
}
|
||||
|
||||
enum Portion {
|
||||
@JsonValue("grams")
|
||||
@JsonValue("gr")
|
||||
GRAMS,
|
||||
@JsonValue("milliliters")
|
||||
MILLILITERS,
|
||||
|
||||
@@ -268,13 +268,13 @@ mixin _$Diet {
|
||||
@JsonKey(name: "duration")
|
||||
int get duration => throw _privateConstructorUsedError;
|
||||
@JsonKey(name: "state")
|
||||
String get state => throw _privateConstructorUsedError;
|
||||
DietState get state => throw _privateConstructorUsedError;
|
||||
@JsonKey(name: "type")
|
||||
DietType get type => throw _privateConstructorUsedError;
|
||||
@JsonKey(name: "details")
|
||||
String get details => throw _privateConstructorUsedError;
|
||||
@JsonKey(name: "daily_schedule")
|
||||
List<List<List<DailySchedule>>> get dailySchedule =>
|
||||
Map<int, Map<int, Map<int, DailySchedule>>> get dailySchedule =>
|
||||
throw _privateConstructorUsedError;
|
||||
@JsonKey(name: "author")
|
||||
Author get author => throw _privateConstructorUsedError;
|
||||
@@ -310,11 +310,11 @@ abstract class $DietCopyWith<$Res> {
|
||||
@JsonKey(name: "name") String name,
|
||||
@JsonKey(name: "image") String image,
|
||||
@JsonKey(name: "duration") int duration,
|
||||
@JsonKey(name: "state") String state,
|
||||
@JsonKey(name: "state") DietState state,
|
||||
@JsonKey(name: "type") DietType type,
|
||||
@JsonKey(name: "details") String details,
|
||||
@JsonKey(name: "daily_schedule")
|
||||
List<List<List<DailySchedule>>> dailySchedule,
|
||||
Map<int, Map<int, Map<int, DailySchedule>>> dailySchedule,
|
||||
@JsonKey(name: "author") Author author,
|
||||
@JsonKey(name: "total_likes") int totalLikes,
|
||||
@JsonKey(name: "total_views") int totalViews,
|
||||
@@ -378,7 +378,7 @@ class _$DietCopyWithImpl<$Res, $Val extends Diet>
|
||||
state: null == state
|
||||
? _value.state
|
||||
: state // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
as DietState,
|
||||
type: null == type
|
||||
? _value.type
|
||||
: type // ignore: cast_nullable_to_non_nullable
|
||||
@@ -390,7 +390,7 @@ class _$DietCopyWithImpl<$Res, $Val extends Diet>
|
||||
dailySchedule: null == dailySchedule
|
||||
? _value.dailySchedule
|
||||
: dailySchedule // ignore: cast_nullable_to_non_nullable
|
||||
as List<List<List<DailySchedule>>>,
|
||||
as Map<int, Map<int, Map<int, DailySchedule>>>,
|
||||
author: null == author
|
||||
? _value.author
|
||||
: author // ignore: cast_nullable_to_non_nullable
|
||||
@@ -455,11 +455,11 @@ abstract class _$$DietImplCopyWith<$Res> implements $DietCopyWith<$Res> {
|
||||
@JsonKey(name: "name") String name,
|
||||
@JsonKey(name: "image") String image,
|
||||
@JsonKey(name: "duration") int duration,
|
||||
@JsonKey(name: "state") String state,
|
||||
@JsonKey(name: "state") DietState state,
|
||||
@JsonKey(name: "type") DietType type,
|
||||
@JsonKey(name: "details") String details,
|
||||
@JsonKey(name: "daily_schedule")
|
||||
List<List<List<DailySchedule>>> dailySchedule,
|
||||
Map<int, Map<int, Map<int, DailySchedule>>> dailySchedule,
|
||||
@JsonKey(name: "author") Author author,
|
||||
@JsonKey(name: "total_likes") int totalLikes,
|
||||
@JsonKey(name: "total_views") int totalViews,
|
||||
@@ -522,7 +522,7 @@ class __$$DietImplCopyWithImpl<$Res>
|
||||
state: null == state
|
||||
? _value.state
|
||||
: state // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
as DietState,
|
||||
type: null == type
|
||||
? _value.type
|
||||
: type // ignore: cast_nullable_to_non_nullable
|
||||
@@ -534,7 +534,7 @@ class __$$DietImplCopyWithImpl<$Res>
|
||||
dailySchedule: null == dailySchedule
|
||||
? _value._dailySchedule
|
||||
: dailySchedule // ignore: cast_nullable_to_non_nullable
|
||||
as List<List<List<DailySchedule>>>,
|
||||
as Map<int, Map<int, Map<int, DailySchedule>>>,
|
||||
author: null == author
|
||||
? _value.author
|
||||
: author // ignore: cast_nullable_to_non_nullable
|
||||
@@ -579,7 +579,7 @@ class _$DietImpl implements _Diet {
|
||||
@JsonKey(name: "type") required this.type,
|
||||
@JsonKey(name: "details") required this.details,
|
||||
@JsonKey(name: "daily_schedule")
|
||||
required final List<List<List<DailySchedule>>> dailySchedule,
|
||||
required final Map<int, Map<int, Map<int, DailySchedule>>> dailySchedule,
|
||||
@JsonKey(name: "author") required this.author,
|
||||
@JsonKey(name: "total_likes") required this.totalLikes,
|
||||
@JsonKey(name: "total_views") required this.totalViews,
|
||||
@@ -608,20 +608,20 @@ class _$DietImpl implements _Diet {
|
||||
final int duration;
|
||||
@override
|
||||
@JsonKey(name: "state")
|
||||
final String state;
|
||||
final DietState state;
|
||||
@override
|
||||
@JsonKey(name: "type")
|
||||
final DietType type;
|
||||
@override
|
||||
@JsonKey(name: "details")
|
||||
final String details;
|
||||
final List<List<List<DailySchedule>>> _dailySchedule;
|
||||
final Map<int, Map<int, Map<int, DailySchedule>>> _dailySchedule;
|
||||
@override
|
||||
@JsonKey(name: "daily_schedule")
|
||||
List<List<List<DailySchedule>>> get dailySchedule {
|
||||
if (_dailySchedule is EqualUnmodifiableListView) return _dailySchedule;
|
||||
Map<int, Map<int, Map<int, DailySchedule>>> get dailySchedule {
|
||||
if (_dailySchedule is EqualUnmodifiableMapView) return _dailySchedule;
|
||||
// ignore: implicit_dynamic_type
|
||||
return EqualUnmodifiableListView(_dailySchedule);
|
||||
return EqualUnmodifiableMapView(_dailySchedule);
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -728,11 +728,11 @@ abstract class _Diet implements Diet {
|
||||
@JsonKey(name: "name") required final String name,
|
||||
@JsonKey(name: "image") required final String image,
|
||||
@JsonKey(name: "duration") required final int duration,
|
||||
@JsonKey(name: "state") required final String state,
|
||||
@JsonKey(name: "state") required final DietState state,
|
||||
@JsonKey(name: "type") required final DietType type,
|
||||
@JsonKey(name: "details") required final String details,
|
||||
@JsonKey(name: "daily_schedule")
|
||||
required final List<List<List<DailySchedule>>> dailySchedule,
|
||||
required final Map<int, Map<int, Map<int, DailySchedule>>> dailySchedule,
|
||||
@JsonKey(name: "author") required final Author author,
|
||||
@JsonKey(name: "total_likes") required final int totalLikes,
|
||||
@JsonKey(name: "total_views") required final int totalViews,
|
||||
@@ -758,7 +758,7 @@ abstract class _Diet implements Diet {
|
||||
int get duration;
|
||||
@override
|
||||
@JsonKey(name: "state")
|
||||
String get state;
|
||||
DietState get state;
|
||||
@override
|
||||
@JsonKey(name: "type")
|
||||
DietType get type;
|
||||
@@ -767,7 +767,7 @@ abstract class _Diet implements Diet {
|
||||
String get details;
|
||||
@override
|
||||
@JsonKey(name: "daily_schedule")
|
||||
List<List<List<DailySchedule>>> get dailySchedule;
|
||||
Map<int, Map<int, Map<int, DailySchedule>>> get dailySchedule;
|
||||
@override
|
||||
@JsonKey(name: "author")
|
||||
Author get author;
|
||||
@@ -1242,11 +1242,9 @@ DailySchedule _$DailyScheduleFromJson(Map<String, dynamic> json) {
|
||||
mixin _$DailySchedule {
|
||||
@JsonKey(name: "name")
|
||||
String get name => throw _privateConstructorUsedError;
|
||||
@JsonKey(name: "uniq", includeToJson: false)
|
||||
String get uniq => throw _privateConstructorUsedError;
|
||||
@JsonKey(name: "portion")
|
||||
Portion get portion => throw _privateConstructorUsedError;
|
||||
@JsonKey(name: "quantity")
|
||||
@JsonKey(name: "quantity", fromJson: _parseQuantity)
|
||||
int get quantity => throw _privateConstructorUsedError;
|
||||
@JsonKey(includeToJson: false, includeFromJson: false)
|
||||
DailyNutrition? get dailyNutrition => throw _privateConstructorUsedError;
|
||||
@@ -1275,9 +1273,8 @@ abstract class $DailyScheduleCopyWith<$Res> {
|
||||
@useResult
|
||||
$Res call(
|
||||
{@JsonKey(name: "name") String name,
|
||||
@JsonKey(name: "uniq", includeToJson: false) String uniq,
|
||||
@JsonKey(name: "portion") Portion portion,
|
||||
@JsonKey(name: "quantity") int quantity,
|
||||
@JsonKey(name: "quantity", fromJson: _parseQuantity) int quantity,
|
||||
@JsonKey(includeToJson: false, includeFromJson: false)
|
||||
DailyNutrition? dailyNutrition,
|
||||
@JsonKey(
|
||||
@@ -1306,7 +1303,6 @@ class _$DailyScheduleCopyWithImpl<$Res, $Val extends DailySchedule>
|
||||
@override
|
||||
$Res call({
|
||||
Object? name = null,
|
||||
Object? uniq = null,
|
||||
Object? portion = null,
|
||||
Object? quantity = null,
|
||||
Object? dailyNutrition = freezed,
|
||||
@@ -1317,10 +1313,6 @@ class _$DailyScheduleCopyWithImpl<$Res, $Val extends DailySchedule>
|
||||
? _value.name
|
||||
: name // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
uniq: null == uniq
|
||||
? _value.uniq
|
||||
: uniq // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
portion: null == portion
|
||||
? _value.portion
|
||||
: portion // ignore: cast_nullable_to_non_nullable
|
||||
@@ -1365,9 +1357,8 @@ abstract class _$$DailyScheduleImplCopyWith<$Res>
|
||||
@useResult
|
||||
$Res call(
|
||||
{@JsonKey(name: "name") String name,
|
||||
@JsonKey(name: "uniq", includeToJson: false) String uniq,
|
||||
@JsonKey(name: "portion") Portion portion,
|
||||
@JsonKey(name: "quantity") int quantity,
|
||||
@JsonKey(name: "quantity", fromJson: _parseQuantity) int quantity,
|
||||
@JsonKey(includeToJson: false, includeFromJson: false)
|
||||
DailyNutrition? dailyNutrition,
|
||||
@JsonKey(
|
||||
@@ -1395,7 +1386,6 @@ class __$$DailyScheduleImplCopyWithImpl<$Res>
|
||||
@override
|
||||
$Res call({
|
||||
Object? name = null,
|
||||
Object? uniq = null,
|
||||
Object? portion = null,
|
||||
Object? quantity = null,
|
||||
Object? dailyNutrition = freezed,
|
||||
@@ -1406,10 +1396,6 @@ class __$$DailyScheduleImplCopyWithImpl<$Res>
|
||||
? _value.name
|
||||
: name // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
uniq: null == uniq
|
||||
? _value.uniq
|
||||
: uniq // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
portion: null == portion
|
||||
? _value.portion
|
||||
: portion // ignore: cast_nullable_to_non_nullable
|
||||
@@ -1435,9 +1421,9 @@ class __$$DailyScheduleImplCopyWithImpl<$Res>
|
||||
class _$DailyScheduleImpl implements _DailySchedule {
|
||||
const _$DailyScheduleImpl(
|
||||
{@JsonKey(name: "name") required this.name,
|
||||
@JsonKey(name: "uniq", includeToJson: false) required this.uniq,
|
||||
@JsonKey(name: "portion") required this.portion,
|
||||
@JsonKey(name: "quantity") required this.quantity,
|
||||
@JsonKey(name: "quantity", fromJson: _parseQuantity)
|
||||
required this.quantity,
|
||||
@JsonKey(includeToJson: false, includeFromJson: false)
|
||||
this.dailyNutrition,
|
||||
@JsonKey(
|
||||
@@ -1454,13 +1440,10 @@ class _$DailyScheduleImpl implements _DailySchedule {
|
||||
@JsonKey(name: "name")
|
||||
final String name;
|
||||
@override
|
||||
@JsonKey(name: "uniq", includeToJson: false)
|
||||
final String uniq;
|
||||
@override
|
||||
@JsonKey(name: "portion")
|
||||
final Portion portion;
|
||||
@override
|
||||
@JsonKey(name: "quantity")
|
||||
@JsonKey(name: "quantity", fromJson: _parseQuantity)
|
||||
final int quantity;
|
||||
@override
|
||||
@JsonKey(includeToJson: false, includeFromJson: false)
|
||||
@@ -1475,7 +1458,7 @@ class _$DailyScheduleImpl implements _DailySchedule {
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'DailySchedule(name: $name, uniq: $uniq, portion: $portion, quantity: $quantity, dailyNutrition: $dailyNutrition, productNutritionalValueId: $productNutritionalValueId)';
|
||||
return 'DailySchedule(name: $name, portion: $portion, quantity: $quantity, dailyNutrition: $dailyNutrition, productNutritionalValueId: $productNutritionalValueId)';
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -1484,7 +1467,6 @@ class _$DailyScheduleImpl implements _DailySchedule {
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$DailyScheduleImpl &&
|
||||
(identical(other.name, name) || other.name == name) &&
|
||||
(identical(other.uniq, uniq) || other.uniq == uniq) &&
|
||||
(identical(other.portion, portion) || other.portion == portion) &&
|
||||
(identical(other.quantity, quantity) ||
|
||||
other.quantity == quantity) &&
|
||||
@@ -1497,7 +1479,7 @@ class _$DailyScheduleImpl implements _DailySchedule {
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType, name, uniq, portion, quantity,
|
||||
int get hashCode => Object.hash(runtimeType, name, portion, quantity,
|
||||
dailyNutrition, productNutritionalValueId);
|
||||
|
||||
/// Create a copy of DailySchedule
|
||||
@@ -1519,9 +1501,9 @@ class _$DailyScheduleImpl implements _DailySchedule {
|
||||
abstract class _DailySchedule implements DailySchedule {
|
||||
const factory _DailySchedule(
|
||||
{@JsonKey(name: "name") required final String name,
|
||||
@JsonKey(name: "uniq", includeToJson: false) required final String uniq,
|
||||
@JsonKey(name: "portion") required final Portion portion,
|
||||
@JsonKey(name: "quantity") required final int quantity,
|
||||
@JsonKey(name: "quantity", fromJson: _parseQuantity)
|
||||
required final int quantity,
|
||||
@JsonKey(includeToJson: false, includeFromJson: false)
|
||||
final DailyNutrition? dailyNutrition,
|
||||
@JsonKey(
|
||||
@@ -1538,13 +1520,10 @@ abstract class _DailySchedule implements DailySchedule {
|
||||
@JsonKey(name: "name")
|
||||
String get name;
|
||||
@override
|
||||
@JsonKey(name: "uniq", includeToJson: false)
|
||||
String get uniq;
|
||||
@override
|
||||
@JsonKey(name: "portion")
|
||||
Portion get portion;
|
||||
@override
|
||||
@JsonKey(name: "quantity")
|
||||
@JsonKey(name: "quantity", fromJson: _parseQuantity)
|
||||
int get quantity;
|
||||
@override
|
||||
@JsonKey(includeToJson: false, includeFromJson: false)
|
||||
|
||||
@@ -29,16 +29,21 @@ _$DietImpl _$$DietImplFromJson(Map<String, dynamic> json) => _$DietImpl(
|
||||
name: json['name'] as String,
|
||||
image: json['image'] as String,
|
||||
duration: (json['duration'] as num).toInt(),
|
||||
state: json['state'] as String,
|
||||
state: $enumDecode(_$DietStateEnumMap, json['state']),
|
||||
type: DietType.fromJson(json['type'] as Map<String, dynamic>),
|
||||
details: json['details'] as String,
|
||||
dailySchedule: (json['daily_schedule'] as List<dynamic>)
|
||||
.map((e) => (e as List<dynamic>)
|
||||
.map((e) => (e as List<dynamic>)
|
||||
.map((e) => DailySchedule.fromJson(e as Map<String, dynamic>))
|
||||
.toList())
|
||||
.toList())
|
||||
.toList(),
|
||||
dailySchedule: (json['daily_schedule'] as Map<String, dynamic>).map(
|
||||
(k, e) => MapEntry(
|
||||
int.parse(k),
|
||||
(e as Map<String, dynamic>).map(
|
||||
(k, e) => MapEntry(
|
||||
int.parse(k),
|
||||
(e as Map<String, dynamic>).map(
|
||||
(k, e) => MapEntry(int.parse(k),
|
||||
DailySchedule.fromJson(e as Map<String, dynamic>)),
|
||||
)),
|
||||
)),
|
||||
),
|
||||
author: Author.fromJson(json['author'] as Map<String, dynamic>),
|
||||
totalLikes: (json['total_likes'] as num).toInt(),
|
||||
totalViews: (json['total_views'] as num).toInt(),
|
||||
@@ -56,10 +61,13 @@ Map<String, dynamic> _$$DietImplToJson(_$DietImpl instance) =>
|
||||
'name': instance.name,
|
||||
'image': instance.image,
|
||||
'duration': instance.duration,
|
||||
'state': instance.state,
|
||||
'state': _$DietStateEnumMap[instance.state]!,
|
||||
'type': instance.type,
|
||||
'details': instance.details,
|
||||
'daily_schedule': instance.dailySchedule,
|
||||
'daily_schedule': instance.dailySchedule.map((k, e) => MapEntry(
|
||||
k.toString(),
|
||||
e.map((k, e) => MapEntry(
|
||||
k.toString(), e.map((k, e) => MapEntry(k.toString(), e)))))),
|
||||
'author': instance.author,
|
||||
'total_likes': instance.totalLikes,
|
||||
'total_views': instance.totalViews,
|
||||
@@ -69,6 +77,12 @@ Map<String, dynamic> _$$DietImplToJson(_$DietImpl instance) =>
|
||||
'daily_nutrition': instance.dailyNutrition,
|
||||
};
|
||||
|
||||
const _$DietStateEnumMap = {
|
||||
DietState.active: 'active',
|
||||
DietState.draft: 'draft',
|
||||
DietState.personal: 'personal',
|
||||
};
|
||||
|
||||
_$CreatedDietImpl _$$CreatedDietImplFromJson(Map<String, dynamic> json) =>
|
||||
_$CreatedDietImpl(
|
||||
id: (json['id'] as num).toInt(),
|
||||
@@ -101,9 +115,8 @@ Map<String, dynamic> _$$AuthorImplToJson(_$AuthorImpl instance) =>
|
||||
_$DailyScheduleImpl _$$DailyScheduleImplFromJson(Map<String, dynamic> json) =>
|
||||
_$DailyScheduleImpl(
|
||||
name: json['name'] as String,
|
||||
uniq: json['uniq'] as String,
|
||||
portion: $enumDecode(_$PortionEnumMap, json['portion']),
|
||||
quantity: (json['quantity'] as num).toInt(),
|
||||
quantity: _parseQuantity(json['quantity']),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$$DailyScheduleImplToJson(_$DailyScheduleImpl instance) =>
|
||||
@@ -116,7 +129,7 @@ Map<String, dynamic> _$$DailyScheduleImplToJson(_$DailyScheduleImpl instance) =>
|
||||
};
|
||||
|
||||
const _$PortionEnumMap = {
|
||||
Portion.GRAMS: 'grams',
|
||||
Portion.GRAMS: 'gr',
|
||||
Portion.MILLILITERS: 'milliliters',
|
||||
Portion.PCS: 'pcs',
|
||||
};
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import 'dart:developer';
|
||||
|
||||
import 'package:eatvio_app/features/feed/presentation/bloc/consultants_cubit/consultants_state.dart';
|
||||
import 'package:eatvio_app/features/feed/repositories/feed_repository.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
@@ -18,7 +20,8 @@ class ConsultantsCubit extends Cubit<ConsultantsState> {
|
||||
isLoading: false,
|
||||
),
|
||||
);
|
||||
} catch (e) {
|
||||
} catch (e, st) {
|
||||
log(e.toString(), stackTrace: st);
|
||||
emit(ConsultantsState.error(errorMessage: e.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -107,9 +107,10 @@ class DietsCubit extends Cubit<DietsState> {
|
||||
errorMessage: null,
|
||||
),
|
||||
);
|
||||
} catch (e) {
|
||||
} catch (e, st) {
|
||||
log(e.toString(), stackTrace: st);
|
||||
emit(
|
||||
state.copyWith(errorMessage: e.toString()),
|
||||
state.copyWith(isLoading: false),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -143,14 +144,13 @@ class DietsCubit extends Cubit<DietsState> {
|
||||
);
|
||||
}
|
||||
} catch (e) {
|
||||
emit(state.copyWith(errorMessage: e.toString()));
|
||||
emit(state.copyWith(isLoading: false));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> likeDiet(int id, int index) async {
|
||||
final currentDiets = state.dietsList;
|
||||
// if (currentDiets.isEmpty) return;
|
||||
final currentDiets = state.dietsList;
|
||||
final dietsForModification = [...currentDiets];
|
||||
final currentDiet = currentDiets[index];
|
||||
if (currentDiet.wasLikedByMe) {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import 'package:easy_debounce/easy_debounce.dart';
|
||||
import 'package:eatvio_app/core/widgets/add_item_button.dart';
|
||||
import 'package:eatvio_app/core/widgets/bottom_sheet_with_blur.dart';
|
||||
import 'package:eatvio_app/core/widgets/custom_search_bar.dart';
|
||||
import 'package:eatvio_app/features/create_diet/presentation/create_diet_screen.dart';
|
||||
import 'package:eatvio_app/features/create_plan/presentation/create_plan_screen.dart';
|
||||
@@ -14,6 +15,7 @@ import 'package:eatvio_app/features/feed/presentation/widgets/chip_group.dart';
|
||||
import 'package:eatvio_app/features/feed/presentation/widgets/consultants.dart';
|
||||
import 'package:eatvio_app/features/feed/presentation/widgets/diets.dart';
|
||||
import 'package:eatvio_app/features/feed/presentation/widgets/plans.dart';
|
||||
import 'package:eatvio_app/features/feed/presentation/widgets/success_published_diet_bottom_sheet.dart';
|
||||
import 'package:eatvio_app/features/feed/presentation/widgets/tags_modal_widget.dart';
|
||||
import 'package:eatvio_app/features/feed/presentation/bloc/plans_cubit/plans_cubit.dart';
|
||||
import 'package:eatvio_app/core/locator_service.dart';
|
||||
@@ -25,7 +27,6 @@ import 'package:go_router/go_router.dart';
|
||||
|
||||
import '../widgets/recipes.dart';
|
||||
|
||||
|
||||
class FeedScreen extends StatelessWidget {
|
||||
const FeedScreen({super.key});
|
||||
|
||||
@@ -260,10 +261,23 @@ class _FeedScreenContentState extends State<FeedScreenContent> {
|
||||
onTap: () => GoRouter.of(context).pushNamed(RecipeCreateScreen.name),
|
||||
),
|
||||
2 => AddItemButton(
|
||||
onTap: state.profile?.role == 'consultant' ? () => GoRouter.of(context).pushNamed(CreateDietScreen.name) : null,
|
||||
onTap: state.profile?.roles.contains('consultant') ?? false
|
||||
? () async {
|
||||
final result = await GoRouter.of(context).pushNamed<String?>(CreateDietScreen.name);
|
||||
if (result != null) {
|
||||
showBottomSheetWithBlur(
|
||||
userRootNavigator: true,
|
||||
context: context,
|
||||
child: SuccessPublishedDietBottomSheet(
|
||||
title: result,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
: null,
|
||||
),
|
||||
3 => AddItemButton(
|
||||
onTap: state.profile?.role == 'consultant' ? () => GoRouter.of(context).pushNamed(CreatePlanScreen.name) : null,
|
||||
onTap: state.profile?.roles.contains('consultant') ?? false ? () => GoRouter.of(context).pushNamed(CreatePlanScreen.name) : null,
|
||||
),
|
||||
_ => AddItemButton()
|
||||
},
|
||||
|
||||
@@ -63,4 +63,4 @@ class Diets extends StatelessWidget {
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
import 'package:eatvio_app/core/theme/custom_text_style.dart';
|
||||
import 'package:eatvio_app/core/theme/theme_helper.dart';
|
||||
import 'package:eatvio_app/core/widgets/bottom_sheet_handler_bar.dart';
|
||||
import 'package:eatvio_app/core/widgets/custom_outlined_button.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
|
||||
class SuccessPublishedDietBottomSheet extends StatelessWidget {
|
||||
const SuccessPublishedDietBottomSheet({super.key, required this.title});
|
||||
final String title;
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Column(
|
||||
children: [
|
||||
SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
BottomSheetHandlerBar(),
|
||||
SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
Text(
|
||||
title,
|
||||
style: TextStyles.headingXLSemibold.copyWith(color: appTheme.black),
|
||||
),
|
||||
Text(
|
||||
'опубликованна',
|
||||
style: TextStyles.headingXLSemibold.copyWith(color: appTheme.black),
|
||||
),
|
||||
SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 20),
|
||||
child: CustomOutlinedButton(
|
||||
onPressed: () {
|
||||
GoRouter.of(context).pop();
|
||||
},
|
||||
text: 'Хорошо',
|
||||
height: 52,
|
||||
buttonTextStyle: TextStyles.textSSemibold.copyWith(color: appTheme.whiteA700),
|
||||
buttonStyle: ButtonStyle(
|
||||
side: WidgetStatePropertyAll(BorderSide.none),
|
||||
backgroundColor: WidgetStatePropertyAll(appTheme.blueA400),
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user