ohos_CircularProgressBar:基于 OpenHarmony 的圆形进度条组件项目

支持渐变色与动画的Android圆形进度条控件

Branch1Tags1
FilesLast commitLast update
7 months ago
7 months ago
5 months ago
5 months ago
7 months ago
7 months ago
5 months ago
8 years ago
5 months ago
7 months ago
6 months ago
5 months ago
5 months ago
5 months ago
7 months ago
7 months ago
5 months ago

CircularProgressBar

This project is developed based on CircularProgressBar.

Introduction

CircularProgressBar is a customizable circular progress bar component. It supports gradient colors, indeterminate mode, animations, and various customization options.

Demo

CircularProgressBar Demo

Installation

ohpm install @ohos/circularprogressbar

For more information about OpenHarmony ohpm environment configuration, please refer to How to Install OpenHarmony ohpm Packages.

Constraints and Limitations

Compatibility

Verified on the following versions:

  • DevEco Studio: DevEco Studio 6.0.2 Release (6.0.2.640), SDK: API22 (6.0.2.130)
  • DevEco Studio: NEXT Developer Beta1 (5.0.3.122), SDK: API12 (5.0.0.18)

Permissions Required

None

Usage Example

import { CircularProgressBar } from '@ohos/circularprogressbar';

@Entry
@Component
struct Index {
  build() {
    Column() {
      CircularProgressBar({
        backgroundProgressBar: {
          width: 10,
          color: '#E0E0E0'
        },
        frontProgressBar: {
          startAngle: 0,
          endAngle: 65,
          progressMax: 100,
          color: "#2196F3",
          roundBorder: false
        }
      })
        .width(200)
        .height(200)
    }
    .width('100%')
    .height('100%')
  }
}

API Reference

Component Parameters

CircularProgressBar

Parameter Type Required Description
backgroundProgressBar BackgroundProgressBarImpl Yes Background progress bar configuration
frontProgressBar FrontProgressBarImpl Yes Front progress bar configuration
setOnIndeterminateModeChangeListener (isIndeterminate: boolean) => void No Callback when indeterminate mode changes
setOnProgressChangeListener (progress: number) => void No Callback when progress value changes
animationArgs AnimationArgs No Animation configuration object

BackgroundProgressBarImpl

Property Type Default Description
width number 10 Width of the background progress bar
color string '#CCCCCC' Solid color (used if colorStart/colorEnd not set)
colorStart string / Gradient start color
colorEnd string / Gradient end color
colorDirection ColorDirection LEFT_TO_RIGHT Gradient direction

FrontProgressBarImpl

Property Type Default Description
width number 20 Width of the front progress bar
color string '#CCCCCC' Solid color (used if colorStart/colorEnd not set)
colorStart string / Gradient start color
colorEnd string / Gradient end color
colorDirection ColorDirection LEFT_TO_RIGHT Gradient direction
progress number 0 Current progress value
progressMax number 100 Maximum progress value
startAngle number 0 Start angle in degrees
endAngle number 0 End angle in degrees
progressDirection Direction to_right Progress direction (clockwise/counter-clockwise)
roundBorder boolean false Enable rounded line caps
indeterminateMode boolean false Enable indeterminate (loading) mode

AnimationArgs

Property Type Default Description
progress number 100 Target progress value to animate to
duration number 1500 Animation duration in milliseconds
easing string ease Animation curve
startDelay number 0 Animation delay in milliseconds

Enums

ColorDirection

enum ColorDirection {
  LEFT_TO_RIGHT,
  RIGHT_TO_LEFT,
  TOP_TO_BOTTOM,
  BOTTOM_TO_END 
}

Direction

enum Direction {
  to_right,
  to_left
}

Directory Structure

/CircularProgressBar      # Project root directory
├── entry                 # Example code folder
│   └── src/main/ets/pages
│       └── Index.ets  # Example usage
├── library               # CircularProgressBar library folder
│   └── src/main/ets/components
│       ├── circularProgressBar.ets  # Main component
│       ├── progressBar.ets          # Enums and interfaces
│       └── progressBarImpl.ets      # Implementation classes
├── README.md             # Installation and usage (English)
├── README_zh.md          # Installation and usage (Chinese)
└── CHANGELOG.md          # Changelog

About Obfuscation

  • For code obfuscation, please see Introduction to Code Obfuscation.
  • If you want the circularprogressbar library to be excluded from obfuscation, you need to add exclusion rules in the obfuscation-rules.txt configuration file:
-keep
./oh_modules/@ohos/circularprogressbar

Contributing

If you find any issues during usage, you are welcome to submit Issues. Of course, Pull Requests are also highly appreciated.

License

This project is licensed under the Apache-2.0.

Introduction

支持渐变色与动画的Android圆形进度条控件

Customize your domain