Skip to content

Extend ActionButton to take buttonFontSize and btnOutRange #2

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 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
26 changes: 19 additions & 7 deletions ActionButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ export default class ActionButton extends Component {
clearTimeout(this.timeout);
}

componentWillReceiveProps(nextProps) {
this.setState({
active: nextProps.active
});
}

getActionButtonStyle() {
return [styles.actionBarItem, this.getButtonSize()];
}
Expand All @@ -60,7 +66,7 @@ export default class ActionButton extends Component {
return [styles.overlay, styles.actionContainer, {
alignItems,
justifyContent,
}];
}, {padding: this.props.padding}];
}
getActionsStyle() {
return [this.getButtonSize()];
Expand Down Expand Up @@ -95,6 +101,7 @@ export default class ActionButton extends Component {
}).start();

setTimeout(() => {
this.props.onClose();
this.setState({ active: false });
}, 250);
}
Expand Down Expand Up @@ -156,6 +163,7 @@ export default class ActionButton extends Component {
<Animated.Text
style={[styles.btnText,
{
fontSize: this.props.buttonFontSize,
color: this.state.anim.interpolate({
inputRange: [0, 1],
outputRange: [this.props.buttonTextColor, this.props.btnOutRangeTxt]
Expand Down Expand Up @@ -196,7 +204,7 @@ export default class ActionButton extends Component {
angle={startRadian + index * offset}
btnColor={this.props.btnOutRange}
{...button.props}
onPress={() => {
onPress={() => {
if (this.props.autoInactive) {
this.timeout = setTimeout(() => {
this.reset();
Expand Down Expand Up @@ -265,6 +273,7 @@ ActionButton.propTypes = {
autoInactive: PropTypes.bool,
onPress: PropTypes.func,
onOverlayPress: PropTypes.func,
onClose: PropTypes.func,
backdrop: PropTypes.oneOfType([
PropTypes.bool,
PropTypes.object,
Expand All @@ -273,19 +282,25 @@ ActionButton.propTypes = {
endDegree: PropTypes.number,
radius: PropTypes.number,
children: PropTypes.node,
padding: PropTypes.number,
position: PropTypes.oneOf(['left', 'center', 'right']),
btnOutRange: PropTypes.string,
buttonFontSize: PropTypes.number,
};

ActionButton.defaultProps = {
active: false,
bgColor: 'transparent',
buttonColor: 'rgba(0,0,0,1)',
buttonTextColor: 'rgba(255,255,255,1)',
buttonFontSize: 24,
padding: 10,
position: 'center',
outRangeScale: 1,
autoInactive: true,
autoInactive: false,
onPress: () => {},
onOverlayPress: () => {},
onClose: () => {},
backdrop: false,
degrees: 135,
size: 63,
Expand All @@ -305,8 +320,7 @@ const styles = StyleSheet.create({
backgroundColor: 'transparent',
},
actionContainer: {
flexDirection: 'column',
padding: 10,
flexDirection: 'column'
},
actionBarItem: {
alignItems: 'center',
Expand All @@ -325,8 +339,6 @@ const styles = StyleSheet.create({
shadowRadius: 1,
},
btnText: {
marginTop: -4,
fontSize: 24,
backgroundColor: 'transparent',
position: 'relative',
},
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ Also this example uses `react-native-vector-icons` for the button Icons.
| radiua | number | 100 | radius of menu
| bgColor | string | "transparent" | color of overlay when ActionButtons are visible
| buttonColor | string | "rgba(0,0,0,1)" | background color of the +Button **(must be rgba value!)**
| buttonFontSize | number | 24 | + and x sizes
| btnOutRange | string | props.buttonColor | button background color to animate to
| outRangeScale | number | 1 | changes size of button during animation
| onPress | function | null | fires, when ActionButton is tapped
Expand Down