import 'package:flutter/material.dart'; import 'package:test_sa/extensions/context_extension.dart'; import 'package:test_sa/extensions/int_extensions.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( padding: const EdgeInsets.all(16), child: Container( decoration: ShapeDecoration( color: Colors.white, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(20), ), shadows: const [ BoxShadow( color: Color(0x07000000), blurRadius: 14, offset: Offset(0, 0), spreadRadius: 0, ) ], ), child: ListView.separated( shrinkWrap: true, physics: const NeverScrollableScrollPhysics(), padding: const EdgeInsets.all(16), itemCount: notifications.length, separatorBuilder: (context, itemIndex) => 1.divider.paddingOnly(top: 16, bottom: 16), itemBuilder: (context, itemIndex) { return 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); }, ); }, ), ), ), ); } }