Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import React, { Component } from 'react'
- import {
- AppRegistry,
- StyleSheet,
- TouchableOpacity,
- Linking,Text
- } from 'react-native';
- import { Container, Header, Title, Left, Icon, Right, Button, Body, Content, Card, CardItem } from "native-base";
- import { withNavigationFocus } from 'react-navigation';
- import QRCodeScanner from 'react-native-qrcode-scanner';
- type Props = {};
- export default class HomeScreens extends Component<Props> {
- constructor(props){
- super(props)
- this.state = {
- link : ''
- }
- console.log('constucturt')
- }
- componentDidMount() {
- console.log('did mount home')
- }
- onSuccess(e) {
- this.setState({link:e.data})
- this.props.navigation.navigate('About')
- // Linking
- //.openURL(e.data)
- //.catch(err => console.error('An error occured', err));
- }
- componentWillUnmount(){
- this.scanner.reactivate()
- console.log('will unmount home')
- }
- render() {
- return (
- <Container>
- <Header>
- <Body>
- <Title>Scan Code</Title>
- </Body>
- <Right />
- </Header>
- <Content>
- <QRCodeScanner
- ref={(node) => { this.scanner = node }}
- onRead={this.onSuccess.bind(this)}
- topContent={
- <Text style={styles.centerText}>
- arahkan ke kamera HP kamu
- {this.props.isFocused ? ' Focused' : ' Not focused'}
- </Text>
- }
- />
- </Content>
- </Container>
- )
- }
- }
- const styles = StyleSheet.create({
- centerText: {
- flex: 1,
- fontSize: 18,
- padding: 32,
- color: '#777',
- },
- textBold: {
- fontWeight: '500',
- color: '#000',
- },
- buttonText: {
- fontSize: 21,
- color: 'rgb(0,122,255)',
- },
- buttonTouchable: {
- padding: 16,
- },
- });
Add Comment
Please, Sign In to add comment