Post

Replies

Boosts

Views

Activity

How can I detect Standby mode widget in TimelineProvider?
I want to check whether the widget is at Standby mode in TimelineProvider. I thought showsWidgetContainerBackground == false means the widget is at Standby mode, referring to 'WWDC 2023 Bring widgets to new places'. struct Provider: TimelineProvider { func getTimeline(in context: Context, completion: @escaping (Timeline<Entry>) -> ()) { let isBackgroundShown = context.environmentVariants.showsWidgetContainerBackground // Error: Cannot assign to property: 'showsWidgetContainerBackground' is a get-only property ... completion(timeline) } ... } But in TimelineProvider, I can't get context.environmentVariants.showsWidgetContainerBackground because it is get-only property. This is because context.environmentVariants adopts @dynamicMemberLookup with WritableKeypath<EnvironmentValues, T>. Is there any chance to detect the widget is at Standby mode in TimelineProvider? Is it possible or not? Any suggestion would be very grateful. Thank you.
0
0
478
Sep ’23
Only in Xcode15 + iOS 17, SwiftUI ToolbarItem > Button > Image's color is not set
struct ContentView: View { var body: some View { Text("Hello, world!") .padding() .navigationTitle("Title") .toolbar { ToolbarItem(placement: .cancellationAction) { Button { } label: { Label { Text("Button Text") } icon: { Image("commonIcoClose") .renderingMode(.template) // .foregroundColor(.red) .foregroundStyle(.red) } } } } } } Above code should set Button's Image color to red but in Xcode15(15A240d), color is not applied and just set to default blue. In iOS 15, 16 in Xcode 14.3.1 and iOS 15, 16 + Xcode15(15A240d) works fine(image's color is set to red). So if i want to set color to red, I should use .tint like below. struct ContentView: View { var body: some View { Text("Hello, world!") .padding() .navigationTitle("Title") .toolbar { ToolbarItem(placement: .cancellationAction) { Button { } label: { Label { Text("Button Text") } icon: { Image("commonIcoClose") .renderingMode(.template) } } .tint(.red) } } } } Is this change intended? Or is it a bug?
2
1
1k
Oct ’23