-
Notifications
You must be signed in to change notification settings - Fork 693
/
EmptyStateScreen.js
75 lines (71 loc) · 2.03 KB
/
EmptyStateScreen.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
import React, {Component} from 'react';
import {StyleSheet, ScrollView, View} from 'react-native';
import {StateScreen, Constants, PageControl} from 'react-native-ui-lib';//eslint-disable-line
const localImageSource = require('../../assets/images/empty-state.jpg'); // eslint-disable-line
const remoteImageSource = {uri: 'https://static.pexels.com/photos/169651/pexels-photo-169651.jpeg'};
export default class EmptyStateScreen extends Component {
constructor(props) {
super(props);
this.state = {currentPage: 0};
}
setCurrentPage(offsetX) {
if (offsetX >= 0) {
this.setState({
currentPage: Math.floor(offsetX / Constants.screenWidth),
});
}
}
render() {
return (
<View>
<ScrollView
style={styles.pageView}
horizontal
showsHorizontalScrollIndicator={false}
pagingEnabled
onScroll={(event) => {
this.setCurrentPage(event.nativeEvent.contentOffset.x);
}}
scrollEventThrottle={200}
>
<View style={styles.pageView}>
<StateScreen
title='Oppsie (with local image)'
subtitle='Nothing to see here..'
ctaLabel='OK'
imageSource={localImageSource}
/>
</View>
<View style={styles.pageView}>
<StateScreen
title='Oppsie (with remote image)'
subtitle='Nothing to see here..'
ctaLabel='OK'
imageSource={remoteImageSource}
/>
</View>
</ScrollView>
<PageControl
containerStyle={{
position: 'absolute',
bottom: 10,
left: 0,
width: Constants.screenWidth,
}}
numOfPages={2}
currentPage={this.state.currentPage}
/>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
flexDirection: 'column',
},
pageView: {
width: Constants.screenWidth,
height: Constants.screenHeight,
},
});