import React, {Component} from 'react';
import {
StyleSheet,
SafeAreaView,
Text,
TouchableOpacity,
View,
Keyboard,
Button,
Platform,
} from 'react-native';
import Alerts from './examples/Alerts';
import Scrolling from './examples/Scrolling';
import Background from './examples/Background';
import Downloads from './examples/Downloads';
import Uploads from './examples/Uploads';
import Injection from './examples/Injection';
import LocalPageLoad from './examples/LocalPageLoad';
import Messaging from './examples/Messaging';
const TESTS = {
Messaging: {
title: 'Messaging',
testId: 'messaging',
description: 'js-webview postMessage messaging test',
render() {
return ;
},
},
Alerts: {
title: 'Alerts',
testId: 'alerts',
description: 'Alerts tests',
render() {
return ;
},
},
Scrolling: {
title: 'Scrolling',
testId: 'scrolling',
description: 'Scrolling event test',
render() {
return ;
},
},
Background: {
title: 'Background',
testId: 'background',
description: 'Background color test',
render() {
return ;
},
},
Downloads: {
title: 'Downloads',
testId: 'downloads',
description: 'File downloads test',
render() {
return ;
},
},
Uploads: {
title: 'Uploads',
testId: 'uploads',
description: 'Upload test',
render() {
return ;
},
},
Injection: {
title: 'Injection',
testId: 'injection',
description: 'Injection test',
render() {
return ;
},
},
PageLoad: {
title: 'LocalPageLoad',
testId: 'LocalPageLoad',
description: 'Local Page load test',
render() {
return ;
},
},
};
type Props = {};
type State = {restarting: boolean; currentTest: Object};
export default class App extends Component {
state = {
restarting: false,
currentTest: TESTS.Alerts,
};
_simulateRestart = () => {
this.setState({restarting: true}, () => this.setState({restarting: false}));
};
_changeTest = (testName) => {
this.setState({currentTest: TESTS[testName]});
};
render() {
const {restarting, currentTest} = this.state;
return (
Keyboard.dismiss()}
testID="closeKeyboard"
/>
Simulate Restart
{restarting ? null : (
{currentTest.title}
{currentTest.description}
{currentTest.render()}
)}
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#F5FCFF',
padding: 8,
},
exampleContainer: {
padding: 16,
backgroundColor: '#FFF',
borderColor: '#EEE',
borderTopWidth: 1,
borderBottomWidth: 1,
flex: 1,
},
exampleTitle: {
fontSize: 18,
},
exampleDescription: {
color: '#333333',
marginBottom: 16,
},
exampleInnerContainer: {
borderColor: '#EEE',
borderTopWidth: 1,
paddingTop: 10,
flex: 1,
},
restartButton: {
padding: 6,
fontSize: 16,
borderRadius: 5,
backgroundColor: '#F3F3F3',
alignItems: 'center',
justifyContent: 'center',
alignSelf: 'flex-end',
},
closeKeyboardView: {
width: 5,
height: 5,
},
testPickerContainer: {
flexDirection: 'row',
flexWrap: 'wrap',
},
});