Skip to content

Commit 1fb2bd1

Browse files
authored
Merge pull request #167 from adulbrich/bug_fixes
Fixed issue #58 #59, #62 and added templates for pregnancy tracking
2 parents 127a91f + d08c4f9 commit 1fb2bd1

16 files changed

Lines changed: 804 additions & 118 deletions

File tree

app/(pregnancy-tabs)/_layout.tsx

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
import { Tabs } from "expo-router";
2+
import React, { useEffect, useState } from "react";
3+
import { Platform } from "react-native";
4+
import * as SplashScreen from "expo-splash-screen";
5+
import { getDrizzleDatabase } from "@/db/database";
6+
import { HapticTab } from "@/components/HapticTab";
7+
import { IconSymbol } from "@/components/ui/IconSymbol";
8+
import TabBarBackground from "@/components/ui/TabBarBackground";
9+
import { useTheme } from "react-native-paper";
10+
11+
export default function PregnancyTabLayout() {
12+
const [appIsReady, setAppIsReady] = useState(false);
13+
const theme = useTheme();
14+
15+
useEffect(() => {
16+
async function prepare() {
17+
let db;
18+
let attempts = 0;
19+
20+
while (!db && attempts < 10) {
21+
db = getDrizzleDatabase();
22+
if (!db) {
23+
attempts++;
24+
await new Promise((resolve) => setTimeout(resolve, 500));
25+
}
26+
}
27+
28+
if (db) {
29+
setAppIsReady(true);
30+
} else {
31+
console.warn("Failed to access database after multiple attempts.");
32+
}
33+
34+
await SplashScreen.hideAsync();
35+
}
36+
37+
prepare();
38+
}, []);
39+
40+
if (!appIsReady) {
41+
return null;
42+
}
43+
44+
return (
45+
<Tabs
46+
screenOptions={{
47+
tabBarActiveTintColor: theme.colors.primary,
48+
headerShown: false,
49+
tabBarButton: HapticTab,
50+
tabBarBackground: TabBarBackground,
51+
tabBarStyle: Platform.select({
52+
ios: {
53+
position: "absolute",
54+
paddingBottom: 6,
55+
paddingTop: 6,
56+
height: 60,
57+
},
58+
default: {
59+
height: 65,
60+
paddingTop: 6,
61+
},
62+
}),
63+
}}
64+
>
65+
<Tabs.Screen
66+
name="index"
67+
options={{
68+
title: "Home",
69+
tabBarIcon: ({ color }) => (
70+
<IconSymbol size={28} name="house.fill" color={color} />
71+
),
72+
}}
73+
/>
74+
<Tabs.Screen
75+
name="calendar"
76+
options={{
77+
title: "Calendar",
78+
tabBarIcon: ({ color }) => (
79+
<IconSymbol size={28} name="calendar" color={color} />
80+
),
81+
}}
82+
/>
83+
<Tabs.Screen
84+
name="info"
85+
options={{
86+
title: "Info",
87+
tabBarIcon: ({ color }) => (
88+
<IconSymbol size={28} name="info.circle" color={color} />
89+
),
90+
}}
91+
/>
92+
<Tabs.Screen
93+
name="settings"
94+
options={{
95+
title: "Settings",
96+
tabBarIcon: ({ color }) => (
97+
<IconSymbol size={28} name="gearshape" color={color} />
98+
),
99+
}}
100+
/>
101+
</Tabs>
102+
);
103+
}

app/(pregnancy-tabs)/calendar.tsx

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
import { ThemedView } from "@/components/ThemedView";
2+
import FadeInView from "@/components/animations/FadeInView";
3+
import { Text, useTheme } from "react-native-paper";
4+
import { SafeAreaView, StyleSheet, View } from "react-native";
5+
import { IconSymbol } from "@/components/ui/IconSymbol";
6+
7+
export default function PregnancyCalendar() {
8+
const theme = useTheme();
9+
10+
return (
11+
<FadeInView duration={200} backgroundColor={theme.colors.background}>
12+
<ThemedView style={styles.container}>
13+
<SafeAreaView style={styles.safeArea}>
14+
<Text
15+
variant="titleLarge"
16+
style={[styles.title, { color: theme.colors.onBackground }]}
17+
>
18+
Calendar
19+
</Text>
20+
<View style={styles.content}>
21+
<IconSymbol
22+
size={64}
23+
name="calendar"
24+
color={theme.colors.primary}
25+
/>
26+
<Text
27+
variant="headlineSmall"
28+
style={[styles.comingSoon, { color: theme.colors.onBackground }]}
29+
>
30+
Coming Soon
31+
</Text>
32+
<Text
33+
variant="bodyMedium"
34+
style={[
35+
styles.description,
36+
{ color: theme.colors.onSurfaceVariant },
37+
]}
38+
>
39+
Pregnancy calendar tracking is under development.
40+
</Text>
41+
</View>
42+
</SafeAreaView>
43+
</ThemedView>
44+
</FadeInView>
45+
);
46+
}
47+
48+
const styles = StyleSheet.create({
49+
container: {
50+
height: "100%",
51+
padding: 10,
52+
},
53+
safeArea: {
54+
flex: 1,
55+
},
56+
title: {
57+
textAlign: "center",
58+
fontSize: 30,
59+
fontWeight: "bold",
60+
paddingTop: 4,
61+
},
62+
content: {
63+
flex: 1,
64+
justifyContent: "center",
65+
alignItems: "center",
66+
gap: 16,
67+
},
68+
comingSoon: {
69+
fontWeight: "bold",
70+
},
71+
description: {
72+
textAlign: "center",
73+
paddingHorizontal: 32,
74+
},
75+
});

app/(pregnancy-tabs)/index.tsx

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
import { ThemedView } from "@/components/ThemedView";
2+
import FadeInView from "@/components/animations/FadeInView";
3+
import { Text, useTheme } from "react-native-paper";
4+
import { SafeAreaView, StyleSheet, View } from "react-native";
5+
import { IconSymbol } from "@/components/ui/IconSymbol";
6+
7+
export default function PregnancyHome() {
8+
const theme = useTheme();
9+
10+
return (
11+
<FadeInView duration={200} backgroundColor={theme.colors.background}>
12+
<ThemedView style={styles.container}>
13+
<SafeAreaView style={styles.safeArea}>
14+
<Text
15+
variant="titleLarge"
16+
style={[styles.title, { color: theme.colors.onBackground }]}
17+
>
18+
Home
19+
</Text>
20+
<View style={styles.content}>
21+
<IconSymbol
22+
size={64}
23+
name="house.fill"
24+
color={theme.colors.primary}
25+
/>
26+
<Text
27+
variant="headlineSmall"
28+
style={[styles.comingSoon, { color: theme.colors.onBackground }]}
29+
>
30+
Coming Soon
31+
</Text>
32+
<Text
33+
variant="bodyMedium"
34+
style={[
35+
styles.description,
36+
{ color: theme.colors.onSurfaceVariant },
37+
]}
38+
>
39+
Pregnancy tracking home screen is under development.
40+
</Text>
41+
</View>
42+
</SafeAreaView>
43+
</ThemedView>
44+
</FadeInView>
45+
);
46+
}
47+
48+
const styles = StyleSheet.create({
49+
container: {
50+
height: "100%",
51+
padding: 10,
52+
},
53+
safeArea: {
54+
flex: 1,
55+
},
56+
title: {
57+
textAlign: "center",
58+
fontSize: 30,
59+
fontWeight: "bold",
60+
paddingTop: 4,
61+
},
62+
content: {
63+
flex: 1,
64+
justifyContent: "center",
65+
alignItems: "center",
66+
gap: 16,
67+
},
68+
comingSoon: {
69+
fontWeight: "bold",
70+
},
71+
description: {
72+
textAlign: "center",
73+
paddingHorizontal: 32,
74+
},
75+
});

app/(pregnancy-tabs)/info.tsx

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
import { ThemedView } from "@/components/ThemedView";
2+
import FadeInView from "@/components/animations/FadeInView";
3+
import { Text, useTheme } from "react-native-paper";
4+
import { SafeAreaView, StyleSheet, View } from "react-native";
5+
import { IconSymbol } from "@/components/ui/IconSymbol";
6+
7+
export default function PregnancyInfo() {
8+
const theme = useTheme();
9+
10+
return (
11+
<FadeInView duration={200} backgroundColor={theme.colors.background}>
12+
<ThemedView style={styles.container}>
13+
<SafeAreaView style={styles.safeArea}>
14+
<Text
15+
variant="titleLarge"
16+
style={[styles.title, { color: theme.colors.onBackground }]}
17+
>
18+
Info
19+
</Text>
20+
<View style={styles.content}>
21+
<IconSymbol
22+
size={64}
23+
name="info.circle"
24+
color={theme.colors.primary}
25+
/>
26+
<Text
27+
variant="headlineSmall"
28+
style={[styles.comingSoon, { color: theme.colors.onBackground }]}
29+
>
30+
Coming Soon
31+
</Text>
32+
<Text
33+
variant="bodyMedium"
34+
style={[
35+
styles.description,
36+
{ color: theme.colors.onSurfaceVariant },
37+
]}
38+
>
39+
Pregnancy information and week-by-week tracking is under
40+
development.
41+
</Text>
42+
</View>
43+
</SafeAreaView>
44+
</ThemedView>
45+
</FadeInView>
46+
);
47+
}
48+
49+
const styles = StyleSheet.create({
50+
container: {
51+
height: "100%",
52+
padding: 10,
53+
},
54+
safeArea: {
55+
flex: 1,
56+
},
57+
title: {
58+
textAlign: "center",
59+
fontSize: 30,
60+
fontWeight: "bold",
61+
paddingTop: 4,
62+
},
63+
content: {
64+
flex: 1,
65+
justifyContent: "center",
66+
alignItems: "center",
67+
gap: 16,
68+
},
69+
comingSoon: {
70+
fontWeight: "bold",
71+
},
72+
description: {
73+
textAlign: "center",
74+
paddingHorizontal: 32,
75+
},
76+
});

app/(pregnancy-tabs)/settings.tsx

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
import { ThemedView } from "@/components/ThemedView";
2+
import AuthenticationSettings from "@/components/settings/AuthenticationSettings";
3+
import PrivacyPolicy from "@/components/settings/PrivacyPolicy";
4+
import Customization from "@/components/settings/Customization";
5+
import DataSettings from "@/components/settings/DataSettings";
6+
import { Text, Divider, useTheme } from "react-native-paper";
7+
import { ScrollView, SafeAreaView, StyleSheet } from "react-native";
8+
import ThemeSelector from "@/components/settings/ThemeSelector";
9+
import FadeInView from "@/components/animations/FadeInView";
10+
import NotificationSettings from "@/components/settings/NotificationSettings";
11+
import WalkthroughReplay from "@/components/settings/WalkthroughReplay";
12+
import TrackingModeSettings from "@/components/settings/TrackingModeSettings";
13+
14+
export default function PregnancySettings() {
15+
const theme = useTheme();
16+
return (
17+
<FadeInView duration={200} backgroundColor={theme.colors.background}>
18+
<ThemedView style={{ height: "100%", padding: 10 }}>
19+
<SafeAreaView style={{ flex: 1 }}>
20+
<Text
21+
variant="titleLarge"
22+
style={{
23+
textAlign: "center",
24+
fontSize: 30,
25+
fontWeight: "bold",
26+
color: theme.colors.onBackground,
27+
paddingTop: 4,
28+
}}
29+
>
30+
Settings
31+
</Text>
32+
<Divider style={{ marginTop: 10 }} />
33+
<ScrollView contentContainerStyle={{ paddingBottom: 60 }}>
34+
<TrackingModeSettings />
35+
<Divider style={styles.divider} />
36+
<AuthenticationSettings />
37+
<Divider style={styles.divider} />
38+
<Customization />
39+
<Divider style={styles.divider} />
40+
<ThemeSelector />
41+
<Divider style={styles.divider} />
42+
<DataSettings />
43+
<Divider style={styles.divider} />
44+
<NotificationSettings />
45+
<WalkthroughReplay />
46+
<Divider style={styles.divider} />
47+
<PrivacyPolicy />
48+
</ScrollView>
49+
</SafeAreaView>
50+
</ThemedView>
51+
</FadeInView>
52+
);
53+
}
54+
55+
const styles = StyleSheet.create({
56+
divider: {
57+
marginBottom: 0.2,
58+
},
59+
});

0 commit comments

Comments
 (0)