From 11ed8c3acc2839755e388bcdb8e12fe28dbbaf24 Mon Sep 17 00:00:00 2001 From: Max schwenk Date: Wed, 18 Nov 2026 22:37:25 -0500 Subject: [PATCH 1/2] fix(mobile): iPhone Duo rail buttons stay sharp after the app returns from the background After a return from the background, UIKit stacks the tab bar's private VerticalBarPocketView over the folded Duo's whole rail, above the screen's, and its CABackdropLayer blurs the header buttons under it. An app delegate subscriber hides the blurring layer of the topmost overlapping pocket and shows it again once that pocket no longer overlaps another. --- .../expo-module.config.json | 3 +- .../ios/T3RailPocketBlur.swift | 89 +++++++++++++++++++ 2 files changed, 91 insertions(+), 1 deletion(-) create mode 100644 apps/mobile/modules/t3-native-controls/ios/T3RailPocketBlur.swift diff --git a/apps/mobile/modules/t3-native-controls/expo-module.config.json b/apps/mobile/modules/t3-native-controls/expo-module.config.json index d405bf41cc335..983f1dff114af 100644 --- a/apps/mobile/modules/t3-native-controls/expo-module.config.json +++ b/apps/mobile/modules/t3-native-controls/expo-module.config.json @@ -5,7 +5,8 @@ "appDelegateSubscribers": [ "T3WorkspaceOrientationSubscriber", "T3MenuDismissTouchGateSubscriber", - "T3BackgroundGraceSubscriber" + "T3BackgroundGraceSubscriber", + "T3RailPocketBlurSubscriber" ] }, "android": { diff --git a/apps/mobile/modules/t3-native-controls/ios/T3RailPocketBlur.swift b/apps/mobile/modules/t3-native-controls/ios/T3RailPocketBlur.swift new file mode 100644 index 0000000000000..a7122f0f962d9 --- /dev/null +++ b/apps/mobile/modules/t3-native-controls/ios/T3RailPocketBlur.swift @@ -0,0 +1,89 @@ +import ExpoModulesCore +import QuartzCore +import UIKit + +// Folded iPhone Duo rail (iOS 27.2): after a return from the background, UIKit lays the tab bar's +// private VerticalBarPocketView over the whole rail, above the screen's, and its CABackdropLayer +// blurs the screen's header buttons. A UIKit rename of these private classes makes this a no-op. +public final class T3RailPocketBlurSubscriber: ExpoAppDelegateSubscriber { + public func applicationDidBecomeActive(_ application: UIApplication) { + // UIKit can add the second pocket a moment after activation, so look again shortly after. + DispatchQueue.main.async { T3RailPocketBlur.update() } + for delay in [0.3, 1.5] { + DispatchQueue.main.asyncAfter(deadline: .now() + delay) { T3RailPocketBlur.update() } + } + } +} + +@MainActor +enum T3RailPocketBlur { + private static let pocketClassName = "VerticalBar".appending("PocketView") + private static let backdropClassName = "CABackdrop".appending("Layer") + /// Backdrop layers this hid, so they can be shown again once their pocket is alone. + private static let hiddenLayers = NSHashTable.weakObjects() + + private struct Pocket { + let view: UIView + /// Subview indexes from the window, which give the drawing order. + let path: [Int] + let frame: CGRect + } + + static func update() { + var stacked: [CALayer] = [] + let windows = UIApplication.shared.connectedScenes + .compactMap { $0 as? UIWindowScene } + .flatMap(\.windows) + for window in windows { + var pockets: [Pocket] = [] + var path: [Int] = [] + collectPockets(in: window, window: window, path: &path, into: &pockets) + let overlapping = pockets.filter { pocket in + pockets.contains { $0.view !== pocket.view && $0.frame.intersects(pocket.frame) } + } + if let top = overlapping.max(by: { drawsBelow($0.path, $1.path) }) { + stacked += backdropLayers(of: top.view) + } + } + for layer in hiddenLayers.allObjects where !stacked.contains(where: { $0 === layer }) { + layer.isHidden = false + hiddenLayers.remove(layer) + } + // A backdrop UIKit hid itself stays UIKit's to show again. + for layer in stacked where !layer.isHidden { + layer.isHidden = true + hiddenLayers.add(layer) + } + } + + private static func collectPockets( + in view: UIView, window: UIWindow, path: inout [Int], into pockets: inout [Pocket] + ) { + guard !view.isHidden, view.alpha > 0.01 else { return } + if NSStringFromClass(type(of: view)).contains(pocketClassName) { + let frame = view.convert(view.bounds, to: window) + if !frame.isEmpty { pockets.append(Pocket(view: view, path: path, frame: frame)) } + } + for (index, subview) in view.subviews.enumerated() { + path.append(index) + collectPockets(in: subview, window: window, path: &path, into: &pockets) + path.removeLast() + } + } + + /// A later sibling, or a descendant, draws above. + private static func drawsBelow(_ a: [Int], _ b: [Int]) -> Bool { + for (x, y) in zip(a, b) where x != y { return x < y } + return a.count < b.count + } + + /// The pocket's frost is a layer no view owns, holding the backdrop layer that blurs. + private static func backdropLayers(of pocket: UIView) -> [CALayer] { + (pocket.layer.sublayers ?? []).filter { layer in + !(layer.delegate is UIView) + && ([layer] + (layer.sublayers ?? [])).contains { + NSStringFromClass(type(of: $0)) == backdropClassName + } + } + } +} From 231b330496e8cdd7d8215265ce2b15e827d7641f Mon Sep 17 00:00:00 2001 From: Max schwenk Date: Wed, 18 Nov 2026 23:01:50 -0500 Subject: [PATCH 2/2] chore(mobile): rail pocket comment no longer blames UIKit alone for the Duo blur --- .../modules/t3-native-controls/ios/T3RailPocketBlur.swift | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/apps/mobile/modules/t3-native-controls/ios/T3RailPocketBlur.swift b/apps/mobile/modules/t3-native-controls/ios/T3RailPocketBlur.swift index a7122f0f962d9..603cdc6b2c17a 100644 --- a/apps/mobile/modules/t3-native-controls/ios/T3RailPocketBlur.swift +++ b/apps/mobile/modules/t3-native-controls/ios/T3RailPocketBlur.swift @@ -2,9 +2,10 @@ import ExpoModulesCore import QuartzCore import UIKit -// Folded iPhone Duo rail (iOS 27.2): after a return from the background, UIKit lays the tab bar's -// private VerticalBarPocketView over the whole rail, above the screen's, and its CABackdropLayer -// blurs the screen's header buttons. A UIKit rename of these private classes makes this a no-op. +// Folded iPhone Duo rail (iOS 27.2): each of T3's navigation controllers shows its own private +// VerticalBarPocketView. After a return from the background the tab bar's pocket lands above that +// one and its CABackdropLayer blurs the header buttons. A plain UIKit app only has the tab bar's +// pocket, so this is a stopgap. A UIKit rename of these private classes makes this a no-op. public final class T3RailPocketBlurSubscriber: ExpoAppDelegateSubscriber { public func applicationDidBecomeActive(_ application: UIApplication) { // UIKit can add the second pocket a moment after activation, so look again shortly after.