回复
鸿蒙开源组件——CookieBar弹窗控件
jacksky
发布于 2021-8-18 11:45
浏览
0收藏
CookieBar2
项目介绍
- 项目名称:CookieBar2
- 所属系列:openharmony的第三方组件适配移植
- 功能:CookieBar2是一个底部和顶部可弹出Bar的控件,且可以自动弹回或者侧滑删除
- 项目移植状态:主功能完成
- 调用差异:有一定差异(具体看使用说明)
- 开发版本:sdk6,DevEco Studio2.2 Beta1
- 基线版本:Release 1.1.4
效果演示
安装教程
1.在项目根目录下的build.gradle文件中,
allprojects {
repositories {
maven {
url 'https://s01.oss.sonatype.org/content/repositories/snapshots/'
}
}
}
2.在entry模块的build.gradle文件中,
dependencies {
implementation('com.gitee.chinasoft_ohos:cookiebar2:0.0.1-SNAPSHOT')
......
}
在sdk6,DevEco Studio2.2 Beta1下项目可直接运行 如无法运行,删除项目.gradle,.idea,build,gradle,build.gradle文件, 并依据自己的版本创建新项目,将新项目的对应文件复制到根目录下
使用说明
使用以下方法来设置top和bottom的关联,可以使点击两个CookieBar空白同时回收,且可同时进行侧滑
cookieTopView.setCookieBottomView(cookieBottomView);
当需要点击空白回收的时候,请在rootComponent添加以下方法
rootComponent.setClickedListener(component -> {
if (cookieTopView.isTopExist) {
cookieTopView.isNeedTopToBottom = false;
cookieTopView.startAnimationBottom();
cookieTopView.isTopExist = false;
} else if (cookieTopView.isLeftExit) {
cookieTopView.isNeedLeftToRight = false;
cookieTopView.startAnimationRight();
cookieTopView.isLeftExit = false;
}
if (cookieBottomView.isExit) {
cookieBottomView.removeHandler();
cookieBottomView.isNeedTopToBottom = false;
cookieBottomView.startAnimationBottom();
}
});
xml布局
<org.aviran.cookiebar2.CookieTopView
ohos:id="$+id:cookieTopView"
ohos:height="match_parent"
ohos:width="match_parent"
app:title="Top cookie with an icon!"
app:message="This is a top cookie with an icon (#%d)"/>
<org.aviran.cookiebar2.CookieBottomView
ohos:id="$+id:cookieBottomView"
ohos:height="match_parent"
ohos:width="match_parent"
app:message="This is a top cookie with an icon (#%d)"
app:title="Top cookie with an icon!"/>
完整示例 topCookieBar:
topCookieButton.setClickedListener(component -> {
topCookieBarTimes = topCookieBarTimes + 1;
cookieTopView.setIcon(ResourceTable.Media_icon);
cookieTopView.setDuration(5000);
cookieTopView.setTitle("Top cookie with an icon!");
cookieTopView.setTitleColor(Color.YELLOW);
cookieTopView.setMessage("This is a top cookie with an icon (#" + topCookieBarTimes + ")");
cookieTopView.setMessageColor(Color.WHITE);
ShapeElement shapeElement = new ShapeElement();
shapeElement.setRgbColor(new RgbColor(171, 71, 188));
cookieTopView.setBackgroundColor(shapeElement);
cookieTopView.startAnimationTopToBottom();
});
bottomCookieBar(不带botton):
cookieBottomView.setDuration(5000);
cookieBottomView.setTitle("Bottom cookie with and icon");
cookieBottomView.setTitleColor(Color.YELLOW);
cookieBottomView.setMessage("This is a bottom cookie with an icon and an action. Nice right?");
cookieBottomView.setMessageColor(Color.WHITE);
cookieBottomView.setAction("Action");
cookieBottomView.setActionColor(Color.YELLOW);
cookieBottomView.setIcon(ResourceTable.Media_icon);
cookieBottomView.showThreeStatusButton(false);// 是否需要显示三个状态按钮
ShapeElement shapeElement = new ShapeElement();
shapeElement.setRgbColor(new RgbColor(33, 150, 243));
cookieBottomView.setBackgroundColor(shapeElement);
cookieBottomView.startAnimationBottomToTop();
bottomCookieBar(带botton的):
cookieBottomView.setTitle("Custom cookie view demo!");
cookieBottomView.setTitleColor(Color.WHITE);
cookieBottomView.setMessage("You can customize CookieBar2. Here's an example of a simple dialog.");
cookieTopView.setMessageColor(Color.WHITE);
cookieBottomView.setAction("CLOSE");
Color color = new Color(Color.getIntColor("#26a69a"));
cookieBottomView.setActionColor(color);
cookieBottomView.setIcon(ResourceTable.Media_icon);
cookieBottomView.showThreeStatusButton(true); // 是否需要显示三个状态按钮
ShapeElement shapeElement = new ShapeElement();
shapeElement.setRgbColor(new RgbColor(63, 81, 181));
cookieBottomView.setBackgroundColor(shapeElement);
cookieBottomView.startAnimationBottomToTop();
关于 CookieTopView
Method | Description |
---|---|
setIcon | 设置CookieBar的icon |
setDuration | 设置CookieBar的回收时间 |
setTitle | 设置CookieBar的Title |
setTitleColor | 设置CookieBar的Title的字体颜色 |
setMessage | 设置CookieBar的Message |
setMessageColor | 设置CookieBar的Message的字体颜色 |
setBackgroundColor | 设置CookieBar的背景颜色 |
startAnimationTopToBottom | CookieBar从上到下开始的动画调用方法 |
startAnimationLeftToRight | 开始CookieBar上方从左到有右的动画调用方法 |
关于 CookieBottomView
Method | Description |
---|---|
setIcon | 设置CookieBar的icon |
setDuration | 设置CookieBar的回收时间 |
setTitle | 设置CookieBar的Title |
setTitleColor | 设置CookieBar的Title的字体颜色 |
setAction | 设置CookieBar的按钮文字 |
setActionColor | 设置CookieBar的action按钮的字体颜色 |
showThreeStatusButton | 是否显示三个状态按钮 |
setNewBtListener | 设置NEW按钮的监听 |
setOpenBtListener | 设置OPEN按钮的监听 |
setSaveBtListener | 设置SAVE按钮的监听 |
setMessage | 设置CookieBar的Message |
setMessageColor | 设置CookieBar的Message的字体颜色 |
setBackgroundColor | 设置CookieBar的背景颜色 |
startAnimationBottomToTop | 开始底部向上的动画调用方法 |
测试信息
CodeCheck代码测试无异常
CloudTest代码测试无异常
病毒安全检测通过
当前版本demo功能与原组件基本无差异
版本迭代
- 0.0.1-SNAPSHOT
版权和许可信息
opyright 2018, Aviran Abady.
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.
CookieBar2-master.zip 1.32M 8次下载
已于2021-8-18 11:45:10修改
赞
收藏
回复
相关推荐