feat(loading): Changed loading/error rendering (#612)

This commit is contained in:
Penar Musaraj 2019-06-02 14:32:22 -04:00 committed by Thibault Malbranche
parent 3f3bcfc0ba
commit d429e82c3a
4 changed files with 8 additions and 31 deletions

View File

@ -244,13 +244,6 @@ class WebView extends React.Component<AndroidWebViewProps, State> {
}
const webViewStyles = [styles.container, styles.webView, style];
if (
this.state.viewState === 'LOADING'
|| this.state.viewState === 'ERROR'
) {
// if we're in either LOADING or ERROR states, don't show the webView
webViewStyles.push(styles.hidden);
}
if (source && 'method' in source) {
if (source.method === 'POST' && source.headers) {

View File

@ -346,13 +346,6 @@ class WebView extends React.Component<IOSWebViewProps, State> {
}
const webViewStyles = [styles.container, styles.webView, style];
if (
this.state.viewState === 'LOADING'
|| this.state.viewState === 'ERROR'
) {
// if we're in either LOADING or ERROR states, don't show the webView
webViewStyles.push(styles.hidden);
}
const onShouldStartLoadWithRequest = createOnShouldStartLoadWithRequest(
this.onShouldStartLoadWithRequestCallback,

View File

@ -2,11 +2,9 @@ import { StyleSheet, ViewStyle, TextStyle } from 'react-native';
interface Styles {
container: ViewStyle;
errorContainer: ViewStyle;
errorText: TextStyle;
errorTextTitle: TextStyle;
hidden: ViewStyle;
loadingView: ViewStyle;
loadingOrErrorView: ViewStyle;
webView: ViewStyle;
loadingProgressBar: ViewStyle;
}
@ -16,21 +14,14 @@ const styles = StyleSheet.create<Styles>({
flex: 1,
overflow: 'hidden',
},
errorContainer: {
loadingOrErrorView: {
position: 'absolute',
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: 'white',
},
hidden: {
height: 0,
flex: 0, // disable 'flex:1' when hiding a View
},
loadingView: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: 'white',
height: '100%',
width: '100%',
backgroundColor: 'white'
},
loadingProgressBar: {
height: 20,

View File

@ -75,7 +75,7 @@ const getViewManagerConfig = (
};
const defaultRenderLoading = () => (
<View style={styles.loadingView}>
<View style={styles.loadingOrErrorView}>
<ActivityIndicator />
</View>
);
@ -84,7 +84,7 @@ const defaultRenderError = (
errorCode: number,
errorDesc: string,
) => (
<View style={styles.errorContainer}>
<View style={styles.loadingOrErrorView}>
<Text style={styles.errorTextTitle}>Error loading page</Text>
<Text style={styles.errorText}>{`Domain: ${errorDomain}`}</Text>
<Text style={styles.errorText}>{`Error Code: ${errorCode}`}</Text>