package ui import ( "gioui.org/layout" "gioui.org/unit" "gioui.org/widget" "gioui.org/widget/material" "git.wxccs.org/iceking2nd/winauth-go/internal/i18n" ) // welcomeDialog is the first-run prompt. Triggered when the config // file does not exist. The user picks between enabling password // protection and skipping — both branches hand control back to the // caller via onDone. type welcomeDialog struct { enableBtn widget.Clickable skipBtn widget.Clickable } func newWelcomeDialog() *welcomeDialog { return &welcomeDialog{} } // welcomeResult is what onDone receives. encrypt=true means the user // picked "Enable password protection" and the caller should raise the // setPasswordDialog next. skip=true means the user dismissed the prompt // and we should start with an empty, unencrypted config. type welcomeResult struct { encrypt bool skip bool } func (d *welcomeDialog) Layout( gtx layout.Context, th *material.Theme, onDone func(welcomeResult), ) layout.Dimensions { if d.enableBtn.Clicked(gtx) { onDone(welcomeResult{encrypt: true}) return layout.Dimensions{Size: gtx.Constraints.Max} } if d.skipBtn.Clicked(gtx) { onDone(welcomeResult{skip: 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, i18n.T("msg_welcome_intro")).Layout), ) } // Custom footer: two side-by-side actions. Use the shared modalShell // to reuse the standard backdrop/title/inset; only the action row // differs from the OK/Cancel modalCard pattern. footer := func(gtx layout.Context) layout.Dimensions { return layout.Flex{Axis: layout.Horizontal, Spacing: layout.SpaceStart}.Layout(gtx, layout.Rigid(material.Button(th, &d.enableBtn, i18n.T("btn_welcome_enable_password")).Layout), layout.Rigid(func(gtx layout.Context) layout.Dimensions { return layout.Inset{Left: unit.Dp(8)}.Layout(gtx, material.Button(th, &d.skipBtn, i18n.T("btn_welcome_skip")).Layout) }), ) } return modalShell(gtx, th, i18n.T("dialog_welcome_title"), body, footer) }