1998code / iOS16-Live-Activities

SwiftPizza App for Apple ActivityKit & WidgetKit & Dynamic Island.
https://oss.1998.media/doc/live-activities
MIT License
370 stars 34 forks source link

How you preview the live activity UI on development? #2

Closed Yggdrasilqh closed 2 years ago

Yggdrasilqh commented 2 years ago

It's a helpful and amazing demo!

but I don't see any preview code on this demo. I wanna know how to preview the activity widget use the PreviewProvider ? or you just run entire app to preview the UI?

struct live_activities_Previews: PreviewProvider {
    static var previews: some View {
        live_activitiesEntryView(context: !how to create this!)
            .previewContext(WidgetPreviewContext(family: .systemSmall))
    }
}

Thanks!

1998code commented 2 years ago

Hi. I cannot find how to preview the live activities widget in Apple Developer Documentation. The thing is still in beta. So, I simply run the app to preview the UI.

Or you may preview the widget design first, then copy the code back to the Live Widget(s).

CleanShot 2022-07-30 at 23 46 10@2x

Hope help :) @Yggdrasilqh

Yggdrasilqh commented 2 years ago

Hi. I cannot find how to preview the live activities widget in Apple Developer Documentation. The thing is still in beta. So, I simply run the app to preview the UI.

Or you may preview the widget design first, then copy the code back to the Live Widget(s). CleanShot 2022-07-30 at 23 46 10@2x

Hope help :) @Yggdrasilqh

Oh, that's a good idea! thanks for your reply. have a good day!

1998code commented 1 year ago

@Yggdrasilqh Sample is updated with preview (iOS 16.2 or above) https://github.com/1998code/iOS16-Live-Activities#xcode-preview-ios-162-or-above