From 9fdf073dbf73e8e9d220b21a869f411179a85f45 Mon Sep 17 00:00:00 2001 From: yaso Date: Mon, 7 Oct 2024 15:36:12 +0200 Subject: [PATCH] Add indicator if new notification are available --- .../lib/mih_packages/mih_home/mih_home.dart | 35 ++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) 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 14031679..5d8ff910 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 @@ -516,9 +516,28 @@ class _MIHHomeState extends State { } Widget getSecondaryActionButton() { + Widget notIIcon; + if (hasNewNotifications()) { + notIIcon = Stack( + children: [ + const Icon(Icons.notifications), + Positioned( + right: 0, + top: 0, + child: Icon( + Icons.circle, + size: 10, + color: MzanziInnovationHub.of(context)!.theme.errorColor(), + ), + ) + ], + ); + } else { + notIIcon = const Icon(Icons.notifications); + } return Builder(builder: (context) { return MIHAction( - icon: const Icon(Icons.notifications), + icon: notIIcon, iconSize: 35, onTap: () { setState(() { @@ -679,6 +698,19 @@ class _MIHHomeState extends State { ); } + bool hasNewNotifications() { + //print(widget.notifications.toString()); + if (widget.notifications + .map((item) => item.notification_read) + .contains("No")) { + print("New Notification Available"); + return true; + } else { + print("No New Notification Available"); + return false; + } + } + @override void dispose() { searchController.dispose(); @@ -701,6 +733,7 @@ class _MIHHomeState extends State { final Size size = MediaQuery.sizeOf(context); final double width = size.width; final double height = size.height; + return MIHLayoutBuilder( actionButton: getActionButton(), header: getHeader(),