Skip to content

A fully customizable super-easy Page Indicator, with stunning animations and very original and discreet graphics, for HMOS. Needs a very small screen, perfect when many pages need to be shown and reached in a small time.

License

Notifications You must be signed in to change notification settings

Applib-HarmonyOS/ArcPageIndicator

Repository files navigation

ArcPageIndicator Quality Gate Status Build

Bored of the usual small points or stressed by the space occupied by a tab bar?
Try this elevator-like elegant and original page indicator! A fully customizable super-easy Page Indicator, with stunning animations and very original and discreet graphics, for HarmonyOS. Needs a very small screen, perfect when many pages need to be shown and reached in a small time.


  • Out-of-the-box working indicator
  • Fully customizable and styleable
  • Can be programmatically controlled
  • Includes rather complex ellipses calculations :-)


An old elevator that inspired this project.

Source

The code in this repository was inspired from BeppiMenozzi/ArcPageIndicator - v1.0.2. We are very thankful to Mr. BeppiMenozzi.

Dependency

  1. For using ArcPageIndicator module in sample app, include the source code and add the below dependencies in entry/build.gradle to generate hap/support.har.
	dependencies {
		implementation project(':arcpageindicator')
        	implementation fileTree(dir: 'libs', include: ['*.har'])
        	testCompile 'junit:junit:4.12'
	}
  1. For using ArcPageIndicator in separate application using har file, add the har file in the entry/libs folder and add the dependencies in entry/build.gradle file.
	dependencies {
		implementation fileTree(dir: 'libs', include: ['*.har'])
		testCompile 'junit:junit:4.12'
	}

  1. For using ArcPageIndicator from a remote repository in separate application, add the below dependencies in entry/build.gradle file.
	dependencies {
		implementation 'dev.applibgroup:arcpageindicator:1.0.0'
		testCompile 'junit:junit:4.12'
	}

Minimal usage

Layout for left 180° ellipse:

    <it.beppi.arcpageindicator.ArcPageIndicator
        ohos:height="120vp"
        ohos:width="60vp"
        ohos:vertical_center="true"
        ohos:align_right="$id:page_slider"
        ohos:id="$+id:arc_pi_5"
        app:pageSliderId="$id:page_slider"
        app:arcOrientation="toLeft"
        app:animationType="fill"
        app:spotsColor = "#FFFFFFFF"
        app:selectedSpotColor = "#FF000000"
        />

Layout for upper-right 90° ellipse:

    <it.beppi.arcpageindicator.ArcPageIndicator
        ohos:height="60vp"
        ohos:width="60vp"
        ohos:align_bottom="$id:page_slider"
        ohos:align_left="$id:page_slider"
        ohos:id="$+id:arc_pi_2"
        app:pageSliderId="$id:page_slider"
        app:arcOrientation="toUpRight"
        app:animationType="slide"
        app:spotsRadius = "18"
        app:spotsColor = "#FF3F51B5"
        app:selectedSpotColor = "#FFFF4081"
        />

Attributes description

List of attributes with description:

General
pageSliderIdThe pageSlider Id associated to the Indicator
Arc appearance
arcOrientationOrientation of the "belly" of the arc. This parameter also affects if the arc will be 90° (corner arc) or 180° (edge arc)
Spot appearance
spotsColorColor of the spots
selectedSpotColorColor of the selected spot
spotsRadiusSize of the spots
spotsShapeShape of the spots: Circle, RoundedSquare or Square
Spots distribution and movement
intervalMeasureHow spots are distributed on the circumference: constant angle or constant arc length. With constant angle, the spots will not be distributed evenly, because of ellipse's eccentricity. Normally constant arc length is used: being a non-finite math problem, here an approximation function is used, as explained later on.
invertDirectionIf spots will be selected in inverted direction
animationTypeSee below to detailed explanation of animation types
Hand appearance
handEnabledIf hand is drawn
handColorHand's color
handWidthHand's width
handRelativeLengthHand's relative length starting from center to edges (1 = full length)

Animation types

List of animation types:

NametoBottomRighttoUpNotes
Color
Color cross-fade
Slide
Simple movement
Pinch
Simple movement
with size reduction
Bump
Simple movement
with size growth.
Might need additional padding
Rotate
Inverted movement of all spots
Rotate Pinch
Inverted movement of all spots
with size reduction
Cover
Spots are filled from inside
Fill
Spots are empty and filled from inside
Surround
Simple movement of a circle
surrounding smaller spots
Necklace
Inverted movement of all spots,
with center spot biggest
and lateral spots smaller
Necklace 2
Inverted movement of all spots,
with selected spot biggest
and farthest spot smallest
Example of hand
Example of rounded squared spots

Some maths

This question Mr. Beppi Menozzi made helped him solve the ellipse's problem. Indeed, finding arcs of constant length on a known ellipse is a problem with a non-finite solution, that needs integrals to be calculated. There were at least 5 approaches to solve this problem with acceptable performance:

  • find the points recursively, by iteratively reducing the error until it's close enough to zero. Pros: easy to do. Cons: adds a indetermined (although very small) time to the drawing process
  • create a big table of sampled data and storing them to provide a database of pre-calculated solutions. Pros: fastest. Cons: can't work for any number of elements
  • distribute the points on the radius and project them on the circumference. Pros: very fast. Cons: error still pretty large
  • use an approximated function. Pros: fast and good enough. Cons: never perfect
  • calculate the elliptic integrals. Pros: perfect. Cons: very very very heavy on performance

He chose to find a good approximated function and that is what you can find inside the code, it's fast enough and the error is near to invisibility. In case you need more performance, you can remove the e6 part of the formula and have a slightly bigger error.

The formula used is the one of the referenced question, and thanks very much to its author, Ng Chung Tak that is both the author of the answer, and the author of the formula itself.

Author

License

The MIT License (MIT)

Copyright (c) 2016 Beppi Menozzi

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

About

A fully customizable super-easy Page Indicator, with stunning animations and very original and discreet graphics, for HMOS. Needs a very small screen, perfect when many pages need to be shown and reached in a small time.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages