-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.js
119 lines (103 loc) · 3.15 KB
/
App.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
import React, { useState, useEffect } from 'react';
import {
Alert,
BackHandler,
ToastAndroid,
} from 'react-native'
import MaterialCommunityIcons from 'react-native-vector-icons/MaterialCommunityIcons';
import Feather from 'react-native-vector-icons/Feather';
import { createSwitchNavigator, createAppContainer } from 'react-navigation';
import { createStackNavigator } from 'react-navigation-stack';
import { RewardedAd, TestIds, RewardedAdEventType } from '@react-native-firebase/admob';
import PINCode from '@haskkor/react-native-pincode'
import { hasUserSetPinCode } from '@haskkor/react-native-pincode'
import SplashScreen from 'react-native-splash-screen';
import { REWARDS } from './src/api/Data';
import ThemeContext from './src/theme';
import HomeScreen from './src/screens/HomeScreen';
import CustomDrawerScreen from './src/screens/CustomDrawerScreen';
import AppLockScreen from './src/screens/AppLockScreen';
import { createDrawerNavigator } from 'react-navigation-drawer';
import SelectedCategory from './src/screens/SelectedCategory';
import VideoPlayer from './src/components/VideoPlayer';
import { Appearance } from 'react-native';
import DownloadChangelog from './src/screens/DownloadChangelog';
MaterialCommunityIcons.loadFont();
Feather.loadFont();
const MainNavigator = createStackNavigator({
HomeScreen,
SelectedCategory,
VideoScreen: VideoPlayer
}, {
initialRouteName: 'HomeScreen',
headerMode: 'none',
mode: 'modal',
keyboardHandlingEnabled: true
})
const Dashboard = createDrawerNavigator(
{
MainNavigator,
appLock: AppLockScreen,
download: DownloadChangelog
},
{
contentOptions: {
activeTintColor: '#fd6d24',
backgroundTintColor: '#fdbf83',
},
initialRouteName: 'MainNavigator',
drawerType: 'slide',
contentComponent: (props) => <CustomDrawerScreen {...props} />,
},
);
const AppNavigator = createSwitchNavigator(
{
Dashboard
},
);
const AppContainer = createAppContainer(AppNavigator);
export default App = () => {
const [auth, setAuth] = useState(false);
const checkUserPIN = async () => {
try {
const auth = await hasUserSetPinCode()
setAuth(auth);
SplashScreen.hide();
} catch {
console.log('here')
ToastAndroid.showWithGravity('Who dis?', ToastAndroid.LONG, ToastAndroid.CENTER)
BackHandler.exitApp()
}
}
const giveAuth = () => {
setAuth(false)
}
useEffect(() => {
checkUserPIN();
const rewarded = RewardedAd.createForAdRequest(REWARDS, {
requestNonPersonalizedAdsOnly: false,
});
rewarded.onAdEvent((type, error, reward) => {
if (type === RewardedAdEventType.LOADED) {
rewarded.show();
}
if (type === RewardedAdEventType.EARNED_REWARD) {
console.log('User earned reward of ', reward);
}
});
setTimeout(() => {
rewarded.load();
}, 5000);
}, []);
const themeHook = useState(Appearance.getColorScheme());
return (
!auth ?
<ThemeContext.Provider value={themeHook}>
<AppContainer />
</ThemeContext.Provider> :
<PINCode status={'enter'}
finishProcess={giveAuth}
disableLockScreen={true}
/>
);
};