Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
2997f68
[TS migration] Migrate 'Picker' and 'LocalePicker' components
VickyStash Oct 31, 2023
25f87b6
Update picker style type
VickyStash Oct 31, 2023
80816b6
Update TODO messages
VickyStash Nov 2, 2023
4a1773e
Update react-native-picker-select lib version to resolve ts issues
VickyStash Nov 2, 2023
192998e
Merge branch 'main' into ts-migration/picker-component
VickyStash Nov 6, 2023
a8b8188
Update react-native-picker-select lib to fix TS issues
VickyStash Nov 6, 2023
2cd2771
Merge branch 'main' into ts-migration/picker-component
VickyStash Nov 8, 2023
e376918
Update forwardRef logic
VickyStash Nov 9, 2023
977058f
Merge branch 'main' into ts-migration/picker-component
VickyStash Nov 16, 2023
dbc9fca
Merge branch 'main' into ts-migration/picker-component
VickyStash Nov 17, 2023
f17b26e
Updates after merging main
VickyStash Nov 17, 2023
548c98a
Trigger snyk checks
VickyStash Nov 17, 2023
2222de7
Merge branch 'main' into ts-migration/picker-component
VickyStash Nov 20, 2023
a73ba69
Replace withLocalize HOC with hook usage
VickyStash Nov 20, 2023
da35fc0
Update picker props type to be generic
VickyStash Nov 21, 2023
aac29da
Create separate function for default picker icon
VickyStash Nov 21, 2023
a53ec87
Create separate Locale type and add useScroll hook
VickyStash Nov 21, 2023
8914066
Rename custom hook
VickyStash Nov 21, 2023
e9b526c
Minor code improvements
VickyStash Nov 22, 2023
b6edfdc
Update key usage
VickyStash Nov 22, 2023
3ce21d3
Merge branch 'main' into ts-migration/picker-component
VickyStash Nov 22, 2023
c1df876
Minor code improvements
VickyStash Nov 24, 2023
9e3c8f7
Merge branch 'main' into ts-migration/picker-component
VickyStash Dec 1, 2023
275a908
Updates after merging main
VickyStash Dec 1, 2023
eb53666
Remove old BasePicker js file
VickyStash Dec 1, 2023
01ea064
Merge branch 'main' into ts-migration/picker-component
VickyStash Dec 5, 2023
237bb94
Update hooks call order to follow main updates
VickyStash Dec 5, 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
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@
"react-native-pdf": "^6.7.3",
"react-native-performance": "^5.1.0",
"react-native-permissions": "^3.9.3",
"react-native-picker-select": "git+https://github.com/Expensify/react-native-picker-select.git#eae05855286dc699954415cc1d629bfd8e8e47e2",
"react-native-picker-select": "git+https://github.com/Expensify/react-native-picker-select.git#0d15d4618f58e99c1261921111e68ee85bb3c2a8",

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.

Picker needs to be fully tested as this change includes Expensify/react-native-picker-select#14 which has lots of upstream changes

"react-native-plaid-link-sdk": "10.8.0",
"react-native-qrcode-svg": "^6.2.0",
"react-native-quick-sqlite": "^8.0.0-beta.2",
Expand Down
2 changes: 1 addition & 1 deletion src/ONYXKEYS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ type OnyxValues = {
[ONYXKEYS.IS_PLAID_DISABLED]: boolean;
[ONYXKEYS.PLAID_LINK_TOKEN]: string;
[ONYXKEYS.ONFIDO_TOKEN]: string;
[ONYXKEYS.NVP_PREFERRED_LOCALE]: ValueOf<typeof CONST.LOCALES>;
[ONYXKEYS.NVP_PREFERRED_LOCALE]: OnyxTypes.Locale;
[ONYXKEYS.USER_WALLET]: OnyxTypes.UserWallet;
[ONYXKEYS.WALLET_ONFIDO]: OnyxTypes.WalletOnfido;
[ONYXKEYS.WALLET_ADDITIONAL_DETAILS]: OnyxTypes.WalletAdditionalDetails;
Expand Down
68 changes: 0 additions & 68 deletions src/components/LocalePicker.js

This file was deleted.

59 changes: 59 additions & 0 deletions src/components/LocalePicker.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import React from 'react';
import {OnyxEntry, withOnyx} from 'react-native-onyx';
import useLocalize from '@hooks/useLocalize';
import useTheme from '@styles/themes/useTheme';
import useThemeStyles from '@styles/useThemeStyles';
import * as App from '@userActions/App';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import type {Locale} from '@src/types/onyx';
import Picker from './Picker';
import type {PickerSize} from './Picker/types';

type LocalePickerOnyxProps = {
/** Indicates which locale the user currently has selected */
preferredLocale: OnyxEntry<Locale>;
};

type LocalePickerProps = LocalePickerOnyxProps & {
/** Indicates size of a picker component and whether to render the label or not */
size?: PickerSize;
};

function LocalePicker({preferredLocale = CONST.LOCALES.DEFAULT, size = 'normal'}: LocalePickerProps) {
const theme = useTheme();
const styles = useThemeStyles();
const {translate} = useLocalize();
const localesToLanguages = CONST.LANGUAGES.map((language) => ({
value: language,
label: translate(`languagePage.languages.${language}.label`),
Comment thread
VickyStash marked this conversation as resolved.
keyForList: language,
isSelected: preferredLocale === language,
}));

return (
<Picker
label={size === 'normal' ? translate('languagePage.language') : null}
onInputChange={(locale) => {
if (locale === preferredLocale) {
return;
}

App.setLocale(locale);
}}
items={localesToLanguages}
size={size}
value={preferredLocale}
containerStyles={size === 'small' ? styles.pickerContainerSmall : {}}
backgroundColor={theme.signInPage}
/>
);
}

LocalePicker.displayName = 'LocalePicker';

export default withOnyx<LocalePickerProps, LocalePickerOnyxProps>({
preferredLocale: {
key: ONYXKEYS.NVP_PREFERRED_LOCALE,
},
})(LocalePicker);
Loading