TEAM LICENSES: Save money and learn new skills through a Hacking with Swift+ team license >>

How to set widget intent parameters based on context.family?

Forums > SwiftUI

@bci  

I have a nice new widget I created for a Bed Side Clock app. There are a number of Bool parameters in the .intentdefinition. In placeholder() and getSnapshot() I build the widget based on context.family (.systemSmall, .systemMedium, and .system Large). These all look great and show the three supported size widgets with working views. The problem is when editing the widget:

  1. The user long presses the home screen and presses +
  2. The user selects my app
  3. The system displays my three widget sizes from placeholder() with the correct content - Great!
  4. The user selects the widget size and taps on Add Widget
  5. The system generates a widget using getSnapshot() and it wiggles on the screen - Great!
  6. The use taps the widget to edit it, it flips over to show the list of parameters, all turned off - Sad, unhappy user

I would like to make it easy on the user to edit the existing widget which may be displaying 4 items. I want the items for that display to be turned on when entering widget edit. Manually turning on each of the displays works fine.

How do I notify WidgetKit that a widget is created in getSnapshot() or getTimeline() has the parameters set a specific way so the edit form matched the displying widget?

Thanks for reading!

2      

Hacking with Swift is sponsored by RevenueCat.

SPONSORED Take the pain out of configuring and testing your paywalls. RevenueCat's Paywalls allow you to remotely configure your entire paywall view without any code changes or app updates.

Learn more here

Sponsor Hacking with Swift and reach the world's largest Swift community!

Archived topic

This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.