This repository has been archived by the owner on Oct 15, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
AdChoicesManager.js
69 lines (58 loc) · 1.66 KB
/
AdChoicesManager.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
import React, {PropTypes} from 'react';
import {requireNativeComponent, StyleSheet, Platform} from 'react-native';
const NativeAdChoicesView = requireNativeComponent('AdChoicesView', null);
let positionStyle = null;
type adChoiceLocation = 'topLeft' | 'topRight' | 'bottomLeft' | 'bottomRight';
export default class AdChoicesView extends React.Component<Object> {
location: adChoiceLocation
componentWillMount() {
positionStyle = styles.topRight;
location = this.props.position;
if (location === 'topLeft') {
positionStyle = styles.topLeft
} else if (location === 'topRight') {
positionStyle = styles.topRight
} else if (location === 'bottomLeft') {
positionStyle = styles.bottomLeft
} else if (location === 'bottomRight') {
positionStyle = styles.bottomRight
}
}
render() {
return (
<NativeAdChoicesView {...this.props}
style={[styles.adChoice, positionStyle]}
location={this.props.position || 'topRight'}/>
);
}
}
let styles = StyleSheet.create({
adChoice: {
backgroundColor: 'transparent',
...Platform.select({
ios: {
width: 0, height: 0,
},
android: {
width: 22, height: 22,
},
}),
position: 'absolute',
},
topLeft: {
left: 0,
top: 0,
},
topRight: {
top: 0,
right: 0
},
bottomLeft: {
left: 0,
bottom: 0,
},
bottomRight: {
bottom: 0,
right: 0
}
})