diff --git a/apps/mobile/modules/t3-composer-editor/ios/T3ComposerEditorView.swift b/apps/mobile/modules/t3-composer-editor/ios/T3ComposerEditorView.swift index 50ac2afbcb46f3848fd89dd62662a4c2b066c71d..bff803f69c0032e8a96d9466528cd993d21d6e2e 100644 --- a/apps/mobile/modules/t3-composer-editor/ios/T3ComposerEditorView.swift +++ b/apps/mobile/modules/t3-composer-editor/ios/T3ComposerEditorView.swift @@ -436,6 +436,7 @@ public final class T3ComposerEditorView: ExpoView, UITextViewDelegate, UITextDro private var iconImages: [String: UIImage] = [:] private var pendingIconUris = Set() private var tokensNeedRebuild = false + private var chipsNeedMeasuredWidth = false let onComposerChange = EventDispatcher() let onComposerSelectionChange = EventDispatcher() @@ -571,6 +572,10 @@ public final class T3ComposerEditorView: ExpoView, UITextViewDelegate, UITextDro public override func layoutSubviews() { super.layoutSubviews() textView.frame = bounds + if chipsNeedMeasuredWidth, bounds.width > 0 { + chipsNeedMeasuredWidth = false + applyControlledDocument(force: true) + } let placeholderX = textView.textContainerInset.left + textView.textContainer.lineFragmentPadding let placeholderY = textView.textContainerInset.top let placeholderWidth = max( @@ -970,7 +975,10 @@ public final class T3ComposerEditorView: ExpoView, UITextViewDelegate, UITextDro // `maximumWidth` does, so the chip always fits the line it sits on. let availableWidth = textView.textContainer.size.width > 0 ? textView.textContainer.size.width - textView.textContainer.lineFragmentPadding * 2 - : UIScreen.main.bounds.width + : (textView.window?.bounds.width ?? bounds.width) + if availableWidth <= 0 { + chipsNeedMeasuredWidth = true + } let maximumLabelWidth = max(chipFontSize * 3, availableWidth - padding * 2 - iconWidth - iconGap) paragraph.lineBreakMode = .byTruncatingMiddle attributedLabel.addAttribute( diff --git a/apps/mobile/modules/t3-review-diff/ios/T3ReviewDiffView.swift b/apps/mobile/modules/t3-review-diff/ios/T3ReviewDiffView.swift index e2400e0a93933e175d1d99cc73843cd1ba1276ea..928e3b5669d1840c44f5978eca7f496c475047e5 100644 --- a/apps/mobile/modules/t3-review-diff/ios/T3ReviewDiffView.swift +++ b/apps/mobile/modules/t3-review-diff/ios/T3ReviewDiffView.swift @@ -1923,7 +1923,7 @@ private final class ReviewDiffContentView: UIView, UIGestureRecognizerDelegate { theme.headerBackground.setFill() context.fill(cardRect) - let hairline = 1 / UIScreen.main.scale + let hairline = 1 / traitCollection.displayScale theme.border.setFill() context.fill(CGRect(x: cardRect.minX, y: cardRect.maxY - hairline, width: cardRect.width, height: hairline)) @@ -1982,7 +1982,7 @@ private final class ReviewDiffContentView: UIView, UIGestureRecognizerDelegate { theme.background.setFill() context.fill(rect) - let hairline = 1 / UIScreen.main.scale + let hairline = 1 / traitCollection.displayScale theme.border.withAlphaComponent(0.65).setFill() context.fill(CGRect(x: 0, y: rect.maxY - hairline, width: rect.width, height: hairline)) diff --git a/apps/mobile/modules/t3-terminal/ios/T3TerminalView.swift b/apps/mobile/modules/t3-terminal/ios/T3TerminalView.swift index 69f8a6d4af162a8692674fe1286d9b5420bb4aac..9e382bfcd7eda0d2a7d333c3461a1d974dd15c04 100644 --- a/apps/mobile/modules/t3-terminal/ios/T3TerminalView.swift +++ b/apps/mobile/modules/t3-terminal/ios/T3TerminalView.swift @@ -315,7 +315,8 @@ public final class T3TerminalView: ExpoView, UITextFieldDelegate { applyTheme() clipsToBounds = true - contentScaleFactor = UIScreen.main.scale + // The real scale arrives with the window; layoutSubviews corrects it. + contentScaleFactor = traitCollection.displayScale terminalViewport.clipsToBounds = true terminalViewport.contentScaleFactor = contentScaleFactor @@ -677,7 +678,9 @@ public final class T3TerminalView: ExpoView, UITextFieldDelegate { } private func updateContentScale() { - let scale = window?.screen.scale ?? UIScreen.main.scale + // The trait collection follows the scene the view is in, which matters once + // iPhone apps run resizable and on external displays; UIScreen.main does not. + let scale = traitCollection.displayScale if contentScaleFactor != scale { contentScaleFactor = scale }