Skip to content

Commit 9d28825

Browse files
committed
Merge branch 'develop' of https://github.com/RocketChat/Rocket.Chat.ReactNative into chore.gh-poc-lint
2 parents 4ccf335 + 0f6b015 commit 9d28825

70 files changed

Lines changed: 2158 additions & 672 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

app/containers/AudioPlayer/PlayButton.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import RCActivityIndicator from '../ActivityIndicator';
77
import { AUDIO_BUTTON_HIT_SLOP } from './constants';
88
import { TAudioState } from './types';
99
import NativeButton from '../NativeButton';
10+
import getPlayButtonAccessibilityLabel from './getPlayButtonAccessibilityLabel';
1011

1112
interface IButton {
1213
disabled?: boolean;
@@ -45,6 +46,8 @@ const PlayButton = ({ onPress, disabled = false, audioState }: IButton): React.R
4546

4647
return (
4748
<NativeButton
49+
accessible
50+
accessibilityLabel={getPlayButtonAccessibilityLabel(audioState)}
4851
style={[styles.playPauseButton, { backgroundColor: colors.buttonBackgroundPrimaryDefault }]}
4952
disabled={disabled}
5053
onPress={onPress}

app/containers/AudioPlayer/PlaybackSpeed.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React from 'react';
22
import { Text } from 'react-native';
33

4+
import i18n from '../../i18n';
45
import styles from './styles';
56
import { useTheme } from '../../theme';
67
import { AUDIO_PLAYBACK_SPEED, AVAILABLE_SPEEDS } from './constants';
@@ -19,6 +20,8 @@ const PlaybackSpeed = () => {
1920

2021
return (
2122
<NativeButton
23+
accessible
24+
accessibilityLabel={i18n.t('Playback_speed', { playbackSpeed: `${playbackSpeed} x` })}
2225
onPress={onPress}
2326
style={[styles.containerPlaybackSpeed, { backgroundColor: colors.buttonBackgroundSecondaryDefault }]}>
2427
<Text style={[styles.playbackSpeedText, { color: colors.buttonFontSecondary }]}>{playbackSpeed}x</Text>
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import i18n from '../../i18n';
2+
import { TAudioState } from './types';
3+
4+
const getPlayButtonAccessibilityLabel = (state: TAudioState) => {
5+
switch (state) {
6+
case 'loading':
7+
return i18n.t('Loading');
8+
case 'paused':
9+
return i18n.t('Play');
10+
case 'playing':
11+
return i18n.t('Pause');
12+
case 'to-download':
13+
return i18n.t('To_download');
14+
default:
15+
return '';
16+
}
17+
};
18+
19+
export default getPlayButtonAccessibilityLabel;

app/containers/EmojiPicker/EmojiSearch.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ export const EmojiSearch = ({ onBlur, onChangeText, bottomSheet }: IEmojiSearchB
2020

2121
return (
2222
<FormTextInput
23+
accessibilityLabel={I18n.t('Search_emoji')}
2324
autoCapitalize='none'
2425
autoCorrect={false}
2526
autoComplete='off'

app/containers/EmojiPicker/PressableEmoji.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,12 @@ import { Emoji } from './Emoji';
99

1010
export const PressableEmoji = ({ emoji, onPress }: { emoji: IEmoji; onPress: (emoji: IEmoji) => void }): React.ReactElement => {
1111
const { colors } = useTheme();
12+
const accessibilityLabel = typeof emoji === 'string' ? emoji : emoji.name;
13+
1214
return (
1315
<Pressable
16+
accessible
17+
accessibilityLabel={accessibilityLabel}
1418
key={typeof emoji === 'string' ? emoji : emoji.name}
1519
onPress={() => onPress(emoji)}
1620
testID={`emoji-${typeof emoji === 'string' ? emoji : emoji.name}`}

app/containers/EmojiPicker/index.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ import { TabView } from '../TabView';
1414

1515
const routes = categories.tabs.map(tab => ({
1616
key: tab.category,
17-
title: tab.tabLabel
17+
title: tab.tabLabel,
18+
accessibilityLabel: tab.accessibilityLabel
1819
}));
1920

2021
const EmojiPicker = ({
@@ -39,6 +40,8 @@ const EmojiPicker = ({
3940

4041
const renderTabItem = (tab: Route, color: string) => (
4142
<CustomIcon
43+
accessible
44+
accessibilityLabel={tab?.accessibilityLabel}
4245
size={24}
4346
name={tab.title as TIconsName}
4447
color={color}

app/containers/Header/components/HeaderBackButton.tsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { HeaderBackButtonProps, HeaderBackButton as RNHeaderBackButton } from '@
22
import { Platform, StyleSheet } from 'react-native';
33

44
import { useTheme } from '../../../theme';
5+
import I18n from '../../../i18n';
56

67
const styles = StyleSheet.create({
78
container: {
@@ -20,6 +21,13 @@ const styles = StyleSheet.create({
2021

2122
export const HeaderBackButton = ({ ...props }: HeaderBackButtonProps) => {
2223
const { colors } = useTheme();
23-
24-
return <RNHeaderBackButton tintColor={colors.fontDefault} style={styles.container} testID='header-back' {...props} />;
24+
return (
25+
<RNHeaderBackButton
26+
accessibilityLabel={I18n.t('Back')}
27+
tintColor={colors.fontDefault}
28+
style={styles.container}
29+
testID='header-back'
30+
{...props}
31+
/>
32+
);
2533
};

app/containers/Header/components/HeaderButton/Common.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,14 @@ export const Drawer = ({
2424
const { colors } = useTheme();
2525
return (
2626
<Container style={style} left>
27-
<Item iconName='hamburguer' onPress={onPress} testID={testID} color={colors.fontDefault} {...props} />
27+
<Item
28+
accessibilityLabel={I18n.t('Menu')}
29+
iconName='hamburguer'
30+
onPress={onPress}
31+
testID={testID}
32+
color={colors.fontDefault}
33+
{...props}
34+
/>
2835
</Container>
2936
);
3037
};
@@ -78,6 +85,6 @@ export const Preferences = React.memo(({ onPress, testID, ...props }: IHeaderBut
7885

7986
export const Legal = React.memo(
8087
({ navigation, testID, onPress = () => navigation?.navigate('LegalView'), ...props }: IHeaderButtonCommon) => (
81-
<More onPress={onPress} testID={testID} {...props} />
88+
<More accessibilityLabel={I18n.t('More')} onPress={onPress} testID={testID} {...props} />
8289
)
8390
);

app/containers/MessageActions/Header.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import CustomEmoji from '../EmojiPicker/CustomEmoji';
1111
import sharedStyles from '../../views/Styles';
1212
import { IEmoji, TAnyMessageModel } from '../../definitions';
1313
import Touch from '../Touch';
14+
import I18n from '../../i18n';
1415

1516
export interface IHeader {
1617
handleReaction: (emoji: IEmoji | null, message: TAnyMessageModel) => void;
@@ -67,6 +68,8 @@ const HeaderItem = ({ item, onReaction, theme }: THeaderItem) => {
6768
return (
6869
<Touch
6970
testID={`message-actions-emoji-${item}`}
71+
accessible
72+
accessibilityLabel={I18n.t('React_with_emojjname', { emojiName: item })}
7073
onPress={() => onReaction({ emoji: item })}
7174
style={[styles.headerItem, { backgroundColor: themes[theme].surfaceHover }]}>
7275
{typeof item === 'string' ? (
@@ -80,6 +83,8 @@ const HeaderItem = ({ item, onReaction, theme }: THeaderItem) => {
8083
const HeaderFooter = ({ onReaction, theme }: THeaderFooter) => (
8184
<Touch
8285
testID='add-reaction'
86+
accessible
87+
accessibilityLabel={I18n.t('Select_emoji_reaction')}
8388
onPress={(param: any) => onReaction(param)}
8489
style={[styles.headerItem, { backgroundColor: themes[theme].surfaceHover }]}>
8590
<CustomIcon name='reaction-add' size={24} />

app/containers/MessageComposer/MessageComposer.tsx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React, { ReactElement, useRef, useImperativeHandle, useCallback } from 'react';
2-
import { View, StyleSheet, NativeModules } from 'react-native';
2+
import { View, StyleSheet, NativeModules, AccessibilityInfo, findNodeHandle } from 'react-native';
33
import { KeyboardAccessoryView } from 'react-native-ui-lib/keyboard';
44
import { useBackHandler } from '@react-native-community/hooks';
55
import { Q } from '@nozbe/watermelondb';
@@ -210,6 +210,13 @@ export const MessageComposer = ({
210210
emitter.emit(`setComposerHeight${tmid ? 'Thread' : ''}`, height);
211211
};
212212

213+
const accessibilityFocusOnInput = () => {
214+
const node = findNodeHandle(composerInputRef.current);
215+
if (node) {
216+
AccessibilityInfo.setAccessibilityFocus(node);
217+
}
218+
};
219+
213220
const backgroundColor = action === 'edit' ? colors.statusBackgroundWarning2 : colors.surfaceLight;
214221

215222
const renderContent = () => {
@@ -249,7 +256,10 @@ export const MessageComposer = ({
249256
iOSScrollBehavior={NativeModules.KeyboardTrackingViewTempManager?.KeyboardTrackingScrollBehaviorFixedOffset}
250257
onHeightChanged={onHeightChanged}
251258
/>
252-
<Autocomplete onPress={item => composerInputComponentRef.current.onAutocompleteItemSelected(item)} />
259+
<Autocomplete
260+
onPress={item => composerInputComponentRef.current.onAutocompleteItemSelected(item)}
261+
accessibilityFocusOnInput={accessibilityFocusOnInput}
262+
/>
253263
</MessageInnerContext.Provider>
254264
);
255265
};

0 commit comments

Comments
 (0)