Skip to content

Commit 9520862

Browse files
committed
home page names
1 parent dadf376 commit 9520862

5 files changed

Lines changed: 40 additions & 30 deletions

File tree

KonditionExpo/app/_layout.tsx

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { StatusBar } from 'expo-status-bar';
55
import 'react-native-reanimated';
66

77
import { useColorScheme } from '@/hooks/useColorScheme';
8+
import { UserProvider } from '@/contexts/UserContext';
89

910
export default function RootLayout() {
1011
const colorScheme = useColorScheme();
@@ -13,18 +14,19 @@ export default function RootLayout() {
1314
});
1415

1516
if (!loaded) {
16-
// Async font loading only occurs in development.
1717
return null;
1818
}
1919

2020
return (
21-
<ThemeProvider value={colorScheme === 'dark' ? DarkTheme : DefaultTheme}>
22-
<Stack>
23-
<Stack.Screen name="(tabs)" options={{ headerShown: false }} />
24-
<Stack.Screen name="login" options={{ headerShown: false }} />
25-
<Stack.Screen name="+not-found" />
26-
</Stack>
27-
<StatusBar style="auto" />
28-
</ThemeProvider>
21+
<UserProvider> {/* ✅ Wrap the entire app in your context provider */}
22+
<ThemeProvider value={colorScheme === 'dark' ? DarkTheme : DefaultTheme}>
23+
<Stack>
24+
<Stack.Screen name="(tabs)" options={{ headerShown: false }} />
25+
<Stack.Screen name="login" options={{ headerShown: false }} />
26+
<Stack.Screen name="+not-found" />
27+
</Stack>
28+
<StatusBar style="auto" />
29+
</ThemeProvider>
30+
</UserProvider>
2931
);
3032
}

KonditionExpo/app/home.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import React from 'react';
2+
import { useUser } from '@/contexts/UserContext';
23
import { SafeAreaView, View, Text, StyleSheet, ScrollView, TouchableOpacity, Image, Dimensions } from 'react-native';
34
import { LineChart, PieChart } from 'react-native-svg-charts';
45
import { router } from 'expo-router';
@@ -8,6 +9,7 @@ const { width } = Dimensions.get('window');
89
const HomeScreen = ({ navigation }) => {
910
// TODO: Replace with real data
1011
const bmiValue = '20.1';
12+
const { name } = useUser();
1113
const heartRateData = [60, 62, 65, 70, 75, 78, 80, 82, 79, 76];
1214
const waterIntake = '4L';
1315
const sleepHours = '8h 20m';
@@ -27,7 +29,7 @@ const HomeScreen = ({ navigation }) => {
2729
{/* Header */}
2830
<View style={styles.header}>
2931
<Text style={styles.welcomeText}>Welcome Back,</Text>
30-
<Text style={styles.userName}>Andy Vo</Text>
32+
<Text style={styles.userName}>{name}</Text>
3133
<TouchableOpacity style={styles.notificationBtn} onPress={() => navigation.navigate('Notifications')}>
3234
<Image source={require('../assets/images/bell.png')} style={styles.bellIcon} />
3335
</TouchableOpacity>

KonditionExpo/app/login.tsx

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@ import { Button } from '../components/ui/Button';
55
import { Input } from '../components/ui/Input';
66
import { Checkbox } from '../components/ui/Checkbox';
77
import { router } from 'expo-router';
8+
import { useUser } from '@/contexts/UserContext';
89

910
export default function LoginScreen() {
11+
const { setName: setUserName } = useUser();
1012
const [email, setEmail] = useState('');
1113
const [password, setPassword] = useState('');
1214
const [rememberMe, setRememberMe] = useState(false);
@@ -21,33 +23,28 @@ export default function LoginScreen() {
2123
const handleLogin = async () => {
2224
setErrors({});
2325

24-
// Simple validation
2526
const newErrors: { email?: string; password?: string } = {};
26-
27-
if (!email) {
28-
newErrors.email = 'Email is required';
29-
} else if (!/\S+@\S+\.\S+/.test(email)) {
30-
newErrors.email = 'Please enter a valid email';
31-
}
32-
33-
if (!password) {
34-
newErrors.password = 'Password is required';
35-
} else if (password.length < 6) {
36-
newErrors.password = 'Password must be at least 6 characters';
37-
}
38-
27+
28+
if (!email) newErrors.email = 'Email is required';
29+
else if (!/\S+@\S+\.\S+/.test(email)) newErrors.email = 'Please enter a valid email';
30+
31+
if (!password) newErrors.password = 'Password is required';
32+
else if (password.length < 6) newErrors.password = 'Password must be at least 6 characters';
33+
3934
if (Object.keys(newErrors).length > 0) {
4035
setErrors(newErrors);
4136
return;
4237
}
43-
38+
4439
setIsLoading(true);
45-
40+
4641
try {
4742
// Simulate API call
4843
await new Promise(resolve => setTimeout(resolve, 1500));
49-
50-
// Navigate to main screen after successful login
44+
45+
// Set the name (this mimics what signup does)
46+
setUserName('Returning User'); // You can replace this with a real name from API later
47+
5148
router.replace('/home');
5249
} catch (error) {
5350
console.error('Login error:', error);
@@ -57,7 +54,6 @@ export default function LoginScreen() {
5754
};
5855

5956
const handleForgotPassword = () => {
60-
// For now, just go back to main screen since we don't have forgot password yet
6157
router.push('/(tabs)');
6258
};
6359

KonditionExpo/app/notification.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import React from 'react';
22
import { View, Text, StyleSheet, TouchableOpacity, FlatList, Image } from 'react-native';
3+
/*
34
import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
45
56
const notifications = [
@@ -10,6 +11,7 @@ const notifications = [
1011
{ id: '5', title: "Hey, it's time for lunch", time: '8 April', icon: require('./assets/lunch.png') },
1112
{ id: '6', title: 'Ups, You have missed your Lowerbo..', time: '3 April', icon: require('./assets/workout.png') },
1213
];
14+
*/
1315

1416
export default function NotificationScreen({ navigation }) {
1517
const renderItem = ({ item }) => (

KonditionExpo/app/signup.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,30 @@ import { View, Text, StyleSheet, ScrollView } from 'react-native';
33
import { Input } from '@/components/ui/Input';
44
import { Button } from '@/components/ui/Button';
55
import { router } from 'expo-router';
6+
import { useUser } from '@/contexts/UserContext';
7+
8+
9+
610

711
export default function SignUpScreen() {
812
const [email, setEmail] = useState('');
913
const [name, setName] = useState('');
1014
const [password, setPassword] = useState('');
1115
const [confirmPassword, setConfirmPassword] = useState('');
16+
const { setName: setUserName } = useUser();
1217

1318
const handleCreateAccount = () => {
1419
if (password !== confirmPassword) {
1520
alert("Passwords don't match");
1621
return;
1722
}
18-
23+
24+
setUserName(name);
25+
1926
// TODO: Send signup data to API
2027
router.replace('/signup2');
2128
};
29+
2230

2331
return (
2432
<ScrollView contentContainerStyle={styles.container}>

0 commit comments

Comments
 (0)