Skip to content

feat: allow font scaling prop for Text and TextInput #342

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
11 changes: 11 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,14 @@ android/keystores/debug.keystore

# generated by bob
lib/
# Yarn
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions

# Lock files
yarn.lock
ios/Podfile.lock
3 changes: 3 additions & 0 deletions src/components/Dropdown/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ const DropdownComponent = React.forwardRef<IDropdownRef, DropdownProps<any>>(
closeModalWhenSelectedItem = true,
excludeItems = [],
excludeSearchItems = [],
allowFontScaling = false,
} = props;

const ref = useRef<View>(null);
Expand Down Expand Up @@ -452,6 +453,7 @@ const DropdownComponent = React.forwardRef<IDropdownRef, DropdownProps<any>>(
<View style={styles.dropdown}>
{renderLeftIcon?.(visible)}
<Text
allowFontScaling={allowFontScaling}
style={[
styles.textItem,
isSelected !== null ? selectedTextStyle : placeholderStyle,
Expand Down Expand Up @@ -510,6 +512,7 @@ const DropdownComponent = React.forwardRef<IDropdownRef, DropdownProps<any>>(
) : (
<View style={styles.item}>
<Text
allowFontScaling={allowFontScaling}
style={StyleSheet.flatten([
styles.textItem,
itemTextStyle,
Expand Down
1 change: 1 addition & 0 deletions src/components/Dropdown/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,5 @@ export interface DropdownProps<T> {
searchQuery?: (keyword: string, labelValue: string) => boolean;
onChangeText?: (search: string) => void;
onConfirmSelectItem?: (item: T) => void;
allowFontScaling?: boolean;
}
6 changes: 6 additions & 0 deletions src/components/MultiSelect/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ const MultiSelectComponent = React.forwardRef<
mode = 'default',
excludeItems = [],
excludeSearchItems = [],
allowFontScaling = false,
} = props;

const ref = useRef<View>(null);
Expand Down Expand Up @@ -420,6 +421,7 @@ const MultiSelectComponent = React.forwardRef<
<View style={styles.dropdown}>
{renderLeftIcon?.(visible)}
<Text
allowFontScaling={allowFontScaling}
style={StyleSheet.flatten([
styles.textItem,
placeholderStyle,
Expand Down Expand Up @@ -484,6 +486,7 @@ const MultiSelectComponent = React.forwardRef<
) : (
<View style={styles.item}>
<Text
allowFontScaling={allowFontScaling}
style={StyleSheet.flatten([
styles.textItem,
itemTextStyle,
Expand Down Expand Up @@ -764,6 +767,7 @@ const MultiSelectComponent = React.forwardRef<
])}
>
<Text
allowFontScaling={allowFontScaling}
style={StyleSheet.flatten([
styles.selectedTextLeftItem,
selectedTextStyle,
Expand All @@ -773,6 +777,7 @@ const MultiSelectComponent = React.forwardRef<
{_get(e, labelField)}
</Text>
<Text
allowFontScaling={allowFontScaling}
style={StyleSheet.flatten([
styles.selectedTextItem,
selectedTextStyle,
Expand Down Expand Up @@ -816,6 +821,7 @@ const MultiSelectComponent = React.forwardRef<
_renderItemSelected(true)
) : (
<Text
allowFontScaling={allowFontScaling}
style={StyleSheet.flatten([
styles.textItem,
placeholderStyle,
Expand Down
1 change: 1 addition & 0 deletions src/components/MultiSelect/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,5 @@ export interface MultiSelectProps<T> {
searchQuery?: (keyword: string, labelValue: string) => boolean;
onChangeText?: (search: string) => void;
onConfirmSelectItem?: (item: any) => void;
allowFontScaling?: boolean;
}
6 changes: 5 additions & 1 deletion src/components/SelectCountry/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const SelectCountryComponent = React.forwardRef<
imageField,
selectedTextStyle,
imageStyle,
allowFontScaling = false,
} = props;
const ref: any = useRef(null);

Expand All @@ -35,7 +36,10 @@ const SelectCountryComponent = React.forwardRef<
return (
<View style={styles.item}>
<Image source={item[imageField]} style={[styles.image, imageStyle]} />
<Text style={[styles.selectedTextStyle, selectedTextStyle]}>
<Text
allowFontScaling={allowFontScaling}
style={[styles.selectedTextStyle, selectedTextStyle]}
>
{item[labelField]}
</Text>
</View>
Expand Down
2 changes: 2 additions & 0 deletions src/components/TextInput/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ const TextInputComponent: CTextInput = (props) => {
onChangeText = (_value: string) => {},
renderLeftIcon,
renderRightIcon,
allowFontScaling = false,
} = props;

const [text, setText] = useState<string>('');
Expand Down Expand Up @@ -77,6 +78,7 @@ const TextInputComponent: CTextInput = (props) => {
<View style={styles.textInput}>
{renderLeftIcon?.()}
<TextInput
allowFontScaling={allowFontScaling}
{...props}
style={StyleSheet.flatten([styles.input, inputStyle, font()])}
value={text}
Expand Down
Loading