mirror of
https://gitee.com/konyshe/goodlink.git
synced 2025-09-26 20:51:22 +08:00
u
This commit is contained in:
54
ui2/local_ui.go
Normal file
54
ui2/local_ui.go
Normal file
@@ -0,0 +1,54 @@
|
||||
package ui2
|
||||
|
||||
import (
|
||||
"fyne.io/fyne/v2"
|
||||
"fyne.io/fyne/v2/container"
|
||||
"fyne.io/fyne/v2/layout"
|
||||
"fyne.io/fyne/v2/widget"
|
||||
)
|
||||
|
||||
type LocalUI struct {
|
||||
local_ip string
|
||||
port_box *portEntry
|
||||
radio *widget.RadioGroup
|
||||
}
|
||||
|
||||
func (c *LocalUI) Disable() {
|
||||
c.port_box.Disable()
|
||||
c.radio.Disable()
|
||||
}
|
||||
|
||||
func (c *LocalUI) Enable() {
|
||||
c.port_box.Enable()
|
||||
c.radio.Enable()
|
||||
}
|
||||
|
||||
func (c *LocalUI) GetContainer() *fyne.Container {
|
||||
return container.NewVBox(
|
||||
container.New(layout.NewFormLayout(), widget.NewRichTextWithText("访问权限: "), c.radio),
|
||||
container.New(layout.NewFormLayout(), widget.NewRichTextWithText("监听端口: "), c.port_box),
|
||||
)
|
||||
}
|
||||
|
||||
func NewLocalUI(myWindow *fyne.Window) *LocalUI {
|
||||
c := &LocalUI{
|
||||
port_box: NewPortEntry(),
|
||||
radio: widget.NewRadioGroup([]string{"只允许本机", "允许局域网"}, nil),
|
||||
}
|
||||
|
||||
c.radio.OnChanged = func(value string) {
|
||||
switch value {
|
||||
case "只允许本机":
|
||||
c.local_ip = "127.0.0.1"
|
||||
case "允许局域网":
|
||||
c.local_ip = "0.0.0.0"
|
||||
default:
|
||||
c.radio.SetSelected("只允许本机")
|
||||
}
|
||||
(*myWindow).Resize((*myWindow).Content().MinSize())
|
||||
}
|
||||
c.radio.SetSelected("只允许本机")
|
||||
c.radio.Horizontal = true
|
||||
|
||||
return c
|
||||
}
|
Reference in New Issue
Block a user