2.0.5 • Published 6 years ago

react-native-action-bar v2.0.5

Weekly downloads
46
License
MIT
Repository
github
Last release
6 years ago

react-native-action-bar

An Android-like action bar for react-native

For react-native v0.39+

:warning: Breaking change for versions < 2.*

The component has been redone so it hasn't much in common.

Check that README for versions lower than 2.*

Example

iOSAndroid
<ActionBar
    containerStyle={styles.bar}
    title={'React-native-action-bar Example'}
    rightText={'Hello'}
    leftIconName={'menu'}
    leftBadge={''}
    onLeftPress={() => console.log('Left!')}
    onTitlePress={() => console.log('Title!')}
    rightIcons={[
        {
            name: 'star',
            badge: '1',
            onPress: () => console.log('Right Star !'),
        },
        {
            name: 'phone',
            badge: '1',
            onPress: () => console.log('Right Phone !'),
            isBadgeLeft: true,
        },
        {
            name: 'plus',
            onPress: () => console.log('Right Plus !'),
        },
        {
            name: 'flag',
            badge: '1',
            onPress: () => console.log('Right Flag !'),
        },
        {
            image: require('my-custom-image.png'), // To use a custom image
            badge: '1',
            onPress: () => console.log('Right Custom image !'),
        },
    ]}
/>

Are you looking for React-native's ToolbarAndroid?

To allow more customization, I do not use ToolbarAndroid, however, this might be what you are looking for instead of my package.

react-native-action-bar is here to provide a similar top screen bar but that looks the same on Android and iOS.

Properties

Property NameTypeComment
allowFontScalingReact.PropTypes.boolIf you want to allow font scaling on the title and the right text (false by default)
backgroundColorReact.PropTypes.stringThe background color of the Bar
badgeColorBadge.propTypes.backgroundColorThe color of all badges
badgeTextColorBadge.propTypes.colorThe color of the text of the badges
containerStyleViewPropTypes.styleStyle of the container of the bar (has the backgroundColor)
disableShadowsReact.PropTypes.boolIf you want the ActionBar to drop a shadow or not (The default is false)
disableStatusBarHandlingReact.PropTypes.boolIf you want the ActionBar to set the color/style of the StatusBar (The default is false)
elevationReact.PropTypes.numberOn Android, to 'control' the Shadow dropped by the bar (default is 2)
iconContainerStyleViewPropTypes.styleSee the Icon component (applies to all Icons (left and right)
iconImageStyleImage.propTypes.styleSee the Icon component (applies to all Icons (left and right)
isLeftBadgeLeftReact.PropTypes.boolPosition of the badge on the left Icon
leftBadgeBadge.propTypes.contentText of the badge on the left Icon ('' is a valid value, it will display an empty badge. undefined is needed to not have the badge displayed)
leftIconContainerStyleIcon.propTypes.containerStyleSee the Icon component
leftIconImageIcon.propTypes.sourceAn image to use as Icon (require()). Don't use remote images ({ uri: ... }) as it will have bad performance, but I guess you can
leftIconImageStyleIcon.propTypes.imageStyleSee the Icon component
leftIconNameIcon.propTypes.nameThe name of one of the predefined Icons (see List of predefined Icons)
leftTouchableChildStyleViewPropTypes.styleThe style of the View inside the TouchableWithoutFeedback element for the left Icon
leftZoneContentContainerStyleViewPropTypes.styleThe style of the View around the TouchableWithoutFeedback element for the left Icon
onLeftPressReact.PropTypes.funcThe function to execute onPress for the left Icon
onRightTextPressReact.PropTypes.funcThe function to execute onPress for the Text that you can display on the right of the Title
onTitlePressReact.PropTypes.funcThe function to execute onPress for the Title
renderLeftSideReact.PropTypes.funcA function to override the rendering of the part left of the Title
renderRightSideReact.PropTypes.funcA function to override the rendering of the part right of the Title
rightIconContainerStyleIcon.propTypes.containerStyleSee the Icon component
rightIconImageStyleIcon.propTypes.imageStyleSee the Icon component
rightIconsReact.PropTypes.arrayOf( React.PropTypes.shape({ ...Icon.propTypes, badge: Badge.propTypes.content, onPress: React.PropTypes.func.isRequired, }),)See below
rightTextReact.PropTypes.stringThe text to display on the right
rightTextStyleText.propTypes.styleStyle of the text to display on the right
rightTouchableChildStyleViewPropTypes.styleThe style of the View inside the TouchableWithoutFeedback element for all the Icons on the right
rightZoneContentContainerStyleViewPropTypes.styleThe style of the View around all the Icons + Text on the right
throttleDelayReact.PropTypes.numberThe delay to throttle the presses on the Icons (The default is 750ms)
titleReact.PropTypes.stringThe Text of the Title
titleContainerStyleViewPropTypes.styleThe style of the View containing the Text element for the Title
titleStyleText.propTypes.styleThe style of the Text element for the Title

rightIcons elements example

{
    name: 'phone',
    badge: '1',
    onPress: () => console.log('Right Phone !'),
    isBadgeLeft: true,
}

Predefined Icons

Right now the following Icons are defined:

  • back
  • flag
  • loading
  • location
  • menu
  • phone
  • plus
  • star
  • star-outline

Example

See an implementation example in the Example folder

2.0.5

6 years ago

2.0.4

6 years ago

2.0.3

6 years ago

2.0.2

7 years ago

2.0.1

7 years ago

2.0.0

7 years ago

1.0.8

8 years ago

1.0.7

8 years ago

1.0.6

8 years ago

1.0.5

8 years ago

1.0.4

8 years ago

1.0.3

8 years ago

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago