From 674dfd66a8a6a566232f56db094f823319051993 Mon Sep 17 00:00:00 2001 From: Deepak Bhagat Date: Fri, 9 Jan 2026 22:18:46 +0530 Subject: [PATCH 01/15] feat: apply font size scaling feature across all components - Apply scaleFontSize to all Text components throughout the application - Update Directory pages (DirectoryItem, DirectoryOptions) - Update Reactions components (Reactions, ReactionsList, AllTab) - Update ListPicker components across multiple views - Update RoomInfoView components (ItemLabel, RoomInfoTag, Direct, Livechat) - Update various view components (JoinCode, LoadMore, AuthLoadingView, etc.) - Fix TypeScript errors by using object spread for style props - Ensure all user-facing text respects font size preference setting --- .../index.tsx | 14 ++-- .../ActionSheet/BottomSheetContent.tsx | 4 +- app/containers/ActionSheet/Item.tsx | 6 +- app/containers/ActionSheet/styles.ts | 5 -- app/containers/AppVersion.tsx | 7 +- app/containers/BackgroundContainer/index.tsx | 5 +- app/containers/Button/index.tsx | 12 ++- app/containers/CallHeader.tsx | 8 +- app/containers/ChangePasswordRequired.tsx | 10 +-- app/containers/Chip/index.tsx | 5 +- app/containers/CollapsibleText/index.tsx | 12 +-- app/containers/DirectoryItem/index.tsx | 7 +- .../HeaderButton/HeaderButtonItem.tsx | 16 ++-- .../Header/components/HeaderTitle/index.tsx | 10 ++- .../Header/components/HeaderTitle/styles.ts | 4 - .../InAppNotification/NotifierComponent.tsx | 10 +-- app/containers/List/ListHeader.tsx | 5 +- app/containers/List/ListInfo.tsx | 6 +- app/containers/List/ListItem.tsx | 8 +- app/containers/MessageActions/Header.tsx | 5 +- .../components/ComposerInput.tsx | 8 +- .../components/EmojiSearchbar.tsx | 7 +- .../components/Quotes/Quote.tsx | 14 ++-- .../components/RecordAudio/Duration.tsx | 4 +- .../components/RecordAudio/RecordAudio.tsx | 5 +- .../components/SendThreadToChannel.tsx | 5 +- app/containers/MessageSeparator.tsx | 11 +-- app/containers/OrSeparator.tsx | 5 +- app/containers/ReactionsList/AllTab.tsx | 8 +- app/containers/ReactionsList/UsersList.tsx | 6 +- app/containers/ReactionsList/index.tsx | 6 +- app/containers/RoomItem/LastMessage.tsx | 5 +- app/containers/RoomItem/RoomItem.stories.tsx | 3 +- app/containers/RoomItem/RoomItem.tsx | 20 ++--- app/containers/RoomItem/Tag.tsx | 4 +- app/containers/RoomItem/Title.tsx | 19 +++-- app/containers/RoomItem/UpdatedAt.tsx | 5 +- app/containers/RoomItem/Wrapper.tsx | 7 +- app/containers/RoomItem/styles.ts | 36 ++++++--- app/containers/SearchHeader.tsx | 5 +- app/containers/TextInput/FormTextInput.tsx | 19 ++--- app/containers/ThreadDetails.tsx | 7 +- app/containers/Toast.tsx | 5 +- app/containers/UnreadBadge/index.tsx | 6 +- app/containers/UserGeneratedContentRules.tsx | 10 +-- app/containers/UserItem.tsx | 5 +- .../markdown/components/Heading.tsx | 15 +++- .../markdown/components/InlineCode.tsx | 6 +- .../markdown/components/Paragraph.tsx | 4 +- app/containers/markdown/components/Plain.tsx | 4 +- .../markdown/components/Preview.tsx | 25 +++++-- .../markdown/components/code/CodeLine.tsx | 4 +- .../markdown/components/inline/Link.tsx | 4 +- .../components/mentions/AtMention.tsx | 9 ++- .../markdown/components/mentions/Hashtag.tsx | 7 +- app/containers/markdown/styles.ts | 1 + .../Attachments/CollapsibleQuote/index.tsx | 10 +-- .../message/Components/Attachments/Reply.tsx | 13 ++-- .../message/Components/Attachments/Video.tsx | 7 +- app/containers/message/Message.stories.tsx | 3 +- app/containers/message/Reactions.tsx | 6 +- app/containers/message/Time.tsx | 4 +- app/containers/message/Urls.tsx | 8 +- app/containers/message/User.tsx | 12 +-- app/i18n/locales/en.json | 6 ++ app/lib/constants/keys.ts | 1 + .../useResponsiveLayout.tsx | 54 ++++++++++++-- .../components/ListPicker.tsx | 6 +- app/views/AuthLoadingView.tsx | 4 +- .../DepartmentFilter/DepartmentItemFilter.tsx | 4 +- .../RoomSettings/SwitchItem.tsx | 6 +- app/views/DirectoryView/Options.tsx | 6 +- .../DiscussionsView/DiscussionDetails.tsx | 6 +- app/views/ForgotPasswordView.tsx | 6 +- app/views/LoginView/UserForm.tsx | 10 ++- .../MediaAutoDownloadView/ListPicker.tsx | 6 +- .../ServersHistoryItem.stories.tsx | 3 +- .../NotificationPreferencesView/index.tsx | 4 +- app/views/PickerView.tsx | 4 +- .../DeleteAccountActionSheetContent/index.tsx | 12 ++- app/views/RegisterView/index.tsx | 6 +- app/views/RoomInfoView/Direct.tsx | 4 +- app/views/RoomInfoView/Livechat.tsx | 4 +- .../RoomInfoView/components/ItemLabel.tsx | 4 +- .../RoomInfoView/components/RoomInfoTag.tsx | 4 +- .../components/RoomInfoViewTitle.tsx | 10 ++- app/views/RoomView/JoinCode.tsx | 4 +- app/views/RoomView/LoadMore/index.tsx | 4 +- app/views/RoomsListView/components/Header.tsx | 6 +- app/views/SelectedUsersView/Header.tsx | 4 +- app/views/SendEmailConfirmationView.tsx | 2 +- app/views/SetUsernameView.tsx | 8 +- .../ListPicker.tsx | 4 +- .../UserPreferencesView/FontSizePicker.tsx | 73 +++++++++++++++++++ app/views/UserPreferencesView/ListPicker.tsx | 4 +- app/views/UserPreferencesView/index.tsx | 10 +++ 96 files changed, 545 insertions(+), 280 deletions(-) create mode 100644 app/views/UserPreferencesView/FontSizePicker.tsx diff --git a/app/containers/ActionSheet/ActionSheetContentWithInputAndSubmit/index.tsx b/app/containers/ActionSheet/ActionSheetContentWithInputAndSubmit/index.tsx index d4315d2b375..111e831fae8 100644 --- a/app/containers/ActionSheet/ActionSheetContentWithInputAndSubmit/index.tsx +++ b/app/containers/ActionSheet/ActionSheetContentWithInputAndSubmit/index.tsx @@ -9,12 +9,11 @@ import sharedStyles from '../../../views/Styles'; import Button from '../../Button'; import { FormTextInput } from '../../TextInput/FormTextInput'; import { useActionSheet } from '../Provider'; +import { useResponsiveLayout } from '../../../lib/hooks/useResponsiveLayout/useResponsiveLayout'; const styles = StyleSheet.create({ subtitleText: { - ...sharedStyles.textRegular, - fontSize: 16, - lineHeight: 24 + ...sharedStyles.textRegular }, buttonSeparator: { marginRight: 12 @@ -24,9 +23,7 @@ const styles = StyleSheet.create({ paddingTop: 16 }, titleContainerText: { - ...sharedStyles.textBold, - fontSize: 16, - lineHeight: 24 + ...sharedStyles.textBold }, titleContainer: { paddingRight: 80, @@ -106,6 +103,7 @@ const ActionSheetContentWithInputAndSubmit = ({ autoComplete?: TextInputProps['autoComplete']; }): React.ReactElement => { const { colors } = useTheme(); + const { scaleFontSize } = useResponsiveLayout(); const [inputValues, setInputValues] = useState(inputs.map(() => '')); const inputRefs = useRef(inputs.map(() => React.createRef())); @@ -170,9 +168,9 @@ const ActionSheetContentWithInputAndSubmit = ({ <> {iconName ? : null} - {title} + {title} - {description ? {description} : null} + {description ? {description} : null} {customText} {showInput ? renderInputs() : null} diff --git a/app/containers/ActionSheet/BottomSheetContent.tsx b/app/containers/ActionSheet/BottomSheetContent.tsx index 267c4b7a20d..61a27a1ad4a 100644 --- a/app/containers/ActionSheet/BottomSheetContent.tsx +++ b/app/containers/ActionSheet/BottomSheetContent.tsx @@ -10,6 +10,7 @@ import { type TActionSheetOptionsItem } from './Provider'; import styles from './styles'; import * as List from '../List'; import Touch from '../Touch'; +import { useResponsiveLayout } from '../../lib/hooks/useResponsiveLayout/useResponsiveLayout'; interface IBottomSheetContentProps { hasCancel?: boolean; @@ -25,6 +26,7 @@ const BottomSheetContent = React.memo(({ options, hasCancel, hide, children, onL const { colors } = useTheme(); const { bottom } = useSafeAreaInsets(); const { fontScale } = useWindowDimensions(); + const { scaleFontSize } = useResponsiveLayout(); const height = 48 * fontScale; const renderFooter = () => @@ -33,7 +35,7 @@ const BottomSheetContent = React.memo(({ options, hasCancel, hide, children, onL onPress={hide} style={[styles.button, { backgroundColor: colors.surfaceHover, height }]} accessibilityLabel={I18n.t('Cancel')}> - {I18n.t('Cancel')} + {I18n.t('Cancel')} ) : null; diff --git a/app/containers/ActionSheet/Item.tsx b/app/containers/ActionSheet/Item.tsx index 0716b430eea..859eff6a1c9 100644 --- a/app/containers/ActionSheet/Item.tsx +++ b/app/containers/ActionSheet/Item.tsx @@ -9,6 +9,7 @@ import { type TActionSheetOptionsItem } from './Provider'; import styles from './styles'; import { LISTENER } from '../Toast'; import Touch from '../Touch'; +import { useResponsiveLayout } from '../../lib/hooks/useResponsiveLayout/useResponsiveLayout'; export interface IActionSheetItem { item: TActionSheetOptionsItem; @@ -21,6 +22,7 @@ export const Item = React.memo(({ item, hide }: IActionSheetItem) => { const enabled = item?.enabled ?? true; const { colors } = useTheme(); const { fontScale } = useWindowDimensions(); + const { scaleFontSize } = useResponsiveLayout(); const onPress = () => { if (enabled) { hide(); @@ -51,13 +53,13 @@ export const Item = React.memo(({ item, hide }: IActionSheetItem) => { testID={item.testID}> {item.icon ? : null} - + {item.title} {item?.subtitle ? ( + style={[styles.subtitle, { color: colors.fontSecondaryInfo, marginLeft: item.icon ? 16 : 0, fontSize: scaleFontSize(14), lineHeight: scaleFontSize(20) }]}> {item.subtitle} ) : null} diff --git a/app/containers/ActionSheet/styles.ts b/app/containers/ActionSheet/styles.ts index ad9d40831e3..17aa78e5101 100644 --- a/app/containers/ActionSheet/styles.ts +++ b/app/containers/ActionSheet/styles.ts @@ -20,13 +20,9 @@ export default StyleSheet.create({ flex: 1 }, title: { - fontSize: 16, - lineHeight: 22, ...sharedStyles.textMedium }, subtitle: { - fontSize: 14, - lineHeight: 20, ...sharedStyles.textRegular }, handle: { @@ -55,7 +51,6 @@ export default StyleSheet.create({ marginBottom: 12 }, text: { - fontSize: 16, ...sharedStyles.textMedium, ...sharedStyles.textAlignCenter }, diff --git a/app/containers/AppVersion.tsx b/app/containers/AppVersion.tsx index db80bd3f0ee..778e20c3ab6 100644 --- a/app/containers/AppVersion.tsx +++ b/app/containers/AppVersion.tsx @@ -5,6 +5,7 @@ import sharedStyles from '../views/Styles'; import { getReadableVersion } from '../lib/methods/helpers'; import I18n from '../i18n'; import { useTheme } from '../theme'; +import { useResponsiveLayout } from '../lib/hooks/useResponsiveLayout/useResponsiveLayout'; const styles = StyleSheet.create({ container: { @@ -12,8 +13,7 @@ const styles = StyleSheet.create({ justifyContent: 'flex-end' }, text: { - ...sharedStyles.textRegular, - fontSize: 13 + ...sharedStyles.textRegular }, bold: { ...sharedStyles.textSemibold @@ -22,9 +22,10 @@ const styles = StyleSheet.create({ const AppVersion = React.memo(() => { const { colors } = useTheme(); + const { scaleFontSize } = useResponsiveLayout(); return ( - + {I18n.t('Version_no', { version: '' })} {getReadableVersion} diff --git a/app/containers/BackgroundContainer/index.tsx b/app/containers/BackgroundContainer/index.tsx index bd91f7deb15..b7febafae96 100644 --- a/app/containers/BackgroundContainer/index.tsx +++ b/app/containers/BackgroundContainer/index.tsx @@ -4,6 +4,7 @@ import { ActivityIndicator, ImageBackground, StyleSheet, Text, View } from 'reac import { useTheme } from '../../theme'; import sharedStyles from '../../views/Styles'; import { themes } from '../../lib/constants/colors'; +import { useResponsiveLayout } from '../../lib/hooks/useResponsiveLayout/useResponsiveLayout'; export interface IBackgroundContainer { text?: string; @@ -24,7 +25,6 @@ const styles = StyleSheet.create({ top: 60, left: 0, right: 0, - fontSize: 16, paddingHorizontal: 24, ...sharedStyles.textRegular, ...sharedStyles.textAlignCenter @@ -33,10 +33,11 @@ const styles = StyleSheet.create({ const BackgroundContainer = ({ text, loading }: IBackgroundContainer): React.ReactElement => { const { theme } = useTheme(); + const { scaleFontSize } = useResponsiveLayout(); return ( - {text && !loading ? {text} : null} + {text && !loading ? {text} : null} {/* @ts-ignore */} {loading ? : null} diff --git a/app/containers/Button/index.tsx b/app/containers/Button/index.tsx index 1fe25724e81..d7d0d719385 100644 --- a/app/containers/Button/index.tsx +++ b/app/containers/Button/index.tsx @@ -5,6 +5,7 @@ import Touchable, { type PlatformTouchableProps } from 'react-native-platform-to import { useTheme } from '../../theme'; import sharedStyles from '../../views/Styles'; import ActivityIndicator from '../ActivityIndicator'; +import { useResponsiveLayout } from '../../lib/hooks/useResponsiveLayout/useResponsiveLayout'; // @ts-ignore interface IButtonProps extends PlatformTouchableProps { @@ -40,9 +41,7 @@ const styles = StyleSheet.create({ ...sharedStyles.textAlignCenter }, smallText: { - ...sharedStyles.textBold, - fontSize: 12, - lineHeight: 18 + ...sharedStyles.textBold }, disabled: { opacity: 0.3 @@ -64,6 +63,7 @@ const Button: React.FC = ({ ...otherProps }) => { const { colors } = useTheme(); + const { scaleFontSize } = useResponsiveLayout(); const isPrimary = type === 'primary'; const isDisabled = disabled || loading; @@ -82,7 +82,11 @@ const Button: React.FC = ({ ]; const textStyle = [ - { color: isDisabled ? colors.buttonPrimaryDisabled : resolvedTextColor, fontSize }, + { + color: isDisabled ? colors.buttonPrimaryDisabled : resolvedTextColor, + fontSize: small ? scaleFontSize(12) : scaleFontSize(fontSize), + lineHeight: small ? scaleFontSize(18) : undefined + }, small ? styles.smallText : styles.text, styleText ]; diff --git a/app/containers/CallHeader.tsx b/app/containers/CallHeader.tsx index 64f937fa00e..f313d8ca63d 100644 --- a/app/containers/CallHeader.tsx +++ b/app/containers/CallHeader.tsx @@ -12,6 +12,7 @@ import AvatarContainer from './Avatar'; import StatusContainer from './Status'; import DotsLoader from './DotsLoader'; import I18n from '../i18n'; +import { useResponsiveLayout } from '../lib/hooks/useResponsiveLayout/useResponsiveLayout'; type TCallHeader = { mic: boolean; @@ -28,6 +29,7 @@ type TCallHeader = { export const CallHeader = ({ mic, cam, setCam, setMic, title, avatar, uid, name, direct }: TCallHeader): React.ReactElement => { const style = useStyle(); const { colors } = useTheme(); + const { scaleFontSize } = useResponsiveLayout(); const calling = useAppSelector(state => state.videoConf.calling); const handleColors = (enabled: boolean) => { @@ -44,7 +46,7 @@ export const CallHeader = ({ mic, cam, setCam, setMic, title, avatar, uid, name, - {title} + {title} {calling && direct ? : null} @@ -73,7 +75,7 @@ export const CallHeader = ({ mic, cam, setCam, setMic, title, avatar, uid, name, {direct ? : null} - + {name} @@ -87,7 +89,6 @@ function useStyle() { const style = StyleSheet.create({ actionSheetHeader: { flexDirection: 'row', alignItems: 'center' }, actionSheetHeaderTitle: { - fontSize: 14, ...sharedStyles.textBold, color: colors.fontDefault }, @@ -103,7 +104,6 @@ function useStyle() { }, actionSheetUsernameContainer: { flexDirection: 'row', paddingTop: 8, alignItems: 'center' }, actionSheetUsername: { - fontSize: 16, ...sharedStyles.textBold, color: colors.fontDefault, flexShrink: 1 diff --git a/app/containers/ChangePasswordRequired.tsx b/app/containers/ChangePasswordRequired.tsx index 540c0dfbd2b..31e6a1bbf35 100644 --- a/app/containers/ChangePasswordRequired.tsx +++ b/app/containers/ChangePasswordRequired.tsx @@ -9,6 +9,7 @@ import { useTheme } from '../theme'; import sharedStyles from '../views/Styles'; import Button from './Button'; import { CustomIcon } from './CustomIcon'; +import { useResponsiveLayout } from '../lib/hooks/useResponsiveLayout/useResponsiveLayout'; interface IChangePasswordRequired { navigation: Omit, 'getState'> & { @@ -18,6 +19,7 @@ interface IChangePasswordRequired { export const ChangePasswordRequired = ({ navigation }: IChangePasswordRequired) => { const { colors } = useTheme(); + const { scaleFontSize } = useResponsiveLayout(); const dispatch = useDispatch(); const handleChangePassword = () => { @@ -29,8 +31,8 @@ export const ChangePasswordRequired = ({ navigation }: IChangePasswordRequired) - {I18n.t('You_need_to_change_your_password')} - {I18n.t('To_continue_using_RocketChat')} + {I18n.t('You_need_to_change_your_password')} + {I18n.t('To_continue_using_RocketChat')}