53 lines
1.6 KiB
Dart
53 lines
1.6 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:provider/provider.dart';
|
|
import 'package:tm_app/core/services/tab_navigation_service.dart';
|
|
import 'package:tm_app/core/utils/size_config.dart';
|
|
import 'package:tm_app/view_models/notification_view_model.dart';
|
|
import 'package:tm_app/views/notification/pages/d_notification_page.dart';
|
|
import 'package:tm_app/views/notification/pages/m_notification_page.dart';
|
|
import 'package:tm_app/views/notification/pages/t_notification_page.dart';
|
|
import 'package:tm_app/views/shared/responsive_builder.dart';
|
|
|
|
class NotificationScreen extends StatefulWidget {
|
|
const NotificationScreen({super.key});
|
|
|
|
@override
|
|
State<NotificationScreen> createState() => _NotificationScreenState();
|
|
}
|
|
|
|
class _NotificationScreenState extends State<NotificationScreen> {
|
|
late final NotificationViewModel _viewModel;
|
|
late final TabNavigationService _tabService;
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
_viewModel = context.read<NotificationViewModel>();
|
|
_tabService = context.read<TabNavigationService>();
|
|
_tabService.addListener(_onTabChanged);
|
|
}
|
|
|
|
@override
|
|
void dispose() {
|
|
_tabService.removeListener(_onTabChanged);
|
|
super.dispose();
|
|
}
|
|
|
|
void _onTabChanged() {
|
|
// Tab index 3 is Notification
|
|
if (_tabService.currentTabIndex == 3 && mounted) {
|
|
_viewModel.init();
|
|
}
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
SizeConfig.init(context);
|
|
return const ResponsiveBuilder(
|
|
mobile: MobileNotificationPage(),
|
|
tablet: TabletNotificationPage(),
|
|
desktop: DesktopNotificationPage(),
|
|
);
|
|
}
|
|
}
|