Skip to content

Commit

Permalink
Merge pull request #4810 from parasharrajat/locale-pick
Browse files Browse the repository at this point in the history
fix Locale Picker and small picker styles
  • Loading branch information
Beamanator authored Aug 27, 2021
2 parents ae38f1b + 358ff1e commit 1f332a6
Show file tree
Hide file tree
Showing 7 changed files with 81 additions and 2 deletions.
10 changes: 10 additions & 0 deletions src/CONST.js

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

4 changes: 4 additions & 0 deletions src/components/Picker/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ const Picker = ({
fixAndroidTouchableBug
onOpen={onOpen}
onClose={onClose}
pickerProps={{
onFocus: onOpen,
onBlur: onClose,
}}
/>
);

Expand Down
19 changes: 18 additions & 1 deletion src/components/Picker/pickerStyles/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,22 @@
import CONST from '../../../CONST';
import getBrowser from '../../../libs/getBrowser';
import styles from '../../../styles/styles';

const pickerStyles = disabled => styles.expensiPicker(disabled);
const pickerStylesWeb = () => {
if (CONST.BROWSER.FIREFOX === getBrowser()) {
return {
textIndent: -2,
};
}
return {};
};

const pickerStyles = disabled => ({
...styles.expensiPicker(disabled),
inputWeb: {
...styles.expensiPicker(disabled).inputWeb,
...pickerStylesWeb(),
},
});

export default pickerStyles;
4 changes: 3 additions & 1 deletion src/libs/actions/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ function setCurrentURL(url) {
* @param {String} locale
*/
function setLocale(locale) {
API.PreferredLocale_Update({name: 'preferredLocale', value: locale});
if (currentUserAccountID) {
API.PreferredLocale_Update({name: 'preferredLocale', value: locale});
}
Onyx.merge(ONYXKEYS.NVP_PREFERRED_LOCALE, locale);
}

Expand Down
1 change: 1 addition & 0 deletions src/libs/getBrowser/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default () => '';
42 changes: 42 additions & 0 deletions src/libs/getBrowser/index.web.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import CONST from '../../CONST';

/**
* Fetch browser name from UA string
*
* @return {String} e.g. Chrome
*/
function getBrowser() {
const {userAgent} = window.navigator;
let match = userAgent.match(/(opera|chrome|safari|firefox|msie|trident(?=\/))/i) || [];
let temp;

if (/trident/i.test(match[1])) {
return 'IE';
}

if (match[1] && (match[1].toLowerCase() === 'chrome')) {
temp = userAgent.match(/\b(OPR|Edge)\/(\d+)/);

if (temp !== null) {
return temp.slice(1).replace('OPR', 'Opera');
}

temp = userAgent.match(/\b(Edg)\/(\d+)/);

if (temp !== null) {
return temp.slice(1).replace('Edg', 'Edge');
}
}

match = match[1] ? match[1] : navigator.appName;
return match;
}

/**
* Get the Browser name
* @returns {String}
*/
export default () => {
const browser = getBrowser();
return browser ? browser.toLowerCase() : CONST.BROWSER.OTHER;
};
3 changes: 3 additions & 0 deletions src/styles/styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,7 @@ const styles = {
borderRadius: variables.componentBorderRadius,
borderWidth: 1,
borderColor: themeColors.border,
borderStyle: 'solid',
color: themeColors.text,
height: variables.componentSizeSmall,
opacity: 1,
Expand All @@ -387,6 +388,7 @@ const styles = {
borderWidth: 1,
borderRadius: variables.componentBorderRadius,
borderColor: themeColors.border,
borderStyle: 'solid',
color: themeColors.text,
appearance: 'none',
height: variables.componentSizeSmall,
Expand All @@ -404,6 +406,7 @@ const styles = {
borderWidth: 1,
borderRadius: variables.componentBorderRadius,
borderColor: themeColors.border,
borderStyle: 'solid',
color: themeColors.text,
height: variables.componentSizeSmall,
opacity: 1,
Expand Down

0 comments on commit 1f332a6

Please sign in to comment.