You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
LeCountdown/LaunchWidget/CountdownView.swift

41 lines
877 B

//
// CountdownView.swift
// LeCountdown
//
// Created by Laurent Morvillier on 25/01/2023.
//
import SwiftUI
import WidgetKit
struct CountdownView: View {
@Environment(\.widgetFamily) var family: WidgetFamily
var name: String?
var duration: Double
var body: some View {
VStack {
Text(name ?? "")
Text(duration.minuteSecond)
}
.font(self.font)
}
private var font: Font {
switch family {
case .systemSmall, .systemMedium, .systemLarge, .systemExtraLarge:
return .title2
default:
return .body
}
}
}
struct CountdownView_Previews: PreviewProvider {
static var previews: some View {
CountdownView(name: "Tea", duration: 3 * 60.0).previewContext(WidgetPreviewContext(family: .accessoryRectangular))
}
}