improvements

ui_ux_rollout_merge_notification_settings
Sikander Saleem 4 weeks ago
parent 59a9721fb1
commit 1f65b2e0ac

@ -191,9 +191,7 @@ class NotificationsProvider extends ChangeNotifier {
final response = await ApiManager.instance.get(URLs.getUnreadNotificationCount, enableToastMessage: false);
if (response.statusCode >= 200 && response.statusCode < 300) {
final responseData = json.decode(response.body);
log('count response :: $responseData');
count = responseData['data'];
// Update the totalNotificationUnread property
totalNotificationUnread = count ?? 0;
notifyListeners();
}

@ -60,7 +60,7 @@ class _DashboardViewState extends State<DashboardView> {
_dashBoardProvider.setTabs(userType: userProvider.user!.type!, context: context);
_dashBoardProvider.getDashBoardCount(usersType: userProvider.user!.type!);
_dashBoardProvider.resetRequestDataList();
notificationsProvider.getUnreadCount();
if (userProvider.isHouseKeeper) {
_dashBoardProvider.currentListIndex = 0;
_dashBoardProvider.getRequestDetail(

@ -41,9 +41,6 @@ class _AppBarWidgetState extends State<AppBarWidget> with TickerProviderStateMix
void initState() {
super.initState();
// Profile section animation (left to right with fade)
getUnreadCount();
_leftController = AnimationController(
duration: const Duration(milliseconds: 600),
vsync: this,
@ -101,12 +98,6 @@ class _AppBarWidgetState extends State<AppBarWidget> with TickerProviderStateMix
super.dispose();
}
Future<void> getUnreadCount () async{
NotificationsProvider notificationsProvider = Provider.of<NotificationsProvider>(context,listen: false);
log('i am initstate');
await notificationsProvider.getUnreadCount();
}
@override
Widget build(BuildContext context) {
return AppBar(
@ -273,21 +264,19 @@ class _AppBarWidgetState extends State<AppBarWidget> with TickerProviderStateMix
},
),
],
// Notification icon with unread count badge
Consumer<NotificationsProvider>(
builder: (context, notificationsProvider, child) {
final unreadCount = notificationsProvider.totalNotificationUnread;
Selector<NotificationsProvider, int>(
selector: (_, myModel) => myModel.totalNotificationUnread, // Selects only the userName
builder: (_, totalNotificationUnread, __) {
return CustomBadge(
width: 20,
height: 20,
width: 16,
height: 16,
positionT: -10,
value: unreadCount,
value: totalNotificationUnread,
child: ("dashboard/notification").toSvgAsset(height: 24, width: 24, color: AppColor.icon2Color(context)).paddingOnly(top: 0, end: 0),
).onPress(() {
Navigator.of(context).pushNamed(NotificationsPage.id);
});
},
),
}).paddingOnly(end: 8, start: 4),
],
),
),

@ -70,16 +70,8 @@ class _NotificationsPageState extends State<NotificationsPage> with TickerProvid
_activeFilters!.isAscending = isAscending;
_activeFilters!.isRead = _selectedTabIndex; // 0 = All, 1 = Unread, 2 = Read
// Reset and fetch fresh data with filters
notificationsProvider.reset();
await notificationsProvider.getSystemNotifications(
user: userProvider.user!,
resetProvider: true,
filters: _activeFilters,
);
// Refresh the unread count after loading notifications
// This updates the badge on the app bar
await notificationsProvider.getSystemNotifications(user: userProvider.user!, resetProvider: true, filters: _activeFilters);
await notificationsProvider.getUnreadCount();
}

Loading…
Cancel
Save