-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
66 lines (59 loc) · 1.29 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package main
import (
"gioui.org/unit"
"gioui.org/widget"
"gioui.org/widget/material"
"log"
"os"
"gioui.org/app"
"gioui.org/font/gofont"
"gioui.org/io/system"
"gioui.org/layout"
"gioui.org/op"
)
func main() {
go func() {
w := app.NewWindow(app.Title("Qiscord"))
err := run(w)
if err != nil {
log.Fatal(err)
}
os.Exit(0)
}()
app.Main()
}
func run(w *app.Window) error {
th := material.NewTheme(gofont.Collection())
flex := &layout.Flex{}
flex.Alignment = layout.Middle
flex.Axis = layout.Vertical
flex.Spacing = layout.SpaceAround
l := &widget.Editor{SingleLine: true}
lw := material.Editor(th, l, "Guild Id")
b := &widget.Clickable{}
bw := material.Button(th, b, "Start")
margin := &layout.Inset{
Top: unit.Dp(25),
Bottom: unit.Dp(25),
Left: unit.Dp(25),
Right: unit.Dp(25),
}
var ops op.Ops
for {
e := <-w.Events()
switch e := e.(type) {
case system.DestroyEvent:
return e.Err
case system.FrameEvent:
gtx := layout.NewContext(&ops, e)
flex.Layout(gtx, layout.Rigid(func(gtx layout.Context) layout.Dimensions {
return lw.Layout(gtx)
}), layout.Rigid(func(gtx layout.Context) layout.Dimensions {
return margin.Layout(gtx, func(gtx layout.Context) layout.Dimensions {
return bw.Layout(gtx)
})
}))
e.Frame(gtx.Ops)
}
}
}