Skip to content

Commit

Permalink
Merge pull request #96 from polkawallet-io/develop0311
Browse files Browse the repository at this point in the history
Gesture password logic modified
  • Loading branch information
0xthreebody authored Mar 12, 2019
2 parents 76fd704 + 6b6218f commit cb2ff88
Show file tree
Hide file tree
Showing 7 changed files with 128 additions and 177 deletions.
2 changes: 0 additions & 2 deletions App.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import {
View,
StyleSheet
} from 'react-native';
import Start from './src/code/Start'
import {StackNavigator} from 'react-navigation'
import Tabbed_Navigation from './src/code/Tabbed_Navigation.js'
import Create_Account from './src/code/Assets/secondary/Create_Account'
Expand Down Expand Up @@ -40,7 +39,6 @@ import {Provider} from 'mobx-react'
import AppState from './src/mobx/mobx'

const Polkawallet_App = StackNavigator({
// Start:{screen:Start,navigationOptions:{header:null}},
Tabbed_Navigation:{screen:Tabbed_Navigation,navigationOptions:{header:null}},
Create_Account:{screen:Create_Account,navigationOptions:{header:null}},
Backup_Account:{screen:Backup_Account,navigationOptions:{header:null}},
Expand Down
23 changes: 19 additions & 4 deletions src/code/Assets/Assets.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import {
AsyncStorage,
AppState
} from 'react-native';
import {NavigationActions, StackActions} from "react-navigation";

import Identicon from 'polkadot-identicon-react-native';
import moment from "moment/moment";
import SInfo from 'react-native-sensitive-info';
Expand Down Expand Up @@ -333,7 +335,13 @@ export default class Assets extends Component {
}
handleAppStateChange(appState){
if(appState=='background'&&this.props.rootStore.stateStore.GestureState==2){
this.props.navigation.navigate('Gesture')
let resetAction = StackActions.reset({
index: 0,
actions: [
NavigationActions.navigate({ routeName: 'Gesture'})
]
})
this.props.navigation.dispatch(resetAction)
}
}
componentWillMount(){
Expand All @@ -343,18 +351,25 @@ export default class Assets extends Component {
this.props.rootStore.stateStore.balanceIndex=(index)
}
})
// alert(this.props.rootStore.stateStore.balances[this.props.rootStore.stateStore.balanceIndex].address)
},5000)
AppState.addEventListener('change', this.handleAppStateChange)
AsyncStorage.getItem('Gesture').then(
(result)=>{
if(result==null){
this.props.rootStore.stateStore.GestureState=0
}else{
if(this.props.rootStore.stateStore.GestureState!=2){
this.props.rootStore.stateStore.Gesture=result
this.props.rootStore.stateStore.GestureState=2
this.props.navigation.navigate('Gesture')
let resetAction = StackActions.reset({
index: 0,
actions: [
NavigationActions.navigate({ routeName: 'Gesture'})
]
})
this.props.navigation.dispatch(resetAction)
}
}
this.props.rootStore.stateStore.Gesture=result
}
)

Expand Down
2 changes: 1 addition & 1 deletion src/code/Assets/secondary/right_menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ export default class New extends Component {
render() {
return (
<View style={[styles.container]}>
<TouchableOpacity style={{width:ScreenWidth*0.43,flex:1}}
<TouchableOpacity style={{width:ScreenWidth*0.43,flex:1,height:ScreenHeight}}
onPress={()=>{
this.props.t.setState({
is:false
Expand Down
229 changes: 76 additions & 153 deletions src/code/Assets/secondary/shiyan.js
Original file line number Diff line number Diff line change
@@ -1,163 +1,86 @@
import React, { Component } from 'react';
import {
StyleSheet,
Text,
View,
ScrollView,
TouchableOpacity,
TouchableWithoutFeedback,
Image,
ListView,
Modal ,
} from 'react-native';
var Dimensions = require('Dimensions');
const {width,height} = Dimensions.get('window');
export default class Select extends Component {
constructor(props){
super(props);
this.state=({
showModal:false,
course:"语文",
});
}
componentWillMount(){

}
selCourse(course){
this.setState({
showModal:false,
course:course,
});
Text,
TextInput,
Alert
} from "react-native";

import PasswordGesture from 'react-native-gesture-password'
let Password1 = '';

export default class GesturePassword extends Component {
constructor(props) {
super(props);
this.state = {
message: '请绘制解锁图案',
status: 'normal',
timeOut: 300,
}
}

render() {
return (
<View style={styles.container}>
<View style={styles.headStyle}>
<Text style={styles.headText} onPress={()=>{this.setState({showModal:true})}}>
{this.state.course}
</Text>
<TouchableOpacity style={{marginLeft:10}}
onPress={()=>{this.setState({showModal:true})}}
hitSlop={{top: 15, left: 15, bottom: 15, right: 15}}>
<Image style={styles.arrowStyle} source={require('../../../images/Assets/right_menu/Create_Account.png')}/>
</TouchableOpacity>
</View>
<Modal
visible={this.state.showModal}
transparent={true}
animationType='fade'
onRequestClose={() => {}}
style={{flex:1}}
ref="modal" >
<TouchableWithoutFeedback onPress={()=>{this.setState({showModal:false})}} >
<View style={{flex:1,alignItems:'center',backgroundColor:'rgba(0, 0, 0, 0.5)',}}

>
<TouchableWithoutFeedback onPress={()=>{}}>
<View style={{backgroundColor:'#fff',width:width,
justifyContent:'center',

}}
return (
<View>

>
<View style={styles.headStyle}>
<Text style={styles.headText} onPress={()=>{this.setState({showModal:false})}}>
{this.state.course}
</Text>
<TouchableOpacity style={{marginLeft:10}}
onPress={()=>{this.setState({showModal:false})}}
hitSlop={{top: 15, left: 15, bottom: 15, right: 15}}>
<Image style={styles.arrStyle} source={{uri:'arr_up'}}/>
</TouchableOpacity>
</View>
<View style={styles.courseWrap}>
<CourseItem course="语文" onPress={()=>{this.selCourse('语文')}}/>
<CourseItem course="数学" onPress={()=>{this.selCourse('数学')}}/>
<CourseItem course="英语" onPress={()=>{this.selCourse('英语')}}/>
</View>
<View style={[styles.courseWrap,{marginBottom:10}]}>
<CourseItem course="物理" onPress={()=>{this.selCourse('物理')}}/>
<CourseItem course="化学" onPress={()=>{this.selCourse('化学')}}/>
</View>
</View>
</TouchableWithoutFeedback>
<PasswordGesture
ref='pg'
status={this.state.status}
message={this.state.message}
onStart={() => this.onStart()}
onEnd={(password) => this.onEnd(password)}
innerCircle={true}
outerCircle={true}
interval={this.state.timeOut}
/>
</View>
</TouchableWithoutFeedback>
</Modal>
</View>
);
)
}

onEnd(password) {
const {timeOut}=this.state;
if (Password1 === '') {
// The first password
Password1 = password;
if (timeOut) {
this.time = setTimeout(() => {
this.setState({
status: 'normal',
message: '请再次绘制解锁图案',
});
}, timeOut)
}
} else {
// The second password
if (password === Password1) {
this.setState({
status: 'right',
message: '您的密码是' + password,
});

Password1 = '';
} else {
this.setState({
status: 'wrong',
message: '密码错误, 请再次输入.',
});
}
}
}
}
class CourseItem extends Component{
render(){
return(
<TouchableOpacity style={styles.boxView} onPress={this.props.onPress}>
<View style={{padding:10}}>
<Text style={{fontSize:18,fontWeight:'bold'}}>{this.props.course}</Text>
</View>
</TouchableOpacity>
)

onStart() {
if (Password1 === '') {
this.setState({
message: '请绘制解锁图案',
});
} else {
this.setState({
message: '请再次绘制解锁图案',
});
}
if (this.state.timeOut) {
clearTimeout(this.time);
}
}
}
var cols = 3;
var boxW = 70;
var vMargin = (width-cols*boxW)/(cols+1);
var hMargin = 25;
const styles = StyleSheet.create({
arrStyle:{
width:26,
height:26,
resizeMode:'contain',
},
boxView:{
justifyContent:'center',
alignItems:'center',
width:boxW,
height:boxW,
marginLeft:vMargin,
marginTop:hMargin,
borderWidth:StyleSheet.hairlineWidth,
borderColor:'#999',
borderRadius:5,
},
courseWrap:{
flexDirection:'row',
justifyContent:'flex-start',
borderWidth:0,
borderColor:'orange',
},
selCourseText:{
padding:8,
fontSize:18,
},
blackText:{
color:'black',
fontSize:16,
},
arrowStyle:{
width:20,
height:20,
},
textWrapView:{
paddingTop:10,
paddingBottom:10,
},
headText:{
fontSize:22,
},
headStyle:{
flexDirection:'row',
width:width,
justifyContent:"center",
alignItems:'center',
backgroundColor:'#F2F2F2',
paddingTop:15,
paddingBottom:15,
},
container: {
flex: 1,
alignItems: 'center',
backgroundColor: '#fff',
},

});
}
11 changes: 1 addition & 10 deletions src/code/Profile/Profile.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
SafeAreaView,
AsyncStorage
} from 'react-native';

let Platform = require('Platform');
let ScreenWidth = Dimensions.get("screen").width;
let ScreenHeight = Dimensions.get("screen").height;
Expand Down Expand Up @@ -52,16 +53,6 @@ export default class New extends Component {
this.props.navigation.navigate('About')
}
componentWillMount(){
AsyncStorage.getItem('Gesture').then(
(result)=>{
if(result==null){
this.props.rootStore.stateStore.GestureState=0
}else{
this.props.rootStore.stateStore.GestureState=2
}
this.props.rootStore.stateStore.Gesture=result
}
)
}
render() {
return (
Expand Down
14 changes: 10 additions & 4 deletions src/code/Profile/secondary/Settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
Switch,
Alert
} from 'react-native';

import {NavigationActions, StackActions} from "react-navigation";
let ScreenWidth = Dimensions.get("screen").width;
let ScreenHeight = Dimensions.get("screen").height;
const msg = [
Expand Down Expand Up @@ -47,14 +47,21 @@ export default class New extends Component {
Gesture(e){
this.setState({Gesture: e});
if(e){
this.props.navigation.navigate('Gesture')
let resetAction = StackActions.reset({
index: 0,
actions: [
NavigationActions.navigate({ routeName: 'Gesture'})
]
})
this.props.navigation.dispatch(resetAction)
}else{
Alert.alert(
'Alert',
'Delete gesture password ?',
[
{text: 'Cancel', onPress: () => {this.setState({Gesture:true})}, style: 'cancel'},
{text: 'Confirm', onPress: () => {
this.props.rootStore.stateStore.GestureState=0
AsyncStorage.removeItem('Gesture').then(
alert('The gesture password has been canceled.')
)
Expand All @@ -70,8 +77,7 @@ export default class New extends Component {
Facial_Recognition(e) {
this.setState({Facial_Recognition: e});
}
componentWillMount(){

componentWillUpdate(){
}
render() {
return (
Expand Down
Loading

0 comments on commit cb2ff88

Please sign in to comment.