Skip to content

height, width and borderRadius available to use with ActionButtonItem #207

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 18 additions & 13 deletions ActionButtonItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,10 @@ export default class ActionButtonItem extends Component {

render() {
const {
borderRadius,
size,
width,
height,
position,
verticalOrientation,
hideShadow,
Expand Down Expand Up @@ -79,9 +82,9 @@ export default class ActionButtonItem extends Component {
const buttonStyle = {
justifyContent: "center",
alignItems: "center",
width: size,
height: size,
borderRadius: size / 2,
width: width || size,
height: height || size,
borderRadius: borderRadius || size / 2,
backgroundColor: this.props.buttonColor || this.props.btnColor
};

Expand All @@ -96,11 +99,11 @@ export default class ActionButtonItem extends Component {
height: size,
marginBottom: spacing,
right: this.props.offsetX,
borderRadius: this.props.size / 2
borderRadius: this.props.borderRadius || this.props.size / 2
}
: {
paddingHorizontal: this.props.offsetX,
height: size + SHADOW_SPACE + spacing
height: (this.props.height || size) + SHADOW_SPACE + spacing
};
return (
<Animated.View
Expand All @@ -110,9 +113,9 @@ export default class ActionButtonItem extends Component {
<View
style={[
{
width: this.props.size,
height: this.props.size,
borderRadius: size / 2
width: width || this.props.size,
height: height || this.props.size,
borderRadius: borderRadius || size / 2
},
!hideShadow && shadowStyle,
!hideShadow && this.props.shadowStyle
Expand All @@ -126,7 +129,7 @@ export default class ActionButtonItem extends Component {
activeOpacity={this.props.activeOpacity || DEFAULT_ACTIVE_OPACITY}
onPress={this.props.onPress}
>
<View style={[buttonStyle]}>
<View style={[buttonStyle, this.props.containerStyle]}>
{this.props.children}
</View>
</Touchable>
Expand All @@ -146,19 +149,21 @@ export default class ActionButtonItem extends Component {
parentSize,
size,
position,
spaceBetween
spaceBetween,
width,
height,
} = this.props;
const offsetTop = Math.max(size / 2 - TEXT_HEIGHT / 2, 0);
const offsetTop = Math.max((height || size) / 2 - TEXT_HEIGHT / 2, 0);
const positionStyles = { top: offsetTop };
const hideShadow = hideLabelShadow === undefined
? this.props.hideShadow
: hideLabelShadow;

if (position !== "center") {
positionStyles[position] =
offsetX + (parentSize - size) / 2 + size + spaceBetween;
offsetX + (parentSize - (width || size)) / 2 + (width || size) + spaceBetween;
} else {
positionStyles.right = WIDTH / 2 + size / 2 + spaceBetween;
positionStyles.right = WIDTH / 2 + (width || size) / 2 + spaceBetween;
}

const textStyles = [
Expand Down