# FlipViewPager.Draco #### 项目介绍 - 项目名称:**FlipViewPager.Draco** - 所属系列:openharmony的第三方组件适配移植 - 功能:openharmony 这个项目提供一个页面翻转实功能,在ListContainer中使用。在item上左右滑动,可以实现页面的切换。 - 项目移植状态:功能完成,缺少3D翻转效果 - 调用差异:和原库有差异 - 基线版本: master - 开发版本:sdk6,DevEco Studio2.2 Beta1 #### 效果演示 <p align="center"> <img src="image/demo.gif" alt="FlipViewPager.Draco" /> </p> #### 安装教程 1.在项目根目录下的build.gradle文件中, ```gradle allprojects { repositories { maven { url 'https://s01.oss.sonatype.org/content/repositories/snapshots/' } } } ``` 2.在entry模块的build.gradle文件中, ```xml dependencies { implementation('com.gitee.chinasoft_ohos:FlipViewPager.Draco:0.0.2-SNAPSHOT') } ``` #### 使用说明 xml布局引用 FlipViewPager ```xml <?xml version="1.0" encoding="utf-8"?> <com.yalantis.flipviewpager.view.FlipViewPager xmlns:ohos="http://schemas.huawei.com/res/ohos" ohos:height="match_content" ohos:width="match_parent" ohos:orientation="vertical" > </com.yalantis.flipviewpager.view.FlipViewPager> ``` 用自己的Adapter继承 BaseFlipAdapter,实现抽象的方法 ```java public class FriendProvider extends BaseFlipAdapter { public FriendProvider(Context context, List<Friend> items) { super(context,items); this.items = items; this.context=context; map = new HashMap<>(); //记录当前item滑动的位置 for (int a = 0; a < items.size(); a++) { map.put(a, 1); } } @Override public Component getView(int position, Component component, ComponentContainer componentContainer) { // ... return component; } ``` FriendsHolder属性说明 component|说明 :------|:------------------ DependentLayout left|左边的布局 DependentLayout right|右边的布局 DirectionalLayout center|中间的布局 Image leftAvatar|中间布局左边的图片 Image rightAvatar|中间布局右边的图片 Text leftNickName|左边布局的名字 Text rightNickName|右边布局的名字 List<Text> leftInterests|左边布局名称下面的分类文字 List<Text> rightInterests|右边布局文字下面的分类文字 设置你的Provider ```ListContainer``` ```Java ListContainer listContainer = (ListContainer) findComponentById(ResourceTable.Id_listContainer); FriendProvider provider = new FriendProvider(this, Utils.friends); listContainer.setItemProvider(provider); listContainer.setLongClickable(false); ``` #### 测试信息 CodeCheck代码测试无异常 CloudTest代码测试无异常 火绒安全病毒安全检测通过 #### 版本迭代 0.0.2-SNAPSHOT #### 版权和许可信息 ``` Copyright 2015, Yalantis 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. ```