mirror of
https://github.com/ecency/ecency-mobile.git
synced 2025-01-04 12:05:54 +03:00
created toast notf
This commit is contained in:
parent
8448f0691f
commit
f9fc08a06c
@ -1,4 +1,8 @@
|
||||
import { UPDATE_ACTIVE_BOTTOM_TAB, IS_COLLAPSE_POST_BUTTON } from '../constants/constants';
|
||||
import {
|
||||
IS_COLLAPSE_POST_BUTTON,
|
||||
TOAST_NOTIFICATION,
|
||||
UPDATE_ACTIVE_BOTTOM_TAB,
|
||||
} from '../constants/constants';
|
||||
|
||||
export const updateActiveBottomTab = payload => ({
|
||||
payload,
|
||||
@ -9,3 +13,8 @@ export const isCollapsePostButton = payload => ({
|
||||
payload,
|
||||
type: IS_COLLAPSE_POST_BUTTON,
|
||||
});
|
||||
|
||||
export const toastNotification = payload => ({
|
||||
payload,
|
||||
type: TOAST_NOTIFICATION,
|
||||
});
|
||||
|
@ -35,3 +35,4 @@ export const FETCH_GLOBAL_PROPS = 'FETCH_GLOBAL_PROPS';
|
||||
// UI
|
||||
export const IS_COLLAPSE_POST_BUTTON = 'IS_COLLAPSE_POST_BUTTON';
|
||||
export const UPDATE_ACTIVE_BOTTOM_TAB = 'UPDATE_ACTIVE_BOTTOM_TAB';
|
||||
export const TOAST_NOTIFICATION = 'TOAST_NOTIFICATION';
|
||||
|
@ -1,8 +1,13 @@
|
||||
import { UPDATE_ACTIVE_BOTTOM_TAB, IS_COLLAPSE_POST_BUTTON } from '../constants/constants';
|
||||
import {
|
||||
UPDATE_ACTIVE_BOTTOM_TAB,
|
||||
IS_COLLAPSE_POST_BUTTON,
|
||||
TOAST_NOTIFICATION,
|
||||
} from '../constants/constants';
|
||||
|
||||
const initialState = {
|
||||
activeBottomTab: 'HomeTabbar',
|
||||
isCollapsePostButton: false,
|
||||
toastNotifcaion: '',
|
||||
};
|
||||
|
||||
export default function (state = initialState, action) {
|
||||
@ -18,6 +23,12 @@ export default function (state = initialState, action) {
|
||||
...state,
|
||||
isCollapsePostButton: action.payload,
|
||||
};
|
||||
|
||||
case TOAST_NOTIFICATION:
|
||||
return {
|
||||
...state,
|
||||
toastNotification: action.payload,
|
||||
};
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
|
@ -315,7 +315,7 @@ class ApplicationContainer extends Component {
|
||||
};
|
||||
|
||||
render() {
|
||||
const { selectedLanguage, isConnected } = this.props;
|
||||
const { selectedLanguage, isConnected, toastNotification} = this.props;
|
||||
const { isRenderRequire, isReady } = this.state;
|
||||
|
||||
// For testing It comented out.
|
||||
@ -326,7 +326,7 @@ class ApplicationContainer extends Component {
|
||||
|
||||
if (isRenderRequire && isReady) {
|
||||
return (
|
||||
<ApplicationScreen isConnected={isConnected} locale={selectedLanguage} {...this.props} />
|
||||
<ApplicationScreen isConnected={isConnected} locale={selectedLanguage} toastNotification={toastNotification} {...this.props} />
|
||||
);
|
||||
}
|
||||
return <Launch />;
|
||||
@ -349,6 +349,9 @@ export default connect(
|
||||
currentAccount: state.account.currentAccount,
|
||||
otherAccounts: state.account.otherAccounts,
|
||||
pinCode: state.account.pin,
|
||||
|
||||
// UI
|
||||
toastNotification: state.ui.toastNotification
|
||||
}),
|
||||
(dispatch, props) => ({
|
||||
dispatch,
|
||||
|
@ -18,7 +18,9 @@ import lightTheme from '../../../themes/lightTheme';
|
||||
class ApplicationScreen extends Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.state = {};
|
||||
this.state = {
|
||||
isShowToastNotification: false,
|
||||
};
|
||||
}
|
||||
|
||||
componentWillMount() {
|
||||
@ -26,8 +28,20 @@ class ApplicationScreen extends Component {
|
||||
EStyleSheet.build(isDarkTheme ? darkTheme : lightTheme);
|
||||
}
|
||||
|
||||
componentWillReceiveProps(nextProps) {
|
||||
const { toastNotification } = this.props;
|
||||
if (nextProps.toastNotification !== toastNotification) {
|
||||
this.setState({ isShowToastNotification: true });
|
||||
} else {
|
||||
this.setState({ isShowToastNotification: false });
|
||||
}
|
||||
}
|
||||
|
||||
render() {
|
||||
const { isConnected, isDarkTheme, locale } = this.props;
|
||||
const {
|
||||
isConnected, isDarkTheme, locale, toastNotification,
|
||||
} = this.props;
|
||||
const { isShowToastNotification } = this.state;
|
||||
const barStyle = isDarkTheme ? 'light-content' : 'dark-content';
|
||||
const barColor = isDarkTheme ? '#1e2835' : '#fff';
|
||||
|
||||
@ -48,7 +62,7 @@ class ApplicationScreen extends Component {
|
||||
<IntlProvider locale={locale} messages={flattenMessages(messages[locale])}>
|
||||
<ErrorBoundary>
|
||||
<ReduxNavigation />
|
||||
<ToastNotificaiton text="ugur erdal" />
|
||||
{isShowToastNotification && <ToastNotificaiton text={toastNotification} />}
|
||||
</ErrorBoundary>
|
||||
</IntlProvider>
|
||||
</Fragment>
|
||||
|
@ -23,6 +23,7 @@ import {
|
||||
isDarkTheme,
|
||||
openPinCodeModal,
|
||||
} from '../../../redux/actions/applicationActions';
|
||||
import { toastNotification } from '../../../redux/actions/uiAction';
|
||||
import { setPushToken, getNodes, getCurrencyRate } from '../../../providers/esteem/esteem';
|
||||
|
||||
// Middleware
|
||||
@ -92,10 +93,10 @@ class SettingsContainer extends Component {
|
||||
try {
|
||||
serverResp = await client.database.getDynamicGlobalProperties();
|
||||
} catch (e) {
|
||||
alert(e);
|
||||
dispatch(toastNotification('Connection Failed!'));
|
||||
return;
|
||||
} finally {
|
||||
alert('done');
|
||||
dispatch(toastNotification('Succesfuly connected!'));
|
||||
}
|
||||
|
||||
const localTime = new Date(new Date().toISOString().split('.')[0]);
|
||||
@ -103,7 +104,7 @@ class SettingsContainer extends Component {
|
||||
const isAlive = localTime - serverTime < 15000;
|
||||
|
||||
if (!isAlive) {
|
||||
alert("server not alive");
|
||||
alert('server not alive');
|
||||
return;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user