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
+25 -15
View File
@@ -10,7 +10,9 @@ import 'package:tm_app/data/repositories/tenders_repository.dart';
import 'package:tm_app/data/repositories/your_tenders_repository.dart';
import 'package:tm_app/data/services/home_service.dart';
import 'package:tm_app/data/services/liked_tenders_service.dart';
import 'package:tm_app/data/services/notification_check_service.dart';
import 'package:tm_app/data/services/notification_service.dart';
import 'package:tm_app/data/services/notification_state_service.dart';
import 'package:tm_app/data/services/tender_detail_service.dart';
import 'package:tm_app/data/services/your_tenders_service.dart';
import 'package:tm_app/view_models/final_completion_of_documents_view_model.dart';
@@ -30,13 +32,14 @@ import '../../view_models/home_view_model.dart';
import '../../view_models/profile_view_model.dart';
List<SingleChildWidget> get providersRemote {
return [...cores, ...apiClients, ...repositories, ...viewModels, ...others];
return [...cores, ...apiClients, ...repositories, ...services, ...viewModels];
}
List<SingleChildWidget> get cores {
return [
Provider(create: (context) => NetworkManager(context.read())),
ChangeNotifierProvider(create: (context) => ThemeProvider()),
ChangeNotifierProvider(create: (context) => NotificationStateService()),
];
}
@@ -108,20 +111,32 @@ List<SingleChildWidget> get repositories {
];
}
List<SingleChildWidget> get services {
return [
Provider(
create:
(context) => NotificationCheckService(
homeRepository: context.read(),
notificationStateService: context.read(),
),
),
];
}
List<SingleChildWidget> get viewModels {
return [
ChangeNotifierProvider(
create: (context) => AuthViewModel(authRepository: context.read()),
),
ChangeNotifierProvider(
create: (context) => HomeViewModel(homeRepository: context.read()),
create:
(context) => HomeViewModel(
homeRepository: context.read(),
notificationStateService: context.read(),
),
),
ChangeNotifierProvider(
create:
(context) => TendersViewModel(
tendersRepository: context.read(),
homeViewModel: context.read(),
),
create: (context) => TendersViewModel(tendersRepository: context.read()),
),
ChangeNotifierProvider(
create:
@@ -129,7 +144,6 @@ List<SingleChildWidget> get viewModels {
tenderDetailRepository: context.read(),
tendersRepository: context.read(),
tendersViewModel: context.read(),
homeViewModel: context.read(),
),
),
@@ -143,7 +157,6 @@ List<SingleChildWidget> get viewModels {
(context) => LikedTendersViewModel(
likedTendersRepository: context.read(),
tendersRepository: context.read(),
homeViewModel: context.read(),
),
),
ChangeNotifierProvider(
@@ -160,13 +173,10 @@ List<SingleChildWidget> get viewModels {
ChangeNotifierProvider(
create:
(context) => NotificationViewModel(
repositoryViewModel: context.read(),
homeViewModel: context.read(),
notificationsRepository: context.read(),
notificationStateService: context.read(),
notificationCheckService: context.read(),
),
),
];
}
List<SingleChildWidget> get others {
return [];
}
@@ -4,26 +4,41 @@ import 'package:provider/provider.dart';
import 'package:tm_app/core/routes/app_shell/desktop_shell_page.dart';
import 'package:tm_app/core/routes/app_shell/mobile_shell_page.dart';
import 'package:tm_app/core/routes/app_shell/tablet_shell_page.dart';
import 'package:tm_app/data/services/notification_check_service.dart';
import 'package:tm_app/view_models/home_view_model.dart';
import 'package:tm_app/view_models/tenders_view_model.dart';
import 'package:tm_app/views/shared/responsive_builder.dart';
import '../../../view_models/notification_view_model.dart';
class AppShellScreen extends StatelessWidget {
class AppShellScreen extends StatefulWidget {
const AppShellScreen({required this.navigationShell, super.key});
final StatefulNavigationShell navigationShell;
@override
State<AppShellScreen> createState() => _AppShellScreenState();
}
class _AppShellScreenState extends State<AppShellScreen> {
@override
void initState() {
super.initState();
// Check for unread notifications when app shell loads
WidgetsBinding.instance.addPostFrameCallback((_) {
context.read<NotificationCheckService>().checkUnreadNotifications();
});
}
void _gotoBranch(int index, BuildContext context) {
if (index == navigationShell.currentIndex) {
if (index == widget.navigationShell.currentIndex) {
return;
}
// Navigate first
navigationShell.goBranch(
widget.navigationShell.goBranch(
index,
initialLocation: index == navigationShell.currentIndex,
initialLocation: index == widget.navigationShell.currentIndex,
);
// Then trigger data loading after navigation is complete
@@ -45,16 +60,16 @@ class AppShellScreen extends StatelessWidget {
return ResponsiveBuilder(
mobile: SafeArea(
child: MobileShellPage(
navigationShell: navigationShell,
navigationShell: widget.navigationShell,
onTap: (value) => _gotoBranch(value, context),
),
),
tablet: TabletShellPage(
navigationShell: navigationShell,
navigationShell: widget.navigationShell,
onTap: (value) => _gotoBranch(value, context),
),
desktop: DesktopShellPage(
navigationShell: navigationShell,
navigationShell: widget.navigationShell,
onTap: (value) => _gotoBranch(value, context),
),
);
@@ -5,9 +5,9 @@ import 'package:provider/provider.dart';
import 'package:tm_app/core/constants/assets.dart';
import 'package:tm_app/core/theme/colors.dart';
import 'package:tm_app/core/utils/size_config.dart';
import 'package:tm_app/view_models/home_view_model.dart';
import 'package:tm_app/views/profile/strings/profile_strings.dart';
import '../../../data/services/notification_state_service.dart';
import '../../../views/home/strings/home_strings.dart';
import '../../../views/tenders/strings/tenders_strings.dart';
@@ -65,7 +65,10 @@ class MobileShellPage extends StatelessWidget {
onTap: () => onTap(3),
iconPath: AssetsManager.notify,
activeIconPath: AssetsManager.notifyActive,
showBadge: context.watch<HomeViewModel>().hasUnreadNotification,
showBadge:
context
.watch<NotificationStateService>()
.hasUnreadNotification,
),
_bottomNavigationItem(
context: context,