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) }