Merge pull request #1329 from esteemapp/new/currency-endpoint

added new api enhanced settings screen
This commit is contained in:
Feruz M 2019-11-29 20:40:14 +02:00 committed by GitHub
commit d335c0f276
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 229 additions and 246 deletions

View File

@ -4,10 +4,10 @@ import imageApi from '../../config/imageApi';
import serverList from '../../config/serverListApi'; import serverList from '../../config/serverListApi';
import { jsonStringify } from '../../utils/jsonUtils'; import { jsonStringify } from '../../utils/jsonUtils';
import bugsnag from '../../config/bugsnag'; import bugsnag from '../../config/bugsnag';
//market-data/currency-rate/USD/estm
export const getCurrencyRate = currency => export const getCurrencyRate = currency =>
api api
.get(`/currencyRate/${currency.toUpperCase()}/steem`) .get(`/market-data/currency-rate/${currency.toUpperCase()}/steem`)
.then(resp => resp.data) .then(resp => resp.data)
.catch(err => { .catch(err => {
console.log('err :', err); console.log('err :', err);

View File

@ -1,5 +1,5 @@
/* eslint-disable react/jsx-wrap-multilines */ /* eslint-disable react/jsx-wrap-multilines */
import React, { PureComponent, Fragment } from 'react'; import React, { Fragment } from 'react';
import { ScrollView, View, RefreshControl } from 'react-native'; import { ScrollView, View, RefreshControl } from 'react-native';
import { injectIntl } from 'react-intl'; import { injectIntl } from 'react-intl';
@ -17,261 +17,244 @@ import { BasicHeader, SettingsItem, CollapsibleCard } from '../../../components'
// Styles // Styles
import styles from './settingsStyles'; import styles from './settingsStyles';
class SettingsScreen extends PureComponent { const SettingsScreen = ({
/* Props handleOnChange,
* ------------------------------------------------ intl,
* @prop { type } name - Description.... isDarkTheme,
*/ isPinCodeOpen,
constructor(props) { isLoggedIn,
super(props); isNotificationSettingsOpen,
this.state = {}; nsfw,
} selectedApi,
selectedCurrency,
selectedLanguage,
serverList,
isNotificationMenuOpen,
commentNotification,
followNotification,
mentionNotification,
reblogNotification,
transfersNotification,
voteNotification,
handleOnButtonPress,
isLoading,
}) => {
return (
<Fragment>
<BasicHeader
title={intl.formatMessage({
id: 'settings.settings',
})}
/>
// Component Life Cycles <ScrollView
style={styles.container}
// Component Functions refreshControl={
// TODO: REFACTOR ME ! <RefreshControl
render() { refreshing={isLoading}
const { progressBackgroundColor="#357CE6"
handleOnChange, tintColor={!isDarkTheme ? '#357ce6' : '#96c0ff'}
intl, titleColor="#fff"
isDarkTheme, colors={['#fff']}
isPinCodeOpen, />
isLoggedIn, }
isNotificationSettingsOpen, >
nsfw, <View style={styles.settingsCard}>
selectedApi, <SettingsItem
selectedCurrency, title={intl.formatMessage({
selectedLanguage, id: 'settings.general',
serverList, })}
isNotificationMenuOpen, titleStyle={styles.cardTitle}
commentNotification, />
followNotification, <SettingsItem
mentionNotification, title={intl.formatMessage({
reblogNotification, id: 'settings.currency',
transfersNotification, })}
voteNotification, type="dropdown"
handleOnButtonPress, actionType="currency"
isLoading, options={CURRENCY}
} = this.props; selectedOptionIndex={CURRENCY_VALUE.indexOf(selectedCurrency.currency)}
handleOnChange={handleOnChange}
return ( />
<Fragment> <SettingsItem
<BasicHeader title={intl.formatMessage({
title={intl.formatMessage({ id: 'settings.language',
id: 'settings.settings', })}
})} type="dropdown"
/> actionType="language"
options={LANGUAGE}
<ScrollView selectedOptionIndex={LANGUAGE_VALUE.indexOf(selectedLanguage)}
style={styles.container} handleOnChange={handleOnChange}
refreshControl={ />
<RefreshControl <SettingsItem
refreshing={isLoading} title={intl.formatMessage({
progressBackgroundColor="#357CE6" id: 'settings.server',
tintColor={!isDarkTheme ? '#357ce6' : '#96c0ff'} })}
titleColor="#fff" type="dropdown"
colors={['#fff']} actionType="api"
/> options={serverList.map(serverName => groomingServerName(serverName))}
} selectedOptionIndex={serverList.indexOf(selectedApi)}
> defaultText={
<View style={styles.settingsCard}> groomingServerName(selectedApi) ||
intl.formatMessage({
id: 'alert.checking',
})
}
handleOnChange={handleOnChange}
/>
<SettingsItem
title={intl.formatMessage({
id: 'settings.nsfw_content',
})}
type="dropdown"
actionType="nsfw"
options={NSFW.map(item =>
intl.formatMessage({
id: item,
}),
)}
selectedOptionIndex={parseInt(nsfw, 10)}
handleOnChange={handleOnChange}
/>
<SettingsItem
title={intl.formatMessage({
id: 'settings.dark_theme',
})}
type="toggle"
actionType="theme"
isOn={isDarkTheme}
handleOnChange={handleOnChange}
/>
{!!isLoggedIn && (
<SettingsItem <SettingsItem
title={intl.formatMessage({ title={intl.formatMessage({
id: 'settings.general', id: 'settings.pincode',
})}
titleStyle={styles.cardTitle}
/>
<SettingsItem
title={intl.formatMessage({
id: 'settings.currency',
})}
type="dropdown"
actionType="currency"
options={CURRENCY}
selectedOptionIndex={CURRENCY_VALUE.indexOf(selectedCurrency.currency)}
handleOnChange={handleOnChange}
/>
<SettingsItem
title={intl.formatMessage({
id: 'settings.language',
})}
type="dropdown"
actionType="language"
options={LANGUAGE}
selectedOptionIndex={LANGUAGE_VALUE.indexOf(selectedLanguage)}
handleOnChange={handleOnChange}
/>
<SettingsItem
title={intl.formatMessage({
id: 'settings.server',
})}
type="dropdown"
actionType="api"
options={serverList.map(serverName => groomingServerName(serverName))}
selectedOptionIndex={serverList.indexOf(selectedApi)}
defaultText={
groomingServerName(selectedApi) ||
intl.formatMessage({
id: 'alert.checking',
})
}
handleOnChange={handleOnChange}
/>
<SettingsItem
title={intl.formatMessage({
id: 'settings.nsfw_content',
})}
type="dropdown"
actionType="nsfw"
options={NSFW.map(item =>
intl.formatMessage({
id: item,
}),
)}
selectedOptionIndex={parseInt(nsfw, 10)}
handleOnChange={handleOnChange}
/>
<SettingsItem
title={intl.formatMessage({
id: 'settings.dark_theme',
})} })}
type="toggle" type="toggle"
actionType="theme" actionType="pincode"
isOn={isDarkTheme} isOn={isPinCodeOpen}
handleOnChange={handleOnChange} handleOnChange={handleOnChange}
/> />
{!!isLoggedIn && ( )}
{!!isLoggedIn && !!isPinCodeOpen && (
<Fragment>
<SettingsItem <SettingsItem
title={intl.formatMessage({ title={intl.formatMessage({
id: 'settings.pincode', id: 'settings.reset_pin',
})}
text={intl.formatMessage({
id: 'settings.reset',
})}
type="button"
actionType="reset_pin"
handleOnButtonPress={handleOnButtonPress}
/>
</Fragment>
// <SettingsItem
// title={intl.formatMessage({
// id: 'settings.default_footer',
// })}
// type="toggle"
// actionType="default_footer"
// isOn={isDefaultFooter}
// handleOnChange={handleOnChange}
// />
)}
</View>
{!!isLoggedIn && (
<View style={styles.settingsCard}>
<CollapsibleCard
titleComponent={
<SettingsItem
title={intl.formatMessage({
id: 'settings.push_notification',
})}
titleStyle={styles.cardTitle}
type="toggle"
actionType="notification"
isOn={isNotificationSettingsOpen}
handleOnChange={handleOnChange}
/>
}
noBorder
fitContent
locked
isExpanded={isNotificationSettingsOpen}
expanded={isNotificationMenuOpen}
>
<SettingsItem
title={intl.formatMessage({
id: 'settings.notification.follow',
})} })}
type="toggle" type="toggle"
actionType="pincode" actionType="notification.follow"
isOn={isPinCodeOpen} isOn={followNotification}
handleOnChange={handleOnChange} handleOnChange={handleOnChange}
/> />
)} <SettingsItem
title={intl.formatMessage({
{!!isLoggedIn && !!isPinCodeOpen && ( id: 'settings.notification.vote',
<Fragment> })}
<SettingsItem type="toggle"
title={intl.formatMessage({ actionType="notification.vote"
id: 'settings.reset_pin', isOn={voteNotification}
})} handleOnChange={handleOnChange}
text={intl.formatMessage({ />
id: 'settings.reset', <SettingsItem
})} title={intl.formatMessage({
type="button" id: 'settings.notification.comment',
actionType="reset_pin" })}
handleOnButtonPress={handleOnButtonPress} type="toggle"
/> actionType="notification.comment"
</Fragment> isOn={commentNotification}
// <SettingsItem handleOnChange={handleOnChange}
// title={intl.formatMessage({ />
// id: 'settings.default_footer', <SettingsItem
// })} title={intl.formatMessage({
// type="toggle" id: 'settings.notification.mention',
// actionType="default_footer" })}
// isOn={isDefaultFooter} type="toggle"
// handleOnChange={handleOnChange} actionType="notification.mention"
// /> isOn={mentionNotification}
)} handleOnChange={handleOnChange}
/>
<SettingsItem
title={intl.formatMessage({
id: 'settings.notification.reblog',
})}
type="toggle"
actionType="notification.reblog"
isOn={reblogNotification}
handleOnChange={handleOnChange}
/>
<SettingsItem
title={intl.formatMessage({
id: 'settings.notification.transfers',
})}
type="toggle"
actionType="notification.transfers"
isOn={transfersNotification}
handleOnChange={handleOnChange}
/>
</CollapsibleCard>
</View> </View>
{!!isLoggedIn && ( )}
<View style={styles.settingsCard}> <View style={[styles.settingsCard, styles.paddingBottom]}>
<CollapsibleCard <SettingsItem
titleComponent={ title={intl.formatMessage({
<SettingsItem id: 'settings.send_feedback',
title={intl.formatMessage({ })}
id: 'settings.push_notification', text={intl.formatMessage({
})} id: 'settings.send',
titleStyle={styles.cardTitle} })}
type="toggle" type="button"
actionType="notification" actionType="feedback"
isOn={isNotificationSettingsOpen} handleOnButtonPress={handleOnButtonPress}
handleOnChange={handleOnChange} />
/> </View>
} </ScrollView>
noBorder </Fragment>
fitContent );
locked };
isExpanded={isNotificationSettingsOpen}
expanded={isNotificationMenuOpen}
>
<SettingsItem
title={intl.formatMessage({
id: 'settings.notification.follow',
})}
type="toggle"
actionType="notification.follow"
isOn={followNotification}
handleOnChange={handleOnChange}
/>
<SettingsItem
title={intl.formatMessage({
id: 'settings.notification.vote',
})}
type="toggle"
actionType="notification.vote"
isOn={voteNotification}
handleOnChange={handleOnChange}
/>
<SettingsItem
title={intl.formatMessage({
id: 'settings.notification.comment',
})}
type="toggle"
actionType="notification.comment"
isOn={commentNotification}
handleOnChange={handleOnChange}
/>
<SettingsItem
title={intl.formatMessage({
id: 'settings.notification.mention',
})}
type="toggle"
actionType="notification.mention"
isOn={mentionNotification}
handleOnChange={handleOnChange}
/>
<SettingsItem
title={intl.formatMessage({
id: 'settings.notification.reblog',
})}
type="toggle"
actionType="notification.reblog"
isOn={reblogNotification}
handleOnChange={handleOnChange}
/>
<SettingsItem
title={intl.formatMessage({
id: 'settings.notification.transfers',
})}
type="toggle"
actionType="notification.transfers"
isOn={transfersNotification}
handleOnChange={handleOnChange}
/>
</CollapsibleCard>
</View>
)}
<View style={[styles.settingsCard, styles.paddingBottom]}>
<SettingsItem
title={intl.formatMessage({
id: 'settings.send_feedback',
})}
text={intl.formatMessage({
id: 'settings.send',
})}
type="button"
actionType="feedback"
handleOnButtonPress={handleOnButtonPress}
/>
</View>
</ScrollView>
</Fragment>
);
}
}
export default injectIntl(SettingsScreen); export default injectIntl(SettingsScreen);