feat(ui): 条目管理增强 — 重命名/删除/重排序
每行右侧增加 ⋯ 按钮,弹出菜单支持重命名、删除、上移、下移。 - renameEntry / deleteEntry / moveEntry 三个 appState 方法 - rowActionMenu 弹出菜单 + renameDialog + confirmDeleteDialog - 删除自动注销快捷键,所有操作触发配置保存 - 保留顶栏 Add/Remove 全局按钮不变
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
package ui
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"gioui.org/layout"
|
||||
"gioui.org/widget"
|
||||
"gioui.org/widget/material"
|
||||
|
||||
"git.wxccs.org/iceking2nd/winauth-go/internal/i18n"
|
||||
)
|
||||
|
||||
// confirmDeleteDialog asks the user to confirm deletion of a specific
|
||||
// entry. The dialog displays the target name verbatim in the prompt so
|
||||
// the user can sanity-check what they are about to lose.
|
||||
type confirmDeleteDialog struct {
|
||||
name string
|
||||
okBtn widget.Clickable
|
||||
cancelBtn widget.Clickable
|
||||
}
|
||||
|
||||
func newConfirmDeleteDialog(name string) *confirmDeleteDialog {
|
||||
return &confirmDeleteDialog{name: name}
|
||||
}
|
||||
|
||||
func (d *confirmDeleteDialog) Layout(
|
||||
gtx layout.Context, th *material.Theme,
|
||||
onDone func(confirmed bool),
|
||||
) layout.Dimensions {
|
||||
if d.cancelBtn.Clicked(gtx) {
|
||||
onDone(false)
|
||||
return layout.Dimensions{Size: gtx.Constraints.Max}
|
||||
}
|
||||
if d.okBtn.Clicked(gtx) {
|
||||
onDone(true)
|
||||
return layout.Dimensions{Size: gtx.Constraints.Max}
|
||||
}
|
||||
|
||||
body := func(gtx layout.Context) layout.Dimensions {
|
||||
return layout.Flex{Axis: layout.Vertical}.Layout(gtx,
|
||||
layout.Rigid(material.Body1(th,
|
||||
fmt.Sprintf(i18n.T("msg_confirm_delete"), d.name)).Layout),
|
||||
)
|
||||
}
|
||||
return modalCard(gtx, th, i18n.T("dialog_confirm_delete_title"),
|
||||
i18n.T("btn_delete"), i18n.T("btn_cancel"),
|
||||
&d.okBtn, &d.cancelBtn, body)
|
||||
}
|
||||
Reference in New Issue
Block a user