Commit d2b7893e by zeven

刷脸屏幕保护

parent f1eafaf1
import React, {Component} from 'react';
import {Image, Dimensions} from 'react-native';
import Touch from './Touch';
const {width} = Dimensions.get('screen');
const logoSize = width / 3;
class Screensaver extends Component {
onPress = () => {
const {onPress} = this.props;
onPress && onPress();
};
render() {
return (
<Touch style={styles.page} onPress={this.onPress}>
<Image style={styles.logo} source={require('../assets/logo2.png')} />
</Touch>
);
}
}
const styles = {
page: {
flex: 1,
backgroundColor: 'black',
justifyContent: 'center',
alignItems: 'center',
},
logo: {
width: logoSize,
height: logoSize,
opacity: 0.1,
},
};
export default Screensaver;
...@@ -14,6 +14,7 @@ import Smilepay from '../utils/Smilepay'; ...@@ -14,6 +14,7 @@ import Smilepay from '../utils/Smilepay';
import phone from '../assets/Vertical/phone.png'; import phone from '../assets/Vertical/phone.png';
import {onTalkCall, leaveTalkCall} from '../utils/agora'; import {onTalkCall, leaveTalkCall} from '../utils/agora';
import Toast from '../components/Toast'; import Toast from '../components/Toast';
import Screensaver from '../components/Screensaver';
const {width} = Dimensions.get('screen'); const {width} = Dimensions.get('screen');
...@@ -31,6 +32,7 @@ class FacePage extends Component { ...@@ -31,6 +32,7 @@ class FacePage extends Component {
tip: '', tip: '',
tipsModal: false, tipsModal: false,
faceType: 'wxpay', faceType: 'wxpay',
sleep: true,
}; };
async componentWillMount() { async componentWillMount() {
...@@ -159,7 +161,7 @@ class FacePage extends Component { ...@@ -159,7 +161,7 @@ class FacePage extends Component {
try { try {
clearInterval(this.noTalkCall); clearInterval(this.noTalkCall);
clearInterval(this.callTimeout); clearInterval(this.callTimeout);
await leaveTalkCall; await leaveTalkCall();
// if (this.engine) { // if (this.engine) {
// await this.engine.leaveChannel(); // await this.engine.leaveChannel();
// } // }
...@@ -175,6 +177,7 @@ class FacePage extends Component { ...@@ -175,6 +177,7 @@ class FacePage extends Component {
}; };
face = () => { face = () => {
this.wakeUp();
this.state.faceType === 'wxpay' ? this.wechatFace() : this.smileFace(); this.state.faceType === 'wxpay' ? this.wechatFace() : this.smileFace();
}; };
...@@ -192,6 +195,7 @@ class FacePage extends Component { ...@@ -192,6 +195,7 @@ class FacePage extends Component {
verifyCodeModal: false, verifyCodeModal: false,
current: 1, current: 1,
tipsModal: false, tipsModal: false,
sleep: true,
tip: '', tip: '',
}); });
} }
...@@ -368,6 +372,14 @@ class FacePage extends Component { ...@@ -368,6 +372,14 @@ class FacePage extends Component {
} }
}; };
wakeUp = () => {
this.setState({sleep: false});
clearTimeout(this.wakeUpTimeout);
this.wakeUpTimeout = setTimeout(() => {
this.setState({sleep: true});
}, 30000);
};
render() { render() {
const { const {
verifyCodeModal, verifyCodeModal,
...@@ -381,6 +393,7 @@ class FacePage extends Component { ...@@ -381,6 +393,7 @@ class FacePage extends Component {
current, current,
tip, tip,
tipsModal, tipsModal,
sleep,
} = this.state; } = this.state;
let {dispatch} = this.props; let {dispatch} = this.props;
if (this.state.faceType === 'alipay') { if (this.state.faceType === 'alipay') {
...@@ -389,7 +402,9 @@ class FacePage extends Component { ...@@ -389,7 +402,9 @@ class FacePage extends Component {
styles.footer = {...styles.footer, backgroundColor: '#1b7dc7'}; styles.footer = {...styles.footer, backgroundColor: '#1b7dc7'};
styles.onCall = {...styles.onCall, backgroundColor: '#1b7dc7'}; styles.onCall = {...styles.onCall, backgroundColor: '#1b7dc7'};
} }
return ( return sleep ? (
<Screensaver onPress={this.wakeUp} />
) : (
<View style={styles.content}> <View style={styles.content}>
<PhoneModal <PhoneModal
visible={phoneModal} visible={phoneModal}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment