Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Modal bottom menu in react-native

How can I create a menu like on screenshot for react-native?

enter image description here

like image 642
Tony Avatar asked Aug 31 '17 21:08

Tony


2 Answers

you can set backgroundColor: 'rgba(0,0,0,0.2)'.

<Modal
      animationType={"slide"}
      transparent={false}
      visible={this.state.modalVisible}
      onRequestClose={() => {alert("Modal has been closed.")}}

      >

     <View style={{flex: 1,backgroundColor: 'rgba(0,0,0,0.2)'}}>
      <View style ={{flex:1, alignItems: 'center', justifyContent: 'center'}}>
          <View style={{backgroundColor: '#ffffff', width: 300, height: 300}}>
              <Text>Hello World!</Text>
          </View>
        <TouchableHighlight
          style={{backgroundColor: '#ffffff', width: 300, height: 40, marginTop: 40}}
          onPress={() => {this.setModalVisible(!this.state.modalVisible)}}
        >
          <Text>Hide Modal</Text>
        </TouchableHighlight>

      </View>
     </View>
    </Modal>
like image 52
An Cam Avatar answered Oct 14 '22 00:10

An Cam


For iOS in specific there's a component called ActionSheetIOS and you can call it like this:

ActionSheetIOS.showActionSheetWithOptions(
  {
    options: ["Cancel", ...options],
    title: "Select something",
    message: "Some description",
    cancelButtonIndex: 0 
  },
  index => {
    // do something with the selected index
    const listIndex = index - 1;
    if (index > 0) {
      this.setState({ selectedIndex: listIndex });
    }
  }
);
like image 34
Javier P Avatar answered Oct 14 '22 00:10

Javier P