mirror of
https://codeberg.org/secana/Forji.git
synced 2026-06-16 05:13:55 -07:00
feat: make tappable diff lines act as buttons for VoiceOver
Diff lines that accept a review comment used an onTapGesture, which VoiceOver neither announces as actionable nor reliably activates. Commentable lines are now wrapped in a Button (.plain style, so they look identical), giving them the button trait, an "Add a comment on this line" hint, and proper activation. Non-commentable lines stay plain. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
b0f50eca38
commit
e108283e96
1 changed files with 14 additions and 4 deletions
|
|
@ -60,8 +60,10 @@ struct DiffView: View {
|
|||
}
|
||||
}
|
||||
|
||||
@ViewBuilder
|
||||
private func diffLineRow(line: DiffLine, filePath: String) -> some View {
|
||||
HStack(spacing: 0) {
|
||||
let isCommentable = onLineTap != nil && line.type != .header && line.diffPosition != nil
|
||||
let row = HStack(spacing: 0) {
|
||||
HStack(spacing: 2) {
|
||||
Text(line.oldLineNumber.map { "\($0)" } ?? "")
|
||||
.font(.system(.caption2, design: .monospaced))
|
||||
|
|
@ -88,7 +90,7 @@ struct DiffView: View {
|
|||
|
||||
Spacer(minLength: 0)
|
||||
|
||||
if onLineTap != nil, line.type != .header, line.diffPosition != nil {
|
||||
if isCommentable {
|
||||
Image(systemName: "plus.bubble")
|
||||
.font(.caption2)
|
||||
.foregroundStyle(.tertiary)
|
||||
|
|
@ -100,10 +102,18 @@ struct DiffView: View {
|
|||
.padding(.vertical, 1)
|
||||
.background(line.type.backgroundColor)
|
||||
.contentShape(Rectangle())
|
||||
.onTapGesture {
|
||||
if line.type != .header, line.diffPosition != nil {
|
||||
|
||||
// A tappable line is a Button so VoiceOver announces it and can activate it.
|
||||
if isCommentable {
|
||||
Button {
|
||||
onLineTap?(line, filePath)
|
||||
} label: {
|
||||
row
|
||||
}
|
||||
.buttonStyle(.plain)
|
||||
.accessibilityHint("Add a comment on this line")
|
||||
} else {
|
||||
row
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue