feat(ui): 条目管理增强 — 重命名/删除/重排序
每行右侧增加 ⋯ 按钮,弹出菜单支持重命名、删除、上移、下移。 - renameEntry / deleteEntry / moveEntry 三个 appState 方法 - rowActionMenu 弹出菜单 + renameDialog + confirmDeleteDialog - 删除自动注销快捷键,所有操作触发配置保存 - 保留顶栏 Add/Remove 全局按钮不变
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
package ui
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"gioui.org/layout"
|
||||
"gioui.org/widget"
|
||||
"gioui.org/widget/material"
|
||||
|
||||
"git.wxccs.org/iceking2nd/winauth-go/internal/i18n"
|
||||
)
|
||||
|
||||
type renameDialog struct {
|
||||
ed widget.Editor
|
||||
okBtn widget.Clickable
|
||||
cancel widget.Clickable
|
||||
errMsg string
|
||||
}
|
||||
|
||||
func newRenameDialog(currentName string) *renameDialog {
|
||||
d := &renameDialog{}
|
||||
d.ed.SingleLine = true
|
||||
d.ed.SetText(currentName)
|
||||
return d
|
||||
}
|
||||
|
||||
func (d *renameDialog) Layout(
|
||||
gtx layout.Context, th *material.Theme,
|
||||
onDone func(string, bool),
|
||||
) layout.Dimensions {
|
||||
if d.cancel.Clicked(gtx) {
|
||||
onDone("", true)
|
||||
return layout.Dimensions{Size: gtx.Constraints.Max}
|
||||
}
|
||||
if d.okBtn.Clicked(gtx) {
|
||||
name := strings.TrimSpace(d.ed.Text())
|
||||
if name == "" {
|
||||
d.errMsg = i18n.T("msg_empty_name")
|
||||
} else {
|
||||
onDone(name, false)
|
||||
return layout.Dimensions{Size: gtx.Constraints.Max}
|
||||
}
|
||||
}
|
||||
|
||||
body := func(gtx layout.Context) layout.Dimensions {
|
||||
return layout.Flex{Axis: layout.Vertical}.Layout(gtx,
|
||||
layout.Rigid(labeledEditor(th, i18n.T("label_entry_name"), &d.ed, "")),
|
||||
layout.Rigid(errorLabel(th, d.errMsg)),
|
||||
)
|
||||
}
|
||||
return modalCard(gtx, th, i18n.T("dialog_rename_title"),
|
||||
i18n.T("btn_ok"), i18n.T("btn_cancel"),
|
||||
&d.okBtn, &d.cancel, body)
|
||||
}
|
||||
Reference in New Issue
Block a user