Giter Site home page Giter Site logo

theblixguy / dynamicislandutilities Goto Github PK

View Code? Open in Web Editor NEW
94.0 5.0 8.0 249 KB

A collection of utilities that provides functionality around the Dynamic Island on the iPhone 14 Pro/Max.

License: Apache License 2.0

Swift 100.00%
dynamic-island ios iphone

dynamicislandutilities's Introduction

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:

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.

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:

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

Manual

Requirements

  • Swift Package Manager
  • Xcode 14
  • iOS 11 to import the package, iOS 16 to actually use it (this is obvious!)

dynamicislandutilities's People

Contributors

theblixguy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

dynamicislandutilities's Issues

iPhone 15 and iPhone 15 Pro

I just discovered this library and it's pretty good so far. However, it seems like the library still doesn't support the new iPhones. Any chance we could get an update to make it work on the 15 and 15 Pro? That would be awesome! Thanks

dynamic size

do you have any ideea how to get dynamic island size when is expanded? or at least to get status expanded/minimized? thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.