Repository navigation
Expand file tree
/
Copy pathhome_screen.dart
More file actions
242 lines (232 loc) · 8.09 KB
/
Copy pathhome_screen.dart
File metadata and controls
242 lines (232 loc) · 8.09 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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
import 'package:flutter/material.dart';
import 'profile.dart'; // Import ProfileScreen
void main() => runApp(const MyApp());
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
initialRoute: '/',
routes: {
'/': (context) => const HomeScreen(),
'/profile': (context) => const ProfileScreen(),
},
);
}
}
class HomeScreen extends StatefulWidget {
const HomeScreen({super.key});
@override
State<HomeScreen> createState() => _HomeScreenState();
}
class _HomeScreenState extends State<HomeScreen> {
int _waterIntake = 0;
final int _dailyWaterGoal = 2000;
void _addWater(int amount) {
setState(() => _waterIntake = (_waterIntake + amount).clamp(0, _dailyWaterGoal));
}
Widget _buildCard({required String title, required Widget content}) {
return Container(
padding: const EdgeInsets.all(15),
margin: const EdgeInsets.only(bottom: 15),
decoration: BoxDecoration(
gradient: const LinearGradient(
colors: [Color(0xFF5BC0EB), Color(0xFF3A86FF)],
begin: Alignment.topLeft,
end: Alignment.bottomRight,
),
borderRadius: BorderRadius.circular(15),
boxShadow: [
BoxShadow(
color: Colors.black26,
blurRadius: 5,
offset: const Offset(2, 2),
),
],
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(title, style: const TextStyle(color: Colors.white, fontSize: 20, fontWeight: FontWeight.bold)),
const SizedBox(height: 10),
content,
],
),
);
}
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.white,
appBar: AppBar(
backgroundColor: Colors.transparent,
elevation: 0,
leading: IconButton(
icon: const Icon(Icons.arrow_back, color: Colors.blue),
onPressed: () {
Navigator.pushReplacementNamed(context, '/register');
},
),
actions: [
IconButton(
icon: const Icon(Icons.menu, color: Colors.blue),
onPressed: () {},
),
],
),
body: Padding(
padding: const EdgeInsets.all(20),
child: Flexible( // Prevents overflow by making content adaptive
child: SingleChildScrollView( // Enables scrolling when content overflows
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
_buildCard(
title: 'Step Count',
content: Row(
children: const [
Icon(Icons.directions_walk, color: Colors.white, size: 40),
SizedBox(width: 10),
Text('5478', style: TextStyle(color: Colors.white, fontSize: 24, fontWeight: FontWeight.bold)),
Spacer(),
Icon(Icons.circle, color: Colors.white54, size: 60),
],
),
),
_buildCard(
title: 'Sleep',
content: Container(
padding: const EdgeInsets.symmetric(horizontal: 115, vertical: 5),
decoration: BoxDecoration(
color: Colors.blue[800],
borderRadius: BorderRadius.circular(15),
),
child: const Text('Record Time', style: TextStyle(color: Colors.white)),
),
),
_buildCard(
title: 'Water',
content: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
LinearProgressIndicator(
value: _waterIntake / _dailyWaterGoal,
backgroundColor: Colors.white24,
color: const Color.fromARGB(255, 12, 103, 177),
minHeight: 8,
borderRadius: BorderRadius.circular(10),
),
const SizedBox(height: 10),
Row(
children: [
Text('$_waterIntake / $_dailyWaterGoal ml', style: const TextStyle(color: Colors.white70)),
const Spacer(),
ElevatedButton(
style: ElevatedButton.styleFrom(
backgroundColor: Colors.white,
foregroundColor: Colors.blue[800],
padding: const EdgeInsets.symmetric(horizontal: 15, vertical: 8),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(15),
),
),
onPressed: () => _addWater(250),
child: const Text('+ 250 ml'),
),
],
),
],
),
),
_buildCard(
title: 'Heartbeat',
content: Container(
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 5),
decoration: BoxDecoration(
color: Colors.blue[800], // Updated for better theme
borderRadius: BorderRadius.circular(15),
),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
const Icon(Icons.favorite, color: Colors.white),
const Text(
'72 BPM',
style: TextStyle(color: Colors.white, fontWeight: FontWeight.bold),
),
],
),
),
),
_buildCard(
title: 'Blood Pressure',
content: Container(
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 5),
decoration: BoxDecoration(
color: Colors.blue[800],
borderRadius: BorderRadius.circular(15),
),
constraints: const BoxConstraints(minHeight: 50), // Prevent overflow
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
const Icon(Icons.monitor_heart, color: Colors.white),
Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.end,
children: const [
Text(
'120/80 mmHg',
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold,
),
),
SizedBox(height: 2),
Text(
'Normal',
style: TextStyle(
color: Colors.white70,
fontSize: 12,
),
),
],
),
],
),
),
),
],
),
),
),
),
bottomNavigationBar: BottomNavigationBar(
backgroundColor: Colors.blue[800],
selectedItemColor: Colors.blue,
unselectedItemColor: Colors.lightBlueAccent,
items: const [
BottomNavigationBarItem(icon: Icon(Icons.home), label: 'Home'),
BottomNavigationBarItem(icon: Icon(Icons.person), label: 'Profile'),
BottomNavigationBarItem(icon: Icon(Icons.local_hospital), label: ''),
BottomNavigationBarItem(icon: Icon(Icons.settings), label: 'Settings'),
],
onTap: (index) {
if (index == 1) {
Navigator.pushNamed(context, '/profile');
} else if (index == 2) {
Navigator.pushNamed(context, '/consult');
}
// Handle navigation for other tabs if needed
else if (index == 3) {
Navigator.pushNamed(context, '/settings');
}
else if (index == 4) {
Navigator.pushNamed(context, '/profile');
}
}
),
);
}
}