まずはガワだけ。
import React from "react";
import { View, Text, TouchableOpacity, StyleSheet } from "react-native";
export default class QRCodeModal extends React.Component {
static navigationOptions = props => ({
title: 'バーコード読み込み',
headerLeft: (
<TouchableOpacity onPress={() => {props.navigation.goBack()}}>
<Text style={{ fontWeight:'bold', fontSize: 16, marginHorizontal: 16 }}>キャンセル</Text>
</TouchableOpacity>
)
});
render() {
return (
<View style={styles.container}>
<Text>カメラの使用許可をリクエスト中です...</Text>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
alignItems: "center",
justifyContent: "center",
}
});
import React from 'react';
- import { StyleSheet, Text, View } from 'react-native';
+ import { StyleSheet, Text, View, Button } from 'react-native';
export default class MainScreen extends React.Component {
static navigationOptions = {
title: 'CRNA Demo',
};
render() {
return (
<View style={styles.container}>
<Text>Open up App.js to start working on your app!</Text>
<Text>Changes you make will automatically reload.</Text>
<Text>Shake your phone to open the developer menu.</Text>
+ <View style={{ height: 16 }} />
+ <Button
+ title="QRCode Sample"
+ onPress={() => this.props.navigation.navigate('QRCode')} />
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'center',
},
});
import React from "react";
import { createStackNavigator } from "react-navigation";
import MainScreen from "./MainScreen";
+ import QRCodeModal from "./QRCodeModal";
export default createStackNavigator({
Main: MainScreen,
+ QRCode: QRCodeModal,
+ }, {
+ mode: "modal",
});