Created
March 26, 2019 20:07
-
-
Save a-bishop/cf871bd67b0087e1f040316c53bf9e2a to your computer and use it in GitHub Desktop.
React Native WebView example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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