mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-01 07:35:40 +00:00
apps: update gio version
Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
+1
-1
@@ -3,7 +3,7 @@ module gioui.org/apps
|
||||
go 1.13
|
||||
|
||||
require (
|
||||
gioui.org v0.0.0-20191005092226-b4a52d301013
|
||||
gioui.org v0.0.0-20191005202732-2097c6475da9
|
||||
github.com/google/go-github/v24 v24.0.1
|
||||
golang.org/x/exp v0.0.0-20190627132806-fd42eb6b336f
|
||||
golang.org/x/image v0.0.0-20190703141733-d6a02ce849c9
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
|
||||
gioui.org v0.0.0-20191005092226-b4a52d301013 h1:G4Mf6/6BEmE2j6poDpANVdWZ5+JM3wzgR55OqvVIo7k=
|
||||
gioui.org v0.0.0-20191005092226-b4a52d301013/go.mod h1:+CEjc9B//HrBfWsQOVxjCyih7HGIj3Pww1xFHVDZyyk=
|
||||
gioui.org v0.0.0-20191005202732-2097c6475da9 h1:ussyIS8IC0ekvvIdaltbV1MsHfCCDt4W5HICqRNEQvk=
|
||||
gioui.org v0.0.0-20191005202732-2097c6475da9/go.mod h1:+CEjc9B//HrBfWsQOVxjCyih7HGIj3Pww1xFHVDZyyk=
|
||||
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
|
||||
github.com/golang/protobuf v1.2.0 h1:P3YflyNX/ehuJFLhxviNdFxQPkGK5cDcApsge1SqnvM=
|
||||
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
|
||||
+26
-15
@@ -42,7 +42,8 @@ import (
|
||||
)
|
||||
|
||||
type UI struct {
|
||||
faces shape.Faces
|
||||
family *shape.Family
|
||||
mono *shape.Family
|
||||
fab *ActionButton
|
||||
usersList *layout.List
|
||||
users []*user
|
||||
@@ -58,7 +59,7 @@ type UI struct {
|
||||
}
|
||||
|
||||
type userPage struct {
|
||||
faces shape.Faces
|
||||
family *shape.Family
|
||||
user *user
|
||||
commitsList *layout.List
|
||||
commits []*github.Commit
|
||||
@@ -123,6 +124,14 @@ func init() {
|
||||
func newUI(fetchCommits func(string)) *UI {
|
||||
u := &UI{
|
||||
fetchCommits: fetchCommits,
|
||||
family: &shape.Family{
|
||||
Regular: fonts.regular,
|
||||
Italic: fonts.italic,
|
||||
Bold: fonts.bold,
|
||||
},
|
||||
mono: &shape.Family{
|
||||
Regular: fonts.mono,
|
||||
},
|
||||
}
|
||||
u.usersList = &layout.List{
|
||||
Axis: layout.Vertical,
|
||||
@@ -132,7 +141,10 @@ func newUI(fetchCommits func(string)) *UI {
|
||||
icons: []*icon{},
|
||||
}
|
||||
u.edit2 = &text.Editor{
|
||||
Face: u.faces.For(fonts.italic),
|
||||
Family: u.family,
|
||||
Face: text.Face{
|
||||
Style: text.Italic,
|
||||
},
|
||||
Size: unit.Sp(14),
|
||||
//Alignment: text.End,
|
||||
SingleLine: true,
|
||||
@@ -142,7 +154,7 @@ func newUI(fetchCommits func(string)) *UI {
|
||||
}
|
||||
u.edit2.SetText("Single line editor. Edit me!")
|
||||
u.edit = &text.Editor{
|
||||
Face: u.faces.For(fonts.regular),
|
||||
Family: u.family,
|
||||
Size: unit.Sp(16),
|
||||
Material: theme.text,
|
||||
//Alignment: text.End,
|
||||
@@ -185,13 +197,12 @@ func (u *UI) layoutTimings(gtx *layout.Context) {
|
||||
layout.Align(layout.NE).Layout(gtx, func() {
|
||||
layout.Inset{Top: unit.Dp(16)}.Layout(gtx, func() {
|
||||
txt := fmt.Sprintf("m: %d %s", mallocs, u.profile.Timings)
|
||||
text.Label{Material: theme.text, Face: u.faces.For(fonts.mono), Size: unit.Sp(10), Text: txt}.Layout(gtx)
|
||||
text.Label{Material: theme.text, Size: unit.Sp(10), Text: txt}.Layout(gtx, u.mono)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
func (u *UI) Layout(gtx *layout.Context) {
|
||||
u.faces.Reset()
|
||||
for i := range u.userClicks {
|
||||
click := &u.userClicks[i]
|
||||
for _, e := range click.Events(gtx) {
|
||||
@@ -210,7 +221,7 @@ func (u *UI) Layout(gtx *layout.Context) {
|
||||
|
||||
func (u *UI) newUserPage(user *user) *userPage {
|
||||
up := &userPage{
|
||||
faces: u.faces,
|
||||
family: u.family,
|
||||
user: user,
|
||||
commitsList: &layout.List{Axis: layout.Vertical},
|
||||
}
|
||||
@@ -231,7 +242,7 @@ func (up *userPage) Layout(gtx *layout.Context) {
|
||||
func (up *userPage) commit(gtx *layout.Context, index int) {
|
||||
u := up.user
|
||||
msg := up.commits[index].GetMessage()
|
||||
label := text.Label{Material: theme.text, Face: up.faces.For(fonts.regular), Size: unit.Sp(12), Text: msg}
|
||||
label := text.Label{Material: theme.text, Size: unit.Sp(12), Text: msg}
|
||||
in := layout.Inset{Top: unit.Dp(16), Right: unit.Dp(8), Left: unit.Dp(8)}
|
||||
in.Layout(gtx, func() {
|
||||
f := (&layout.Flex{Axis: layout.Horizontal}).Init(gtx)
|
||||
@@ -246,7 +257,7 @@ func (up *userPage) commit(gtx *layout.Context, index int) {
|
||||
c2 := f.Flexible(1, func() {
|
||||
gtx.Constraints.Width.Min = gtx.Constraints.Width.Max
|
||||
layout.Inset{Left: unit.Dp(8)}.Layout(gtx, func() {
|
||||
label.Layout(gtx)
|
||||
label.Layout(gtx, up.family)
|
||||
})
|
||||
})
|
||||
f.Layout(c1, c2)
|
||||
@@ -293,8 +304,8 @@ func (u *UI) layoutUsers(gtx *layout.Context) {
|
||||
grey := colorMaterial(gtx.Ops, rgb(0x888888))
|
||||
in := layout.Inset{Top: unit.Dp(16), Right: unit.Dp(8), Bottom: unit.Dp(8), Left: unit.Dp(8)}
|
||||
in.Layout(gtx, func() {
|
||||
lbl := text.Label{Material: grey, Face: u.faces.For(fonts.regular), Size: unit.Sp(11), Text: "GOPHERS"}
|
||||
lbl.Layout(gtx)
|
||||
lbl := text.Label{Material: grey, Size: unit.Sp(11), Text: "GOPHERS"}
|
||||
lbl.Layout(gtx, u.family)
|
||||
})
|
||||
})
|
||||
c1 := s.Expand(func() {
|
||||
@@ -360,14 +371,14 @@ func (u *UI) user(gtx *layout.Context, index int) {
|
||||
f := baseline()
|
||||
f.Init(gtx)
|
||||
c1 := f.Rigid(func() {
|
||||
text.Label{Material: theme.text, Face: u.faces.For(fonts.regular), Size: unit.Sp(13), Text: user.name}.Layout(gtx)
|
||||
text.Label{Material: theme.text, Size: unit.Sp(13), Text: user.name}.Layout(gtx, u.family)
|
||||
})
|
||||
c2 := f.Flexible(1, func() {
|
||||
gtx.Constraints.Width.Min = gtx.Constraints.Width.Max
|
||||
layout.Align(layout.E).Layout(gtx, func() {
|
||||
layout.Inset{Left: unit.Dp(2)}.Layout(gtx, func() {
|
||||
lbl := text.Label{Material: theme.text, Face: u.faces.For(fonts.regular), Size: unit.Sp(10), Text: "3 hours ago"}
|
||||
lbl.Layout(gtx)
|
||||
lbl := text.Label{Material: theme.text, Size: unit.Sp(10), Text: "3 hours ago"}
|
||||
lbl.Layout(gtx, u.family)
|
||||
})
|
||||
})
|
||||
})
|
||||
@@ -376,7 +387,7 @@ func (u *UI) user(gtx *layout.Context, index int) {
|
||||
c2 := f.Rigid(func() {
|
||||
in := layout.Inset{Top: unit.Dp(4)}
|
||||
in.Layout(gtx, func() {
|
||||
text.Label{Material: theme.tertText, Face: u.faces.For(fonts.regular), Size: unit.Sp(12), Text: user.company}.Layout(gtx)
|
||||
text.Label{Material: theme.tertText, Size: unit.Sp(12), Text: user.company}.Layout(gtx, u.family)
|
||||
})
|
||||
})
|
||||
f.Layout(c1, c2)
|
||||
|
||||
+4
-4
@@ -35,9 +35,10 @@ func loop(w *app.Window) error {
|
||||
if err != nil {
|
||||
panic("failed to load font")
|
||||
}
|
||||
var faces shape.Faces
|
||||
family := &shape.Family{
|
||||
Regular: regular,
|
||||
}
|
||||
maroon := color.RGBA{127, 0, 0, 255}
|
||||
face := faces.For(regular)
|
||||
message := "Hello, Gio"
|
||||
gtx := &layout.Context{
|
||||
Queue: w.Queue(),
|
||||
@@ -49,12 +50,11 @@ func loop(w *app.Window) error {
|
||||
return e.Err
|
||||
case app.UpdateEvent:
|
||||
gtx.Reset(&e.Config, e.Size)
|
||||
faces.Reset()
|
||||
var material op.MacroOp
|
||||
material.Record(gtx.Ops)
|
||||
paint.ColorOp{Color: maroon}.Add(gtx.Ops)
|
||||
material.Stop()
|
||||
text.Label{Material: material, Face: face, Size: unit.Sp(72), Alignment: text.Middle, Text: message}.Layout(gtx)
|
||||
text.Label{Material: material, Size: unit.Sp(72), Alignment: text.Middle, Text: message}.Layout(gtx, family)
|
||||
w.Update(gtx.Ops)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user