Skip to content

Commit 7ecf4f7

Browse files
iris-changmastermoo
authored andcommitted
Fixed Action Button Items shadows cropped left and right on Android (mastermoo#108)
* Increased size of shadow on iOS, changed shadow color to black * Increased elevation in Android as well. Reduced height offset in iOS from 10 to 8. * Hotfix: wrong single quote character * Added bottom margin to prevent shadow cutoff on Android. Extraction of code from @paulomenezes's PR mastermoo#99, I take no credit for this work. * Added margin to left and right of the button to resolve the shadow cropping issue. * Correct spelling mistake * Fix Action Button Items shadows which were cropped left and right on Android * Fixes main button shadow rotating in iOS
1 parent fedd4bd commit 7ecf4f7

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

ActionButton.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React, { Component, PropTypes } from 'react';
2-
import { StyleSheet, Text, View, Animated, TouchableOpacity } from 'react-native';
2+
import { StyleSheet, Text, View, Animated, TouchableOpacity, Platform } from 'react-native';
33
import ActionButtonItem from './ActionButtonItem';
44

55
const alignItemsMap = {
@@ -38,6 +38,7 @@ export default class ActionButton extends Component {
3838

3939
getActionButtonStyles() {
4040
const actionButtonStyles = [styles.actionBarItem, this.getButtonSize()];
41+
if(!this.props.hideShadow) actionButtonStyles.push(styles.btnShadow);
4142
return actionButtonStyles;
4243
}
4344

@@ -127,7 +128,7 @@ export default class ActionButton extends Component {
127128
},
128129
];
129130

130-
if(!this.props.hideShadow) animatedViewStyle.push(styles.btnShadow);
131+
if(!this.props.hideShadow && Platform.OS === 'android') animatedViewStyle.push(styles.btnShadow);
131132

132133
return (
133134
<View style={this.getActionButtonStyles()}>

ActionButtonItem.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ export default class ActionButtonItem extends Component {
2525
render() {
2626
const translateXMap = {
2727
center: 0,
28-
left: (this.props.parentSize - this.props.size) / 2,
29-
right: -(this.props.parentSize - this.props.size) / 2,
28+
left: (this.props.parentSize - this.props.size) / 2 - 8,
29+
right: -(this.props.parentSize - this.props.size) / 2 + 8,
3030
}
3131

3232
const translateX = translateXMap[this.props.position];
@@ -68,6 +68,7 @@ export default class ActionButtonItem extends Component {
6868
height: this.props.size,
6969
borderRadius: this.props.size / 2,
7070
backgroundColor: this.props.buttonColor || this.props.btnColor,
71+
marginHorizontal: 8,
7172
marginBottom: this.props.verticalOrientation === 'up' ? 12 : 0,
7273
marginTop: this.props.verticalOrientation === 'down' ? 12 : 0,
7374
}]}
@@ -96,7 +97,7 @@ export default class ActionButtonItem extends Component {
9697
let offsetTop = this.props.size >= 28 ? (this.props.size / 2) - 14 : 0;
9798

9899
let positionStyles = {
99-
right: this.props.size + this.state.spaceBetween,
100+
right: this.props.size + this.state.spaceBetween + 8,
100101
top: offsetTop
101102
}
102103

@@ -107,7 +108,7 @@ export default class ActionButtonItem extends Component {
107108
}
108109

109110
if (this.props.position == 'left') positionStyles = {
110-
left: this.props.size + this.state.spaceBetween,
111+
left: this.props.size + this.state.spaceBetween + 8,
111112
top: offsetTop
112113
}
113114

0 commit comments

Comments
 (0)