You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
cloudsolutions-atoms/lib/views/pages/user/notifications/notifications_list.dart

46 lines
1.8 KiB
Dart

import 'package:flutter/material.dart';
import 'package:test_sa/controllers/notification/firebase_notification_manger.dart';
import 'package:test_sa/extensions/context_extension.dart';
import 'package:test_sa/extensions/widget_extensions.dart';
import 'package:test_sa/models/system_notification_model.dart';
import 'package:test_sa/views/widgets/loaders/lazy_loading.dart';
import 'package:test_sa/views/widgets/loaders/no_item_found.dart';
import 'package:test_sa/views/widgets/notifications/notification_item.dart';
class NotificationsList extends StatelessWidget {
final List<SystemNotificationModel> notifications;
final bool nextPage;
final Future<void> Function() onLazyLoad;
const NotificationsList({Key key, this.notifications, this.nextPage, this.onLazyLoad}) : super(key: key);
@override
Widget build(BuildContext context) {
if (notifications.isEmpty) {
return NoItemFound(message: context.translation.notificationsNotFound);
}
return LazyLoading(
nextPage: nextPage,
onLazyLoad: onLazyLoad,
child: SingleChildScrollView(
padding: const EdgeInsets.all(16),
child: ListView.separated(
shrinkWrap: true,
physics: const NeverScrollableScrollPhysics(),
padding: const EdgeInsets.all(0),
itemCount: notifications.length,
separatorBuilder: (context, itemIndex) => const Divider().defaultStyle(context).paddingOnly(top: 16, bottom: 16),
itemBuilder: (context, itemIndex) {
return NotificationItem(
notification: notifications[itemIndex],
onPressed: (notification) {
FirebaseNotificationManger.handleMessage(context, notification.toNotificationJson());
},
);
},
).toShadowContainer(context),
),
);
}
}