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); final response = await ApiManager.instance.get(URLs.getUnreadNotificationCount, enableToastMessage: false);
if (response.statusCode >= 200 && response.statusCode < 300) { if (response.statusCode >= 200 && response.statusCode < 300) {
final responseData = json.decode(response.body); final responseData = json.decode(response.body);
log('count response :: $responseData');
count = responseData['data']; count = responseData['data'];
// Update the totalNotificationUnread property
totalNotificationUnread = count ?? 0; totalNotificationUnread = count ?? 0;
notifyListeners(); notifyListeners();
} }

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

@ -41,9 +41,6 @@ class _AppBarWidgetState extends State<AppBarWidget> with TickerProviderStateMix
void initState() { void initState() {
super.initState(); super.initState();
// Profile section animation (left to right with fade)
getUnreadCount();
_leftController = AnimationController( _leftController = AnimationController(
duration: const Duration(milliseconds: 600), duration: const Duration(milliseconds: 600),
vsync: this, vsync: this,
@ -101,12 +98,6 @@ class _AppBarWidgetState extends State<AppBarWidget> with TickerProviderStateMix
super.dispose(); super.dispose();
} }
Future<void> getUnreadCount () async{
NotificationsProvider notificationsProvider = Provider.of<NotificationsProvider>(context,listen: false);
log('i am initstate');
await notificationsProvider.getUnreadCount();
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return AppBar( return AppBar(
@ -273,21 +264,19 @@ class _AppBarWidgetState extends State<AppBarWidget> with TickerProviderStateMix
}, },
), ),
], ],
// Notification icon with unread count badge Selector<NotificationsProvider, int>(
Consumer<NotificationsProvider>( selector: (_, myModel) => myModel.totalNotificationUnread, // Selects only the userName
builder: (context, notificationsProvider, child) { builder: (_, totalNotificationUnread, __) {
final unreadCount = notificationsProvider.totalNotificationUnread; return CustomBadge(
return CustomBadge( width: 16,
width: 20, height: 16,
height: 20, positionT: -10,
positionT: -10, value: totalNotificationUnread,
value: unreadCount, child: ("dashboard/notification").toSvgAsset(height: 24, width: 24, color: AppColor.icon2Color(context)).paddingOnly(top: 0, end: 0),
child: ("dashboard/notification").toSvgAsset(height: 24, width: 24, color: AppColor.icon2Color(context)).paddingOnly(top: 0, end: 0), ).onPress(() {
).onPress(() { Navigator.of(context).pushNamed(NotificationsPage.id);
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!.isAscending = isAscending;
_activeFilters!.isRead = _selectedTabIndex; // 0 = All, 1 = Unread, 2 = Read _activeFilters!.isRead = _selectedTabIndex; // 0 = All, 1 = Unread, 2 = Read
// Reset and fetch fresh data with filters
notificationsProvider.reset(); notificationsProvider.reset();
await notificationsProvider.getSystemNotifications( await notificationsProvider.getSystemNotifications(user: userProvider.user!, resetProvider: true, filters: _activeFilters);
user: userProvider.user!,
resetProvider: true,
filters: _activeFilters,
);
// Refresh the unread count after loading notifications
// This updates the badge on the app bar
await notificationsProvider.getUnreadCount(); await notificationsProvider.getUnreadCount();
} }

Loading…
Cancel
Save