authorgravatar for julius0216@outlook.comJulius Marminge <julius0216@outlook.com> 2026-10-01 10:51:24-07:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2026-10-01 10:51:24-07:00
log9962e6986db68cd5537d23153e7898d6b3696b85
treeb7cde15b2122f95e79e0b804f288ed4058328be2
parentce920f2ac893051bff2108c03346bd35340fd988
signature Signed by PGP key B5690EEEBB952194

fix(mobile): read display scale and width from the view's scene, not UIScreen.main (#12050)

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>

3 files changed, 16 insertions(+), 5 deletions(-)

apps/mobile/modules/t3-composer-editor/ios/T3ComposerEditorView.swift+9-1
......@@ -436,6 +436,7 @@ public final class T3ComposerEditorView: ExpoView, UITextViewDelegate, UITextDro
436436 private var iconImages: [String: UIImage] = [:]
437437 private var pendingIconUris = Set<String>()
438438 private var tokensNeedRebuild = false
439 private var chipsNeedMeasuredWidth = false
439440
440441 let onComposerChange = EventDispatcher()
441442 let onComposerSelectionChange = EventDispatcher()
......@@ -571,6 +572,10 @@ public final class T3ComposerEditorView: ExpoView, UITextViewDelegate, UITextDro
571572 public override func layoutSubviews() {
572573 super.layoutSubviews()
573574 textView.frame = bounds
575 if chipsNeedMeasuredWidth, bounds.width > 0 {
576 chipsNeedMeasuredWidth = false
577 applyControlledDocument(force: true)
578 }
574579 let placeholderX = textView.textContainerInset.left + textView.textContainer.lineFragmentPadding
575580 let placeholderY = textView.textContainerInset.top
576581 let placeholderWidth = max(
......@@ -970,7 +975,10 @@ public final class T3ComposerEditorView: ExpoView, UITextViewDelegate, UITextDro
970975 // `maximumWidth` does, so the chip always fits the line it sits on.
971976 let availableWidth = textView.textContainer.size.width > 0
972977 ? textView.textContainer.size.width - textView.textContainer.lineFragmentPadding * 2
973 : UIScreen.main.bounds.width
978 : (textView.window?.bounds.width ?? bounds.width)
979 if availableWidth <= 0 {
980 chipsNeedMeasuredWidth = true
981 }
974982 let maximumLabelWidth = max(chipFontSize * 3, availableWidth - padding * 2 - iconWidth - iconGap)
975983 paragraph.lineBreakMode = .byTruncatingMiddle
976984 attributedLabel.addAttribute(
apps/mobile/modules/t3-review-diff/ios/T3ReviewDiffView.swift+2-2
......@@ -1923,7 +1923,7 @@ private final class ReviewDiffContentView: UIView, UIGestureRecognizerDelegate {
19231923 theme.headerBackground.setFill()
19241924 context.fill(cardRect)
19251925
1926 let hairline = 1 / UIScreen.main.scale
1926 let hairline = 1 / traitCollection.displayScale
19271927 theme.border.setFill()
19281928 context.fill(CGRect(x: cardRect.minX, y: cardRect.maxY - hairline, width: cardRect.width, height: hairline))
19291929
......@@ -1982,7 +1982,7 @@ private final class ReviewDiffContentView: UIView, UIGestureRecognizerDelegate {
19821982 theme.background.setFill()
19831983 context.fill(rect)
19841984
1985 let hairline = 1 / UIScreen.main.scale
1985 let hairline = 1 / traitCollection.displayScale
19861986 theme.border.withAlphaComponent(0.65).setFill()
19871987 context.fill(CGRect(x: 0, y: rect.maxY - hairline, width: rect.width, height: hairline))
19881988
apps/mobile/modules/t3-terminal/ios/T3TerminalView.swift+5-2
......@@ -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 }