Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
jvxis committed Aug 2, 2023
2 parents 4346714 + 52f89b8 commit e4864a6
Show file tree
Hide file tree
Showing 28 changed files with 1,099 additions and 208 deletions.
29 changes: 23 additions & 6 deletions app_instance/app_instance.go
Original file line number Diff line number Diff line change
@@ -1,18 +1,35 @@
package app_instance

import (
"image/color"

"gioui.org/app"
"gioui.org/unit"
"gioui.org/x/explorer"
expl "gioui.org/x/explorer"
"github.com/g45t345rt/g45w/router"
"github.com/g45t345rt/g45w/settings"
)

var Window *app.Window
var Router *router.Router
var Explorer *explorer.Explorer

const (
PAGE_SETTINGS = "page_settings"
PAGE_NODE = "page_node"
PAGE_WALLET = "page_wallet"
PAGE_WALLET_SELECT = "page_wallet_select"
)
func Load() {
minSizeX := unit.Dp(375)
minSizeY := unit.Dp(600)
maxSizeX := unit.Dp(500)
maxSizeY := unit.Dp(1000)

Window = app.NewWindow(
app.Title(settings.Name),
app.MinSize(minSizeX, minSizeY),
app.Size(minSizeX, minSizeY),
app.MaxSize(maxSizeX, maxSizeY),
app.PortraitOrientation.Option(),
app.NavigationColor(color.NRGBA{A: 0}),
)

Explorer = expl.NewExplorer(Window)
Router = router.NewRouter()
}
75 changes: 47 additions & 28 deletions components/input.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,10 @@ type Input struct {
Inset layout.Inset
Clickable *widget.Clickable

submitted bool
submitText string
activeSubmit bool
keyboardClick *widget.Clickable
submitted bool
submitText string
activeSubmit bool
}

func NewInput() *Input {
Expand All @@ -41,16 +42,24 @@ func NewInput() *Input {
}

return &Input{
Editor: editor,
Border: border,
Clickable: new(widget.Clickable),
Editor: editor,
Border: border,
Clickable: new(widget.Clickable),
keyboardClick: new(widget.Clickable),
Inset: layout.Inset{
Top: unit.Dp(15), Bottom: unit.Dp(15),
Left: unit.Dp(12), Right: unit.Dp(12),
},
}
}

func NewNumberInput() *Input {
input := NewInput()
input.Editor.Filter = "0123456789."
input.Editor.InputHint = key.HintNumeric
return input
}

func NewPasswordInput() *Input {
editor := new(widget.Editor)
editor.SingleLine = true
Expand All @@ -64,9 +73,10 @@ func NewPasswordInput() *Input {
}

return &Input{
Editor: editor,
Border: border,
Clickable: new(widget.Clickable),
Editor: editor,
Border: border,
Clickable: new(widget.Clickable),
keyboardClick: new(widget.Clickable),
Inset: layout.Inset{
Top: unit.Dp(15), Bottom: unit.Dp(15),
Left: unit.Dp(12), Right: unit.Dp(12),
Expand Down Expand Up @@ -106,28 +116,37 @@ func (t *Input) Layout(gtx layout.Context, th *material.Theme, hint string) layo

gtx.Constraints.Min.Y = t.EditorMinY

if t.keyboardClick.Clicked() {
// on mobile if the keyboard popups and the input lose focus it will automatically close the keyboard
// so we have to manually force keyboard request to avoid this issue
key.SoftKeyboardOp{Show: true}.Add(gtx.Ops)
}

return t.Clickable.Layout(gtx, func(gtx layout.Context) layout.Dimensions {
return t.Border.Layout(gtx, func(gtx layout.Context) layout.Dimensions {
macro := op.Record(gtx.Ops)
dims := t.Inset.Layout(gtx, func(gtx layout.Context) layout.Dimensions {
editorStyle := material.Editor(th, t.Editor, hint)
if t.TextSize != 0 {
editorStyle.TextSize = t.TextSize
}
if t.FontWeight != font.Normal {
editorStyle.Font.Weight = t.FontWeight
}
return editorStyle.Layout(gtx)
return t.keyboardClick.Layout(gtx, func(gtx layout.Context) layout.Dimensions {
return t.Border.Layout(gtx, func(gtx layout.Context) layout.Dimensions {
macro := op.Record(gtx.Ops)
dims := t.Inset.Layout(gtx, func(gtx layout.Context) layout.Dimensions {
editorStyle := material.Editor(th, t.Editor, hint)
if t.TextSize != 0 {
editorStyle.TextSize = t.TextSize
}
if t.FontWeight != font.Normal {
editorStyle.Font.Weight = t.FontWeight
}
return editorStyle.Layout(gtx)
})
call := macro.Stop()

paint.FillShape(gtx.Ops, color.NRGBA{R: 255, G: 255, B: 255, A: 255}, clip.UniformRRect(
image.Rectangle{Max: dims.Size},
int(t.Border.CornerRadius),
).Op(gtx.Ops))

call.Add(gtx.Ops)
return dims
})
call := macro.Stop()

paint.FillShape(gtx.Ops, color.NRGBA{R: 255, G: 255, B: 255, A: 255}, clip.UniformRRect(
image.Rectangle{Max: dims.Size},
int(t.Border.CornerRadius),
).Op(gtx.Ops))

call.Add(gtx.Ops)
return dims
})
})
}
7 changes: 7 additions & 0 deletions components/textfield.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@ func NewTextField() *TextField {
}
}

func NewNumberTextField() *TextField {
input := NewNumberInput()
return &TextField{
Input: input,
}
}

func NewPasswordTextField() *TextField {
input := NewPasswordInput()

Expand Down
13 changes: 7 additions & 6 deletions containers/bottom_bar/bottom_bar.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"github.com/g45t345rt/g45w/components"
"github.com/g45t345rt/g45w/containers/recent_txs_modal"
"github.com/g45t345rt/g45w/lang"
"github.com/g45t345rt/g45w/pages"
"github.com/g45t345rt/g45w/router"
"github.com/g45t345rt/g45w/wallet_manager"
"golang.org/x/exp/shiny/materialdesign/icons"
Expand Down Expand Up @@ -153,24 +154,24 @@ func (b *BottomBar) Layout(gtx layout.Context, th *material.Theme) layout.Dimens
}

if b.confirmClose.ClickedYes() {
b.appRouter.SetCurrent(app_instance.PAGE_WALLET_SELECT)
b.appRouter.SetCurrent(pages.PAGE_WALLET_SELECT)
wallet_manager.CloseOpenedWallet()
}

if b.ButtonNode.Button.Clicked() {
b.appRouter.SetCurrent(app_instance.PAGE_NODE)
b.appRouter.SetCurrent(pages.PAGE_NODE)
}

if b.ButtonWallet.Button.Clicked() {
if b.appRouter.Current == app_instance.PAGE_WALLET {
b.appRouter.SetCurrent(app_instance.PAGE_WALLET_SELECT)
if b.appRouter.Current == pages.PAGE_WALLET {
b.appRouter.SetCurrent(pages.PAGE_WALLET_SELECT)
} else {
b.appRouter.SetCurrent(app_instance.PAGE_WALLET)
b.appRouter.SetCurrent(pages.PAGE_WALLET)
}
}

if b.ButtonSettings.Button.Clicked() {
b.appRouter.SetCurrent(app_instance.PAGE_SETTINGS)
b.appRouter.SetCurrent(pages.PAGE_SETTINGS)
}

if b.ButtonTxs.Button.Clicked() {
Expand Down
17 changes: 17 additions & 0 deletions containers/containers.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package containers

import (
"github.com/g45t345rt/g45w/containers/bottom_bar"
"github.com/g45t345rt/g45w/containers/build_tx_modal.go"
"github.com/g45t345rt/g45w/containers/node_status_bar"
"github.com/g45t345rt/g45w/containers/notification_modals"
"github.com/g45t345rt/g45w/containers/recent_txs_modal"
)

func Load() {
bottom_bar.LoadInstance()
node_status_bar.LoadInstance()
notification_modals.LoadInstance()
recent_txs_modal.LoadInstance()
build_tx_modal.LoadInstance()
}
3 changes: 2 additions & 1 deletion containers/node_status_bar/node_status_bar.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
"github.com/g45t345rt/g45w/integrated_node"
"github.com/g45t345rt/g45w/lang"
"github.com/g45t345rt/g45w/node_manager"
"github.com/g45t345rt/g45w/pages"
page_node "github.com/g45t345rt/g45w/pages/node"
"github.com/g45t345rt/g45w/wallet_manager"
)
Expand Down Expand Up @@ -109,7 +110,7 @@ func (n *NodeStatusBar) Layout(gtx layout.Context, th *material.Theme) layout.Di
}

if n.clickable.Clicked() {
app_instance.Router.SetCurrent(app_instance.PAGE_NODE)
app_instance.Router.SetCurrent(pages.PAGE_NODE)
op.InvalidateOp{}.Add(gtx.Ops)
}

Expand Down
Loading

0 comments on commit e4864a6

Please sign in to comment.