1.03 for iOS and 1.5.0 for Android
This commit is contained in:
@@ -114,7 +114,7 @@ struct ActiveSessionBanner: View {
|
||||
@State private var currentTime = Date()
|
||||
@State private var navigateToDetail = false
|
||||
|
||||
private let timer = Timer.publish(every: 1, on: .main, in: .common).autoconnect()
|
||||
@State private var timer: Timer?
|
||||
|
||||
var body: some View {
|
||||
HStack {
|
||||
@@ -162,8 +162,11 @@ struct ActiveSessionBanner: View {
|
||||
.fill(.green.opacity(0.1))
|
||||
.stroke(.green.opacity(0.3), lineWidth: 1)
|
||||
)
|
||||
.onReceive(timer) { _ in
|
||||
currentTime = Date()
|
||||
.onAppear {
|
||||
startTimer()
|
||||
}
|
||||
.onDisappear {
|
||||
stopTimer()
|
||||
}
|
||||
.background(
|
||||
NavigationLink(
|
||||
@@ -190,6 +193,17 @@ struct ActiveSessionBanner: View {
|
||||
return String(format: "%ds", seconds)
|
||||
}
|
||||
}
|
||||
|
||||
private func startTimer() {
|
||||
timer = Timer.scheduledTimer(withTimeInterval: 5.0, repeats: true) { _ in
|
||||
currentTime = Date()
|
||||
}
|
||||
}
|
||||
|
||||
private func stopTimer() {
|
||||
timer?.invalidate()
|
||||
timer = nil
|
||||
}
|
||||
}
|
||||
|
||||
struct SessionRow: View {
|
||||
|
||||
Reference in New Issue
Block a user