forked from eatvio/eatvio_app
1423 lines
60 KiB
Dart
1423 lines
60 KiB
Dart
import 'package:eatvio_app/core/const.dart';
|
||
import 'package:eatvio_app/core/routing/route_constants.dart';
|
||
import 'package:eatvio_app/core/theme/custom_text_style.dart';
|
||
import 'package:eatvio_app/features/bottom_navigation_bar/presentation/widgets/bottom_nav_scope.dart';
|
||
import 'package:eatvio_app/core/theme/theme_helper.dart';
|
||
import 'package:eatvio_app/core/utils/date_time_utils.dart';
|
||
import 'package:eatvio_app/core/widgets/custom_outlined_button.dart';
|
||
import 'package:eatvio_app/features/diary/presentation/pages/diary_screen.dart';
|
||
import 'package:eatvio_app/features/my_finance/presentation/pages/card_settings.dart';
|
||
import 'package:eatvio_app/features/notifications/models/notification_model.dart';
|
||
import 'package:eatvio_app/features/profile/presentation/pages/subs_screen.dart';
|
||
import 'package:eatvio_app/generated/l10n.dart';
|
||
import 'package:flutter/material.dart';
|
||
import 'package:go_router/go_router.dart';
|
||
|
||
class NotificationWidget extends StatelessWidget {
|
||
const NotificationWidget({super.key, required this.notification});
|
||
final BaseNotificationModel notification;
|
||
|
||
@override
|
||
Widget build(BuildContext context) {
|
||
return switch (notification) {
|
||
PlanSubscriptionStartedToAuthorNotification() => _PlanSubscriptionStartedToAuthorWidget(
|
||
notification: notification as PlanSubscriptionStartedToAuthorNotification,
|
||
),
|
||
PlanSubscriptionCanceledToAuthorNotification() => _PlanSubscriptionCanceledToAuthorWidget(
|
||
notification: notification as PlanSubscriptionCanceledToAuthorNotification,
|
||
),
|
||
ChosenPlanStartedToClientNotification() => _ChosenPlanStartedToClientWidget(notification: notification as ChosenPlanStartedToClientNotification),
|
||
ChosenPlanTomorrowReminderToClientNotification() => _ChosenPlanTomorrowReminderToClientWidget(
|
||
notification: notification as ChosenPlanTomorrowReminderToClientNotification,
|
||
),
|
||
DiaryReminderNotification() => _DiaryReminderWidget(notification: notification as DiaryReminderNotification),
|
||
ConsultantLeftCommentNotification() => _ConsultantLeftCommentWidget(notification: notification as ConsultantLeftCommentNotification),
|
||
PersonalizedDietIsDefinedNotification() => _PersonalizedDietIsDefinedWidget(notification: notification as PersonalizedDietIsDefinedNotification),
|
||
ChosenPlanFinishedToClientNotification() => _ChosenPlanFinishedToClientWidget(notification: notification as ChosenPlanFinishedToClientNotification),
|
||
PlanSubscriptionCanceledToCustomerNotification() => _PlanSubscriptionCanceledToCustomerWidget(
|
||
notification: notification as PlanSubscriptionCanceledToCustomerNotification,
|
||
),
|
||
ChosenPlanStartedToConsultantNotification() => _ChosenPlanStartedToConsultantWidget(
|
||
notification: notification as ChosenPlanStartedToConsultantNotification,
|
||
),
|
||
ChosenPlanTomorrowReminderToConsultantNotification() => _ChosenPlanTomorrowReminderToConsultantWidget(
|
||
notification: notification as ChosenPlanTomorrowReminderToConsultantNotification,
|
||
),
|
||
PlanSubscriptionPaidToAuthorNotification() => _PlanSubscriptionPaidToAuthorWidget(notification: notification as PlanSubscriptionPaidToAuthorNotification),
|
||
ChosenPlanFinishedToConsultantNotification() => _ChosenPlanFinishedToConsultantWidget(
|
||
notification: notification as ChosenPlanFinishedToConsultantNotification,
|
||
),
|
||
ChosenPlanLastDayFinishedForUser() => _ChosenPlanLastDayFinishedForUserWidget(notification: notification as ChosenPlanLastDayFinishedForUser),
|
||
ChosenPlanConsultantLastDayStarted() => _ChosenPlanConsultantLastDayStartedWidget(notification: notification as ChosenPlanConsultantLastDayStarted),
|
||
ComplaintToModerationForUser() => _ComplaintToModerationForUserWidget(notification: notification as ComplaintToModerationForUser),
|
||
CommentReplied() => _CommentRepliedWidget(notification: notification as CommentReplied),
|
||
ScoreAdded() => _ScoreAddedWidget(notification: notification as ScoreAdded),
|
||
EntityCommented() => _EntityCommentedWidget(notification: notification as EntityCommented),
|
||
// Новые типы уведомлений
|
||
PlanSubscriptionExpiredNotification() => _PlanSubscriptionExpiredWidget(notification: notification as PlanSubscriptionExpiredNotification),
|
||
PlanSubscriptionRenewedNotification() => _PlanSubscriptionRenewedWidget(notification: notification as PlanSubscriptionRenewedNotification),
|
||
ConsultantAssignedNotification() => _ConsultantAssignedWidget(notification: notification as ConsultantAssignedNotification),
|
||
ConsultantUnassignedNotification() => _ConsultantUnassignedWidget(notification: notification as ConsultantUnassignedNotification),
|
||
PaymentFailedNotification() => _PaymentFailedWidget(notification: notification as PaymentFailedNotification),
|
||
PaymentSuccessfulNotification() => _PaymentSuccessfulWidget(notification: notification as PaymentSuccessfulNotification),
|
||
GoalAchievedNotification() => _GoalAchievedWidget(notification: notification as GoalAchievedNotification),
|
||
WorkoutReminderNotification() => _WorkoutReminderWidget(notification: notification as WorkoutReminderNotification),
|
||
MealReminderNotification() => _MealReminderWidget(notification: notification as MealReminderNotification),
|
||
// New notification types
|
||
DietCancelledNotification() => _DietCancelledWidget(notification: notification as DietCancelledNotification),
|
||
DietStartedNotification() => _DietStartedWidget(notification: notification as DietStartedNotification),
|
||
DietExpiredNotification() => _DietExpiredWidget(notification: notification as DietExpiredNotification),
|
||
DietWillStartedInNotification() => _DietWillStartedInWidget(notification: notification as DietWillStartedInNotification),
|
||
DietCanNotBeStartedNotification() => _DietCanNotBeStartedWidget(notification: notification as DietCanNotBeStartedNotification),
|
||
PersonalDietCreationNeededNotification() => _PersonalDietCreationNeededWidget(notification: notification as PersonalDietCreationNeededNotification),
|
||
ChosenPlanClientLastDayFinishedNotification() => _ChosenPlanClientLastDayFinishedWidget(
|
||
notification: notification as ChosenPlanClientLastDayFinishedNotification,
|
||
),
|
||
ChosenPlanClientLastDayStartedNotification() => _ChosenPlanClientLastDayStartedWidget(
|
||
notification: notification as ChosenPlanClientLastDayStartedNotification,
|
||
),
|
||
StayOnTrackToAuthorNotification() => _StayOnTrackToAuthorWidget(notification: notification as StayOnTrackToAuthorNotification),
|
||
ClientStartPlanSubscriptionToSubscriberNotification() => _ClientStartPlanSubscriptionToSubscriberWidget(
|
||
notification: notification as ClientStartPlanSubscriptionToSubscriberNotification,
|
||
),
|
||
ConsultantConfirmPlanSubscriptionToSubscriberNotification() => _ConsultantConfirmPlanSubscriptionToSubscriberWidget(
|
||
notification: notification as ConsultantConfirmPlanSubscriptionToSubscriberNotification,
|
||
),
|
||
ClientPaidPlanSubscriptionToAuthorNotification() => _ClientPaidPlanSubscriptionToAuthorWidget(
|
||
notification: notification as ClientPaidPlanSubscriptionToAuthorNotification,
|
||
),
|
||
ConsultantLeftDiaryCommentNotification() => _ConsultantLeftDiaryCommentWidget(notification: notification as ConsultantLeftDiaryCommentNotification),
|
||
ConsultantConfirmPlanSubscriptionToAuthorNotification() => _ConsultantConfirmPlanSubscriptionToAuthorWidget(
|
||
notification: notification as ConsultantConfirmPlanSubscriptionToAuthorNotification,
|
||
),
|
||
ClientPaidPlanSubscriptionToSubscriberNotification() => _ClientPaidPlanSubscriptionToSubscriberWidget(
|
||
notification: notification as ClientPaidPlanSubscriptionToSubscriberNotification,
|
||
),
|
||
ClientStartPlanSubscriptionToAuthorNotification() => _ClientStartPlanSubscriptionToAuthorWidget(
|
||
notification: notification as ClientStartPlanSubscriptionToAuthorNotification,
|
||
),
|
||
ClientCancelPlanSubscriptionToAuthorNotification() => _ClientCancelPlanSubscriptionToAuthorWidget(
|
||
notification: notification as ClientCancelPlanSubscriptionToAuthorNotification,
|
||
),
|
||
ClientCancelPlanSubscriptionToSubscriberNotification() => _ClientCancelPlanSubscriptionToSubscriberWidget(
|
||
notification: notification as ClientCancelPlanSubscriptionToSubscriberNotification,
|
||
),
|
||
UserDailyReportCompletedNotification() => _UserDailyReportCompletedWidget(notification: notification as UserDailyReportCompletedNotification),
|
||
StayOnTrackToCustomerNotification() => _StayOnTrackToCustomerWidget(notification: notification as StayOnTrackToCustomerNotification),
|
||
PhoneChangedNotification() => _PhoneChangedWidget(notification: notification as PhoneChangedNotification),
|
||
SubscriptionNotification() => _SubscriptionWidget(notification: notification as SubscriptionNotification),
|
||
BadgeAwardedNotification() => _BadgeAwardedWidget(notification: notification as BadgeAwardedNotification),
|
||
BadgeRevokedNotification() => _BadgeRevokedWidget(notification: notification as BadgeRevokedNotification),
|
||
ConsultantRequestStartedNotification() => _ConsultantRequestStartedWidget(notification: notification as ConsultantRequestStartedNotification),
|
||
ClientCloseComplaintSuccessNotification() => _ClientCloseComplaintSuccessWidget(notification: notification as ClientCloseComplaintSuccessNotification),
|
||
ClientRefundSuccessNotification() => _ClientRefundSuccessWidget(notification: notification as ClientRefundSuccessNotification),
|
||
ConsultantRefundSuccessNotification() => _ConsultantRefundSuccessWidget(notification: notification as ConsultantRefundSuccessNotification),
|
||
ClientRejectSuccessNotification() => _ClientRejectSuccessWidget(notification: notification as ClientRejectSuccessNotification),
|
||
ConsultantRejectSuccessNotification() => _ConsultantRejectSuccessWidget(notification: notification as ConsultantRejectSuccessNotification),
|
||
ScoreSubstractedNotification() => _ScoreSubstractedWidget(notification: notification as ScoreSubstractedNotification),
|
||
ProductStatusUpdatedForAuthorNotification() => _ProductStatusUpdatedForAuthorWidget(
|
||
notification: notification as ProductStatusUpdatedForAuthorNotification,
|
||
),
|
||
DiaryReminderForUsersNotification() => _DiaryReminderForUsersWidget(notification: notification as DiaryReminderForUsersNotification),
|
||
PersonalDietIsDefinedToCustomerNotification() => _PersonalDietIsDefinedToCustomerWidget(
|
||
notification: notification as PersonalDietIsDefinedToCustomerNotification,
|
||
),
|
||
// New Widgets
|
||
ConsultantEducationUpdatedNotification() => _ConsultantEducationUpdatedWidget(notification: notification as ConsultantEducationUpdatedNotification),
|
||
ComplaintRegisteredNotification() => _ComplaintRegisteredWidget(notification: notification as ComplaintRegisteredNotification),
|
||
ContentUnpublishedNotification() => _ContentUnpublishedWidget(notification: notification as ContentUnpublishedNotification),
|
||
FinanceQuestionCreatedNotification() => _FinanceQuestionCreatedWidget(notification: notification as FinanceQuestionCreatedNotification),
|
||
NewChatMessageNotification() => _NewChatMessageWidget(notification: notification as NewChatMessageNotification),
|
||
CompleteRegistrationNotification() => _CompleteRegistrationWidget(notification: notification as CompleteRegistrationNotification),
|
||
ChosenDietExpiredNotification() => _ChosenDietExpiredWidget(notification: notification as ChosenDietExpiredNotification),
|
||
MotivateUserNotification() => _MotivateUserWidget(notification: notification as MotivateUserNotification),
|
||
CommentComplaintNotification() => _CommentComplaintWidget(notification: notification as CommentComplaintNotification),
|
||
CommentDeletedNotification() => _CommentDeletedWidget(notification: notification as CommentDeletedNotification),
|
||
UserSubscribedNotification() => _UserSubscribedWidget(notification: notification as UserSubscribedNotification),
|
||
UnknownNotification() => const SizedBox.shrink(),
|
||
};
|
||
}
|
||
}
|
||
|
||
void _navigateToBottomNavRoute(BuildContext context, String path, [Object? extra]) {
|
||
final controller = BottomNavScope.maybeOf(context);
|
||
if (controller != null) {
|
||
controller.switchToRoute(path, extra);
|
||
} else {
|
||
context.push(path, extra: extra);
|
||
}
|
||
}
|
||
|
||
void _navigateToEntity(BuildContext context, CommentedEntityType type, int id, int? commentId) {
|
||
switch (type) {
|
||
case CommentedEntityType.blogPost:
|
||
context.push(RouteConstants.blogPostScreen, extra: {'id': id, 'highlightedCommentId': commentId});
|
||
case CommentedEntityType.diet:
|
||
if (id > 0) {
|
||
context.push(RouteConstants.aboutDietScreen, extra: {'id': id, 'highlightedCommentId': commentId});
|
||
}
|
||
case CommentedEntityType.unknown:
|
||
break;
|
||
}
|
||
}
|
||
|
||
class _PlanSubscriptionStartedToAuthorWidget extends StatelessWidget {
|
||
const _PlanSubscriptionStartedToAuthorWidget({required this.notification});
|
||
final PlanSubscriptionStartedToAuthorNotification notification;
|
||
@override
|
||
Widget build(BuildContext context) {
|
||
final s = S.of(context);
|
||
|
||
return _BaseNotificationWidget(
|
||
isRead: notification.isRead,
|
||
notificationsText: '${s.userSubscribedToPlan(notification.customerName, notification.planName)}! 🎉',
|
||
createdAt: notification.createdAt,
|
||
onTap: () {
|
||
_navigateToBottomNavRoute(context, RouteConstants.chatSelectScreen, notification.customerName.isNotEmpty ? notification.customerName : null);
|
||
},
|
||
);
|
||
}
|
||
}
|
||
|
||
class _PlanSubscriptionCanceledToAuthorWidget extends StatelessWidget {
|
||
const _PlanSubscriptionCanceledToAuthorWidget({required this.notification});
|
||
final PlanSubscriptionCanceledToAuthorNotification notification;
|
||
@override
|
||
Widget build(BuildContext context) {
|
||
return _BaseNotificationWidget(
|
||
isRead: notification.isRead,
|
||
notificationsText: 'Отмена подписки. Клиент ${notification.customerName} отказался от плана "${notification.planName}"',
|
||
createdAt: notification.createdAt,
|
||
onTap: () {
|
||
_navigateToBottomNavRoute(context, RouteConstants.chatSelectScreen, notification.customerName.isNotEmpty ? notification.customerName : null);
|
||
},
|
||
);
|
||
}
|
||
}
|
||
|
||
class _ChosenPlanStartedToClientWidget extends StatelessWidget {
|
||
const _ChosenPlanStartedToClientWidget({required this.notification});
|
||
final ChosenPlanStartedToClientNotification notification;
|
||
@override
|
||
Widget build(BuildContext context) {
|
||
return _BaseNotificationWidget(
|
||
isRead: notification.isRead,
|
||
notificationsText: 'Ваш план "${notification.planName}" начался! Удачи! 🚀',
|
||
createdAt: notification.createdAt,
|
||
onTap: () {
|
||
_navigateToBottomNavRoute(context, RouteConstants.diaryScreen);
|
||
},
|
||
);
|
||
}
|
||
}
|
||
|
||
class _ChosenPlanTomorrowReminderToClientWidget extends StatelessWidget {
|
||
const _ChosenPlanTomorrowReminderToClientWidget({required this.notification});
|
||
final ChosenPlanTomorrowReminderToClientNotification notification;
|
||
@override
|
||
Widget build(BuildContext context) {
|
||
return _BaseNotificationWidget(
|
||
isRead: notification.isRead,
|
||
notificationsText: 'Напоминание: Завтра старт плана "${notification.planName}"',
|
||
createdAt: notification.createdAt,
|
||
);
|
||
}
|
||
}
|
||
|
||
class _DiaryReminderWidget extends StatelessWidget {
|
||
const _DiaryReminderWidget({required this.notification});
|
||
final DiaryReminderNotification notification;
|
||
@override
|
||
Widget build(BuildContext context) {
|
||
return _BaseNotificationWidget(
|
||
isRead: notification.isRead,
|
||
notificationsText: 'Не забудьте заполнить дневник за вчера! 📝',
|
||
createdAt: notification.createdAt,
|
||
onTap: () {
|
||
final yesterday = notification.createdAt.subtract(const Duration(days: 1));
|
||
final dateOnly = DateTime(yesterday.year, yesterday.month, yesterday.day);
|
||
_navigateToBottomNavRoute(context, RouteConstants.diaryScreen, dateOnly);
|
||
},
|
||
);
|
||
}
|
||
}
|
||
|
||
class _ConsultantLeftCommentWidget extends StatelessWidget {
|
||
const _ConsultantLeftCommentWidget({required this.notification});
|
||
final ConsultantLeftCommentNotification notification;
|
||
@override
|
||
Widget build(BuildContext context) {
|
||
return _BaseNotificationWidget(
|
||
isRead: notification.isRead,
|
||
notificationsText: 'Новый комментарий от консультанта (за ${notification.date.format('dd.MM.yyyy')})',
|
||
createdAt: notification.createdAt,
|
||
onTap: () {
|
||
_navigateToBottomNavRoute(context, RouteConstants.diaryScreen, notification.date);
|
||
},
|
||
);
|
||
}
|
||
}
|
||
|
||
class _PersonalizedDietIsDefinedWidget extends StatelessWidget {
|
||
const _PersonalizedDietIsDefinedWidget({required this.notification});
|
||
final PersonalizedDietIsDefinedNotification notification;
|
||
@override
|
||
Widget build(BuildContext context) {
|
||
return _BaseNotificationWidget(
|
||
isRead: notification.isRead,
|
||
notificationsText: 'Персональная диета определена',
|
||
createdAt: notification.createdAt,
|
||
onTap: () {
|
||
_navigateToBottomNavRoute(context, RouteConstants.consultationsScreen);
|
||
},
|
||
);
|
||
}
|
||
}
|
||
|
||
class _ChosenPlanFinishedToClientWidget extends StatelessWidget {
|
||
const _ChosenPlanFinishedToClientWidget({required this.notification});
|
||
final ChosenPlanFinishedToClientNotification notification;
|
||
@override
|
||
Widget build(BuildContext context) {
|
||
return _BaseNotificationWidget(
|
||
isRead: notification.isRead,
|
||
notificationsText: 'Поздравляем! План «${notification.planName}» успешно завершен! 🏆',
|
||
createdAt: notification.createdAt,
|
||
);
|
||
}
|
||
}
|
||
|
||
class _PlanSubscriptionCanceledToCustomerWidget extends StatelessWidget {
|
||
const _PlanSubscriptionCanceledToCustomerWidget({required this.notification});
|
||
final PlanSubscriptionCanceledToCustomerNotification notification;
|
||
@override
|
||
Widget build(BuildContext context) {
|
||
return _BaseNotificationWidget(
|
||
isRead: notification.isRead,
|
||
notificationsText: 'Подписка на план "${notification.planName}" отменена.',
|
||
createdAt: notification.createdAt,
|
||
);
|
||
}
|
||
}
|
||
|
||
class _ChosenPlanStartedToConsultantWidget extends StatelessWidget {
|
||
const _ChosenPlanStartedToConsultantWidget({required this.notification});
|
||
final ChosenPlanStartedToConsultantNotification notification;
|
||
@override
|
||
Widget build(BuildContext context) {
|
||
return _BaseNotificationWidget(
|
||
isRead: notification.isRead,
|
||
notificationsText: 'Начало работы: План "${notification.planName}" с клиентом ${notification.customerName}',
|
||
createdAt: notification.createdAt,
|
||
);
|
||
}
|
||
}
|
||
|
||
class _ChosenPlanTomorrowReminderToConsultantWidget extends StatelessWidget {
|
||
const _ChosenPlanTomorrowReminderToConsultantWidget({required this.notification});
|
||
final ChosenPlanTomorrowReminderToConsultantNotification notification;
|
||
@override
|
||
Widget build(BuildContext context) {
|
||
return _BaseNotificationWidget(
|
||
isRead: notification.isRead,
|
||
notificationsText: 'Напоминание: Завтра старт работы с ${notification.customerName} по плану "${notification.planName}"',
|
||
createdAt: notification.createdAt,
|
||
);
|
||
}
|
||
}
|
||
|
||
class _PlanSubscriptionPaidToAuthorWidget extends StatelessWidget {
|
||
const _PlanSubscriptionPaidToAuthorWidget({required this.notification});
|
||
final PlanSubscriptionPaidToAuthorNotification notification;
|
||
@override
|
||
Widget build(BuildContext context) {
|
||
return _BaseNotificationWidget(
|
||
isRead: notification.isRead,
|
||
notificationsText: 'Оплата получена! Клиент ${notification.customerName} оплатил план "${notification.planName}" 💰',
|
||
createdAt: notification.createdAt,
|
||
onTap: () {
|
||
context.push(RouteConstants.consultantFinancesScreen);
|
||
},
|
||
);
|
||
}
|
||
}
|
||
|
||
class _ChosenPlanFinishedToConsultantWidget extends StatelessWidget {
|
||
const _ChosenPlanFinishedToConsultantWidget({required this.notification});
|
||
final ChosenPlanFinishedToConsultantNotification notification;
|
||
@override
|
||
Widget build(BuildContext context) {
|
||
final s = S.of(context);
|
||
return GestureDetector(
|
||
onTap: () {},
|
||
behavior: HitTestBehavior.opaque,
|
||
child: Column(
|
||
crossAxisAlignment: CrossAxisAlignment.start,
|
||
children: [
|
||
Row(
|
||
children: [
|
||
Expanded(
|
||
child: Column(
|
||
crossAxisAlignment: CrossAxisAlignment.start,
|
||
children: [
|
||
Text('План «${notification.planName}» завершен! Поздравляем! 🎉', style: TextStyles.textMSemibold.copyWith(color: appTheme.black)),
|
||
const SizedBox(height: 12),
|
||
Text(s.userConfirmedPlanCompletionWithoutSum, style: TextStyles.textSMedium.copyWith(color: appTheme.black)),
|
||
const SizedBox(height: 12),
|
||
CustomOutlinedButton(
|
||
text: s.collectCharge,
|
||
buttonTextStyle: TextStyles.textMSemibold.copyWith(color: appTheme.whiteA700),
|
||
buttonStyle: ButtonStyle(side: const WidgetStatePropertyAll(BorderSide.none), backgroundColor: WidgetStatePropertyAll(appTheme.green)),
|
||
onPressed: () {
|
||
GoRouter.of(context).push(CardSettingsScreen.path, extra: notification.chosenPlanId);
|
||
},
|
||
),
|
||
],
|
||
),
|
||
),
|
||
if (!notification.isRead)
|
||
Container(
|
||
decoration: BoxDecoration(color: appTheme.blueA400, shape: BoxShape.circle),
|
||
width: 8,
|
||
height: 8,
|
||
),
|
||
],
|
||
),
|
||
const SizedBox(height: 4),
|
||
Text(
|
||
'${notification.createdAt.day} ${_getMonthName(notification.createdAt.month)} ${notification.createdAt.hour.toString().padLeft(2, '0')}:${notification.createdAt.minute.toString().padLeft(2, '0')}',
|
||
style: TextStyles.textSMedium.copyWith(color: appTheme.gray600),
|
||
),
|
||
],
|
||
),
|
||
);
|
||
}
|
||
|
||
String _getMonthName(int month) {
|
||
switch (month) {
|
||
case 1:
|
||
return 'янв';
|
||
case 2:
|
||
return 'фев';
|
||
case 3:
|
||
return 'мар';
|
||
case 4:
|
||
return 'апр';
|
||
case 5:
|
||
return 'май';
|
||
case 6:
|
||
return 'июн';
|
||
case 7:
|
||
return 'июл';
|
||
case 8:
|
||
return 'авг';
|
||
case 9:
|
||
return 'сен';
|
||
case 10:
|
||
return 'окт';
|
||
case 11:
|
||
return 'ноя';
|
||
case 12:
|
||
return 'дек';
|
||
default:
|
||
return '';
|
||
}
|
||
}
|
||
}
|
||
|
||
// CardSettingsScreen
|
||
class _BaseNotificationWidget extends StatelessWidget {
|
||
const _BaseNotificationWidget({required this.notificationsText, required this.isRead, required this.createdAt, this.onTap});
|
||
final String notificationsText;
|
||
final bool isRead;
|
||
final DateTime createdAt;
|
||
final void Function()? onTap;
|
||
@override
|
||
Widget build(BuildContext context) {
|
||
return GestureDetector(
|
||
onTap: onTap,
|
||
behavior: HitTestBehavior.opaque,
|
||
child: Column(
|
||
crossAxisAlignment: CrossAxisAlignment.start,
|
||
children: [
|
||
Row(
|
||
children: [
|
||
Expanded(
|
||
child: Text(notificationsText, style: TextStyles.textMMedium.copyWith(color: appTheme.black)),
|
||
),
|
||
if (onTap != null)
|
||
Padding(
|
||
padding: const EdgeInsets.only(left: 8),
|
||
child: Icon(Icons.chevron_right, color: appTheme.gray500, size: 20),
|
||
),
|
||
if (!isRead)
|
||
Container(
|
||
margin: const EdgeInsets.only(left: 8),
|
||
decoration: BoxDecoration(color: appTheme.blueA400, shape: BoxShape.circle),
|
||
width: 8,
|
||
height: 8,
|
||
),
|
||
],
|
||
),
|
||
const SizedBox(height: 4),
|
||
Text(
|
||
'${createdAt.day} ${_getMonthName(createdAt.month)} ${createdAt.hour.toString().padLeft(2, '0')}:${createdAt.minute.toString().padLeft(2, '0')}',
|
||
style: TextStyles.textSMedium.copyWith(color: appTheme.gray600),
|
||
),
|
||
],
|
||
),
|
||
);
|
||
}
|
||
|
||
String _getMonthName(int month) {
|
||
switch (month) {
|
||
case 1:
|
||
return 'янв';
|
||
case 2:
|
||
return 'фев';
|
||
case 3:
|
||
return 'мар';
|
||
case 4:
|
||
return 'апр';
|
||
case 5:
|
||
return 'май';
|
||
case 6:
|
||
return 'июн';
|
||
case 7:
|
||
return 'июл';
|
||
case 8:
|
||
return 'авг';
|
||
case 9:
|
||
return 'сен';
|
||
case 10:
|
||
return 'окт';
|
||
case 11:
|
||
return 'ноя';
|
||
case 12:
|
||
return 'дек';
|
||
default:
|
||
return '';
|
||
}
|
||
}
|
||
}
|
||
|
||
class _ChosenPlanLastDayFinishedForUserWidget extends StatelessWidget {
|
||
const _ChosenPlanLastDayFinishedForUserWidget({required this.notification});
|
||
final ChosenPlanLastDayFinishedForUser notification;
|
||
@override
|
||
Widget build(BuildContext context) {
|
||
return _BaseNotificationWidget(
|
||
isRead: notification.isRead,
|
||
notificationsText: 'Финишная прямая! Последний день плана завершен.',
|
||
createdAt: notification.createdAt,
|
||
);
|
||
}
|
||
}
|
||
|
||
class _ChosenPlanConsultantLastDayStartedWidget extends StatelessWidget {
|
||
const _ChosenPlanConsultantLastDayStartedWidget({required this.notification});
|
||
final ChosenPlanConsultantLastDayStarted notification;
|
||
@override
|
||
Widget build(BuildContext context) {
|
||
return _BaseNotificationWidget(
|
||
isRead: notification.isRead,
|
||
notificationsText: 'Внимание: Начался последний день плана "${notification.planName}"',
|
||
createdAt: notification.createdAt,
|
||
onTap: () {
|
||
_navigateToBottomNavRoute(context, RouteConstants.consultationsScreen);
|
||
},
|
||
);
|
||
}
|
||
}
|
||
|
||
class _ComplaintToModerationForUserWidget extends StatelessWidget {
|
||
const _ComplaintToModerationForUserWidget({required this.notification});
|
||
final ComplaintToModerationForUser notification;
|
||
@override
|
||
Widget build(BuildContext context) {
|
||
return _BaseNotificationWidget(
|
||
isRead: notification.isRead,
|
||
notificationsText: 'Ваша жалоба принята и находится на модерации.',
|
||
createdAt: notification.createdAt,
|
||
);
|
||
}
|
||
}
|
||
|
||
class _CommentRepliedWidget extends StatelessWidget {
|
||
const _CommentRepliedWidget({required this.notification});
|
||
final CommentReplied notification;
|
||
@override
|
||
Widget build(BuildContext context) {
|
||
return _BaseNotificationWidget(
|
||
isRead: notification.isRead,
|
||
notificationsText: 'Вам ответили в комментариях к: ${notification.entityName}',
|
||
createdAt: notification.createdAt,
|
||
onTap: (notification.commentedEntityType == CommentedEntityType.unknown || notification.commentedEntityId <= 0)
|
||
? null
|
||
: () {
|
||
_navigateToEntity(context, notification.commentedEntityType, notification.commentedEntityId, notification.commentId);
|
||
},
|
||
);
|
||
}
|
||
}
|
||
|
||
class _ScoreAddedWidget extends StatelessWidget {
|
||
const _ScoreAddedWidget({required this.notification});
|
||
final ScoreAdded notification;
|
||
@override
|
||
Widget build(BuildContext context) {
|
||
return _BaseNotificationWidget(
|
||
isRead: notification.isRead,
|
||
notificationsText: 'Поздравляем! Вам начислены баллы: ${notification.scoreValue} ⭐',
|
||
createdAt: notification.createdAt,
|
||
onTap: () {
|
||
context.push(RouteConstants.consultantRatingScreen);
|
||
},
|
||
);
|
||
}
|
||
}
|
||
|
||
class _EntityCommentedWidget extends StatelessWidget {
|
||
const _EntityCommentedWidget({required this.notification});
|
||
final EntityCommented notification;
|
||
@override
|
||
Widget build(BuildContext context) {
|
||
return _BaseNotificationWidget(
|
||
isRead: notification.isRead,
|
||
notificationsText: 'Новый комментарий к вашей публикации "${notification.entityTranslatedType}": ${notification.entityName}',
|
||
createdAt: notification.createdAt,
|
||
onTap: (notification.entityType == CommentedEntityType.unknown || notification.entityId <= 0)
|
||
? null
|
||
: () {
|
||
_navigateToEntity(context, notification.entityType, notification.entityId, notification.commentId);
|
||
},
|
||
);
|
||
}
|
||
}
|
||
|
||
// Новые виджеты для дополнительных типов уведомлений
|
||
class _PlanSubscriptionExpiredWidget extends StatelessWidget {
|
||
const _PlanSubscriptionExpiredWidget({required this.notification});
|
||
final PlanSubscriptionExpiredNotification notification;
|
||
@override
|
||
Widget build(BuildContext context) {
|
||
return _BaseNotificationWidget(
|
||
isRead: notification.isRead,
|
||
notificationsText: 'Срок действия подписки на план "${notification.planName}" истек. Продлите, чтобы продолжить! ⏳',
|
||
createdAt: notification.createdAt,
|
||
);
|
||
}
|
||
}
|
||
|
||
class _PlanSubscriptionRenewedWidget extends StatelessWidget {
|
||
const _PlanSubscriptionRenewedWidget({required this.notification});
|
||
final PlanSubscriptionRenewedNotification notification;
|
||
@override
|
||
Widget build(BuildContext context) {
|
||
return _BaseNotificationWidget(
|
||
isRead: notification.isRead,
|
||
notificationsText: 'Успешное продление! Подписка на план "${notification.planName}" активна до ${notification.renewalDate} ✅',
|
||
createdAt: notification.createdAt,
|
||
);
|
||
}
|
||
}
|
||
|
||
class _ConsultantAssignedWidget extends StatelessWidget {
|
||
const _ConsultantAssignedWidget({required this.notification});
|
||
final ConsultantAssignedNotification notification;
|
||
@override
|
||
Widget build(BuildContext context) {
|
||
return _BaseNotificationWidget(
|
||
isRead: notification.isRead,
|
||
notificationsText: 'Вам назначен консультант ${notification.consultantName} по плану "${notification.planName}". Приветствуйте! 👋',
|
||
createdAt: notification.createdAt,
|
||
onTap: () {
|
||
_navigateToBottomNavRoute(context, RouteConstants.chatSelectScreen, notification.consultantName.isNotEmpty ? notification.consultantName : null);
|
||
},
|
||
);
|
||
}
|
||
}
|
||
|
||
class _ConsultantUnassignedWidget extends StatelessWidget {
|
||
const _ConsultantUnassignedWidget({required this.notification});
|
||
final ConsultantUnassignedNotification notification;
|
||
@override
|
||
Widget build(BuildContext context) {
|
||
return _BaseNotificationWidget(
|
||
isRead: notification.isRead,
|
||
notificationsText: 'Изменение в плане "${notification.planName}": консультант ${notification.consultantName} отстранен.',
|
||
createdAt: notification.createdAt,
|
||
);
|
||
}
|
||
}
|
||
|
||
class _PaymentFailedWidget extends StatelessWidget {
|
||
const _PaymentFailedWidget({required this.notification});
|
||
final PaymentFailedNotification notification;
|
||
@override
|
||
Widget build(BuildContext context) {
|
||
return _BaseNotificationWidget(
|
||
isRead: notification.isRead,
|
||
notificationsText: 'Не удалось провести оплату за план "${notification.planName}". Причина: ${notification.errorMessage} ❌',
|
||
createdAt: notification.createdAt,
|
||
onTap: () {
|
||
context.push(RouteConstants.userFinanceScreen);
|
||
},
|
||
);
|
||
}
|
||
}
|
||
|
||
class _PaymentSuccessfulWidget extends StatelessWidget {
|
||
const _PaymentSuccessfulWidget({required this.notification});
|
||
final PaymentSuccessfulNotification notification;
|
||
@override
|
||
Widget build(BuildContext context) {
|
||
return _BaseNotificationWidget(
|
||
isRead: notification.isRead,
|
||
notificationsText: 'Оплата прошла успешно! План "${notification.planName}" оплачен на сумму ${notification.amount} ${notification.currency} 💳',
|
||
createdAt: notification.createdAt,
|
||
onTap: () {
|
||
context.push(RouteConstants.userFinanceScreen);
|
||
},
|
||
);
|
||
}
|
||
}
|
||
|
||
class _GoalAchievedWidget extends StatelessWidget {
|
||
const _GoalAchievedWidget({required this.notification});
|
||
final GoalAchievedNotification notification;
|
||
@override
|
||
Widget build(BuildContext context) {
|
||
return _BaseNotificationWidget(
|
||
isRead: notification.isRead,
|
||
notificationsText: 'Цель достигнута! "${notification.goalName}": ${notification.achievedValue}/${notification.targetValue} 🎯',
|
||
createdAt: notification.createdAt,
|
||
);
|
||
}
|
||
}
|
||
|
||
class _WorkoutReminderWidget extends StatelessWidget {
|
||
const _WorkoutReminderWidget({required this.notification});
|
||
final WorkoutReminderNotification notification;
|
||
@override
|
||
Widget build(BuildContext context) {
|
||
return _BaseNotificationWidget(
|
||
isRead: notification.isRead,
|
||
notificationsText: 'Время тренировки! "${notification.workoutName}" ждет вас (${notification.duration} мин) 💪',
|
||
createdAt: notification.createdAt,
|
||
);
|
||
}
|
||
}
|
||
|
||
class _MealReminderWidget extends StatelessWidget {
|
||
const _MealReminderWidget({required this.notification});
|
||
final MealReminderNotification notification;
|
||
@override
|
||
Widget build(BuildContext context) {
|
||
return _BaseNotificationWidget(
|
||
isRead: notification.isRead,
|
||
notificationsText: 'Пора подкрепиться! "${notification.mealName}" (${notification.calories} ккал) 🍎',
|
||
createdAt: notification.createdAt,
|
||
onTap: () {
|
||
_navigateToBottomNavRoute(context, RouteConstants.diaryScreen);
|
||
},
|
||
);
|
||
}
|
||
}
|
||
|
||
// New notification widget classes
|
||
class _DietCancelledWidget extends StatelessWidget {
|
||
const _DietCancelledWidget({required this.notification});
|
||
final DietCancelledNotification notification;
|
||
@override
|
||
Widget build(BuildContext context) {
|
||
return _BaseNotificationWidget(
|
||
isRead: notification.isRead,
|
||
notificationsText: 'Диета "${notification.dietName}" была отменена.',
|
||
createdAt: notification.createdAt,
|
||
onTap: () {
|
||
if (notification.dietId > 0) {
|
||
const dietTabIndexWithHiddenPlansTab = 3;
|
||
const dietTabIndexWithoutHiddenPlansTab = 4;
|
||
|
||
final initialTabIndex = hidePlans ? dietTabIndexWithHiddenPlansTab : dietTabIndexWithoutHiddenPlansTab;
|
||
_navigateToBottomNavRoute(context, RouteConstants.feedScreen, initialTabIndex);
|
||
}
|
||
},
|
||
);
|
||
}
|
||
}
|
||
|
||
class _DietStartedWidget extends StatelessWidget {
|
||
const _DietStartedWidget({required this.notification});
|
||
final DietStartedNotification notification;
|
||
@override
|
||
Widget build(BuildContext context) {
|
||
return _BaseNotificationWidget(
|
||
isRead: notification.isRead,
|
||
notificationsText: 'Старт диеты "${notification.dietName}"! Успехов! 🥗',
|
||
createdAt: notification.createdAt,
|
||
onTap: () {
|
||
_navigateToBottomNavRoute(context, RouteConstants.diaryScreen);
|
||
},
|
||
);
|
||
}
|
||
}
|
||
|
||
class _DietExpiredWidget extends StatelessWidget {
|
||
const _DietExpiredWidget({required this.notification});
|
||
final DietExpiredNotification notification;
|
||
@override
|
||
Widget build(BuildContext context) {
|
||
return _BaseNotificationWidget(
|
||
isRead: notification.isRead,
|
||
notificationsText: 'Срок действия диеты "${notification.dietName}" подошел к концу.',
|
||
createdAt: notification.createdAt,
|
||
onTap: () {
|
||
if (notification.dietId > 0) {
|
||
context.push(RouteConstants.aboutDietScreen, extra: {'id': notification.dietId});
|
||
}
|
||
},
|
||
);
|
||
}
|
||
}
|
||
|
||
class _DietWillStartedInWidget extends StatelessWidget {
|
||
const _DietWillStartedInWidget({required this.notification});
|
||
final DietWillStartedInNotification notification;
|
||
@override
|
||
Widget build(BuildContext context) {
|
||
return _BaseNotificationWidget(
|
||
isRead: notification.isRead,
|
||
notificationsText: 'Скоро старт! Диета "${notification.dietName}" начнется ${notification.startDate} ⏰',
|
||
createdAt: notification.createdAt,
|
||
onTap: () {
|
||
if (notification.dietId > 0) {
|
||
context.push(RouteConstants.aboutDietScreen, extra: {'id': notification.dietId});
|
||
}
|
||
},
|
||
);
|
||
}
|
||
}
|
||
|
||
class _DietCanNotBeStartedWidget extends StatelessWidget {
|
||
const _DietCanNotBeStartedWidget({required this.notification});
|
||
final DietCanNotBeStartedNotification notification;
|
||
@override
|
||
Widget build(BuildContext context) {
|
||
return _BaseNotificationWidget(
|
||
isRead: notification.isRead,
|
||
notificationsText: 'Внимание: Не удалось начать диету "${notification.dietName}". Причина: ${notification.reason}',
|
||
createdAt: notification.createdAt,
|
||
onTap: () {
|
||
if (notification.dietId > 0) {
|
||
context.push(RouteConstants.aboutDietScreen, extra: {'id': notification.dietId});
|
||
}
|
||
},
|
||
);
|
||
}
|
||
}
|
||
|
||
class _PersonalDietCreationNeededWidget extends StatelessWidget {
|
||
const _PersonalDietCreationNeededWidget({required this.notification});
|
||
final PersonalDietCreationNeededNotification notification;
|
||
@override
|
||
Widget build(BuildContext context) {
|
||
return _BaseNotificationWidget(
|
||
isRead: notification.isRead,
|
||
notificationsText: 'Задача: Создать персональную диету для клиента ${notification.userName}',
|
||
createdAt: notification.createdAt,
|
||
onTap: () {
|
||
context.push(RouteConstants.myDietsScreen);
|
||
},
|
||
);
|
||
}
|
||
}
|
||
|
||
class _ChosenPlanClientLastDayFinishedWidget extends StatelessWidget {
|
||
const _ChosenPlanClientLastDayFinishedWidget({required this.notification});
|
||
final ChosenPlanClientLastDayFinishedNotification notification;
|
||
@override
|
||
Widget build(BuildContext context) {
|
||
return _BaseNotificationWidget(
|
||
isRead: notification.isRead,
|
||
notificationsText: 'Поздравляем с завершением плана "${notification.planName}"! 🎉',
|
||
createdAt: notification.createdAt,
|
||
);
|
||
}
|
||
}
|
||
|
||
class _ChosenPlanClientLastDayStartedWidget extends StatelessWidget {
|
||
const _ChosenPlanClientLastDayStartedWidget({required this.notification});
|
||
final ChosenPlanClientLastDayStartedNotification notification;
|
||
@override
|
||
Widget build(BuildContext context) {
|
||
return _BaseNotificationWidget(
|
||
isRead: notification.isRead,
|
||
notificationsText: 'Сегодня последний день плана "${notification.planName}"! Финиш близко! 🏁',
|
||
createdAt: notification.createdAt,
|
||
onTap: () {
|
||
_navigateToBottomNavRoute(context, RouteConstants.diaryScreen);
|
||
},
|
||
);
|
||
}
|
||
}
|
||
|
||
class _StayOnTrackToAuthorWidget extends StatelessWidget {
|
||
const _StayOnTrackToAuthorWidget({required this.notification});
|
||
final StayOnTrackToAuthorNotification notification;
|
||
@override
|
||
Widget build(BuildContext context) {
|
||
return _BaseNotificationWidget(
|
||
isRead: notification.isRead,
|
||
notificationsText: 'Клиент ${notification.userName} завершил день ${notification.dayNum} по плану "${notification.planName}" 💪',
|
||
createdAt: notification.createdAt,
|
||
onTap: () {
|
||
if (notification.diaryDayId > 0) {
|
||
context.push(RouteConstants.userDiaryScreen, extra: {'diaryId': notification.diaryDayId});
|
||
} else {
|
||
_navigateToBottomNavRoute(context, RouteConstants.consultationsScreen);
|
||
}
|
||
},
|
||
);
|
||
}
|
||
}
|
||
|
||
class _ClientStartPlanSubscriptionToSubscriberWidget extends StatelessWidget {
|
||
const _ClientStartPlanSubscriptionToSubscriberWidget({required this.notification});
|
||
final ClientStartPlanSubscriptionToSubscriberNotification notification;
|
||
@override
|
||
Widget build(BuildContext context) {
|
||
return _BaseNotificationWidget(
|
||
isRead: notification.isRead,
|
||
notificationsText: 'У вас новая подписка на план "${notification.planName}"! 🌟',
|
||
createdAt: notification.createdAt,
|
||
onTap: () {
|
||
_navigateToBottomNavRoute(context, RouteConstants.chatSelectScreen);
|
||
},
|
||
);
|
||
}
|
||
}
|
||
|
||
class _ConsultantConfirmPlanSubscriptionToSubscriberWidget extends StatelessWidget {
|
||
const _ConsultantConfirmPlanSubscriptionToSubscriberWidget({required this.notification});
|
||
final ConsultantConfirmPlanSubscriptionToSubscriberNotification notification;
|
||
@override
|
||
Widget build(BuildContext context) {
|
||
return _BaseNotificationWidget(
|
||
isRead: notification.isRead,
|
||
notificationsText: 'Ваша подписка на план "${notification.planName}" подтверждена консультантом ${notification.consultantName} ✅',
|
||
createdAt: notification.createdAt,
|
||
onTap: () {
|
||
_navigateToBottomNavRoute(context, RouteConstants.chatSelectScreen, notification.consultantName.isNotEmpty ? notification.consultantName : null);
|
||
},
|
||
);
|
||
}
|
||
}
|
||
|
||
class _ClientPaidPlanSubscriptionToAuthorWidget extends StatelessWidget {
|
||
const _ClientPaidPlanSubscriptionToAuthorWidget({required this.notification});
|
||
final ClientPaidPlanSubscriptionToAuthorNotification notification;
|
||
@override
|
||
Widget build(BuildContext context) {
|
||
return _BaseNotificationWidget(
|
||
isRead: notification.isRead,
|
||
notificationsText: 'Поступление средств: Клиент ${notification.clientName} оплатил подписку на план "${notification.planName}" 💸',
|
||
createdAt: notification.createdAt,
|
||
onTap: () {
|
||
context.push(RouteConstants.consultantFinancesScreen);
|
||
},
|
||
);
|
||
}
|
||
}
|
||
|
||
class _ConsultantLeftDiaryCommentWidget extends StatelessWidget {
|
||
const _ConsultantLeftDiaryCommentWidget({required this.notification});
|
||
final ConsultantLeftDiaryCommentNotification notification;
|
||
@override
|
||
Widget build(BuildContext context) {
|
||
return _BaseNotificationWidget(
|
||
isRead: notification.isRead,
|
||
notificationsText: 'Ваш консультант ${notification.consultantName} прокомментировал дневник по плану "${notification.planName}" 💬',
|
||
createdAt: notification.createdAt,
|
||
onTap: () {
|
||
_navigateToBottomNavRoute(context, RouteConstants.diaryScreen, notification.diaryDate);
|
||
},
|
||
);
|
||
}
|
||
}
|
||
|
||
class _ConsultantConfirmPlanSubscriptionToAuthorWidget extends StatelessWidget {
|
||
const _ConsultantConfirmPlanSubscriptionToAuthorWidget({required this.notification});
|
||
final ConsultantConfirmPlanSubscriptionToAuthorNotification notification;
|
||
@override
|
||
Widget build(BuildContext context) {
|
||
return _BaseNotificationWidget(
|
||
isRead: notification.isRead,
|
||
notificationsText: 'Клиент ${notification.clientName} подтвердил подписку на план "${notification.planName}" 🤝',
|
||
createdAt: notification.createdAt,
|
||
onTap: () {
|
||
_navigateToBottomNavRoute(context, RouteConstants.chatSelectScreen, notification.clientName.isNotEmpty ? notification.clientName : null);
|
||
},
|
||
);
|
||
}
|
||
}
|
||
|
||
class _ClientPaidPlanSubscriptionToSubscriberWidget extends StatelessWidget {
|
||
const _ClientPaidPlanSubscriptionToSubscriberWidget({required this.notification});
|
||
final ClientPaidPlanSubscriptionToSubscriberNotification notification;
|
||
@override
|
||
Widget build(BuildContext context) {
|
||
return _BaseNotificationWidget(
|
||
isRead: notification.isRead,
|
||
notificationsText: 'Оплата подписки на план "${notification.planName}" прошла успешно ✅',
|
||
createdAt: notification.createdAt,
|
||
onTap: () {
|
||
context.push(RouteConstants.consultantFinancesScreen);
|
||
},
|
||
);
|
||
}
|
||
}
|
||
|
||
class _ClientStartPlanSubscriptionToAuthorWidget extends StatelessWidget {
|
||
const _ClientStartPlanSubscriptionToAuthorWidget({required this.notification});
|
||
final ClientStartPlanSubscriptionToAuthorNotification notification;
|
||
@override
|
||
Widget build(BuildContext context) {
|
||
return _BaseNotificationWidget(
|
||
isRead: notification.isRead,
|
||
notificationsText: 'Новый подписчик! Клиент ${notification.clientName} начал подписку на план "${notification.planName}" 🎈',
|
||
createdAt: notification.createdAt,
|
||
onTap: () {
|
||
_navigateToBottomNavRoute(context, RouteConstants.chatSelectScreen, notification.clientName.isNotEmpty ? notification.clientName : null);
|
||
},
|
||
);
|
||
}
|
||
}
|
||
|
||
class _ClientCancelPlanSubscriptionToAuthorWidget extends StatelessWidget {
|
||
const _ClientCancelPlanSubscriptionToAuthorWidget({required this.notification});
|
||
final ClientCancelPlanSubscriptionToAuthorNotification notification;
|
||
@override
|
||
Widget build(BuildContext context) {
|
||
return _BaseNotificationWidget(
|
||
isRead: notification.isRead,
|
||
notificationsText: 'Отмена подписки: Клиент ${notification.clientName} отказался от плана "${notification.planName}"',
|
||
createdAt: notification.createdAt,
|
||
onTap: () {
|
||
_navigateToBottomNavRoute(context, RouteConstants.chatSelectScreen, notification.clientName.isNotEmpty ? notification.clientName : null);
|
||
},
|
||
);
|
||
}
|
||
}
|
||
|
||
class _ClientCancelPlanSubscriptionToSubscriberWidget extends StatelessWidget {
|
||
const _ClientCancelPlanSubscriptionToSubscriberWidget({required this.notification});
|
||
final ClientCancelPlanSubscriptionToSubscriberNotification notification;
|
||
@override
|
||
Widget build(BuildContext context) {
|
||
return _BaseNotificationWidget(
|
||
isRead: notification.isRead,
|
||
notificationsText: 'Ваша подписка на план "${notification.planName}" была отменена.',
|
||
createdAt: notification.createdAt,
|
||
onTap: () {
|
||
_navigateToBottomNavRoute(context, RouteConstants.chatSelectScreen);
|
||
},
|
||
);
|
||
}
|
||
}
|
||
|
||
class _UserDailyReportCompletedWidget extends StatelessWidget {
|
||
const _UserDailyReportCompletedWidget({required this.notification});
|
||
final UserDailyReportCompletedNotification notification;
|
||
@override
|
||
Widget build(BuildContext context) {
|
||
return _BaseNotificationWidget(
|
||
isRead: notification.isRead,
|
||
notificationsText: 'Отчет получен: Клиент ${notification.clientName} заполнил дневник по плану "${notification.planName}" 📝',
|
||
createdAt: notification.createdAt,
|
||
onTap: () {
|
||
context.push(UserDiaryScreen.path, extra: {'diaryId': notification.diaryId});
|
||
},
|
||
);
|
||
}
|
||
}
|
||
|
||
class _StayOnTrackToCustomerWidget extends StatelessWidget {
|
||
const _StayOnTrackToCustomerWidget({required this.notification});
|
||
final StayOnTrackToCustomerNotification notification;
|
||
@override
|
||
Widget build(BuildContext context) {
|
||
return _BaseNotificationWidget(
|
||
isRead: notification.isRead,
|
||
notificationsText: 'Вы продолжаете идти по плану "${notification.planName}" (день ${notification.dayNum}) 💪',
|
||
createdAt: notification.createdAt,
|
||
);
|
||
}
|
||
}
|
||
|
||
class _PhoneChangedWidget extends StatelessWidget {
|
||
const _PhoneChangedWidget({required this.notification});
|
||
final PhoneChangedNotification notification;
|
||
@override
|
||
Widget build(BuildContext context) {
|
||
return _BaseNotificationWidget(
|
||
isRead: notification.isRead,
|
||
notificationsText: 'Ваш номер телефона был успешно изменен на ${notification.newPhone} 📱',
|
||
createdAt: notification.createdAt,
|
||
);
|
||
}
|
||
}
|
||
|
||
class _SubscriptionWidget extends StatelessWidget {
|
||
const _SubscriptionWidget({required this.notification});
|
||
final SubscriptionNotification notification;
|
||
@override
|
||
Widget build(BuildContext context) {
|
||
return _BaseNotificationWidget(
|
||
isRead: notification.isRead,
|
||
notificationsText: 'У вас новый подписчик: ${notification.userName} 🎉',
|
||
createdAt: notification.createdAt,
|
||
onTap: () {
|
||
context.push(RouteConstants.subsScreen, extra: SubType.subscribers);
|
||
},
|
||
);
|
||
}
|
||
}
|
||
|
||
class _BadgeAwardedWidget extends StatelessWidget {
|
||
const _BadgeAwardedWidget({required this.notification});
|
||
final BadgeAwardedNotification notification;
|
||
@override
|
||
Widget build(BuildContext context) {
|
||
return _BaseNotificationWidget(
|
||
isRead: notification.isRead,
|
||
notificationsText: 'Новая награда! Вы получили значок "${notification.badgeTitle}" (${notification.badgeType}) 🏅',
|
||
createdAt: notification.createdAt,
|
||
onTap: () {
|
||
_navigateToBottomNavRoute(context, RouteConstants.myProfileScreen);
|
||
},
|
||
);
|
||
}
|
||
}
|
||
|
||
class _BadgeRevokedWidget extends StatelessWidget {
|
||
const _BadgeRevokedWidget({required this.notification});
|
||
final BadgeRevokedNotification notification;
|
||
@override
|
||
Widget build(BuildContext context) {
|
||
return _BaseNotificationWidget(
|
||
isRead: notification.isRead,
|
||
notificationsText: 'Значок "${notification.badgeTitle}" (${notification.badgeType}) был отозван.',
|
||
createdAt: notification.createdAt,
|
||
onTap: () {
|
||
_navigateToBottomNavRoute(context, RouteConstants.myProfileScreen);
|
||
},
|
||
);
|
||
}
|
||
}
|
||
|
||
class _ConsultantRequestStartedWidget extends StatelessWidget {
|
||
const _ConsultantRequestStartedWidget({required this.notification});
|
||
final ConsultantRequestStartedNotification notification;
|
||
@override
|
||
Widget build(BuildContext context) {
|
||
return _BaseNotificationWidget(
|
||
isRead: notification.isRead,
|
||
notificationsText: 'Запрос отправлен консультанту ${notification.consultantName} 📩',
|
||
createdAt: notification.createdAt,
|
||
);
|
||
}
|
||
}
|
||
|
||
class _ClientCloseComplaintSuccessWidget extends StatelessWidget {
|
||
const _ClientCloseComplaintSuccessWidget({required this.notification});
|
||
final ClientCloseComplaintSuccessNotification notification;
|
||
@override
|
||
Widget build(BuildContext context) {
|
||
return _BaseNotificationWidget(
|
||
isRead: notification.isRead,
|
||
notificationsText: 'Ваша жалоба по плану "${notification.planName}" была рассмотрена и закрыта.',
|
||
createdAt: notification.createdAt,
|
||
);
|
||
}
|
||
}
|
||
|
||
class _ClientRefundSuccessWidget extends StatelessWidget {
|
||
const _ClientRefundSuccessWidget({required this.notification});
|
||
final ClientRefundSuccessNotification notification;
|
||
@override
|
||
Widget build(BuildContext context) {
|
||
return _BaseNotificationWidget(
|
||
isRead: notification.isRead,
|
||
notificationsText: 'Вам одобрен возврат средств по плану "${notification.planName}" (${notification.amount}).',
|
||
createdAt: notification.createdAt,
|
||
onTap: () {
|
||
context.push(RouteConstants.userFinanceScreen);
|
||
},
|
||
);
|
||
}
|
||
}
|
||
|
||
class _ConsultantRefundSuccessWidget extends StatelessWidget {
|
||
const _ConsultantRefundSuccessWidget({required this.notification});
|
||
final ConsultantRefundSuccessNotification notification;
|
||
@override
|
||
Widget build(BuildContext context) {
|
||
return _BaseNotificationWidget(
|
||
isRead: notification.isRead,
|
||
notificationsText: 'Выполнен возврат средств клиенту ${notification.clientName} по плану "${notification.planName}" (${notification.amount})',
|
||
createdAt: notification.createdAt,
|
||
onTap: () {
|
||
context.push(RouteConstants.consultantFinancesScreen);
|
||
},
|
||
);
|
||
}
|
||
}
|
||
|
||
class _ClientRejectSuccessWidget extends StatelessWidget {
|
||
const _ClientRejectSuccessWidget({required this.notification});
|
||
final ClientRejectSuccessNotification notification;
|
||
@override
|
||
Widget build(BuildContext context) {
|
||
return _BaseNotificationWidget(
|
||
isRead: notification.isRead,
|
||
notificationsText: 'Отказ по плану "${notification.planName}" принят.',
|
||
createdAt: notification.createdAt,
|
||
onTap: () {
|
||
_navigateToBottomNavRoute(context, RouteConstants.chatSelectScreen);
|
||
},
|
||
);
|
||
}
|
||
}
|
||
|
||
class _ConsultantRejectSuccessWidget extends StatelessWidget {
|
||
const _ConsultantRejectSuccessWidget({required this.notification});
|
||
final ConsultantRejectSuccessNotification notification;
|
||
@override
|
||
Widget build(BuildContext context) {
|
||
return _BaseNotificationWidget(
|
||
isRead: notification.isRead,
|
||
notificationsText: 'Клиент ${notification.clientName} отказался от плана "${notification.planName}".',
|
||
createdAt: notification.createdAt,
|
||
onTap: () {
|
||
_navigateToBottomNavRoute(context, RouteConstants.chatSelectScreen, notification.clientName.isNotEmpty ? notification.clientName : null);
|
||
},
|
||
);
|
||
}
|
||
}
|
||
|
||
class _ScoreSubstractedWidget extends StatelessWidget {
|
||
const _ScoreSubstractedWidget({required this.notification});
|
||
final ScoreSubstractedNotification notification;
|
||
@override
|
||
Widget build(BuildContext context) {
|
||
return _BaseNotificationWidget(
|
||
isRead: notification.isRead,
|
||
notificationsText: 'Списание баллов: -${notification.scoreValue} за ${notification.scorableName}',
|
||
createdAt: notification.createdAt,
|
||
onTap: () {
|
||
_navigateToBottomNavRoute(context, RouteConstants.consultantRatingScreen);
|
||
},
|
||
);
|
||
}
|
||
}
|
||
|
||
class _ProductStatusUpdatedForAuthorWidget extends StatelessWidget {
|
||
const _ProductStatusUpdatedForAuthorWidget({required this.notification});
|
||
final ProductStatusUpdatedForAuthorNotification notification;
|
||
@override
|
||
Widget build(BuildContext context) {
|
||
final text = notification.subject.isNotEmpty
|
||
? notification.subject
|
||
: notification.status.isNotEmpty
|
||
? 'Статус продукта "${notification.productName}": ${notification.status}'
|
||
: 'Статус продукта "${notification.productName}" обновлен';
|
||
|
||
return _BaseNotificationWidget(isRead: notification.isRead, notificationsText: text, createdAt: notification.createdAt);
|
||
}
|
||
}
|
||
|
||
class _DiaryReminderForUsersWidget extends StatelessWidget {
|
||
const _DiaryReminderForUsersWidget({required this.notification});
|
||
final DiaryReminderForUsersNotification notification;
|
||
@override
|
||
Widget build(BuildContext context) {
|
||
return _BaseNotificationWidget(
|
||
isRead: notification.isRead,
|
||
notificationsText: 'Не забудьте заполнить дневник сегодня! 📓',
|
||
createdAt: notification.createdAt,
|
||
onTap: () {
|
||
final date = notification.createdAt;
|
||
_navigateToBottomNavRoute(context, RouteConstants.diaryScreen, date);
|
||
},
|
||
);
|
||
}
|
||
}
|
||
|
||
class _PersonalDietIsDefinedToCustomerWidget extends StatelessWidget {
|
||
const _PersonalDietIsDefinedToCustomerWidget({required this.notification});
|
||
final PersonalDietIsDefinedToCustomerNotification notification;
|
||
@override
|
||
Widget build(BuildContext context) {
|
||
return _BaseNotificationWidget(
|
||
isRead: notification.isRead,
|
||
notificationsText: 'Для вас составлена персональная диета "${notification.dietName}"! 🥗',
|
||
createdAt: notification.createdAt,
|
||
onTap: () {
|
||
if (notification.dietId > 0) {
|
||
context.push(RouteConstants.aboutDietScreen, extra: {'id': notification.dietId});
|
||
}
|
||
},
|
||
);
|
||
}
|
||
}
|
||
|
||
class _ConsultantEducationUpdatedWidget extends StatelessWidget {
|
||
const _ConsultantEducationUpdatedWidget({required this.notification});
|
||
final ConsultantEducationUpdatedNotification notification;
|
||
@override
|
||
Widget build(BuildContext context) {
|
||
return _BaseNotificationWidget(
|
||
isRead: notification.isRead,
|
||
notificationsText: 'Консультант ${notification.consultantName} обновил данные об образовании.',
|
||
createdAt: notification.createdAt,
|
||
onTap: () {
|
||
_navigateToBottomNavRoute(context, RouteConstants.myProfileScreen);
|
||
},
|
||
);
|
||
}
|
||
}
|
||
|
||
class _ComplaintRegisteredWidget extends StatelessWidget {
|
||
const _ComplaintRegisteredWidget({required this.notification});
|
||
final ComplaintRegisteredNotification notification;
|
||
@override
|
||
Widget build(BuildContext context) {
|
||
return _BaseNotificationWidget(
|
||
isRead: notification.isRead,
|
||
notificationsText: 'Мы получили вашу жалобу на ${notification.entityName}. Спасибо за сигнал!',
|
||
createdAt: notification.createdAt,
|
||
);
|
||
}
|
||
}
|
||
|
||
class _ContentUnpublishedWidget extends StatelessWidget {
|
||
const _ContentUnpublishedWidget({required this.notification});
|
||
final ContentUnpublishedNotification notification;
|
||
@override
|
||
Widget build(BuildContext context) {
|
||
return _BaseNotificationWidget(
|
||
isRead: notification.isRead,
|
||
notificationsText: 'Ваша публикация ${notification.entityName} была скрыта. Причина: ${notification.reason}',
|
||
createdAt: notification.createdAt,
|
||
);
|
||
}
|
||
}
|
||
|
||
class _FinanceQuestionCreatedWidget extends StatelessWidget {
|
||
const _FinanceQuestionCreatedWidget({required this.notification});
|
||
final FinanceQuestionCreatedNotification notification;
|
||
@override
|
||
Widget build(BuildContext context) {
|
||
return _BaseNotificationWidget(
|
||
isRead: notification.isRead,
|
||
notificationsText: 'Служба поддержки: Новый вопрос по финансам: ${notification.questionText}',
|
||
createdAt: notification.createdAt,
|
||
onTap: () {
|
||
_navigateToBottomNavRoute(context, RouteConstants.chatSelectScreen);
|
||
},
|
||
);
|
||
}
|
||
}
|
||
|
||
class _NewChatMessageWidget extends StatelessWidget {
|
||
const _NewChatMessageWidget({required this.notification});
|
||
final NewChatMessageNotification notification;
|
||
@override
|
||
Widget build(BuildContext context) {
|
||
return _BaseNotificationWidget(
|
||
isRead: notification.isRead,
|
||
notificationsText: 'Входящее сообщение от ${notification.senderName}: "${notification.messagePreview}"',
|
||
createdAt: notification.createdAt,
|
||
onTap: () {
|
||
_navigateToBottomNavRoute(context, RouteConstants.chatSelectScreen, notification.senderName.isNotEmpty ? notification.senderName : null);
|
||
},
|
||
);
|
||
}
|
||
}
|
||
|
||
class _CompleteRegistrationWidget extends StatelessWidget {
|
||
const _CompleteRegistrationWidget({required this.notification});
|
||
final CompleteRegistrationNotification notification;
|
||
@override
|
||
Widget build(BuildContext context) {
|
||
return _BaseNotificationWidget(
|
||
isRead: notification.isRead,
|
||
notificationsText: 'Завершите регистрацию, чтобы получить доступ ко всем функциям! 🚀',
|
||
createdAt: notification.createdAt,
|
||
);
|
||
}
|
||
}
|
||
|
||
class _ChosenDietExpiredWidget extends StatelessWidget {
|
||
const _ChosenDietExpiredWidget({required this.notification});
|
||
final ChosenDietExpiredNotification notification;
|
||
@override
|
||
Widget build(BuildContext context) {
|
||
return _BaseNotificationWidget(
|
||
isRead: notification.isRead,
|
||
notificationsText: 'Диета "${notification.dietName}" завершена. Время подвести итоги!',
|
||
createdAt: notification.createdAt,
|
||
);
|
||
}
|
||
}
|
||
|
||
class _MotivateUserWidget extends StatelessWidget {
|
||
const _MotivateUserWidget({required this.notification});
|
||
final MotivateUserNotification notification;
|
||
@override
|
||
Widget build(BuildContext context) {
|
||
return _BaseNotificationWidget(isRead: notification.isRead, notificationsText: notification.message, createdAt: notification.createdAt);
|
||
}
|
||
}
|
||
|
||
class _CommentComplaintWidget extends StatelessWidget {
|
||
const _CommentComplaintWidget({required this.notification});
|
||
final CommentComplaintNotification notification;
|
||
@override
|
||
Widget build(BuildContext context) {
|
||
return _BaseNotificationWidget(
|
||
isRead: notification.isRead,
|
||
notificationsText: 'Поступила жалоба на ваш комментарий: "${notification.commentPreview}". Причина: ${notification.reason}',
|
||
createdAt: notification.createdAt,
|
||
);
|
||
}
|
||
}
|
||
|
||
class _CommentDeletedWidget extends StatelessWidget {
|
||
const _CommentDeletedWidget({required this.notification});
|
||
final CommentDeletedNotification notification;
|
||
@override
|
||
Widget build(BuildContext context) {
|
||
return _BaseNotificationWidget(
|
||
isRead: notification.isRead,
|
||
notificationsText: 'Ваш комментарий был удален по правилам сообщества: "${notification.commentPreview}"',
|
||
createdAt: notification.createdAt,
|
||
);
|
||
}
|
||
}
|
||
|
||
class _UserSubscribedWidget extends StatelessWidget {
|
||
const _UserSubscribedWidget({required this.notification});
|
||
final UserSubscribedNotification notification;
|
||
@override
|
||
Widget build(BuildContext context) {
|
||
return _BaseNotificationWidget(
|
||
isRead: notification.isRead,
|
||
notificationsText: 'У вас новый подписчик: ${notification.userName}! 👋',
|
||
createdAt: notification.createdAt,
|
||
);
|
||
}
|
||
}
|