-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain_screen.dart
More file actions
98 lines (91 loc) · 3.4 KB
/
main_screen.dart
File metadata and controls
98 lines (91 loc) · 3.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
import 'package:flutter/material.dart';
import 'package:task_management_app/features/statistics/viewmodel/statistics_viewmodel.dart';
import 'package:task_management_app/features/tasks/view/screens/home_screen.dart';
import 'settings_screen.dart';
import '../../../../core/theme/app_colors.dart';
import '../../../note/view/focus_screen.dart';
import '../../../note/viewmodel/focus_viewmodel.dart';
import '../../../statistics/view/screens/statistics_screen.dart';
// import '../../../tasks/view/screens/home_screen.dart';
import 'package:provider/provider.dart';
class MainScreen extends StatefulWidget {
const MainScreen({super.key});
@override
State<MainScreen> createState() => _MainScreenState();
}
class _MainScreenState extends State<MainScreen> {
int _currentIndex = 0;
final List<Widget> _screens = [
const Center(child: HomeScreen()),
const Center(child: Text('Màn hình Lịch')),
ChangeNotifierProvider(
create: (_) => FocusViewModel(),
child: const FocusScreen(),
),
ChangeNotifierProvider(
create: (_) => StatisticsViewmodel(),
child: const StatisticsScreen(),
),
const SettingsScreen(),
];
@override
Widget build(BuildContext context) {
return Scaffold(
extendBody: true,
body: IndexedStack(
index: _currentIndex,
children: _screens,
),
bottomNavigationBar: Container(
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 15),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: const BorderRadius.only(topLeft: Radius.circular(30), topRight: Radius.circular(30)),
boxShadow: [BoxShadow(color: Colors.black.withValues(alpha: 0.05), blurRadius: 20, offset: const Offset(0, -5))],
),
child: SafeArea(
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
_buildNavItem(Icons.checklist_rounded, 'Công việc', 0),
_buildNavItem(Icons.calendar_today_rounded, 'Lịch', 1),
_buildNavItem(Icons.timer_rounded, 'Tập trung', 2),
_buildNavItem(Icons.bar_chart_rounded, 'Thống kê', 3),
_buildNavItem(Icons.settings_rounded, 'Cài đặt', 4),
],
),
),
),
);
}
Widget _buildNavItem(IconData icon, String label, int index) {
bool isSelected = _currentIndex == index;
return GestureDetector(
onTap: () => setState(() => _currentIndex = index),
child: AnimatedContainer(
duration: const Duration(milliseconds: 300),
curve: Curves.easeInOut,
padding: EdgeInsets.symmetric(horizontal: isSelected ? 15 : 10, vertical: 10),
decoration: BoxDecoration(
color: isSelected ? const Color(0xFFE8F0FE) : Colors.transparent,
borderRadius: BorderRadius.circular(15),
),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Icon(icon, color: isSelected ? AppColors.primaryBlue : AppColors.grayText, size: 24),
const SizedBox(height: 4),
Text(
label,
style: TextStyle(
fontSize: 10,
fontWeight: isSelected ? FontWeight.bold : FontWeight.normal,
color: isSelected ? AppColors.primaryBlue : AppColors.grayText,
),
)
],
),
),
);
}
}