Skip to content

Commit 74c7d59

Browse files
committed
initial version (beta)
1 parent 8809e4b commit 74c7d59

Some content is hidden

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

57 files changed

+3898
-551
lines changed

.gitignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,13 @@ web-build/
1212

1313
# macOS
1414
.DS_Store
15+
16+
# @generated expo-cli sync-2b81b286409207a5da26e14c78851eb30d8ccbdb
17+
# The following patterns were generated by expo-cli
18+
19+
expo-env.d.ts
20+
# @end expo-cli
21+
22+
.env
23+
android
24+
android/*

app.json

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,35 @@
1919
"adaptiveIcon": {
2020
"foregroundImage": "./assets/images/adaptive-icon.png",
2121
"backgroundColor": "#ffffff"
22-
}
22+
},
23+
"package": "com.bagusok.animestream"
2324
},
2425
"web": {
2526
"bundler": "metro",
2627
"output": "static",
2728
"favicon": "./assets/images/favicon.png"
2829
},
2930
"plugins": [
30-
"expo-router"
31+
"expo-router",
32+
"expo-font",
33+
"expo-secure-store",
34+
[
35+
"expo-screen-orientation",
36+
{
37+
"initialOrientation": "DEFAULT"
38+
}
39+
]
3140
],
3241
"experiments": {
3342
"typedRoutes": true
43+
},
44+
"extra": {
45+
"router": {
46+
"origin": false
47+
},
48+
"eas": {
49+
"projectId": "b5f26acf-eff2-492d-8062-7e3d7e82b6b7"
50+
}
3451
}
3552
}
3653
}

app/(home)/_layout.tsx

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
import { Tabs } from "expo-router";
2+
import React from "react";
3+
4+
import { TabBarIcon } from "@/components/navigation/TabBarIcon";
5+
import { Colors } from "@/constants/Colors";
6+
import { useColors } from "@/hooks/useColors";
7+
import { AntDesign, Feather } from "@expo/vector-icons";
8+
9+
export default function TabLayout() {
10+
const colors = useColors();
11+
12+
return (
13+
<Tabs
14+
screenOptions={{
15+
tabBarActiveTintColor: colors.primary,
16+
headerShown: false,
17+
tabBarStyle: {
18+
backgroundColor: colors.background,
19+
borderTopColor: colors.border,
20+
},
21+
}}
22+
>
23+
<Tabs.Screen
24+
name="index"
25+
options={{
26+
title: "Home",
27+
tabBarIcon: ({ color, focused }) => (
28+
<Feather name="home" size={24} color={color} />
29+
),
30+
}}
31+
/>
32+
<Tabs.Screen
33+
name="all-anime"
34+
options={{
35+
title: "All",
36+
tabBarIcon: ({ color, focused }) => (
37+
<Feather name="list" size={24} color={color} />
38+
),
39+
}}
40+
/>
41+
<Tabs.Screen
42+
name="schedule"
43+
options={{
44+
title: "Schedule",
45+
tabBarIcon: ({ color, focused }) => (
46+
<Feather name="calendar" size={24} color={color} />
47+
),
48+
}}
49+
/>
50+
<Tabs.Screen
51+
name="history"
52+
options={{
53+
title: "History",
54+
tabBarIcon: ({ color, focused }) => (
55+
<Feather name="clock" size={24} color={color} />
56+
),
57+
}}
58+
/>
59+
<Tabs.Screen
60+
name="user"
61+
options={{
62+
title: "User",
63+
tabBarIcon: ({ color, focused }) => (
64+
<Feather name="user" size={24} color={color} />
65+
),
66+
}}
67+
/>
68+
</Tabs>
69+
);
70+
}

app/(home)/all-anime.tsx

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
import LoadingPage from "@/components/LoadingPage";
2+
import SafeAreaWrapper from "@/components/SafeAreaWrapper";
3+
import { CustomText } from "@/components/ui";
4+
import CardAllAnime from "@/components/ui/card-anime/CardAllAnime";
5+
import { ThemeColors } from "@/constants/Colors";
6+
import { API_URL } from "@/constants/Strings";
7+
import { useColors } from "@/hooks/useColors";
8+
import { axiosIn } from "@/utils/axios";
9+
10+
import { useInfiniteQuery, useQuery } from "@tanstack/react-query";
11+
import { useMemo } from "react";
12+
import { ActivityIndicator, Pressable, StyleSheet, View } from "react-native";
13+
import { FlatList } from "react-native-gesture-handler";
14+
import { SafeAreaView } from "react-native-safe-area-context";
15+
16+
export default function AllAnime() {
17+
const colors = useColors();
18+
const style = createStyles(colors);
19+
20+
const allAnime = useInfiniteQuery({
21+
initialPageParam: 1,
22+
queryKey: ["allAnime"],
23+
queryFn: async ({ pageParam }) =>
24+
axiosIn
25+
.get(`${API_URL}/anime?page=${pageParam}`)
26+
.then((res) => res.data)
27+
.catch((err) => err),
28+
getNextPageParam: (lastPage) => {
29+
const nextPage = lastPage.pagination.page + 1;
30+
return nextPage <= lastPage.pagination.totalPage ? nextPage : null;
31+
},
32+
});
33+
34+
const flatData = useMemo(
35+
() => allAnime.data?.pages.flatMap((page) => page.data) ?? [],
36+
[allAnime.data]
37+
);
38+
39+
if (allAnime.isLoading) {
40+
return <LoadingPage />;
41+
}
42+
43+
return (
44+
<SafeAreaView>
45+
<View style={style.header}>
46+
<CustomText fontStyle="semibold" size={16}>
47+
All Anime
48+
</CustomText>
49+
</View>
50+
<View style={style.container}>
51+
<FlatList
52+
data={flatData}
53+
keyExtractor={(item) => item.id}
54+
renderItem={({ item }) => <CardAllAnime key={item.id} item={item} />}
55+
ItemSeparatorComponent={() => <View style={{ height: 16 }} />}
56+
onEndReached={() => {
57+
if (allAnime.hasNextPage) {
58+
allAnime.fetchNextPage();
59+
}
60+
}}
61+
onEndReachedThreshold={0.5}
62+
initialNumToRender={10}
63+
maxToRenderPerBatch={10}
64+
windowSize={10}
65+
removeClippedSubviews={true}
66+
ListFooterComponent={
67+
allAnime.isFetchingNextPage ? (
68+
<ActivityIndicator color={colors.primary} />
69+
) : null
70+
}
71+
/>
72+
</View>
73+
</SafeAreaView>
74+
);
75+
}
76+
77+
const createStyles = (colors: ThemeColors) =>
78+
StyleSheet.create({
79+
header: {
80+
height: 50,
81+
paddingHorizontal: 14,
82+
flexDirection: "row",
83+
justifyContent: "space-between",
84+
alignItems: "center",
85+
backgroundColor: colors.background,
86+
},
87+
container: {
88+
gap: 14,
89+
paddingHorizontal: 14,
90+
paddingBottom: 100,
91+
backgroundColor: colors.background,
92+
},
93+
cardAnime: {
94+
flexDirection: "row",
95+
gap: 14,
96+
},
97+
});

app/(home)/history.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import SafeAreaWrapper from "@/components/SafeAreaWrapper";
2+
import { CustomText } from "@/components/ui";
3+
4+
export default function AllAnime() {
5+
return (
6+
<SafeAreaWrapper>
7+
<CustomText>All Anime</CustomText>
8+
</SafeAreaWrapper>
9+
);
10+
}

0 commit comments

Comments
 (0)