Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kkebo/ringprogressviewstyle
RingProgressViewStyle is a library that adds a ring style to SwiftUI's ProgressViewStyle.
https://github.com/kkebo/ringprogressviewstyle
ios ipados macos swift swiftui
Last synced: 17 days ago
JSON representation
RingProgressViewStyle is a library that adds a ring style to SwiftUI's ProgressViewStyle.
- Host: GitHub
- URL: https://github.com/kkebo/ringprogressviewstyle
- Owner: kkebo
- License: mit
- Created: 2022-08-20T15:32:22.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-10-14T13:45:03.000Z (about 1 month ago)
- Last Synced: 2024-10-15T18:19:12.717Z (29 days ago)
- Topics: ios, ipados, macos, swift, swiftui
- Language: Swift
- Homepage:
- Size: 619 KB
- Stars: 6
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# RingProgressViewStyle
[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Fkkebo%2FRingProgressViewStyle%2Fbadge%3Ftype%3Dswift-versions)](https://swiftpackageindex.com/kkebo/RingProgressViewStyle)
[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Fkkebo%2FRingProgressViewStyle%2Fbadge%3Ftype%3Dplatforms)](https://swiftpackageindex.com/kkebo/RingProgressViewStyle)
[![License](https://img.shields.io/github/license/kkebo/RingProgressViewStyle.svg)](LICENSE.txt)RingProgressViewStyle is a library that adds a ring style to SwiftUI's `ProgressViewStyle`. The default apperance is based on the `.linear` style of `ProgressViewStyle`, but you can customize colors and a stroke style.
## Example
[Example.swiftpm](./Example.swiftpm/ContentView.swift) can be opened in Swift Playgrounds app or Xcode.
![preview](preview.gif)
## Motivation
The `.circular` style already exists in `ProgressViewStyle`, but it's just an indicator, not a progress bar. So basically, you have to implement that by yourself.
Fortunately, if you google "SwiftUI progress ring", you can find a number of code examples. Almost all of them looks like:
```swift
Circle()
.trim(from: 0, to: value)
.stroke(...)
.rotationEffect(.degrees(-90))
```However, when you try to specify its size by `.frame(width: ..., height: ...)`, its stroke line overflows its frame.
To prevent this, I often use `strokeBorder` instead of `stroke`.
```swift
Circle()
.trim(from: 0, to: value)
.strokeBorder(...)
.rotationEffect(.degrees(-90))
```But it occurs a compilation error because `trim` returns `some Shape` that doesn't conform to `InsettableShape` but `strokeBorder` is a method of `InsettableShape`.
So I created a solution.
## How to Use
Add this repository to your package dependencies in your app.
## Supported Platforms
- iOS 14+
- iPadOS 14+
- macOS 11+