Wrap long lines in the Changes view
This commit is contained in:
@@ -605,40 +605,29 @@ struct DiffLines: View {
|
|||||||
let rows: [DiffRow]
|
let rows: [DiffRow]
|
||||||
var taskId: String?
|
var taskId: String?
|
||||||
@Environment(Store.self) private var store
|
@Environment(Store.self) private var store
|
||||||
@ViewState private var width: CGFloat = 0
|
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
ScrollView(.horizontal) {
|
VStack(alignment: .leading, spacing: 0) {
|
||||||
StretchColumn(minWidth: width) {
|
ForEach(Array(rows.enumerated()), id: \.offset) { _, row in
|
||||||
ForEach(Array(rows.enumerated()), id: \.offset) { _, row in
|
if let taskId, let anchor = row.anchor, let drafts = store.drafts {
|
||||||
if let taskId, let anchor = row.anchor, let drafts = store.drafts {
|
let comment = drafts.lineComment(taskId, anchor)
|
||||||
let comment = drafts.lineComment(taskId, anchor)
|
DiffLineRow(row: row, mark: comment != nil, hoverable: true)
|
||||||
DiffLineRow(row: row, mark: comment != nil, hoverable: true)
|
.simultaneousGesture(TapGesture().onEnded {
|
||||||
.simultaneousGesture(TapGesture().onEnded {
|
drafts.toggleLineComment(taskId, anchor, ready: lineCommentReady(store.images, taskId))
|
||||||
drafts.toggleLineComment(taskId, anchor, ready: lineCommentReady(store.images, taskId))
|
})
|
||||||
})
|
if comment != nil {
|
||||||
if comment != nil {
|
LineCommentBox(drafts: drafts, taskId: taskId, anchor: anchor)
|
||||||
LineCommentBox(drafts: drafts, taskId: taskId, anchor: anchor)
|
.padding(.horizontal, 10)
|
||||||
.frame(width: max(0, width - 20))
|
.padding(.vertical, 4)
|
||||||
.padding(.horizontal, 10)
|
|
||||||
.padding(.vertical, 4)
|
|
||||||
.frame(maxWidth: .infinity, alignment: .leading)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
DiffLineRow(row: row, mark: row.mark, hoverable: false)
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
DiffLineRow(row: row, mark: row.mark, hoverable: false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.font(Fonts.font(11, mono: true))
|
|
||||||
.padding(.vertical, 4)
|
|
||||||
.textSelection(.enabled)
|
|
||||||
}
|
|
||||||
.scrollBounceBehavior(.basedOnSize)
|
|
||||||
.onGeometryChange(for: CGFloat.self) { g in
|
|
||||||
g.size.width
|
|
||||||
} action: { w in
|
|
||||||
width = w
|
|
||||||
}
|
}
|
||||||
|
.font(Fonts.font(11, mono: true))
|
||||||
|
.padding(.vertical, 4)
|
||||||
|
.textSelection(.enabled)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -649,17 +638,18 @@ private struct DiffLineRow: View {
|
|||||||
@ViewState private var hover = false
|
@ViewState private var hover = false
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
HStack(spacing: 0) {
|
HStack(alignment: .firstTextBaseline, spacing: 0) {
|
||||||
if let n = row.lineno {
|
if let n = row.lineno {
|
||||||
Text(n)
|
Text(n)
|
||||||
.foregroundStyle(Palette.muted)
|
.foregroundStyle(Palette.muted)
|
||||||
.frame(minWidth: 30, alignment: .trailing)
|
.frame(minWidth: 30, alignment: .trailing)
|
||||||
.padding(.trailing, 8)
|
.padding(.trailing, 8)
|
||||||
|
.fixedSize()
|
||||||
}
|
}
|
||||||
Text(verbatim: row.text.isEmpty ? " " : row.text)
|
Text(verbatim: row.text.isEmpty ? " " : row.text)
|
||||||
.foregroundStyle(row.kind.color)
|
.foregroundStyle(row.kind.color)
|
||||||
|
.fixedSize(horizontal: false, vertical: true)
|
||||||
}
|
}
|
||||||
.fixedSize()
|
|
||||||
.padding(.horizontal, 10)
|
.padding(.horizontal, 10)
|
||||||
.frame(maxWidth: .infinity, alignment: .leading)
|
.frame(maxWidth: .infinity, alignment: .leading)
|
||||||
.background(row.kind.background)
|
.background(row.kind.background)
|
||||||
|
|||||||
Reference in New Issue
Block a user