diff --git a/Frontend/patient_manager/lib/mih_components/mih_pop_up_messages/mih_notification_message.dart b/Frontend/patient_manager/lib/mih_components/mih_pop_up_messages/mih_notification_message.dart index 9e4717fe..7a0a257f 100644 --- a/Frontend/patient_manager/lib/mih_components/mih_pop_up_messages/mih_notification_message.dart +++ b/Frontend/patient_manager/lib/mih_components/mih_pop_up_messages/mih_notification_message.dart @@ -25,6 +25,8 @@ class _MIHNotificationMessageState extends State late double popUpBodySize; late double popUpIconSize; late double popUpPaddingSize; + late Color primary; + late Color secondary; Size? size; void checkScreenSize() { @@ -35,105 +37,87 @@ class _MIHNotificationMessageState extends State popUpTitleSize = 20.0; popUpSubtitleSize = 20.0; popUpBodySize = 15; - popUpPaddingSize = 5.0; + popUpPaddingSize = 25.0; popUpIconSize = 100; }); } else { setState(() { - popUpWidth = size!.width - 20; + popUpWidth = size!.width; popUpheight = 90; popUpTitleSize = 20.0; popUpSubtitleSize = 18.0; popUpBodySize = 15; - popUpPaddingSize = 15.0; + popUpPaddingSize = 5.0; popUpIconSize = 100; }); } } - Widget NotifyPopUp() { + Widget notifyPopUp() { //messageTypes["Input Error"] = - return Stack( - children: [ - Container( - padding: EdgeInsets.all(popUpPaddingSize), - alignment: Alignment.topLeft, - width: popUpWidth, - height: popUpheight, - decoration: BoxDecoration( - color: MzanziInnovationHub.of(context)!.theme.secondaryColor(), - borderRadius: BorderRadius.circular(25.0), - // border: Border.all( - // color: MzanziInnovationHub.of(context)!.theme.primaryColor(), - // width: 5.0), - ), - child: SingleChildScrollView( - child: Column( - // crossAxisAlignment: CrossAxisAlignment.start, - // mainAxisAlignment: MainAxisAlignment.start, - mainAxisSize: MainAxisSize.max, + return GestureDetector( + onTap: widget.arguments.onTap, + child: Container( + padding: + EdgeInsets.symmetric(vertical: 5, horizontal: popUpPaddingSize), + alignment: Alignment.topLeft, + width: popUpWidth, + height: popUpheight, + decoration: BoxDecoration( + color: primary, + borderRadius: BorderRadius.circular(25.0), + border: Border.all(color: secondary, width: 5.0), + ), + child: Column( + // crossAxisAlignment: CrossAxisAlignment.start, + // mainAxisAlignment: MainAxisAlignment.start, + mainAxisSize: MainAxisSize.max, + children: [ + //const SizedBox(height: 5), + Row( + mainAxisAlignment: MainAxisAlignment.center, children: [ - //const SizedBox(height: 5), - Row( - children: [ - Icon( - Icons.notifications, - color: - MzanziInnovationHub.of(context)!.theme.primaryColor(), - ), - Flexible( - child: Text( - widget.arguments.title, - textAlign: TextAlign.left, - overflow: TextOverflow.ellipsis, - style: TextStyle( - color: MzanziInnovationHub.of(context)! - .theme - .primaryColor(), - fontSize: popUpTitleSize, - fontWeight: FontWeight.bold, - ), - ), - ), - ], + Icon( + Icons.notifications, + color: secondary, ), - const SizedBox(height: 5), - Row( - children: [ - Text( - widget.arguments.body, - textAlign: TextAlign.left, - style: TextStyle( - color: MzanziInnovationHub.of(context)! - .theme - .primaryColor(), - fontSize: popUpBodySize, - fontWeight: FontWeight.bold, - ), + const SizedBox(width: 10), + Flexible( + child: Text( + widget.arguments.title, + textAlign: TextAlign.center, + overflow: TextOverflow.ellipsis, + style: TextStyle( + color: secondary, + fontSize: popUpTitleSize, + fontWeight: FontWeight.bold, ), - ], + ), ), ], ), - ), - ), - Positioned( - top: 5, - right: 5, - width: 50, - height: 50, - child: IconButton( - onPressed: () { - Navigator.pop(context); - }, - icon: Icon( - Icons.close, - color: MzanziInnovationHub.of(context)!.theme.errorColor(), - size: 35, + const SizedBox(height: 5), + Wrap( + alignment: WrapAlignment.start, + children: [ + SizedBox( + width: popUpWidth, + child: Text( + widget.arguments.body, + textAlign: TextAlign.left, + overflow: TextOverflow.ellipsis, + style: TextStyle( + color: secondary, + fontSize: popUpBodySize, + fontWeight: FontWeight.bold, + ), + ), + ), + ], ), - ), + ], ), - ], + ), ); } @@ -146,11 +130,14 @@ class _MIHNotificationMessageState extends State @override void initState() { super.initState(); - + setState(() { + primary = MzanziInnovationHub.of(context)!.theme.primaryColor(); + secondary = MzanziInnovationHub.of(context)!.theme.secondaryColor(); + }); _animationController = AnimationController( vsync: this, duration: - const Duration(milliseconds: 200), // Adjust the duration as needed + const Duration(milliseconds: 300), // Adjust the duration as needed ); _scaleAnimation = Tween( @@ -177,10 +164,9 @@ class _MIHNotificationMessageState extends State return SlideTransition( position: _scaleAnimation, child: Dialog( - insetAnimationDuration: const Duration(milliseconds: 1000), - insetAnimationCurve: Curves.bounceIn, + shadowColor: MzanziInnovationHub.of(context)!.theme.secondaryColor(), alignment: Alignment.topCenter, - child: NotifyPopUp(), + child: notifyPopUp(), ), ); // return SlideTransition( diff --git a/Frontend/patient_manager/lib/mih_objects/arguments.dart b/Frontend/patient_manager/lib/mih_objects/arguments.dart index c4657bfb..2b85d839 100644 --- a/Frontend/patient_manager/lib/mih_objects/arguments.dart +++ b/Frontend/patient_manager/lib/mih_objects/arguments.dart @@ -10,10 +10,12 @@ import 'package:patient_manager/mih_objects/patients.dart'; class NotificationArguments { final String title; final String body; + final void Function()? onTap; NotificationArguments( this.title, this.body, + this.onTap, ); } diff --git a/Frontend/patient_manager/lib/mih_packages/mih_home/mih_home.dart b/Frontend/patient_manager/lib/mih_packages/mih_home/mih_home.dart index 91a83fd0..0f150765 100644 --- a/Frontend/patient_manager/lib/mih_packages/mih_home/mih_home.dart +++ b/Frontend/patient_manager/lib/mih_packages/mih_home/mih_home.dart @@ -247,12 +247,18 @@ class _MIHHomeState extends State { barrierColor: const Color(0x01000000), context: context, builder: (context) { - return MIHNotificationMessage( - arguments: NotificationArguments( - "Testing", - "Testing the new MIH Notification", - ), - ); + return Builder(builder: (context) { + return MIHNotificationMessage( + arguments: NotificationArguments( + "Testing", + "Testing the new MIH Notification", + () { + Navigator.of(context).pop(); + //Scaffold.of(context).openEndDrawer(); + }, + ), + ); + }); }, ); }, @@ -733,6 +739,7 @@ class _MIHHomeState extends State { //print(widget.notifications.toString()); if (notifiList.map((item) => item.notification_read).contains("No")) { //print("New Notification Available"); + return true; } else { //print("No New Notification Available"); @@ -760,25 +767,30 @@ class _MIHHomeState extends State { setState(() { notifiList = notifi; }); - - if (hasNewNotifications()) { - print("New Notifications"); - // await MIHNotificationServices.showNotification( - // title: "New Notification waiting", - // body: - // "You have new notification waiting for you in the notification panel", - // ); - notificationPopUp(); - } + notificationPopUp(); } void notificationPopUp() { - showDialog( - context: context, - builder: (context) { - return const MIHErrorMessage(errorType: "Internet Connection"); - }, - ); + if (hasNewNotifications()) { + showDialog( + barrierColor: const Color(0x01000000), + context: context, + builder: (context) { + return Builder(builder: (context) { + return MIHNotificationMessage( + arguments: NotificationArguments( + "Unread Notification", + "You have unread notifications waiting for you.", + () { + Navigator.of(context).pop(); + //Scaffold.of(context).openEndDrawer(); + }, + ), + ); + }); + }, + ); + } } @override @@ -790,12 +802,15 @@ class _MIHHomeState extends State { @override void initState() { + super.initState(); setState(() { pbswitch = setApps(persHTList, busHTList); businessUserSwitch = false; notifiList = widget.notifications; }); - super.initState(); + WidgetsBinding.instance.addPostFrameCallback((_) { + notificationPopUp(); + }); } @override