refactor(tracker/gioui): give Editor Text / SetText methods

This commit is contained in:
5684185+vsariola@users.noreply.github.com
2024-10-14 23:36:32 +03:00
parent 03c994e4da
commit 2b7ce39069
3 changed files with 40 additions and 40 deletions

View File

@ -141,11 +141,6 @@ func (pe *UnitEditor) layoutFooter(gtx C, t *Tracker) D {
text = pe.caser.String(text)
}
hintText := Label(text, white, t.Theme.Shaper)
commentStyle := MaterialEditor(t.Theme, pe.commentEditor, "---")
commentStyle.Font = labelDefaultFont
commentStyle.TextSize = labelDefaultFontSize
commentStyle.Color = mediumEmphasisTextColor
commentStyle.HintColor = mediumEmphasisTextColor
return layout.Flex{Axis: layout.Horizontal, Alignment: layout.Middle}.Layout(gtx,
layout.Rigid(deleteUnitBtnStyle.Layout),
layout.Rigid(copyUnitBtnStyle.Layout),
@ -164,14 +159,17 @@ func (pe *UnitEditor) layoutFooter(gtx C, t *Tracker) D {
}),
layout.Flexed(1, func(gtx C) D {
s := t.UnitComment().String()
if commentStyle.Editor.Text() != s.Value() {
commentStyle.Editor.SetText(s.Value())
}
pe.commentEditor.SetText(s.Value())
for pe.commentEditor.Submitted(gtx) || pe.commentEditor.Cancelled(gtx) {
t.InstrumentEditor.Focus()
}
commentStyle := MaterialEditor(t.Theme, pe.commentEditor, "---")
commentStyle.Font = labelDefaultFont
commentStyle.TextSize = labelDefaultFontSize
commentStyle.Color = mediumEmphasisTextColor
commentStyle.HintColor = mediumEmphasisTextColor
ret := commentStyle.Layout(gtx)
s.Set(commentStyle.Editor.Text())
s.Set(pe.commentEditor.Text())
return ret
}),
)