import 'package:flutter/material.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 notifications; final bool nextPage; final Future 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( child: Card( child: ListView.builder( physics: const NeverScrollableScrollPhysics(), itemCount: notifications.length, shrinkWrap: true, itemBuilder: (context, itemIndex) { return Column( children: [ NotificationItem( notification: notifications[itemIndex], onPressed: (notification) { // todo @sikander, check notifications payload, because notification model is different to need to check from backend //Navigator.of(context).pushNamed(FutureRequestServiceDetails.id, arguments: notification.requestId); }, ), if (itemIndex != (notifications.length - 1)) const Divider().defaultStyle(context).paddingOnly(start: 16, end: 16), ], ); }, ), ), ).paddingAll(16), ); } }