Minor tweaks for refactored touch component
This commit is contained in:
parent
7d2924e2e9
commit
4bac054105
|
@ -7439,11 +7439,10 @@ exports[`Storyshots List with custom colors 1`] = `
|
||||||
style={
|
style={
|
||||||
Array [
|
Array [
|
||||||
Object {
|
Object {
|
||||||
"backgroundColor": "#ffffff",
|
"backgroundColor": "red",
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
underlayColor="green"
|
|
||||||
>
|
>
|
||||||
<View
|
<View
|
||||||
style={
|
style={
|
||||||
|
|
|
@ -79,11 +79,11 @@ const Content = React.memo(({
|
||||||
));
|
));
|
||||||
|
|
||||||
const Button = React.memo(({
|
const Button = React.memo(({
|
||||||
onPress, underlayColor, ...props
|
onPress, backgroundColor, underlayColor, ...props
|
||||||
}) => (
|
}) => (
|
||||||
<Touch
|
<Touch
|
||||||
onPress={() => onPress(props.title)}
|
onPress={() => onPress(props.title)}
|
||||||
underlayColor={underlayColor}
|
style={({ pressed }) => [{ backgroundColor: pressed ? underlayColor || themes[props.theme].bannerBackground : backgroundColor || themes[props.theme].backgroundColor }]}
|
||||||
enabled={!props.disabled}
|
enabled={!props.disabled}
|
||||||
theme={props.theme}
|
theme={props.theme}
|
||||||
>
|
>
|
||||||
|
|
|
@ -7,6 +7,7 @@ import { connect } from 'react-redux';
|
||||||
import { Base64 } from 'js-base64';
|
import { Base64 } from 'js-base64';
|
||||||
import * as AppleAuthentication from 'expo-apple-authentication';
|
import * as AppleAuthentication from 'expo-apple-authentication';
|
||||||
|
|
||||||
|
import { transparentize } from 'color2k';
|
||||||
import { withTheme } from '../theme';
|
import { withTheme } from '../theme';
|
||||||
import sharedStyles from '../views/Styles';
|
import sharedStyles from '../views/Styles';
|
||||||
import { themes } from '../constants/colors';
|
import { themes } from '../constants/colors';
|
||||||
|
@ -344,10 +345,8 @@ class LoginServices extends React.PureComponent {
|
||||||
<Touch
|
<Touch
|
||||||
key={service.name}
|
key={service.name}
|
||||||
onPress={onPress}
|
onPress={onPress}
|
||||||
style={[styles.serviceButton, { backgroundColor }]}
|
style={({ pressed }) => [styles.serviceButton, { backgroundColor: pressed ? transparentize(themes[theme].buttonText, 0.5) : backgroundColor }]}
|
||||||
theme={theme}
|
theme={theme}
|
||||||
activeOpacity={0.5}
|
|
||||||
underlayColor={themes[theme].buttonText}
|
|
||||||
>
|
>
|
||||||
<View style={styles.serviceButtonContainer}>
|
<View style={styles.serviceButtonContainer}>
|
||||||
{service.authType === 'oauth' || service.authType === 'apple' ? <CustomIcon name={icon} size={24} color={themes[theme].titleText} style={styles.serviceIcon} /> : null}
|
{service.authType === 'oauth' || service.authType === 'apple' ? <CustomIcon name={icon} size={24} color={themes[theme].titleText} style={styles.serviceIcon} /> : null}
|
||||||
|
|
|
@ -14,7 +14,7 @@ const Button = React.memo(({
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Touch
|
<Touch
|
||||||
style={[styles.buttonView, { backgroundColor: 'transparent' }]}
|
style={({ pressed }) => [styles.buttonView, { backgroundColor: pressed ? 'transparent' : themes[theme].bannerBackground }]}
|
||||||
underlayColor={themes[theme].passcodeButtonActive}
|
underlayColor={themes[theme].passcodeButtonActive}
|
||||||
rippleColor={themes[theme].passcodeButtonActive}
|
rippleColor={themes[theme].passcodeButtonActive}
|
||||||
enabled={!disabled}
|
enabled={!disabled}
|
||||||
|
|
|
@ -10,6 +10,7 @@ import {
|
||||||
LONG_SWIPE
|
LONG_SWIPE
|
||||||
} from './styles';
|
} from './styles';
|
||||||
import { isRTL } from '../../i18n';
|
import { isRTL } from '../../i18n';
|
||||||
|
import { themes } from '../../constants/colors';
|
||||||
import { LeftActions, RightActions } from './Actions';
|
import { LeftActions, RightActions } from './Actions';
|
||||||
|
|
||||||
class Touchable extends React.Component {
|
class Touchable extends React.Component {
|
||||||
|
@ -253,6 +254,7 @@ class Touchable extends React.Component {
|
||||||
onLongPress={this.onLongPress}
|
onLongPress={this.onLongPress}
|
||||||
theme={theme}
|
theme={theme}
|
||||||
testID={testID}
|
testID={testID}
|
||||||
|
style={({ pressed }) => [{ backgroundColor: pressed ? themes[theme].chatComponentBackground : themes[theme].backgroundColor }]}
|
||||||
>
|
>
|
||||||
{children}
|
{children}
|
||||||
</Touch>
|
</Touch>
|
||||||
|
|
|
@ -15,7 +15,7 @@ class Touch extends React.Component {
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const {
|
const {
|
||||||
children, onPress, onLongPress, theme, ...props
|
children, onPress, onLongPress, theme, style, ...props
|
||||||
} = this.props;
|
} = this.props;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@ -24,9 +24,7 @@ class Touch extends React.Component {
|
||||||
onPress={onPress}
|
onPress={onPress}
|
||||||
onLongPress={onLongPress}
|
onLongPress={onLongPress}
|
||||||
activeOpacity={1}
|
activeOpacity={1}
|
||||||
style={({ pressed }) => [{
|
style={style}
|
||||||
backgroundColor: pressed ? themes[theme].chatComponentBackground : themes[theme].backgroundColor
|
|
||||||
}]}
|
|
||||||
android_ripple={{ color: themes[theme].bannerBackground }}
|
android_ripple={{ color: themes[theme].bannerBackground }}
|
||||||
{...props}
|
{...props}
|
||||||
>
|
>
|
||||||
|
@ -41,7 +39,8 @@ Touch.propTypes = {
|
||||||
onPress: PropTypes.func,
|
onPress: PropTypes.func,
|
||||||
onLongPress: PropTypes.func,
|
onLongPress: PropTypes.func,
|
||||||
theme: PropTypes.string,
|
theme: PropTypes.string,
|
||||||
underlayColor: PropTypes.string
|
underlayColor: PropTypes.string,
|
||||||
|
style: PropTypes.object
|
||||||
};
|
};
|
||||||
|
|
||||||
export default Touch;
|
export default Touch;
|
||||||
|
|
|
@ -72,6 +72,9 @@ class AddChannelTeamView extends React.Component {
|
||||||
return (
|
return (
|
||||||
<Touch
|
<Touch
|
||||||
onPress={onPress}
|
onPress={onPress}
|
||||||
|
style={({ pressed }) => [{
|
||||||
|
backgroundColor: pressed ? themes[theme].chatComponentBackground : themes[theme].backgroundColor
|
||||||
|
}]}
|
||||||
testID={testID}
|
testID={testID}
|
||||||
theme={theme}
|
theme={theme}
|
||||||
>
|
>
|
||||||
|
|
|
@ -67,7 +67,7 @@ export default class DirectoryOptions extends PureComponent {
|
||||||
return (
|
return (
|
||||||
<Touch
|
<Touch
|
||||||
onPress={() => changeType(itemType)}
|
onPress={() => changeType(itemType)}
|
||||||
style={styles.dropdownItemButton}
|
style={({ pressed }) => [{ backgroundColor: pressed ? themes[theme].bannerBackground : themes[theme].backgroundColor }, styles.dropdownItemButton]}
|
||||||
theme={theme}
|
theme={theme}
|
||||||
>
|
>
|
||||||
<View style={styles.dropdownItemContainer}>
|
<View style={styles.dropdownItemContainer}>
|
||||||
|
|
|
@ -169,7 +169,7 @@ class DirectoryView extends React.Component {
|
||||||
/>
|
/>
|
||||||
<Touch
|
<Touch
|
||||||
onPress={this.toggleDropdown}
|
onPress={this.toggleDropdown}
|
||||||
style={styles.dropdownItemButton}
|
style={({ pressed }) => [{ backgroundColor: pressed ? themes[theme].bannerBackground : themes[theme].backgroundColor }, styles.dropdownItemButton]}
|
||||||
testID='directory-view-dropdown'
|
testID='directory-view-dropdown'
|
||||||
theme={theme}
|
theme={theme}
|
||||||
>
|
>
|
||||||
|
|
|
@ -148,6 +148,9 @@ class NewMessageView extends React.Component {
|
||||||
return (
|
return (
|
||||||
<Touch
|
<Touch
|
||||||
onPress={onPress}
|
onPress={onPress}
|
||||||
|
style={({ pressed }) => [{
|
||||||
|
backgroundColor: pressed ? themes[theme].bannerBackground : themes[theme].backgroundColor
|
||||||
|
}]}
|
||||||
testID={testID}
|
testID={testID}
|
||||||
theme={theme}
|
theme={theme}
|
||||||
>
|
>
|
||||||
|
|
|
@ -309,7 +309,7 @@ class ProfileView extends React.Component {
|
||||||
key={key}
|
key={key}
|
||||||
testID={key}
|
testID={key}
|
||||||
onPress={onPress}
|
onPress={onPress}
|
||||||
style={[styles.avatarButton, { opacity: disabled ? 0.5 : 1 }, { backgroundColor: themes[theme].borderColor }]}
|
style={({ pressed }) => [styles.avatarButton, { opacity: disabled ? 0.5 : 1 }, { backgroundColor: pressed ? themes[theme].borderColor : themes[theme].bannerBackground }]}
|
||||||
enabled={!disabled}
|
enabled={!disabled}
|
||||||
theme={theme}
|
theme={theme}
|
||||||
>
|
>
|
||||||
|
|
|
@ -433,7 +433,7 @@ class RoomActionsView extends React.Component {
|
||||||
rid, t, room, member
|
rid, t, room, member
|
||||||
}
|
}
|
||||||
})}
|
})}
|
||||||
style={{ backgroundColor: themes[theme].backgroundColor }}
|
style={({ pressed }) => [{ backgroundColor: pressed ? themes[theme].bannerBackground : themes[theme].backgroundColor }]}
|
||||||
accessibilityLabel={I18n.t('Room_Info')}
|
accessibilityLabel={I18n.t('Room_Info')}
|
||||||
accessibilityTraits='button'
|
accessibilityTraits='button'
|
||||||
enabled={!isGroupChat}
|
enabled={!isGroupChat}
|
||||||
|
|
|
@ -15,7 +15,7 @@ const Item = React.memo(({
|
||||||
testID={testID}
|
testID={testID}
|
||||||
onPress={onPress}
|
onPress={onPress}
|
||||||
theme={theme}
|
theme={theme}
|
||||||
style={[styles.item, current && { backgroundColor: themes[theme].borderColor }]}
|
style={({ pressed }) => [styles.item, current && { backgroundColor: pressed ? themes[theme].borderColor : themes[theme].bannerBackground }]}
|
||||||
>
|
>
|
||||||
<View style={styles.itemHorizontal}>
|
<View style={styles.itemHorizontal}>
|
||||||
{left}
|
{left}
|
||||||
|
|
|
@ -26,7 +26,7 @@ const styles = StyleSheet.create({
|
||||||
const DropdownItem = React.memo(({
|
const DropdownItem = React.memo(({
|
||||||
theme, onPress, iconName, text
|
theme, onPress, iconName, text
|
||||||
}) => (
|
}) => (
|
||||||
<Touch theme={theme} onPress={onPress} style={{ backgroundColor: themes[theme].backgroundColor }}>
|
<Touch theme={theme} onPress={onPress} style={({ pressed }) => [{ backgroundColor: pressed ? themes[theme].bannerBackground : 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}
|
||||||
|
|
Loading…
Reference in New Issue