feat(push_notifications): issue-660, fix: issue-908

This commit is contained in:
misha
2026-10-14 08:16:20 +03:00
parent 98c175df44
commit dcd343e765
29 changed files with 2281 additions and 608 deletions

View File

@@ -11,6 +11,7 @@ import 'package:eatvio_app/core/widgets/markdown_html_widget.dart';
import 'package:eatvio_app/features/diets/presentation/widgets/info_bouble.dart';
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';
@@ -37,7 +38,14 @@ class _PlanWidgetState extends State<PlanWidget> {
Widget build(BuildContext context) {
final s = S.of(context);
return InkWell(
onTap: () => GoRouter.of(context).pushNamed('aboutPlanScreen', extra: {'slug': widget.plan.slug, 'index': widget.index, 'navigateToComments': false}),
onTap: () => GoRouter.of(context).pushNamed(
'aboutPlanScreen',
extra: {
'slug': widget.plan.slug,
'index': widget.index,
'navigateToComments': false,
},
),
child: Material(
borderRadius: BorderRadius.circular(12),
color: Colors.white,
@@ -48,9 +56,12 @@ class _PlanWidgetState extends State<PlanWidget> {
Stack(
children: [
ClipRRect(
borderRadius: const BorderRadius.vertical(top: Radius.circular(12)),
borderRadius: const BorderRadius.vertical(
top: Radius.circular(12),
),
child: CachedNetworkImage(
imageUrl: '${sl<AppConfig>().baseUrl}/storage/${widget.plan.image}',
imageUrl:
'${sl<AppConfig>().baseUrl}/storage/${widget.plan.image}',
fit: BoxFit.cover,
width: MediaQuery.of(context).size.width,
height: 426,
@@ -61,14 +72,22 @@ class _PlanWidgetState extends State<PlanWidget> {
child: BookmarkButton(
onTap: () async {
if (widget.plan.isFavorite) {
await context.read<PlansCubit>().removePlanFromFavorite(widget.plan.slug, widget.index);
await context.read<PlansCubit>().removePlanFromFavorite(
widget.plan.slug,
widget.index,
);
} else {
await context.read<PlansCubit>().addPlanToFavorite(widget.plan.slug, widget.index);
await context.read<PlansCubit>().addPlanToFavorite(
widget.plan.slug,
widget.index,
);
}
},
color: appTheme.whiteA700,
isFavorite: widget.plan.isFavorite,
borderRadius: const BorderRadius.vertical(bottom: Radius.circular(12)),
borderRadius: const BorderRadius.vertical(
bottom: Radius.circular(12),
),
width: 40,
height: 44,
size: 19,
@@ -100,7 +119,12 @@ class _PlanWidgetState extends State<PlanWidget> {
bottom: 16,
child: SizedBox(
width: MediaQuery.sizeOf(context).width,
child: InfoRow(plan: widget.plan, itemsBackgroundColor: appTheme.whiteA700, disableDescriptionOfTypes: true, type: ProductType.plan),
child: InfoRow(
plan: widget.plan,
itemsBackgroundColor: appTheme.whiteA700,
disableDescriptionOfTypes: true,
type: ProductType.plan,
),
),
),
],
@@ -111,14 +135,22 @@ class _PlanWidgetState extends State<PlanWidget> {
children: [
Padding(
padding: const EdgeInsets.symmetric(horizontal: 16),
child: Text(widget.plan.name, style: TextStyles.textMSemibold.copyWith(color: appTheme.black, fontSize: 18)),
child: Text(
widget.plan.name,
style: TextStyles.textMSemibold.copyWith(
color: appTheme.black,
fontSize: 18,
),
),
),
if (widget.plan.details.isNotEmpty) ...[
const SizedBox(height: 12),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 16),
child: MarkdownHtmlWidget(
markdownText: widget.plan.details.length > 200 ? '${widget.plan.details.substring(0, 200)}...' : widget.plan.details,
markdownText: widget.plan.details.length > 200
? '${widget.plan.details.substring(0, 200)}...'
: widget.plan.details,
textColor: appTheme.black,
),
),
@@ -127,7 +159,12 @@ class _PlanWidgetState extends State<PlanWidget> {
padding: EdgeInsets.only(left: 16, top: 8),
child: Text(
'Показать ещё',
style: TextStyle(height: 1, color: Color(0xFF8B8B8B), fontSize: 14, fontWeight: FontWeight.w600),
style: TextStyle(
height: 1,
color: Color(0xFF8B8B8B),
fontSize: 14,
fontWeight: FontWeight.w600,
),
),
),
],
@@ -136,7 +173,10 @@ class _PlanWidgetState extends State<PlanWidget> {
const SizedBox(height: 16),
GestureDetector(
onTap: () {
GoRouter.of(context).pushNamed('profileScreen', extra: widget.plan.author.authorSlug);
GoRouter.of(context).pushNamed(
'profileScreen',
extra: widget.plan.author.authorSlug,
);
},
child: Padding(
padding: const EdgeInsets.only(left: 16.0),
@@ -147,7 +187,15 @@ class _PlanWidgetState extends State<PlanWidget> {
height: 46,
decoration: BoxDecoration(
shape: BoxShape.circle,
image: DecorationImage(image: NetworkImage(sl<AppConfig>().baseUrl + widget.plan.author.authorProfileIcon), fit: BoxFit.cover),
image: DecorationImage(
image: NetworkImage(
joinBaseUrl(
sl<AppConfig>().baseUrl,
widget.plan.author.authorProfileIcon,
),
),
fit: BoxFit.cover,
),
),
),
subtitle: Row(
@@ -155,22 +203,37 @@ class _PlanWidgetState extends State<PlanWidget> {
InfoBouble(
radius: 12,
backgroundColor: appTheme.gray50,
padding: const EdgeInsets.symmetric(vertical: 4, horizontal: 10),
padding: const EdgeInsets.symmetric(
vertical: 4,
horizontal: 10,
),
children: [
Text('${widget.plan.author.authorPlaceInRating}-й в рейтинге', style: TextStyles.textXSSemibold.copyWith(color: appTheme.blueA400)),
Text(
'${widget.plan.author.authorPlaceInRating}-й в рейтинге',
style: TextStyles.textXSSemibold.copyWith(
color: appTheme.blueA400,
),
),
],
),
const Spacer(),
Text(
'${widget.plan.packetsCount == 1 ? widget.plan.packet1Options?.price : '${s.from} ${widget.plan.minPriceOfOptions.toStringAsFixed(0)}'}₽',
style: TextStyles.headingXLSemibold.copyWith(color: appTheme.greenA700),
style: TextStyles.headingXLSemibold.copyWith(
color: appTheme.greenA700,
),
),
const SizedBox(width: 16),
],
),
title: Padding(
padding: const EdgeInsets.only(bottom: 4.0),
child: Text(widget.plan.author.authorName, style: TextStyles.textSSemibold.copyWith(color: appTheme.black)),
child: Text(
widget.plan.author.authorName,
style: TextStyles.textSSemibold.copyWith(
color: appTheme.black,
),
),
),
),
),
@@ -181,12 +244,21 @@ class _PlanWidgetState extends State<PlanWidget> {
child: Row(
children: [
FeedIconButton(
icon: widget.plan.wasLikedByMe ? Icons.favorite_rounded : Icons.favorite_border_rounded,
icon: widget.plan.wasLikedByMe
? Icons.favorite_rounded
: Icons.favorite_border_rounded,
text: widget.plan.totalLikes.toString(),
iconColor: widget.plan.wasLikedByMe ? appTheme.blueA400 : null,
backgroundColor: widget.plan.wasLikedByMe ? appTheme.transparentBlue : null,
iconColor: widget.plan.wasLikedByMe
? appTheme.blueA400
: null,
backgroundColor: widget.plan.wasLikedByMe
? appTheme.transparentBlue
: null,
onTap: () async {
await context.read<PlansCubit>().likePlan(widget.plan.slug, widget.index);
await context.read<PlansCubit>().likePlan(
widget.plan.slug,
widget.index,
);
},
),
const SizedBox(width: 12),
@@ -194,9 +266,14 @@ class _PlanWidgetState extends State<PlanWidget> {
icon: Icons.chat_bubble_outline,
text: widget.plan.totalComments.toString(),
onTap: () {
return GoRouter.of(
context,
).pushNamed('aboutPlanScreen', extra: {'slug': widget.plan.slug, 'index': widget.index, 'navigateToComments': true});
return GoRouter.of(context).pushNamed(
'aboutPlanScreen',
extra: {
'slug': widget.plan.slug,
'index': widget.index,
'navigateToComments': true,
},
);
},
),
const SizedBox(width: 12),
@@ -206,8 +283,11 @@ class _PlanWidgetState extends State<PlanWidget> {
final box = context.findRenderObject() as RenderBox?;
final result = await SharePlus.instance.share(
ShareParams(
uri: Uri.parse('${sl<AppConfig>().baseUrl}/ru/diet/${widget.plan.id}'),
sharePositionOrigin: box!.localToGlobal(Offset.zero) & box.size,
uri: Uri.parse(
'${sl<AppConfig>().baseUrl}/ru/diet/${widget.plan.id}',
),
sharePositionOrigin:
box!.localToGlobal(Offset.zero) & box.size,
),
);
switch (result.status) {