forked from eatvio/eatvio_app
refactor: profile model
This commit is contained in:
@@ -84,6 +84,9 @@ class _$CommentsStateCopyWithImpl<$Res, $Val extends CommentsState>
|
||||
final $Val _value;
|
||||
// ignore: unused_field
|
||||
final $Res Function($Val) _then;
|
||||
|
||||
/// Create a copy of CommentsState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@@ -100,6 +103,9 @@ class __$$CommentsStateImplCopyWithImpl<$Res>
|
||||
__$$CommentsStateImplCopyWithImpl(
|
||||
_$CommentsStateImpl _value, $Res Function(_$CommentsStateImpl) _then)
|
||||
: super(_value, _then);
|
||||
|
||||
/// Create a copy of CommentsState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@@ -214,6 +220,9 @@ class __$$CommentsStateLoadingImplCopyWithImpl<$Res>
|
||||
__$$CommentsStateLoadingImplCopyWithImpl(_$CommentsStateLoadingImpl _value,
|
||||
$Res Function(_$CommentsStateLoadingImpl) _then)
|
||||
: super(_value, _then);
|
||||
|
||||
/// Create a copy of CommentsState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@@ -334,6 +343,8 @@ class __$$CommentsStateLoadedImplCopyWithImpl<$Res>
|
||||
$Res Function(_$CommentsStateLoadedImpl) _then)
|
||||
: super(_value, _then);
|
||||
|
||||
/// Create a copy of CommentsState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
@@ -352,6 +363,8 @@ class __$$CommentsStateLoadedImplCopyWithImpl<$Res>
|
||||
));
|
||||
}
|
||||
|
||||
/// Create a copy of CommentsState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
$CommentModelCopyWith<$Res> get comment {
|
||||
@@ -388,7 +401,9 @@ class _$CommentsStateLoadedImpl implements CommentsStateLoaded {
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType, comment, replyId);
|
||||
|
||||
@JsonKey(ignore: true)
|
||||
/// Create a copy of CommentsState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$CommentsStateLoadedImplCopyWith<_$CommentsStateLoadedImpl> get copyWith =>
|
||||
@@ -477,7 +492,10 @@ abstract class CommentsStateLoaded implements CommentsState {
|
||||
|
||||
CommentModel get comment;
|
||||
int? get replyId;
|
||||
@JsonKey(ignore: true)
|
||||
|
||||
/// Create a copy of CommentsState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
_$$CommentsStateLoadedImplCopyWith<_$CommentsStateLoadedImpl> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
@@ -499,6 +517,8 @@ class __$$CommentsStateErrorImplCopyWithImpl<$Res>
|
||||
$Res Function(_$CommentsStateErrorImpl) _then)
|
||||
: super(_value, _then);
|
||||
|
||||
/// Create a copy of CommentsState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
@@ -538,7 +558,9 @@ class _$CommentsStateErrorImpl implements CommentsStateError {
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType, errorMessage);
|
||||
|
||||
@JsonKey(ignore: true)
|
||||
/// Create a copy of CommentsState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$CommentsStateErrorImplCopyWith<_$CommentsStateErrorImpl> get copyWith =>
|
||||
@@ -625,7 +647,10 @@ abstract class CommentsStateError implements CommentsState {
|
||||
_$CommentsStateErrorImpl;
|
||||
|
||||
String get errorMessage;
|
||||
@JsonKey(ignore: true)
|
||||
|
||||
/// Create a copy of CommentsState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
_$$CommentsStateErrorImplCopyWith<_$CommentsStateErrorImpl> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
@@ -84,6 +84,9 @@ class _$DietsStateCopyWithImpl<$Res, $Val extends DietsState>
|
||||
final $Val _value;
|
||||
// ignore: unused_field
|
||||
final $Res Function($Val) _then;
|
||||
|
||||
/// Create a copy of DietsState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@@ -100,6 +103,9 @@ class __$$DietsStateImplCopyWithImpl<$Res>
|
||||
__$$DietsStateImplCopyWithImpl(
|
||||
_$DietsStateImpl _value, $Res Function(_$DietsStateImpl) _then)
|
||||
: super(_value, _then);
|
||||
|
||||
/// Create a copy of DietsState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@@ -214,6 +220,9 @@ class __$$DietsStateLoadingImplCopyWithImpl<$Res>
|
||||
__$$DietsStateLoadingImplCopyWithImpl(_$DietsStateLoadingImpl _value,
|
||||
$Res Function(_$DietsStateLoadingImpl) _then)
|
||||
: super(_value, _then);
|
||||
|
||||
/// Create a copy of DietsState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@@ -333,6 +342,8 @@ class __$$DietsStateLoadedImplCopyWithImpl<$Res>
|
||||
$Res Function(_$DietsStateLoadedImpl) _then)
|
||||
: super(_value, _then);
|
||||
|
||||
/// Create a copy of DietsState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
@@ -346,6 +357,8 @@ class __$$DietsStateLoadedImplCopyWithImpl<$Res>
|
||||
));
|
||||
}
|
||||
|
||||
/// Create a copy of DietsState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
$DietsPaginationCopyWith<$Res> get diets {
|
||||
@@ -379,7 +392,9 @@ class _$DietsStateLoadedImpl implements DietsStateLoaded {
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType, diets);
|
||||
|
||||
@JsonKey(ignore: true)
|
||||
/// Create a copy of DietsState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$DietsStateLoadedImplCopyWith<_$DietsStateLoadedImpl> get copyWith =>
|
||||
@@ -466,7 +481,10 @@ abstract class DietsStateLoaded implements DietsState {
|
||||
_$DietsStateLoadedImpl;
|
||||
|
||||
DietsPagination get diets;
|
||||
@JsonKey(ignore: true)
|
||||
|
||||
/// Create a copy of DietsState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
_$$DietsStateLoadedImplCopyWith<_$DietsStateLoadedImpl> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
@@ -488,6 +506,8 @@ class __$$DietsStateErrorImplCopyWithImpl<$Res>
|
||||
_$DietsStateErrorImpl _value, $Res Function(_$DietsStateErrorImpl) _then)
|
||||
: super(_value, _then);
|
||||
|
||||
/// Create a copy of DietsState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
@@ -527,7 +547,9 @@ class _$DietsStateErrorImpl implements DietsStateError {
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType, errorMessage);
|
||||
|
||||
@JsonKey(ignore: true)
|
||||
/// Create a copy of DietsState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$DietsStateErrorImplCopyWith<_$DietsStateErrorImpl> get copyWith =>
|
||||
@@ -614,7 +636,10 @@ abstract class DietsStateError implements DietsState {
|
||||
_$DietsStateErrorImpl;
|
||||
|
||||
String get errorMessage;
|
||||
@JsonKey(ignore: true)
|
||||
|
||||
/// Create a copy of DietsState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
_$$DietsStateErrorImplCopyWith<_$DietsStateErrorImpl> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
@@ -87,6 +87,9 @@ class _$FeedStateCopyWithImpl<$Res, $Val extends FeedState>
|
||||
final $Val _value;
|
||||
// ignore: unused_field
|
||||
final $Res Function($Val) _then;
|
||||
|
||||
/// Create a copy of FeedState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@@ -103,6 +106,9 @@ class __$$FeedStateImplCopyWithImpl<$Res>
|
||||
__$$FeedStateImplCopyWithImpl(
|
||||
_$FeedStateImpl _value, $Res Function(_$FeedStateImpl) _then)
|
||||
: super(_value, _then);
|
||||
|
||||
/// Create a copy of FeedState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@@ -221,6 +227,9 @@ class __$$FeedStateLoadingImplCopyWithImpl<$Res>
|
||||
__$$FeedStateLoadingImplCopyWithImpl(_$FeedStateLoadingImpl _value,
|
||||
$Res Function(_$FeedStateLoadingImpl) _then)
|
||||
: super(_value, _then);
|
||||
|
||||
/// Create a copy of FeedState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@@ -342,6 +351,8 @@ class __$$FeedStateLoadedImplCopyWithImpl<$Res>
|
||||
_$FeedStateLoadedImpl _value, $Res Function(_$FeedStateLoadedImpl) _then)
|
||||
: super(_value, _then);
|
||||
|
||||
/// Create a copy of FeedState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
@@ -401,7 +412,9 @@ class _$FeedStateLoadedImpl implements FeedStateLoaded {
|
||||
int get hashCode => Object.hash(runtimeType,
|
||||
const DeepCollectionEquality().hash(_feedBlogPostList), isLoading);
|
||||
|
||||
@JsonKey(ignore: true)
|
||||
/// Create a copy of FeedState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$FeedStateLoadedImplCopyWith<_$FeedStateLoadedImpl> get copyWith =>
|
||||
@@ -494,7 +507,10 @@ abstract class FeedStateLoaded implements FeedState {
|
||||
|
||||
List<FeedBlogPostModel> get feedBlogPostList;
|
||||
bool get isLoading;
|
||||
@JsonKey(ignore: true)
|
||||
|
||||
/// Create a copy of FeedState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
_$$FeedStateLoadedImplCopyWith<_$FeedStateLoadedImpl> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
@@ -516,6 +532,8 @@ class __$$FeedStateErrorImplCopyWithImpl<$Res>
|
||||
_$FeedStateErrorImpl _value, $Res Function(_$FeedStateErrorImpl) _then)
|
||||
: super(_value, _then);
|
||||
|
||||
/// Create a copy of FeedState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
@@ -555,7 +573,9 @@ class _$FeedStateErrorImpl implements FeedStateError {
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType, errorMessage);
|
||||
|
||||
@JsonKey(ignore: true)
|
||||
/// Create a copy of FeedState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$FeedStateErrorImplCopyWith<_$FeedStateErrorImpl> get copyWith =>
|
||||
@@ -646,7 +666,10 @@ abstract class FeedStateError implements FeedState {
|
||||
_$FeedStateErrorImpl;
|
||||
|
||||
String get errorMessage;
|
||||
@JsonKey(ignore: true)
|
||||
|
||||
/// Create a copy of FeedState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
_$$FeedStateErrorImplCopyWith<_$FeedStateErrorImpl> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
@@ -8,6 +8,10 @@ class RecipesCubit extends Cubit<RecipesState> {
|
||||
final FeedRepository feedRepository;
|
||||
final RecipeRepository recipeRepository;
|
||||
Set<int> _selectedTags = {};
|
||||
int currentPage = 1;
|
||||
late int lastPage;
|
||||
bool isLoading = false;
|
||||
String? _query;
|
||||
|
||||
RecipesCubit({
|
||||
required this.feedRepository,
|
||||
@@ -18,6 +22,7 @@ class RecipesCubit extends Cubit<RecipesState> {
|
||||
String? query,
|
||||
}) async {
|
||||
try {
|
||||
_query = query;
|
||||
final recipesList = await feedRepository.getRecipes(
|
||||
tags: _selectedTags.toList(),
|
||||
query: query,
|
||||
@@ -28,12 +33,42 @@ class RecipesCubit extends Cubit<RecipesState> {
|
||||
recipesTags: recipesTags,
|
||||
selectedTags: _selectedTags,
|
||||
selectedTagsCounter: _selectedTags.length,
|
||||
isLoading: isLoading,
|
||||
));
|
||||
} catch (e) {
|
||||
emit(RecipesState.error(errorMessage: e.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
loadNextPage() async {
|
||||
if (currentPage < lastPage && !isLoading) {
|
||||
isLoading = true;
|
||||
|
||||
emit((state as RecipesStateLoaded).copyWith(isLoading: isLoading));
|
||||
|
||||
try {
|
||||
if (currentPage < lastPage) {
|
||||
currentPage++;
|
||||
final recipesList = await feedRepository.getRecipes(
|
||||
page: currentPage,
|
||||
tags: _selectedTags.toList(),
|
||||
query: _query,
|
||||
);
|
||||
isLoading = false;
|
||||
emit((state as RecipesStateLoaded).copyWith(
|
||||
recipesList: [
|
||||
...(state as RecipesStateLoaded).recipesList,
|
||||
...recipesList,
|
||||
],
|
||||
isLoading: isLoading,
|
||||
));
|
||||
}
|
||||
} catch (e) {
|
||||
emit(RecipesState.error(errorMessage: e.toString()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
updateTags(RecipeTag tag) {
|
||||
_selectedTags.contains(tag.id) ? _selectedTags.remove(tag.id) : _selectedTags.add(tag.id);
|
||||
emit((state as RecipesStateLoaded).copyWith(
|
||||
|
||||
@@ -15,6 +15,7 @@ abstract class RecipesState with _$RecipesState {
|
||||
required List<RecipeTag> recipesTags,
|
||||
required Set<int> selectedTags,
|
||||
required int selectedTagsCounter,
|
||||
required bool isLoading,
|
||||
}) = RecipesStateLoaded;
|
||||
|
||||
const factory RecipesState.error({
|
||||
|
||||
@@ -24,7 +24,8 @@ mixin _$RecipesState {
|
||||
List<Recipes> recipesList,
|
||||
List<RecipeTag> recipesTags,
|
||||
Set<int> selectedTags,
|
||||
int selectedTagsCounter)
|
||||
int selectedTagsCounter,
|
||||
bool isLoading)
|
||||
loaded,
|
||||
required TResult Function(String errorMessage) error,
|
||||
}) =>
|
||||
@@ -34,7 +35,7 @@ mixin _$RecipesState {
|
||||
TResult? Function()? $default, {
|
||||
TResult? Function()? loading,
|
||||
TResult? Function(List<Recipes> recipesList, List<RecipeTag> recipesTags,
|
||||
Set<int> selectedTags, int selectedTagsCounter)?
|
||||
Set<int> selectedTags, int selectedTagsCounter, bool isLoading)?
|
||||
loaded,
|
||||
TResult? Function(String errorMessage)? error,
|
||||
}) =>
|
||||
@@ -44,7 +45,7 @@ mixin _$RecipesState {
|
||||
TResult Function()? $default, {
|
||||
TResult Function()? loading,
|
||||
TResult Function(List<Recipes> recipesList, List<RecipeTag> recipesTags,
|
||||
Set<int> selectedTags, int selectedTagsCounter)?
|
||||
Set<int> selectedTags, int selectedTagsCounter, bool isLoading)?
|
||||
loaded,
|
||||
TResult Function(String errorMessage)? error,
|
||||
required TResult orElse(),
|
||||
@@ -93,6 +94,9 @@ class _$RecipesStateCopyWithImpl<$Res, $Val extends RecipesState>
|
||||
final $Val _value;
|
||||
// ignore: unused_field
|
||||
final $Res Function($Val) _then;
|
||||
|
||||
/// Create a copy of RecipesState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@@ -109,6 +113,9 @@ class __$$RecipesStateImplCopyWithImpl<$Res>
|
||||
__$$RecipesStateImplCopyWithImpl(
|
||||
_$RecipesStateImpl _value, $Res Function(_$RecipesStateImpl) _then)
|
||||
: super(_value, _then);
|
||||
|
||||
/// Create a copy of RecipesState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@@ -139,7 +146,8 @@ class _$RecipesStateImpl implements _RecipesState {
|
||||
List<Recipes> recipesList,
|
||||
List<RecipeTag> recipesTags,
|
||||
Set<int> selectedTags,
|
||||
int selectedTagsCounter)
|
||||
int selectedTagsCounter,
|
||||
bool isLoading)
|
||||
loaded,
|
||||
required TResult Function(String errorMessage) error,
|
||||
}) {
|
||||
@@ -152,7 +160,7 @@ class _$RecipesStateImpl implements _RecipesState {
|
||||
TResult? Function()? $default, {
|
||||
TResult? Function()? loading,
|
||||
TResult? Function(List<Recipes> recipesList, List<RecipeTag> recipesTags,
|
||||
Set<int> selectedTags, int selectedTagsCounter)?
|
||||
Set<int> selectedTags, int selectedTagsCounter, bool isLoading)?
|
||||
loaded,
|
||||
TResult? Function(String errorMessage)? error,
|
||||
}) {
|
||||
@@ -165,7 +173,7 @@ class _$RecipesStateImpl implements _RecipesState {
|
||||
TResult Function()? $default, {
|
||||
TResult Function()? loading,
|
||||
TResult Function(List<Recipes> recipesList, List<RecipeTag> recipesTags,
|
||||
Set<int> selectedTags, int selectedTagsCounter)?
|
||||
Set<int> selectedTags, int selectedTagsCounter, bool isLoading)?
|
||||
loaded,
|
||||
TResult Function(String errorMessage)? error,
|
||||
required TResult orElse(),
|
||||
@@ -232,6 +240,9 @@ class __$$RecipesStateLoadingImplCopyWithImpl<$Res>
|
||||
__$$RecipesStateLoadingImplCopyWithImpl(_$RecipesStateLoadingImpl _value,
|
||||
$Res Function(_$RecipesStateLoadingImpl) _then)
|
||||
: super(_value, _then);
|
||||
|
||||
/// Create a copy of RecipesState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@@ -263,7 +274,8 @@ class _$RecipesStateLoadingImpl implements RecipesStateLoading {
|
||||
List<Recipes> recipesList,
|
||||
List<RecipeTag> recipesTags,
|
||||
Set<int> selectedTags,
|
||||
int selectedTagsCounter)
|
||||
int selectedTagsCounter,
|
||||
bool isLoading)
|
||||
loaded,
|
||||
required TResult Function(String errorMessage) error,
|
||||
}) {
|
||||
@@ -276,7 +288,7 @@ class _$RecipesStateLoadingImpl implements RecipesStateLoading {
|
||||
TResult? Function()? $default, {
|
||||
TResult? Function()? loading,
|
||||
TResult? Function(List<Recipes> recipesList, List<RecipeTag> recipesTags,
|
||||
Set<int> selectedTags, int selectedTagsCounter)?
|
||||
Set<int> selectedTags, int selectedTagsCounter, bool isLoading)?
|
||||
loaded,
|
||||
TResult? Function(String errorMessage)? error,
|
||||
}) {
|
||||
@@ -289,7 +301,7 @@ class _$RecipesStateLoadingImpl implements RecipesStateLoading {
|
||||
TResult Function()? $default, {
|
||||
TResult Function()? loading,
|
||||
TResult Function(List<Recipes> recipesList, List<RecipeTag> recipesTags,
|
||||
Set<int> selectedTags, int selectedTagsCounter)?
|
||||
Set<int> selectedTags, int selectedTagsCounter, bool isLoading)?
|
||||
loaded,
|
||||
TResult Function(String errorMessage)? error,
|
||||
required TResult orElse(),
|
||||
@@ -352,7 +364,8 @@ abstract class _$$RecipesStateLoadedImplCopyWith<$Res> {
|
||||
{List<Recipes> recipesList,
|
||||
List<RecipeTag> recipesTags,
|
||||
Set<int> selectedTags,
|
||||
int selectedTagsCounter});
|
||||
int selectedTagsCounter,
|
||||
bool isLoading});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@@ -363,6 +376,8 @@ class __$$RecipesStateLoadedImplCopyWithImpl<$Res>
|
||||
$Res Function(_$RecipesStateLoadedImpl) _then)
|
||||
: super(_value, _then);
|
||||
|
||||
/// Create a copy of RecipesState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
@@ -370,6 +385,7 @@ class __$$RecipesStateLoadedImplCopyWithImpl<$Res>
|
||||
Object? recipesTags = null,
|
||||
Object? selectedTags = null,
|
||||
Object? selectedTagsCounter = null,
|
||||
Object? isLoading = null,
|
||||
}) {
|
||||
return _then(_$RecipesStateLoadedImpl(
|
||||
recipesList: null == recipesList
|
||||
@@ -388,6 +404,10 @@ class __$$RecipesStateLoadedImplCopyWithImpl<$Res>
|
||||
? _value.selectedTagsCounter
|
||||
: selectedTagsCounter // ignore: cast_nullable_to_non_nullable
|
||||
as int,
|
||||
isLoading: null == isLoading
|
||||
? _value.isLoading
|
||||
: isLoading // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
));
|
||||
}
|
||||
}
|
||||
@@ -399,7 +419,8 @@ class _$RecipesStateLoadedImpl implements RecipesStateLoaded {
|
||||
{required final List<Recipes> recipesList,
|
||||
required final List<RecipeTag> recipesTags,
|
||||
required final Set<int> selectedTags,
|
||||
required this.selectedTagsCounter})
|
||||
required this.selectedTagsCounter,
|
||||
required this.isLoading})
|
||||
: _recipesList = recipesList,
|
||||
_recipesTags = recipesTags,
|
||||
_selectedTags = selectedTags;
|
||||
@@ -430,10 +451,12 @@ class _$RecipesStateLoadedImpl implements RecipesStateLoaded {
|
||||
|
||||
@override
|
||||
final int selectedTagsCounter;
|
||||
@override
|
||||
final bool isLoading;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'RecipesState.loaded(recipesList: $recipesList, recipesTags: $recipesTags, selectedTags: $selectedTags, selectedTagsCounter: $selectedTagsCounter)';
|
||||
return 'RecipesState.loaded(recipesList: $recipesList, recipesTags: $recipesTags, selectedTags: $selectedTags, selectedTagsCounter: $selectedTagsCounter, isLoading: $isLoading)';
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -448,7 +471,9 @@ class _$RecipesStateLoadedImpl implements RecipesStateLoaded {
|
||||
const DeepCollectionEquality()
|
||||
.equals(other._selectedTags, _selectedTags) &&
|
||||
(identical(other.selectedTagsCounter, selectedTagsCounter) ||
|
||||
other.selectedTagsCounter == selectedTagsCounter));
|
||||
other.selectedTagsCounter == selectedTagsCounter) &&
|
||||
(identical(other.isLoading, isLoading) ||
|
||||
other.isLoading == isLoading));
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -457,9 +482,12 @@ class _$RecipesStateLoadedImpl implements RecipesStateLoaded {
|
||||
const DeepCollectionEquality().hash(_recipesList),
|
||||
const DeepCollectionEquality().hash(_recipesTags),
|
||||
const DeepCollectionEquality().hash(_selectedTags),
|
||||
selectedTagsCounter);
|
||||
selectedTagsCounter,
|
||||
isLoading);
|
||||
|
||||
@JsonKey(ignore: true)
|
||||
/// Create a copy of RecipesState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$RecipesStateLoadedImplCopyWith<_$RecipesStateLoadedImpl> get copyWith =>
|
||||
@@ -475,11 +503,13 @@ class _$RecipesStateLoadedImpl implements RecipesStateLoaded {
|
||||
List<Recipes> recipesList,
|
||||
List<RecipeTag> recipesTags,
|
||||
Set<int> selectedTags,
|
||||
int selectedTagsCounter)
|
||||
int selectedTagsCounter,
|
||||
bool isLoading)
|
||||
loaded,
|
||||
required TResult Function(String errorMessage) error,
|
||||
}) {
|
||||
return loaded(recipesList, recipesTags, selectedTags, selectedTagsCounter);
|
||||
return loaded(
|
||||
recipesList, recipesTags, selectedTags, selectedTagsCounter, isLoading);
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -488,12 +518,12 @@ class _$RecipesStateLoadedImpl implements RecipesStateLoaded {
|
||||
TResult? Function()? $default, {
|
||||
TResult? Function()? loading,
|
||||
TResult? Function(List<Recipes> recipesList, List<RecipeTag> recipesTags,
|
||||
Set<int> selectedTags, int selectedTagsCounter)?
|
||||
Set<int> selectedTags, int selectedTagsCounter, bool isLoading)?
|
||||
loaded,
|
||||
TResult? Function(String errorMessage)? error,
|
||||
}) {
|
||||
return loaded?.call(
|
||||
recipesList, recipesTags, selectedTags, selectedTagsCounter);
|
||||
recipesList, recipesTags, selectedTags, selectedTagsCounter, isLoading);
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -502,14 +532,14 @@ class _$RecipesStateLoadedImpl implements RecipesStateLoaded {
|
||||
TResult Function()? $default, {
|
||||
TResult Function()? loading,
|
||||
TResult Function(List<Recipes> recipesList, List<RecipeTag> recipesTags,
|
||||
Set<int> selectedTags, int selectedTagsCounter)?
|
||||
Set<int> selectedTags, int selectedTagsCounter, bool isLoading)?
|
||||
loaded,
|
||||
TResult Function(String errorMessage)? error,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (loaded != null) {
|
||||
return loaded(
|
||||
recipesList, recipesTags, selectedTags, selectedTagsCounter);
|
||||
return loaded(recipesList, recipesTags, selectedTags, selectedTagsCounter,
|
||||
isLoading);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
@@ -557,13 +587,18 @@ abstract class RecipesStateLoaded implements RecipesState {
|
||||
{required final List<Recipes> recipesList,
|
||||
required final List<RecipeTag> recipesTags,
|
||||
required final Set<int> selectedTags,
|
||||
required final int selectedTagsCounter}) = _$RecipesStateLoadedImpl;
|
||||
required final int selectedTagsCounter,
|
||||
required final bool isLoading}) = _$RecipesStateLoadedImpl;
|
||||
|
||||
List<Recipes> get recipesList;
|
||||
List<RecipeTag> get recipesTags;
|
||||
Set<int> get selectedTags;
|
||||
int get selectedTagsCounter;
|
||||
@JsonKey(ignore: true)
|
||||
bool get isLoading;
|
||||
|
||||
/// Create a copy of RecipesState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
_$$RecipesStateLoadedImplCopyWith<_$RecipesStateLoadedImpl> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
@@ -585,6 +620,8 @@ class __$$RecipesStateErrorImplCopyWithImpl<$Res>
|
||||
$Res Function(_$RecipesStateErrorImpl) _then)
|
||||
: super(_value, _then);
|
||||
|
||||
/// Create a copy of RecipesState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
@@ -624,7 +661,9 @@ class _$RecipesStateErrorImpl implements RecipesStateError {
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType, errorMessage);
|
||||
|
||||
@JsonKey(ignore: true)
|
||||
/// Create a copy of RecipesState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$RecipesStateErrorImplCopyWith<_$RecipesStateErrorImpl> get copyWith =>
|
||||
@@ -640,7 +679,8 @@ class _$RecipesStateErrorImpl implements RecipesStateError {
|
||||
List<Recipes> recipesList,
|
||||
List<RecipeTag> recipesTags,
|
||||
Set<int> selectedTags,
|
||||
int selectedTagsCounter)
|
||||
int selectedTagsCounter,
|
||||
bool isLoading)
|
||||
loaded,
|
||||
required TResult Function(String errorMessage) error,
|
||||
}) {
|
||||
@@ -653,7 +693,7 @@ class _$RecipesStateErrorImpl implements RecipesStateError {
|
||||
TResult? Function()? $default, {
|
||||
TResult? Function()? loading,
|
||||
TResult? Function(List<Recipes> recipesList, List<RecipeTag> recipesTags,
|
||||
Set<int> selectedTags, int selectedTagsCounter)?
|
||||
Set<int> selectedTags, int selectedTagsCounter, bool isLoading)?
|
||||
loaded,
|
||||
TResult? Function(String errorMessage)? error,
|
||||
}) {
|
||||
@@ -666,7 +706,7 @@ class _$RecipesStateErrorImpl implements RecipesStateError {
|
||||
TResult Function()? $default, {
|
||||
TResult Function()? loading,
|
||||
TResult Function(List<Recipes> recipesList, List<RecipeTag> recipesTags,
|
||||
Set<int> selectedTags, int selectedTagsCounter)?
|
||||
Set<int> selectedTags, int selectedTagsCounter, bool isLoading)?
|
||||
loaded,
|
||||
TResult Function(String errorMessage)? error,
|
||||
required TResult orElse(),
|
||||
@@ -720,7 +760,10 @@ abstract class RecipesStateError implements RecipesState {
|
||||
_$RecipesStateErrorImpl;
|
||||
|
||||
String get errorMessage;
|
||||
@JsonKey(ignore: true)
|
||||
|
||||
/// Create a copy of RecipesState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
_$$RecipesStateErrorImplCopyWith<_$RecipesStateErrorImpl> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
@@ -10,11 +10,12 @@ import 'package:eatvio_app/features/feed/presentation/widgets/diets_widget.dart'
|
||||
import 'package:eatvio_app/features/feed/presentation/widgets/recipes_widget.dart';
|
||||
import 'package:eatvio_app/features/feed/presentation/widgets/tags_modal_widget.dart';
|
||||
import 'package:eatvio_app/theme/theme_helper.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
|
||||
final bucket = PageStorageBucket();
|
||||
|
||||
class FeedScreen extends StatefulWidget {
|
||||
const FeedScreen({super.key});
|
||||
|
||||
@@ -32,11 +33,25 @@ class _FeedScreenState extends State<FeedScreen> {
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
blogPostsScrollController.addListener(_onScroll);
|
||||
blogPostsScrollController.addListener(_onScrollBlogPosts);
|
||||
recipesScrollController.addListener(_onScrollBlogRecipes);
|
||||
dietsScrollController.addListener(_onScrollBlogDiets);
|
||||
super.initState();
|
||||
}
|
||||
|
||||
_onScroll() {
|
||||
_onScrollBlogPosts() {
|
||||
if (blogPostsScrollController.offset >= blogPostsScrollController.position.maxScrollExtent && !blogPostsScrollController.position.outOfRange) {
|
||||
context.read<FeedCubit>().loadNextPage();
|
||||
}
|
||||
}
|
||||
|
||||
_onScrollBlogRecipes() {
|
||||
if (blogPostsScrollController.offset >= blogPostsScrollController.position.maxScrollExtent && !blogPostsScrollController.position.outOfRange) {
|
||||
context.read<FeedCubit>().loadNextPage();
|
||||
}
|
||||
}
|
||||
|
||||
_onScrollBlogDiets() {
|
||||
if (blogPostsScrollController.offset >= blogPostsScrollController.position.maxScrollExtent && !blogPostsScrollController.position.outOfRange) {
|
||||
context.read<FeedCubit>().loadNextPage();
|
||||
}
|
||||
@@ -45,6 +60,8 @@ class _FeedScreenState extends State<FeedScreen> {
|
||||
@override
|
||||
void dispose() {
|
||||
blogPostsScrollController.dispose();
|
||||
recipesScrollController.dispose();
|
||||
dietsScrollController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@@ -89,7 +106,11 @@ class _FeedScreenState extends State<FeedScreen> {
|
||||
),
|
||||
backgroundColor: Colors.grey.shade200,
|
||||
body: NestedScrollView(
|
||||
controller: blogPostsScrollController,
|
||||
controller: _selectedChipIndex == 0
|
||||
? blogPostsScrollController
|
||||
: _selectedChipIndex == 1
|
||||
? recipesScrollController
|
||||
: dietsScrollController,
|
||||
headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) {
|
||||
return [
|
||||
SliverAppBar(
|
||||
@@ -139,10 +160,10 @@ class _FeedScreenState extends State<FeedScreen> {
|
||||
return ListView.separated(
|
||||
padding: EdgeInsets.symmetric(vertical: 8),
|
||||
shrinkWrap: true,
|
||||
physics: NeverScrollableScrollPhysics(),
|
||||
physics: BouncingScrollPhysics(),
|
||||
itemBuilder: (context, index) {
|
||||
if (index == state.feedBlogPostList.length) {
|
||||
return CupertinoActivityIndicator();
|
||||
return CircularProgressIndicator();
|
||||
}
|
||||
return BlogPostWidget(feedBlogPostModel: state.feedBlogPostList[index]);
|
||||
},
|
||||
@@ -165,7 +186,7 @@ class _FeedScreenState extends State<FeedScreen> {
|
||||
return Scaffold(
|
||||
backgroundColor: Colors.grey.shade200,
|
||||
body: Center(
|
||||
child: CupertinoActivityIndicator(),
|
||||
child: CircularProgressIndicator(),
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -206,7 +227,7 @@ class _FeedScreenState extends State<FeedScreen> {
|
||||
return Scaffold(
|
||||
backgroundColor: Colors.grey.shade200,
|
||||
body: Center(
|
||||
child: CupertinoActivityIndicator(),
|
||||
child: CircularProgressIndicator(),
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -247,7 +268,7 @@ class _FeedScreenState extends State<FeedScreen> {
|
||||
return Scaffold(
|
||||
backgroundColor: Colors.grey.shade200,
|
||||
body: Center(
|
||||
child: CupertinoActivityIndicator(),
|
||||
child: CircularProgressIndicator(),
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -319,6 +340,7 @@ class _FeedScreenState extends State<FeedScreen> {
|
||||
switch (_selectedChipIndex) {
|
||||
case 1:
|
||||
context.read<RecipesCubit>().loadRecipesList(query: query);
|
||||
break;
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user