Chore: Migrate Touch to hooks (#4422)
* migrate to hooks and fix types * fix import and remove theme prop * update tests * fix touch file name * wip * rename * change to touch * remove button and change to touch
This commit is contained in:
parent
1ba4ba669e
commit
ab58208139
|
@ -2,13 +2,13 @@ import { Text } from 'react-native';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { BottomSheetView, BottomSheetFlatList } from '@gorhom/bottom-sheet';
|
import { BottomSheetView, BottomSheetFlatList } from '@gorhom/bottom-sheet';
|
||||||
|
|
||||||
import { Button } from './Button';
|
|
||||||
import I18n from '../../i18n';
|
import I18n from '../../i18n';
|
||||||
import { useTheme } from '../../theme';
|
import { useTheme } from '../../theme';
|
||||||
import { IActionSheetItem, Item } from './Item';
|
import { IActionSheetItem, Item } from './Item';
|
||||||
import { TActionSheetOptionsItem } from './Provider';
|
import { TActionSheetOptionsItem } from './Provider';
|
||||||
import styles from './styles';
|
import styles from './styles';
|
||||||
import * as List from '../List';
|
import * as List from '../List';
|
||||||
|
import Touch from '../Touch';
|
||||||
|
|
||||||
interface IBottomSheetContentProps {
|
interface IBottomSheetContentProps {
|
||||||
hasCancel?: boolean;
|
hasCancel?: boolean;
|
||||||
|
@ -18,19 +18,17 @@ interface IBottomSheetContentProps {
|
||||||
}
|
}
|
||||||
|
|
||||||
const BottomSheetContent = React.memo(({ options, hasCancel, hide, children }: IBottomSheetContentProps) => {
|
const BottomSheetContent = React.memo(({ options, hasCancel, hide, children }: IBottomSheetContentProps) => {
|
||||||
const { theme, colors } = useTheme();
|
const { colors } = useTheme();
|
||||||
|
|
||||||
const renderFooter = () =>
|
const renderFooter = () =>
|
||||||
hasCancel ? (
|
hasCancel ? (
|
||||||
<Button
|
<Touch
|
||||||
onPress={hide}
|
onPress={hide}
|
||||||
style={[styles.button, { backgroundColor: colors.auxiliaryBackground }]}
|
style={[styles.button, { backgroundColor: colors.auxiliaryBackground }]}
|
||||||
// TODO: Remove when migrate Touch
|
|
||||||
theme={theme}
|
|
||||||
accessibilityLabel={I18n.t('Cancel')}
|
accessibilityLabel={I18n.t('Cancel')}
|
||||||
>
|
>
|
||||||
<Text style={[styles.text, { color: colors.bodyText }]}>{I18n.t('Cancel')}</Text>
|
<Text style={[styles.text, { color: colors.bodyText }]}>{I18n.t('Cancel')}</Text>
|
||||||
</Button>
|
</Touch>
|
||||||
) : null;
|
) : null;
|
||||||
|
|
||||||
const renderItem = ({ item }: { item: IActionSheetItem['item'] }) => <Item item={item} hide={hide} />;
|
const renderItem = ({ item }: { item: IActionSheetItem['item'] }) => <Item item={item} hide={hide} />;
|
||||||
|
|
|
@ -1,8 +0,0 @@
|
||||||
import React from 'react';
|
|
||||||
import { TouchableOpacity } from 'react-native';
|
|
||||||
|
|
||||||
import { isAndroid } from '../../lib/methods/helpers';
|
|
||||||
import Touch from '../../lib/methods/helpers/touch';
|
|
||||||
|
|
||||||
// Taken from https://github.com/rgommezz/react-native-scroll-bottom-sheet#touchables
|
|
||||||
export const Button: typeof React.Component = isAndroid ? Touch : TouchableOpacity;
|
|
|
@ -4,9 +4,9 @@ import { Text, View } from 'react-native';
|
||||||
import { themes } from '../../lib/constants';
|
import { themes } from '../../lib/constants';
|
||||||
import { CustomIcon } from '../CustomIcon';
|
import { CustomIcon } from '../CustomIcon';
|
||||||
import { useTheme } from '../../theme';
|
import { useTheme } from '../../theme';
|
||||||
import { Button } from './Button';
|
|
||||||
import { TActionSheetOptionsItem } from './Provider';
|
import { TActionSheetOptionsItem } from './Provider';
|
||||||
import styles from './styles';
|
import styles from './styles';
|
||||||
|
import Touch from '../Touch';
|
||||||
|
|
||||||
export interface IActionSheetItem {
|
export interface IActionSheetItem {
|
||||||
item: TActionSheetOptionsItem;
|
item: TActionSheetOptionsItem;
|
||||||
|
@ -21,12 +21,7 @@ export const Item = React.memo(({ item, hide }: IActionSheetItem) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Button
|
<Touch onPress={onPress} style={[styles.item, { backgroundColor: themes[theme].focusedBackground }]} testID={item.testID}>
|
||||||
onPress={onPress}
|
|
||||||
style={[styles.item, { backgroundColor: themes[theme].focusedBackground }]}
|
|
||||||
theme={theme}
|
|
||||||
testID={item.testID}
|
|
||||||
>
|
|
||||||
{item.icon ? (
|
{item.icon ? (
|
||||||
<CustomIcon name={item.icon} size={20} color={item.danger ? themes[theme].dangerColor : themes[theme].bodyText} />
|
<CustomIcon name={item.icon} size={20} color={item.danger ? themes[theme].dangerColor : themes[theme].bodyText} />
|
||||||
) : null}
|
) : null}
|
||||||
|
@ -42,6 +37,6 @@ export const Item = React.memo(({ item, hide }: IActionSheetItem) => {
|
||||||
</Text>
|
</Text>
|
||||||
</View>
|
</View>
|
||||||
{item.right ? <View style={styles.rightContainer}>{item.right ? item.right() : null}</View> : null}
|
{item.right ? <View style={styles.rightContainer}>{item.right ? item.right() : null}</View> : null}
|
||||||
</Button>
|
</Touch>
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,2 +1 @@
|
||||||
export * from './Provider';
|
export * from './Provider';
|
||||||
export * from './Button';
|
|
||||||
|
|
|
@ -4,6 +4,7 @@ import { storiesOf } from '@storybook/react-native';
|
||||||
|
|
||||||
import { ThemeContext } from '../../theme';
|
import { ThemeContext } from '../../theme';
|
||||||
import { longText } from '../../../storybook/utils';
|
import { longText } from '../../../storybook/utils';
|
||||||
|
import { themes } from '../../lib/constants';
|
||||||
import BackgroundContainer from '.';
|
import BackgroundContainer from '.';
|
||||||
|
|
||||||
const stories = storiesOf('BackgroundContainer', module);
|
const stories = storiesOf('BackgroundContainer', module);
|
||||||
|
@ -17,7 +18,7 @@ stories.add('text', () => <BackgroundContainer text='Text here' />);
|
||||||
stories.add('long text', () => <BackgroundContainer text={longText} />);
|
stories.add('long text', () => <BackgroundContainer text={longText} />);
|
||||||
|
|
||||||
const ThemeStory = ({ theme, ...props }) => (
|
const ThemeStory = ({ theme, ...props }) => (
|
||||||
<ThemeContext.Provider value={{ theme }}>
|
<ThemeContext.Provider value={{ theme, colors: themes[theme] }}>
|
||||||
<BackgroundContainer {...props} />
|
<BackgroundContainer {...props} />
|
||||||
</ThemeContext.Provider>
|
</ThemeContext.Provider>
|
||||||
);
|
);
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { Text, View, ViewStyle } from 'react-native';
|
import { Text, View, ViewStyle } from 'react-native';
|
||||||
|
|
||||||
import Touch from '../../lib/methods/helpers/touch';
|
import Touch from '../Touch';
|
||||||
import Avatar from '../Avatar';
|
import Avatar from '../Avatar';
|
||||||
import RoomTypeIcon from '../RoomTypeIcon';
|
import RoomTypeIcon from '../RoomTypeIcon';
|
||||||
import styles, { ROW_HEIGHT } from './styles';
|
import styles, { ROW_HEIGHT } from './styles';
|
||||||
|
@ -49,7 +49,7 @@ const DirectoryItem = ({
|
||||||
}: IDirectoryItem): React.ReactElement => {
|
}: IDirectoryItem): React.ReactElement => {
|
||||||
const { theme } = useTheme();
|
const { theme } = useTheme();
|
||||||
return (
|
return (
|
||||||
<Touch onPress={onPress} style={{ backgroundColor: themes[theme].backgroundColor }} testID={testID} theme={theme}>
|
<Touch onPress={onPress} style={{ backgroundColor: themes[theme].backgroundColor }} testID={testID}>
|
||||||
<View style={[styles.directoryItemContainer, styles.directoryItemButton, style]}>
|
<View style={[styles.directoryItemContainer, styles.directoryItemButton, style]}>
|
||||||
<Avatar text={avatar} size={30} type={type} rid={rid} style={styles.directoryItemAvatar} />
|
<Avatar text={avatar} size={30} type={type} rid={rid} style={styles.directoryItemAvatar} />
|
||||||
<View style={styles.directoryItemTextContainer}>
|
<View style={styles.directoryItemTextContainer}>
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { I18nManager, StyleProp, StyleSheet, Text, TextStyle, View } from 'react-native';
|
import { I18nManager, StyleProp, StyleSheet, Text, TextStyle, View } from 'react-native';
|
||||||
|
|
||||||
import Touch from '../../lib/methods/helpers/touch';
|
import Touch from '../Touch';
|
||||||
import { themes } from '../../lib/constants';
|
import { themes } from '../../lib/constants';
|
||||||
import sharedStyles from '../../views/Styles';
|
import sharedStyles from '../../views/Styles';
|
||||||
import { TSupportedThemes, useTheme } from '../../theme';
|
import { TSupportedThemes, useTheme } from '../../theme';
|
||||||
|
@ -139,7 +139,6 @@ const Button = React.memo(({ onPress, backgroundColor, underlayColor, ...props }
|
||||||
style={{ backgroundColor: backgroundColor || themes[props.theme].backgroundColor }}
|
style={{ backgroundColor: backgroundColor || themes[props.theme].backgroundColor }}
|
||||||
underlayColor={underlayColor}
|
underlayColor={underlayColor}
|
||||||
enabled={!props.disabled}
|
enabled={!props.disabled}
|
||||||
theme={props.theme}
|
|
||||||
>
|
>
|
||||||
<Content {...props} />
|
<Content {...props} />
|
||||||
</Touch>
|
</Touch>
|
||||||
|
|
|
@ -2,20 +2,19 @@ import React from 'react';
|
||||||
import { Text, View } from 'react-native';
|
import { Text, View } from 'react-native';
|
||||||
|
|
||||||
import { useTheme } from '../../theme';
|
import { useTheme } from '../../theme';
|
||||||
import Touch from '../../lib/methods/helpers/touch';
|
import Touch from '../Touch';
|
||||||
import { CustomIcon } from '../CustomIcon';
|
import { CustomIcon } from '../CustomIcon';
|
||||||
import { IButtonService } from './interfaces';
|
import { IButtonService } from './interfaces';
|
||||||
import styles from './styles';
|
import styles from './styles';
|
||||||
|
|
||||||
const ButtonService = ({ name, authType, onPress, backgroundColor, buttonText, icon }: IButtonService) => {
|
const ButtonService = ({ name, authType, onPress, backgroundColor, buttonText, icon }: IButtonService) => {
|
||||||
const { theme, colors } = useTheme();
|
const { colors } = useTheme();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Touch
|
<Touch
|
||||||
key={name}
|
key={name}
|
||||||
onPress={onPress}
|
onPress={onPress}
|
||||||
style={[styles.serviceButton, { backgroundColor }]}
|
style={[styles.serviceButton, { backgroundColor }]}
|
||||||
theme={theme}
|
|
||||||
activeOpacity={0.5}
|
activeOpacity={0.5}
|
||||||
underlayColor={colors.buttonText}
|
underlayColor={colors.buttonText}
|
||||||
>
|
>
|
||||||
|
|
|
@ -7,10 +7,10 @@ import { CustomIcon } from '../CustomIcon';
|
||||||
import shortnameToUnicode from '../../lib/methods/helpers/shortnameToUnicode';
|
import shortnameToUnicode from '../../lib/methods/helpers/shortnameToUnicode';
|
||||||
import CustomEmoji from '../EmojiPicker/CustomEmoji';
|
import CustomEmoji from '../EmojiPicker/CustomEmoji';
|
||||||
import database from '../../lib/database';
|
import database from '../../lib/database';
|
||||||
import { Button } from '../ActionSheet';
|
|
||||||
import { useDimensions } from '../../dimensions';
|
import { useDimensions } from '../../dimensions';
|
||||||
import sharedStyles from '../../views/Styles';
|
import sharedStyles from '../../views/Styles';
|
||||||
import { TAnyMessageModel, TFrequentlyUsedEmojiModel } from '../../definitions';
|
import { TAnyMessageModel, TFrequentlyUsedEmojiModel } from '../../definitions';
|
||||||
|
import Touch from '../Touch';
|
||||||
|
|
||||||
type TItem = TFrequentlyUsedEmojiModel | string;
|
type TItem = TFrequentlyUsedEmojiModel | string;
|
||||||
|
|
||||||
|
@ -75,30 +75,28 @@ const HeaderItem = ({ item, onReaction, server, theme }: THeaderItem) => {
|
||||||
const emojiModel = item as TFrequentlyUsedEmojiModel;
|
const emojiModel = item as TFrequentlyUsedEmojiModel;
|
||||||
const emoji = (emojiModel.id ? emojiModel.content : item) as string;
|
const emoji = (emojiModel.id ? emojiModel.content : item) as string;
|
||||||
return (
|
return (
|
||||||
<Button
|
<Touch
|
||||||
testID={`message-actions-emoji-${emoji}`}
|
testID={`message-actions-emoji-${emoji}`}
|
||||||
onPress={() => onReaction({ emoji: `:${emoji}:` })}
|
onPress={() => onReaction({ emoji: `:${emoji}:` })}
|
||||||
style={[styles.headerItem, { backgroundColor: themes[theme].auxiliaryBackground }]}
|
style={[styles.headerItem, { backgroundColor: themes[theme].auxiliaryBackground }]}
|
||||||
theme={theme}
|
|
||||||
>
|
>
|
||||||
{emojiModel?.isCustom ? (
|
{emojiModel?.isCustom ? (
|
||||||
<CustomEmoji style={styles.customEmoji} emoji={emojiModel} baseUrl={server} />
|
<CustomEmoji style={styles.customEmoji} emoji={emojiModel} baseUrl={server} />
|
||||||
) : (
|
) : (
|
||||||
<Text style={styles.headerIcon}>{shortnameToUnicode(`:${emoji}:`)}</Text>
|
<Text style={styles.headerIcon}>{shortnameToUnicode(`:${emoji}:`)}</Text>
|
||||||
)}
|
)}
|
||||||
</Button>
|
</Touch>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
const HeaderFooter = ({ onReaction, theme }: THeaderFooter) => (
|
const HeaderFooter = ({ onReaction, theme }: THeaderFooter) => (
|
||||||
<Button
|
<Touch
|
||||||
testID='add-reaction'
|
testID='add-reaction'
|
||||||
onPress={onReaction}
|
onPress={(param: any) => onReaction(param)}
|
||||||
style={[styles.headerItem, { backgroundColor: themes[theme].auxiliaryBackground }]}
|
style={[styles.headerItem, { backgroundColor: themes[theme].auxiliaryBackground }]}
|
||||||
theme={theme}
|
|
||||||
>
|
>
|
||||||
<CustomIcon name='reaction-add' size={24} color={themes[theme].bodyText} />
|
<CustomIcon name='reaction-add' size={24} color={themes[theme].bodyText} />
|
||||||
</Button>
|
</Touch>
|
||||||
);
|
);
|
||||||
|
|
||||||
const Header = React.memo(({ handleReaction, server, message, isMasterDetail }: IHeader) => {
|
const Header = React.memo(({ handleReaction, server, message, isMasterDetail }: IHeader) => {
|
||||||
|
|
|
@ -3,7 +3,7 @@ import { Text } from 'react-native';
|
||||||
|
|
||||||
import styles from './styles';
|
import styles from './styles';
|
||||||
import { themes } from '../../../lib/constants';
|
import { themes } from '../../../lib/constants';
|
||||||
import Touch from '../../../lib/methods/helpers/touch';
|
import Touch from '../../Touch';
|
||||||
import { CustomIcon, TIconsName } from '../../CustomIcon';
|
import { CustomIcon, TIconsName } from '../../CustomIcon';
|
||||||
import { useTheme } from '../../../theme';
|
import { useTheme } from '../../../theme';
|
||||||
|
|
||||||
|
@ -25,7 +25,6 @@ const Button = React.memo(({ text, disabled, onPress, icon }: IPasscodeButton) =
|
||||||
underlayColor={themes[theme].passcodeButtonActive}
|
underlayColor={themes[theme].passcodeButtonActive}
|
||||||
rippleColor={themes[theme].passcodeButtonActive}
|
rippleColor={themes[theme].passcodeButtonActive}
|
||||||
enabled={!disabled}
|
enabled={!disabled}
|
||||||
theme={theme}
|
|
||||||
onPress={press}
|
onPress={press}
|
||||||
>
|
>
|
||||||
{icon ? (
|
{icon ? (
|
||||||
|
|
|
@ -14,7 +14,7 @@ import {
|
||||||
PanGestureHandlerEventPayload
|
PanGestureHandlerEventPayload
|
||||||
} from 'react-native-gesture-handler';
|
} from 'react-native-gesture-handler';
|
||||||
|
|
||||||
import Touch from '../../lib/methods/helpers/touch';
|
import Touch from '../Touch';
|
||||||
import { ACTION_WIDTH, LONG_SWIPE, SMALL_SWIPE } from './styles';
|
import { ACTION_WIDTH, LONG_SWIPE, SMALL_SWIPE } from './styles';
|
||||||
import { LeftActions, RightActions } from './Actions';
|
import { LeftActions, RightActions } from './Actions';
|
||||||
import { ITouchableProps } from './interfaces';
|
import { ITouchableProps } from './interfaces';
|
||||||
|
@ -38,7 +38,7 @@ const Touchable = ({
|
||||||
swipeEnabled,
|
swipeEnabled,
|
||||||
displayMode
|
displayMode
|
||||||
}: ITouchableProps): React.ReactElement => {
|
}: ITouchableProps): React.ReactElement => {
|
||||||
const { theme, colors } = useTheme();
|
const { colors } = useTheme();
|
||||||
|
|
||||||
const rowOffSet = useSharedValue(0);
|
const rowOffSet = useSharedValue(0);
|
||||||
const transX = useSharedValue(0);
|
const transX = useSharedValue(0);
|
||||||
|
@ -221,7 +221,6 @@ const Touchable = ({
|
||||||
<Animated.View style={animatedStyles}>
|
<Animated.View style={animatedStyles}>
|
||||||
<Touch
|
<Touch
|
||||||
onPress={handlePress}
|
onPress={handlePress}
|
||||||
theme={theme}
|
|
||||||
testID={testID}
|
testID={testID}
|
||||||
style={{
|
style={{
|
||||||
backgroundColor: isFocused ? colors.chatComponentBackground : colors.backgroundColor
|
backgroundColor: isFocused ? colors.chatComponentBackground : colors.backgroundColor
|
||||||
|
|
|
@ -0,0 +1,29 @@
|
||||||
|
import React from 'react';
|
||||||
|
import { RectButton, RectButtonProps } from 'react-native-gesture-handler';
|
||||||
|
|
||||||
|
import { useTheme } from '../theme';
|
||||||
|
|
||||||
|
export interface ITouchProps extends RectButtonProps {
|
||||||
|
children: React.ReactNode;
|
||||||
|
accessibilityLabel?: string;
|
||||||
|
testID?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
const Touch = React.forwardRef<RectButton, ITouchProps>(({ children, onPress, underlayColor, ...props }, ref) => {
|
||||||
|
const { colors } = useTheme();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<RectButton
|
||||||
|
ref={ref}
|
||||||
|
onPress={onPress}
|
||||||
|
activeOpacity={1}
|
||||||
|
underlayColor={underlayColor || colors.bannerBackground}
|
||||||
|
rippleColor={colors.bannerBackground}
|
||||||
|
{...props}
|
||||||
|
>
|
||||||
|
{children}
|
||||||
|
</RectButton>
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
export default Touch;
|
|
@ -1,43 +0,0 @@
|
||||||
import React from 'react';
|
|
||||||
import { RectButton, RectButtonProps } from 'react-native-gesture-handler';
|
|
||||||
|
|
||||||
import { TSupportedThemes } from '../../../theme';
|
|
||||||
import { themes } from '../../constants';
|
|
||||||
|
|
||||||
interface ITouchProps extends RectButtonProps {
|
|
||||||
children: React.ReactNode;
|
|
||||||
theme: TSupportedThemes;
|
|
||||||
accessibilityLabel?: string;
|
|
||||||
testID?: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
class Touch extends React.Component<ITouchProps> {
|
|
||||||
private ref: any;
|
|
||||||
|
|
||||||
setNativeProps(props: ITouchProps): void {
|
|
||||||
this.ref.setNativeProps(props);
|
|
||||||
}
|
|
||||||
|
|
||||||
getRef = (ref: RectButton): void => {
|
|
||||||
this.ref = ref;
|
|
||||||
};
|
|
||||||
|
|
||||||
render(): JSX.Element {
|
|
||||||
const { children, onPress, theme, underlayColor, ...props } = this.props;
|
|
||||||
|
|
||||||
return (
|
|
||||||
<RectButton
|
|
||||||
ref={this.getRef}
|
|
||||||
onPress={onPress}
|
|
||||||
activeOpacity={1}
|
|
||||||
underlayColor={underlayColor || themes[theme].bannerBackground}
|
|
||||||
rippleColor={themes[theme].bannerBackground}
|
|
||||||
{...props}
|
|
||||||
>
|
|
||||||
{children}
|
|
||||||
</RectButton>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export default Touch;
|
|
|
@ -3,7 +3,7 @@ import { StyleSheet, Text, View } from 'react-native';
|
||||||
|
|
||||||
import { themes } from '../../../lib/constants';
|
import { themes } from '../../../lib/constants';
|
||||||
import { useTheme } from '../../../theme';
|
import { useTheme } from '../../../theme';
|
||||||
import Touch from '../../../lib/methods/helpers/touch';
|
import Touch from '../../../containers/Touch';
|
||||||
import { CustomIcon, TIconsName } from '../../../containers/CustomIcon';
|
import { CustomIcon, TIconsName } from '../../../containers/CustomIcon';
|
||||||
import sharedStyles from '../../Styles';
|
import sharedStyles from '../../Styles';
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ const DropdownItem = React.memo(({ onPress, iconName, text }: IDropdownItem) =>
|
||||||
const { theme } = useTheme();
|
const { theme } = useTheme();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Touch theme={theme} onPress={onPress} style={{ backgroundColor: themes[theme].backgroundColor }}>
|
<Touch onPress={onPress} style={{ backgroundColor: themes[theme].backgroundColor }}>
|
||||||
<View style={styles.container}>
|
<View style={styles.container}>
|
||||||
<Text style={[styles.text, { color: themes[theme].auxiliaryText }]}>{text}</Text>
|
<Text style={[styles.text, { color: themes[theme].auxiliaryText }]}>{text}</Text>
|
||||||
{iconName ? <CustomIcon name={iconName} size={22} color={themes[theme].auxiliaryText} /> : null}
|
{iconName ? <CustomIcon name={iconName} size={22} color={themes[theme].auxiliaryText} /> : null}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import React, { PureComponent } from 'react';
|
import React, { PureComponent } from 'react';
|
||||||
import { Animated, Easing, Switch, Text, TouchableWithoutFeedback, View } from 'react-native';
|
import { Animated, Easing, Switch, Text, TouchableWithoutFeedback, View } from 'react-native';
|
||||||
|
|
||||||
import Touch from '../../lib/methods/helpers/touch';
|
import Touch from '../../containers/Touch';
|
||||||
import { CustomIcon, TIconsName } from '../../containers/CustomIcon';
|
import { CustomIcon, TIconsName } from '../../containers/CustomIcon';
|
||||||
import Check from '../../containers/Check';
|
import Check from '../../containers/Check';
|
||||||
import I18n from '../../i18n';
|
import I18n from '../../i18n';
|
||||||
|
@ -64,12 +64,7 @@ export default class DirectoryOptions extends PureComponent<IDirectoryOptionsPro
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Touch
|
<Touch onPress={() => changeType(itemType)} style={styles.dropdownItemButton} accessibilityLabel={I18n.t(text)}>
|
||||||
onPress={() => changeType(itemType)}
|
|
||||||
style={styles.dropdownItemButton}
|
|
||||||
theme={theme}
|
|
||||||
accessibilityLabel={I18n.t(text)}
|
|
||||||
>
|
|
||||||
<View style={styles.dropdownItemContainer}>
|
<View style={styles.dropdownItemContainer}>
|
||||||
<CustomIcon name={icon} size={22} color={themes[theme].bodyText} style={styles.dropdownItemIcon} />
|
<CustomIcon name={icon} size={22} color={themes[theme].bodyText} style={styles.dropdownItemIcon} />
|
||||||
<Text style={[styles.dropdownItemText, { color: themes[theme].bodyText }]}>{I18n.t(text)}</Text>
|
<Text style={[styles.dropdownItemText, { color: themes[theme].bodyText }]}>{I18n.t(text)}</Text>
|
||||||
|
@ -97,7 +92,7 @@ export default class DirectoryOptions extends PureComponent<IDirectoryOptionsPro
|
||||||
<Animated.View
|
<Animated.View
|
||||||
style={[styles.dropdownContainer, { transform: [{ translateY }], backgroundColor: themes[theme].backgroundColor }]}
|
style={[styles.dropdownContainer, { transform: [{ translateY }], backgroundColor: themes[theme].backgroundColor }]}
|
||||||
>
|
>
|
||||||
<Touch onPress={this.close} theme={theme} accessibilityLabel={I18n.t('Search_by')}>
|
<Touch onPress={this.close} accessibilityLabel={I18n.t('Search_by')}>
|
||||||
<View
|
<View
|
||||||
style={[
|
style={[
|
||||||
styles.dropdownContainerHeader,
|
styles.dropdownContainerHeader,
|
||||||
|
|
|
@ -7,7 +7,7 @@ import { CompositeNavigationProp } from '@react-navigation/native';
|
||||||
import { ChatsStackParamList } from '../../stacks/types';
|
import { ChatsStackParamList } from '../../stacks/types';
|
||||||
import { MasterDetailInsideStackParamList } from '../../stacks/MasterDetailStack/types';
|
import { MasterDetailInsideStackParamList } from '../../stacks/MasterDetailStack/types';
|
||||||
import * as List from '../../containers/List';
|
import * as List from '../../containers/List';
|
||||||
import Touch from '../../lib/methods/helpers/touch';
|
import Touch from '../../containers/Touch';
|
||||||
import DirectoryItem from '../../containers/DirectoryItem';
|
import DirectoryItem from '../../containers/DirectoryItem';
|
||||||
import sharedStyles from '../Styles';
|
import sharedStyles from '../Styles';
|
||||||
import I18n from '../../i18n';
|
import I18n from '../../i18n';
|
||||||
|
@ -210,7 +210,7 @@ class DirectoryView extends React.Component<IDirectoryViewProps, IDirectoryViewS
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<SearchBox onChangeText={this.onSearchChangeText} onSubmitEditing={this.search} testID='directory-view-search' />
|
<SearchBox onChangeText={this.onSearchChangeText} onSubmitEditing={this.search} testID='directory-view-search' />
|
||||||
<Touch onPress={this.toggleDropdown} style={styles.dropdownItemButton} testID='directory-view-dropdown' theme={theme}>
|
<Touch onPress={this.toggleDropdown} style={styles.dropdownItemButton} testID='directory-view-dropdown'>
|
||||||
<View
|
<View
|
||||||
style={[
|
style={[
|
||||||
sharedStyles.separatorVertical,
|
sharedStyles.separatorVertical,
|
||||||
|
|
|
@ -21,7 +21,7 @@ import UserItem from '../containers/UserItem';
|
||||||
import { withTheme } from '../theme';
|
import { withTheme } from '../theme';
|
||||||
import { goRoom, TGoRoomItem } from '../lib/methods/helpers/goRoom';
|
import { goRoom, TGoRoomItem } from '../lib/methods/helpers/goRoom';
|
||||||
import log, { events, logEvent } from '../lib/methods/helpers/log';
|
import log, { events, logEvent } from '../lib/methods/helpers/log';
|
||||||
import Touch from '../lib/methods/helpers/touch';
|
import Touch from '../containers/Touch';
|
||||||
import sharedStyles from './Styles';
|
import sharedStyles from './Styles';
|
||||||
import { NewMessageStackParamList } from '../stacks/types';
|
import { NewMessageStackParamList } from '../stacks/types';
|
||||||
import { search } from '../lib/methods';
|
import { search } from '../lib/methods';
|
||||||
|
@ -180,7 +180,7 @@ class NewMessageView extends React.Component<INewMessageViewProps, INewMessageVi
|
||||||
renderButton = ({ onPress, testID, title, icon, first }: IButton) => {
|
renderButton = ({ onPress, testID, title, icon, first }: IButton) => {
|
||||||
const { theme } = this.props;
|
const { theme } = this.props;
|
||||||
return (
|
return (
|
||||||
<Touch onPress={onPress} style={{ backgroundColor: themes[theme].backgroundColor }} testID={testID} theme={theme}>
|
<Touch onPress={onPress} style={{ backgroundColor: themes[theme].backgroundColor }} testID={testID}>
|
||||||
<View
|
<View
|
||||||
style={[
|
style={[
|
||||||
first ? sharedStyles.separatorVertical : sharedStyles.separatorBottom,
|
first ? sharedStyles.separatorVertical : sharedStyles.separatorBottom,
|
||||||
|
|
|
@ -5,7 +5,7 @@ import { BorderlessButton } from 'react-native-gesture-handler';
|
||||||
import { themes } from '../../../lib/constants';
|
import { themes } from '../../../lib/constants';
|
||||||
import { CustomIcon } from '../../../containers/CustomIcon';
|
import { CustomIcon } from '../../../containers/CustomIcon';
|
||||||
import sharedStyles from '../../Styles';
|
import sharedStyles from '../../Styles';
|
||||||
import Touch from '../../../lib/methods/helpers/touch';
|
import Touch from '../../../containers/Touch';
|
||||||
import { TServerHistoryModel } from '../../../definitions/IServerHistory';
|
import { TServerHistoryModel } from '../../../definitions/IServerHistory';
|
||||||
import { TSupportedThemes } from '../../../theme';
|
import { TSupportedThemes } from '../../../theme';
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ interface IItem {
|
||||||
}
|
}
|
||||||
|
|
||||||
const Item = ({ item, theme, onPress, onDelete }: IItem): JSX.Element => (
|
const Item = ({ item, theme, onPress, onDelete }: IItem): JSX.Element => (
|
||||||
<Touch style={styles.container} onPress={() => onPress(item.url)} theme={theme} testID={`server-history-${item.url}`}>
|
<Touch style={styles.container} onPress={() => onPress(item.url)} testID={`server-history-${item.url}`}>
|
||||||
<View style={styles.content}>
|
<View style={styles.content}>
|
||||||
<Text numberOfLines={1} style={[styles.server, { color: themes[theme].bodyText }]}>
|
<Text numberOfLines={1} style={[styles.server, { color: themes[theme].bodyText }]}>
|
||||||
{item.url}
|
{item.url}
|
||||||
|
|
|
@ -8,7 +8,7 @@ import { dequal } from 'dequal';
|
||||||
import omit from 'lodash/omit';
|
import omit from 'lodash/omit';
|
||||||
import { StackNavigationOptions } from '@react-navigation/stack';
|
import { StackNavigationOptions } from '@react-navigation/stack';
|
||||||
|
|
||||||
import Touch from '../../lib/methods/helpers/touch';
|
import Touch from '../../containers/Touch';
|
||||||
import KeyboardView from '../../containers/KeyboardView';
|
import KeyboardView from '../../containers/KeyboardView';
|
||||||
import sharedStyles from '../Styles';
|
import sharedStyles from '../Styles';
|
||||||
import scrollPersistTaps from '../../lib/methods/helpers/scrollPersistTaps';
|
import scrollPersistTaps from '../../lib/methods/helpers/scrollPersistTaps';
|
||||||
|
@ -376,7 +376,6 @@ class ProfileView extends React.Component<IProfileViewProps, IProfileViewState>
|
||||||
onPress={onPress}
|
onPress={onPress}
|
||||||
style={[styles.avatarButton, { opacity: disabled ? 0.5 : 1 }, { backgroundColor: themes[theme].borderColor }]}
|
style={[styles.avatarButton, { opacity: disabled ? 0.5 : 1 }, { backgroundColor: themes[theme].borderColor }]}
|
||||||
enabled={!disabled}
|
enabled={!disabled}
|
||||||
theme={theme}
|
|
||||||
>
|
>
|
||||||
{child}
|
{child}
|
||||||
</Touch>
|
</Touch>
|
||||||
|
|
|
@ -28,7 +28,7 @@ import { ChatsStackParamList } from '../../stacks/types';
|
||||||
import { withTheme } from '../../theme';
|
import { withTheme } from '../../theme';
|
||||||
import { showConfirmationAlert, showErrorAlert } from '../../lib/methods/helpers/info';
|
import { showConfirmationAlert, showErrorAlert } from '../../lib/methods/helpers/info';
|
||||||
import log, { events, logEvent } from '../../lib/methods/helpers/log';
|
import log, { events, logEvent } from '../../lib/methods/helpers/log';
|
||||||
import Touch from '../../lib/methods/helpers/touch';
|
import Touch from '../../containers/Touch';
|
||||||
import sharedStyles from '../Styles';
|
import sharedStyles from '../Styles';
|
||||||
import styles from './styles';
|
import styles from './styles';
|
||||||
import { ERoomType } from '../../definitions/ERoomType';
|
import { ERoomType } from '../../definitions/ERoomType';
|
||||||
|
@ -807,7 +807,6 @@ class RoomActionsView extends React.Component<IRoomActionsViewProps, IRoomAction
|
||||||
accessibilityLabel={I18n.t('Room_Info')}
|
accessibilityLabel={I18n.t('Room_Info')}
|
||||||
enabled={!isGroupChatHandler}
|
enabled={!isGroupChatHandler}
|
||||||
testID='room-actions-info'
|
testID='room-actions-info'
|
||||||
theme={theme}
|
|
||||||
>
|
>
|
||||||
<View style={[styles.roomInfoContainer, { height: 72 * fontScale }]}>
|
<View style={[styles.roomInfoContainer, { height: 72 * fontScale }]}>
|
||||||
<Avatar text={avatar} style={styles.avatar} size={50 * fontScale} type={t} rid={rid}>
|
<Avatar text={avatar} style={styles.avatar} size={50 * fontScale} type={t} rid={rid}>
|
||||||
|
|
|
@ -5,7 +5,7 @@ import Animated, { call, cond, greaterOrEq, useCode } from 'react-native-reanima
|
||||||
import { themes } from '../../../lib/constants';
|
import { themes } from '../../../lib/constants';
|
||||||
import { CustomIcon } from '../../../containers/CustomIcon';
|
import { CustomIcon } from '../../../containers/CustomIcon';
|
||||||
import { useTheme } from '../../../theme';
|
import { useTheme } from '../../../theme';
|
||||||
import Touch from '../../../lib/methods/helpers/touch';
|
import Touch from '../../../containers/Touch';
|
||||||
import { hasNotch } from '../../../lib/methods/helpers';
|
import { hasNotch } from '../../../lib/methods/helpers';
|
||||||
|
|
||||||
const SCROLL_LIMIT = 200;
|
const SCROLL_LIMIT = 200;
|
||||||
|
@ -63,7 +63,7 @@ const NavBottomFAB = ({
|
||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
<Animated.View style={[styles.container, { bottom }]} testID='nav-jump-to-bottom'>
|
<Animated.View style={[styles.container, { bottom }]} testID='nav-jump-to-bottom'>
|
||||||
<Touch onPress={handleOnPress} theme={theme} style={[styles.button, { backgroundColor: themes[theme].backgroundColor }]}>
|
<Touch onPress={handleOnPress} style={[styles.button, { backgroundColor: themes[theme].backgroundColor }]}>
|
||||||
<View style={[styles.content, { borderColor: themes[theme].borderColor }]}>
|
<View style={[styles.content, { borderColor: themes[theme].borderColor }]}>
|
||||||
<CustomIcon name='chevron-down' color={themes[theme].auxiliaryTintColor} size={36} />
|
<CustomIcon name='chevron-down' color={themes[theme].auxiliaryTintColor} size={36} />
|
||||||
</View>
|
</View>
|
||||||
|
|
|
@ -24,7 +24,7 @@ stories.add('basic', () => (
|
||||||
));
|
));
|
||||||
|
|
||||||
const ThemeStory = ({ theme }) => (
|
const ThemeStory = ({ theme }) => (
|
||||||
<ThemeContext.Provider value={{ theme }}>
|
<ThemeContext.Provider value={{ theme, colors: themes[theme] }}>
|
||||||
<ScrollView style={{ backgroundColor: themes[theme].backgroundColor }}>
|
<ScrollView style={{ backgroundColor: themes[theme].backgroundColor }}>
|
||||||
<LoadMore load={load} type={MessageTypeLoad.PREVIOUS_CHUNK} />
|
<LoadMore load={load} type={MessageTypeLoad.PREVIOUS_CHUNK} />
|
||||||
<Message msg='Hey!' theme={theme} />
|
<Message msg='Hey!' theme={theme} />
|
||||||
|
|
|
@ -4,7 +4,7 @@ import { ActivityIndicator, StyleSheet, Text } from 'react-native';
|
||||||
import { MessageTypeLoad, themes } from '../../../lib/constants';
|
import { MessageTypeLoad, themes } from '../../../lib/constants';
|
||||||
import { MessageType } from '../../../definitions';
|
import { MessageType } from '../../../definitions';
|
||||||
import { useTheme } from '../../../theme';
|
import { useTheme } from '../../../theme';
|
||||||
import Touch from '../../../lib/methods/helpers/touch';
|
import Touch from '../../../containers/Touch';
|
||||||
import sharedStyles from '../../Styles';
|
import sharedStyles from '../../Styles';
|
||||||
import I18n from '../../../i18n';
|
import I18n from '../../../i18n';
|
||||||
|
|
||||||
|
@ -59,7 +59,7 @@ const LoadMore = ({
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Touch onPress={handleLoad} style={styles.button} theme={theme} enabled={!loading}>
|
<Touch onPress={handleLoad} style={styles.button} enabled={!loading}>
|
||||||
{loading ? (
|
{loading ? (
|
||||||
<ActivityIndicator color={themes[theme].auxiliaryText} />
|
<ActivityIndicator color={themes[theme].auxiliaryText} />
|
||||||
) : (
|
) : (
|
||||||
|
|
|
@ -9,7 +9,7 @@ import { EdgeInsets, withSafeAreaInsets } from 'react-native-safe-area-context';
|
||||||
import { Subscription } from 'rxjs';
|
import { Subscription } from 'rxjs';
|
||||||
|
|
||||||
import { getRoutingConfig } from '../../lib/services/restApi';
|
import { getRoutingConfig } from '../../lib/services/restApi';
|
||||||
import Touch from '../../lib/methods/helpers/touch';
|
import Touch from '../../containers/Touch';
|
||||||
import { replyBroadcast } from '../../actions/messages';
|
import { replyBroadcast } from '../../actions/messages';
|
||||||
import database from '../../lib/database';
|
import database from '../../lib/database';
|
||||||
import Message from '../../containers/message';
|
import Message from '../../containers/message';
|
||||||
|
@ -1385,7 +1385,6 @@ class RoomView extends React.Component<IRoomViewProps, IRoomViewState> {
|
||||||
onPress={this.resumeRoom}
|
onPress={this.resumeRoom}
|
||||||
style={[styles.joinRoomButton, { backgroundColor: themes[theme].actionTintColor }]}
|
style={[styles.joinRoomButton, { backgroundColor: themes[theme].actionTintColor }]}
|
||||||
enabled={!loading}
|
enabled={!loading}
|
||||||
theme={theme}
|
|
||||||
>
|
>
|
||||||
<Text style={[styles.joinRoomText, { color: themes[theme].buttonText }]} testID='room-view-chat-on-hold-button'>
|
<Text style={[styles.joinRoomText, { color: themes[theme].buttonText }]} testID='room-view-chat-on-hold-button'>
|
||||||
{I18n.t('Resume')}
|
{I18n.t('Resume')}
|
||||||
|
@ -1407,7 +1406,6 @@ class RoomView extends React.Component<IRoomViewProps, IRoomViewState> {
|
||||||
onPress={this.joinRoom}
|
onPress={this.joinRoom}
|
||||||
style={[styles.joinRoomButton, { backgroundColor: themes[theme].actionTintColor }]}
|
style={[styles.joinRoomButton, { backgroundColor: themes[theme].actionTintColor }]}
|
||||||
enabled={!loading}
|
enabled={!loading}
|
||||||
theme={theme}
|
|
||||||
>
|
>
|
||||||
<Text style={[styles.joinRoomText, { color: themes[theme].buttonText }]} testID='room-view-join-button'>
|
<Text style={[styles.joinRoomText, { color: themes[theme].buttonText }]} testID='room-view-join-button'>
|
||||||
{I18n.t(this.isOmnichannel ? 'Take_it' : 'Join')}
|
{I18n.t(this.isOmnichannel ? 'Take_it' : 'Join')}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { Text, View } from 'react-native';
|
import { Text, View } from 'react-native';
|
||||||
|
|
||||||
import Touch from '../../lib/methods/helpers/touch';
|
import Touch from '../../containers/Touch';
|
||||||
import { themes } from '../../lib/constants';
|
import { themes } from '../../lib/constants';
|
||||||
import { TSupportedThemes, withTheme } from '../../theme';
|
import { TSupportedThemes, withTheme } from '../../theme';
|
||||||
import styles from './styles';
|
import styles from './styles';
|
||||||
|
@ -21,7 +21,6 @@ const Item = React.memo(({ left, right, text, onPress, testID, current, theme }:
|
||||||
key={testID}
|
key={testID}
|
||||||
testID={testID}
|
testID={testID}
|
||||||
onPress={onPress}
|
onPress={onPress}
|
||||||
theme={theme}
|
|
||||||
style={[styles.item, current && { backgroundColor: themes[theme].borderColor }]}
|
style={[styles.item, current && { backgroundColor: themes[theme].borderColor }]}
|
||||||
>
|
>
|
||||||
<View style={styles.itemHorizontal}>{left}</View>
|
<View style={styles.itemHorizontal}>{left}</View>
|
||||||
|
|
|
@ -2,7 +2,7 @@ import React from 'react';
|
||||||
import { StyleSheet, Text, View } from 'react-native';
|
import { StyleSheet, Text, View } from 'react-native';
|
||||||
|
|
||||||
import { useTheme } from '../../../theme';
|
import { useTheme } from '../../../theme';
|
||||||
import Touch from '../../../lib/methods/helpers/touch';
|
import Touch from '../../../containers/Touch';
|
||||||
import { CustomIcon, TIconsName } from '../../../containers/CustomIcon';
|
import { CustomIcon, TIconsName } from '../../../containers/CustomIcon';
|
||||||
import sharedStyles from '../../Styles';
|
import sharedStyles from '../../Styles';
|
||||||
|
|
||||||
|
@ -28,9 +28,9 @@ interface IDropdownItem {
|
||||||
}
|
}
|
||||||
|
|
||||||
const DropdownItem = React.memo(({ onPress, iconName, text }: IDropdownItem) => {
|
const DropdownItem = React.memo(({ onPress, iconName, text }: IDropdownItem) => {
|
||||||
const { colors, theme } = useTheme();
|
const { colors } = useTheme();
|
||||||
return (
|
return (
|
||||||
<Touch theme={theme} onPress={onPress} style={{ backgroundColor: colors.backgroundColor }}>
|
<Touch onPress={onPress} style={{ backgroundColor: colors.backgroundColor }}>
|
||||||
<View style={styles.container}>
|
<View style={styles.container}>
|
||||||
<Text style={[styles.text, { color: colors.auxiliaryText }]}>{text}</Text>
|
<Text style={[styles.text, { color: colors.auxiliaryText }]}>{text}</Text>
|
||||||
{iconName ? <CustomIcon name={iconName} size={22} color={colors.auxiliaryText} /> : null}
|
{iconName ? <CustomIcon name={iconName} size={22} color={colors.auxiliaryText} /> : null}
|
||||||
|
|
|
@ -8,6 +8,7 @@ import SafeAreaView from '../../app/containers/SafeAreaView';
|
||||||
import { longText } from '../utils';
|
import { longText } from '../utils';
|
||||||
import { ThemeContext } from '../../app/theme';
|
import { ThemeContext } from '../../app/theme';
|
||||||
import { DimensionsContext } from '../../app/dimensions';
|
import { DimensionsContext } from '../../app/dimensions';
|
||||||
|
import { themes } from '../../app/lib/constants';
|
||||||
|
|
||||||
const stories = storiesOf('List', module);
|
const stories = storiesOf('List', module);
|
||||||
|
|
||||||
|
@ -176,7 +177,7 @@ const ListFull = () => (
|
||||||
);
|
);
|
||||||
|
|
||||||
const ThemeStory = ({ theme }) => (
|
const ThemeStory = ({ theme }) => (
|
||||||
<ThemeContext.Provider value={{ theme }}>
|
<ThemeContext.Provider value={{ theme, colors: themes[theme] }}>
|
||||||
<ListFull />
|
<ListFull />
|
||||||
</ThemeContext.Provider>
|
</ThemeContext.Provider>
|
||||||
);
|
);
|
||||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue