plans filters ready

This commit is contained in:
Username1548
2024-12-16 20:31:23 +07:00
parent 067b10ed7f
commit 27241aebac
45 changed files with 1806 additions and 657 deletions

View File

@@ -14,7 +14,7 @@ class AboutDietCubit extends Cubit<AboutDietState> {
try {
final diet = await dietsRepository.getDiet(id);
if (index != null) {
dietsRepository.emitCommentsStateToFeed(DietCommentsState(index: index, totalComments: diet.totalComments));
dietsRepository.emitCommentsStateToFeed(CommentsState(index: index, totalComments: diet.totalComments));
}
emit(AboutDietState.loaded(diet));
} catch (e) {
@@ -42,7 +42,7 @@ class AboutDietCubit extends Cubit<AboutDietState> {
totalLikes: currentDiet.totalLikes - 1,
wasLikedByMe: false,
);
dietsRepository.emitLikesStateToFeed(DietLikesState(wasLikedByMe: updatedDiet.wasLikedByMe, totalLikes: updatedDiet.totalLikes, index: dietIndexInFeed));
dietsRepository.emitLikesStateToFeed(LikesState(wasLikedByMe: updatedDiet.wasLikedByMe, totalLikes: updatedDiet.totalLikes, index: dietIndexInFeed));
emit(AboutDietState.loaded(updatedDiet));
} else {
final updatedDiet = currentDiet.copyWith(
@@ -50,7 +50,7 @@ class AboutDietCubit extends Cubit<AboutDietState> {
wasLikedByMe: true,
);
dietsRepository.emitLikesStateToFeed(DietLikesState(wasLikedByMe: updatedDiet.wasLikedByMe, totalLikes: updatedDiet.totalLikes, index: dietIndexInFeed));
dietsRepository.emitLikesStateToFeed(LikesState(wasLikedByMe: updatedDiet.wasLikedByMe, totalLikes: updatedDiet.totalLikes, index: dietIndexInFeed));
emit(AboutDietState.loaded(updatedDiet));
}
@@ -62,15 +62,14 @@ class AboutDietCubit extends Cubit<AboutDietState> {
await dietsRepository.likeDiet(id);
} catch (e) {
log(e.toString());
dietsRepository
.emitLikesStateToFeed(DietLikesState(wasLikedByMe: currentDiet.wasLikedByMe, totalLikes: currentDiet.totalLikes, index: dietIndexInFeed));
dietsRepository.emitLikesStateToFeed(LikesState(wasLikedByMe: currentDiet.wasLikedByMe, totalLikes: currentDiet.totalLikes, index: dietIndexInFeed));
emit(AboutDietState.loaded(currentDiet));
}
},
);
}
Future<void> addToFavorite(int id, int dietIndexInFeed) async {
Future<void> addToFavorite(int id, int dietIndex) async {
if (state is! DietStateLoaded) return;
final currentDiet = (state as DietStateLoaded).diet;
@@ -78,11 +77,11 @@ class AboutDietCubit extends Cubit<AboutDietState> {
final updatedDiet = currentDiet.copyWith(
isFavorite: true,
);
dietsRepository.emitFavoriteStateToFeed(DietFavoriteState(isFavorite: updatedDiet.isFavorite, index: dietIndexInFeed));
dietsRepository.emitFavoriteStateToFeed(FavoriteState(isFavorite: updatedDiet.isFavorite, index: dietIndex));
emit(AboutDietState.loaded(updatedDiet));
EasyDebounce.debounce(
'add_diet_to_favorites',
'add_or_remove_diet_to_favorites',
Duration(seconds: 1),
() async {
try {
@@ -90,14 +89,14 @@ class AboutDietCubit extends Cubit<AboutDietState> {
} catch (e) {
log(e.toString());
showErrorToast('Произошла ошибка. Попробуйте ещё раз через некоторое время');
dietsRepository.emitFavoriteStateToFeed(DietFavoriteState(isFavorite: currentDiet.isFavorite, index: dietIndexInFeed));
dietsRepository.emitFavoriteStateToFeed(FavoriteState(isFavorite: currentDiet.isFavorite, index: dietIndex));
emit(AboutDietState.loaded(currentDiet));
}
},
);
}
Future<void> removeFromFavorite(int id, int dietIndexInFeed) async {
Future<void> removeFromFavorite(int id, int dietIndex) async {
if (state is! DietStateLoaded) return;
final currentDiet = (state as DietStateLoaded).diet;
@@ -105,11 +104,11 @@ class AboutDietCubit extends Cubit<AboutDietState> {
final updatedDiet = currentDiet.copyWith(
isFavorite: false,
);
dietsRepository.emitFavoriteStateToFeed(DietFavoriteState(isFavorite: updatedDiet.isFavorite, index: dietIndexInFeed));
dietsRepository.emitFavoriteStateToFeed(FavoriteState(isFavorite: updatedDiet.isFavorite, index: dietIndex));
emit(AboutDietState.loaded(updatedDiet));
EasyDebounce.debounce(
'remove_diet_from_favorites',
'add_or_remove_diet_to_favorites',
Duration(seconds: 1),
() async {
try {
@@ -117,7 +116,7 @@ class AboutDietCubit extends Cubit<AboutDietState> {
} catch (e) {
log(e.toString());
showErrorToast('Произошла ошибка. Попробуйте ещё раз через некоторое время');
dietsRepository.emitFavoriteStateToFeed(DietFavoriteState(isFavorite: currentDiet.isFavorite, index: dietIndexInFeed));
dietsRepository.emitFavoriteStateToFeed(FavoriteState(isFavorite: currentDiet.isFavorite, index: dietIndex));
emit(AboutDietState.loaded(currentDiet));
}
},

View File

@@ -128,7 +128,7 @@ class _AboutDietScreenState extends State<AboutDietScreen> {
elevation: 0,
focusElevation: 0,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(16),
borderRadius: BorderRadius.circular(20),
),
backgroundColor: appTheme.greenA700,
onPressed: () {
@@ -159,7 +159,8 @@ class _AboutDietScreenState extends State<AboutDietScreen> {
width: 52,
height: 52,
size: 24,
shape: BoxShape.circle,
shape: BoxShape.rectangle,
borderRadius: BorderRadius.circular(20),
color: appTheme.gray50,
),
],

View File

@@ -11,8 +11,7 @@ class AuthorCard extends StatelessWidget {
final Author author;
final String title;
@override
Widget build(BuildContext context) {
// final s = S.of(context);
Widget build(BuildContext context) {
return Container(
width: MediaQuery.sizeOf(context).width,
decoration: BoxDecoration(borderRadius: BorderRadius.circular(12), color: appTheme.cardBackground),

View File

@@ -32,39 +32,42 @@ class _ExpandableTextState extends State<ExpandableText> {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Stack(
children: [
Html(
data: widget.text,
style: {
"*": Style(
color: Colors.black87,
maxLines: isExpanded ? null : widget.maxLines,
textOverflow: TextOverflow.clip,
),
},
),
if (!isExpanded)
Positioned.fill(
child: Align(
alignment: Alignment.bottomCenter,
child: Container(
height: 35,
decoration: BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: [
Colors.white.withOpacity(0.0),
Colors.white.withOpacity(0.6),
Colors.white,
],
Padding(
padding: const EdgeInsets.symmetric(horizontal: 16),
child: Stack(
children: [
Html(
data: widget.text,
style: {
"*": Style(
color: Colors.black87,
maxLines: isExpanded ? null : widget.maxLines,
textOverflow: TextOverflow.clip,
),
},
),
if (!isExpanded)
Positioned.fill(
child: Align(
alignment: Alignment.bottomCenter,
child: Container(
height: 35,
decoration: BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: [
Colors.white.withOpacity(0.0),
Colors.white.withOpacity(0.6),
Colors.white,
],
),
),
),
),
),
),
],
],
),
),
Align(
alignment: Alignment.bottomCenter,