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:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user