mirror of
https://github.com/ecency/ecency-mobile.git
synced 2024-11-26 09:13:33 +03:00
added change if fail
This commit is contained in:
parent
f062cce769
commit
ceea43f79b
@ -9,105 +9,105 @@
|
||||
<key>isShown</key>
|
||||
<false/>
|
||||
<key>orderHint</key>
|
||||
<integer>7</integer>
|
||||
<integer>3</integer>
|
||||
</dict>
|
||||
<key>CodePush.xcscheme</key>
|
||||
<dict>
|
||||
<key>isShown</key>
|
||||
<false/>
|
||||
<key>orderHint</key>
|
||||
<integer>8</integer>
|
||||
<integer>4</integer>
|
||||
</dict>
|
||||
<key>DoubleConversion.xcscheme</key>
|
||||
<dict>
|
||||
<key>isShown</key>
|
||||
<false/>
|
||||
<key>orderHint</key>
|
||||
<integer>9</integer>
|
||||
<integer>5</integer>
|
||||
</dict>
|
||||
<key>FLAnimatedImage.xcscheme</key>
|
||||
<dict>
|
||||
<key>isShown</key>
|
||||
<false/>
|
||||
<key>orderHint</key>
|
||||
<integer>10</integer>
|
||||
<integer>6</integer>
|
||||
</dict>
|
||||
<key>Folly.xcscheme</key>
|
||||
<dict>
|
||||
<key>isShown</key>
|
||||
<false/>
|
||||
<key>orderHint</key>
|
||||
<integer>11</integer>
|
||||
<integer>7</integer>
|
||||
</dict>
|
||||
<key>JWT.xcscheme</key>
|
||||
<dict>
|
||||
<key>isShown</key>
|
||||
<false/>
|
||||
<key>orderHint</key>
|
||||
<integer>13</integer>
|
||||
<integer>9</integer>
|
||||
</dict>
|
||||
<key>Pods-eSteem-tvOS.xcscheme</key>
|
||||
<dict>
|
||||
<key>isShown</key>
|
||||
<false/>
|
||||
<key>orderHint</key>
|
||||
<integer>15</integer>
|
||||
<integer>11</integer>
|
||||
</dict>
|
||||
<key>Pods-eSteem-tvOSTests.xcscheme</key>
|
||||
<dict>
|
||||
<key>isShown</key>
|
||||
<false/>
|
||||
<key>orderHint</key>
|
||||
<integer>16</integer>
|
||||
<integer>12</integer>
|
||||
</dict>
|
||||
<key>Pods-eSteem.xcscheme</key>
|
||||
<dict>
|
||||
<key>isShown</key>
|
||||
<false/>
|
||||
<key>orderHint</key>
|
||||
<integer>14</integer>
|
||||
<integer>10</integer>
|
||||
</dict>
|
||||
<key>Pods-eSteemTests.xcscheme</key>
|
||||
<dict>
|
||||
<key>isShown</key>
|
||||
<false/>
|
||||
<key>orderHint</key>
|
||||
<integer>17</integer>
|
||||
<integer>13</integer>
|
||||
</dict>
|
||||
<key>QBImagePickerController-QBImagePicker.xcscheme</key>
|
||||
<dict>
|
||||
<key>isShown</key>
|
||||
<false/>
|
||||
<key>orderHint</key>
|
||||
<integer>19</integer>
|
||||
<integer>15</integer>
|
||||
</dict>
|
||||
<key>QBImagePickerController.xcscheme</key>
|
||||
<dict>
|
||||
<key>isShown</key>
|
||||
<false/>
|
||||
<key>orderHint</key>
|
||||
<integer>18</integer>
|
||||
<integer>14</integer>
|
||||
</dict>
|
||||
<key>RNImageCropPicker.xcscheme</key>
|
||||
<dict>
|
||||
<key>isShown</key>
|
||||
<false/>
|
||||
<key>orderHint</key>
|
||||
<integer>22</integer>
|
||||
<integer>19</integer>
|
||||
</dict>
|
||||
<key>RSKImageCropper.xcscheme</key>
|
||||
<dict>
|
||||
<key>isShown</key>
|
||||
<false/>
|
||||
<key>orderHint</key>
|
||||
<integer>23</integer>
|
||||
<integer>21</integer>
|
||||
</dict>
|
||||
<key>SDWebImage.xcscheme</key>
|
||||
<dict>
|
||||
<key>isShown</key>
|
||||
<false/>
|
||||
<key>orderHint</key>
|
||||
<integer>24</integer>
|
||||
<integer>23</integer>
|
||||
</dict>
|
||||
<key>SSZipArchive.xcscheme</key>
|
||||
<dict>
|
||||
@ -121,21 +121,21 @@
|
||||
<key>isShown</key>
|
||||
<false/>
|
||||
<key>orderHint</key>
|
||||
<integer>12</integer>
|
||||
<integer>8</integer>
|
||||
</dict>
|
||||
<key>react-native-fast-image.xcscheme</key>
|
||||
<dict>
|
||||
<key>isShown</key>
|
||||
<false/>
|
||||
<key>orderHint</key>
|
||||
<integer>20</integer>
|
||||
<integer>16</integer>
|
||||
</dict>
|
||||
<key>react-native-version-number.xcscheme</key>
|
||||
<dict>
|
||||
<key>isShown</key>
|
||||
<false/>
|
||||
<key>orderHint</key>
|
||||
<integer>21</integer>
|
||||
<integer>17</integer>
|
||||
</dict>
|
||||
</dict>
|
||||
<key>SuppressBuildableAutocreation</key>
|
||||
|
Binary file not shown.
@ -1,5 +1,7 @@
|
||||
import React from 'react';
|
||||
import { View, Text, TouchableHighlight } from 'react-native';
|
||||
import {
|
||||
View, Text, TouchableHighlight, ActivityIndicator,
|
||||
} from 'react-native';
|
||||
|
||||
// External components
|
||||
import ModalDropdown from 'react-native-modal-dropdown';
|
||||
@ -49,6 +51,7 @@ const DropdownButtonView = ({
|
||||
options,
|
||||
style,
|
||||
noHighlight,
|
||||
isLoading,
|
||||
}) => (
|
||||
<View style={[styles.container, dropdownButtonStyle]}>
|
||||
<ModalDropdown
|
||||
@ -65,7 +68,7 @@ const DropdownButtonView = ({
|
||||
renderRow={(rowData, rowID, highlighted) => renderDropdownRow(rowData, rowID, highlighted, rowTextStyle, noHighlight)
|
||||
}
|
||||
>
|
||||
{isHasChildIcon && (
|
||||
{isHasChildIcon && !isLoading ? (
|
||||
<View style={[styles.iconWrapper, childIconWrapperStyle && childIconWrapperStyle]}>
|
||||
<Icon
|
||||
style={[styles.dropdownIcon, iconStyle]}
|
||||
@ -73,6 +76,8 @@ const DropdownButtonView = ({
|
||||
name={!iconName ? 'arrow-drop-down' : iconName}
|
||||
/>
|
||||
</View>
|
||||
) : isHasChildIcon && (
|
||||
<ActivityIndicator />
|
||||
)}
|
||||
</ModalDropdown>
|
||||
{!children && !isHasChildIcon && (
|
||||
|
@ -40,7 +40,7 @@ class SettingsItemView extends PureComponent {
|
||||
case 'dropdown':
|
||||
return (
|
||||
<DropdownButton
|
||||
key={actionType}
|
||||
key={options[selectedOptionIndex]}
|
||||
defaultText={defaultText || options[selectedOptionIndex]}
|
||||
dropdownButtonStyle={styles.dropdownButtonStyle}
|
||||
selectedOptionIndex={selectedOptionIndex}
|
||||
|
@ -1,3 +1,3 @@
|
||||
import ToastNotificaiton from './view/toastNotificaitonView';
|
||||
import ToastNotification from './view/toastNotificaitonView';
|
||||
|
||||
export { ToastNotificaiton };
|
||||
export { ToastNotification };
|
||||
|
@ -1,9 +1,5 @@
|
||||
import React, { Component } from 'react';
|
||||
import { Animated, Text } from 'react-native';
|
||||
|
||||
// Constants
|
||||
|
||||
// Components
|
||||
import { Animated, TouchableOpacity, Text } from 'react-native';
|
||||
|
||||
// Styles
|
||||
import styles from './toastNotificationStyles';
|
||||
@ -22,13 +18,11 @@ class ToastNotification extends Component {
|
||||
}
|
||||
|
||||
// Component Life Cycles
|
||||
|
||||
// Component Functions
|
||||
|
||||
componentWillMount() {
|
||||
this._showToast();
|
||||
}
|
||||
|
||||
// Component Functions
|
||||
_showToast() {
|
||||
const { duration } = this.props;
|
||||
const animatedValue = new Animated.Value(0);
|
||||
@ -46,10 +40,10 @@ class ToastNotification extends Component {
|
||||
|
||||
_hideToast() {
|
||||
const { animatedValue } = this.state;
|
||||
const { handleOnHide } = this.props;
|
||||
const { onHide } = this.props;
|
||||
|
||||
Animated.timing(animatedValue, { toValue: 0.0, duration: 350 }).start(() => {
|
||||
if (handleOnHide) handleOnHide();
|
||||
if (onHide) onHide();
|
||||
});
|
||||
|
||||
if (this.closeTimer) {
|
||||
@ -58,23 +52,31 @@ class ToastNotification extends Component {
|
||||
}
|
||||
|
||||
render() {
|
||||
const { text } = this.props;
|
||||
const {
|
||||
text, textStyle, style, onPress, isTop,
|
||||
} = this.props;
|
||||
const { animatedValue } = this.state;
|
||||
const outputRange = isTop ? [-50, 0] : [50, 0];
|
||||
const y = animatedValue.interpolate({
|
||||
inputRange: [0, 1],
|
||||
outputRange: [50, 0],
|
||||
outputRange,
|
||||
});
|
||||
const position = isTop ? { top: 100 } : { bottom: 100 };
|
||||
|
||||
return (
|
||||
<Animated.View
|
||||
style={{
|
||||
...styles.container,
|
||||
opacity: animatedValue,
|
||||
transform: [{ translateY: y }],
|
||||
}}
|
||||
>
|
||||
<Text style={styles.text}>{text}</Text>
|
||||
</Animated.View>
|
||||
<TouchableOpacity disabled={!onPress} onPress={() => onPress && onPress()}>
|
||||
<Animated.View
|
||||
style={{
|
||||
...styles.container,
|
||||
...style,
|
||||
...position,
|
||||
opacity: animatedValue,
|
||||
transform: [{ translateY: y }],
|
||||
}}
|
||||
>
|
||||
<Text style={[styles.text, textStyle]}>{text}</Text>
|
||||
</Animated.View>
|
||||
</TouchableOpacity>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,6 @@ import EStyleSheet from 'react-native-extended-stylesheet';
|
||||
export default EStyleSheet.create({
|
||||
container: {
|
||||
position: 'absolute',
|
||||
bottom: 100,
|
||||
zIndex: 9999,
|
||||
justifyContent: 'center',
|
||||
alignItems: 'center',
|
||||
|
@ -9,7 +9,7 @@ import messages from '../../../config/locales';
|
||||
// Components
|
||||
import { NoInternetConnection } from '../../../components/basicUIElements';
|
||||
import { ErrorBoundary } from '../../../components/errorBoundary';
|
||||
import { ToastNotificaiton } from '../../../components/toastNotification';
|
||||
import { ToastNotification } from '../../../components/toastNotification';
|
||||
import { toastNotification as toastNotificationAction } from '../../../redux/actions/uiAction';
|
||||
|
||||
// Themes (Styles)
|
||||
@ -68,10 +68,10 @@ class ApplicationScreen extends Component {
|
||||
<ErrorBoundary>
|
||||
<ReduxNavigation />
|
||||
{isShowToastNotification && (
|
||||
<ToastNotificaiton
|
||||
<ToastNotification
|
||||
text={toastNotification}
|
||||
duration={2000}
|
||||
handleOnHide={this._handleOnHideToastNotification}
|
||||
onHide={this._handleOnHideToastNotification}
|
||||
/>
|
||||
)}
|
||||
</ErrorBoundary>
|
||||
|
@ -84,34 +84,43 @@ class SettingsContainer extends Component {
|
||||
};
|
||||
|
||||
_changeApi = async (action) => {
|
||||
const { dispatch } = this.props;
|
||||
const { dispatch, selectedApi } = this.props;
|
||||
const { serverList } = this.state;
|
||||
const server = serverList[action];
|
||||
let serverResp;
|
||||
let isError = false;
|
||||
const client = new Client(server, { timeout: 3000 });
|
||||
|
||||
dispatch(setApi(server));
|
||||
|
||||
try {
|
||||
serverResp = await client.database.getDynamicGlobalProperties();
|
||||
} catch (e) {
|
||||
isError = true;
|
||||
dispatch(toastNotification('Connection Failed!'));
|
||||
return;
|
||||
} finally {
|
||||
if (!isError) dispatch(toastNotification('Succesfuly connected!'));
|
||||
}
|
||||
|
||||
const localTime = new Date(new Date().toISOString().split('.')[0]);
|
||||
const serverTime = new Date(serverResp.time);
|
||||
const isAlive = localTime - serverTime < 15000;
|
||||
if (!isError) {
|
||||
const localTime = new Date(new Date().toISOString().split('.')[0]);
|
||||
const serverTime = new Date(serverResp.time);
|
||||
const isAlive = localTime - serverTime < 15000;
|
||||
|
||||
if (!isAlive) {
|
||||
dispatch(toastNotification('Server not available'));
|
||||
return;
|
||||
if (!isAlive) {
|
||||
dispatch(toastNotification('Server not available'));
|
||||
isError = true;
|
||||
|
||||
this.setState({ apiCheck: false });
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
dispatch(setApi(server));
|
||||
setServer(server);
|
||||
if (isError) {
|
||||
dispatch(setApi(selectedApi));
|
||||
} else {
|
||||
setServer(server);
|
||||
}
|
||||
};
|
||||
|
||||
_currencyChange = (action) => {
|
||||
|
@ -33,14 +33,14 @@ class SettingsScreen extends PureComponent {
|
||||
render() {
|
||||
const {
|
||||
handleOnChange,
|
||||
selectedLanguage,
|
||||
intl,
|
||||
isDarkTheme,
|
||||
isLoggedIn,
|
||||
isNotificationSettingsOpen,
|
||||
selectedApi,
|
||||
selectedCurrency,
|
||||
isNotificationSettingsOpen,
|
||||
isDarkTheme,
|
||||
selectedLanguage,
|
||||
serverList,
|
||||
intl,
|
||||
isLoggedIn,
|
||||
} = this.props;
|
||||
|
||||
return (
|
||||
|
Loading…
Reference in New Issue
Block a user