[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-taler-ios] 05/204: HelperViews
From: |
gnunet |
Subject: |
[taler-taler-ios] 05/204: HelperViews |
Date: |
Thu, 05 Dec 2024 23:49:33 +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 02d7a4a2b2b23545a6353b42c2efe637516b3633
Author: Marc Stibane <marc@taler.net>
AuthorDate: Sat Sep 28 22:36:35 2024 +0200
HelperViews
---
TalerWallet.xcodeproj/project.pbxproj | 12 ++++
TalerWallet1/Views/HelperViews/ScopePicker.swift | 51 ++++++++++++++
TalerWallet1/Views/HelperViews/TabBarView.swift | 88 ++++++++++++++++++++++++
TalerWallet1/Views/Main/MainView.swift | 77 +--------------------
4 files changed, 152 insertions(+), 76 deletions(-)
diff --git a/TalerWallet.xcodeproj/project.pbxproj
b/TalerWallet.xcodeproj/project.pbxproj
index 2116e9c..d78d2dc 100644
--- a/TalerWallet.xcodeproj/project.pbxproj
+++ b/TalerWallet.xcodeproj/project.pbxproj
@@ -174,6 +174,10 @@
4E77976F2C4BEA4E005D6ECB /* BalanceCellV.swift in Sources */ =
{isa = PBXBuildFile; fileRef = 4E77976E2C4BEA4E005D6ECB /* BalanceCellV.swift
*/; };
4E7797702C4BEA4E005D6ECB /* BalanceCellV.swift in Sources */ =
{isa = PBXBuildFile; fileRef = 4E77976E2C4BEA4E005D6ECB /* BalanceCellV.swift
*/; };
4E7940DE29FC307C00A9AEA1 /* P2PSubjectV.swift in Sources */ =
{isa = PBXBuildFile; fileRef = 4E7940DD29FC307C00A9AEA1 /* P2PSubjectV.swift
*/; };
+ 4E847B7F2C9030E0003A164E /* TabBarView.swift in Sources */ =
{isa = PBXBuildFile; fileRef = 4E847B7E2C9030E0003A164E /* TabBarView.swift */;
};
+ 4E847B802C9030E0003A164E /* TabBarView.swift in Sources */ =
{isa = PBXBuildFile; fileRef = 4E847B7E2C9030E0003A164E /* TabBarView.swift */;
};
+ 4E847B822C9065FD003A164E /* ScopePicker.swift in Sources */ =
{isa = PBXBuildFile; fileRef = 4E847B812C9065FD003A164E /* ScopePicker.swift
*/; };
+ 4E847B832C9065FD003A164E /* ScopePicker.swift in Sources */ =
{isa = PBXBuildFile; fileRef = 4E847B812C9065FD003A164E /* ScopePicker.swift
*/; };
4E87C8732A31CB7F001C6406 /* TransactionsEmptyView.swift in
Sources */ = {isa = PBXBuildFile; fileRef = 4E87C8722A31CB7F001C6406 /*
TransactionsEmptyView.swift */; };
4E8C17202A6509BB005B2392 /*
Atkinson-Hyperlegible-Regular-102.otf in Resources */ = {isa = PBXBuildFile;
fileRef = 4E8C171C2A6509BB005B2392 /* Atkinson-Hyperlegible-Regular-102.otf */;
};
4E8C17212A6509BB005B2392 /*
Atkinson-Hyperlegible-Italic-102.otf in Resources */ = {isa = PBXBuildFile;
fileRef = 4E8C171D2A6509BB005B2392 /* Atkinson-Hyperlegible-Italic-102.otf */;
};
@@ -398,6 +402,8 @@
4E77976E2C4BEA4E005D6ECB /* BalanceCellV.swift */ = {isa =
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path
= BalanceCellV.swift; sourceTree = "<group>"; };
4E7940DD29FC307C00A9AEA1 /* P2PSubjectV.swift */ = {isa =
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path
= P2PSubjectV.swift; sourceTree = "<group>"; };
4E7CFD372A532CE100CBAFF3 /* WhatToTest.en-US.txt */ = {isa =
PBXFileReference; lastKnownFileType = text; path = "WhatToTest.en-US.txt";
sourceTree = "<group>"; };
+ 4E847B7E2C9030E0003A164E /* TabBarView.swift */ = {isa =
PBXFileReference; lastKnownFileType = sourcecode.swift; path =
TabBarView.swift; sourceTree = "<group>"; };
+ 4E847B812C9065FD003A164E /* ScopePicker.swift */ = {isa =
PBXFileReference; lastKnownFileType = sourcecode.swift; path =
ScopePicker.swift; sourceTree = "<group>"; };
4E87C8722A31CB7F001C6406 /* TransactionsEmptyView.swift */ =
{isa = PBXFileReference; fileEncoding = 4; lastKnownFileType =
sourcecode.swift; path = TransactionsEmptyView.swift; sourceTree = "<group>"; };
4E8C171C2A6509BB005B2392 /*
Atkinson-Hyperlegible-Regular-102.otf */ = {isa = PBXFileReference;
lastKnownFileType = file; path = "Atkinson-Hyperlegible-Regular-102.otf";
sourceTree = "<group>"; };
4E8C171D2A6509BB005B2392 /*
Atkinson-Hyperlegible-Italic-102.otf */ = {isa = PBXFileReference;
lastKnownFileType = file; path = "Atkinson-Hyperlegible-Italic-102.otf";
sourceTree = "<group>"; };
@@ -861,6 +867,8 @@
4EBA82AA2A3EB2CA00E5F39A /*
TransactionButton.swift */,
4E983C2B2ADC416800FA9CC5 /*
View+fitsSideBySide.swift */,
4EEBEFAF2C8982180020D340 /*
View+fixedInnerHeight.swift */,
+ 4E847B7E2C9030E0003A164E /* TabBarView.swift */,
+ 4E847B812C9065FD003A164E /* ScopePicker.swift
*/,
);
path = HelperViews;
sourceTree = "<group>";
@@ -1241,6 +1249,7 @@
4E3EAE4B2A990778009F1BE8 /* ShareSheet.swift in
Sources */,
4EC4008F2AE8019700DF72C7 /*
ExchangeRowView.swift in Sources */,
4E3EAE4C2A990778009F1BE8 /* AmountRowV.swift in
Sources */,
+ 4E847B822C9065FD003A164E /* ScopePicker.swift
in Sources */,
4E605DBA2AB05FB6002FB9A7 /* BarGraph.swift in
Sources */,
4E2B337D2C8B1D5500186A3E /* ActionsSheet.swift
in Sources */,
4E3EAE4D2A990778009F1BE8 /* P2pAcceptDone.swift
in Sources */,
@@ -1263,6 +1272,7 @@
4E3EAE592A990778009F1BE8 /*
Model+Settings.swift in Sources */,
4EC4008C2AE5664100DF72C7 /*
CharacterSet+contains.swift in Sources */,
4E3EAE5A2A990778009F1BE8 /* ErrorView.swift in
Sources */,
+ 4E847B7F2C9030E0003A164E /* TabBarView.swift in
Sources */,
4E4F60A82C3BBF9F003BB669 /*
View+Condition.swift in Sources */,
4E96583C2B79656E00404A68 /*
DepositAmountV.swift in Sources */,
4E3EAE5B2A990778009F1BE8 /*
View+Notification.swift in Sources */,
@@ -1371,6 +1381,7 @@
4E753A082A0B6A5F002D9328 /* ShareSheet.swift in
Sources */,
4EC400902AE8019700DF72C7 /*
ExchangeRowView.swift in Sources */,
4EB0956C2989CBFE0043A8A1 /* AmountRowV.swift in
Sources */,
+ 4E847B832C9065FD003A164E /* ScopePicker.swift
in Sources */,
4E605DBB2AB05FB6002FB9A7 /* BarGraph.swift in
Sources */,
4E2B337E2C8B1D5500186A3E /* ActionsSheet.swift
in Sources */,
4E3B4BC32A42252300CC88B8 /* P2pAcceptDone.swift
in Sources */,
@@ -1393,6 +1404,7 @@
4EB095152989CBB00043A8A1 /*
Model+Settings.swift in Sources */,
4EC4008D2AE5664100DF72C7 /*
CharacterSet+contains.swift in Sources */,
4EB095692989CBFE0043A8A1 /* ErrorView.swift in
Sources */,
+ 4E847B802C9030E0003A164E /* TabBarView.swift in
Sources */,
4E4F60A92C3BBF9F003BB669 /*
View+Condition.swift in Sources */,
4E96583D2B79656E00404A68 /*
DepositAmountV.swift in Sources */,
4E3B4BC72A429F2A00CC88B8 /*
View+Notification.swift in Sources */,
diff --git a/TalerWallet1/Views/HelperViews/ScopePicker.swift
b/TalerWallet1/Views/HelperViews/ScopePicker.swift
new file mode 100644
index 0000000..e4c2a08
--- /dev/null
+++ b/TalerWallet1/Views/HelperViews/ScopePicker.swift
@@ -0,0 +1,51 @@
+/*
+ * This file is part of GNU Taler, ©2022-24 Taler Systems S.A.
+ * See LICENSE.md
+ */
+/**
+ * @author Marc Stibane
+ */
+import SwiftUI
+
+struct ScopePicker: View {
+ let stack: CallStack
+ let balances: [Balance]
+
+ @Binding var selected: Int
+// @State private var selected = 0
+
+ func formattedAmount(_ balance: Balance) -> String {
+ let amount = balance.available
+ return amount.formatted(isNegative: false, useISO: false)
+ }
+
+ func label(balance: Balance) -> String {
+ let label = balance.scopeInfo.url?.trimURL
+ ?? balance.scopeInfo.currency
+ return String("\(label):\t\(formattedAmount(balance).nbs)")
+ }
+
+ var body: some View {
+ HStack {
+ Text("From: ")
+ Spacer()
+ if (balances.count > 1) {
+ Picker(EMPTYSTRING, selection: $selected) {
+ ForEach(0..<balances.count, id: \.self) { index in
+ Text(label(balance: balances[index]))
+ .tag(index)
+ }
+ }
+ } else { // only 1 choice, no need for a picker
+ Text(label(balance: balances[0]))
+ .tag(0)
+ }
+ }
+ .padding(.leading)
+ .talerFont(.title3)
+ }
+}
+// MARK: -
+//#Preview {
+// ScopePicker()
+//}
diff --git a/TalerWallet1/Views/HelperViews/TabBarView.swift
b/TalerWallet1/Views/HelperViews/TabBarView.swift
new file mode 100644
index 0000000..dcd4230
--- /dev/null
+++ b/TalerWallet1/Views/HelperViews/TabBarView.swift
@@ -0,0 +1,88 @@
+/*
+ * This file is part of GNU Taler, ©2022-24 Taler Systems S.A.
+ * See LICENSE.md
+ */
+/**
+ * @author Marc Stibane
+ */
+import SwiftUI
+
+struct TabBarView: View {
+ @Binding var selection: Tab
+ let onActionTab: () -> Void
+
+ @AppStorage("minimalistic") var minimalistic: Bool = false
+ @State private var isHidden = 0
+
+ private func tabBarItem(for tab: Tab) -> some View {
+ VStack(spacing: 0) {
+ if tab == .actions {
+ let width = 72.0
+ let height = 57.6
+ tab.image
+ .resizable()
+ .scaledToFill()
+ .frame(width: width, height: height)
+ .clipped() // Crop the image to the frame size
+ .padding(.bottom, 4)
+ } else {
+ let size = minimalistic ? 36.0 : 24.0
+ tab.image
+ .resizable()
+ .renderingMode(.template)
+ .tint(.black)
+ .aspectRatio(contentMode: .fit)
+ .frame(width: size, height: size)
+ if !minimalistic {
+ Text(tab.title)
+ .lineLimit(1)
+ .talerFont(.body)
+ // .padding(.top, 2)
+ }
+ }
+ }
+ .foregroundColor(selection == tab ? .accentColor : .secondary)
+ .padding(.vertical, 8)
+ .accessibilityElement(children: .combine)
+ .accessibility(label: Text(tab.title))
+ .accessibility(addTraits: [.isButton])
+ }
+
+ var body: some View {
+ Group {
+ if isHidden > 0 {
+ EmptyView()
+ } else {
+ HStack(alignment: .bottom) {
+ ForEach(Tab.allCases, id: \.self) { tab in
+ tabBarItem(for: tab)
+ .frame(maxWidth: .infinity)
+ .contentShape(Rectangle())
+ .onTapGesture {
+ if tab == .actions {
+ onActionTab()
+ } else {
+ selection = tab
+ }
+ }
+ }
+ }
+
.background(WalletColors().backgroundColor.edgesIgnoringSafeArea(.bottom))
+ }
+ }
+ .onNotification(.HideTabBarView) {
+ isHidden += 1
+ print("❗️HideTabBarView \(isHidden)")
+ }
+ .onNotification(.ShowTabBarView) {
+ if isHidden > 0 {
+ isHidden -= 1
+ print("❗️ShowTabBarView \(isHidden)")
+ }
+ }
+ }
+}
+// MARK: -
+//#Preview {
+// TabBarView()
+//}
diff --git a/TalerWallet1/Views/Main/MainView.swift
b/TalerWallet1/Views/Main/MainView.swift
index a7e6eba..85587df 100644
--- a/TalerWallet1/Views/Main/MainView.swift
+++ b/TalerWallet1/Views/Main/MainView.swift
@@ -1,5 +1,5 @@
/*
- * This file is part of GNU Taler, ©2022-23 Taler Systems S.A.
+ * This file is part of GNU Taler, ©2022-24 Taler Systems S.A.
* See LICENSE.md
*/
/**
@@ -203,81 +203,6 @@ enum Tab: String, Hashable, CaseIterable {
}
-struct TabBarView: View {
- @Binding var selection: Tab
- let onActionTab: () -> Void
- @AppStorage("minimalistic") var minimalistic: Bool = false
- @State private var isHidden = 0
-
- private func tabBarItem(for tab: Tab) -> some View {
- VStack(spacing: 0) {
- if tab == .actions {
- let width = 72.0
- let height = 57.6
- tab.image
- .resizable()
- .scaledToFill()
- .frame(width: width, height: height)
- .clipped() // Crop the image to the frame size
- .padding(.bottom, 4)
- } else {
- let size = minimalistic ? 36.0 : 24.0
- tab.image
- .resizable()
- .renderingMode(.template)
- .tint(.black)
- .aspectRatio(contentMode: .fit)
- .frame(width: size, height: size)
- if !minimalistic {
- Text(tab.title)
- .lineLimit(1)
- .talerFont(.body)
-// .padding(.top, 2)
- }
- }
- }
- .foregroundColor(selection == tab ? .accentColor : .secondary)
- .padding(.vertical, 8)
- .accessibilityElement(children: .combine)
- .accessibility(label: Text(tab.title))
- .accessibility(addTraits: [.isButton])
- }
-
- var body: some View {
- Group {
- if isHidden > 0 {
- EmptyView()
- } else {
- HStack(alignment: .bottom) {
- ForEach(Tab.allCases, id: \.self) { tab in
- tabBarItem(for: tab)
- .frame(maxWidth: .infinity)
- .contentShape(Rectangle())
- .onTapGesture {
- if tab == .actions {
- onActionTab()
- } else {
- selection = tab
- }
- }
- }
- }
-
.background(WalletColors().backgroundColor.edgesIgnoringSafeArea(.bottom))
- }
- }
- .onNotification(.HideTabBarView) {
- isHidden += 1
- print("❗️HideTabBarView \(isHidden)")
- }
- .onNotification(.ShowTabBarView) {
- if isHidden > 0 {
- isHidden -= 1
- print("❗️ShowTabBarView \(isHidden)")
- }
- }
- }
-}
-
// MARK: - Content
extension MainView {
struct Content: View {
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
- [taler-taler-ios] branch master updated (5f3f808 -> 36ccf96), gnunet, 2024/12/05
- [taler-taler-ios] 01/204: Notifications, gnunet, 2024/12/05
- [taler-taler-ios] 03/204: Actions, gnunet, 2024/12/05
- [taler-taler-ios] 04/204: w.i.p, gnunet, 2024/12/05
- [taler-taler-ios] 02/204: Actions, -Overview, gnunet, 2024/12/05
- [taler-taler-ios] 08/204: cleanup, gnunet, 2024/12/05
- [taler-taler-ios] 06/204: fix fixedInnerHeight, gnunet, 2024/12/05
- [taler-taler-ios] 05/204: HelperViews,
gnunet <=
- [taler-taler-ios] 07/204: amountAvailable @Binding, gnunet, 2024/12/05
- [taler-taler-ios] 09/204: nonZeroBalances, gnunet, 2024/12/05
- [taler-taler-ios] 11/204: debug, gnunet, 2024/12/05
- [taler-taler-ios] 10/204: SendAmount with Picker, gnunet, 2024/12/05
- [taler-taler-ios] 16/204: GetMaxDepositAmount, gnunet, 2024/12/05
- [taler-taler-ios] 12/204: cleanup project, gnunet, 2024/12/05
- [taler-taler-ios] 14/204: PaymentInsufficientBalanceDetails, gnunet, 2024/12/05
- [taler-taler-ios] 22/204: Sheet drop bar, gnunet, 2024/12/05
- [taler-taler-ios] 13/204: balances & selectedBalance, move action navigation to MainView, gnunet, 2024/12/05
- [taler-taler-ios] 24/204: @State ScopeInfo.zero, gnunet, 2024/12/05