Guest User

Untitled

a guest
Jul 17th, 2018
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.80 KB | None | 0 0
  1. import React, { Component } from 'react'
  2.  
  3. import {
  4. AppRegistry,
  5. StyleSheet,
  6. TouchableOpacity,
  7. Linking,Text
  8. } from 'react-native';
  9. import { Container, Header, Title, Left, Icon, Right, Button, Body, Content, Card, CardItem } from "native-base";
  10.  
  11. import { withNavigationFocus } from 'react-navigation';
  12. import QRCodeScanner from 'react-native-qrcode-scanner';
  13.  
  14.  
  15. type Props = {};
  16.  
  17.  
  18. export default class HomeScreens extends Component<Props> {
  19.  
  20. constructor(props){
  21. super(props)
  22. this.state = {
  23. link : ''
  24. }
  25. console.log('constucturt')
  26.  
  27. }
  28.  
  29. componentDidMount() {
  30.  
  31. console.log('did mount home')
  32.  
  33. }
  34. onSuccess(e) {
  35. this.setState({link:e.data})
  36. this.props.navigation.navigate('About')
  37. // Linking
  38. //.openURL(e.data)
  39. //.catch(err => console.error('An error occured', err));
  40. }
  41. componentWillUnmount(){
  42. this.scanner.reactivate()
  43. console.log('will unmount home')
  44.  
  45. }
  46.  
  47. render() {
  48. return (
  49. <Container>
  50. <Header>
  51. <Body>
  52. <Title>Scan Code</Title>
  53. </Body>
  54. <Right />
  55. </Header>
  56. <Content>
  57.  
  58. <QRCodeScanner
  59. ref={(node) => { this.scanner = node }}
  60. onRead={this.onSuccess.bind(this)}
  61. topContent={
  62. <Text style={styles.centerText}>
  63. arahkan ke kamera HP kamu
  64. {this.props.isFocused ? ' Focused' : ' Not focused'}
  65. </Text>
  66. }
  67.  
  68. />
  69. </Content>
  70.  
  71. </Container>
  72. )
  73. }
  74. }
  75.  
  76. const styles = StyleSheet.create({
  77. centerText: {
  78. flex: 1,
  79. fontSize: 18,
  80. padding: 32,
  81. color: '#777',
  82. },
  83. textBold: {
  84. fontWeight: '500',
  85. color: '#000',
  86. },
  87. buttonText: {
  88. fontSize: 21,
  89. color: 'rgb(0,122,255)',
  90. },
  91. buttonTouchable: {
  92. padding: 16,
  93. },
  94. });
Add Comment
Please, Sign In to add comment