Skip to content

Commit c326a3a

Browse files
committed
Home screen with images and shadow and overlapping text
1 parent 0eb3471 commit c326a3a

File tree

4 files changed

+148
-39
lines changed

4 files changed

+148
-39
lines changed

App.js

+16-39
Original file line numberDiff line numberDiff line change
@@ -7,47 +7,24 @@
77
*/
88

99
import React, { Component } from 'react';
10-
import { Platform, StyleSheet, Text, View } from 'react-native';
10+
import { mapping, light as lightTheme } from '@eva-design/eva';
1111
import { Provider } from 'react-redux';
12+
import { ApplicationProvider, Layout } from 'react-native-ui-kitten';
1213
import store from './src/store';
13-
14-
const instructions = Platform.select({
15-
ios: 'Press Cmd+R to reload,\n' + 'Cmd+D or shake for dev menu',
16-
android:
17-
'Double tap R on your keyboard to reload,\n' +
18-
'Shake or press menu button for dev menu',
19-
});
20-
14+
import HomeScreen from './src/HomeScreen';
2115

2216
export default class App extends Component {
23-
render() {
24-
return (
25-
<Provider store={store}>
26-
<View style={styles.container}>
27-
<Text style={styles.welcome}>Welcome to React Native!</Text>
28-
<Text style={styles.instructions}>To get started, edit App.js</Text>
29-
<Text style={styles.instructions}>{instructions}</Text>
30-
</View>
31-
</Provider>
32-
);
33-
}
17+
render() {
18+
return (
19+
<Provider store={store}>
20+
<ApplicationProvider
21+
mapping={mapping}
22+
theme={lightTheme}>
23+
<Layout style={{ flex: 1 }} >
24+
<HomeScreen />
25+
</Layout>
26+
</ApplicationProvider>
27+
</Provider>
28+
);
29+
}
3430
}
35-
36-
const styles = StyleSheet.create({
37-
container: {
38-
flex: 1,
39-
justifyContent: 'center',
40-
alignItems: 'center',
41-
backgroundColor: '#F5FCFF',
42-
},
43-
welcome: {
44-
fontSize: 20,
45-
textAlign: 'center',
46-
margin: 10,
47-
},
48-
instructions: {
49-
textAlign: 'center',
50-
color: '#333333',
51-
marginBottom: 5,
52-
},
53-
});

package-lock.json

+37
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+2
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,13 @@
77
"test": "jest"
88
},
99
"dependencies": {
10+
"@eva-design/eva": "1.0.1",
1011
"axios": "0.19.0",
1112
"react": "16.8.3",
1213
"react-native": "0.59.10",
1314
"react-native-gesture-handler": "1.3.0",
1415
"react-native-reanimated": "1.1.0",
16+
"react-native-ui-kitten": "4.2.0-beta.1",
1517
"react-navigation": "3.11.1",
1618
"react-redux": "7.1.0",
1719
"redux": "4.0.4",

src/HomeScreen.js

+93
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
import React, { Component } from 'react'
2+
import { Platform, StyleSheet, View, Image, Dimensions, ImageBackground } from 'react-native';
3+
import { Text } from 'react-native-ui-kitten'
4+
import { SafeAreaView } from 'react-navigation'
5+
import { FlatList } from 'react-native-gesture-handler';
6+
7+
const WINDOW_WIDTH = Dimensions.get('window').width
8+
9+
class HomeScreen extends Component {
10+
11+
constructor(props) {
12+
super(props)
13+
}
14+
15+
// TODO: replace with real data
16+
state = {
17+
data: [],
18+
images: [
19+
{ title: "Breaking Bad", image: "https://www.thetvdb.com/banners/_cache/fanart/original/81189-1.jpg" },
20+
{ title: "Breaking Bad", image: "https://www.thetvdb.com/banners/_cache/fanart/original/81189-1.jpg" },
21+
{ title: "Breaking Bad", image: "https://www.thetvdb.com/banners/_cache/fanart/original/81189-1.jpg" },
22+
{ title: "Breaking Bad", image: "https://www.thetvdb.com/banners/_cache/fanart/original/81189-1.jpg" },
23+
{ title: "Breaking Bad", image: "https://www.thetvdb.com/banners/_cache/fanart/original/81189-1.jpg" },
24+
]
25+
}
26+
27+
_keyExtractor = (item, index) => index.toString()
28+
29+
_renderItem = ({ item }) => {
30+
const { title, image } = item
31+
32+
return (
33+
<ImageBackground source={{ uri: image }} style={styles.largeThumbnail} imageStyle={{ borderRadius: 12 }} >
34+
<View style={{ position: 'absolute', bottom: 0 }}>
35+
< Text category="h4" style={styles.titleText}>{title} </Text>
36+
</View>
37+
</ImageBackground >
38+
)
39+
}
40+
41+
render() {
42+
return (
43+
<SafeAreaView style={styles.container}>
44+
<Text category="h4" style={styles.welcome}>Welcome to Home Screen</Text>
45+
<Text style={styles.instructions}>To get started, edit App.js</Text>
46+
47+
<FlatList
48+
data={this.state.images}
49+
renderItem={this._renderItem.bind(this)}
50+
keyExtractor={this._keyExtractor.bind(this)}
51+
/>
52+
</SafeAreaView>
53+
)
54+
}
55+
}
56+
57+
export default HomeScreen;
58+
59+
const styles = StyleSheet.create({
60+
container: {
61+
flex: 1,
62+
backgroundColor: '#F5FCFF',
63+
},
64+
titleText: {
65+
alignSelf: 'flex-start',
66+
marginLeft: 20,
67+
marginBottom: 10,
68+
color: 'white'
69+
},
70+
largeThumbnail: {
71+
width: WINDOW_WIDTH - 40,
72+
height: WINDOW_WIDTH - 40,
73+
marginRight: 20,
74+
marginLeft: 20,
75+
marginBottom: 40,
76+
borderRadius: 12,
77+
elevation: 4,
78+
shadowOffset: { height: 4, width: 4 },
79+
shadowOpacity: 0.8,
80+
shadowColor: '#424242',
81+
shadowRadius: 8
82+
},
83+
welcome: {
84+
fontSize: 20,
85+
textAlign: 'center',
86+
margin: 10,
87+
},
88+
instructions: {
89+
textAlign: 'center',
90+
color: '#333333',
91+
marginBottom: 5,
92+
},
93+
});

0 commit comments

Comments
 (0)