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:flutter/material.dart';
|
||||
import 'package:cheminova/widgets/common_background.dart';
|
||||
import 'package:cheminova/widgets/common_drawer.dart';
|
||||
import 'package:cheminova/widgets/common_app_bar.dart';
|
||||
import 'package:cheminova/widgets/common_elevated_button.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
@ -127,20 +125,8 @@ class MyListView extends StatelessWidget {
|
||||
|
||||
@override
|
||||
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(
|
||||
child: (groupedNotifications.isEmpty)
|
||||
child: (value.notificationList.isEmpty)
|
||||
? const Center(
|
||||
child: Text(
|
||||
'No notifications for selected date',
|
||||
@ -149,45 +135,24 @@ class MyListView extends StatelessWidget {
|
||||
)
|
||||
: ListView.builder(
|
||||
padding: const EdgeInsets.only(top: 15),
|
||||
itemCount: groupedNotifications.length,
|
||||
itemCount: value.notificationList.length,
|
||||
itemBuilder: (context, index) {
|
||||
String date = groupedNotifications.keys.elementAt(index);
|
||||
List<Notifications> notificationsForDate =
|
||||
groupedNotifications[date]!;
|
||||
|
||||
return Padding(
|
||||
padding:
|
||||
const EdgeInsets.only(bottom: 10, left: 10, right: 10),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
// Display the date once
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(bottom: 8.0),
|
||||
child: Text(
|
||||
date,
|
||||
style: const TextStyle(
|
||||
fontSize: 16, fontWeight: FontWeight.bold),
|
||||
),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(bottom: 10),
|
||||
child: ExpansionTile(
|
||||
collapsedBackgroundColor: Colors.white,
|
||||
backgroundColor: Colors.white,
|
||||
trailing: const SizedBox.shrink(),
|
||||
title: Text(
|
||||
value.notificationList[index].title ?? '',
|
||||
style: const TextStyle(
|
||||
fontSize: 17, fontWeight: FontWeight.w500),
|
||||
),
|
||||
// Display notifications for the date
|
||||
...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 ?? ''),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
subtitle: Text(value.notificationList[index].msg ?? ''),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user