Improves look of lock screen widget

release
Laurent 3 years ago
parent c274a8f97a
commit 9ff2e184b6
  1. 26
      LaunchWidget/LaunchWidget.swift

@ -76,7 +76,10 @@ struct CountdownMultiWidgetView: View {
struct VoidView : View {
var body: some View {
Text("Configure me!")
VStack {
Text("Tea!")
Text("4:00")
}
}
}
@ -89,9 +92,26 @@ struct LaunchWidgetEntryView : View {
@ViewBuilder
var body: some View {
switch family {
case .systemSmall, .accessoryInline, .accessoryRectangular, .accessoryCircular:
case .systemSmall, .accessoryInline:
if let countdown = entry.countdowns.first {
CountdownSimpleWidgetView(countdown: countdown)
} else {
VoidView()
}
case .accessoryCircular:
if let countdown = entry.countdowns.first {
CountdownSimpleWidgetView(countdown: countdown)
.frame(maxWidth: .infinity, maxHeight: .infinity)
.background(Color.black)
} else {
VoidView()
}
case .accessoryRectangular:
if let countdown = entry.countdowns.first {
CountdownSimpleWidgetView(countdown: countdown)
.frame(maxWidth: .infinity, maxHeight: .infinity)
.background(Color.black)
.cornerRadius(16.0)
} else {
VoidView()
}
@ -134,6 +154,8 @@ struct LaunchWidget_Previews: PreviewProvider {
.previewContext(WidgetPreviewContext(family: .systemSmall))
LaunchWidgetEntryView(entry: SimpleEntry(countdowns: [fake, fake, fake, fake], date: Date(), configuration: SelectCountdownIntent()))
.previewContext(WidgetPreviewContext(family: .systemMedium))
LaunchWidgetEntryView(entry: SimpleEntry(countdowns: [fake], date: Date(), configuration: SelectCountdownIntent()))
.previewContext(WidgetPreviewContext(family: .accessoryRectangular))
}
}

Loading…
Cancel
Save