Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
54f3c9a
Use MenuItemWithTopDescription for priority mode.
cristipaval Jan 25, 2023
09a2e59
Remove priority mode description
cristipaval Jan 25, 2023
6fe6acd
Adjust spacing to the new design.
cristipaval Jan 25, 2023
66eab56
Add Language as menu item
cristipaval Jan 25, 2023
67bc438
Create Priority Modes page.
cristipaval Jan 25, 2023
69dfd47
Add priority modes page header
cristipaval Jan 25, 2023
735f4bd
Add options list in Priority Modes page
cristipaval Jan 25, 2023
25a72d4
Add explainer text in Priority Modes page
cristipaval Jan 25, 2023
276b712
Add priority mode selection
cristipaval Jan 25, 2023
7260c2e
Change priority mode selection
cristipaval Jan 25, 2023
d5b5742
Move PreferencesPage to Preferences package
cristipaval Jan 26, 2023
15f905f
Create languages page
cristipaval Jan 26, 2023
3868463
Organize strings about language
cristipaval Jan 26, 2023
8e59473
Add languages in LanguagesPage and integrate language change
cristipaval Jan 26, 2023
57d0c5d
Merge remote-tracking branch 'origin/main' into cristi_preferences-ne…
cristipaval Jan 26, 2023
4958719
Properly align priority modes and languages in the option list.
cristipaval Jan 26, 2023
fc2e470
Fix spacing in Preferences page.
cristipaval Jan 26, 2023
4384921
Add description for priority mode options
cristipaval Jan 26, 2023
9193e05
Fix console errors
cristipaval Jan 26, 2023
7ebd6ef
Fix lint in i18n files
cristipaval Jan 27, 2023
01b74f8
Fix lint errors
cristipaval Jan 27, 2023
ace0711
Another try with lint
cristipaval Jan 27, 2023
470f896
Lint
cristipaval Jan 27, 2023
0a9cb4b
Pass this one Linter or Imma quit
cristipaval Jan 27, 2023
c198c53
Is this the one?
cristipaval Jan 27, 2023
2b426f3
Fix js doc.
cristipaval Jan 27, 2023
928f474
Rename PriorityMode page
cristipaval Jan 31, 2023
76bfe87
Rename LanguagePage
cristipaval Jan 31, 2023
7131798
Remove unnecessary empty lines
cristipaval Jan 31, 2023
67d365e
Update src/components/OptionRow.js
cristipaval Jan 31, 2023
0e4022e
Update src/pages/settings/Preferences/PreferencesPage.js
cristipaval Jan 31, 2023
1fc1031
remove unnecessary prefferedLocale prop in LanguagePage
cristipaval Jan 31, 2023
14b5468
Address feedback on PriorityMode page
cristipaval Jan 31, 2023
8bf1fb2
More improvements after code review
cristipaval Jan 31, 2023
122d55e
Fix lint errors
cristipaval Jan 31, 2023
de3fa9f
c'mon linter!
cristipaval Jan 31, 2023
6d1c670
Singular names for routes to language and priority mode
cristipaval Feb 3, 2023
77f321d
Address more feedback.
cristipaval Feb 3, 2023
256cf6b
Merge remote-tracking branch 'origin/main' into cristi_preferences-ne…
cristipaval Feb 3, 2023
4c940c6
Suggested improvements.
cristipaval Feb 3, 2023
b7bebb2
Oh yea, Linter again..
cristipaval Feb 3, 2023
33f2f49
Fix prop naming.
cristipaval Feb 4, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/ROUTES.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ export default {
SETTINGS_TIMEZONE_SELECT: 'settings/profile/timezone/select',
SETTINGS_PRONOUNS: 'settings/profile/pronouns',
SETTINGS_PREFERENCES: 'settings/preferences',
SETTINGS_PRIORITY_MODE: 'settings/preferences/priority-mode',
SETTINGS_LANGUAGE: 'settings/preferences/language',
SETTINGS_WORKSPACES: 'settings/workspaces',
SETTINGS_SECURITY: 'settings/security',
SETTINGS_CLOSE: 'settings/security/closeAccount',
Expand Down
6 changes: 3 additions & 3 deletions src/components/LocalePicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ const defaultProps = {
const localesToLanguages = {
default: {
value: 'en',
label: Localize.translate('en', 'preferencesPage.languages.english'),
label: Localize.translate('en', 'languagePage.languages.en.label'),
},
es: {
value: 'es',
label: Localize.translate('es', 'preferencesPage.languages.spanish'),
label: Localize.translate('es', 'languagePage.languages.es.label'),
},
};

Expand All @@ -49,7 +49,7 @@ const LocalePicker = (props) => {

return (
<Picker
label={props.size === 'normal' ? props.translate('preferencesPage.language') : null}
label={props.size === 'normal' ? props.translate('languagePage.language') : null}
onInputChange={(locale) => {
if (locale === props.preferredLocale) {
return;
Expand Down
6 changes: 5 additions & 1 deletion src/components/OptionRow.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ const propTypes = {
/** Whether to show a line separating options in list */
shouldHaveOptionSeparator: PropTypes.bool,

/** Whether to remove the lateral padding and align the content with the margins */
shouldDisableRowInnerPadding: PropTypes.bool,

style: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.object), PropTypes.object]),

...withLocalizePropTypes,
Expand All @@ -74,6 +77,7 @@ const defaultProps = {
optionIsFocused: false,
style: null,
shouldHaveOptionSeparator: false,
shouldDisableRowInnerPadding: false,
};

class OptionRow extends Component {
Expand Down Expand Up @@ -172,7 +176,7 @@ class OptionRow extends Component {
styles.alignItemsCenter,
styles.justifyContentBetween,
styles.sidebarLink,
styles.sidebarLinkInner,
this.props.shouldDisableRowInnerPadding ? null : styles.sidebarLinkInner,
this.props.optionIsFocused ? styles.sidebarLinkActive : null,
hovered && !this.props.optionIsFocused ? this.props.hoverStyle : null,
this.props.isDisabled && styles.cursorDisabled,
Expand Down
1 change: 1 addition & 0 deletions src/components/OptionsList/BaseOptionsList.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ class BaseOptionsList extends Component {
boldStyle={this.props.boldStyle}
isDisabled={isDisabled}
shouldHaveOptionSeparator={index > 0 && this.props.shouldHaveOptionSeparator}
shouldDisableRowInnerPadding={this.props.shouldDisableRowInnerPadding}
/>
);
}
Expand Down
4 changes: 4 additions & 0 deletions src/components/OptionsList/optionsListPropTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ const propTypes = {

/** Whether to show a line separating options in list */
shouldHaveOptionSeparator: PropTypes.bool,

/** Whether to disable the inner padding in rows */
shouldDisableRowInnerPadding: PropTypes.bool,
};

const defaultProps = {
Expand All @@ -90,6 +93,7 @@ const defaultProps = {
isDisabled: false,
onLayout: undefined,
shouldHaveOptionSeparator: false,
shouldDisableRowInnerPadding: false,
};

export {propTypes, defaultProps};
27 changes: 21 additions & 6 deletions src/languages/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -493,16 +493,31 @@ export default {
defaultPaymentMethod: 'Default',
},
preferencesPage: {
mostRecent: 'Most recent',
mostRecentModeDescription: 'This will display all chats by default, sorted by most recent, with pinned items at the top.',
focus: '#focus',
focusModeDescription: '#focus – This will only display unread and pinned chats, all sorted alphabetically.',
receiveRelevantFeatureUpdatesAndExpensifyNews: 'Receive relevant feature updates and Expensify news',
},
priorityModePage: {
priorityMode: 'Priority mode',
explainerText: 'Choose whether to show all chats by default sorted with most recent with pinned items at the top, or #focus on unread pinned items, sorted alphabetically.',
priorityModes: {
default: {
label: 'Most recent',
description: 'Show all chats sorted by most recent',
},
gsd: {
label: '#focus',
description: 'Only show unread sorted alphabetically',
},
},
},
languagePage: {
language: 'Language',
languages: {
english: 'English',
spanish: 'Spanish',
en: {
label: 'English',
},
es: {
label: 'Spanish',
},
},
},
signInPage: {
Expand Down
27 changes: 21 additions & 6 deletions src/languages/es.js
Original file line number Diff line number Diff line change
Expand Up @@ -493,16 +493,31 @@ export default {
defaultPaymentMethod: 'Predeterminado',
},
preferencesPage: {
mostRecent: 'Más recientes',
mostRecentModeDescription: 'Esta opción muestra por defecto todos los chats, ordenados a partir del más reciente, con los chats destacados arriba de todo.',
focus: '#concentración',
focusModeDescription: '#concentración – Muestra sólo los chats no leídos y destacados ordenados alfabéticamente.',
receiveRelevantFeatureUpdatesAndExpensifyNews: 'Recibir noticias sobre Expensify y actualizaciones del producto',
},
priorityModePage: {
priorityMode: 'Modo prioridad',
explainerText: 'Elija si desea mostrar por defecto todos los chats ordenados desde el más reciente y con los elementos anclados en la parte superior, o elija el modo #concentración, con los elementos no leídos anclados en la parte superior y ordenados alfabéticamente.',
priorityModes: {
default: {
label: 'Más recientes',
description: 'Mostrar todos los chats ordenados desde el más reciente',
},
gsd: {
label: '#concentración',
description: 'Mostrar sólo los no leídos ordenados alfabéticamente',
},
},
},
languagePage: {
language: 'Idioma',
languages: {
english: 'Inglés',
spanish: 'Español',
en: {
label: 'Inglés',
},
es: {
label: 'Español',
},
},
},
signInPage: {
Expand Down
16 changes: 15 additions & 1 deletion src/libs/Navigation/AppNavigator/ModalStackNavigators.js
Original file line number Diff line number Diff line change
Expand Up @@ -254,11 +254,25 @@ const SettingsModalStackNavigator = createModalStackNavigator([
},
{
getComponent: () => {
const SettingsPreferencesPage = require('../../../pages/settings/PreferencesPage').default;
const SettingsPreferencesPage = require('../../../pages/settings/Preferences/PreferencesPage').default;
return SettingsPreferencesPage;
},
name: 'Settings_Preferences',
},
{
getComponent: () => {
const SettingsPreferencesPriorityModePage = require('../../../pages/settings/Preferences/PriorityModePage').default;
return SettingsPreferencesPriorityModePage;
},
name: 'Settings_Preferences_PriorityMode',
},
{
getComponent: () => {
const SettingsPreferencesLanguagePage = require('../../../pages/settings/Preferences/LanguagePage').default;
return SettingsPreferencesLanguagePage;
},
name: 'Settings_Preferences_Language',
},
{
getComponent: () => {
const SettingsPasswordPage = require('../../../pages/settings/PasswordPage').default;
Expand Down
8 changes: 8 additions & 0 deletions src/libs/Navigation/linkingConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,14 @@ export default {
path: ROUTES.SETTINGS_PREFERENCES,
exact: true,
},
Settings_Preferences_PriorityMode: {
path: ROUTES.SETTINGS_PRIORITY_MODE,
exact: true,
},
Settings_Preferences_Language: {
path: ROUTES.SETTINGS_LANGUAGE,
exact: true,
},
Settings_Close: {
path: ROUTES.SETTINGS_CLOSE,
exact: true,
Expand Down
1 change: 1 addition & 0 deletions src/libs/actions/User.js
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,7 @@ function updateChatPriorityMode(mode) {
API.write('UpdateChatPriorityMode', {
value: mode,
}, {optimisticData});
Navigation.navigate(ROUTES.SETTINGS_PREFERENCES);
}

/**
Expand Down
77 changes: 77 additions & 0 deletions src/pages/settings/Preferences/LanguagePage.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
import _ from 'underscore';
import React from 'react';
import PropTypes from 'prop-types';
import HeaderWithCloseButton from '../../../components/HeaderWithCloseButton';
import ScreenWrapper from '../../../components/ScreenWrapper';
import withLocalize, {withLocalizePropTypes} from '../../../components/withLocalize';
import Navigation from '../../../libs/Navigation/Navigation';
import ROUTES from '../../../ROUTES';
import OptionsList from '../../../components/OptionsList';
import styles from '../../../styles/styles';
import themeColors from '../../../styles/themes/default';
import * as Expensicons from '../../../components/Icon/Expensicons';
import * as App from '../../../libs/actions/App';

const greenCheckmark = {src: Expensicons.Checkmark, color: themeColors.success};

const propTypes = {
...withLocalizePropTypes,

/** The preferred language of the App */
preferredLocale: PropTypes.string.isRequired,
};

const LanguagePage = (props) => {
const localesToLanguages = _.map(props.translate('languagePage.languages'),
(language, key) => (
{
value: key,
text: language.label,
keyForList: key,

// Include the green checkmark icon to indicate the currently selected value
customIcon: props.preferredLocale === key ? greenCheckmark : undefined,

// This property will make the currently selected value have bold text
boldStyle: props.preferredLocale === key,
}
));

return (
<ScreenWrapper includeSafeAreaPaddingBottom={false}>
<HeaderWithCloseButton

@rushatgabhane rushatgabhane Feb 3, 2023 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cristipaval we should put all this inside ScrollView, right?
To make it scrollable when new items are adding to this page.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we? Isn't OptionList handling the scroll if needed?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cristipaval i was thinking we'll need ScrollView when items other than OptionList are added. (Images, Text etc).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We definitely might need ScrollView eventually, but we can add that later when / if we add those other components

title={props.translate('languagePage.language')}
shouldShowBackButton
onBackButtonPress={() => Navigation.navigate(ROUTES.SETTINGS_PREFERENCES)}
onCloseButtonPress={() => Navigation.dismissModal(true)}
/>
<OptionsList
sections={[{data: localesToLanguages}]}
onSelectRow={
(language) => {
if (language.value !== props.preferredLocale) {
App.setLocale(language.value);
}
Navigation.navigate(ROUTES.SETTINGS_PREFERENCES);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cristipaval I know you want to get this out soon, we really should move this to an action, maybe called setLocaleAndNavigate (since we have functions with similar names). Then that function can call App.setLocale and then navigate. I think we really try to avoid inlining functions like this, too

}
}
hideSectionHeaders
optionHoveredStyle={
{
...styles.hoveredComponentBG,
...styles.mhn5,
...styles.ph5,
}
}
shouldHaveOptionSeparator
shouldDisableRowInnerPadding
contentContainerStyles={[styles.ph5]}
/>
</ScreenWrapper>
);
};

LanguagePage.displayName = 'LanguagePage';
LanguagePage.propTypes = propTypes;

export default withLocalize(LanguagePage);
Loading