Commit a2aeaf3987d8da62974964fcab5948ef6deef6ae
dx: [ios] fix ToggleButton's touchables
Andre Staltz committed on 1/4/2020, 2:37:13 PMParent: 422ca0486fe96d4d967d40fdeb5944843152e4f4
Files changed
src/frontend/components/ToggleButton.ts | changed |
src/frontend/components/ToggleButton.ts | ||
---|---|---|
@@ -12,14 +12,21 @@ | ||
12 | 12 | StyleProp, |
13 | 13 | ViewStyle, |
14 | 14 | StyleSheet, |
15 | 15 | TextStyle, |
16 | + Platform, | |
17 | + TouchableOpacity, | |
16 | 18 | } from 'react-native'; |
17 | 19 | import {Palette} from '../global-styles/palette'; |
18 | 20 | import {h} from '@cycle/react'; |
19 | 21 | import {Typography} from '../global-styles/typography'; |
20 | 22 | import {Dimensions} from '../global-styles/dimens'; |
21 | 23 | |
24 | +const Touchable = Platform.select<any>({ | |
25 | + android: TouchableNativeFeedback, | |
26 | + default: TouchableOpacity, | |
27 | +}); | |
28 | + | |
22 | 29 | export const baseContainerStyle = { |
23 | 30 | borderTopLeftRadius: 3, |
24 | 31 | borderTopRightRadius: 3, |
25 | 32 | borderBottomLeftRadius: 3, |
@@ -118,14 +125,16 @@ | ||
118 | 125 | if (toggled === 'maybe' || toggled === 'yes') { |
119 | 126 | textStyle = styles.textToggled; |
120 | 127 | } |
121 | 128 | |
122 | - const touchableProps = { | |
123 | - background: TouchableNativeFeedback.SelectableBackground(), | |
129 | + const touchableProps: any = { | |
124 | 130 | onPress: () => this._onPress(), |
125 | 131 | }; |
132 | + if (Platform.OS === 'android') { | |
133 | + touchableProps.background = TouchableNativeFeedback.SelectableBackground(); | |
134 | + } | |
126 | 135 | |
127 | - return h(TouchableNativeFeedback, touchableProps, [ | |
136 | + return h(Touchable, touchableProps, [ | |
128 | 137 | h(View, {style: [containerStyle, style]}, [ |
129 | 138 | h(Text, {style: textStyle}, text), |
130 | 139 | ]), |
131 | 140 | ]); |
Built with git-ssb-web