Skip to content

Commit 6fcf2e8

Browse files
committed
profile page + signup validations
1 parent 99abbbb commit 6fcf2e8

4 files changed

Lines changed: 141 additions & 13 deletions

File tree

KonditionExpo/app/home.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -158,19 +158,19 @@ const HomeScreen = ({ navigation }) => {
158158

159159
{/* Bottom Navigation */}
160160
<View style={styles.bottomNav}>
161-
<TouchableOpacity onPress={() => navigation.navigate('Home')}>
161+
<TouchableOpacity onPress={() => router.push('/home')}>
162162
<Image source={require('../assets/images/home-active.png')} style={styles.navIcon} />
163163
</TouchableOpacity>
164-
<TouchableOpacity onPress={() => navigation.navigate('Progress')}>
164+
<TouchableOpacity onPress={() => alert('Progress screen not yet implemented')}>
165165
<Image source={require('../assets/images/chart.png')} style={styles.navIcon} />
166166
</TouchableOpacity>
167-
<TouchableOpacity onPress={() => navigation.navigate('Search')} style={styles.centerButton}>
167+
<TouchableOpacity onPress={() => alert('Search screen not yet implemented')} style={styles.centerButton}>
168168
<Image source={require('../assets/images/search.png')} style={styles.searchIcon} />
169169
</TouchableOpacity>
170-
<TouchableOpacity onPress={() => navigation.navigate('Camera')}>
170+
<TouchableOpacity onPress={() => alert('Camera screen not yet implemented')}>
171171
<Image source={require('../assets/images/camera.png')} style={styles.navIcon} />
172172
</TouchableOpacity>
173-
<TouchableOpacity onPress={() => navigation.navigate('Profile')}>
173+
<TouchableOpacity onPress={() => router.push('/profile')}>
174174
<Image source={require('../assets/images/user.png')} style={styles.navIcon} />
175175
</TouchableOpacity>
176176
</View>

KonditionExpo/app/profile.tsx

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
import React, { useState } from 'react';
2+
import { SafeAreaView, View, Text, StyleSheet, ScrollView, TouchableOpacity, Image, Switch } from 'react-native';
3+
import { useUser } from '@/contexts/UserContext';
4+
import { router } from 'expo-router';
5+
6+
const ProfileScreen = () => {
7+
const { name } = useUser();
8+
const [notificationsEnabled, setNotificationsEnabled] = useState(false);
9+
10+
const toggleNotifications = () => setNotificationsEnabled(prev => !prev);
11+
12+
return (
13+
<SafeAreaView style={styles.container}>
14+
<ScrollView contentContainerStyle={styles.content}>
15+
{/* Back Arrow */}
16+
<TouchableOpacity onPress={() => router.back()} style={styles.backBtn}>
17+
<Image source={require('@/assets/images/arrow-left.png')} style={styles.backIcon} />
18+
</TouchableOpacity>
19+
20+
{/* Profile Box */}
21+
<View style={styles.profileBox}>
22+
<Text style={styles.profileName}>{name}</Text>
23+
<TouchableOpacity style={styles.editBtn}>
24+
<Text style={styles.editText}>Edit</Text>
25+
</TouchableOpacity>
26+
27+
<View style={styles.statsRow}>
28+
<View style={styles.statBox}><Text style={styles.statLabel}>Height</Text><Text style={styles.statValue}>180 cm</Text></View>
29+
<View style={styles.statBox}><Text style={styles.statLabel}>Weight</Text><Text style={styles.statValue}>75 kg</Text></View>
30+
<View style={styles.statBox}><Text style={styles.statLabel}>Age</Text><Text style={styles.statValue}>28</Text></View>
31+
</View>
32+
</View>
33+
34+
{/* Account Box */}
35+
<View style={styles.sectionBox}>
36+
<Text style={styles.sectionTitle}>Account</Text>
37+
<Text style={styles.optionItem}>Personal Data</Text>
38+
<Text style={styles.optionItem}>Achievement</Text>
39+
<Text style={styles.optionItem}>Activity History</Text>
40+
<Text style={styles.optionItem}>Workout Progress</Text>
41+
</View>
42+
43+
{/* Notification Box */}
44+
<View style={styles.sectionBox}>
45+
<Text style={styles.sectionTitle}>Notification</Text>
46+
<View style={styles.toggleRow}>
47+
<Text style={styles.optionItem}>Pop-up Notifications</Text>
48+
<Switch
49+
value={notificationsEnabled}
50+
onValueChange={toggleNotifications}
51+
trackColor={{ false: '#ccc', true: '#70A1FF' }}
52+
thumbColor={notificationsEnabled ? '#FFF' : '#f4f3f4'}
53+
/>
54+
</View>
55+
</View>
56+
57+
{/* Other Box */}
58+
<View style={styles.sectionBox}>
59+
<Text style={styles.sectionTitle}>Other</Text>
60+
<Text style={styles.optionItem}>Privacy Policy</Text>
61+
<Text style={styles.optionItem}>Contact Us</Text>
62+
<Text style={styles.optionItem}>Settings</Text>
63+
</View>
64+
</ScrollView>
65+
66+
{/* Bottom Navigation */}
67+
<View style={styles.bottomNav}>
68+
<TouchableOpacity onPress={() => router.replace('/home')}>
69+
<Image source={require('../assets/images/home-active.png')} style={styles.navIcon} />
70+
</TouchableOpacity>
71+
<TouchableOpacity onPress={() => alert('Progress screen not yet implemented')}>
72+
<Image source={require('../assets/images/chart.png')} style={styles.navIcon} />
73+
</TouchableOpacity>
74+
<TouchableOpacity onPress={() => alert('Search screen not yet implemented')}>
75+
<Image source={require('../assets/images/search.png')} style={styles.searchIcon} />
76+
</TouchableOpacity>
77+
<TouchableOpacity onPress={() => alert('Camera screen not yet implemented')}>
78+
<Image source={require('../assets/images/camera.png')} style={styles.navIcon} />
79+
</TouchableOpacity>
80+
<TouchableOpacity onPress={() => router.replace('/home')}>
81+
<Image source={require('../assets/images/user.png')} style={styles.navIcon} />
82+
</TouchableOpacity>
83+
</View>
84+
</SafeAreaView>
85+
);
86+
};
87+
88+
const styles = StyleSheet.create({
89+
container: { flex: 1, backgroundColor: '#FFFFFF' },
90+
content: { padding: 16, paddingBottom: 80 },
91+
backBtn: { marginBottom: 16 },
92+
backIcon: { width: 24, height: 24 },
93+
profileBox: { backgroundColor: '#E5F1FF', borderRadius: 20, padding: 16, marginBottom: 24 },
94+
profileName: { fontSize: 24, fontWeight: 'bold', color: '#333' },
95+
editBtn: { backgroundColor: '#70A1FF', borderRadius: 12, paddingVertical: 6, paddingHorizontal: 12, alignSelf: 'flex-start', marginTop: 8 },
96+
editText: { color: '#FFF' },
97+
statsRow: { flexDirection: 'row', justifyContent: 'space-between', marginTop: 16 },
98+
statBox: { backgroundColor: '#FFF', borderRadius: 12, padding: 12, width: '30%', alignItems: 'center' },
99+
statLabel: { fontSize: 12, color: '#555' },
100+
statValue: { fontSize: 16, fontWeight: 'bold', color: '#333' },
101+
sectionBox: { backgroundColor: '#F5F8FF', borderRadius: 16, padding: 16, marginBottom: 24 },
102+
sectionTitle: { fontSize: 16, fontWeight: 'bold', color: '#333', marginBottom: 8 },
103+
optionItem: { fontSize: 14, color: '#555', paddingVertical: 6 },
104+
toggleRow: { flexDirection: 'row', justifyContent: 'space-between', alignItems: 'center' },
105+
bottomNav: { position: 'absolute', bottom: 0, left: 0, right: 0, height: 60, flexDirection: 'row', justifyContent: 'space-around', alignItems: 'center', backgroundColor: '#FFF', borderTopWidth: 1, borderColor: '#EEE' },
106+
navIcon: { width: 24, height: 24 },
107+
centerButton: { backgroundColor: '#fff', padding: 12, borderRadius: 24, elevation: 4 },
108+
searchIcon: { width: 28, height: 28 },
109+
});
110+
111+
export default ProfileScreen;

KonditionExpo/app/signup2.tsx

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,21 +56,38 @@ export default function SignUpStep2() {
5656
};
5757

5858
const handleNext = () => {
59-
if (
60-
!gender ||
61-
!dobMM ||
62-
!dobDD ||
63-
!dobYYYY ||
64-
!weight ||
65-
(heightUnit === 'ft/in' && (!heightFeet || !heightInches)) || // check feet/inches
66-
(heightUnit === 'cm' && !height) // check cm
59+
const mm = parseInt(dobMM, 10);
60+
const dd = parseInt(dobDD, 10);
61+
const yyyy = parseInt(dobYYYY, 10);
62+
const currentYear = new Date().getFullYear();
63+
64+
if (!gender || !dobMM || !dobDD || !dobYYYY || !weight ||
65+
(heightUnit === 'ft/in' && (!heightFeet || !heightInches)) ||
66+
(heightUnit === 'cm' && !height)
6767
) {
6868
alert('Please fill out all fields');
6969
return;
7070
}
71+
72+
if (mm < 1 || mm > 12) {
73+
alert('Month must be between 1 and 12');
74+
return;
75+
}
76+
77+
if (dd < 1 || dd > 31) {
78+
alert('Day must be between 1 and 31');
79+
return;
80+
}
81+
82+
if (yyyy < 1900 || yyyy > currentYear) {
83+
alert(`Year must be between 1900 and ${currentYear}`);
84+
return;
85+
}
86+
7187
router.replace('/home');
7288
};
7389

90+
7491

7592
return (
7693
<KeyboardAvoidingView
1.05 KB
Loading

0 commit comments

Comments
 (0)