add ActiveWorkoutSession logic, refactor Home, add additional sample data, add isDebug
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
//
|
||||
// TimerView.swift
|
||||
// WorkoutsPlus
|
||||
//
|
||||
// Created by Felix Förtsch on 12.09.24.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
struct TimerView: View {
|
||||
@Binding var isActive: Bool
|
||||
@State private var time = 0
|
||||
|
||||
let timer = Timer.publish(every: 1, on: .main, in: .common).autoconnect()
|
||||
|
||||
var body: some View {
|
||||
Text("\(time)")
|
||||
.onReceive(timer) { _ in
|
||||
if isActive {
|
||||
self.time += 1
|
||||
}
|
||||
}
|
||||
.onDisappear {
|
||||
self.timer.upstream.connect().cancel()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#Preview {
|
||||
TimerView(isActive: .constant(true))
|
||||
}
|
||||
Reference in New Issue
Block a user