# expanding-collection-ohos
**Repository Path**: chinasoft4_ohos/expanding-collection-ohos
## Basic Information
- **Project Name**: expanding-collection-ohos
- **Description**: ExpandingCollection is a material design card peek/pop controller
- **Primary Language**: Unknown
- **License**: MIT
- **Default Branch**: master
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 0
- **Forks**: 2
- **Created**: 2021-07-08
- **Last Updated**: 2021-09-26
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README
# expanding-collection-ohos
## 项目介绍
- 项目名称:expanding-collection-ohos
- 所属系列:openharmony的第三方组件适配移植
- 功能:一个可以展开查看详情的卡片,背景可跟随卡片来回切换的视图切换器
- 项目移植状态:主功能完成
- 调用差异:无
- 开发版本:sdk6,DevEco Studio 2.2 Beta1
- 基线版本:master分支
## 安装教程
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:expanding-collection:1.0.0'
......
}
```
在sdk6,DevEco Studio2.2 Beta1下项目可直接运行,如无法运行,删除项目.gradle,.idea,build,gradle,build.gradle文件,并依据自己的版本创建新项目,将新项目的对应文件复制到根目录下
## 使用说明
```
1.XML中添加控件
2.MainAbility中代码
ecSwitcher = (EcBackgroundSwitcherView) findComponentById(ResourceTable.Id_ecSwitcher);
pageSlider = (EcPageSlider) findComponentById(ResourceTable.Id_pageSlider);
itemCount = (ItemsCountView) findComponentById(ResourceTable.Id_itemCount);
width = pageSlider.getCardWidth();
height = pageSlider.getCardHeight();
fullWidth = ResUtils.getScreenWidth(this);
fullHeight = ResUtils.getScreenHeight(this);
List dataList = new ExampleDataset().getDataset();
EcPagerViewAdapter ecProvider = new EcPagerViewAdapter(this, dataList) {
@Override
public void instantiateCard(ComponentContainer componentContainer, int i, EcCardData data) {
final CardData cardData = (CardData) data;
ListContainer listContainer = new ListContainer(MainAbility.this);
provider = new CommentArrayProvider(MainAbility.this, cardData, data.getListItems());
listContainer.setItemProvider(provider);
listContainer.setEnabled(false);
listContainers.add(listContainer);
StackLayout.LayoutConfig layoutParams = new StackLayout.LayoutConfig(width, height);
layoutParams.alignment = LayoutAlignment.CENTER;
ShapeElement element = new ShapeElement();
element.setRgbColor(RgbColor.fromArgbInt(Color.getIntColor("#FFFFFF")));
componentContainer.addComponent(listContainer, layoutParams);
listContainer.setBackground(element);
AlphaScalePageTransformer.defaultPage(listContainer, i, pageSlider.getCurrentPage());
listContainer.setItemClickedListener((listContainer1, component, pos, l) -> {
if (pos <= 1) {
toggle();
}
});
}
};
pageSlider.setPagerViewAdapter(ecProvider, dataList);
pageSlider.setBackgroundSwitcherView(ecSwitcher);
pageSlider.setOnCardSelectedListener((newPosition, oldPosition, totalElements) ->
itemCount.update(newPosition, oldPosition, totalElements));
pageSlider.addPageChangedListener(new PageChangedListener() {
@Override
public void onPageSliding(int position, float positionOffset, int positionOffsetPixels) {
AlphaScalePageTransformer.transformPage(listContainers, position, positionOffset, positionOffsetPixels);
}
});
```
## 效果演示
## 测试信息
CodeCheck代码测试无异常
CloudTest代码测试无异常
病毒安全检测通过
当前版本demo功能与原组件基本无差异
## 版本迭代
- 1.0.0
## 版权和许可信息
Expanding Collection Android is released under the MIT license. See LICENSE for details.
This library is a part of a selection of our best UI open-source projects
If you use the open-source library in your project, please make sure to credit and backlink to www.ramotion.com