From a500ecb6cbf41cdcccaf7432b0438f42743e3918 Mon Sep 17 00:00:00 2001 From: Laurent Date: Fri, 27 Jan 2023 19:43:09 +0100 Subject: [PATCH] Improve look --- LaunchWidget/LaunchWidget.swift | 8 +------- LaunchWidget/SingleCountdownView.swift | 3 ++- LeCountdown/Model/Model+Extensions.swift | 5 ++++- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/LaunchWidget/LaunchWidget.swift b/LaunchWidget/LaunchWidget.swift index 247bda6..f28f9df 100644 --- a/LaunchWidget/LaunchWidget.swift +++ b/LaunchWidget/LaunchWidget.swift @@ -95,6 +95,7 @@ struct LaunchWidgetEntryView : View { case .systemSmall, .accessoryInline: if let countdown = entry.countdowns.first { CountdownSimpleWidgetView(countdown: countdown) + .background(Image(countdown.imageName)) } else { VoidView() } @@ -118,16 +119,9 @@ struct LaunchWidgetEntryView : View { default: MultiCountdownView(countdowns: entry.countdowns) -// case .systemMedium: GameStatusWithLastTurnResult(gameStatus) -// case .systemLarge: GameStatusWithStatistics(gameStatus) -// case .systemExtraLarge: GameStatusWithStatisticsExtraLarge(gameStatus) -// case .accessoryCircular: HealthLevelCircular(selectedCharacter) -// case .accessoryRectangular: HealthLevelRectangular(selectedCharacter) -// case .accessoryInline: HealthLevelInline(selectedCharacter) } } - } struct LaunchWidget: Widget { diff --git a/LaunchWidget/SingleCountdownView.swift b/LaunchWidget/SingleCountdownView.swift index 0f126d6..544768c 100644 --- a/LaunchWidget/SingleCountdownView.swift +++ b/LaunchWidget/SingleCountdownView.swift @@ -19,7 +19,7 @@ struct SingleCountdownView: View { VStack { Text(countdown.name ?? "") Text(countdown.duration.minuteSecond) - } + }.foregroundColor(Color.white) .font(self.font) .widgetURL(countdown.url) } @@ -78,6 +78,7 @@ struct MultiCountdownView: View { struct CountdownView_Previews: PreviewProvider { static var previews: some View { + SingleCountdownView(countdown: Countdown.fake(context: PersistenceController.preview.container.viewContext)).previewContext(WidgetPreviewContext(family: .systemSmall)) SingleCountdownView(countdown: Countdown.fake(context: PersistenceController.preview.container.viewContext)).previewContext(WidgetPreviewContext(family: .accessoryRectangular)) MultiCountdownView(countdowns: self.countdowns(context: PersistenceController.preview.container.viewContext)).previewContext(WidgetPreviewContext(family: .systemMedium)) } diff --git a/LeCountdown/Model/Model+Extensions.swift b/LeCountdown/Model/Model+Extensions.swift index ea4b1d4..57eef20 100644 --- a/LeCountdown/Model/Model+Extensions.swift +++ b/LeCountdown/Model/Model+Extensions.swift @@ -24,7 +24,10 @@ extension Countdown { } var imageName: String { - return self.image ?? "default" + if let image { + return image + } + return CoolPic.allCases[0].rawValue } static func fake(context: NSManagedObjectContext) -> Countdown {