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 { struct VoidView : View {
var body: some View { var body: some View {
Text("Configure me!") VStack {
Text("Tea!")
Text("4:00")
}
} }
} }
@ -89,9 +92,26 @@ struct LaunchWidgetEntryView : View {
@ViewBuilder @ViewBuilder
var body: some View { var body: some View {
switch family { 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 { if let countdown = entry.countdowns.first {
CountdownSimpleWidgetView(countdown: countdown) 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 { } else {
VoidView() VoidView()
} }
@ -134,6 +154,8 @@ struct LaunchWidget_Previews: PreviewProvider {
.previewContext(WidgetPreviewContext(family: .systemSmall)) .previewContext(WidgetPreviewContext(family: .systemSmall))
LaunchWidgetEntryView(entry: SimpleEntry(countdowns: [fake, fake, fake, fake], date: Date(), configuration: SelectCountdownIntent())) LaunchWidgetEntryView(entry: SimpleEntry(countdowns: [fake, fake, fake, fake], date: Date(), configuration: SelectCountdownIntent()))
.previewContext(WidgetPreviewContext(family: .systemMedium)) .previewContext(WidgetPreviewContext(family: .systemMedium))
LaunchWidgetEntryView(entry: SimpleEntry(countdowns: [fake], date: Date(), configuration: SelectCountdownIntent()))
.previewContext(WidgetPreviewContext(family: .accessoryRectangular))
} }
} }

Loading…
Cancel
Save