mirror of
https://github.com/ecency/ecency-mobile.git
synced 2025-01-01 10:18:20 +03:00
Added is exist user control to pin code container
This commit is contained in:
parent
6c1e102262
commit
d2a46f6add
@ -173,3 +173,8 @@ export const setUserDataWithPinCode = pinCode =>
|
||||
new Promise((resolve, reject) => {
|
||||
resolve();
|
||||
});
|
||||
|
||||
export const verifyPinCode = pinCode =>
|
||||
new Promise((resolve, reject) => {
|
||||
resolve();
|
||||
});
|
||||
|
@ -1,7 +1,10 @@
|
||||
import React from "react";
|
||||
import { AsyncStorage } from "react-native";
|
||||
|
||||
import { setUserDataWithPinCode } from "../../providers/steem/auth";
|
||||
import {
|
||||
setUserDataWithPinCode,
|
||||
verifyPinCode,
|
||||
} from "../../providers/steem/auth";
|
||||
|
||||
import { default as INITIAL } from "../../constants/initial";
|
||||
|
||||
@ -10,35 +13,82 @@ import PinCodeScreen from "./pinCodeScreen";
|
||||
class PinCodeContainer extends React.Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.state = {
|
||||
isExistUser: null,
|
||||
informationText: "",
|
||||
pinCode: null,
|
||||
};
|
||||
}
|
||||
|
||||
_getDataFromStorage = () => {
|
||||
AsyncStorage.getItem(INITIAL.IS_EXIST_USER, (err, result) => {
|
||||
console.log("err", err);
|
||||
console.log("result", result);
|
||||
this.setState({
|
||||
isFirstLaunch: JSON.parse(result),
|
||||
// TODO: if check for decide to set to pin or verify to pin page
|
||||
componentDidMount() {
|
||||
this._getDataFromStorage().then(() => {
|
||||
const { isExistUser } = this.state;
|
||||
if (isExistUser) {
|
||||
this.setState({
|
||||
informationText: "verify screen",
|
||||
});
|
||||
} else {
|
||||
this.setState({
|
||||
informationText: "setup screen",
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
_getDataFromStorage = () =>
|
||||
new Promise(resolve => {
|
||||
AsyncStorage.getItem(INITIAL.IS_EXIST_USER, (err, result) => {
|
||||
this.setState(
|
||||
{
|
||||
isExistUser: JSON.parse(result),
|
||||
},
|
||||
resolve
|
||||
);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
// TODO: if check for decide to set to pin or verify to pin page
|
||||
_setPinCode = pin => {
|
||||
const { isExistUser, pinCode } = this.state;
|
||||
|
||||
// componentDidMount() {
|
||||
// this._getDataFromStorage();
|
||||
// }
|
||||
|
||||
_setUserData = pinCode => {
|
||||
setUserDataWithPinCode(pinCode).then(() => {});
|
||||
};
|
||||
|
||||
_setPinCode = pinCode => {
|
||||
// TODO: If check for confirm
|
||||
this._setUserData(pinCode);
|
||||
if (isExistUser) {
|
||||
// If the user is exist, we are just checking to pin and navigating to home screen
|
||||
verifyPinCode(pinCode).then(() => {});
|
||||
// TODO navigate to home
|
||||
} else {
|
||||
// If the user is logging in for the first time, the user should set to pin
|
||||
if (!pinCode) {
|
||||
this.setState({
|
||||
informationText: "write again",
|
||||
pinCode: pin,
|
||||
});
|
||||
} else {
|
||||
if (pinCode === pin) {
|
||||
setUserDataWithPinCode(pinCode).then(() => {});
|
||||
// TODO navigate to home
|
||||
} else {
|
||||
this.setState({
|
||||
informationText: "wrongggg!!!",
|
||||
});
|
||||
setTimeout(() => {
|
||||
this.setState({
|
||||
informationText: "setup screen",
|
||||
pinCode: null,
|
||||
});
|
||||
}, 1000);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
render() {
|
||||
return <PinCodeScreen setPinCode={this._setPinCode} />;
|
||||
const { informationText } = this.state;
|
||||
return (
|
||||
<PinCodeScreen
|
||||
informationText={informationText}
|
||||
setPinCode={this._setPinCode}
|
||||
/>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -55,6 +55,10 @@ class PinCodeScreen extends React.Component {
|
||||
Oh, I forgot it…
|
||||
</Text>
|
||||
</TouchableOpacity>
|
||||
|
||||
<Text style={styles.forgotButtonText}>
|
||||
{this.props.informationText}
|
||||
</Text>
|
||||
</Content>
|
||||
</Container>
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user