# NavigationDrawer-MaterialDesign **Repository Path**: chinasoft5_ohos/NavigationDrawer-MaterialDesign ## Basic Information - **Project Name**: NavigationDrawer-MaterialDesign - **Description**: 自定义抽屉布局 - **Primary Language**: Java - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: https://gitee.com/chinasoft5_ohos/NavigationDrawer-MaterialDesign - **GVP Project**: No ## Statistics - **Stars**: 1 - **Forks**: 0 - **Created**: 2021-07-22 - **Last Updated**: 2024-05-29 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # NavigationDrawer-MaterialDesign #### 项目介绍 - 项目名称:NavigationDrawer-MaterialDesign - 所属系列:openharmony的第三方组件适配移植 - 功能:自定义抽屉布局 - 项目移植状态:主功能完成 - 调用差异:无 - 开发版本:sdk6,DevEco Studio2.2 Beta1 - 基线版本:Release 2.5.1 #### 效果演示 ![效果演示](./Screenshot/sample.gif) #### 安装教程 1.在项目根目录下的build.gradle文件中, ``` allprojects { repositories { maven { url 'https://s01.oss.sonatype.org/content/repositories/releases/' } } } ``` 2.在entry模块的build.gradle文件中, ``` dependencies { implementation('com.gitee.chinasoft_ohos:NavigationDrawer-MaterialDesign:1.0.0') ...... } ``` 在sdk6,DevEco Studio2.2 Beta1下项目可直接运行 如无法运行,删除项目.gradle,.idea,build,gradle,build.gradle文件, 并依据自己的版本创建新项目,将新项目的对应文件复制到根目录下 #### 使用说明 1.你的AbilitySlice来继承NavigationLiveo,且不需要重写onStart方法,只需要实现onInt(Intent intent)就可以了, 在onInt里你可以: 设置头像,姓名,邮箱,背景等信息: ``` java //User Information this.userName.setText("Rudson Lima"); this.userEmail.setText(this.getString(ResourceTable.String_Email)); this.userPhoto.setPixelMapAndCircle(ResourceTable.Media_ic_rudsonlive); this.userBackground.setPixelMap(ResourceTable.Media_ic_user_background_first); ``` 设置List列表栏: ``` java mHelpLiveo = new HelpLiveo(); mHelpLiveo.add("Inbox", ResourceTable.Media_ic_inbox_black_24dp, 7); mHelpLiveo.addSubHeader("Categories"); // Item subHeader mHelpLiveo.add("Starred", ResourceTable.Media_ic_star_black_24dp); mHelpLiveo.add("Sent Mail", ResourceTable.Media_ic_send_black_24dp); mHelpLiveo.addNoCheck("Drafts", ResourceTable.Media_ic_drafts_black_24dp); mHelpLiveo.addSeparator(); // Item separator mHelpLiveo.add("Trash", ResourceTable.Media_ic_delete_black_24dp); mHelpLiveo.add("Spam", ResourceTable.Media_ic_report_black_24dp, 120); ``` 设置主界面SliderPage: ``` java TabList.Tab tab1 = tabList.new Tab(getContext()); tab1.setText("STARRED"); tabList.addTab(tab1); TabList.Tab tab2 = tabList.new Tab(getContext()); tab2.setText("IMPORTANT"); tabList.addTab(tab2); TabList.Tab tab3 = tabList.new Tab(getContext()); tab3.setText("DOCUMENTS"); tabList.addTab(tab3); pages = new ArrayList<>(); pages.add(create("Starred")); pages.add(create("Important")); pages.add(create("Documents")); ``` create()方法: ``` java private Component create(String text) { final Component rootView = LayoutScatter.getInstance(this) .parse(ResourceTable.Layout_page_slider_main, null, false); Text t1 = (Text) rootView.findComponentById(ResourceTable.Id_txtTitle); t1.setText(text); return rootView; } ``` 设置监听,起始位置: ``` java with(this).startingPosition(2) .colorItemSelected(Color.getIntColor("#2196F3")) .setFooter("Settings", ResourceTable.Media_ic_settings_black_24dp) .setAddListener(onClickAdd) .setUserPhotoListener(onClickPhoto) .setOnClickFooter(onClickFooter); ``` 接口说明: | Method | Description | | :--------------------------:| :-------------------------------:| | add( String name,int icon) | 添加不带数量的item | | add( String name, int icon, int counter) | 添加带数量的item,item的消息数(大于99显示为99+) | | addSubHeader(String name) | 添加item的Header | | addNoCheck() | 添加不能被选中的item | | addSeparator() | 添加一条分割线 | | with() | 添加item的ClickedListener监听器 | | colorItemSelected() | 添加item被选中时的颜色 | | setCheckedItemNavigation() | 点击item | | setFooter() | 添加footer的item | | setAddListener() | 添加add的监听器 | | setUserPhotoListener() | 添加userPhoto的监听器 | | setOnClickFooter() | 添加footer的监听器 | | setToolBarVisibility() | toolBar是否隐藏 | #### 测试信息 CodeCheck代码测试无异常 CloudTest代码测试无异常 病毒安全检测通过 当前版本demo功能与原组件基本无差异 #### 版本迭代 - 1.0.2 - 1.0.1 - 1.0.0 - 0.0.1-SNAPSHOT #### 版权和许可信息 ``` Copyright 2015 Rudson Lima Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ````