Skip to content

Instantly share code, notes, and snippets.

@a-bishop
Created March 26, 2019 20:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save a-bishop/cf871bd67b0087e1f040316c53bf9e2a to your computer and use it in GitHub Desktop.
Save a-bishop/cf871bd67b0087e1f040316c53bf9e2a to your computer and use it in GitHub Desktop.
React Native WebView example
import React, { Component } from "react";
import { View, Text, Button, StyleSheet, Dimensions } from "react-native";
import { createStackNavigator, createAppContainer } from "react-navigation";
import { WebView } from "react-native-webview";
const dimensions = {
fullHeight: Dimensions.get('window').height,
fullWidth: Dimensions.get('window').width
};
const styles = StyleSheet.create({
container: {
width: dimensions.fullWidth,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#F5FCFF',
}
});
class HomeScreen extends Component {
render() {
return (
<View style={{ flex: 1, alignItems: "center", justifyContent: "center" }}>
<Text>Web View Example</Text>
<Button
title="Make a booking"
onPress={() => this.props.navigation.navigate('Reserve')}
/>
</View>
);
}
}
class ReserveScreen extends Component {
render() {
return (
<WebView
source={{ uri: "https://camosuncapstone.checkfront.com/reserve/" }}
style= {[styles.container]}
onLoadProgress={e => console.log(e.nativeEvent.progress)}
/>
);
}
}
const AppNavigator = createStackNavigator(
{
Home: HomeScreen,
Reserve: ReserveScreen
},
{
initialRouteName: "Home"
}
);
const AppContainer = createAppContainer(AppNavigator);
export default class App extends Component {
render() {
return <AppContainer />;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment