feat(chat/polls/native): added ids for tests (#14994)

* feat(chat/polls/navigation): added ids for tests and removed some unused helpers
This commit is contained in:
Calinteodor
2024-08-10 18:02:48 +03:00
committed by GitHub
parent 200228339b
commit a8958019a5
18 changed files with 90 additions and 62 deletions

View File

@@ -1,7 +1,8 @@
import React from 'react';
import { useTranslation } from 'react-i18next';
import { TouchableHighlight } from 'react-native';
import { StyleProp, TouchableHighlight } from 'react-native';
import { Button as NativePaperButton, Text } from 'react-native-paper';
import { IconSource } from 'react-native-paper/lib/typescript/components/Icon';
import { BUTTON_MODES, BUTTON_TYPES } from '../../constants.native';
import BaseTheme from '../BaseTheme.native';
@@ -13,6 +14,7 @@ import styles from './buttonStyles';
export interface IProps extends IButtonProps {
color?: string | undefined;
contentStyle?: Object | undefined;
id?: string;
labelStyle?: Object | undefined;
mode?: any;
style?: Object | undefined;
@@ -24,6 +26,7 @@ const Button: React.FC<IProps> = ({
contentStyle,
disabled,
icon,
id,
labelKey,
labelStyle,
mode = BUTTON_MODES.CONTAINED,
@@ -74,16 +77,17 @@ const Button: React.FC<IProps> = ({
<TouchableHighlight
accessibilityLabel = { accessibilityLabel }
disabled = { disabled }
id = { id }
onPress = { onPress }
style = { [
buttonStyles,
style
] }>
] as StyleProp<object> }>
<Text
style = { [
buttonLabelStyles,
labelStyle
] }>{ t(labelKey ?? '') }</Text>
] as StyleProp<object> }>{ t(labelKey ?? '') }</Text>
</TouchableHighlight>
);
}
@@ -96,21 +100,20 @@ const Button: React.FC<IProps> = ({
contentStyle = { [
styles.buttonContent,
contentStyle
] }
] as StyleProp<object> }
disabled = { disabled }
// @ts-ignore
icon = { icon }
icon = { icon as IconSource | undefined }
id = { id }
labelStyle = { [
buttonLabelStyles,
labelStyle
] }
] as StyleProp<object> }
mode = { mode }
onPress = { onPress }
style = { [
buttonStyles,
style
] } />
] as StyleProp<object> } />
);
};

View File

@@ -12,6 +12,7 @@ const IconButton: React.FC<IIconButtonProps> = ({
accessibilityLabel,
color: iconColor,
disabled,
id,
onPress,
size,
src,
@@ -52,6 +53,7 @@ const IconButton: React.FC<IIconButtonProps> = ({
<TouchableHighlight
accessibilityLabel = { accessibilityLabel }
disabled = { disabled }
id = { id }
onPress = { onPress }
style = { [
iconButtonContainerStyles,

View File

@@ -1,5 +1,5 @@
import React from 'react';
import { ColorValue } from 'react-native';
import { ColorValue, StyleProp } from 'react-native';
import { Switch as NativeSwitch } from 'react-native-paper';
import { ISwitchProps } from '../types';
@@ -12,6 +12,12 @@ import {
interface IProps extends ISwitchProps {
/**
* Id for the switch.
*/
id?: string;
/**
* Custom styles for the switch.
*/
@@ -31,6 +37,7 @@ interface IProps extends ISwitchProps {
const Switch = ({
checked,
disabled,
id,
onChange,
thumbColor = THUMB_COLOR,
trackColor = {
@@ -41,9 +48,10 @@ const Switch = ({
}: IProps) => (
<NativeSwitch
disabled = { disabled }
id = { id }
ios_backgroundColor = { DISABLED_TRACK_COLOR }
onValueChange = { onChange }
style = { style }
style = { style as StyleProp<object> }
thumbColor = { thumbColor }
trackColor = { trackColor }
value = { checked } />