Skip to content
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

feat(a11y): dynamic text size with custom header #6187

Open
wants to merge 53 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 42 commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
c884b41
fix: removed fixed height on Button and FormTextInput
OtavioStasiak Jan 24, 2025
ca660be
fix: worspace bottom sheet and header
OtavioStasiak Feb 12, 2025
1e3ed30
fix: loading increase height of button
OtavioStasiak Feb 13, 2025
ae0d1eb
fix: padding of NewServerView server history
OtavioStasiak Feb 13, 2025
d95944b
fix: Search header of RoomListview is not working
OtavioStasiak Feb 13, 2025
bf3ea86
fix: space of header on android and header of roomview
OtavioStasiak Feb 13, 2025
186cfdf
Merge branch 'develop' into fix-resized-text-fails-input-and-button
OtavioStasiak Feb 20, 2025
a97694b
fix: adjusting style of headers
OtavioStasiak Feb 21, 2025
378a597
fix: prevent large workspace name breaks the header
OtavioStasiak Feb 21, 2025
2966080
fix: updated gap value of headerContainer
OtavioStasiak Feb 21, 2025
4e36fd6
fix: removed margin horizontal of android header back button
OtavioStasiak Feb 21, 2025
6ffae88
fix: created Back Button component
OtavioStasiak Feb 21, 2025
ca5511e
fix: updated style of headerBackButton on ChangeAvatarView
OtavioStasiak Feb 21, 2025
66185b6
fix: hide back button on isMasterDetail empty room
OtavioStasiak Feb 21, 2025
7df5c86
chore: created customHeader component
OtavioStasiak Feb 22, 2025
13930a0
chore: remove left button of drawer
OtavioStasiak Feb 22, 2025
36d214f
fix: updated padding value if isMasterDetail
OtavioStasiak Feb 22, 2025
b319991
chore: rename prop
OtavioStasiak Feb 22, 2025
18edac3
chore: added customHeader on defaultHeader
OtavioStasiak Feb 22, 2025
02acdcc
fix: prevent roomListHeader from breaking the layout if the name of w…
OtavioStasiak Feb 22, 2025
a7c44c4
chore: rollback RoomView unused changes
OtavioStasiak Feb 22, 2025
177d8e5
fix: lint
OtavioStasiak Feb 22, 2025
53827fd
fix: updated changeAvatarView back button style
OtavioStasiak Feb 22, 2025
786ffb6
fix: header layout on masterDetail
OtavioStasiak Feb 22, 2025
d8e8311
fix: adjusted header layout on shareView
OtavioStasiak Feb 22, 2025
661025f
fix: patch package of react navigation elements
OtavioStasiak Feb 22, 2025
c775281
fix: patch package
OtavioStasiak Feb 22, 2025
3949e46
fix: header breaking on outside stack
OtavioStasiak Feb 22, 2025
fa0ed1a
chore: code improvements
OtavioStasiak Feb 24, 2025
7b0d132
fix: resize icon
OtavioStasiak Feb 24, 2025
e2517bf
fix: dynamic Row height value
OtavioStasiak Feb 24, 2025
7a70cff
fix: message composer test snap
OtavioStasiak Feb 24, 2025
1660e73
fix: status style
OtavioStasiak Feb 25, 2025
69192ea
Merge branch 'develop' into fix-resized-text-fails-input-and-button
OtavioStasiak Feb 25, 2025
2c13cec
Merge branch 'develop' into feat-dynamic-text-size-with-custom-header
OtavioStasiak Feb 28, 2025
8be6b74
fix: customHeader diff on iOS
OtavioStasiak Feb 28, 2025
f25f733
fix: login services and directory
OtavioStasiak Feb 28, 2025
d93f986
fix: layout header size respecting the pattern
OtavioStasiak Mar 5, 2025
ea8690c
fix: header alignment on ipad
OtavioStasiak Mar 5, 2025
5a88104
fix: seach header
OtavioStasiak Mar 5, 2025
876e3f1
fix: spacement on header
OtavioStasiak Mar 6, 2025
76b14ff
fix: snapshot test
OtavioStasiak Mar 6, 2025
d283f72
fix: android left buttons spacement
OtavioStasiak Mar 6, 2025
9aa4124
fix: remove unused props
OtavioStasiak Mar 6, 2025
225ca2f
fix: organize styles of customHeader
OtavioStasiak Mar 6, 2025
5d5daae
fix: reorganized code and rename variables
OtavioStasiak Mar 6, 2025
eff863e
fix: rowHeight hook path and name of variables
OtavioStasiak Mar 7, 2025
80adeb0
fix: magic number and use useWindowDimensions hook instead of PixelRa…
OtavioStasiak Mar 7, 2025
cbc8445
fix: back button patch package
OtavioStasiak Mar 7, 2025
c039333
Merge branch 'develop' into feat-dynamic-text-size-with-custom-header
OtavioStasiak Mar 7, 2025
39ad95a
fix: e2e tests
OtavioStasiak Mar 7, 2025
0f1640b
fix: header alignment on iOS and roomsListViewwith duplicate separator
OtavioStasiak Mar 7, 2025
a3dd35a
fix: e2e tests
OtavioStasiak Mar 7, 2025
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
8 changes: 4 additions & 4 deletions app/containers/Button/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ const styles = StyleSheet.create({
borderRadius: 4
},
normalButton: {
paddingHorizontal: 14,
justifyContent: 'center',
height: 48
paddingVertical: 14,
paddingHorizontal: 16,
justifyContent: 'center'
},
smallButton: {
paddingHorizontal: 12,
Expand Down Expand Up @@ -94,7 +94,7 @@ const Button: React.FC<IButtonProps> = ({
accessibilityLabel={title}
accessibilityRole='button'
{...otherProps}>
{loading ? <ActivityIndicator color={resolvedTextColor} /> : <Text style={textStyle}>{title}</Text>}
{loading ? <ActivityIndicator color={resolvedTextColor} style={{ padding: 0 }} /> : <Text style={textStyle}>{title}</Text>}
</Touchable>
);
};
Expand Down
42 changes: 42 additions & 0 deletions app/containers/CustomHeader/components/HeaderContainer/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import React from 'react';
import { useWindowDimensions, View, ViewProps, StyleSheet } from 'react-native';
import { useSafeAreaInsets } from 'react-native-safe-area-context';

import { useTheme } from '../../../../theme';

interface IHeaderContainer extends ViewProps {
addExtraNotchPadding?: boolean;
isMasterDetail?: boolean;
customLeftIcon?: boolean;
customRightIcon?: boolean;
}

const HeaderContainer = (props: IHeaderContainer) => {
const insets = useSafeAreaInsets();
const { colors } = useTheme();
const { height, width } = useWindowDimensions();
const isPortrait = height > width;
const paddingBottom = isPortrait ? 12 : 4;
const statusBarPadding = props.addExtraNotchPadding ? insets.top : 0;
const paddingRight = props.isMasterDetail || !props.customRightIcon ? 4 : 16;

return (
<View
{...props}
style={{
alignItems: 'center',
flexDirection: 'row',
paddingBottom,
paddingTop: statusBarPadding + paddingBottom,
paddingRight,
paddingLeft: props.customLeftIcon ? 16 : 4,
gap: props.isMasterDetail ? 4 : 16,
backgroundColor: colors.surfaceNeutral,
borderWidth: StyleSheet.hairlineWidth,
borderColor: colors.strokeLight
}}
/>
);
};

export default HeaderContainer;
94 changes: 94 additions & 0 deletions app/containers/CustomHeader/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
import React, { ReactNode } from 'react';
import { PixelRatio, Text, View } from 'react-native';
import { NativeStackHeaderProps } from '@react-navigation/native-stack';
import { HeaderBackButton } from '@react-navigation/elements';

import HeaderContainer from './components/HeaderContainer';
import { isAndroid } from '../../lib/methods/helpers';
import { useAppSelector } from '../../lib/hooks';
import { useTheme } from '../../theme';
import { styles } from './styles';

interface IHeaderTitle {
headerTitle?: string | ((props: { children: string; tintColor?: string }) => ReactNode);
}

const HeaderTitle = ({ headerTitle }: IHeaderTitle) => {
const { colors } = useTheme();
if (!headerTitle) return null;
if (typeof headerTitle === 'string') {
if (isAndroid) {
return (
<Text
numberOfLines={1}
style={{
...styles.title,
paddingVertical: 10,
color: colors.fontTitlesLabels
}}>
{headerTitle}
</Text>
);
}
return (
<View style={styles.headerTitleContainer}>
<Text
numberOfLines={1}
style={{
...styles.title,
paddingVertical: 6,
color: colors.fontTitlesLabels
}}>
{headerTitle}
</Text>
</View>
);
}

return headerTitle({ children: '', tintColor: colors.fontTitlesLabels });
};

interface IHeader extends NativeStackHeaderProps {}

const CustomHeader = ({ options, navigation, route }: IHeader) => {
const { headerLeft, headerTitle, headerRight, title } = options;
const { colors } = useTheme();
const isMasterDetail = useAppSelector(state => state.app.isMasterDetail);
const fontScale = PixelRatio.getFontScale();

const isRoomViewMasterDetail =
!isMasterDetail ||
route.name === 'RoomView' ||
route.name === 'RoomsListView' ||
route.name === 'ShareListView' ||
route.name === 'ShareView' ||
route.name === 'AttachmentView';

return (
<HeaderContainer
customRightIcon={!!headerRight}
customLeftIcon={!!headerLeft}
addExtraNotchPadding={isRoomViewMasterDetail}
isMasterDetail={isMasterDetail}>
{headerLeft ? (
headerLeft({ canGoBack: false })
) : (
<HeaderBackButton
labelVisible={false}
onPress={() => navigation.goBack()}
tintColor={colors.fontDefault}
testID='header-back'
style={styles.headerBackButton}
/>
)}
<HeaderTitle headerTitle={headerTitle ?? title} />
{headerRight ? (
headerRight({ canGoBack: false })
) : (
<View style={{ width: isAndroid ? undefined : 32.5 * fontScale, height: 32.5 * fontScale }} />
)}
</HeaderContainer>
);
};

export default CustomHeader;
22 changes: 22 additions & 0 deletions app/containers/CustomHeader/styles.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { StyleSheet } from 'react-native';

import { isTablet } from '../../lib/methods/helpers';
import sharedStyles from '../../views/Styles';

export const styles = StyleSheet.create({
title: {
...sharedStyles.textBold,
fontSize: 16,
flex: 1,
lineHeight: 24
},
headerBackButton: {
margin: 0,
marginRight: isTablet ? 5 : -5
},
headerTitleContainer: {
flex: 1,
alignItems: 'center',
justifyContent: 'center'
}
});
13 changes: 12 additions & 1 deletion app/containers/CustomIcon/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React from 'react';
import { PixelRatio } from 'react-native';
import { createIconSetFromIcoMoon } from 'react-native-vector-icons';
import type { IconProps } from 'react-native-vector-icons/Icon';

Expand All @@ -19,7 +20,17 @@ export interface ICustomIcon extends IconProps {

const CustomIcon = ({ name, size, color, style, ...props }: ICustomIcon): React.ReactElement => {
const { colors } = useTheme();
return <IconSet name={name} size={size} color={color || colors.fontDefault} style={[{ lineHeight: size }, style]} {...props} />;
const fontScale = PixelRatio.getFontScale();

return (
<IconSet
name={name}
size={size * fontScale}
color={color || colors.fontDefault}
style={[{ lineHeight: size * fontScale }, style]}
{...props}
/>
);
};

export { CustomIcon };
2 changes: 1 addition & 1 deletion app/containers/DirectoryItem/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export const ROW_HEIGHT = 54;

export default StyleSheet.create({
directoryItemButton: {
height: ROW_HEIGHT
paddingVertical: 12
},
directoryItemContainer: {
flex: 1,
Expand Down
12 changes: 10 additions & 2 deletions app/containers/HeaderButton/Common.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from 'react';
import { StackActions, useNavigation } from '@react-navigation/native';
import { StyleProp, ViewStyle } from 'react-native';

import I18n from '../../i18n';
import { isIOS } from '../../lib/methods/helpers';
Expand All @@ -9,13 +10,20 @@ import { useTheme } from '../../theme';

interface IHeaderButtonCommon extends IHeaderButtonItem {
navigation?: any; // TODO: Evaluate proper type
style?: StyleProp<ViewStyle>;
}

// Left
export const Drawer = ({ navigation, testID, onPress = () => navigation?.toggleDrawer(), ...props }: IHeaderButtonCommon) => {
export const Drawer = ({
navigation,
testID,
style = {},
onPress = () => navigation?.toggleDrawer(),
...props
}: IHeaderButtonCommon) => {
const { colors } = useTheme();
return (
<Container left>
<Container style={style}>
<Item iconName='hamburguer' onPress={onPress} testID={testID} color={colors.fontDefault} {...props} />
</Container>
);
Expand Down
7 changes: 4 additions & 3 deletions app/containers/HeaderButton/HeaderButtonContainer.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import React from 'react';
import { StyleSheet, View, ViewProps } from 'react-native';
import { StyleProp, StyleSheet, View, ViewProps, ViewStyle } from 'react-native';

import { isAndroid, isTablet } from '../../lib/methods/helpers';

interface IHeaderButtonContainer {
children?: React.ReactElement | (React.ReactElement | null)[] | null;
left?: boolean;
onLayout?: ViewProps['onLayout'];
style?: StyleProp<ViewStyle>;
}

const styles = StyleSheet.create({
Expand All @@ -24,8 +25,8 @@ const styles = StyleSheet.create({
}
});

const Container = ({ children, left = false, onLayout }: IHeaderButtonContainer): React.ReactElement => (
<View style={[styles.container, left ? styles.left : styles.right]} onLayout={onLayout || undefined}>
const Container = ({ children, left = false, onLayout, style = {} }: IHeaderButtonContainer): React.ReactElement => (
<View style={[styles.container, left ? styles.left : styles.right, style]} onLayout={onLayout || undefined}>
{children}
</View>
);
Expand Down
7 changes: 4 additions & 3 deletions app/containers/InAppNotification/NotifierComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ import { CustomIcon } from '../CustomIcon';
import sharedStyles from '../../views/Styles';
import { themes } from '../../lib/constants';
import { useTheme } from '../../theme';
import { ROW_HEIGHT } from '../RoomItem';
import { goRoom } from '../../lib/methods/helpers/goRoom';
import { IApplicationState, ISubscription, SubscriptionType } from '../../definitions';
import { hideNotification } from '../../lib/methods/helpers/notifications';
import { useRowHeight } from '../RoomItem/useRowHeight';

export interface INotifierComponent {
notification: {
Expand All @@ -33,7 +33,6 @@ const BUTTON_HIT_SLOP = { top: 12, right: 12, bottom: 12, left: 12 };

const styles = StyleSheet.create({
container: {
height: ROW_HEIGHT,
paddingHorizontal: 14,
flexDirection: 'row',
alignItems: 'center',
Expand Down Expand Up @@ -74,6 +73,7 @@ const styles = StyleSheet.create({

const NotifierComponent = React.memo(({ notification, isMasterDetail }: INotifierComponent) => {
const { theme } = useTheme();
const { ROW_HEIGHT } = useRowHeight();
const insets = useSafeAreaInsets();
const { text, payload } = notification;
const { type, rid } = payload;
Expand Down Expand Up @@ -105,7 +105,8 @@ const NotifierComponent = React.memo(({ notification, isMasterDetail }: INotifie
{
backgroundColor: themes[theme].surfaceLight,
borderColor: themes[theme].strokeLight,
marginTop: insets.top
marginTop: insets.top,
height: ROW_HEIGHT
}
]}>
<Touchable
Expand Down
11 changes: 6 additions & 5 deletions app/containers/LoginServices/ButtonService.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import { Text, View } from 'react-native';
import { PixelRatio, Text, View } from 'react-native';

import { useTheme } from '../../theme';
import Touch from '../Touch';
Expand All @@ -9,7 +9,7 @@ import styles from './styles';

const ButtonService = ({ name, authType, onPress, backgroundColor, buttonText, icon, accessibilityLabel }: IButtonService) => {
const { colors } = useTheme();

const size = 24 * PixelRatio.getFontScale();
return (
<Touch
key={name}
Expand All @@ -18,10 +18,11 @@ const ButtonService = ({ name, authType, onPress, backgroundColor, buttonText, i
activeOpacity={0.5}
underlayColor={colors.fontWhite}
accessible
accessibilityLabel={accessibilityLabel}
>
accessibilityLabel={accessibilityLabel}>
<View style={styles.serviceButtonContainer}>
{authType === 'oauth' || authType === 'apple' ? <CustomIcon name={icon} size={24} style={styles.serviceIcon} /> : null}
{authType === 'oauth' || authType === 'apple' ? (
<CustomIcon name={icon} size={24} style={[styles.serviceIcon, { width: size, height: size }]} />
) : null}
<Text style={[styles.serviceText, { color: colors.fontTitlesLabels }]}>{buttonText}</Text>
</View>
</Touch>
Expand Down
8 changes: 2 additions & 6 deletions app/containers/LoginServices/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { StyleSheet } from 'react-native';

import sharedStyles from '../../views/Styles';

export const BUTTON_HEIGHT = 48;
export const SERVICE_HEIGHT = 58;
export const BORDER_RADIUS = 4;
export const SERVICES_COLLAPSED_HEIGHT = 174;
Expand All @@ -15,18 +14,15 @@ export default StyleSheet.create({
serviceButtonContainer: {
borderRadius: BORDER_RADIUS,
width: '100%',
height: BUTTON_HEIGHT,
paddingVertical: 14,
flexDirection: 'row',
alignItems: 'center',
justifyContent: 'center',
paddingHorizontal: 15
},
serviceIcon: {
position: 'absolute',
left: 15,
top: 12,
width: 24,
height: 24
left: 15
},
serviceText: {
...sharedStyles.textRegular,
Expand Down
Loading