2 ms·
I've done a few widgets for Volum (to easily turn on/off DIY lights and mute speakers: https://lowtechguys.com/volum https://lowtechguys.com/volum) and for Sub
by alin23 4y ago
I've done a few widgets for Volum (to easily turn on/off DIY lights and mute speakers: https://lowtechguys.com/volum https://lowtechguys.com/volum) and for Sub Sol (to see the next private party: https://subsol.one https://subsol.one)
Screenshot here: https://f.alinpanaitiu.com/mt37aX/Image.png https://f.alinpanaitiu.com/mt37aX/Image.png
While they're easy to write because of the new SwiftUI APIs, they're indeed very limited.
All I am able to do is add buttons which when pressed, they open an URL.
I managed to make that URL useful in Volum with a handler that extracts the device id from the URL and toggles the device power. Not always working because the app might not be in sync with the current state of the lights/speakers, as apps are not allowed to do much work in the background.
In the Sub Sol case, the URL only navigates to the party that you tapped on in the widget.
But because widgets live in a separate extension, completely isolated from your app's code, you can't do anything inside them. Even the rudimentary stuff needs code duplication between the app and the widget extension.
The good thing is that it leads to a very small widget extension binary that doesn't hog up memory, and I think that's what Apple wanted in the end. But I would love to have a bit more power so I don't have to open an app for stuff that I do often in 1-3 taps.