Swiftpack.co - heltena/Inactivity as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by heltena.
heltena/Inactivity 1.0.4
I needed to detect idle mode on a SwiftUI app for a kiosk, so I did it.
⭐️ 22
🕓 27 weeks ago
iOS macOS
.package(url: "https://github.com/heltena/Inactivity.git", from: "1.0.4")

Inactivity

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

Usage

Note: The Principal class is not necessary.

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)

Find an Xcode app example here: https://github.com/heltena/InactivityExample

Enjoy!

GitHub

link
Stars: 22
Last commit: 27 weeks ago
Advertisement: IndiePitcher.com - Cold Email Software for Startups

Release Notes

1.0.4
27 weeks ago

Added macOS support (thanks to dosboxd https://github.com/dosboxd/Inactivity)

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