-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.tsx
71 lines (66 loc) · 1.75 KB
/
App.tsx
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
import { useState } from 'react';
import { StyleSheet, Text, View, ScrollView, Pressable } from 'react-native';
import 'expo-dev-client';
import { Banner, Interstitial, Rewarded } from './src/screens/';
export default function App() {
const [adType, setAdType] = useState('banner');
const ChangeAdTypeButton = ({ type }: { type: string }) => {
return (
<Pressable
onPress={() => {
setAdType(type);
}}
style={[
styles.button,
{ backgroundColor: adType === type ? 'forestgreen' : 'darkgrey' },
]}>
<Text style={{ color: '#fff', fontSize: 18 }}> {type} </Text>
</Pressable>
);
};
return (
<View style={styles.container}>
<Text style={{ marginTop: 30, fontSize: 26, color: '#fff' }}>
Google Ads Sample
</Text>
<View
style={{
height: '15%',
flexDirection: 'row',
justifyContent: 'center',
alignItems: 'center',
}}>
<ChangeAdTypeButton type='banner' />
<ChangeAdTypeButton type='rewarded' />
<ChangeAdTypeButton type='interstitial' />
</View>
{adType === 'banner' && <Banner />}
{adType === 'rewarded' && <Rewarded />}
{adType === 'interstitial' && <Interstitial />}
</View>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: 'steelblue',
alignItems: 'center',
justifyContent: 'flex-start',
},
button: {
shadowColor: '#000',
shadowOffset: {
width: 0,
height: 2,
},
shadowOpacity: 0.25,
shadowRadius: 3.84,
elevation: 5,
width: 100,
height: 50,
alignItems: 'center',
justifyContent: 'center',
borderRadius: 10,
marginHorizontal: 5,
},
});