Skip to content

Commit a37ce1e

Browse files
committed
Centering and shadows on android fixed with prop fixNativeFeedbackRadius.
When setting fixNativeFeedbackRadius to true and giving the ActionButton position 'Center'. The AtionButton and ActionButtonItems would have an offset from the center due to incorrect styling. fixNativeFeedbackRadius also caused an ugly shadow on ActionButtonItems and their respective lable, and also a cropped dropshadow. For the ActionButtonItem, this was due to the shadow styling was set on the wrong element for android. As for the lable, we do not need to set the fixNativeFeedbackRadius to the touchableBackground (the lable is rectangular anyway). You'll notice that the ripple effect on the lable would extend in a circular fashion outside the borders of the lable.
1 parent a73637c commit a37ce1e

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

ActionButton.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ export default class ActionButton extends Component {
180180
const parentStyle = isAndroid &&
181181
this.props.fixNativeFeedbackRadius
182182
? {
183-
right: this.props.offsetX,
183+
marginHorizontal: this.props.offsetX,
184184
zIndex: this.props.zIndex,
185185
borderRadius: this.props.size / 2,
186186
width: this.props.size

ActionButtonItem.js

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
TouchableNativeFeedback,
99
TouchableWithoutFeedback,
1010
Dimensions,
11+
Platform,
1112
} from "react-native";
1213
import {
1314
shadowStyle,
@@ -92,9 +93,8 @@ export default class ActionButtonItem extends Component {
9293
const parentStyle = isAndroid &&
9394
this.props.fixNativeFeedbackRadius
9495
? {
95-
height: size,
96-
marginBottom: spacing,
97-
right: this.props.offsetX,
96+
paddingHorizontal: this.props.offsetX,
97+
height: size + SHADOW_SPACE + spacing,
9898
borderRadius: this.props.size / 2
9999
}
100100
: {
@@ -107,11 +107,13 @@ export default class ActionButtonItem extends Component {
107107
style={[animatedViewStyle, parentStyle]}
108108
>
109109
<View
110-
style={{
110+
style={[{
111111
width: this.props.size,
112112
height: this.props.size,
113113
borderRadius: size / 2
114-
}}
114+
},
115+
!hideShadow && Platform.OS === "android" ? {...shadowStyle, ...this.props.shadowStyle} : null
116+
]}
115117
>
116118
<Touchable
117119
background={touchableBackground(
@@ -123,7 +125,7 @@ export default class ActionButtonItem extends Component {
123125
>
124126
<View style={[
125127
buttonStyle,
126-
!hideShadow ? {...shadowStyle, ...this.props.shadowStyle} : null
128+
!hideShadow && Platform.OS === "ios" ? {...shadowStyle, ...this.props.shadowStyle} : null
127129
]}>
128130
{this.props.children}
129131
</View>
@@ -182,8 +184,7 @@ export default class ActionButtonItem extends Component {
182184
return (
183185
<TextTouchable
184186
background={touchableBackground(
185-
this.props.nativeFeedbackRippleColor,
186-
this.props.fixNativeFeedbackRadius
187+
this.props.nativeFeedbackRippleColor
187188
)}
188189
activeOpacity={this.props.activeOpacity || DEFAULT_ACTIVE_OPACITY}
189190
onPress={this.props.onPress}

0 commit comments

Comments
 (0)