[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-taler-ios] 26/69: Layout transactions
From: |
gnunet |
Subject: |
[taler-taler-ios] 26/69: Layout transactions |
Date: |
Fri, 19 Jan 2024 09:01:59 +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 eaf3a0595c549c9152ca323c3b4066339c39086b
Author: Marc Stibane <marc@taler.net>
AuthorDate: Thu Jan 4 17:45:09 2024 +0100
Layout transactions
---
.../Views/Transactions/TransactionRowView.swift | 169 +++++++++++----------
1 file changed, 88 insertions(+), 81 deletions(-)
diff --git a/TalerWallet1/Views/Transactions/TransactionRowView.swift
b/TalerWallet1/Views/Transactions/TransactionRowView.swift
index 3a37822..bf97108 100644
--- a/TalerWallet1/Views/Transactions/TransactionRowView.swift
+++ b/TalerWallet1/Views/Transactions/TransactionRowView.swift
@@ -35,73 +35,13 @@ struct IconBadge: View {
}.accessibilityHidden(true)
}
}
-struct TransactionRowContentV: View {
- var centerTop: String
- var centerBottom: String
- let isHorizontal: Bool
- let pending: Bool
- let incoming: Bool
- let shouldConfirm: Bool
- let needsKYC: Bool
- let done: Bool
- let foreColor:Color
-
- @Environment(\.colorSchemeContrast) private var colorSchemeContrast
-
- public static func width(titles: (String, String?), isHorizontal: Bool,
- sizeCategory: ContentSizeCategory) -> CGFloat {
- let imageFont = TalerFont.uiFont(.largeTitle)
- let uiFont1 = TalerFont.uiFont(.headline)
- let uiFont2 = TalerFont.uiFont(.callout)
-
- let image = "++"
- let imageWidth = image.widthOfString(usingUIFont: imageFont,
sizeCategory) + 8.0 // spacing: 8
- let (title1, title2) = titles
- let title1Width = title1.widthOfString(usingUIFont: uiFont1,
sizeCategory)
- var title2Width = 0.0
- var totalWidth = title1Width
- if let title2 {
- title2Width = title2.widthOfString(usingUIFont: uiFont2,
sizeCategory)
- let blankStr = " "
- totalWidth += blankStr.widthOfString(usingUIFont: uiFont1,
sizeCategory) + title2Width
- }
-
-// let logStr = String(format: "image: %.2f title: %.2f total: %.2f",
imageWidth, max(title1Width, title2Width), totalWidth)
-// print(logStr)
- return imageWidth + (isHorizontal ? totalWidth
- : max(title1Width, title2Width))
- }
-
- var body: some View {
- let iconBadge = IconBadge(foreColor: foreColor, done: done, incoming:
incoming,
- shouldConfirm: shouldConfirm, needsKYC: needsKYC)
- let doneOrPending = done || pending
- let increasedContrast = colorSchemeContrast == .increased
- let textColor = doneOrPending ? .primary :
- increasedContrast ? .secondary : WalletColors().gray3
- HStack(spacing: 8) {
- iconBadge
- VStack(alignment: .leading) {
- Text(centerTop)
- .foregroundColor(textColor)
- .strikethrough(!doneOrPending, color: .red)
- .accessibilityFont(.headline)
-// .fontWeight(.medium) iOS 16
- .padding(.bottom, -2.0)
- .accessibilityLabel(doneOrPending ? centerTop : centerTop
+ ", canceled")
- Text(centerBottom)
- .foregroundColor(textColor)
- .accessibilityFont(.callout)
- }
- }
- }
-}
struct TransactionRowView: View {
let transaction : Transaction
let currency: String
@Environment(\.sizeCategory) var sizeCategory
+ @Environment(\.colorSchemeContrast) private var colorSchemeContrast
@EnvironmentObject private var controller: Controller
func needVStack(available: CGFloat, contentWidth: CGFloat, valueWidth:
CGFloat) -> Bool {
@@ -110,11 +50,12 @@ struct TransactionRowView: View {
var body: some View {
let common = transaction.common
- let amount = common.amountEffective
let pending = transaction.isPending
let needsKYC = transaction.isPendingKYC
let shouldConfirm = transaction.shouldConfirm
let done = transaction.isDone
+ let doneOrPending = done || pending
+ let increasedContrast = colorSchemeContrast == .increased
let details = transaction.detailsToShow()
let keys = details.keys
@@ -122,32 +63,98 @@ struct TransactionRowView: View {
let incoming = common.incoming()
let foreColor = pending ? WalletColors().pendingColor(incoming)
: done ? WalletColors().transactionColor(incoming)
- : WalletColors().incompleteColor
+ : WalletColors().uncompletedColor
+ let textColor = doneOrPending ? .primary :
+ increasedContrast ? .secondary : Color(.tertiaryLabel)
let currencyInfo = controller.info(for: currency,
controller.currencyTicker)
- SingleAxisGeometryReader { width in
- Group {
- let amountStr = amount.string(currencyInfo)
- let amountWidth = amountStr.width(largeAmountFont: false,
sizeCategory)
- let contentWidth = TransactionRowContentV.width(titles:
(transaction.localizedType, dateString),
- isHorizontal: false,
sizeCategory: sizeCategory)
- let needVStack = needVStack(available: width, contentWidth:
contentWidth, valueWidth: amountWidth)
+ let iconBadge = IconBadge(foreColor: foreColor, done: done, incoming:
incoming,
+ shouldConfirm: shouldConfirm, needsKYC:
needsKYC)
+ let amountStr = common.amountEffective.string(currencyInfo)
+ let amountText = Text(amountStr)
+ .accessibilityFont(.title2)
+ .foregroundColor(foreColor)
+ .monospacedDigit()
+ let amount = HStack(spacing: 0) {
+ Spacer(minLength: 0)
+ amountText
+ }
+ let topString = transaction.localizedType
+ let centerTop = Text(topString)
+ .foregroundColor(textColor)
+ .strikethrough(!doneOrPending, color: .red)
+ .accessibilityFont(.headline)
+// .fontWeight(.medium) iOS 16
+ .padding(.bottom, -2.0)
+ .accessibilityLabel(doneOrPending ? topString : topString + ",
canceled")
+ let centerBottom = Text(dateString)
+ .foregroundColor(textColor)
+ .accessibilityFont(.callout)
- AmountRowV(amountStr: amountStr, amountColor: foreColor,
doneOrPending: done || pending,
- largeAmountFont: false, fitsHorizontal: !needVStack,
vertAlignment: .center) {
+ let layout1 = HStack(spacing: 0) {
+ HStack(spacing: -4) {
+ iconBadge
+ Spacer(minLength: 0)
+ VStack(alignment: .leading) {
+ centerTop
+ centerBottom
+ }
+ Spacer(minLength: 2)
+ }
+ amountText
+ }
- TransactionRowContentV(centerTop:
transaction.localizedType,
- centerBottom: dateString,
isHorizontal: true,
- pending: pending, incoming:
incoming,
- shouldConfirm: shouldConfirm, needsKYC:
needsKYC,
- done: done, foreColor:
foreColor)
+ let layout2 = VStack(spacing: 0) {
+ centerTop
+ HStack(spacing: 8) {
+ HStack(spacing: 0) {
+ iconBadge//.border(.blue)
+ Spacer(minLength: 0)
+ centerBottom
+ Spacer(minLength: 2)
+ }//.border(.green)
+ amountText//.border(.red)
+ }//.border(.orange)
+ }
+
+ let layout3 = VStack(spacing: 0) {
+ HStack(spacing: 8) {
+ HStack(spacing: 0) {
+ iconBadge
+ Spacer(minLength: 0)
+ centerTop
+ Spacer(minLength: 2)
}
- .accessibilityElement(children: .combine)
- .accessibilityValue(needsKYC ? ". Needs K Y C" :
- shouldConfirm ? ". Needs bank confirmation"
: EMPTYSTRING)
- .accessibilityHint("Will go to detail view.")
+ amountText
}
+ centerBottom
+ }
+
+ let layout4 = VStack(spacing: 0) {
+ centerTop
+ HStack(spacing: -4) {
+ iconBadge//.border(.green)
+ Spacer(minLength: 2
+ )
+ amountText//.border(.green)
+ }//.border(.orange)
+ centerBottom
+ }
+
+ Group {
+ if #available(iOS 16.0, *) {
+ ViewThatFits(in: .horizontal) {
+ layout1//.border(.green)
+ layout2
+ layout3//.border(.red)
+ layout4//.border(.blue)
+ }
+ } else { layout4 } // view for iOS 15
}
+ .accessibilityElement(children: .combine)
+ .accessibilityValue(needsKYC ? ". Needs K Y C" :
+ shouldConfirm ? ". Needs bank confirmation" :
EMPTYSTRING)
+ .accessibilityHint("Will go to detail view.")
}
}
// MARK: -
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
- [taler-taler-ios] 15/69: hapticFeedback, (continued)
- [taler-taler-ios] 15/69: hapticFeedback, gnunet, 2024/01/19
- [taler-taler-ios] 08/69: fixes, gnunet, 2024/01/19
- [taler-taler-ios] 11/69: Landscape, gnunet, 2024/01/19
- [taler-taler-ios] 17/69: Summary in ThreeAmountsV, gnunet, 2024/01/19
- [taler-taler-ios] 50/69: txStates, gnunet, 2024/01/19
- [taler-taler-ios] 24/69: dbg+cleanup, gnunet, 2024/01/19
- [taler-taler-ios] 13/69: definitions, gnunet, 2024/01/19
- [taler-taler-ios] 23/69: aborting Notification, gnunet, 2024/01/19
- [taler-taler-ios] 28/69: AccountRestriction, gnunet, 2024/01/19
- [taler-taler-ios] 60/69: P2P Expiration Timestamp, gnunet, 2024/01/19
- [taler-taler-ios] 26/69: Layout transactions,
gnunet <=
- [taler-taler-ios] 51/69: cleanup, gnunet, 2024/01/19
- [taler-taler-ios] 67/69: Bump version to 0.9.4 (0), gnunet, 2024/01/19
- [taler-taler-ios] 68/69: lowercased(), gnunet, 2024/01/19
- [taler-taler-ios] 54/69: Keyboard needs more time, gnunet, 2024/01/19
- [taler-taler-ios] 49/69: accessibilityDate, gnunet, 2024/01/19
- [taler-taler-ios] 46/69: AccountRestriction, gnunet, 2024/01/19
- [taler-taler-ios] 59/69: bugfix, gnunet, 2024/01/19
- [taler-taler-ios] 43/69: currency == ISO 4217, gnunet, 2024/01/19
- [taler-taler-ios] 56/69: remove "code", since "currency" IS ISO-4217 already for global, gnunet, 2024/01/19
- [taler-taler-ios] 58/69: use scopeInfo, gnunet, 2024/01/19