updated error handling, consultant rating layout and complaining logic

This commit is contained in:
Username1548
2025-02-28 19:18:01 +07:00
parent e5b293db79
commit 0cdd40102f
86 changed files with 3853 additions and 279 deletions

View File

@@ -3,11 +3,13 @@ import 'dart:io';
import 'package:cached_network_image/cached_network_image.dart';
import 'package:eatvio_app/core/const.dart';
import 'package:eatvio_app/core/utils/enums.dart';
import 'package:eatvio_app/core/enums/complained_content.dart';
import 'package:eatvio_app/core/enums/product_type.dart';
import 'package:eatvio_app/core/utils/localization_utils.dart';
import 'package:eatvio_app/core/utils/string_extentions.dart';
import 'package:eatvio_app/core/utils/toasts.dart';
import 'package:eatvio_app/core/widgets/bookmark_button.dart';
import 'package:eatvio_app/core/widgets/data_error_widget.dart';
import 'package:eatvio_app/core/widgets/info_row.dart';
import 'package:eatvio_app/core/widgets/loader.dart';
import 'package:eatvio_app/features/diets/presentation/widgets/author_card.dart';
@@ -243,7 +245,9 @@ class _AboutRecipeScreenState extends State<AboutRecipeScreen> {
PortalTarget(
visible: isMoreOptionsVisible,
portalFollower: MoreOptions(
complainedContentType: ComplainedContent.recipe,
path: 'recipe/${widget.recipe.slug}',
slug: widget.recipe.slug,
),
anchor: Aligned(
shiftToWithinBound: AxisFlag(x: true, y: true),
@@ -460,7 +464,90 @@ class _AboutRecipeScreenState extends State<AboutRecipeScreen> {
),
);
}
if (recipeState is RecipeStateError) {
return Scaffold(
appBar: AppBar(
centerTitle: true,
title: Text(
widget.recipe.title ?? '',
maxLines: 2,
textAlign: TextAlign.center,
overflow: TextOverflow.ellipsis,
softWrap: true,
style: TextStyles.headingXLSemibold.copyWith(color: appTheme.black),
),
actions: [
PortalTarget(
visible: isMoreOptionsVisible,
portalFollower: MoreOptions(
complainedContentType: ComplainedContent.recipe,
path: 'recipe/${widget.recipe.slug}',
slug: widget.recipe.slug,
),
anchor: Aligned(
shiftToWithinBound: AxisFlag(x: true, y: true),
follower: Alignment.topRight,
target: Alignment.bottomRight,
),
child: IconButton(
onPressed: () {
setState(() {
isMoreOptionsVisible = !isMoreOptionsVisible;
});
},
icon: SvgPicture.asset(
'assets/icons/more_button.svg',
width: 20,
height: 20,
),
),
),
],
),
body: DataErrorWidget(
onReload: () => context.read<AboutRecipeCubit>().getRecipe(widget.recipe.slug, index: widget.index),
),
);
}
return Scaffold(
appBar: AppBar(
centerTitle: true,
title: Text(
widget.recipe.title ?? '',
maxLines: 2,
textAlign: TextAlign.center,
overflow: TextOverflow.ellipsis,
softWrap: true,
style: TextStyles.headingXLSemibold.copyWith(color: appTheme.black),
),
actions: [
PortalTarget(
visible: isMoreOptionsVisible,
portalFollower: MoreOptions(
complainedContentType: ComplainedContent.recipe,
path: 'recipe/${widget.recipe.slug}',
slug: widget.recipe.slug,
),
anchor: Aligned(
shiftToWithinBound: AxisFlag(x: true, y: true),
follower: Alignment.topRight,
target: Alignment.bottomRight,
),
child: IconButton(
onPressed: () {
setState(() {
isMoreOptionsVisible = !isMoreOptionsVisible;
});
},
icon: SvgPicture.asset(
'assets/icons/more_button.svg',
width: 20,
height: 20,
),
),
),
],
),
body: const Loader(),
);
},

View File

@@ -9,8 +9,7 @@ import 'package:eatvio_app/features/recipe/presentation/cubit/about_recipe_state
import 'package:flutter_bloc/flutter_bloc.dart';
class AboutRecipeCubit extends Cubit<AboutRecipeState> {
AboutRecipeCubit({required this.recipeRepository, required this.profileRepository })
: super(AboutRecipeState.initial());
AboutRecipeCubit({required this.recipeRepository, required this.profileRepository}) : super(AboutRecipeState.initial());
final AboutRecipeRepository recipeRepository;
final ProfileRepository profileRepository;
bool isCurrentDietStarted = false;
@@ -26,6 +25,7 @@ class AboutRecipeCubit extends Cubit<AboutRecipeState> {
emit(AboutRecipeState.loaded(recipe: recipe));
} catch (e) {
log(e.toString());
emit(AboutRecipeState.error(message: e.toString()));
}
}
@@ -39,6 +39,7 @@ class AboutRecipeCubit extends Cubit<AboutRecipeState> {
emit(AboutRecipeState.loaded(recipe: recipe));
} catch (e) {
log(e.toString());
emit(AboutRecipeState.error(message: e.toString()));
}
}
@@ -53,7 +54,8 @@ class AboutRecipeCubit extends Cubit<AboutRecipeState> {
wasLikedByMe: false,
);
if (recipeIndexInFeed != null) {
recipeRepository.emitLikesStateToFeed(LikesState(wasLikedByMe: updatedRecipe.wasLikedByMe, totalLikes: updatedRecipe.likesCount, index: recipeIndexInFeed));
recipeRepository
.emitLikesStateToFeed(LikesState(wasLikedByMe: updatedRecipe.wasLikedByMe, totalLikes: updatedRecipe.likesCount, index: recipeIndexInFeed));
}
emit(AboutRecipeState.loaded(recipe: updatedRecipe));
} else {
@@ -62,7 +64,8 @@ class AboutRecipeCubit extends Cubit<AboutRecipeState> {
wasLikedByMe: true,
);
if (recipeIndexInFeed != null) {
recipeRepository.emitLikesStateToFeed(LikesState(wasLikedByMe: updatedRecipe.wasLikedByMe, totalLikes: updatedRecipe.likesCount, index: recipeIndexInFeed));
recipeRepository
.emitLikesStateToFeed(LikesState(wasLikedByMe: updatedRecipe.wasLikedByMe, totalLikes: updatedRecipe.likesCount, index: recipeIndexInFeed));
}
emit(AboutRecipeState.loaded(recipe: updatedRecipe));
}
@@ -145,5 +148,5 @@ class AboutRecipeCubit extends Cubit<AboutRecipeState> {
}
},
);
}
}
}