352b1d24b8
每行右侧增加 ⋯ 按钮,弹出菜单支持重命名、删除、上移、下移。 - renameEntry / deleteEntry / moveEntry 三个 appState 方法 - rowActionMenu 弹出菜单 + renameDialog + confirmDeleteDialog - 删除自动注销快捷键,所有操作触发配置保存 - 保留顶栏 Add/Remove 全局按钮不变
49 lines
1.2 KiB
Go
49 lines
1.2 KiB
Go
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)
|
|
}
|