commit fad4fd7a25a5d3203776a60e8caff026fd8319e6
parent 1e9d37b1cbe712a195b896af4b16cc85c33dc425
Author: Marc Stibane <marc@taler.net>
Date: Wed, 16 Sep 2026 11:39:57 +0200
fromSheet
Diffstat:
3 files changed, 20 insertions(+), 3 deletions(-)
diff --git a/TalerCommon/HelperViews/CopyShare.swift b/TalerCommon/HelperViews/CopyShare.swift
@@ -160,6 +160,13 @@ struct ShareType: Hashable {
let image: UIImage?
}
// MARK: -
+/// The Share function can NOT be called from a sheet.
+/// Thus we need to know whether we were called from the .sheet view hierarchy
+/// If yes, then we must first dismiss the sheet before posting the .ShareAction notification
+extension EnvironmentValues {
+ @Entry var fromSheet: Bool = false
+}
+// MARK: -
@MainActor
struct ShareButton: View {
private let symLog = SymLogV(0)
@@ -167,8 +174,6 @@ struct ShareButton: View {
let image: UIImage?
let title: String
- @State private var scale: CGFloat = 1.0
-
init(_ textToShare: String, image: UIImage? = nil) {
self.textToShare = textToShare
self.image = image
@@ -180,12 +185,17 @@ struct ShareButton: View {
self.title = title
}
+ @Environment(\.fromSheet) private var fromSheet
@Environment(\.isEnabled) private var isEnabled: Bool
@EnvironmentObject private var controller: Controller
+ @State private var scale: CGFloat = 1.0
+
@MainActor
func dismissAndPost() {
- dismissTop()
+ if fromSheet {
+ dismissTop()
+ }
let shareType = ShareType(textToShare: textToShare, image: image)
let userInfo = [NOTIFICATIONSHARE: shareType]
NotificationCenter.default.post(name: .ShareAction, object: nil, userInfo: userInfo) // will trigger NavigationLink
diff --git a/TalerWallet1/Controllers/TalerWallet1App.swift b/TalerWallet1/Controllers/TalerWallet1App.swift
@@ -114,6 +114,7 @@ struct TalerWallet1App: App {
.environmentObject(controller)
.environmentObject(model)
.environmentObject(biometricService)
+ .environment(\.fromSheet, false)
.addKeyboardVisibilityToEnvironment()
/// external events are taler:// (or in the future payto://) URLs passed to this app
/// we handle them in .onOpenURL in MainView.swift
diff --git a/TalerWallet1/Views/Main/MainView.swift b/TalerWallet1/Views/Main/MainView.swift
@@ -280,9 +280,11 @@ struct MainView: View {
switch sheet {
case .action:
actionSheet()
+ .environment(\.fromSheet, true)
case .scanner:
qrSheet()
.environmentObject(tabBarModel)
+ .environment(\.fromSheet, true)
case .url(let url):
let uSheet = URLSheet(stack.push(),
selectedBalance: selectedBalance,
@@ -290,6 +292,7 @@ struct MainView: View {
.id("onOpenURL")
Sheet(stack: stack.push(), sheetView: AnyView(uSheet))
.environmentObject(tabBarModel)
+ .environment(\.fromSheet, true)
}
}
#else
@@ -301,16 +304,19 @@ struct MainView: View {
.id("onOpenURL")
Sheet(stack: stack.push(), sheetView: AnyView(sheet))
.environmentObject(tabBarModel)
+ .environment(\.fromSheet, true)
} // UrlSheet
.sheet(isPresented: unlocked($showScanner, locked),
onDismiss: dismissSheet) {
qrSheet()
.environmentObject(tabBarModel)
+ .environment(\.fromSheet, true)
} // QR Scanner
.sheet(isPresented: unlocked($showActionSheet, locked),
onDismiss: dismissActionSheet) {
actionSheet()
.environmentObject(tabBarModel)
+ .environment(\.fromSheet, true)
} // ActionSheet
#endif
} // VStack { networkUnavailable + mainGroup }