-
-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathHomeScreen.js
123 lines (107 loc) · 3.82 KB
/
HomeScreen.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
120
121
122
123
import React from 'react';
import { StackNavigator } from 'react-navigation';
import { StyleSheet, ImageBackground, View, TouchableHighlight, Image, Text} from 'react-native';
import { homeScreenImage, ENGLISH, HINDI } from './config';
import { withDimensions } from "./component/responsive.js";
class HomeScreenWrapped extends React.Component {
constructor(props) {
super(props);
this.state = {
language: ENGLISH
}
}
// could be abstracted to a single function accepting lang prop
// but this works for only two cases
handlePress= (lang) => {
global.LANG = lang;
this.props.navigation.navigate("Chooser");
}
render () {
const navigation = this.props.navigation;
let homeScreenImage = require('./assets/BackgroundForAppLanding.png');
let titleImage = require('./assets/Aashiyaan.png');
let {pressing} = this.state;
let languageImageEnglish =
pressing === ENGLISH ?
require('./assets/AppLandingEnglishSelected.png') :
require('./assets/AppLandingEnglish.png');
let languageImageHindi =
pressing === HINDI ?
require('./assets/AppLandingHindiSelected.png') :
require('./assets/AppLandingHindi.png');
let {width, height} = this.props.windowDimensions;
let titleWidth = 0.51 * width;
let titleHeight = 0.6 * titleWidth;
return (
<ImageBackground
source={ homeScreenImage }
imageStyle={{resizeMode: 'cover'}}
style={{flex: 1, width: width, height: height}}
>
<ImageBackground
source={ titleImage }
resizeMode='contain'
style={{
width: titleWidth,
height: titleHeight,
position: 'absolute',
left: '43%',
bottom: '15%',
flex: 1,
flexDirection: 'row',
justifyContent: 'space-around',
alignItems: 'stretch'
}}
>
<TouchableHighlight
onPress={() => this.handlePress(ENGLISH)}
onPressIn={() => { this.setState({ pressing: ENGLISH }); }}
onPressOut={() => { this.setState({ pressing: null }); }}
underlayColor="transparent"
style={{
padding: 0.1 * titleWidth,
position:'relative'
}}
>
<Image source={languageImageEnglish}
style={{
width: 0.2 * titleWidth,
height: 0.2 * titleWidth,
position:'relative',
top:'40%'
}}
/>
</TouchableHighlight>
<TouchableHighlight
onPress={() => this.handlePress(HINDI)}
onPressIn={() => { this.setState({ pressing: HINDI }); }}
onPressOut={() => { this.setState({ pressing: null }); }}
underlayColor="transparent"
style={{
padding: 0.1 * titleWidth,
position:'relative'
}}
>
<Image source={languageImageHindi} style={{
width: 0.2 * titleWidth,
height: 0.2 * titleWidth,
position:'relative',
top:'80%'
}} />
</TouchableHighlight>
</ImageBackground>
</ImageBackground>
)
}
}
const HomeScreen = withDimensions(HomeScreenWrapped);
export default HomeScreen;
const styles = StyleSheet.create({
previewText: {
margin: 5,
position: 'absolute',
top: 0,
right: 0,
bottom: 0,
}
});