mirror of
https://github.com/expo/react-native-loading-container.git
synced 2026-11-14 19:11:56 -10:00
71 lines
1.4 KiB
JavaScript
71 lines
1.4 KiB
JavaScript
/**
|
|
* Copyright 2015-present 650 Industries. All rights reserved.
|
|
*
|
|
* @providesModule ErrorOverlay
|
|
*/
|
|
'use strict';
|
|
|
|
import React, {
|
|
Image,
|
|
PropTypes,
|
|
StyleSheet,
|
|
Text,
|
|
TouchableOpacity,
|
|
} from 'react-native';
|
|
|
|
// todo(brentvatne): set some base64 image as default
|
|
let NO_NETWORK_IMAGE_URI = '';
|
|
|
|
export default class ErrorOverlay extends React.Component {
|
|
|
|
static propTypes = {
|
|
onRetryLoad: PropTypes.func.isRequired,
|
|
};
|
|
|
|
constructor(props, context) {
|
|
super(props, context);
|
|
this.state = { overlayHidden: true };
|
|
}
|
|
|
|
hideOverlay() {
|
|
this.setState({ overlayHidden: true });
|
|
}
|
|
|
|
showOverlay() {
|
|
this.setState({ overlayHidden: false });
|
|
}
|
|
|
|
render() {
|
|
if (this.state.overlayHidden) {
|
|
return null;
|
|
}
|
|
|
|
// <Image
|
|
// source={{uri: NO_NETWORK_IMAGE_URI}}
|
|
// resizeMode="contain"
|
|
// style={{width: 60, height: 60, marginBottom: 10}} />
|
|
|
|
return (
|
|
<TouchableOpacity style={styles.overlay} onPress={this.props.onRetryLoad}>
|
|
<Text style={{color: '#ababad', fontSize: 14}}>
|
|
Unable to contact server. Tap to retry.
|
|
</Text>
|
|
</TouchableOpacity>
|
|
);
|
|
}
|
|
}
|
|
|
|
|
|
let styles = StyleSheet.create({
|
|
overlay: {
|
|
backgroundColor: '#fff',
|
|
position: 'absolute',
|
|
top: 0,
|
|
bottom: 0,
|
|
left: 0,
|
|
right: 0,
|
|
justifyContent: 'center',
|
|
alignItems: 'center',
|
|
},
|
|
});
|