Post

Replies

Boosts

Views

Activity

Reply to How do I use containerRelative on a grid in my widget?
I took a stab at trying to fix this problem to no avail. It seems that ContainerRelativeShape also takes into account the distance from the edges of the container even if you move the shape using .offset(). For now, what I think is a good idea is to just hardcode the corner radius and calculate the concentric radius accordingly For iOS 18 and below, the corner radius I use is 21.0 and for iOS 26, it's 28.0. var widgetRadius: { if #available(iOS 26.0, *) { 28 } else { 21 } } let padding = 10 let concentricRadius = widgetRadius - padding RoundedRectangle(cornerRadius: concentricRadius) Not the prettiest implementation but it should do for now. iOS 26 has some new concentric rectangle features you could take a look at, but I personally have yet to study them.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Aug ’25
Reply to WidgetKit: Best practices for reloading widgets?
You can try to reload the widget when the app‘s ”scenePhase” changes and moves into the background. Alternatively, try to consider changing how playlists are edited. Try adding a “Save” button that persists all the changes made in the playlist and reloads the widget instead of saving and reloading every time a change is made. Answering your question about refreshing specific widgets, think about how many times a user will actually edit their playlists (that is assuming your app is a normal music player), your widget might not need to reload as often as you think.
Topic: App & System Services SubTopic: General Tags:
Sep ’24
Reply to How do I use containerRelative on a grid in my widget?
I took a stab at trying to fix this problem to no avail. It seems that ContainerRelativeShape also takes into account the distance from the edges of the container even if you move the shape using .offset(). For now, what I think is a good idea is to just hardcode the corner radius and calculate the concentric radius accordingly For iOS 18 and below, the corner radius I use is 21.0 and for iOS 26, it's 28.0. var widgetRadius: { if #available(iOS 26.0, *) { 28 } else { 21 } } let padding = 10 let concentricRadius = widgetRadius - padding RoundedRectangle(cornerRadius: concentricRadius) Not the prettiest implementation but it should do for now. iOS 26 has some new concentric rectangle features you could take a look at, but I personally have yet to study them.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Aug ’25
Reply to SwiftData updates delay in widget
The issue might be with the timeline provider. But basing solely on your code, try reloading the widget right after you insert it. Like this: modelContext.insert(word) WidgetCenter.shared.reloadAllTimelines()
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Sep ’24
Reply to WidgetKit: Best practices for reloading widgets?
You can try to reload the widget when the app‘s ”scenePhase” changes and moves into the background. Alternatively, try to consider changing how playlists are edited. Try adding a “Save” button that persists all the changes made in the playlist and reloads the widget instead of saving and reloading every time a change is made. Answering your question about refreshing specific widgets, think about how many times a user will actually edit their playlists (that is assuming your app is a normal music player), your widget might not need to reload as often as you think.
Topic: App & System Services SubTopic: General Tags:
Replies
Boosts
Views
Activity
Sep ’24
Reply to SwiftData `context.fetch()` possible bug on WidgetKit EntityQuery
I managed to fix the issue. I think it had something to do with the targets of the intent swift file. I did some restructuring and it worked flawlessly.
Replies
Boosts
Views
Activity
Dec ’23
Reply to SwiftData `context.fetch()` possible bug on WidgetKit EntityQuery
Models created after .fetch() is run also does not appear when it is called again in the widget configuration screen. It only shows models created before the first .fetch() was called and any changes made to those models such as edits or deletion.
Replies
Boosts
Views
Activity
Dec ’23