Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/theblixguy/DynamicIslandUtilities
A collection of utilities that provides functionality around the Dynamic Island on the iPhone 14 Pro/Max.
https://github.com/theblixguy/DynamicIslandUtilities
dynamic-island ios iphone
Last synced: about 1 month ago
JSON representation
A collection of utilities that provides functionality around the Dynamic Island on the iPhone 14 Pro/Max.
- Host: GitHub
- URL: https://github.com/theblixguy/DynamicIslandUtilities
- Owner: theblixguy
- License: apache-2.0
- Created: 2022-09-19T22:56:03.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2023-02-11T08:18:32.000Z (over 1 year ago)
- Last Synced: 2024-07-19T03:49:54.550Z (2 months ago)
- Topics: dynamic-island, ios, iphone
- Language: Swift
- Homepage:
- Size: 243 KB
- Stars: 96
- Watchers: 5
- Forks: 9
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# DynamicIslandUtilities
A collection of utilities that provides functionality around the Dynamic Island on the iPhone 14 Pro/Max.
I will be adding more utilities to this package in the near future.
# Utilities
## DynamicIsland
A type that provides the size, origin, rect and some other information related to the Dynamic Island. For example, you can do:
```swift
let size = DynamicIsland.size
```to get the size of the Dynamic Island cutout. This size is the same on both the iPhone 14 Pro and Max.
> **Warning**
> At the moment, this provides the static size of the island, not the dynamic size (the island will expand if there's a live activity running).## DynamicIsland.progressIndicator
A simple object that provides access to a progress indicator around the Dynamic Island cutout. To use it, simply access `DynamicIsland.progressIndicator` from anywhere to control the indicator.
```swift
DynamicIsland.progressIndicator.progressColor = .green
DynamicIsland.progressIndicator.isProgressIndeterminate = false// Manual progress
doFixedWork { currentProgress in
if currentProgress == 100 {
DynamicIsland.progressIndicator.hideProgressIndicator()
} else {
DynamicIsland.progressIndicator.progress = currentProgress
}
}/// Indeterminate progress
DynamicIsland.progressIndicator.showIndeterminateProgressAnimation()
doSomeWorkThatMayFinishLater { result in
...
DynamicIsland.progressIndicator.hideProgressIndicator()
}
```In order to access this property, you need to first check `DynamicIsland.isAvailable` (this is enforced at runtime), which also nudges you to provide fallback logic:
```swift
if DynamicIsland.isAvailable {
// Show a cool progress indicator around the Dynamic Island
DynamicIsland.progressIndicator.showIndeterminateProgressAnimation()
} else {
// Fallback to a default indicator
showIndeterminateProgressBar()
}
```> **Note**
> By default, the progress indicator is added to the key window (or the first window of the first scene). If you want to change that, set `DynamicIsland.progressIndicator.window` to a `UIWindow` of your choice.Example:
### Indeterminate
![](Images/indeterminate_progress.gif)
### Manual
![](Images/fixed_progress.gif)
# Requirements
- Swift Package Manager
- Xcode 14
- iOS 11 to import the package, iOS 16 to actually use it (this is obvious!)