Skip to content

Commit 2442a40

Browse files
committed
New screen to edit profile information
1 parent 0133fe9 commit 2442a40

File tree

4 files changed

+498
-3
lines changed

4 files changed

+498
-3
lines changed

KonditionExpo/app/(tabs)/profile.tsx

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,18 @@ const ProfileScreen = () => {
1414

1515
const toggleNotifications = () => setNotificationsEnabled(prev => !prev);
1616

17+
// Unit conversion functions
18+
const cmToFeetInches = (cm: number): { feet: number; inches: number } => {
19+
const totalInches = cm / 2.54;
20+
const feet = Math.floor(totalInches / 12);
21+
const inches = Math.round(totalInches % 12);
22+
return { feet, inches };
23+
};
24+
25+
const kgToLbs = (kg: number): number => {
26+
return Math.round(kg * 2.20462);
27+
};
28+
1729
// Calculate age from date of birth
1830
const calculateAge = (dateOfBirth: string | undefined): number => {
1931
if (!dateOfBirth) return 0;
@@ -29,6 +41,24 @@ const ProfileScreen = () => {
2941

3042
const age = calculateAge(user?.date_of_birth);
3143

44+
// Display formatted height in feet and inches
45+
const getDisplayHeight = (): string => {
46+
if (!user?.height) return '-';
47+
const { feet, inches } = cmToFeetInches(user.height);
48+
return `${feet}' ${inches}"`;
49+
};
50+
51+
// Display formatted weight in pounds
52+
const getDisplayWeight = (): string => {
53+
if (!user?.weight) return '-';
54+
return `${kgToLbs(user.weight)} lbs`;
55+
};
56+
57+
// Navigate to edit profile screen
58+
const handleEditProfile = () => {
59+
router.push('/edit-profile');
60+
};
61+
3262
const handleLogout = () => {
3363
setShowLogoutDialog(true);
3464
};
@@ -64,18 +94,18 @@ const ProfileScreen = () => {
6494
<View style={styles.profileBox}>
6595
<Text style={styles.profileName}>{user?.full_name || user?.email || 'User'}</Text>
6696
<Text style={styles.profileEmail}>{user?.email || 'No email'}</Text>
67-
<TouchableOpacity style={styles.editBtn}>
97+
<TouchableOpacity style={styles.editBtn} onPress={handleEditProfile}>
6898
<Text style={styles.editText}>Edit</Text>
6999
</TouchableOpacity>
70100

71101
<View style={styles.statsRow}>
72102
<View style={styles.statBox}>
73103
<Text style={styles.statLabel}>Height</Text>
74-
<Text style={styles.statValue}>{user?.height ? `${user.height} cm` : '-'}</Text>
104+
<Text style={styles.statValue}>{getDisplayHeight()}</Text>
75105
</View>
76106
<View style={styles.statBox}>
77107
<Text style={styles.statLabel}>Weight</Text>
78-
<Text style={styles.statValue}>{user?.weight ? `${user.weight} kg` : '-'}</Text>
108+
<Text style={styles.statValue}>{getDisplayWeight()}</Text>
79109
</View>
80110
<View style={styles.statBox}>
81111
<Text style={styles.statLabel}>Age</Text>
@@ -164,6 +194,7 @@ const ProfileScreen = () => {
164194
Are you sure you want to sign out?
165195
</Text>
166196
</Dialog>
197+
167198
</SafeAreaView>
168199
);
169200
};

0 commit comments

Comments
 (0)