Skip to content

Commit ae1f238

Browse files
fix(mobile): read display scale and width from the view's scene, not UIScreen.main
iOS 27 makes iPhone apps resizable and SDK 58 stops reading UIScreen.main across Expo. The terminal, review diff, and composer views now take their display scale from the trait collection and the fallback chip width from the window they sit in, so hairlines and chip truncation stay right when the app is not full screen or is on another display. Co-Authored-By: Claude Fable 5 <[email protected]>
1 parent da341f9 commit ae1f238

3 files changed

Lines changed: 8 additions & 5 deletions

File tree

‎apps/mobile/modules/t3-composer-editor/ios/T3ComposerEditorView.swift‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -970,7 +970,7 @@ public final class T3ComposerEditorView: ExpoView, UITextViewDelegate, UITextDro
970970
// `maximumWidth` does, so the chip always fits the line it sits on.
971971
let availableWidth = textView.textContainer.size.width > 0
972972
? textView.textContainer.size.width - textView.textContainer.lineFragmentPadding * 2
973-
: UIScreen.main.bounds.width
973+
: (textView.window?.bounds.width ?? bounds.width)
974974
let maximumLabelWidth = max(chipFontSize * 3, availableWidth - padding * 2 - iconWidth - iconGap)
975975
paragraph.lineBreakMode = .byTruncatingMiddle
976976
attributedLabel.addAttribute(

‎apps/mobile/modules/t3-review-diff/ios/T3ReviewDiffView.swift‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1818,7 +1818,7 @@ private final class ReviewDiffContentView: UIView, UIGestureRecognizerDelegate {
18181818
theme.headerBackground.setFill()
18191819
context.fill(cardRect)
18201820

1821-
let hairline = 1 / UIScreen.main.scale
1821+
let hairline = 1 / traitCollection.displayScale
18221822
theme.border.setFill()
18231823
context.fill(CGRect(x: cardRect.minX, y: cardRect.maxY - hairline, width: cardRect.width, height: hairline))
18241824

@@ -1877,7 +1877,7 @@ private final class ReviewDiffContentView: UIView, UIGestureRecognizerDelegate {
18771877
theme.background.setFill()
18781878
context.fill(rect)
18791879

1880-
let hairline = 1 / UIScreen.main.scale
1880+
let hairline = 1 / traitCollection.displayScale
18811881
theme.border.withAlphaComponent(0.65).setFill()
18821882
context.fill(CGRect(x: 0, y: rect.maxY - hairline, width: rect.width, height: hairline))
18831883

‎apps/mobile/modules/t3-terminal/ios/T3TerminalView.swift‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,8 @@ public final class T3TerminalView: ExpoView, UITextFieldDelegate {
315315

316316
applyTheme()
317317
clipsToBounds = true
318-
contentScaleFactor = UIScreen.main.scale
318+
// The real scale arrives with the window; layoutSubviews corrects it.
319+
contentScaleFactor = traitCollection.displayScale
319320

320321
terminalViewport.clipsToBounds = true
321322
terminalViewport.contentScaleFactor = contentScaleFactor
@@ -677,7 +678,9 @@ public final class T3TerminalView: ExpoView, UITextFieldDelegate {
677678
}
678679

679680
private func updateContentScale() {
680-
let scale = window?.screen.scale ?? UIScreen.main.scale
681+
// The trait collection follows the scene the view is in, which matters once
682+
// iPhone apps run resizable and on external displays; UIScreen.main does not.
683+
let scale = traitCollection.displayScale
681684
if contentScaleFactor != scale {
682685
contentScaleFactor = scale
683686
}

0 commit comments

Comments
 (0)