Skip to content

Commit 9ae368d

Browse files
authored
Constants - add getFontScale (#3597)
* Added fontScale to constants * Changed fontScale to a getter function * Made fontScale regular proprety * Made fontScale to getFontScale * Moving usage of direct PixelRatio * Removed unsused import * Update src/commons/Constants.ts
1 parent 30fb519 commit 9ae368d

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

src/commons/Constants.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ import {
55
I18nManager,
66
AccessibilityInfo,
77
AccessibilityChangeEvent,
8-
StatusBar
8+
StatusBar,
9+
PixelRatio
910
} from 'react-native';
1011

1112
export enum orientations {
@@ -190,7 +191,10 @@ const constants = {
190191
},
191192
/* Keyboard */
192193
backspaceKey: 'Backspace',
193-
enterKey: 'Enter'
194+
enterKey: 'Enter',
195+
196+
/* Font scale */
197+
getFontScale: PixelRatio.getFontScale
194198
};
195199

196200
setStatusBarHeight();

src/components/colorPicker/ColorPickerPreview.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React, {useRef} from 'react';
2-
import {StyleSheet, TextInput, PixelRatio, I18nManager} from 'react-native';
2+
import {StyleSheet, TextInput, I18nManager} from 'react-native';
33

44
import {Colors, Typography} from '../../style';
55
import {ColorPickerDialogProps} from './ColorPickerDialog';
@@ -22,7 +22,7 @@ const ColorPickerPreview = (props: PreviewProps) => {
2222

2323
const hex = getHexString(color);
2424
const textColor = getTextColor(hex);
25-
const fontScale = PixelRatio.getFontScale();
25+
const fontScale = Constants.getFontScale();
2626
const value = Colors.isTransparent(text) ? '000000' : text;
2727

2828
return (

0 commit comments

Comments
 (0)