-
Notifications
You must be signed in to change notification settings - Fork 42
/
splash.js
76 lines (70 loc) · 1.47 KB
/
splash.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
import React from "react";
import PropTypes from "prop-types";
import { View, Image, StyleSheet } from "react-native";
import { addMissingProtocol } from "@times-components/utils";
import PlayIcon from "./play-icon";
const styles = StyleSheet.create({
overlay: {
alignItems: "center",
flex: 1,
justifyContent: "center",
left: 0,
position: "absolute",
top: 0
}
});
const addMissingProtocolToPoster = poster => ({
uri: addMissingProtocol(poster.uri)
});
const Splash = ({ poster, width, height, playIcon }) => (
<View
accessibilityLabel="splash-component"
style={{
height,
width
}}
testID="splash-component"
>
{poster ? (
<Image
source={addMissingProtocolToPoster(poster)}
style={{
height,
width
}}
/>
) : (
<View
style={{
backgroundColor: "black",
height,
width
}}
/>
)}
<View
style={[
styles.overlay,
{
height,
width
}
]}
>
<PlayIcon icon={playIcon} />
</View>
</View>
);
Splash.defaultProps = {
playIcon: null,
poster: null
};
Splash.propTypes = {
height: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired,
playIcon: PropTypes.node,
poster: PropTypes.shape({
uri: PropTypes.string.isRequired
}),
width: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired
};
export default Splash;