Created
July 17, 2018 09:24
-
-
Save ajiehatajie/d4230acf9758d68e8bcf586622e26446 to your computer and use it in GitHub Desktop.
scan barcode
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 { | |
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, | |
}, | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment