Notificatio screen updated
This commit is contained in:
parent
d75170e314
commit
7d658f4b70
@ -1,11 +1,9 @@
|
|||||||
import 'package:cheminova/models/notification_list_response.dart';
|
|
||||||
import 'package:cheminova/provider/notification_provider.dart';
|
import 'package:cheminova/provider/notification_provider.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:cheminova/widgets/common_background.dart';
|
import 'package:cheminova/widgets/common_background.dart';
|
||||||
import 'package:cheminova/widgets/common_drawer.dart';
|
import 'package:cheminova/widgets/common_drawer.dart';
|
||||||
import 'package:cheminova/widgets/common_app_bar.dart';
|
import 'package:cheminova/widgets/common_app_bar.dart';
|
||||||
import 'package:cheminova/widgets/common_elevated_button.dart';
|
import 'package:cheminova/widgets/common_elevated_button.dart';
|
||||||
import 'package:flutter/widgets.dart';
|
|
||||||
import 'package:intl/intl.dart';
|
import 'package:intl/intl.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
@ -127,20 +125,8 @@ class MyListView extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
// Group notifications by date
|
|
||||||
Map<String, List<Notifications>> groupedNotifications = {};
|
|
||||||
|
|
||||||
for (var notification in value.notificationList) {
|
|
||||||
String date = DateFormat("dd MMM yyyy")
|
|
||||||
.format(DateTime.parse(notification.createdAt ?? ''));
|
|
||||||
if (!groupedNotifications.containsKey(date)) {
|
|
||||||
groupedNotifications[date] = [];
|
|
||||||
}
|
|
||||||
groupedNotifications[date]!.add(notification);
|
|
||||||
}
|
|
||||||
|
|
||||||
return Expanded(
|
return Expanded(
|
||||||
child: (groupedNotifications.isEmpty)
|
child: (value.notificationList.isEmpty)
|
||||||
? const Center(
|
? const Center(
|
||||||
child: Text(
|
child: Text(
|
||||||
'No notifications for selected date',
|
'No notifications for selected date',
|
||||||
@ -149,45 +135,24 @@ class MyListView extends StatelessWidget {
|
|||||||
)
|
)
|
||||||
: ListView.builder(
|
: ListView.builder(
|
||||||
padding: const EdgeInsets.only(top: 15),
|
padding: const EdgeInsets.only(top: 15),
|
||||||
itemCount: groupedNotifications.length,
|
itemCount: value.notificationList.length,
|
||||||
itemBuilder: (context, index) {
|
itemBuilder: (context, index) {
|
||||||
String date = groupedNotifications.keys.elementAt(index);
|
|
||||||
List<Notifications> notificationsForDate =
|
|
||||||
groupedNotifications[date]!;
|
|
||||||
|
|
||||||
return Padding(
|
return Padding(
|
||||||
padding:
|
padding:
|
||||||
const EdgeInsets.only(bottom: 10, left: 10, right: 10),
|
const EdgeInsets.only(bottom: 10, left: 10, right: 10),
|
||||||
child: Column(
|
child: Padding(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
padding: const EdgeInsets.only(bottom: 10),
|
||||||
children: [
|
child: ExpansionTile(
|
||||||
// Display the date once
|
collapsedBackgroundColor: Colors.white,
|
||||||
Padding(
|
backgroundColor: Colors.white,
|
||||||
padding: const EdgeInsets.only(bottom: 8.0),
|
trailing: const SizedBox.shrink(),
|
||||||
child: Text(
|
title: Text(
|
||||||
date,
|
value.notificationList[index].title ?? '',
|
||||||
style: const TextStyle(
|
style: const TextStyle(
|
||||||
fontSize: 16, fontWeight: FontWeight.bold),
|
fontSize: 17, fontWeight: FontWeight.w500),
|
||||||
),
|
|
||||||
),
|
),
|
||||||
// Display notifications for the date
|
subtitle: Text(value.notificationList[index].msg ?? ''),
|
||||||
...notificationsForDate.map(
|
),
|
||||||
(item) => Padding(
|
|
||||||
padding: const EdgeInsets.only(bottom: 10),
|
|
||||||
child: ExpansionTile(
|
|
||||||
collapsedBackgroundColor: Colors.white,
|
|
||||||
backgroundColor: Colors.white,
|
|
||||||
trailing: const SizedBox.shrink(),
|
|
||||||
title: Text(
|
|
||||||
item.title ?? '',
|
|
||||||
style: const TextStyle(
|
|
||||||
fontSize: 17, fontWeight: FontWeight.w500),
|
|
||||||
),
|
|
||||||
subtitle: Text(item.msg ?? ''),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user