add(project): initial commit
This commit is contained in:
parent
f34565bf49
commit
cf17a4ec59
11 changed files with 628 additions and 0 deletions
63
internal/ui/home.go
Normal file
63
internal/ui/home.go
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
package ui
|
||||
|
||||
import (
|
||||
"gioui.org/layout"
|
||||
"gioui.org/widget"
|
||||
"gioui.org/widget/material"
|
||||
)
|
||||
|
||||
type HomePage struct {
|
||||
searchButton *widget.Clickable
|
||||
searchField *widget.Editor
|
||||
theme *material.Theme
|
||||
}
|
||||
|
||||
func NewHomePage(theme *material.Theme) *HomePage {
|
||||
return &HomePage{
|
||||
searchButton: &widget.Clickable{},
|
||||
theme: theme,
|
||||
searchField: &widget.Editor{SingleLine: true},
|
||||
}
|
||||
}
|
||||
|
||||
func searchClicked(searchField *widget.Editor) {
|
||||
query := searchField.Text()
|
||||
searchField.SetText("")
|
||||
println("Search query:", query)
|
||||
}
|
||||
|
||||
func (h *HomePage) Layout(gtx layout.Context) layout.Dimensions {
|
||||
return layout.UniformInset(16).Layout(gtx, func(gtx layout.Context) layout.Dimensions {
|
||||
return layout.Flex{
|
||||
Axis: layout.Vertical,
|
||||
}.Layout(gtx,
|
||||
layout.Rigid(func(gtx layout.Context) layout.Dimensions {
|
||||
return layout.Center.Layout(gtx, func(gtx layout.Context) layout.Dimensions {
|
||||
return layout.Flex{
|
||||
Axis: layout.Vertical,
|
||||
}.Layout(gtx,
|
||||
layout.Rigid(func(gtx layout.Context) layout.Dimensions {
|
||||
return layout.Flex{
|
||||
Axis: layout.Horizontal,
|
||||
}.Layout(gtx,
|
||||
layout.Flexed(0.5, func(gtx layout.Context) layout.Dimensions {
|
||||
return material.Editor(h.theme, h.searchField, "Search...").Layout(gtx)
|
||||
}),
|
||||
layout.Rigid(func(gtx layout.Context) layout.Dimensions {
|
||||
if h.searchButton.Clicked(gtx) {
|
||||
searchClicked(h.searchField)
|
||||
}
|
||||
return material.Button(h.theme, h.searchButton, "Search").Layout(gtx)
|
||||
}),
|
||||
)
|
||||
}),
|
||||
)
|
||||
})
|
||||
}),
|
||||
layout.Rigid(func(gtx layout.Context) layout.Dimensions {
|
||||
|
||||
return layout.Dimensions{}
|
||||
}),
|
||||
)
|
||||
})
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue