加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

react-native + teaset(Drawer)实现侧边菜单

发布时间:2020-12-15 20:24:27 所属栏目:百科 来源:网络整理
导读:1.代码 /** * 购物车 */import React,{Component} from ‘react‘;import { View,Image,} from ‘react-native‘;import { BaseContainer } from ‘../../../components‘;import Icon from ‘react-native-vector-icons/Ionicons‘; //引入图标import { The

1.代码

/**
 * 购物车
 */
import React,{Component} from ‘react‘;
import {
  View,Image,} from ‘react-native‘;
import { BaseContainer } from ‘../../../components‘;
import Icon from ‘react-native-vector-icons/Ionicons‘; //引入图标
import { Theme,Drawer,ListRow,Button } from ‘teaset‘;
import { images } from ‘../../../res‘;

export default class ShopCarPage extends Component {
  constructor(props) {
    super(props);
  
    this.state = {
      rootTransform: ‘none‘
    };
  }

  // 显示或隐藏侧边菜单(抽屉)
  toggleMenu(side){
    let { rootTransform } = this.state;
    this.drawer = Drawer.open(this.renderDrawerMenu(),side,rootTransform);
  }

  // 侧边菜单(抽屉)
  renderDrawerMenu(){
    return (
      <View style={{backgroundColor: Theme.defaultColor,width: 260,flex: 1}}>
        <View style={{height: 60}} />
        <ListRow
          icon={
            <View style={{paddingRight: 12}}>
              <Image style={{width: 30,height: 30,tintColor: Theme.primaryColor}} source={images.error} />
            </View>
          }
          title=‘User name‘
          />
        <ListRow
          icon={images.error}
          title=‘Home‘
          />
        <ListRow
          icon={images.error}
          title=‘Store‘
          bottomSeparator=‘none‘
          />
        <View style={{flex: 1}} />
        <Button type=‘link‘ size=‘sm‘ title=‘Hide‘ onPress={() => this.drawer && this.drawer.close()} />
      </View>
    );
  }

  render() {
    return (
      <BaseContainer
        hideLeft
        title={‘购物车‘}
        rightView={<Icon name=‘md-home‘ size={30} onPress={() => this.toggleMenu(‘left‘)} />}
      >
      </BaseContainer>
    )
  }
}

2.效果图

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读