Swiftpack.co -  heltena/Inactivity as Swift Package
Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
heltena/Inactivity
I needed to detect idle mode on a SwiftUI app for a kiosk, so I did it.
.package(url: "https://github.com/heltena/Inactivity.git", from: "1.0.0")

Inactivity

I needed to detect idle mode on a SwiftUI app for a kiosk, so I did it.

Usage

Important: You must set the Principal class of your app to Inactivity.InactivityApplication in your info.plist.

This is an example:

InactivityWatcherView { proxy in
    InactiveView {
        proxy.becomeActive(timeout: 5)
    }
    .transition(.opacity)
    
    ActiveView()
        .transition(.opacity)
}

Also, you can perform an action when the state changes:

Text("Example")
    .onInactivityStateChanged { state in print("Going to \(state)") }

Finally, it is possible to access to the InactivityWatcher class using the shared attribute of the InactivityApplication:

InactivityApplication.shared.watcher.startWatch(timeout: 120)

Enjoy!

GitHub

link
Stars: 4
Last commit: 3 weeks ago

Ad: Job Offers

iOS Software Engineer @ Perry Street Software
Perry Street Software is Jack’d and SCRUFF. We are two of the world’s largest gay, bi, trans and queer social dating apps on iOS and Android. Our brands reach more than 20 million members worldwide so members can connect, meet and express themselves on a platform that prioritizes privacy and security. We invest heavily into SwiftUI and using Swift Packages to modularize the codebase.

Release Notes

First version
3 weeks ago

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API