taler-ios

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

commit 4be72e065a561975052d57f446e64f822a2252f9
parent 9c67c1200cc3badecbaed4e8f74f3d4a0209fb06
Author: Marc Stibane <marc@taler.net>
Date:   Sun, 30 Mar 2025 21:55:39 +0200

hasNotch, hasIsland

Diffstat:
MTalerWallet1/Controllers/DebugViewC.swift | 9+--------
MTalerWallet1/Helper/UIScreen+screenSize.swift | 18++++++++++++++++++
2 files changed, 19 insertions(+), 8 deletions(-)

diff --git a/TalerWallet1/Controllers/DebugViewC.swift b/TalerWallet1/Controllers/DebugViewC.swift @@ -107,13 +107,6 @@ public let SHEET_REFUND = SHEET_RCV_P2P + 10 // 170 Recei // MARK: - -extension UIDevice { - var hasNotch: Bool { - let bottom = UIApplication.shared.keyWindow?.safeAreaInsets.bottom ?? 0 - return bottom > 0 - } -} -// MARK: - struct DebugViewV: View { private let symLog = SymLogV(0) @EnvironmentObject private var debugViewC: DebugViewC @@ -128,7 +121,7 @@ struct DebugViewV: View { HStack { Spacer() Spacer() - if UIDevice.current.hasNotch { + if UIScreen.hasNotch { Spacer() Spacer() } diff --git a/TalerWallet1/Helper/UIScreen+screenSize.swift b/TalerWallet1/Helper/UIScreen+screenSize.swift @@ -27,4 +27,22 @@ extension UIScreen { return size.height/size.width < 2 } } + static var hasNotch: Bool { + let insets = UIApplication.shared.keyWindow?.safeAreaInsets + let bottom = insets?.bottom ?? 0 + return bottom > 0 + } + static var hasIsland: Bool { + let insets = UIApplication.shared.keyWindow?.safeAreaInsets + let left = insets?.left ?? 0 + let bottom = insets?.bottom ?? 0 + /// Portrait: 15PM 59,0,34 XS 38,0,29 8plus 20,0,0 + /// Landscape: 0,59,21 0,38,21 0,0,0 + return bottom > 30 || left > 50 + } + static var horzInsets: CGFloat { + let insets = UIApplication.shared.keyWindow?.safeAreaInsets + let left = insets?.left ?? 0 + return left + } }