11import 'package:flutter/material.dart' ;
2+ // import '../../../tasks/view/screens/home_screen.dart';
3+ import 'package:provider/provider.dart' ;
4+ import 'package:task_management_app/features/chatbot/view/chatbot_view.dart' ;
25import 'package:task_management_app/features/statistics/viewmodel/statistics_viewmodel.dart' ;
36import 'package:task_management_app/features/tasks/view/screens/home_screen.dart' ;
4- import 'package:task_management_app/features/chatbot/view/chatbot_view.dart' ;
5- import 'settings_screen.dart' ;
67import 'package:task_management_app/features/user/viewmodel/user_profile_viewmodel.dart' ;
8+
9+ import '../../../category/viewmodel/category_viewmodel.dart' ;
710import '../../../note/view/focus_screen.dart' ;
811import '../../../note/viewmodel/focus_viewmodel.dart' ;
912import '../../../statistics/view/screens/statistics_screen.dart' ;
10- // import '../../../tasks/view/screens/home_screen.dart';
11- import 'package:provider/provider.dart' ;
12-
13+ import '../../../tag/viewmodel/tag_viewmodel.dart' ;
1314import '../../../user/view/user_profile_view.dart' ;
15+ import 'settings_screen.dart' ;
1416
1517class MainScreen extends StatefulWidget {
1618 const MainScreen ({super .key});
@@ -30,34 +32,50 @@ class _MainScreenState extends State<MainScreen> {
3032 child: const FocusScreen (),
3133 ),
3234 ChangeNotifierProvider (
33- create: (_) => StatisticsViewmodel (),
34- child: const StatisticsScreen (),
35+ create: (_) => StatisticsViewmodel (),
36+ child: const StatisticsScreen (),
3537 ),
3638 ChangeNotifierProvider (
37- create: (_) => UserProfileViewModel (useMockData: true )..loadProfile (),
38- child: const UserProfileView (),
39+ create: (_) => UserProfileViewModel (useMockData: true )..loadProfile (),
40+ child: const UserProfileView (),
3941 ),
4042 const SettingsScreen (),
4143 ];
4244
45+ @override
46+ void initState () {
47+ super .initState ();
48+
49+ WidgetsBinding .instance.addPostFrameCallback ((_) {
50+ context.read <CategoryViewModel >().loadCategories ();
51+ context.read <TagViewModel >().loadTags ();
52+ });
53+ }
54+
4355 @override
4456 Widget build (BuildContext context) {
4557 final isDark = Theme .of (context).brightness == Brightness .dark;
4658
4759 return Scaffold (
4860 extendBody: true ,
49- body: IndexedStack (
50- index: _currentIndex,
51- children: _screens,
52- ),
61+ body: IndexedStack (index: _currentIndex, children: _screens),
5362 bottomNavigationBar: Container (
5463 padding: const EdgeInsets .symmetric (horizontal: 10 , vertical: 15 ),
5564 decoration: BoxDecoration (
5665 color: isDark
5766 ? const Color (0xFF1A2945 )
5867 : Theme .of (context).colorScheme.surface,
59- borderRadius: const BorderRadius .only (topLeft: Radius .circular (30 ), topRight: Radius .circular (30 )),
60- boxShadow: [BoxShadow (color: Colors .black.withValues (alpha: 0.05 ), blurRadius: 20 , offset: const Offset (0 , - 5 ))],
68+ borderRadius: const BorderRadius .only (
69+ topLeft: Radius .circular (30 ),
70+ topRight: Radius .circular (30 ),
71+ ),
72+ boxShadow: [
73+ BoxShadow (
74+ color: Colors .black.withValues (alpha: 0.05 ),
75+ blurRadius: 20 ,
76+ offset: const Offset (0 , - 5 ),
77+ ),
78+ ],
6179 ),
6280 child: SafeArea (
6381 child: Row (
@@ -75,20 +93,28 @@ class _MainScreenState extends State<MainScreen> {
7593 );
7694 }
7795
78- Widget _buildNavItem (BuildContext context, IconData icon, String label, int index) {
96+ Widget _buildNavItem (
97+ BuildContext context,
98+ IconData icon,
99+ String label,
100+ int index,
101+ ) {
79102 bool isSelected = _currentIndex == index;
80103
81104 return GestureDetector (
82105 onTap: () => setState (() => _currentIndex = index),
83106 child: AnimatedContainer (
84107 duration: const Duration (milliseconds: 300 ),
85108 curve: Curves .easeInOut,
86- padding: EdgeInsets .symmetric (horizontal: isSelected ? 15 : 10 , vertical: 10 ),
109+ padding: EdgeInsets .symmetric (
110+ horizontal: isSelected ? 15 : 10 ,
111+ vertical: 10 ,
112+ ),
87113 decoration: BoxDecoration (
88114 color: isSelected
89115 ? (Theme .of (context).brightness == Brightness .dark
90- ? const Color (0xFF23395D )
91- : const Color (0xFFE8F0FE ))
116+ ? const Color (0xFF23395D )
117+ : const Color (0xFFE8F0FE ))
92118 : Colors .transparent,
93119 borderRadius: BorderRadius .circular (15 ),
94120 ),
@@ -112,10 +138,10 @@ class _MainScreenState extends State<MainScreen> {
112138 ? Theme .of (context).colorScheme.primary
113139 : Theme .of (context).colorScheme.onSurfaceVariant,
114140 ),
115- )
141+ ),
116142 ],
117143 ),
118144 ),
119145 );
120146 }
121- }
147+ }
0 commit comments