diff --git a/containers/confirm_modal/confirm_modal.go b/containers/confirm_modal/confirm_modal.go index 035866b..38e861e 100644 --- a/containers/confirm_modal/confirm_modal.go +++ b/containers/confirm_modal/confirm_modal.go @@ -93,17 +93,21 @@ func (c *ConfirmModal) Open(confirmText ConfirmText) chan bool { return c.resChan } -func (c *ConfirmModal) Layout(gtx layout.Context, th *material.Theme) layout.Dimensions { - if c.buttonYes.Clicked(gtx) { - c.resChan <- true +func (c *ConfirmModal) Close(yes bool) { + if c.Modal.Visible { + c.resChan <- yes c.Modal.SetVisible(false) close(c.resChan) } +} + +func (c *ConfirmModal) Layout(gtx layout.Context, th *material.Theme) layout.Dimensions { + if c.buttonYes.Clicked(gtx) { + c.Close(true) + } if c.buttonNo.Clicked(gtx) { - c.resChan <- false - c.Modal.SetVisible(false) - close(c.resChan) + c.Close(false) } var lblSize layout.Dimensions diff --git a/pages/wallet/page.go b/pages/wallet/page.go index f973867..29555fb 100644 --- a/pages/wallet/page.go +++ b/pages/wallet/page.go @@ -1,7 +1,6 @@ package page_wallet import ( - "fmt" "image" "image/color" "strings" @@ -320,25 +319,31 @@ func (p *Page) OpenXSWD() error { Prompt: prompt, }) + go func() { + <-appData.OnClose + confirm_modal.Instance.Close(false) + }() + w.Invalidate() yes := <-yesChan - go func() { - time.Sleep(100 * time.Millisecond) + + time.AfterFunc(500*time.Millisecond, func() { page_instance.pageXSWDManage.Load() - w.Invalidate() - }() + }) return yes } reqHandler := func(appData *xswd.ApplicationData, req *jrpc2.Request) (xswd.Permission, interface{}, error) { - fmt.Println(req.Method(), req.ParamString()) + // fmt.Println(req.Method(), req.ParamString()) + txt := lang.Translate("An app is requesting access for {}.") txt = strings.Replace(txt, "{}", req.Method(), -1) - notify.Push("XSWD", txt) switch req.Method() { case "transfer": + notify.Push("XSWD", txt) // notify only for transfer or sc_invoke + var params rpc.Transfer_Params err := req.UnmarshalParams(¶ms) if err != nil { @@ -362,6 +367,8 @@ func (p *Page) OpenXSWD() error { res := <-transferResponse return xswd.Allow, res.Result, res.Err case "sc_invoke": + notify.Push("XSWD", txt) + var params rpc.SC_Invoke_Params err := req.UnmarshalParams(¶ms) if err != nil { diff --git a/pages/wallet/xswd_manage.go b/pages/wallet/xswd_manage.go index 8a59092..c77771e 100644 --- a/pages/wallet/xswd_manage.go +++ b/pages/wallet/xswd_manage.go @@ -13,6 +13,7 @@ import ( "gioui.org/widget" "gioui.org/widget/material" "github.com/deroproject/derohe/walletapi/xswd" + "github.com/g45t345rt/g45w/app_instance" "github.com/g45t345rt/g45w/components" "github.com/g45t345rt/g45w/containers/notification_modal" "github.com/g45t345rt/g45w/lang" @@ -120,6 +121,8 @@ func (p *PageXSWDManage) Load() { p.apps = append(p.apps, NewDAppItem(app)) } } + + app_instance.Window.Invalidate() } func (p *PageXSWDManage) Leave() {