forked from eatvio/eatvio_app
Merge remote-tracking branch 'upstream/main' into issue-851
# Conflicts: # lib/features/feed/presentation/widgets/plan_widget.dart # lib/features/profile/presentation/pages/profile_screen.dart
This commit is contained in:
@@ -13,10 +13,8 @@ import 'package:eatvio_app/features/feed/models/plan_pagination_model.dart';
|
||||
import 'package:eatvio_app/core/theme/custom_text_style.dart';
|
||||
import 'package:eatvio_app/core/utils/url_utils.dart';
|
||||
import 'package:eatvio_app/core/theme/theme_helper.dart';
|
||||
import 'package:eatvio_app/features/feed/presentation/bloc/plans_cubit/plans_cubit.dart';
|
||||
import 'package:eatvio_app/generated/l10n.dart';
|
||||
import 'package:material_ui/material_ui.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:flutter_svg/flutter_svg.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:share_plus/share_plus.dart';
|
||||
@@ -25,12 +23,18 @@ class PlanWidget extends StatefulWidget {
|
||||
final PlanModel plan;
|
||||
final int index;
|
||||
final bool showPriceOnCover;
|
||||
final Future<void> Function(String slug)? onLikeTap;
|
||||
final Future<void> Function(String slug, bool isFavorite)? onToggleFavorite;
|
||||
final VoidCallback? onPlanChanged;
|
||||
|
||||
const PlanWidget({
|
||||
super.key,
|
||||
required this.plan,
|
||||
required this.index,
|
||||
this.showPriceOnCover = false,
|
||||
this.onLikeTap,
|
||||
this.onToggleFavorite,
|
||||
this.onPlanChanged,
|
||||
});
|
||||
|
||||
@override
|
||||
@@ -81,17 +85,10 @@ class _PlanWidgetState extends State<PlanWidget> {
|
||||
left: 14,
|
||||
child: BookmarkButton(
|
||||
onTap: () async {
|
||||
if (widget.plan.isFavorite) {
|
||||
await context.read<PlansCubit>().removePlanFromFavorite(
|
||||
widget.plan.slug,
|
||||
widget.index,
|
||||
);
|
||||
} else {
|
||||
await context.read<PlansCubit>().addPlanToFavorite(
|
||||
widget.plan.slug,
|
||||
widget.index,
|
||||
);
|
||||
}
|
||||
await widget.onToggleFavorite?.call(
|
||||
widget.plan.slug,
|
||||
widget.plan.isFavorite,
|
||||
);
|
||||
},
|
||||
color: appTheme.whiteA700,
|
||||
isFavorite: widget.plan.isFavorite,
|
||||
@@ -121,6 +118,7 @@ class _PlanWidgetState extends State<PlanWidget> {
|
||||
plan: widget.plan,
|
||||
complainedContentType: ComplainedContent.plan,
|
||||
userSlug: widget.plan.author.authorSlug,
|
||||
onPlanChanged: widget.onPlanChanged,
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -236,22 +234,25 @@ class _PlanWidgetState extends State<PlanWidget> {
|
||||
),
|
||||
subtitle: Row(
|
||||
children: [
|
||||
InfoBouble(
|
||||
radius: 12,
|
||||
backgroundColor: appTheme.gray50,
|
||||
padding: const EdgeInsets.symmetric(
|
||||
vertical: 4,
|
||||
horizontal: 10,
|
||||
),
|
||||
children: [
|
||||
Text(
|
||||
'${widget.plan.author.authorPlaceInRating}-й в рейтинге',
|
||||
style: TextStyles.textXSSemibold.copyWith(
|
||||
color: appTheme.blueA400,
|
||||
),
|
||||
if (widget.plan.author.authorPlaceInRating != null)
|
||||
InfoBouble(
|
||||
radius: 12,
|
||||
backgroundColor: appTheme.gray50,
|
||||
padding: const EdgeInsets.symmetric(
|
||||
vertical: 4,
|
||||
horizontal: 10,
|
||||
),
|
||||
],
|
||||
),
|
||||
children: [
|
||||
Text(
|
||||
s.rating_place(
|
||||
widget.plan.author.authorPlaceInRating!,
|
||||
),
|
||||
style: TextStyles.textXSSemibold.copyWith(
|
||||
color: appTheme.blueA400,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
if (!widget.showPriceOnCover) ...[
|
||||
const Spacer(),
|
||||
Text(
|
||||
@@ -293,10 +294,7 @@ class _PlanWidgetState extends State<PlanWidget> {
|
||||
? appTheme.transparentBlue
|
||||
: null,
|
||||
onTap: () async {
|
||||
await context.read<PlansCubit>().likePlan(
|
||||
widget.plan.slug,
|
||||
widget.index,
|
||||
);
|
||||
await widget.onLikeTap?.call(widget.plan.slug);
|
||||
},
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
|
||||
@@ -44,7 +44,15 @@ class Plans extends StatelessWidget {
|
||||
final id = state.plans[index].id;
|
||||
handleVisibility(visibleFraction: info.visibleFraction, id: id, type: ViewableContentType.plans);
|
||||
},
|
||||
child: PlanWidget(plan: state.plans[index], index: index),
|
||||
child: PlanWidget(
|
||||
plan: state.plans[index],
|
||||
index: index,
|
||||
onLikeTap: (slug) => context.read<PlansCubit>().likePlan(slug, index),
|
||||
onToggleFavorite: (slug, isFavorite) => isFavorite
|
||||
? context.read<PlansCubit>().removePlanFromFavorite(slug, index)
|
||||
: context.read<PlansCubit>().addPlanToFavorite(slug, index),
|
||||
onPlanChanged: () => context.read<PlansCubit>().loadPlans(),
|
||||
),
|
||||
);
|
||||
},
|
||||
separatorBuilder: (context, index) {
|
||||
|
||||
Reference in New Issue
Block a user