如何将此代码重构到 Xcode 15 并使预览正常工作?
struct HistoryView_Previews: PreviewProvider {
static var history: History {
History(attendees: [
DailyScrum.Attendee(name: "Jon"),
DailyScrum.Attendee(name: "Darla"),
DailyScrum.Attendee(name: "Luis")
],
transcript: "Darla, would you like to start today? Sure, yesterday I reviewed Luis' PR and met with the design team to finalize the UI...")
}
static var previews: some View {
HistoryView(history: history)
}
}
我不知道如何使用这个新的#Preview,求助!
您可以像这样转换为#Preview宏样式:
#Preview {
var history: History {
History(attendees: [
DailyScrum.Attendee(name: "Jon"),
DailyScrum.Attendee(name: "Darla"),
DailyScrum.Attendee(name: "Luis")
],
transcript: "Darla, would you like to start today? Sure, yesterday I reviewed Luis' PR and met with the design team to finalize the UI...")
}
return HistoryView(history: history)
}