自定义侧滑操作UI组件
| 文件 | 最后提交记录 | 最后更新时间 |
|---|---|---|
| 1 年前 | ||
| 1 年前 | ||
| 1 年前 | ||
| 1 年前 | ||
| 1 年前 | ||
| 1 年前 | ||
| 1 年前 | ||
| 1 年前 | ||
| 1 年前 | ||
| 1 年前 | ||
| 1 年前 | ||
| 1 年前 | ||
| 1 年前 | ||
| 1 年前 |
介绍
swipe-item-cj 支持组件左侧和右侧的滑动布局。
特性
- 支持组件左侧和右侧的滑动布局;
源码目录
├─AppScope
├─doc # API文档和使用手册存放目录
├─entry # 示例代码文件夹
├─swipeitem # swipeItemlayout 库源目录
│ └─src
│ └─main
│ ├─cangjie
│ │ └─src
│ │ ├─swipe_item_layout.cj # 左右侧滑动容器
│ └─resources
├─hvigor # 构建工具目录
├─README.md # swipe-item-cj 介绍及使用说明
接口说明
主要类和函数接口说明详见 API
使用说明
-
通过 module 引入
- 克隆下载项目
- 将 swipeitem 模块拷贝到应用项目下
- 修改自身应用 entry 下的 oh-package.json5 文件,在 dependencies 字段添加 "swipeitem": "file:../swipeitem"
{ "name": "entry", "version": "1.0.0", "description": "Please describe the basic information.", "main": "", "author": "", "license": "", "dependencies": { "swipeitem": "file:../swipeitem" } }- 修改自身应用 entry/src/main/cangjie 下的 cjpm.toml 文件,在 [dependencies] 字段下添加 swipeitem = {path = "../../../../swipeitem/src/main/cangjie", version = "1.0.0"}
[dependencies] swipeitem = {path = "../../../../swipeitem/src/main/cangjie", version = "1.0.0"} - 在项目中使用 import swipeitem.* 引用 swipeitem 项目
import swipeitem.*
-
把 swipe-item-cj 作为三方库依赖引入
- 目标工程把 swipe-item-cj 依赖库作为 git submodule 引入
> cd $工程根目录 > mkdir third-party > cd third-party > git submodule add "https://gitcode.com/Cangjie-TPC/swipe-item-cj.git"- 修改自身应用 entry/src/main/cangjie 下的 cjpm.toml 文件,添加依赖
[dependencies] swipeitem = {path = "../../../../third-party/swipe-item-cj/swipeitem/src/main/cangjie", version = "1.0.0"}- 在项目中使用 swipeitem 组件
import swipeitem.*
功能示例
详见 entry
左右侧滑动示例
import ohos.base.*
import ohos.component.*
import ohos.state_manage.*
import ohos.state_macro_manage.*
import swipeitem.*
import ohos.prompt_action.*
import ohos.hilog.Hilog
@Entry
@Component
class NormalView {
var content: String = "侧滑内容子组件侧滑内容子组件侧滑内容子组件"
protected override func aboutToAppear() {
AppLog.info("aboutToAppear")
}
@Builder
func surfaceView(itemContent: String, itemId: Int64) {
Text(itemContent).fontSize(16).width(100.percent).height(45).fontColor(Color(0x999999)).backgroundColor(
Color(0xEBEBEB)).padding(left: 10.0)
}
@Builder
func swipeRightView(itemId: Int64) {
Text("删除").fontSize(14).backgroundColor(0xFFFF1E38).fontColor(Color.WHITE).width(100.percent).height(
100.percent).textAlign(TextAlign.Center).onClick(
{
evt => PromptAction.showToast(
message: "delete",
duration: 1500,
)
})
}
@Builder
func swipeLeftView(itemId: Int64) {
Text("选择").fontSize(14).backgroundColor(0x317aff).fontColor(Color.WHITE).width(100.percent).height(
100.percent).textAlign(TextAlign.Center).onClick(
{
evt => PromptAction.showToast(
message: "choose",
duration: 1500,
)
})
}
func build() {
Row {
Column() {
ColumnSplit() {
SwipeItemLayout(
mWidth: 100.0,
mHeight: 45.0,
swipeLeftWidth: 85.0,
swipeRightWidth: 85.0,
surfaceView: surfaceView,
swipeLeftView: this.swipeLeftView,
swipeRightView: this.swipeRightView,
itemContent: content,
itemId: 0
)
}.height(10.percent)
}.width(100.percent)
}.height(100.percent)
}
}
约束与限制
在下述版本验证通过:
DevEco Studio NEXT Developer Beta2(5.0.3.906)
Cangjie Support Plugin 5.0.3.906
Cangjie Compiler: 0.53.13 (cjnative)
开源协议
本项目基于 MIT License,请自由的享受和参与开源。
参与贡献
欢迎给我们提交PR,欢迎给我们提交Issue,欢迎参与任何形式的贡献。