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.
51 lines
1.5 KiB
51 lines
1.5 KiB
//
|
|
// CountdownLiveView.swift
|
|
// LeCountdown
|
|
//
|
|
// Created by Laurent Morvillier on 01/02/2023.
|
|
//
|
|
|
|
import SwiftUI
|
|
|
|
struct CountdownDialView: View {
|
|
|
|
@EnvironmentObject var conductor: Conductor
|
|
|
|
@ObservedObject var countdown: Countdown
|
|
|
|
var body: some View {
|
|
|
|
HStack {
|
|
VStack(alignment: .leading) {
|
|
Text(countdown.activity?.name?.uppercased() ?? "")
|
|
// let dateInterval = DateInterval(start: Date(), end: Date())
|
|
if let dateInterval = conductor.currentCountdowns[countdown.stringId] {
|
|
Text(dateInterval.end, style: .timer)
|
|
Spacer()
|
|
HStack {
|
|
Spacer()
|
|
Button {
|
|
CountdownScheduler.master.cancelCurrentNotifications(countdown: countdown)
|
|
} label: {
|
|
Text("Cancel".uppercased())
|
|
}
|
|
.buttonStyle(.bordered)
|
|
Spacer()
|
|
}
|
|
|
|
} else {
|
|
Text(countdown.duration.minuteSecond)
|
|
}
|
|
Spacer()
|
|
}
|
|
Spacer()
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
struct CountdownLiveView_Previews: PreviewProvider {
|
|
static var previews: some View {
|
|
CountdownDialView(countdown: Countdown.fake(context: PersistenceController.preview.container.viewContext)).background(.cyan).environmentObject(Conductor.maestro)
|
|
}
|
|
}
|
|
|