Merge branch 'master' of https://github.com/esteemapp/esteem-mobile into enhancment/performance
@ -88,6 +88,8 @@
|
||||
<array>
|
||||
<string>armv7</string>
|
||||
</array>
|
||||
<key>UIRequiresFullScreen</key>
|
||||
<true/>
|
||||
<key>UISupportedInterfaceOrientations</key>
|
||||
<array>
|
||||
<string>UIInterfaceOrientationPortrait</string>
|
||||
|
BIN
src/assets/avatar_default@2x.png
Normal file
After Width: | Height: | Size: 438 B |
BIN
src/assets/avatar_default@3x.png
Normal file
After Width: | Height: | Size: 561 B |
BIN
src/assets/dark_cover_image@2x.png
Normal file
After Width: | Height: | Size: 4.1 KiB |
BIN
src/assets/dark_cover_image@3x.png
Normal file
After Width: | Height: | Size: 7.0 KiB |
BIN
src/assets/default_cover_image.png
Executable file → Normal file
Before Width: | Height: | Size: 32 KiB After Width: | Height: | Size: 9.1 KiB |
BIN
src/assets/default_cover_image@2x.png
Normal file
After Width: | Height: | Size: 19 KiB |
BIN
src/assets/default_cover_image@3x.png
Normal file
After Width: | Height: | Size: 31 KiB |
BIN
src/assets/esteem.png
Normal file
After Width: | Height: | Size: 1.1 KiB |
BIN
src/assets/esteem@2x.png
Executable file → Normal file
Before Width: | Height: | Size: 4.2 KiB After Width: | Height: | Size: 2.6 KiB |
BIN
src/assets/esteem@3x.png
Normal file
After Width: | Height: | Size: 3.7 KiB |
BIN
src/assets/esteem_logo_transparent.png
Executable file → Normal file
Before Width: | Height: | Size: 3.1 KiB After Width: | Height: | Size: 1.4 KiB |
BIN
src/assets/esteem_logo_transparent@2x.png
Normal file
After Width: | Height: | Size: 2.5 KiB |
BIN
src/assets/esteem_logo_transparent@3x.png
Normal file
After Width: | Height: | Size: 2.9 KiB |
BIN
src/assets/keep_calm.png
Executable file → Normal file
Before Width: | Height: | Size: 23 KiB After Width: | Height: | Size: 5.9 KiB |
BIN
src/assets/keep_calm@2x.png
Normal file
After Width: | Height: | Size: 14 KiB |
BIN
src/assets/keep_calm@3x.png
Normal file
After Width: | Height: | Size: 24 KiB |
BIN
src/assets/love_mascot.png
Executable file → Normal file
Before Width: | Height: | Size: 286 KiB After Width: | Height: | Size: 48 KiB |
BIN
src/assets/love_mascot@2x.png
Normal file
After Width: | Height: | Size: 170 KiB |
BIN
src/assets/love_mascot@3x.png
Normal file
After Width: | Height: | Size: 309 KiB |
BIN
src/assets/no_image.png
Executable file → Normal file
Before Width: | Height: | Size: 2.8 KiB After Width: | Height: | Size: 926 B |
BIN
src/assets/no_image@2x.png
Normal file
After Width: | Height: | Size: 1.8 KiB |
BIN
src/assets/no_image@3x.png
Normal file
After Width: | Height: | Size: 2.7 KiB |
BIN
src/assets/no_post.png
Executable file → Normal file
Before Width: | Height: | Size: 61 KiB After Width: | Height: | Size: 13 KiB |
BIN
src/assets/no_post@2x.png
Normal file
After Width: | Height: | Size: 39 KiB |
BIN
src/assets/no_post@3x.png
Normal file
After Width: | Height: | Size: 66 KiB |
BIN
src/assets/side_menu_background.png
Executable file → Normal file
Before Width: | Height: | Size: 7.8 KiB After Width: | Height: | Size: 1.7 KiB |
BIN
src/assets/side_menu_background@2x.png
Normal file
After Width: | Height: | Size: 5.2 KiB |
BIN
src/assets/side_menu_background@3x.png
Normal file
After Width: | Height: | Size: 9.1 KiB |
BIN
src/assets/steem_connect@2x.png
Normal file
After Width: | Height: | Size: 1.1 KiB |
BIN
src/assets/steem_connect@3x.png
Normal file
After Width: | Height: | Size: 921 B |
@ -61,6 +61,15 @@ class SettingsItemView extends PureComponent {
|
||||
onToggle={e => handleOnChange(e, type, actionType)}
|
||||
/>
|
||||
);
|
||||
case 'button':
|
||||
return (
|
||||
<TextButton
|
||||
onPress={() => handleOnChange(null, type, actionType)}
|
||||
textStyle={styles.textStyle}
|
||||
style={styles.textButton}
|
||||
text={text}
|
||||
/>
|
||||
);
|
||||
|
||||
default:
|
||||
return (
|
||||
|
@ -8,6 +8,7 @@ import {
|
||||
setPinCode,
|
||||
getPinCode,
|
||||
updateCurrentUsername,
|
||||
getUserData,
|
||||
} from '../../realm/realm';
|
||||
import { encryptKey, decryptKey } from '../../utils/crypto';
|
||||
import steemConnect from './steemConnectAPI';
|
||||
@ -201,6 +202,50 @@ export const setUserDataWithPinCode = data => new Promise((resolve, reject) => {
|
||||
});
|
||||
});
|
||||
|
||||
export const updatePinCode = async (data) => {
|
||||
let updatedUserData;
|
||||
|
||||
const users = await getUserData();
|
||||
if (users.length > 0) {
|
||||
users.forEach(async (userData) => {
|
||||
const password = decryptKey(userData.masterKey, data.oldPinCode);
|
||||
const privateKeys = getPrivateKeys(userData.username, password);
|
||||
if (userData.authType === 'masterKey') {
|
||||
updatedUserData = {
|
||||
username: userData.username,
|
||||
authType: 'masterKey',
|
||||
masterKey: encryptKey(password, data.pinCode),
|
||||
postingKey: encryptKey(privateKeys.posting.toString(), data.pinCode),
|
||||
activeKey: encryptKey(privateKeys.active.toString(), data.pinCode),
|
||||
memoKey: encryptKey(privateKeys.memo.toString(), data.pinCode),
|
||||
};
|
||||
} else if (userData.authType === 'steemConnect') {
|
||||
updatedUserData = {
|
||||
username: userData.username,
|
||||
authType: 'steemConnect',
|
||||
accessToken: encryptKey(data.accessToken, data.pinCode),
|
||||
masterKey: '',
|
||||
postingKey: encryptKey(privateKeys.posting.toString(), data.pinCode),
|
||||
activeKey: encryptKey(privateKeys.active.toString(), data.pinCode),
|
||||
memoKey: encryptKey(privateKeys.memo.toString(), data.pinCode),
|
||||
};
|
||||
}
|
||||
|
||||
const response = await updateUserData(updatedUserData);
|
||||
const authData = {
|
||||
isLoggedIn: true,
|
||||
currentUsername: userData.username,
|
||||
};
|
||||
|
||||
await setAuthStatus(authData);
|
||||
const encriptedPinCode = encryptKey(data.pinCode, 'pin-code');
|
||||
await setPinCode(encriptedPinCode);
|
||||
|
||||
return response;
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
export const getDigitPinCode = async () => decryptKey(await getPinCode(), 'pin-code');
|
||||
|
||||
export const verifyPinCode = async (data) => {
|
||||
|
@ -102,9 +102,9 @@ class EditorContainer extends Component {
|
||||
|
||||
_handleOpenImagePicker = () => {
|
||||
ImagePicker.openPicker({
|
||||
width: 300,
|
||||
height: 400,
|
||||
cropping: true,
|
||||
//width: 300,
|
||||
//height: 400,
|
||||
//cropping: true,
|
||||
// writeTempFile: true,
|
||||
// includeBase64: true,
|
||||
// multiple: true,
|
||||
@ -119,9 +119,9 @@ class EditorContainer extends Component {
|
||||
|
||||
_handleOpenCamera = () => {
|
||||
ImagePicker.openCamera({
|
||||
width: 300,
|
||||
height: 400,
|
||||
cropping: true,
|
||||
//width: 300,
|
||||
//height: 400,
|
||||
//cropping: true,
|
||||
// includeBase64: true,
|
||||
})
|
||||
.then((image) => {
|
||||
|
@ -3,7 +3,11 @@ import { Alert } from 'react-native';
|
||||
import { connect } from 'react-redux';
|
||||
import { injectIntl } from 'react-intl';
|
||||
|
||||
import { setUserDataWithPinCode, verifyPinCode } from '../../../providers/steem/auth';
|
||||
import {
|
||||
setUserDataWithPinCode,
|
||||
verifyPinCode,
|
||||
updatePinCode,
|
||||
} from '../../../providers/steem/auth';
|
||||
|
||||
// Actions & Services
|
||||
import { closePinCodeModal } from '../../../redux/actions/applicationActions';
|
||||
@ -18,6 +22,8 @@ class PinCodeContainer extends Component {
|
||||
isExistUser: null,
|
||||
informationText: '',
|
||||
pinCode: null,
|
||||
isOldPinVerified: false,
|
||||
oldPinCode: null,
|
||||
};
|
||||
}
|
||||
|
||||
@ -25,9 +31,9 @@ class PinCodeContainer extends Component {
|
||||
// TODO: these text should move to view!
|
||||
componentDidMount() {
|
||||
this._getDataFromStorage().then(() => {
|
||||
const { intl } = this.props;
|
||||
const { intl, isReset } = this.props;
|
||||
const { isExistUser } = this.state;
|
||||
if (isExistUser) {
|
||||
if (isExistUser || !isReset) {
|
||||
this.setState({
|
||||
informationText: intl.formatMessage({
|
||||
id: 'pincode.enter_text',
|
||||
@ -63,9 +69,53 @@ class PinCodeContainer extends Component {
|
||||
navigateTo,
|
||||
navigation,
|
||||
intl,
|
||||
isReset,
|
||||
} = this.props;
|
||||
const { isExistUser, pinCode } = this.state;
|
||||
if (isExistUser) {
|
||||
const {
|
||||
isExistUser, pinCode, isOldPinVerified, oldPinCode,
|
||||
} = this.state;
|
||||
|
||||
if (isReset) {
|
||||
const pinData = {
|
||||
pinCode: pin,
|
||||
password: currentAccount ? currentAccount.password : '',
|
||||
username: currentAccount ? currentAccount.name : '',
|
||||
accessToken,
|
||||
oldPinCode,
|
||||
};
|
||||
|
||||
if (isOldPinVerified) {
|
||||
updatePinCode(pinData).then((response) => {
|
||||
const _currentAccount = currentAccount;
|
||||
_currentAccount.local = response;
|
||||
|
||||
dispatch(updateCurrentAccount({ ..._currentAccount }));
|
||||
|
||||
dispatch(closePinCodeModal());
|
||||
if (navigateTo) {
|
||||
navigation.navigate(navigateTo);
|
||||
}
|
||||
resolve();
|
||||
});
|
||||
} else {
|
||||
verifyPinCode(pinData)
|
||||
.then(() => {
|
||||
this.setState({ isOldPinVerified: true });
|
||||
this.setState({
|
||||
informationText: intl.formatMessage({
|
||||
id: 'pincode.set_new',
|
||||
}),
|
||||
pinCode: null,
|
||||
oldPinCode: pin,
|
||||
});
|
||||
resolve();
|
||||
})
|
||||
.catch((err) => {
|
||||
Alert.alert('Warning', err.message);
|
||||
reject(err);
|
||||
});
|
||||
}
|
||||
} else if (isExistUser) {
|
||||
// If the user is exist, we are just checking to pin and navigating to home screen
|
||||
const pinData = {
|
||||
pinCode: pin,
|
||||
@ -104,8 +154,8 @@ class PinCodeContainer extends Component {
|
||||
} else if (pinCode === pin) {
|
||||
const pinData = {
|
||||
pinCode: pin,
|
||||
password: currentAccount.password,
|
||||
username: currentAccount.name,
|
||||
password: currentAccount ? currentAccount.password : '',
|
||||
username: currentAccount ? currentAccount.name : '',
|
||||
accessToken,
|
||||
};
|
||||
setUserDataWithPinCode(pinData).then((response) => {
|
||||
|
@ -20,16 +20,15 @@ import {
|
||||
setCurrency,
|
||||
setApi,
|
||||
isDarkTheme,
|
||||
openPinCodeModal,
|
||||
} from '../../../redux/actions/applicationActions';
|
||||
import { setPushToken } from '../../../providers/esteem/esteem';
|
||||
import { getNodes } from '../../../providers/esteem/esteem';
|
||||
import { setPushToken, getNodes } from '../../../providers/esteem/esteem';
|
||||
|
||||
// Middleware
|
||||
|
||||
// Constants
|
||||
import { VALUE as CURRENCY_VALUE } from '../../../constants/options/currency';
|
||||
import { VALUE as LANGUAGE_VALUE } from '../../../constants/options/language';
|
||||
import API_VALUE from '../../../constants/options/api';
|
||||
|
||||
// Utilities
|
||||
|
||||
@ -86,7 +85,7 @@ class SettingsContainer extends Component {
|
||||
};
|
||||
|
||||
_handleToggleChanged = (action, actionType) => {
|
||||
const { dispatch } = this.props;
|
||||
const { dispatch, setPinCodeState } = this.props;
|
||||
|
||||
switch (actionType) {
|
||||
case 'notification':
|
||||
@ -98,7 +97,23 @@ class SettingsContainer extends Component {
|
||||
dispatch(isDarkTheme(action));
|
||||
setTheme(action);
|
||||
break;
|
||||
case 'pincode':
|
||||
// test
|
||||
dispatch(openPinCodeModal());
|
||||
setPinCodeState({ isReset: true });
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
_handleButtonPress = (action, actionType) => {
|
||||
const { dispatch, setPinCodeState } = this.props;
|
||||
switch (actionType) {
|
||||
case 'pincode':
|
||||
dispatch(openPinCodeModal());
|
||||
setPinCodeState({ isReset: true });
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -115,6 +130,7 @@ class SettingsContainer extends Component {
|
||||
break;
|
||||
|
||||
case 'button':
|
||||
this._handleButtonPress(action, actionType);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -104,6 +104,9 @@ class SettingsScreen extends PureComponent {
|
||||
text={intl.formatMessage({
|
||||
id: 'settings.reset',
|
||||
})}
|
||||
type="button"
|
||||
actionType="pincode"
|
||||
handleOnChange={handleOnChange}
|
||||
/>
|
||||
</ScrollView>
|
||||
</View>
|
||||
|