Hello,
In WidgetKit, I have to write multiple #Preview macros for each family the widget supports. So is there any better way to write the #Preview?
(Although I can use the legacy PreviewProvider but it does not support timeline to test transition animation.)
#import WidgetKit
#import SwiftUI
struct DailyCaffeineWidget: Widget {
...
}
@available(iOS 17.0, *)
#Preview("Inline", as: .accessoryInline) {
DailyCaffeineWidget()
} timelineProvider: {
previewTimelineProvider()
}
@available(iOS 17.0, *)
#Preview("Circular", as: .accessoryCircular) {
DailyCaffeineWidget()
} timelineProvider: {
previewTimelineProvider()
}
@available(iOS 17.0, *)
#Preview("Rectangular", as: .accessoryRectangular) {
DailyCaffeineWidget()
} timelineProvider: {
previewTimelineProvider()
}
@available(iOS 17.0, *)
#Preview("Small", as: .systemSmall) {
DailyCaffeineWidget()
} timelineProvider: {
previewTimelineProvider()
}
@available(iOS 17.0, *)
#Preview("Medium", as: .systemMedium) {
DailyCaffeineWidget()
} timelineProvider: {
previewTimelineProvider()
}
...
Posts under wwdc2023-10028 tag
3 Posts
Sort by:
Post
Replies
Boosts
Views
Activity
How in interactive widgets in ios 17 to prevent the opening of the application by clicking on the widget? Sometimes the user may miss the button and opening the application is inappropriate in this case
With the new interactive widgets brought by iOS 17, is it possible to indicate that an action (button tap or toggle use) has been triggered by firing an Haptic feedback to the user?