taler-ios

iOS apps for GNU Taler (wallet)
Log | Files | Refs | README | LICENSE

commit 2877a94e4947147ebae2b1ab187252d19cb5efb1
parent 2c24ed7bd0f3410a72d253a52f473db5e447fa8f
Author: Marc Stibane <marc@taler.net>
Date:   Fri, 17 Jul 2026 11:08:12 +0200

isFinished

Diffstat:
MTalerWallet1/Views/HelperViews/TimeView.swift | 21+++++++++++++++++++--
1 file changed, 19 insertions(+), 2 deletions(-)

diff --git a/TalerWallet1/Views/HelperViews/TimeView.swift b/TalerWallet1/Views/HelperViews/TimeView.swift @@ -11,11 +11,28 @@ struct TimeView: View { let title: String let seconds: Int let trailer: String + @Binding var isFinished: Bool? - init(_ title: String, seconds: Int,_ trailer: String? = nil) { + init(_ title: String, seconds: Int,_ trailer: String? = nil, isFinished: Binding<Bool?> = .constant(nil)) { self.title = title self.seconds = seconds self.trailer = trailer ?? String(localized: "seconds") + self._isFinished = isFinished + } + + func remainingTime(_ elapsed: Int) -> Int { + let remaining = seconds - elapsed + if remaining <= 0 { + if isFinished != nil { + DispatchQueue.main.async { + isFinished = true + DispatchQueue.main.asyncAfter(deadline: .now() + 2.6) { + isFinished = nil + } + } + } + } + return remaining } var body: some View { @@ -24,7 +41,7 @@ struct TimeView: View { Text(title) TimelineView(.animation) { context in let elapsed = Int(context.date.timeIntervalSince(startDate)) - let remaining = seconds - elapsed + let remaining = remainingTime(elapsed) let text = Text(verbatim: "\(remaining)") if #available(iOS 17.0, *) { text