1.0.2 • Published 7 years ago

react-native-sf-drawer v1.0.2

Weekly downloads
-
License
ISC
Repository
-
Last release
7 years ago

react-native-sf-drawer

侧边栏

show

安装

npm install react-native-sf-drawer

Props

parametertyperequireddescriptiondefault
drawerWidthRatenumberno侧边栏暂屏幕宽度的比例(0.0-1.0)0.7
drawerHeightnumberno侧边栏高度null
drawerDirectionstringno侧边栏的方向('left','right')'left'
drawerTopnumberno侧边栏距离上方的高度0
backgroundColorstringno背景颜色'rgba(0,0,0,0.7)'
onOpenfuncno开始显示null
onClosefuncno开始关闭null

Methods

MethodsParamsParam TypesdescriptionExample
shownullnull显示侧边栏
hidenullnull隐藏侧边栏

例子

import React, { Component } from 'react';
import {
  Platform,
  StyleSheet,
  Text,
  View,
    Dimensions,
    TouchableOpacity
} from 'react-native';

import SFDrawer from "react-native-sf-drawer"
var dw = Dimensions.get('window').width;
var dh = Dimensions.get('window').height;
export default class App extends Component {
  click = () => {
    this.refs.drawer.show()

  }
  render() {
    return (
      <View style={styles.container}>
        <TouchableOpacity onPress={this.click}>
          <View style={{
            width:dw,
            height:150,
            backgroundColor:'red'
          }}></View>
        </TouchableOpacity>

        <SFDrawer
            ref="drawer"

          drawerDirection={'left'}
        >
          <View style={{
            height:dh,
            backgroundColor:'green'
          }}></View>
        </SFDrawer>
      </View>
    );
  }
}