|
@@ -3,7 +3,7 @@
|
|
|
* @邠心vbe on 2021/03/24
|
|
* @邠心vbe on 2021/03/24
|
|
|
*/
|
|
*/
|
|
|
import React, { Component } from 'react'
|
|
import React, { Component } from 'react'
|
|
|
-import { StyleSheet, View } from 'react-native'
|
|
|
|
|
|
|
+import { Pressable, StyleSheet, View } from 'react-native'
|
|
|
import QRCodeScanner from 'react-native-qrcode-scanner';
|
|
import QRCodeScanner from 'react-native-qrcode-scanner';
|
|
|
import { RNCamera } from 'react-native-camera';
|
|
import { RNCamera } from 'react-native-camera';
|
|
|
import apiCharge from '../../api/apiCharge';
|
|
import apiCharge from '../../api/apiCharge';
|
|
@@ -83,7 +83,8 @@ export default class QRScan extends Component {
|
|
|
super(props);
|
|
super(props);
|
|
|
this.state={
|
|
this.state={
|
|
|
isResult: true,
|
|
isResult: true,
|
|
|
- params: this.props.route.params
|
|
|
|
|
|
|
+ params: this.props.route.params,
|
|
|
|
|
+ flashLight: false
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -182,6 +183,12 @@ export default class QRScan extends Component {
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ switchFlash() {
|
|
|
|
|
+ this.setState({
|
|
|
|
|
+ flashLight: !this.state.flashLight
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
render() {
|
|
render() {
|
|
|
return (
|
|
return (
|
|
|
<View style={styles.container}>
|
|
<View style={styles.container}>
|
|
@@ -193,13 +200,23 @@ export default class QRScan extends Component {
|
|
|
reactivateTimeout={1000}
|
|
reactivateTimeout={1000}
|
|
|
cameraStyle={{ width: $width, height: $vh(100)}}
|
|
cameraStyle={{ width: $width, height: $vh(100)}}
|
|
|
containerStyle={{ width: $width, height: $vh(100)}}
|
|
containerStyle={{ width: $width, height: $vh(100)}}
|
|
|
- flashMode={RNCamera.Constants.FlashMode.off}
|
|
|
|
|
|
|
+ flashMode={this.state.flashLight ? RNCamera.Constants.FlashMode.torch : RNCamera.Constants.FlashMode.off}
|
|
|
checkAndroid6Permissions={true} />
|
|
checkAndroid6Permissions={true} />
|
|
|
: <View style={ui.flex1}></View>
|
|
: <View style={ui.flex1}></View>
|
|
|
/*<Image
|
|
/*<Image
|
|
|
style={Styles.logo}
|
|
style={Styles.logo}
|
|
|
source={require('../../images/app-logo.png')}/> */
|
|
source={require('../../images/app-logo.png')}/> */
|
|
|
}
|
|
}
|
|
|
|
|
+ { !this.state.isResult &&
|
|
|
|
|
+ <Pressable
|
|
|
|
|
+ style={styles.flashLight}
|
|
|
|
|
+ onPress={() => this.switchFlash()}>
|
|
|
|
|
+ <MaterialIcons
|
|
|
|
|
+ name={this.state.flashLight ? "flashlight-on" : "flashlight-off"}
|
|
|
|
|
+ size={36}
|
|
|
|
|
+ color="#fff"/>
|
|
|
|
|
+ </Pressable>
|
|
|
|
|
+ }
|
|
|
</View>
|
|
</View>
|
|
|
);
|
|
);
|
|
|
}
|
|
}
|
|
@@ -211,6 +228,13 @@ const styles = StyleSheet.create({
|
|
|
justifyContent: 'center',
|
|
justifyContent: 'center',
|
|
|
backgroundColor: '#000',
|
|
backgroundColor: '#000',
|
|
|
...StyleSheet.absoluteFillObject
|
|
...StyleSheet.absoluteFillObject
|
|
|
|
|
+ },
|
|
|
|
|
+ flashLight: {
|
|
|
|
|
+ bottom: 90,
|
|
|
|
|
+ zIndex: 2,
|
|
|
|
|
+ opacity: 0.7,
|
|
|
|
|
+ padding: 8,
|
|
|
|
|
+ position: 'absolute'
|
|
|
}
|
|
}
|
|
|
})
|
|
})
|
|
|
|
|
|