Skip to content

Commit 5697bd7

Browse files
authored
chore: Rewrite of Complete Repository (#27)
Signed-off-by: Soorya U <[email protected]>
2 parents 3ee951f + adc9a77 commit 5697bd7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+360
-537
lines changed

src/app/(auth)/_layout.tsx

Lines changed: 10 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ import {
88
} from "@react-navigation/material-top-tabs";
99
import { ParamListBase, TabNavigationState } from "@react-navigation/native";
1010

11-
import { useConstantTheme, useTheme } from "@/hooks/use-theme";
12-
import { usePlatform } from "@/hooks/use-platform";
11+
import { theme } from "@/constants/theme";
12+
import { setPlatformSettings, setTheme } from "@/utils/setters";
1313

1414
const { Navigator } = createMaterialTopTabNavigator();
1515

@@ -21,54 +21,36 @@ export const MaterialTopTabs = withLayoutContext<
2121
>(Navigator);
2222

2323
export default function AuthLayout() {
24-
const { setPlatformSettings } = usePlatform();
25-
const { setTheme } = useTheme();
26-
const { foregroundColor, backgroundColor, activeBackground } =
27-
useConstantTheme();
2824
const { width } = useWindowDimensions();
2925

3026
return (
3127
<SafeAreaView className="flex-1">
3228
<MaterialTopTabs
3329
screenOptions={{
34-
tabBarActiveTintColor: foregroundColor,
30+
tabBarActiveTintColor: theme.secondary,
3531
tabBarLabelStyle: {
3632
fontWeight: "bold",
3733
textTransform: "capitalize",
3834
fontSize: 17,
3935
},
4036
tabBarIndicatorStyle: {
41-
backgroundColor: foregroundColor,
37+
backgroundColor: theme.secondary,
4238
height: 4,
4339
width: width / 2,
4440
borderRadius: 15,
4541
},
4642
tabBarIndicatorContainerStyle: {
4743
backgroundColor: setPlatformSettings({
48-
ios: setTheme(activeBackground, "rgb(245 245 245)"),
49-
android: setTheme("#000", backgroundColor),
44+
ios: setTheme(theme.primary, "rgb(245 245 245)"),
45+
android: setTheme("#000", theme.primary),
5046
}),
5147
},
52-
tabBarContentContainerStyle: {
53-
height: 50,
54-
},
55-
tabBarItemStyle: {
56-
width: width / 2,
57-
},
48+
tabBarContentContainerStyle: { height: 50 },
49+
tabBarItemStyle: { width: width / 2 },
5850
}}
5951
>
60-
<MaterialTopTabs.Screen
61-
name="login"
62-
options={{
63-
title: "Login",
64-
}}
65-
/>
66-
<MaterialTopTabs.Screen
67-
name="signup"
68-
options={{
69-
title: "Sign Up",
70-
}}
71-
/>
52+
<MaterialTopTabs.Screen name="login" options={{ title: "Login" }} />
53+
<MaterialTopTabs.Screen name="signup" options={{ title: "Sign Up" }} />
7254
</MaterialTopTabs>
7355
</SafeAreaView>
7456
);

src/app/(auth)/login.tsx

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,39 +5,34 @@ import {
55
KeyboardAvoidingView,
66
useWindowDimensions,
77
} from "react-native";
8-
import { useConstantTheme } from "@/hooks/use-theme";
98

10-
import AuthProviders from "@/components/AuthProviders";
11-
import AuthForm from "@/components/AuthForm";
9+
import AuthProviders from "@/components/auth-providers";
10+
import AuthForm from "@/components/auth-form";
1211

1312
export default function LoginScreen() {
1413
const { height } = useWindowDimensions();
15-
const { styles } = useConstantTheme();
1614

1715
return (
1816
<KeyboardAvoidingView className="flex-1">
1917
<ScrollView
20-
contentContainerStyle={{
21-
minHeight: height * 0.90,
22-
}}
23-
contentContainerClassName="flex-1 items-center justify-start py-4"
24-
style={styles.bg}
18+
contentContainerStyle={{ minHeight: height * 0.9 }}
19+
contentContainerClassName="flex-1 items-center justify-start py-4 bg-primary"
2520
>
2621
<View className="w-[85%] py-5">
27-
<Text className="text-center font-['Poppins'] text-2xl text-black dark:text-white">
22+
<Text className="text-center font-poppins text-2xl text-black dark:text-white">
2823
Enter your Credentials to Login
2924
</Text>
3025
</View>
3126
<AuthForm type="login" />
3227
<View className="my-6 w-[85%] flex-row items-center justify-center gap-3">
3328
<View className="h-1 w-[85%] flex-1 rounded bg-[#a3acb9] dark:bg-[#33373b]" />
34-
<Text className="font-[Inder] text-xl text-[#a3acb9] dark:text-[#33373b]">
29+
<Text className="font-inder text-xl text-[#a3acb9] dark:text-[#33373b]">
3530
OR
3631
</Text>
3732
<View className="h-1 w-[85%] flex-1 rounded bg-[#a3acb9] dark:bg-[#33373b]" />
3833
</View>
3934
<View className="mb-6 w-[85%]">
40-
<Text className="text-center font-['Poppins'] text-2xl text-black dark:text-white">
35+
<Text className="text-center font-poppins text-2xl text-black dark:text-white">
4136
Continue with
4237
</Text>
4338
</View>

src/app/(auth)/signup.tsx

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,37 +6,32 @@ import {
66
useWindowDimensions,
77
} from "react-native";
88

9-
import { useConstantTheme } from "@/hooks/use-theme";
10-
import AuthProviders from "@/components/AuthProviders";
11-
import AuthForm from "@/components/AuthForm";
9+
import AuthProviders from "@/components/auth-providers";
10+
import AuthForm from "@/components/auth-form";
1211

1312
export default function SignUpScreen() {
14-
const { styles } = useConstantTheme();
1513
const { height } = useWindowDimensions();
1614
return (
1715
<KeyboardAvoidingView className="flex-1">
1816
<ScrollView
19-
contentContainerStyle={{
20-
minHeight: height*1.05,
21-
}}
22-
contentContainerClassName="flex-1 py-4 justify-start items-center"
23-
style={styles.bg}
17+
contentContainerStyle={{ minHeight: height * 1.05 }}
18+
contentContainerClassName="flex-1 py-4 justify-start items-center bg-primary"
2419
>
2520
<View className="w-[85%] py-5">
26-
<Text className="text-center font-['Poppins'] text-2xl text-black dark:text-white">
21+
<Text className="text-center font-poppins text-2xl text-black dark:text-white">
2722
Enter your Credentials to Sign Up
2823
</Text>
2924
</View>
3025
<AuthForm type="sign-up" />
3126
<View className="my-6 w-[85%] flex-row items-center justify-center gap-3">
3227
<View className="h-1 w-[85%] flex-1 rounded bg-[#a3acb9] dark:bg-[#33373b]" />
33-
<Text className="font-[Inder] text-xl text-[#a3acb9] dark:text-[#33373b]">
28+
<Text className="font-inder text-xl text-[#a3acb9] dark:text-[#33373b]">
3429
OR
3530
</Text>
3631
<View className="h-1 w-[85%] flex-1 rounded bg-[#a3acb9] dark:bg-[#33373b]" />
3732
</View>
3833
<View className="mb-6 w-[85%]">
39-
<Text className="text-center font-['Poppins'] text-2xl text-black dark:text-white">
34+
<Text className="text-center font-poppins text-2xl text-black dark:text-white">
4035
Continue with
4136
</Text>
4237
</View>

src/app/(drawer)/(stack)/(tabs)/_layout.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
import { MaterialIcons, Ionicons } from "@expo/vector-icons";
22
import { Tabs } from "expo-router";
33

4-
import { useConstantTabOptions } from "@/hooks/use-screen-options";
4+
import { tabOptions } from "@/constants/options";
55

66
export default function TabsLayout() {
7-
const { tabContainerStyle, tabOptions } = useConstantTabOptions();
8-
97
return (
10-
<Tabs screenOptions={{ ...tabOptions, sceneStyle: tabContainerStyle }}>
8+
<Tabs screenOptions={tabOptions}>
119
<Tabs.Screen
1210
name="browse"
1311
options={{
Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,10 @@
1+
import { stackOptions } from "@/constants/options";
12
import { Stack } from "expo-router";
23

3-
import { useConstantStackOptions } from "@/hooks/use-screen-options";
4-
54
export default function BrowseLayout() {
6-
const stackOptions = useConstantStackOptions();
7-
85
return (
96
<Stack screenOptions={stackOptions}>
10-
<Stack.Screen
11-
name="index"
12-
options={{
13-
headerTitle: "Browse",
14-
}}
15-
/>
7+
<Stack.Screen name="index" options={{ headerTitle: "Browse" }} />
168
</Stack>
179
);
1810
}

src/app/(drawer)/(stack)/(tabs)/browse/index.tsx

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,14 @@
1-
import { useEffect, useState } from "react";
1+
import { useEffect, useMemo, useState } from "react";
22
import { FlatList, ScrollView, View } from "react-native";
33

4-
import MarkdownList from "@/components/MarkdownList";
4+
import MarkdownList from "@/components/markdown-list";
55
import { markdown } from "@/constants/markdown";
6+
import { theme } from "@/constants/theme";
67
import { useScreenOptions } from "@/hooks/use-screen-options";
7-
import { useConstantTheme } from "@/hooks/use-theme";
88
import { Markdown } from "@/types/markdown";
9-
import {
10-
markdownSorter,
11-
markdownSearcher,
12-
} from "@/utils/markdownSorterAndSearcher";
9+
import { markdownSorter, markdownSearcher } from "@/utils/markdown-helpers";
1310

1411
export default function BrowseScreen() {
15-
const { foregroundColor } = useConstantTheme();
1612
const [searchText, setSearchText] = useState("");
1713

1814
const [filteredList, setFilteredList] = useState<Markdown[]>([]);
@@ -25,16 +21,19 @@ export default function BrowseScreen() {
2521

2622
useScreenOptions({
2723
headerSearchBarOptions: {
28-
textColor: foregroundColor,
29-
headerIconColor: foregroundColor,
30-
tintColor: foregroundColor,
31-
hintTextColor: foregroundColor,
24+
textColor: theme.secondary,
25+
headerIconColor: theme.secondary,
26+
tintColor: theme.secondary,
27+
hintTextColor: theme.secondary,
3228
placeholder: "Search",
3329
onChangeText: (e) => setSearchText(e.nativeEvent.text),
3430
},
3531
});
3632

37-
const { sortedMd, keys } = markdownSorter(markdown);
33+
const { sortedMd, keys } = useMemo(
34+
() => markdownSorter(markdown),
35+
[markdown],
36+
);
3837

3938
return !searchText ? (
4039
<FlatList
Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,12 @@
1+
import { stackOptions } from "@/constants/options";
12
import { Stack } from "expo-router";
23

3-
import { useConstantStackOptions } from "@/hooks/use-screen-options";
44

55
export default function DownloadLayout() {
6-
const stackOptions = useConstantStackOptions();
76

87
return (
98
<Stack screenOptions={stackOptions}>
10-
<Stack.Screen
11-
name="index"
12-
options={{
13-
headerTitle: "Downloads",
14-
}}
15-
/>
9+
<Stack.Screen name="index" options={{ headerTitle: "Downloads" }} />
1610
</Stack>
1711
);
1812
}
Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,10 @@
1+
import { stackOptions } from "@/constants/options";
12
import { Stack } from "expo-router";
23

3-
import { useConstantStackOptions } from "@/hooks/use-screen-options";
4-
54
export default function LibraryLayout() {
6-
const stackOptions = useConstantStackOptions();
7-
85
return (
96
<Stack screenOptions={stackOptions}>
10-
<Stack.Screen
11-
name="index"
12-
options={{
13-
headerTitle: "Library",
14-
}}
15-
/>
7+
<Stack.Screen name="index" options={{ headerTitle: "Library" }} />
168
</Stack>
179
);
1810
}

src/app/(drawer)/(stack)/[file].tsx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,13 @@ import { Ionicons } from "@expo/vector-icons";
33
import { useLocalSearchParams } from "expo-router";
44
import { type FlatList, TouchableOpacity } from "react-native";
55

6-
import MarkdownRenderer from "@/components/MarkdownRenderer";
6+
import MarkdownRenderer from "@/components/markdown-renderer";
77
import { markdown } from "@/constants/markdown";
88
import { useScreenOptions } from "@/hooks/use-screen-options";
9-
import { useTheme } from "@/hooks/use-theme";
10-
import { MarkdownIcon } from "@/components/Icons";
9+
import { MarkdownIcon } from "@/components/icons";
10+
import { setTheme } from "@/utils/setters";
1111

1212
export default function MarkdownContent() {
13-
const { setTheme } = useTheme();
14-
1513
const flatListRef = useRef<FlatList<React.ReactNode>>(null);
1614

1715
const { file: id } = useLocalSearchParams<{ file: string }>();

src/app/(drawer)/(stack)/_layout.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1+
import { stackOptions } from "@/constants/options";
12
import { Stack } from "expo-router";
23

3-
import { useConstantStackOptions } from "@/hooks/use-screen-options";
44

55
function StackLayout() {
6-
const stackOptions = useConstantStackOptions();
76

87
return (
98
<Stack screenOptions={stackOptions}>

0 commit comments

Comments
 (0)