fix(swift-ios): keep code views readable

This commit is contained in:
Theo Browne committed 2026-08-09 20:55:03 -07:00
1 parent 58d043737d
commit 3180cbcd04
2 files changed
+46 -27

No files matched your search

@@ -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")
@@ -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 {