From 5e1d6517dee106fdc55944ec66fe537eeabd9e84 Mon Sep 17 00:00:00 2001 From: zaid_daoud Date: Mon, 6 Nov 2023 10:15:19 +0300 Subject: [PATCH] Change Notifications Screen Design DONE --- .../notifications/notifications_list.dart | 47 ++++++++------ .../notifications/notification_item.dart | 65 +++++++------------ 2 files changed, 49 insertions(+), 63 deletions(-) diff --git a/lib/views/pages/user/notifications/notifications_list.dart b/lib/views/pages/user/notifications/notifications_list.dart index c01425f4..22296c0d 100644 --- a/lib/views/pages/user/notifications/notifications_list.dart +++ b/lib/views/pages/user/notifications/notifications_list.dart @@ -1,9 +1,7 @@ import 'package:flutter/material.dart'; -import 'package:test_sa/controllers/localization/localization.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/models/subtitle.dart'; -import 'package:test_sa/views/pages/user/requests/future_request_service_details.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'; @@ -17,28 +15,35 @@ class NotificationsList extends StatelessWidget { @override Widget build(BuildContext context) { - - if (notifications.length == 0) { - return NoItemFound( - message: context.translation.notificationsNotFound, - ); + if (notifications.isEmpty) { + return NoItemFound(message: context.translation.notificationsNotFound); } return LazyLoading( nextPage: nextPage, onLazyLoad: onLazyLoad, - child: ListView.builder( - physics: BouncingScrollPhysics(), - itemCount: notifications.length, - padding: EdgeInsets.symmetric(horizontal: 16, vertical: 8), - 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); - }, - ); - }), + 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), ); } } diff --git a/lib/views/widgets/notifications/notification_item.dart b/lib/views/widgets/notifications/notification_item.dart index be4412e3..5e0b7a81 100644 --- a/lib/views/widgets/notifications/notification_item.dart +++ b/lib/views/widgets/notifications/notification_item.dart @@ -1,7 +1,9 @@ import 'package:flutter/material.dart'; +import 'package:test_sa/extensions/int_extensions.dart'; +import 'package:test_sa/extensions/string_extensions.dart'; +import 'package:test_sa/extensions/text_extensions.dart'; +import 'package:test_sa/extensions/widget_extensions.dart'; import 'package:test_sa/models/system_notification_model.dart'; -import 'package:test_sa/views/app_style/colors.dart'; -import 'package:test_sa/views/app_style/sizing.dart'; class NotificationItem extends StatelessWidget { final SystemNotificationModel notification; @@ -11,49 +13,28 @@ class NotificationItem extends StatelessWidget { @override Widget build(BuildContext context) { - return Padding( - padding: const EdgeInsets.symmetric(vertical: 4), - child: ElevatedButton( - style: ElevatedButton.styleFrom( - padding: EdgeInsets.symmetric(vertical: 8, horizontal: 8), - primary: AColors.primaryColor, - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(AppStyle.getBorderRadius(context)), - ), - ), - onPressed: () { - onPressed(notification); - }, - child: Column( + return Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Row( - children: [ - Expanded( - child: Text( - notification.title ?? "No Hospital Found", - style: Theme.of(context).textTheme.headline6.copyWith(color: AColors.white, fontSize: 16, fontWeight: FontWeight.bold), - ), - ), - Text( - notification.createdOn ?? "complaint not available", - style: Theme.of(context).textTheme.subtitle1.copyWith(color: AColors.white, fontSize: 12, fontWeight: FontWeight.bold), - ), - ], - ), - Divider( - color: AColors.white, - ), - Text( - notification.text ?? "complaint not available", - style: Theme.of(context).textTheme.subtitle1.copyWith( - color: AColors.white, - fontSize: 14, - ), + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + (notification.title ?? "No Hospital Found").heading6(context), + 8.height, + (notification.text ?? "complaint not available").bodyText2(context), + ], + ), ), + (notification.createdOn.toServiceRequestCardFormat ?? "complaint not available").tinyFont(context), ], - ), - ), - ); + ).onPress(() { + onPressed(notification); + }), + ], + ).paddingAll(16); } }