circle-indicator-cj:基于 Cangjie 的 UI 组件库项目

圆形指示器归一化UI组件

Branch1Tags0
FilesLast commitLast update
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago

circleIndicator4cj

介绍

circleIndicator4cj 是一款 UI 组件库,为 Tabs/Swiper 容器提供了多种自定义风格的指示器。

效果展示:

圆形指示器:

长条指示器:

横幅指示器:

图标指示器:

携带中央视图的Tabs指示器:

固定位置Tabs指示器:

固定位置Tabs指示器(胶囊风格):

固定位置Tabs指示器(携带角标):

可滑动Tabs指示器:

可滑动Tabs指示器(水滴滑块):

可滑动Tabs指示器(首列固定):

titles指示器:

特性

  • 支持圆形指示器
  • 支持长条指示器:
  • 支持横幅指示器:
  • 支持图标指示器:
  • 支持携带中央视图的Tabs指示器:
  • 支持固定位置 Tabs 指示器
  • 支持固定位置 Tabs 指示器(胶囊风格)
  • 支持固定位置 Tabs 指示器(携带角标)
  • 支持可滑动 Tabs 指示器
  • 支持可滑动 Tabs 指示器(水滴滑块)
  • 支持可滑动 Tabs 指示器(首列固定)
  • 支持 titles 指示器

源码目录

├─AppScope
├─doc        # API文档和使用手册存放目录                   
├─entry      # 示例代码文件夹                  
├─circleIndicator    # circleIndicator 库文件夹                   
│  └─src
│      └─main
│          ├─cangjie
│          │  └─src                                     
│          │      ├─indicator      # 指示器组件
│          │      ├─model          # 指示器数据
│          │      ├─utils          # 公共类
│          └─resources
├─hvigor  # 构建工具目录
├─README.md  # circleIndicator4cj 介绍及使用说明   

接口说明

主要类和函数接口说明详见 API

使用说明

  1. 通过 module 引入

    1. 克隆下载项目
    2. 将 circleIndicator4cj 模块拷贝到应用项目下
    3. 修改自身应用 entry 下的 oh-package.json5 文件,在 dependencies 字段添加 "circleIndicator": "file:../circleIndicator"
    {
       "name": "entry",
       "version": "1.0.0",
       "description": "Please describe the basic information.",
       "main": "",
       "author": "",
       "license": "",
      "dependencies": {
          "circleIndicator": "file:../circleIndicator"
      }
    }
    
    1. 修改自身应用 entry/src/main/cangjie 下的 cjpm.toml 文件,在 [dependencies] 字段下添加 circleIndicator = {path = "../../../../circleIndicator/src/main/cangjie", version = "1.0.0"}
      [dependencies]
          circleIndicator = {path = "../../../../circleIndicator/src/main/cangjie", version = "1.0.0"}
      
    2. 在项目中使用 import circleIndicator.* 引用 circleIndicator 项目
      import circleIndicator.*
      
  2. 把 circleIndicator4cj 作为三方库依赖引入

    1. 目标工程把 circleIndicator4cj 依赖库作为 git submodule 引入
    > cd $工程根目录
    > mkdir third-party
    > cd third-party
    > git submodule add "https://gitcode.com/Cangjie-TPC/circleIndicator4cj.git"
    
    1. 修改自身应用 entry/src/main/cangjie 下的 cjpm.toml 文件,添加依赖
    [dependencies]
        circleIndicator = {path = "../../../../third-party/circleIndicator4cj/circleIndicator/src/main/cangjie", version = "1.0.0"}
    
    1. 在项目中使用 circleIndicator 组件
      import circleIndicator.*
      

功能示例

详见 entry

横幅指示器

import ohos.state_macro_manage.Entry
import ohos.state_macro_manage.Component
import ohos.state_macro_manage.State
import ohos.state_macro_manage.r

@Entry
@Component
class BannerSampleAutoPlay {
    var swiperController: SwiperController = SwiperController()
    var model: BannerModel =  BannerModel(this.swiperController)
    @State
    var index: Int32 = 0
    @State
    var count: Int32 = 4
    protected override func aboutToAppear(): Unit {
        this.model.startAutoPlay()
        this.model.setAutoPlayTime(1000)
    }
    func build() {
    Flex(FlexParams (direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center) ) {
      Swiper(this.swiperController) {
        Image(@r(app.media.p1))
          .objectFit(ImageFit.Cover)
          .width(100.percent)
          .height(440.lpx)

        Image(@r(app.media.p2))
          .objectFit(ImageFit.Cover)
          .width(100.percent)
          .height(440.lpx)

        Image(@r(app.media.p3))
          .objectFit(ImageFit.Cover)
          .width(100.percent)
          .height(440.lpx)

        Image(@r(app.media.p4))
          .objectFit(ImageFit.Cover)
          .width(100.percent)
          .height(440.lpx)
      }
      .loop(true)
      .indicator(false)
      .onTouch({event: TouchEvent =>
        this.model.notifyTouch(event, this.index)
      })
      .onChange({index: Int32 =>
        this.index = index
      })

      BannerIndicator(count: this.count, flingIndex: this.index, model: this.model )
    }
    .width(100.percent)
    .height(100.percent)
    }
}

约束与限制

在下述版本验证通过:

DevEco Studio 5.0.13.200
Cangjie Support Plugin 5.0.13.200

1. 仓颉 UI `Cangjie Support Plugin 5.0.3.906 `未支持 `Path()` 和 `Polygon` 组件,所以部分效果未支持;
2. 三角指示器(triangulaiIndicator)、可滑动tab指示器水滴滑块(SpringScrollTabsIndicator)不支持;

开源协议

本项目基于 Apache License 2.0,请自由的享受和参与开源。

参与贡献

欢迎给我们提交PR,欢迎给我们提交Issue,欢迎参与任何形式的贡献。

Introduction

圆形指示器归一化UI组件

Customize your domain