forked from eatvio/eatvio_app
added notifications layoute
This commit is contained in:
@@ -74,33 +74,3 @@ class NotificationsCubit extends Cubit<NotificationsState> {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
final qwe = {
|
||||
'event': 'IlluminateNotificationsEventsBroadcastNotificationCreated',
|
||||
'channel': 'private-message-events.36',
|
||||
'data': {
|
||||
"plan_name": "Little Cheeseburger",
|
||||
"plan_id": 18,
|
||||
"user_name": "\u041b\u044f\u043f\u0438\u0441 \u041b\u0430\u043f\u0448\u0430",
|
||||
"user_id": 53,
|
||||
"user_photo_path": "https://dev2.eatvio.com/storage/profile-photos/X2aHwD6IOIFxEK8HM2d2oLuqio5BmocDLeWoH3Gs.jpg",
|
||||
"chat_id": "3d14615d-1388-4833-8165-b40daa78f96a",
|
||||
"chat_url": "https://dev2.eatvio.com/chat/3d14615d-1388-4833-8165-b40daa78f96a",
|
||||
"notification_class_name": "App\\Notifications\\Plan\\PlanSubscriptionStartedToAuthor",
|
||||
"database_type": "client-start-plan-subscription-to-author",
|
||||
"id": "65cbea6d-1734-406e-b5da-79db270aed90",
|
||||
"type": "client-start-plan-subscription-to-author"
|
||||
}
|
||||
};
|
||||
final qwe2 = {
|
||||
"plan_name": "Little Cheeseburger",
|
||||
"plan_id": 18,
|
||||
"user_name": "\u041b\u044f\u043f\u0438\u0441 \u041b\u0430\u043f\u0448\u0430",
|
||||
"user_id": 53,
|
||||
"user_photo_path": "https://dev2.eatvio.com/storage/profile-photos/X2aHwD6IOIFxEK8HM2d2oLuqio5BmocDLeWoH3Gs.jpg",
|
||||
"chat_url": "https://dev2.eatvio.com/chat/3d14615d-1388-4833-8165-b40daa78f96a",
|
||||
"notification_class_name": "App\\Notifications\\Plan\\PlanSubscriptionCanceledToAuthor",
|
||||
"database_type": "client-cancel-plan-subscription-to-author",
|
||||
"id": "cf86d0e7-8ebb-4360-9b8a-b6df97e12aed",
|
||||
"type": "client-cancel-plan-subscription-to-author"
|
||||
};
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import 'package:eatvio_app/core/theme/theme_helper.dart';
|
||||
import 'package:eatvio_app/core/widgets/custom_divider.dart';
|
||||
import 'package:eatvio_app/features/notifications/presentation/notifications_cubit/notifications_cubit.dart';
|
||||
import 'package:eatvio_app/features/notifications/presentation/notifications_cubit/notifications_state.dart';
|
||||
import 'package:eatvio_app/features/notifications/presentation/widgets/notification_widget.dart';
|
||||
@@ -12,19 +14,42 @@ class NotificationsScreen extends StatelessWidget {
|
||||
return BlocBuilder<NotificationsCubit, NotificationsState>(
|
||||
builder: (BuildContext context, NotificationsState state) {
|
||||
return Scaffold(
|
||||
backgroundColor: appTheme.gray100,
|
||||
appBar: AppBar(
|
||||
title: const Text('Уведомления'),
|
||||
),
|
||||
body: state is NotificationsStateLoaded
|
||||
? CustomScrollView(
|
||||
slivers: [
|
||||
SliverList.builder(
|
||||
itemBuilder: (context, index) => NotificationWidget(
|
||||
notification: state.notifications[index],
|
||||
? Padding(
|
||||
padding: const EdgeInsets.only(top: 8.0),
|
||||
child: Container(
|
||||
padding: const EdgeInsets.only(top: 16),
|
||||
decoration: BoxDecoration(
|
||||
color: appTheme.whiteA700,
|
||||
borderRadius: const BorderRadius.only(
|
||||
topLeft: Radius.circular(12),
|
||||
topRight: Radius.circular(12),
|
||||
),
|
||||
itemCount: state.notifications.length,
|
||||
)
|
||||
],
|
||||
),
|
||||
child: CustomScrollView(
|
||||
slivers: [
|
||||
SliverList.separated(
|
||||
separatorBuilder: (context, index) => const Padding(
|
||||
padding: EdgeInsets.symmetric(vertical: 12, horizontal: 16),
|
||||
child: CustomDivider(),
|
||||
),
|
||||
itemBuilder: (context, index) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||
child: NotificationWidget(
|
||||
notification: state.notifications[index],
|
||||
),
|
||||
);
|
||||
},
|
||||
itemCount: state.notifications.length,
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
)
|
||||
: const Placeholder(),
|
||||
);
|
||||
|
||||
@@ -1,21 +1,257 @@
|
||||
import 'package:eatvio_app/core/theme/custom_text_style.dart';
|
||||
import 'package:eatvio_app/core/theme/theme_helper.dart';
|
||||
import 'package:eatvio_app/core/widgets/custom_outlined_button.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/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 Container(
|
||||
width: MediaQuery.sizeOf(context).width,
|
||||
height: 60,
|
||||
margin: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
|
||||
decoration: BoxDecoration(
|
||||
color: appTheme.green,
|
||||
borderRadius: BorderRadius.circular(18),
|
||||
),
|
||||
child: Center(child: Text(notification.type.name)),
|
||||
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() => throw _PlanSubscriptionPaidToAuthorWidget(
|
||||
notification: notification as PlanSubscriptionPaidToAuthorNotification,
|
||||
),
|
||||
ChosenPlanFinishedToConsultantNotification() => _ChosenPlanFinishedToConsultantWidget(
|
||||
notification: notification as ChosenPlanFinishedToConsultantNotification,
|
||||
),
|
||||
UnknownNotification() => const SizedBox.shrink(),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
class _PlanSubscriptionStartedToAuthorWidget extends StatelessWidget {
|
||||
const _PlanSubscriptionStartedToAuthorWidget({required this.notification});
|
||||
final PlanSubscriptionStartedToAuthorNotification notification;
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final s = S.of(context);
|
||||
|
||||
return _BaseNotificationWidget(
|
||||
notificationsText: s.userSubscribedToPlan(notification.customerName, notification.planName),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _PlanSubscriptionCanceledToAuthorWidget extends StatelessWidget {
|
||||
const _PlanSubscriptionCanceledToAuthorWidget({required this.notification});
|
||||
final PlanSubscriptionCanceledToAuthorNotification notification;
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final s = S.of(context);
|
||||
|
||||
return _BaseNotificationWidget(
|
||||
notificationsText: s.userCanceldThePlanSubscription(notification.customerName, notification.planName),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _ChosenPlanStartedToClientWidget extends StatelessWidget {
|
||||
const _ChosenPlanStartedToClientWidget({required this.notification});
|
||||
final ChosenPlanStartedToClientNotification notification;
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final s = S.of(context);
|
||||
|
||||
return _BaseNotificationWidget(
|
||||
notificationsText: s.planStarted(notification.planName),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _ChosenPlanTomorrowReminderToClientWidget extends StatelessWidget {
|
||||
const _ChosenPlanTomorrowReminderToClientWidget({required this.notification});
|
||||
final ChosenPlanTomorrowReminderToClientNotification notification;
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final s = S.of(context);
|
||||
|
||||
return _BaseNotificationWidget(
|
||||
notificationsText: s.tomorrowYourPlanWillStart(notification.planName),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _DiaryReminderWidget extends StatelessWidget {
|
||||
const _DiaryReminderWidget({required this.notification});
|
||||
final DiaryReminderNotification notification;
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final s = S.of(context);
|
||||
return _BaseNotificationWidget(
|
||||
notificationsText: s.fillYasterday,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _ConsultantLeftCommentWidget extends StatelessWidget {
|
||||
const _ConsultantLeftCommentWidget({required this.notification});
|
||||
final ConsultantLeftCommentNotification notification;
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final s = S.of(context);
|
||||
|
||||
return _BaseNotificationWidget(
|
||||
notificationsText: s.consultantLeftComment(notification.date),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _PersonalizedDietIsDefinedWidget extends StatelessWidget {
|
||||
const _PersonalizedDietIsDefinedWidget({required this.notification});
|
||||
final PersonalizedDietIsDefinedNotification notification;
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container();
|
||||
}
|
||||
}
|
||||
|
||||
class _ChosenPlanFinishedToClientWidget extends StatelessWidget {
|
||||
const _ChosenPlanFinishedToClientWidget({required this.notification});
|
||||
final ChosenPlanFinishedToClientNotification notification;
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final s = S.of(context);
|
||||
|
||||
return _BaseNotificationWidget(
|
||||
notificationsText: '${s.congratsYouHaveFinishedPlan} «${notification.planName}»',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _PlanSubscriptionCanceledToCustomerWidget extends StatelessWidget {
|
||||
const _PlanSubscriptionCanceledToCustomerWidget({required this.notification});
|
||||
final PlanSubscriptionCanceledToCustomerNotification notification;
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final s = S.of(context);
|
||||
|
||||
return _BaseNotificationWidget(
|
||||
notificationsText: s.youCanceledSubscriptionToPlan(notification.planName),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _ChosenPlanStartedToConsultantWidget extends StatelessWidget {
|
||||
const _ChosenPlanStartedToConsultantWidget({required this.notification});
|
||||
final ChosenPlanStartedToConsultantNotification notification;
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final s = S.of(context);
|
||||
|
||||
return _BaseNotificationWidget(
|
||||
notificationsText: s.planWithUserStarted(notification.planName, notification.customerName),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _ChosenPlanTomorrowReminderToConsultantWidget extends StatelessWidget {
|
||||
const _ChosenPlanTomorrowReminderToConsultantWidget({required this.notification});
|
||||
final ChosenPlanTomorrowReminderToConsultantNotification notification;
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final s = S.of(context);
|
||||
|
||||
return _BaseNotificationWidget(
|
||||
notificationsText: s.tommorowPlanWithUserWillStart(notification.planName, notification.customerName),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _PlanSubscriptionPaidToAuthorWidget extends StatelessWidget {
|
||||
const _PlanSubscriptionPaidToAuthorWidget({required this.notification});
|
||||
final PlanSubscriptionPaidToAuthorNotification notification;
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final s = S.of(context);
|
||||
|
||||
return _BaseNotificationWidget(
|
||||
notificationsText: s.userPaidThePlan(notification.customerName, notification.planName),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _ChosenPlanFinishedToConsultantWidget extends StatelessWidget {
|
||||
const _ChosenPlanFinishedToConsultantWidget({required this.notification});
|
||||
final ChosenPlanFinishedToConsultantNotification notification;
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final s = S.of(context);
|
||||
return Container(
|
||||
child: Column(children: [
|
||||
Text(
|
||||
'${s.congratsYouHaveFinishedPlan} «${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).pushNamed(CardSettingsScreen.name, extra: notification.planId);
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
]),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// CardSettingsScreen
|
||||
class _BaseNotificationWidget extends StatelessWidget {
|
||||
const _BaseNotificationWidget({required this.notificationsText});
|
||||
final String notificationsText;
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return SizedBox(
|
||||
width: MediaQuery.sizeOf(context).width * 0.6,
|
||||
child: Text(
|
||||
notificationsText,
|
||||
style: TextStyles.textMMedium.copyWith(color: appTheme.black),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user