很久没发博客了,现在在这里说明一下私信的问题,我已经很久没做任何js逆向了,想好好学一下别的东西,所以统一回复一下各位,别再问我Akamai和别的事情了,我实在不知道怎么回复,在这里对一些没给答复的兄弟道个歉。
这篇是一篇关于gio的学习记录,gio的学习对我来说无疑是困难的,没有QT那种拖拉组件的功能,只能通过不断地看一些源码和example来进行了解,当然啊,我觉得难不排除是因为我经验不足学习能力弱的原因。
研究了好些日子,虽然中间因为摆烂和学车断断续续地,但是也成功自己写出了第一个我想要的login in的页面,相关联的组件暂时还没有赋予一些功能,就单单一个button就困扰了我老久,不知道为什么我的就是没有点击的效果,不过现在我已经解决了,是因为变量局部有效性的问题,经过不断修改测试,实际上只需要挂一个全局变量就行了,下面放一下简易版的页面图和代码。
package main
import (
"gioui.org/app"
"gioui.org/font/gofont"
"gioui.org/io/system"
"gioui.org/layout"
"gioui.org/op"
"gioui.org/unit"
"gioui.org/widget"
"gioui.org/widget/material"
"image/color"
"log"
"os"
)
func main() {
go func() {
w := app.NewWindow(
app.Title("Login_in"),
app.Size(unit.Dp(400),unit.Dp(200)))
if err := loop(w); err != nil{
log.Println(err)
os.Exit(1)
}
os.Exit(0)
}()
app.Main()
}
func loop(w *app.Window) error{
th := material.NewTheme(gofont.Collection())
var ops op.Ops
for{
select {
case e:= <-w.Events():
switch e := e.(type) {
case system.DestroyEvent:
return e.Err
case system.FrameEvent:
gtx := layout.NewContext(&ops, e)
LoginWindow(gtx, th)
e.Frame(gtx.Ops)
}
}
}
return nil
}
type Information struct {
AccountNum Feild
Passport Feild
}
type Feild struct {
widget.Editor
}
var(
postBtn = new(widget.Clickable)
editor = new(widget.Editor)
list = &widget.List{
List: layout.List{
Axis: layout.Vertical,
},
}
info = Information{}
)
func LoginWindow(gtx layout.Context, th *material.Theme) layout.Dimensions {
spacer := layout.Rigid(layout.Spacer{Width: unit.Dp(10)}.Layout)
widgets := []layout.Widget{
func(gtx layout.Context) layout.Dimensions {
return layout.Flex{}.Layout(gtx,
layout.Rigid(material.Body1(th, "Account:").Layout),
spacer,
layout.Flexed(1, func(gtx layout.Context) layout.Dimensions {
return info.AccountNum.Layout(th, gtx)
}))
},
func(gtx layout.Context) layout.Dimensions {
return layout.Flex{}.Layout(gtx,
layout.Rigid(material.Body1(th, "Passport:").Layout),
spacer,
layout.Flexed(1, func(gtx layout.Context) layout.Dimensions {
return info.Passport.Layout(th, gtx)
}))
},
func(gtx layout.Context) layout.Dimensions {
return layout.Flex{}.Layout(gtx,
layout.Rigid(func(gtx layout.Context) layout.Dimensions {
dp := unit.Dp
margins := layout.Inset{
Left: dp(150),
}
return margins.Layout(gtx, func(gtx layout.Context) layout.Dimensions {
btn := material.Button(th, postBtn, "Post")
return btn.Layout(gtx)
})
}),
)
},
}
return material.List(th, list).Layout(gtx, len(widgets), func(gtx layout.Context, index int) layout.Dimensions {
return layout.UniformInset(unit.Dp(16)).Layout(gtx, widgets[index])
})
}
func (ed *Feild) Layout(th *material.Theme, gtx layout.Context) layout.Dimensions{
borderWidth := float32(0.5)
borderColor := color.NRGBA{A: 107}
switch {
case ed.Editor.Focused():
borderColor = th.Palette.ContrastBg
borderWidth = 2
}
return widget.Border{
Color: borderColor,
CornerRadius: unit.Dp(4),
Width: unit.Dp(borderWidth),
}.Layout(gtx, func(gtx layout.Context) layout.Dimensions {
return layout.UniformInset(unit.Dp(4)).Layout(gtx, material.Editor(th, &ed.Editor, "").Layout)
})
}
注释我就没写了,简单的记录一下子。