|
|
|
|
@ -37,6 +37,39 @@ struct SingleCountdownView: View { |
|
|
|
|
switch family { |
|
|
|
|
case .systemSmall, .systemMedium, .systemLarge, .systemExtraLarge: |
|
|
|
|
return .body |
|
|
|
|
case .accessoryCircular: |
|
|
|
|
return .footnote |
|
|
|
|
default: |
|
|
|
|
return .body |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct LockScreenCountdownView: View { |
|
|
|
|
|
|
|
|
|
@Environment(\.widgetFamily) var family: WidgetFamily |
|
|
|
|
|
|
|
|
|
var countdown: Countdown |
|
|
|
|
|
|
|
|
|
var body: some View { |
|
|
|
|
VStack { |
|
|
|
|
Text(countdown.displayName.uppercased()) |
|
|
|
|
Text(countdown.duration.minuteSecond) |
|
|
|
|
} |
|
|
|
|
.monospaced() |
|
|
|
|
.foregroundColor(Color.white) |
|
|
|
|
.font(self.font) |
|
|
|
|
.widgetURL(countdown.url) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private var font: Font { |
|
|
|
|
switch family { |
|
|
|
|
case .systemSmall, .systemMedium, .systemLarge, .systemExtraLarge: |
|
|
|
|
return .body |
|
|
|
|
case .accessoryCircular: |
|
|
|
|
return .footnote |
|
|
|
|
default: |
|
|
|
|
return .body |
|
|
|
|
} |
|
|
|
|
@ -125,7 +158,8 @@ struct CountdownView_Previews: PreviewProvider { |
|
|
|
|
static var previews: some View { |
|
|
|
|
|
|
|
|
|
SingleCountdownView(countdown: Countdown.fake(context: PersistenceController.preview.container.viewContext)).previewContext(WidgetPreviewContext(family: .systemSmall)).background(.black) |
|
|
|
|
SingleCountdownView(countdown: Countdown.fake(context: PersistenceController.preview.container.viewContext)).previewContext(WidgetPreviewContext(family: .accessoryRectangular)) |
|
|
|
|
LockScreenCountdownView(countdown: Countdown.fake(context: PersistenceController.preview.container.viewContext)).previewContext(WidgetPreviewContext(family: .accessoryRectangular)) |
|
|
|
|
LockScreenCountdownView(countdown: Countdown.fake(context: PersistenceController.preview.container.viewContext)).previewContext(WidgetPreviewContext(family: .accessoryCircular)) |
|
|
|
|
MultiCountdownView(countdowns: self.countdowns(context: PersistenceController.preview.container.viewContext)).previewContext(WidgetPreviewContext(family: .systemMedium)) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|