@sk39/react-native-action-menu

Action menu for React Native.

Usage no npm install needed!

<script type="module">
  import sk39ReactNativeActionMenu from 'https://cdn.skypack.dev/@sk39/react-native-action-menu';
</script>

README

react-native-action-menu

Action menu for React Native.

NPM

menu

Dependencies

Install

npm install @sk39/react-native-action-menu

Usage

Props

Props Default Description
duration 400
centralCircleSize 130
circleSpaceSize 56
import React, {Component} from 'react';
import {TouchableOpacity, View} from 'react-native';
import {ActionMenu} from "react-native-action-menu";

class Example extends Component {
  menuRef = React.createRef<ActionMenu>();

  onSelect(ev, item) {
    const actions = [
        {
            title: "Show Detail",
            method: ()=>console.log("Show Detail"),
            icon: {name: "eye", type: "feather"},
            color: Colors.primary
        },
        {
            title: "Invest",
            method: ()=>console.log("Show Detail"),
            icon: {name: "shopping-cart", type: "feather"},
            color: Colors.second
        }
    ];

    this.menuRef.current.show({
        title: item.name,
        actions,
        py: ev.nativeEvent.pageY
    })
  }

  render () {
    return (
       <View>
          <TouchableOpacity onPress={ev => this.onSelect(ev, item)}>...</TouchableOpacity>
          <ActionMenu ref={this.menuRef}/>
       </View>
    )
  }
}

License

MIT © sk39