Skip to content

Commit 4541fb0

Browse files
committed
Added app splash screen
1 parent 94d789d commit 4541fb0

File tree

6 files changed

+117
-48
lines changed

6 files changed

+117
-48
lines changed

App.tsx

+11-6
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import { createNativeStackNavigator } from "@react-navigation/native-stack";
33
import { RootRoute } from "./Route/RootRoute";
44
import { GestureHandlerRootView } from "react-native-gesture-handler";
55
import { VideoPlayerScreen } from "./Route/VideoPlayerScreen";
6+
import { InitialScreen } from "./Route/InitialRoute";
7+
import { ContextState } from "./GlobalState/ContextState";
68
function App() {
79
const Stack = createNativeStackNavigator()
810
const MyTheme = {
@@ -18,12 +20,15 @@ function App() {
1820
};
1921
return (
2022
<GestureHandlerRootView style={{ flex: 1 }}>
21-
<NavigationContainer theme={MyTheme}>
22-
<Stack.Navigator screenOptions={{headerShown:false}}>
23-
<Stack.Screen name="MainRoute" component={RootRoute} />
24-
<Stack.Screen name="VideoPlayer" component={VideoPlayerScreen} />
25-
</Stack.Navigator>
26-
</NavigationContainer>
23+
<ContextState>
24+
<NavigationContainer theme={MyTheme}>
25+
<Stack.Navigator screenOptions={{headerShown:false}}>
26+
<Stack.Screen name="InitialRoute" component={InitialScreen} />
27+
<Stack.Screen name="MainRoute" component={RootRoute} />
28+
<Stack.Screen name="VideoPlayer" component={VideoPlayerScreen} />
29+
</Stack.Navigator>
30+
</NavigationContainer>
31+
</ContextState>
2732
</GestureHandlerRootView>
2833
);
2934
}

GlobalState/Context.jsx

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import {createContext} from "react";
2+
3+
const Context = createContext()
4+
5+
export default Context

GlobalState/ContextState.jsx

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import Context from "./Context";
2+
import { useCallback, useEffect, useState } from "react";
3+
import { getAiringScheduleAnime, getPopularAnime, getTrendingAnime } from "../Api/AnimeData";
4+
export const ContextState = (props)=>{
5+
const [TrendingLoading, setTrendingLoading] = useState(true);
6+
const [PopularLoading, setPopularLoading] = useState(true);
7+
const [AirngLoading, setAirngLoading] = useState(true);
8+
const [Trending, setTrending] = useState([]);
9+
const [Popular, setPopular] = useState([]);
10+
const [Airing, setAiring] = useState([]);
11+
const GetTrending = useCallback(async function GetTrending(){
12+
try {
13+
const data = await getTrendingAnime()
14+
setTrending(data.results)
15+
} catch (e) {
16+
console.warn("Error in getting Trending Anime", e);
17+
}
18+
setTrendingLoading(false)
19+
}, []);
20+
21+
const GetPopular = useCallback( async function GetPopular(){
22+
try {
23+
const data = await getPopularAnime()
24+
setPopular(data.results)
25+
} catch (e) {
26+
console.warn("Error in getting Popular Anime", e);
27+
}
28+
setPopularLoading(false)
29+
},[])
30+
31+
const GetAiring = useCallback( async function GetAiring(){
32+
try {
33+
const data = await getAiringScheduleAnime()
34+
setAiring(data.results)
35+
} catch (e) {
36+
console.warn("Error in getting Airing Anime", e);
37+
}
38+
setAirngLoading(false)
39+
},[])
40+
useEffect(()=>{
41+
GetTrending()
42+
GetPopular()
43+
GetAiring()
44+
},[])
45+
return <Context.Provider value={{TrendingLoading,
46+
PopularLoading,
47+
AirngLoading,
48+
Trending,
49+
Popular,
50+
Airing}}>
51+
{props.children}
52+
</Context.Provider>
53+
}

Route/Home/Home.jsx

+9-42
Original file line numberDiff line numberDiff line change
@@ -3,64 +3,31 @@ import Crousel from "../../Components/Home/TopCrousel/Crousel";
33
import { ScrollView } from "react-native";
44
import { Spacer } from "../../Components/Global/Spacer";
55
import { Sections } from "../../Components/Home/Sections/Sections";
6-
import { useCallback, useEffect, useState } from "react";
7-
import { getAiringScheduleAnime, getPopularAnime, getTrendingAnime } from "../../Api/AnimeData";
6+
import { useCallback, useContext, useEffect, useState } from "react";
87
import { getContinueWatching } from "../../LocalStorage/ContinueWatching";
8+
import Context from "../../GlobalState/Context";
99

1010
export const Home = ({navigation}) => {
11-
const [TrendingLoading, setTrendingLoading] = useState(true);
12-
const [PopularLoading, setPopularLoading] = useState(true);
13-
const [AirngLoading, setAirngLoading] = useState(true);
11+
const {TrendingLoading,
12+
PopularLoading,
13+
AirngLoading,
14+
Trending,
15+
Popular,
16+
Airing} = useContext(Context)
1417
const [ContinueWatchingLoading, setContinueWatchingLoading] = useState(true);
15-
const [Trending, setTrending] = useState([]);
16-
const [Popular, setPopular] = useState([]);
17-
const [Airing, setAiring] = useState([]);
1818
const [ContinueWatching, setContinueWatching] = useState([]);
1919

20-
const GetTrending = useCallback(async function GetTrending(){
21-
try {
22-
const data = await getTrendingAnime()
23-
setTrending(data.results)
24-
} catch (e) {
25-
console.warn("Error in getting Trending Anime", e);
26-
}
27-
setTrendingLoading(false)
28-
}, []);
29-
30-
const GetPopular = useCallback( async function GetPopular(){
31-
try {
32-
const data = await getPopularAnime()
33-
setPopular(data.results)
34-
} catch (e) {
35-
console.warn("Error in getting Popular Anime", e);
36-
}
37-
setPopularLoading(false)
38-
},[])
39-
40-
const GetAiring = useCallback( async function GetAiring(){
41-
try {
42-
const data = await getAiringScheduleAnime()
43-
setAiring(data.results)
44-
} catch (e) {
45-
console.warn("Error in getting Airing Anime", e);
46-
}
47-
setAirngLoading(false)
48-
},[])
49-
5020
const GetContinueWatching = useCallback(async function GetContinueWatching(){
5121
try {
5222
const data = await getContinueWatching()
5323
setContinueWatching(data)
5424
} catch (e) {
5525
console.warn("Error in getting Continue Watching Anime", e);
56-
}finally {
26+
} finally {
5727
setContinueWatchingLoading(false)
5828
}
5929
},[])
6030
useEffect(()=>{
61-
GetTrending()
62-
GetPopular()
63-
GetAiring()
6431
GetContinueWatching()
6532
},[])
6633
return (<MainWrapper>

Route/InitialRoute.jsx

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import Animated, { FadeIn } from "react-native-reanimated";
2+
import { View } from "react-native";
3+
import { MainWrapper } from "../Layout/MainWrapper";
4+
import { useTheme } from "@react-navigation/native";
5+
import { useEffect } from "react";
6+
import FastImage from "react-native-fast-image";
7+
8+
export const InitialScreen = ({navigation}) => {
9+
const theme = useTheme()
10+
async function InitialCall(){
11+
navigation.replace("MainRoute")
12+
}
13+
useEffect(() => {
14+
setTimeout(() => {InitialCall()}, 820)
15+
}, []);
16+
return (
17+
<MainWrapper>
18+
<View style={{
19+
flex:1,
20+
alignItems:"center",
21+
justifyContent:"center",
22+
}}>
23+
<FastImage source={require("../assets/AppImages/nekoJump.gif")} style={{
24+
height:200,
25+
width:200,
26+
}} resizeMode={FastImage.resizeMode.stretch}/>
27+
<Animated.Text entering={FadeIn.delay(100).duration(300)} style={{
28+
fontSize:40,
29+
color:theme.colors.text,
30+
fontWeight:500,
31+
}}>Nekoflix</Animated.Text>
32+
<Animated.Text entering={FadeIn.delay(300)} style={{
33+
fontSize:15,
34+
color:theme.colors.primary,
35+
}}>Anime for you.</Animated.Text>
36+
</View>
37+
</MainWrapper>
38+
);
39+
};

assets/AppImages/nekoJump.gif

112 KB
Loading

0 commit comments

Comments
 (0)