Skip to content

Commit 9fdadea

Browse files
committed
use Touchable instead of TouchableOpacity
1 parent 6f9ab33 commit 9fdadea

File tree

3 files changed

+17
-5
lines changed

3 files changed

+17
-5
lines changed

source/views/components/filter/filter-popover.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@ import {StyleSheet, View, TouchableOpacity} from 'react-native'
44
import Popover from 'react-native-popover-view'
55
import {FilterSection} from './section'
66
import type {FilterType} from './types'
7+
import {Touchable, type TouchableUnion} from '../touchable'
78
import * as c from '../colors'
89

910
type Props = {
10-
anchor: React.Ref<typeof TouchableOpacity>,
11+
anchor: ?React.Ref<TouchableUnion>,
1112
filter: FilterType,
1213
onClosePopover: (filter: FilterType) => any,
1314
visible: boolean,

source/views/components/filter/filter-toolbar-button.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import Icon from 'react-native-vector-icons/Ionicons'
55
import type {FilterType} from './types'
66
import {FilterPopover} from './filter-popover'
77
import * as c from '../colors'
8+
import {Touchable, type TouchableUnion} from '../touchable'
89

910
const buttonStyles = StyleSheet.create({
1011
button: {
@@ -51,7 +52,7 @@ type State = {
5152
}
5253

5354
export class FilterToolbarButton extends React.PureComponent<Props, State> {
54-
touchable: TouchableOpacity
55+
touchable: ?TouchableUnion = null
5556

5657
state = {
5758
popoverVisible: false,
@@ -101,14 +102,15 @@ export class FilterToolbarButton extends React.PureComponent<Props, State> {
101102

102103
return (
103104
<React.Fragment>
104-
<TouchableOpacity
105-
ref={ref => (this.touchable = ref)}
105+
<Touchable
106+
getRef={ref => (this.touchable = ref)}
107+
highlight={false}
106108
onPress={this.openPopover}
107109
style={[buttonStyles.button, activeButtonStyle, style]}
108110
>
109111
<Text style={buttonTextStyle}>{title}</Text>
110112
<Icon name={icon} size={18} style={activeContentStyle} />
111-
</TouchableOpacity>
113+
</Touchable>
112114
<FilterPopover
113115
anchor={this.touchable}
114116
filter={filter}

source/views/components/touchable.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ import {
99
View,
1010
} from 'react-native'
1111

12+
export type TouchableUnion =
13+
| typeof TouchableHighlight
14+
| typeof TouchableOpacity
15+
| typeof TouchableNativeFeedback
16+
1217
type Props = {|
1318
accessibilityComponentType?: string,
1419
accessibilityLabel?: string,
@@ -17,6 +22,7 @@ type Props = {|
1722
borderless?: boolean,
1823
children?: React.Node,
1924
containerStyle?: any,
25+
getRef?: () => TouchableUnion,
2026
highlight?: boolean,
2127
onPress?: () => any,
2228
style?: any,
@@ -27,6 +33,7 @@ export const Touchable = ({
2733
borderless = false,
2834
children,
2935
containerStyle,
36+
getRef,
3037
highlight = true,
3138
onPress = () => {},
3239
style,
@@ -45,6 +52,7 @@ export const Touchable = ({
4552

4653
return (
4754
<Component
55+
ref={getRef}
4856
onPress={onPress}
4957
{...innerProps}
5058
style={containerStyle}
@@ -64,6 +72,7 @@ export const Touchable = ({
6472

6573
return (
6674
<TouchableNativeFeedback
75+
ref={getRef}
6776
background={background}
6877
onPress={onPress}
6978
style={containerStyle}

0 commit comments

Comments
 (0)