[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-taler-ios] 190/204: timeToPay w.i.p.
From: |
gnunet |
Subject: |
[taler-taler-ios] 190/204: timeToPay w.i.p. |
Date: |
Thu, 05 Dec 2024 23:52:38 +0100 |
This is an automated email from the git hooks/post-receive script.
marc-stibane pushed a commit to branch master
in repository taler-ios.
commit 60ce6feee08490700f9f7d6180382f87c1adcb3a
Author: Marc Stibane <marc@taler.net>
AuthorDate: Wed Dec 4 07:24:30 2024 +0100
timeToPay w.i.p.
---
.../Views/Sheets/Payment/PaymentView.swift | 38 +++++++++++++++++++++-
1 file changed, 37 insertions(+), 1 deletion(-)
diff --git a/TalerWallet1/Views/Sheets/Payment/PaymentView.swift
b/TalerWallet1/Views/Sheets/Payment/PaymentView.swift
index b384f65..c78ee08 100644
--- a/TalerWallet1/Views/Sheets/Payment/PaymentView.swift
+++ b/TalerWallet1/Views/Sheets/Payment/PaymentView.swift
@@ -87,13 +87,14 @@ struct PaymentView: View, Sendable {
@State private var currencyInfo: CurrencyInfo = CurrencyInfo.zero(UNKNOWN)
@State var preparePayResult: PreparePayResult? = nil
+ @State private var elapsed: Int = 0
@MainActor
func checkCurrencyInfo(for result: PreparePayResult) async {
let scopes = result.scopes
if scopes.count > 0 {
for scope in scopes {
- await controller.checkInfo(for: scope, model: model)
+ controller.checkInfo(for: scope, model: model)
}
return
}
@@ -130,6 +131,17 @@ struct PaymentView: View, Sendable {
}
}
+ func timeToPay(_ terms: MerchantContractTerms) -> Int {
+ if terms.payDeadline > terms.timestamp {
+ if let duration = try? terms.payDeadline - terms.timestamp {
+ switch duration {
+ case .milliseconds(let uInt64):
+ return Int(uInt64 / 1000)
+ case .forever: break
+ } } }
+ return 0
+ }
+
var body: some View {
Group {
if let preparePayResult {
@@ -144,6 +156,8 @@ struct PaymentView: View, Sendable {
let paid = status == .alreadyConfirmed
let navTitle = paid ? String(localized: "Already paid",
comment:"pay merchant navTitle")
: String(localized: "Confirm Payment",
comment:"pay merchant navTitle")
+ let timeToPay = timeToPay(terms)
+
List {
if paid {
Text("You already paid for this article.")
@@ -219,6 +233,28 @@ struct PaymentView: View, Sendable {
if !paid {
if let effective {
VStack {
+ if timeToPay > 0 {
+ let startDate = Date()
+ HStack {
+ Text("Time to pay:")
+ TimelineView(.animation) { context in
+ let elapsed =
Int(context.date.timeIntervalSince(startDate))
+ let seconds = timeToPay - elapsed
+
+ if #available(iOS 17.0, *) {
+ Text("\(seconds)")
+
.contentTransition(.numericText(countsDown: true))
+ .animation(.default, value:
elapsed)
+ } else if #available(iOS 16.0, *) {
+ Text("\(seconds)")
+ .animation(.default, value:
elapsed)
+ } else {
+ Text("\(seconds)")
+ }
+ }.monospacedDigit()
+ Text("seconds")
+ }
+ }
let destination = PaymentDone(stack: stack.push(),
// scope: firstScope,
// TODO: let user choose which currency
transactionId:
preparePayResult.transactionId)
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
- [taler-taler-ios] 172/204: a11y for tabBar, (continued)
- [taler-taler-ios] 172/204: a11y for tabBar, gnunet, 2024/12/05
- [taler-taler-ios] 173/204: update after +, gnunet, 2024/12/05
- [taler-taler-ios] 174/204: only in debug mode, gnunet, 2024/12/05
- [taler-taler-ios] 176/204: cleanup, comments, gnunet, 2024/12/05
- [taler-taler-ios] 179/204: Bump version to 0.13.8 (0.13.13), gnunet, 2024/12/05
- [taler-taler-ios] 180/204: Comparable, gnunet, 2024/12/05
- [taler-taler-ios] 181/204: don't update if same data, gnunet, 2024/12/05
- [taler-taler-ios] 188/204: regional exchange baseURL, gnunet, 2024/12/05
- [taler-taler-ios] 182/204: L10N helper, gnunet, 2024/12/05
- [taler-taler-ios] 184/204: don't add to knownBankAccounts, gnunet, 2024/12/05
- [taler-taler-ios] 190/204: timeToPay w.i.p.,
gnunet <=
- [taler-taler-ios] 191/204: layout, legal hint, gnunet, 2024/12/05
- [taler-taler-ios] 194/204: A11y, gnunet, 2024/12/05
- [taler-taler-ios] 136/204: Available for transfer, gnunet, 2024/12/05
- [taler-taler-ios] 192/204: layout, gnunet, 2024/12/05
- [taler-taler-ios] 196/204: Nav header, gnunet, 2024/12/05
- [taler-taler-ios] 189/204: AccountPicker, gnunet, 2024/12/05
- [taler-taler-ios] 142/204: DepositAmountView, gnunet, 2024/12/05
- [taler-taler-ios] 153/204: products, gnunet, 2024/12/05
- [taler-taler-ios] 161/204: DepositWireTypesForCurrency, gnunet, 2024/12/05
- [taler-taler-ios] 150/204: layout improvement, gnunet, 2024/12/05