Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

customizable multi-action-button component for react-native

License

NotificationsYou must be signed in to change notification settings

ge-tracker/react-native-action-button

 
 

Repository files navigation

customizable multi-action-button component for react-native (I'm going to be maintaining this package since the main one is no longer being maintained).

react-native-action-button demoreact-native-action-button demoreact-native-action-button demoreact-native-action-button demo

Known Issues

  • Doesn't Work While Android Debugging. See issue#79.

Installation

npm i @logvinme/react-native-action-button --save

If you have the latest version skip this (no need to link).

Linkreact-native-vector-icons native dependencies to your project with:

react-native link react-native-vector-icons

or just:

react-native link

to link all libraries with native dependencies in your project.

Usage

First, require it from your app's JavaScript files with:

import ActionButton from'@logvinme/react-native-action-button';
ActionButton

ActionButton component is the main component which wraps everything and provides a couple of props (see Config below).

ActionButton.Item

ActionButton.Item specifies an Action Button. You have to include at least 1ActionButton.Item.

Example

The following Basic example can be found inexample/Basic.

importReact,{Component}from'react';import{StyleSheet,View}from'react-native';importActionButtonfrom'@logvinme/react-native-action-button';importIconfrom'react-native-vector-icons/Ionicons';classAppextendsComponent{render(){return(<Viewstyle={{flex:1,backgroundColor:'#f3f3f3'}}>{/* Rest of the app comes ABOVE the action button component !*/}<ActionButtonbuttonColor="rgba(231,76,60,1)"><ActionButton.ItembuttonColor='#9b59b6'title="New Task"onPress={()=>console.log("notes tapped!")}><Iconname="md-create"style={styles.actionButtonIcon}/></ActionButton.Item><ActionButton.ItembuttonColor='#3498db'title="Notifications"onPress={()=>{}}><Iconname="md-notifications-off"style={styles.actionButtonIcon}/></ActionButton.Item><ActionButton.ItembuttonColor='#1abc9c'title="All Tasks"onPress={()=>{}}><Iconname="md-done-all"style={styles.actionButtonIcon}/></ActionButton.Item></ActionButton></View>);}}conststyles=StyleSheet.create({actionButtonIcon:{fontSize:20,height:22,color:'white',},});

This will create a floating Button in the bottom right corner with 3 action buttons.Also this example usesreact-native-vector-icons for the button Icons.

FAB Example

<ActionButtonbuttonColor="rgba(231,76,60,1)"onPress={()=>{console.log("hi")}}/>

Show/hide the FAB on scroll

Take a look atthis gist for showing and hiding the floating action button depending on the scroll direction.

Configuration

ActionButton:
PropertyTypeDefaultDescription
sizenumber56use this to change the size of the Button
resetTokenanynulluse this to reset the internal component state (expand/collapse) in a re-render cycle. Synchronize the component state.
activebooleanfalseaction buttons visible or not
autoInactivebooleantrueAuto hide ActionButtons when ActionButton.Item is pressed.
hideShadowbooleanfalseuse this to hide the default elevation and boxShadow
positionstring"right" / "center"one of:leftcenter andright
bgColorstring"transparent"background color when ActionButtons are visible
buttonColorstring"rgba(0,0,0,1)"background color of the +Button(must be rgba value!)
spacingnumber20spacing between theActionButton.Items
offsetXnumber30offset from the left/right side of the screen
offsetYnumber30offset from the bottom/top of the screen
btnOutRangestringprops.buttonColorbutton background color to animate to
outRangeScalenumber1changes size of button during animation
onPressfunctionnullfires, when ActionButton is tapped
onPressInfunctionnullfires, before ActionButton is released
onPressOutfunctionnullfires, after ActionButton is released
onLongPressfunctionnullfires, when ActionButton is long pressed
renderIcon  functionnullFunction to render the component for ActionButton Icon. It is passed a boolean,active, which is true if the FAB has been expanded, and false if it is collapsed, allowing you to show a different icon when the ActionButton Items are expanded.
icon        Component    +                  Deprecated, userenderIcon Custom component for ActionButton Icon
backdropComponentfalseCustom component for use as Backdrop (i.e.BlurView,VibrancyView)
degreesnumber135degrees to rotate icon
buttonTextstring+use this to set a different text on the button
buttonTextStylestylenulluse this to set the textstyle of the button's text
onResetfunctionnulluse this to set the callback that will be called after the button reset's it's items
verticalOrientationstring"up"direction action buttons should expand. One of:up ordown
backgroundTappablebooleanfalsemake background tappable in active state of ActionButton
activeOpacitynumber0.85activeOpacity props of TouchableOpacity
shadowStylestylenullThe custom shadow style you want to pass in the action button
useNativeFeedbackbooleantrueAndroid: Whether to use a TouchableNativeFeedback
fixNativeFeedbackRadiusbooleanfalseAndroid: Activate this to fix TouchableNativeFeedback Ripple UI problems
nativeFeedbackRippleColorstring'rgba(255,255,255,0.75)'Android: Pass a color to the Ripple Effect of a TouchableNativeFeedback
ActionButton.Item:
PropertyTypeDefaultDescription
sizenumberparentSizeuse this to change the size of the Button
titlestringundefinedthe title shown next to the button. Whenundefined the title is not hidden
onPressfuncnullrequired function, triggers when a button is tapped
buttonColorstringsame as + buttonbackground color of the Button
titleColorstring"#444"color of title,removed in v2.5. usetextStyle instead
titleBgColorstring"white"background color of title,removed in v2.5. usetextStyle instead
textContainerStylestylenulluse this to set the textstyle of the button's item text container
textStylestylenulluse this to set the textstyle of the button's item text
spaceBetweennumber15use this to set the space between the Button and the text container
numberOfLinesnumber1use this to set the number of lines on the button's item text
activeOpacitynumber0.85activeOpacity props of TouchableOpacity
hideLabelShadowbooleansame as hideShadowuse this to hide the button's label default elevation and boxShadow
shadowStylestylenullThe custom shadow style you want to pass in the action button item
useNativeFeedbackbooleantrueAndroid: Whether to use a TouchableNativeFeedback
fixNativeFeedbackRadiusbooleanfalseAndroid: Activate this to fix TouchableNativeFeedback Ripple UI problems
nativeFeedbackRippleColorstring'rgba(255,255,255,0.75)'Android: Pass a color to the Ripple Effect of a TouchableNativeFeedback

About

customizable multi-action-button component for react-native

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript72.1%
  • Objective-C18.6%
  • Starlark5.6%
  • Java3.7%

[8]ページ先頭

©2009-2025 Movatter.jp