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

rescriptbr/bs-react-native-action-sheet

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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>
};