Skip to content
This repository has been archived by the owner on Jan 31, 2023. It is now read-only.

Latest commit

 

History

History
54 lines (50 loc) · 1.75 KB

README.md

File metadata and controls

54 lines (50 loc) · 1.75 KB

bs-react-native-action-sheet

Greenkeeper badge Build Status

BS bindings for @expo/react-native-action-sheet

Install

yarn add bs-react-native-action-sheet @expo/react-native-action-sheet

And then update your bsconfig.json with it Also do the normal setup as you would do for the JS one. Add the ActionSheetProvider somewhere in the top of your components tree.

Usage

let component = ReasonReact.statelessComponent("ListItem");
let handlePress = (showActionSheetWithOptions, ()) =>
  showActionSheetWithOptions(
    /* We'll probably make these variants in the next release */
    ~options=["Edit", "Delete", "Cancel"],
    ~destructiveButtonIndex=1,
    ~cancelButtonIndex=2,
    ~callback=
      (buttonIndex) =>
        switch buttonIndex {
        | 0 => ()
        | _ => ()
        }
  );
let make = (~label, ~image, ~onPress=ignore, _children) => {
  ...component,
  render: (_self) =>
    <ActionSheet>
      (
        (~showActionSheetWithOptions) =>
          <Wrapper onPress>
            <HGroup>
              <ListIcon source=image />
              <Text
                ellipsizeMode=`tail
                style=Style.(style([fontSize(15.), marginLeft(20.)]))
                value=label
              />
            </HGroup>
            <TouchableOpacity onPress=(handlePress(showActionSheetWithOptions))>
              <MaterialCommunityIcons name="dots-vertical" color=AppTheme.Colors.greyLight />
            </TouchableOpacity>
          </Wrapper>
      )
    </ActionSheet>
};