Unify attention cards
This commit is contained in:
@@ -662,14 +662,14 @@ private struct LineCommentBox: View {
|
||||
let anchor: LineAnchor
|
||||
@Environment(Store.self) private var store
|
||||
@FocusState private var focused: Bool
|
||||
@ViewState private var text = ""
|
||||
|
||||
var body: some View {
|
||||
let text = Binding(get: { drafts.lineComment(taskId, anchor)?.text ?? "" }, set: { drafts.setLineComment(taskId, anchor, $0) })
|
||||
let key = lineCommentImageKey(taskId, anchor)
|
||||
VStack(alignment: .trailing, spacing: 4) {
|
||||
Thumbnails(key: key)
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
TextEditor(text: text)
|
||||
TextEditor(text: $text)
|
||||
.font(Fonts.font(12))
|
||||
.scrollContentBackground(.hidden)
|
||||
.writingToolsBehavior(.disabled)
|
||||
@@ -679,7 +679,7 @@ private struct LineCommentBox: View {
|
||||
.frame(height: 64)
|
||||
.background(Palette.surface, in: RoundedRectangle(cornerRadius: 6))
|
||||
.overlay(alignment: .topLeading) {
|
||||
if text.wrappedValue.isEmpty {
|
||||
if text.isEmpty {
|
||||
Text("Comment on line \(anchor.line)…")
|
||||
.foregroundStyle(Palette.muted)
|
||||
.padding(.horizontal, 10)
|
||||
@@ -696,9 +696,18 @@ private struct LineCommentBox: View {
|
||||
.buttonStyle(SmallLinkButtonStyle())
|
||||
}
|
||||
.onAppear {
|
||||
if text.wrappedValue.isEmpty {
|
||||
text = drafts.lineComment(taskId, anchor)?.text ?? ""
|
||||
if text.isEmpty {
|
||||
focused = true
|
||||
}
|
||||
}
|
||||
.onChange(of: text) {
|
||||
drafts.setLineComment(taskId, anchor, text)
|
||||
}
|
||||
.onChange(of: drafts.lineComment(taskId, anchor)?.text) { _, new in
|
||||
if let new, new != text {
|
||||
text = new
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user