Update .gitignore to exclude Firebase configuration files and refactor notification handling in the app. Removed redundant logging and notification data storage in SharedPreferences. Introduced NotificationCheckService and NotificationStateService for improved notification management. Updated view models and UI components to utilize the new services, enhancing notification state tracking and user experience.

This commit is contained in:
amirrezaghabeli
2025-10-06 11:59:54 +03:30
parent 17634744f7
commit 42f2e93a8e
28 changed files with 1499 additions and 595 deletions
@@ -0,0 +1,32 @@
import 'package:tm_app/core/utils/result.dart';
import 'package:tm_app/data/repositories/home_repository.dart';
import 'package:tm_app/data/services/notification_state_service.dart';
/// Service to check for unread notifications and update state
class NotificationCheckService {
final HomeRepository _homeRepository;
final NotificationStateService _notificationStateService;
NotificationCheckService({
required HomeRepository homeRepository,
required NotificationStateService notificationStateService,
}) : _homeRepository = homeRepository,
_notificationStateService = notificationStateService;
Future<void> checkUnreadNotifications() async {
final result = await _homeRepository.checkUnreadNotifications();
switch (result) {
case Ok<Map<String, dynamic>>():
final response = result.value;
final data = response['data'];
_notificationStateService.setHasUnreadNotification(
data is List && data.isNotEmpty,
);
break;
case Error<Map<String, dynamic>>():
_notificationStateService.setHasUnreadNotification(false);
break;
}
}
}
@@ -0,0 +1,17 @@
import 'package:flutter/foundation.dart';
/// Service to manage notification state across the app
class NotificationStateService extends ChangeNotifier {
bool _hasUnreadNotification = false;
bool get hasUnreadNotification => _hasUnreadNotification;
void setHasUnreadNotification(bool value) {
if (_hasUnreadNotification != value) {
_hasUnreadNotification = value;
notifyListeners();
}
}
void clearUnreadNotification() => setHasUnreadNotification(false);
}