# Lighter **Repository Path**: chinasoft_ohos/Lighter ## Basic Information - **Project Name**: Lighter - **Description**: 高亮功能的库: 1、一次可以显示一个或多个高亮显示的视图 2、用于高亮显示视图的绘制 3、可自定义高亮显示视图的形状和形状的大小 4、可自定义提示视图 5、可自定义相对位置简单易用的链接显示 - **Primary Language**: Java - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 2 - **Forks**: 0 - **Created**: 2021-04-09 - **Last Updated**: 2022-11-29 ## Categories & Tags **Categories**: harmonyos-advanced **Tags**: None ## README # Lighter #### 项目介绍 - 项目名称:Lighter - 所属系列:openharmony的第三方组件适配移植 - 功能:Lighter是一个首次进入页面的按钮提示功能库 - 项目移植状态:主功能完成 - 调用差异:无 - 开发版本:sdk6,DevEco Studio2.2 beta1 - 基线版本:release 1.0.3 #### 效果演示 ![效果演示](/gif/new_tab.gif "截图.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:Lighter:1.0.4') ...... } ``` 在sdk6,DevEco Studio2.2 beta1下项目可直接运行 如无法运行,删除项目.gradle,.idea,build,gradle,build.gradle文件, 并依据自己的版本创建新项目,将新项目的对应文件复制到根目录下 #### 使用说明 你可以指定highlight view所依附的父view, 通过使用以下代码来指定: ```java Lighter with(ComponentContainer rootView) //使用 'rootView' 作为父view ``` 完整调用: ```java Lighter lighter = Lighter.with(viewpager_root) .setBackgroundColor(0x000000, 0.5f) .setIntercept(true) .addHighlight(new LighterParameter.Builder() .setHighlightedViewId(ResourceTable.Id_vp_btn_1) .setLighterShape(new OvalShape()) .setTipView(mTipViewList.get(0)) .setTipViewDisplayAnimation(LighterHelper.getScaleAnimation()) .setTipViewRelativeDirection(Direction.RIGHT) .setTipViewRelativeOffset(new MarginOffset(30, 0, 80, 0)) .build()) .addHighlight(new LighterParameter.Builder() .setHighlightedViewId(ResourceTable.Id_vp_btn_2) .setLighterShape(new OvalShape()) .setTipView(mTipViewList.get(1)) .setTipViewRelativeDirection(Direction.LEFT) .setTipViewDisplayAnimation(LighterHelper.getScaleAnimation()) .setTipViewRelativeOffset(new MarginOffset(50, 0, 100, 0)) .build()) .addHighlight(new LighterParameter.Builder() .setHighlightedViewId(ResourceTable.Id_vp_btn_3) .setLighterShape(new OvalShape()) .setTipView(mTipViewList.get(2)) .setTipViewRelativeDirection(Direction.TOP) .setTipViewDisplayAnimation(LighterHelper.getScaleAnimation()) .setTipViewRelativeOffset(new MarginOffset(-400, 0, 0, 30)) .build()); lighter.show(); ``` 当你需要一次显示多个高亮的时候, 可调用**addHighlight(LighterParameter...lighterParameters)** ```java Lighter.with(ability) .addHighlight( //一次显示两个高亮 new LighterParameter.Builder() .setHighlightedViewId(R.id.vp_btn_1) .setTipLayoutId(R.layout.layout_tip_1) .setLighterShape(new RectShape(5, 5, 30)) .setTipViewRelativeDirection(Direction.BOTTOM) .setTipViewRelativeOffset(new MarginOffset(150, 0, 30, 0)) .build(), new LighterParameter.Builder() .setHighlightedViewId(R.id.vp_btn_2) .setTipLayoutId(R.layout.layout_tip_2) .setLighterShape(new RectShape(5, 5, 30)) .setTipViewRelativeDirection(Direction.TOP) .setTipViewRelativeOffset(new MarginOffset(-400, 0, 0, 30)) .build()) .show(); ``` ##### 关于 [LighterParameter.Builder](https://gitee.com/chinasoft_ohos/Lighter/blob/master/lighter/src/main/java/me/samlss/lighter/parameter/LighterParameter.java) | Method | Description | | :-------------------------- | :------------------------------- | | setHighlightedViewId | 设置需要高亮的view id | | setAutoVerticalFixed | 设置垂直方向是否需要自动修改展示位置 | | setHighlightedView | 设置需要高亮的view | | setTipLayoutId | 设置提示view的layout id | | setTipView | 设置提示view | | setLighterShape | 设置围着高亮view的形状 | | setShapeXOffset | 设置形状的x偏移量 | | setShapeYOffset | 设置形状的y偏移量 | | setTipViewRelativeDirection | 设置提示view相对高亮view的方向 | | setTipViewRelativeOffset | 设置提示view相对高亮view的便宜量 | | setTipViewDisplayAnimation | 设置提示view的显示动画 | | build | 创建LighterParameter对象 | ###### 注意: - setHighlightedViewId & setHighlightedView - setTipLayoutId & setTipView 上面两组方法中,只需使用其中一个方法,若都不使用的话,则会抛出异常 ##### 关于 [Shape](https://gitee.com/chinasoft_ohos/Lighter/tree/master/lighter/src/main/java/me/samlss/lighter/shape) | Shape | Description | | ------ | ---------------------------- | | Rect | 可设置圆角和模糊度的矩形图形 | | Circle | 可设置模糊度的圆形 | | Oval | 可设置模糊度的椭圆形 | ###### ShapeXOffset & ShapeYOffset 参考下面图片 : ![Lighter](./screenshots/screenshot6.png) ###### 关于提示view的参数 ###### 方向 参考下面图片: ![Lighter](./screenshots/screenshot7.png) ###### 偏移量 当指定方向后(默认为左边), 偏移量计算基于方向 例如: Left: topMargin 和 rightMargin生效 Right: topMargin 和 leftmargin生效 Top: 当高亮view处于屏幕的左边的时候, teftMargin & bottomMargin生效. 否则, rightMargin & bottomMargin生效 Bottom: 当高亮view处于屏幕的左边的时候, leftMargin 和 topMargin生效. 否则, rightMargin & topMargin生效 ###### Animation 可使用任何动画 #### 测试信息 CodeCheck代码测试无异常 CloudTest代码测试无异常 病毒安全检测通过 当前版本demo功能与原组件基本无差异 #### 版本迭代 - 1.0.4 - 0.0.1-SNAPSHOT #### 版权和许可信息 ``` Copyright 2018 samlss 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. ```