I change my widget func to
Code Block IntentConfiguration(kind: kind, intent: ***, provider: Provider()) { entry in EntryView(entry: entry) }
by removing placeholder parameter
And i also add func to my provider to return an Entry
Code Block func placeholder(with: Context) -> FeedModelEntry
So where I should add this modifier to indicate this view should look likes placeholderView style?
Code Block .redacted(reason: .placeholder)
My widget has three line text , but after add placeholder(with: Context) i can not see my view change to placeholder view style when i edited my widget
Should my entry object need hold a isPlaceholder property to let my widget view to know it should show placeholder style?
Code Block if entry.isPlaceHolderView { someView() .redacted(reason: .placeholder) } else { someView() }
Thank you very much
Xcode-beta3
https://developer.apple.com/forums/thread/655182?answerId=623062022#623062022
You should implement placeholder(with: Context) to return a TimelineEntry that contains whatever you need for your placeholder. Note that unlike snapshot and timeline which are asynchronous with a completion block, the placeholder method is synchronous and you return a timeline entry immediately. So you want to be fast to return that entry.
When your widget's view is rendered for placeholder purposes it's given the placeholder entry and you can render your view accordingly. Note, there's some new SwiftUI support for marking a view as redacted. What should happen is that when WidgetKit renders the widget's view using the placeholder timeline entry, it would automatically render the view using .redacted(reason: .placeholder). Unfortunately that isn't working in Beta 3, but should be fixed in an upcoming seed.
Hope this helps. 😊