Loading indicator for watchOS. Project is based on EMTLoadingIndicator but I needed some customizations, SPM compatability and implemented some fancy that would be too much to expect to get accepted for a PR.
Using Swift Package Manager, add https://github.com/Reiszecke/LiquidLoadingIndicator
as a dependency, and add it to your WatchKit Extension.
private var indicator: LiquidLoadingIndicator?
override func willActivate() {
indicator = LiquidLoadingIndicator(interfaceController: self, interfaceImage: image!,
width: 40, height: 40, style: .line)
width and height are the size of WKInterfaceImage passed to 2nd argument. Indicator images will be created with this size. Style argument decides the visual of wait (loop) indicator - Dot or Line.
This is where the project differs from the original. The original indicator could just do this:
indicator = LiquidLoadingIndicator(interfaceController: self, interfaceImage: image!,
width: 40, height: 40, style: .line)
indicator?.showWait()
indicator?.hide()
With this repo, you can adjust parameters like line width on the object itself.
indicator.setLineWidth(5.3)
indicator.setLineColor(UIColor(red: 1.0, green: 1.0, src="https://raw.github.com/Reiszecke/LiquidLoadingIndicator/master/1.0, alpha: 0.8))
indicator.setLineLength(0.6)
Addionally, if you want the circular line's head and tail play catch you can look src="https://raw.github.com/Reiszecke/LiquidLoadingIndicator/master/``` indicator.enableLavaLamp(moreBubbly: false)
<img style="max-width:100%;" src="../assets/webpage/loading-indicator-less-bubbly.gif?raw=true" height="250"/>
src="https://raw.github.com/Reiszecke/LiquidLoadingIndicator/master/
indicator.enableLavaLamp(moreBubbly: true)
<img style="max-width:100%;" src="../assets/webpage/loading-indicator-more-bubbly.gif?raw=true" height="250"/>
It's also possible to set the viscosity (I don't know what to call this, I'm a car guy) by playing around with values such as
indicator.setKinetic(energy: 1.1)
You may not want this at all so you can do
indicator.disableLavaLamp()
This is everything that this repo added. If you only need stuff that is mentioned below this sentence, feel free to check out the original at https://github.com/hirokimu/EMTLoadingIndicator
### Dot Indicator
![Image](https://raw.github.com/Reiszecke/LiquidLoadingIndicator/master/../assets/webpage/stockdot.jpeg)
```swift
indicator = LiquidLoadingIndicator(interfaceController: self, interfaceImage: image!,
width: 40, height: 40, style: .dot)
// prepareImageForWait will be called automatically in the showWait method at the first time.
// It takes a bit of time. You can call it manually if necessary.
indicator?.prepareImagesForWait()
// show
indicator?.showWait()
// hide
indicator?.hide()
*Images of Dot indicator are static resource files size of 80px x 80px. These PNG files are created with Flash CC (waitIndicatorGraphic.fla).
indicator?.prepareImagesForProgress()
// You can set start percentage other than 0.
indicator?.showProgress(startPercentage: 0)
// Update progress percentage with animation
indicator?.updateProgress(percentage: 75)
indicator?.hide()
You can display static reload icon (in some loading error situations).
indicator?.showReload()
If you want to change styles, you need to set properties before using prepare/show methods.
// defaults
LiquidLoadingIndicator.circleLineColor = UIColor(white: 1, alpha: 0.8)
LiquidLoadingIndicator.circleLineWidth = 1
LiquidLoadingIndicator.progressLineColorOuter = UIColor(white: 1, alpha: 0.28)
LiquidLoadingIndicator.progressLineColorInner = UIColor(white: 1, alpha: 0.70)
LiquidLoadingIndicator.progressLineWidthOuter = 1
LiquidLoadingIndicator.progressLineWidthInner = 2
LiquidLoadingIndicator.reloadColor = UIColor.white
LiquidLoadingIndicator.reloadLineWidth = 4
LiquidLoadingIndicator.reloadArrowRatio = 3
All created images are stored in static properties and used for all instances. If you want to clear them, use following methods.
indicator?.clearWaitImage()
indicator?.clearReloadImage()
indicator?.clearProgressImage()
LiquidLoadingIndicator is available under the MIT license. See the LICENSE file for more info.
link |
Stars: 0 |
Last commit: 3 years ago |
Lowered minimum API level to watchOS 3.0 Removed some unnecessary prints
Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics