SimilarProductGuider.js
2.24 KB
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
'use strict';
import React, {Component} from 'react';
import ReactNative, {
View,
Text,
Image,
Platform,
StyleSheet,
Dimensions,
TouchableOpacity,
} from 'react-native';
import TimerMixin from 'react-timer-mixin';
export default class SimilarProductGuider extends Component {
constructor(props) {
super(props);
this.state = {
isVisible: true,
};
}
componentDidMount() {
this.timer = TimerMixin.setTimeout(() => {
this.setState({
isVisible: false,
});
}, 3000);
}
componentWillUnmount() {
this.timer && TimerMixin.clearTimeout(this.timer);
}
render() {
if (!this.state.isVisible) {
return null;
}
return (
<TouchableOpacity
style={{
position: 'absolute',
top: 0,
width: rowWidth,
height: imageHeight,
}}
onPress={() => {
this.setState({
isVisible: false,
});
}}
>
<View style={styles.imageContainer} >
<Image source={require('../../images/find_resemblance_hand.png')}/>
<Image style={styles.word} source={require('../../images/find_resemblance_word.png')}/>
</View>
</TouchableOpacity>
);
}
}
let {width, height} = Dimensions.get('window');
const DEVICE_WIDTH_RATIO = width / 320;
let rowWidth = Math.ceil(137.5 * DEVICE_WIDTH_RATIO);
let rowHeight = Math.ceil(254 * DEVICE_WIDTH_RATIO);
const IMAGE_WIDTH = 145;
const IMAGE_HEIGHT = 193;
const IMAGE_RATIO = IMAGE_HEIGHT / IMAGE_WIDTH;
let imageTop = 14 * DEVICE_WIDTH_RATIO;
let imageHeight = rowWidth * IMAGE_RATIO;
let wordTop = Math.ceil(15 * width / 375);
let styles = StyleSheet.create({
imageContainer: {
position: 'absolute',
top: 0,
width: rowWidth,
height: imageHeight,
backgroundColor: 'black',
opacity: 0.5,
justifyContent: 'center',
alignItems: 'center',
},
word: {
marginTop: wordTop,
},
});