forked from eatvio/eatvio_app
Compare commits
2 Commits
comments
...
notificati
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
26ff548752 | ||
|
|
43e9098d8d |
@@ -1,4 +1,5 @@
|
|||||||
String baseUrl = 'https://eatvio.ru';
|
String baseUrl = 'https://eatvio.ru';
|
||||||
|
// String baseUrl = 'https://dev2.eatvio.com';
|
||||||
|
|
||||||
const List<int> durationValues = [7, 14, 21];
|
const List<int> durationValues = [7, 14, 21];
|
||||||
|
|
||||||
|
|||||||
@@ -24,8 +24,8 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
|
|
||||||
class DiaryScreen extends StatelessWidget {
|
class DiaryScreen extends StatelessWidget {
|
||||||
const DiaryScreen({super.key});
|
const DiaryScreen({super.key, this.date});
|
||||||
|
final DateTime? date;
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return const DiaryScreenContent();
|
return const DiaryScreenContent();
|
||||||
@@ -52,9 +52,10 @@ class UserDiaryScreen extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class DiaryScreenContent extends StatelessWidget {
|
class DiaryScreenContent extends StatelessWidget {
|
||||||
const DiaryScreenContent({super.key, this.diaryId, this.currentPlanDay});
|
const DiaryScreenContent({super.key, this.diaryId, this.currentPlanDay, this.date});
|
||||||
final int? diaryId;
|
final int? diaryId;
|
||||||
final int? currentPlanDay;
|
final int? currentPlanDay;
|
||||||
|
final DateTime? date;
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final s = S.of(context);
|
final s = S.of(context);
|
||||||
|
|||||||
@@ -8,8 +8,7 @@ import 'package:flutter_bloc/flutter_bloc.dart';
|
|||||||
import 'package:table_calendar/table_calendar.dart';
|
import 'package:table_calendar/table_calendar.dart';
|
||||||
|
|
||||||
class CalendarWidget extends StatefulWidget {
|
class CalendarWidget extends StatefulWidget {
|
||||||
const CalendarWidget({super.key});
|
const CalendarWidget({super.key,});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<CalendarWidget> createState() => _CalendarWidgetState();
|
State<CalendarWidget> createState() => _CalendarWidgetState();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -106,12 +106,16 @@ class DiaryReminderNotification implements BaseNotificationModel {
|
|||||||
final NotificationType type;
|
final NotificationType type;
|
||||||
@override
|
@override
|
||||||
final bool isRead;
|
final bool isRead;
|
||||||
|
final DateTime date;
|
||||||
|
|
||||||
DiaryReminderNotification({required this.type, required this.isRead});
|
DiaryReminderNotification({
|
||||||
|
required this.type,
|
||||||
|
required this.isRead,
|
||||||
|
required this.date,
|
||||||
|
});
|
||||||
|
|
||||||
factory DiaryReminderNotification.fromJson(Map<String, dynamic> json, NotificationType type, {bool? isRead}) {
|
factory DiaryReminderNotification.fromJson(Map<String, dynamic> json, NotificationType type, {bool? isRead}) {
|
||||||
return DiaryReminderNotification(type: type, isRead: isRead ?? false);
|
return DiaryReminderNotification(type: type, isRead: isRead ?? false, date: parseDate(json['date']));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,8 @@ class NotificationsCubit extends Cubit<NotificationsState> {
|
|||||||
Future<void> connectToWebSocket() async {
|
Future<void> connectToWebSocket() async {
|
||||||
await _newNotificationsSubscription?.cancel();
|
await _newNotificationsSubscription?.cancel();
|
||||||
_newNotificationsSubscription = wsManager.newNotificationsStream?.listen((event) {
|
_newNotificationsSubscription = wsManager.newNotificationsStream?.listen((event) {
|
||||||
_handleNotification(event.data);
|
|
||||||
|
_handleNotification(event.data, event.rootObject['created_at']);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -49,8 +50,9 @@ class NotificationsCubit extends Cubit<NotificationsState> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void _handleNotification(String notificationData) {
|
void _handleNotification(String notificationData, String createdAt) {
|
||||||
final json = jsonDecode(notificationData) as Map<String, dynamic>;
|
final json = jsonDecode(notificationData) as Map<String, dynamic>;
|
||||||
|
json.addAll({'date': createdAt});
|
||||||
final stringifiedType = json['notification_class_name'];
|
final stringifiedType = json['notification_class_name'];
|
||||||
final type = NotificationType.getTypeFromString(stringifiedType);
|
final type = NotificationType.getTypeFromString(stringifiedType);
|
||||||
final notification = _parseNotification(json, type);
|
final notification = _parseNotification(json, type);
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ class NotificationWidget extends StatelessWidget {
|
|||||||
notification: notification as ChosenPlanTomorrowReminderToClientNotification,
|
notification: notification as ChosenPlanTomorrowReminderToClientNotification,
|
||||||
),
|
),
|
||||||
DiaryReminderNotification() => _DiaryReminderWidget(
|
DiaryReminderNotification() => _DiaryReminderWidget(
|
||||||
notification: notification as DiaryReminderNotification,
|
notification: notification as DiaryReminderNotification,
|
||||||
),
|
),
|
||||||
ConsultantLeftCommentNotification() => _ConsultantLeftCommentWidget(
|
ConsultantLeftCommentNotification() => _ConsultantLeftCommentWidget(
|
||||||
notification: notification as ConsultantLeftCommentNotification,
|
notification: notification as ConsultantLeftCommentNotification,
|
||||||
@@ -121,6 +121,9 @@ class _DiaryReminderWidget extends StatelessWidget {
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final s = S.of(context);
|
final s = S.of(context);
|
||||||
return _BaseNotificationWidget(
|
return _BaseNotificationWidget(
|
||||||
|
onTap: () {
|
||||||
|
GoRouter.of(context).go('/diary');
|
||||||
|
},
|
||||||
isRead: notification.isRead,
|
isRead: notification.isRead,
|
||||||
notificationsText: s.fillYasterday,
|
notificationsText: s.fillYasterday,
|
||||||
);
|
);
|
||||||
@@ -252,32 +255,36 @@ class _ChosenPlanFinishedToConsultantWidget extends StatelessWidget {
|
|||||||
|
|
||||||
// CardSettingsScreen
|
// CardSettingsScreen
|
||||||
class _BaseNotificationWidget extends StatelessWidget {
|
class _BaseNotificationWidget extends StatelessWidget {
|
||||||
const _BaseNotificationWidget({required this.notificationsText, required this.isRead});
|
const _BaseNotificationWidget({required this.notificationsText, required this.isRead, this.onTap});
|
||||||
final String notificationsText;
|
final String notificationsText;
|
||||||
final bool isRead;
|
final bool isRead;
|
||||||
|
final Function()? onTap;
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Row(
|
return GestureDetector(
|
||||||
children: [
|
onTap: onTap,
|
||||||
SizedBox(
|
child: Row(
|
||||||
width: MediaQuery.sizeOf(context).width * 0.6,
|
children: [
|
||||||
child: Text(
|
SizedBox(
|
||||||
notificationsText,
|
width: MediaQuery.sizeOf(context).width * 0.6,
|
||||||
style: TextStyles.textMMedium.copyWith(color: appTheme.black),
|
child: Text(
|
||||||
),
|
notificationsText,
|
||||||
),
|
style: TextStyles.textMMedium.copyWith(color: appTheme.black),
|
||||||
if (!isRead) ...[
|
|
||||||
const Spacer(),
|
|
||||||
Container(
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: appTheme.blueA400,
|
|
||||||
shape: BoxShape.circle,
|
|
||||||
),
|
),
|
||||||
width: 8,
|
),
|
||||||
height: 8,
|
if (!isRead) ...[
|
||||||
)
|
const Spacer(),
|
||||||
]
|
Container(
|
||||||
],
|
decoration: BoxDecoration(
|
||||||
|
color: appTheme.blueA400,
|
||||||
|
shape: BoxShape.circle,
|
||||||
|
),
|
||||||
|
width: 8,
|
||||||
|
height: 8,
|
||||||
|
)
|
||||||
|
]
|
||||||
|
],
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,7 +24,9 @@ class NotificationsService {
|
|||||||
ChosenPlanStartedToClientNotification.fromJson(notificationJson['data'], type, isRead: readDate != null),
|
ChosenPlanStartedToClientNotification.fromJson(notificationJson['data'], type, isRead: readDate != null),
|
||||||
NotificationType.chosenPlanTomorrowReminderToClientNotification =>
|
NotificationType.chosenPlanTomorrowReminderToClientNotification =>
|
||||||
ChosenPlanTomorrowReminderToClientNotification.fromJson(notificationJson['data'], type, isRead: readDate != null),
|
ChosenPlanTomorrowReminderToClientNotification.fromJson(notificationJson['data'], type, isRead: readDate != null),
|
||||||
NotificationType.diaryReminderNotification => DiaryReminderNotification.fromJson(notificationJson['data'], type, isRead: readDate != null),
|
NotificationType.diaryReminderNotification => DiaryReminderNotification.fromJson(
|
||||||
|
(notificationJson['data'] as Map<String, dynamic>).putIfAbsent('date', () => notificationJson['created_at']), type,
|
||||||
|
isRead: readDate != null),
|
||||||
NotificationType.consultantLeftComment => ConsultantLeftCommentNotification.fromJson(notificationJson['data'], type, isRead: readDate != null),
|
NotificationType.consultantLeftComment => ConsultantLeftCommentNotification.fromJson(notificationJson['data'], type, isRead: readDate != null),
|
||||||
NotificationType.personalizedDietIsDefined =>
|
NotificationType.personalizedDietIsDefined =>
|
||||||
PersonalizedDietIsDefinedNotification.fromJson(notificationJson['data'], type, isRead: readDate != null),
|
PersonalizedDietIsDefinedNotification.fromJson(notificationJson['data'], type, isRead: readDate != null),
|
||||||
|
|||||||
Reference in New Issue
Block a user