diff --git a/lib/view_models/notification_view_model.dart b/lib/view_models/notification_view_model.dart index 4f5836a..fffad77 100644 --- a/lib/view_models/notification_view_model.dart +++ b/lib/view_models/notification_view_model.dart @@ -39,9 +39,16 @@ class NotificationViewModel with ChangeNotifier { _unreadNotificationResponse; bool get isUnreadLoading => _isUnreadLoading; + bool _isMoreLoading = false; + bool get isMoreLoading => _isMoreLoading; + /// Fetch notifications Future getNotifications({int page = 1, bool isMobile = false}) async { - _isLoading = true; + if (isMobile && page > 1) { + _isMoreLoading = true; // 👈 لودینگ فقط برای پیج بعدی + } else { + _isLoading = true; // 👈 لودینگ عادی (اولین بار یا رفرش) + } notifyListeners(); final int offset = _pageSize * page; @@ -80,6 +87,7 @@ class NotificationViewModel with ChangeNotifier { } _isLoading = false; + _isMoreLoading = false; notifyListeners(); } @@ -107,7 +115,9 @@ class NotificationViewModel with ChangeNotifier { case Ok>(): final response = result.value; final success = response['success'] as bool? ?? false; - final message = response['message'] as String? ?? NotificationStrings.unknownResponse; + final message = + response['message'] as String? ?? + NotificationStrings.unknownResponse; if (success) { if (_notificationResponseModel?.data?.notifications != null) { diff --git a/lib/views/notification/pages/m_notification_page.dart b/lib/views/notification/pages/m_notification_page.dart index 2d0a879..952a6c9 100644 --- a/lib/views/notification/pages/m_notification_page.dart +++ b/lib/views/notification/pages/m_notification_page.dart @@ -112,7 +112,17 @@ class _MobileNotificationPageState extends State ], ), ), - if (viewModel.isLoading) ...[ + if (viewModel.isMoreLoading) ...[ + const Padding( + padding: EdgeInsets.symmetric(vertical: 16), + child: Center( + child: CircularProgressIndicator(color: AppColors.secondary50), + ), + ), + ], + if (viewModel.isLoading && + (viewModel.notificationResponse?.data?.notifications?.isEmpty ?? + true)) ...[ const Spacer(), const Center( child: CircularProgressIndicator(color: AppColors.secondary50),