From 3180cbcd0487edcac92a8fdaaae602b29625aa35 Mon Sep 17 00:00:00 2001 From: Theo Browne Date: Fri, 7 Aug 2026 04:45:21 -0700 Subject: [PATCH] fix(swift-ios): keep code views readable --- .../Features/Files/FeatureFilesView.swift | 36 +++++++++++------- .../Features/Review/FeatureReviewView.swift | 37 ++++++++++++------- 2 files changed, 46 insertions(+), 27 deletions(-) diff --git a/apps/swift-ios/Features/Files/FeatureFilesView.swift b/apps/swift-ios/Features/Files/FeatureFilesView.swift index 4ac6dab297..9b95543b03 100644 --- a/apps/swift-ios/Features/Files/FeatureFilesView.swift +++ b/apps/swift-ios/Features/Files/FeatureFilesView.swift @@ -306,23 +306,31 @@ private struct FeatureSourceTextView: View { let lines: [FeatureSourceLine] var body: some View { - ScrollView([.horizontal, .vertical]) { - LazyVStack(alignment: .leading, spacing: 0) { - ForEach(lines) { line in - HStack(alignment: .top, spacing: 10) { - Text("\(line.number)") - .foregroundStyle(.tertiary) - .frame(width: 44, alignment: .trailing) - .accessibilityHidden(true) - FeatureHighlightedSourceLine(line: line) + GeometryReader { proxy in + ScrollView([.horizontal, .vertical]) { + LazyVStack(alignment: .leading, spacing: 0) { + ForEach(lines) { line in + HStack(alignment: .top, spacing: 10) { + Text("\(line.number)") + .foregroundStyle(.tertiary) + .frame(width: 44, alignment: .trailing) + .accessibilityHidden(true) + FeatureHighlightedSourceLine(line: line) + } + .font(T3Typography.code) + .fixedSize(horizontal: true, vertical: false) + .frame( + minWidth: proxy.size.width, + minHeight: 22, + alignment: .leading + ) } - .font(T3Typography.code) - .frame(minHeight: 22) } + .frame(minWidth: proxy.size.width, alignment: .leading) + .padding(.vertical, 10) + .padding(.trailing, 14) + .textSelection(.enabled) } - .padding(.vertical, 10) - .padding(.trailing, 14) - .textSelection(.enabled) } .background(Color.black) .accessibilityLabel("Source file") diff --git a/apps/swift-ios/Features/Review/FeatureReviewView.swift b/apps/swift-ios/Features/Review/FeatureReviewView.swift index 1b1d146322..a2ab122ce1 100644 --- a/apps/swift-ios/Features/Review/FeatureReviewView.swift +++ b/apps/swift-ios/Features/Review/FeatureReviewView.swift @@ -218,20 +218,24 @@ private struct FeatureDiffView: View { description: Text("No line-level preview is available.") ) } else { - ScrollView([.horizontal, .vertical]) { - LazyVStack(alignment: .leading, spacing: 0) { - ForEach(renderedLines) { line in - FeatureDiffLineRow( - line: line, - isSelected: selection(for: line) == selectedLine - ) { - guard let selection = selection(for: line) else { return } - selectedLine = selection - openCommentComposer() + GeometryReader { proxy in + ScrollView([.horizontal, .vertical]) { + LazyVStack(alignment: .leading, spacing: 0) { + ForEach(renderedLines) { line in + FeatureDiffLineRow( + line: line, + isSelected: selection(for: line) == selectedLine, + minimumWidth: proxy.size.width + ) { + guard let selection = selection(for: line) else { return } + selectedLine = selection + openCommentComposer() + } } } + .frame(minWidth: proxy.size.width, alignment: .leading) + .padding(.vertical, 8) } - .padding(.vertical, 8) } } } @@ -419,6 +423,7 @@ private struct FeatureDiffView: View { private struct FeatureDiffLineRow: View { let line: FeatureDiffLine let isSelected: Bool + let minimumWidth: CGFloat let select: () -> Void var body: some View { @@ -427,6 +432,7 @@ private struct FeatureDiffLineRow: View { Text(line.text) .foregroundStyle(.blue) .padding(.horizontal, 10) + .fixedSize(horizontal: true, vertical: false) } else { lineNumber(line.oldLine) lineNumber(line.newLine) @@ -434,13 +440,18 @@ private struct FeatureDiffLineRow: View { .foregroundStyle(prefixColor) .frame(width: 18) diffText + .fixedSize(horizontal: true, vertical: false) .textSelection(.enabled) .padding(.trailing, 12) } } .font(T3Typography.code) - .frame(minHeight: line.kind == .hunk ? 30 : 22, alignment: .leading) - .frame(maxWidth: .infinity, alignment: .leading) + .fixedSize(horizontal: true, vertical: false) + .frame( + minWidth: minimumWidth, + minHeight: line.kind == .hunk ? 30 : 22, + alignment: .leading + ) .background(isSelected ? T3Colors.accent.opacity(0.14) : background) .overlay(alignment: .leading) { if isSelected {