mirror of
https://gitee.com/konyshe/goodlink.git
synced 2025-09-27 04:56:28 +08:00
UI基本成型
This commit is contained in:
@@ -67,6 +67,13 @@ func main() {
|
||||
keyValidated = widget.NewEntry()
|
||||
keyValidated.SetPlaceHolder("请自定义16-32长度字符串")
|
||||
|
||||
key_create_button := widget.NewButton("生成密钥", func() {
|
||||
})
|
||||
key_copy_button := widget.NewButton("复制密钥", func() {
|
||||
})
|
||||
key_paste_button := widget.NewButton("粘贴密钥", func() {
|
||||
})
|
||||
|
||||
localUI := ui2.NewLocalUI(&myWindow)
|
||||
localUI_Container := localUI.GetContainer()
|
||||
|
||||
@@ -93,28 +100,30 @@ func main() {
|
||||
log_view := widget.NewLabel("等待启动")
|
||||
LogInit(log_view)
|
||||
|
||||
a2 := widget.NewActivity()
|
||||
|
||||
ret := 0
|
||||
|
||||
start_button_stats := 0
|
||||
start_button_activity := widget.NewActivity()
|
||||
start_button := widget.NewButton("点击启动", func() {
|
||||
switch ret {
|
||||
switch start_button_stats {
|
||||
case 0:
|
||||
radio.Disable()
|
||||
keyValidated.Disable()
|
||||
localUI.Disable()
|
||||
a2.Start()
|
||||
a2.Show()
|
||||
key_create_button.Disable()
|
||||
key_paste_button.Disable()
|
||||
start_button_activity.Start()
|
||||
start_button_activity.Show()
|
||||
log_view.SetText("正在启动...")
|
||||
ret = 1
|
||||
start_button_stats = 1
|
||||
case 1:
|
||||
radio.Enable()
|
||||
keyValidated.Enable()
|
||||
localUI.Enable()
|
||||
a2.Stop()
|
||||
a2.Hide()
|
||||
key_create_button.Enable()
|
||||
key_paste_button.Enable()
|
||||
start_button_activity.Stop()
|
||||
start_button_activity.Hide()
|
||||
log_view.SetText("正在停止...")
|
||||
ret = 0
|
||||
start_button_stats = 0
|
||||
}
|
||||
myWindow.Resize(myWindow.Content().MinSize())
|
||||
})
|
||||
@@ -123,9 +132,10 @@ func main() {
|
||||
myWindow.SetContent(container.New(layout.NewVBoxLayout(),
|
||||
container.New(layout.NewFormLayout(), widget.NewRichTextWithText("选择工作端: "), radio),
|
||||
container.New(layout.NewFormLayout(), widget.NewRichTextWithText("连接密钥: "), keyValidated),
|
||||
container.NewGridWithColumns(3, key_create_button, key_copy_button, key_paste_button),
|
||||
localUI_Container, remoteUI_Container,
|
||||
container.New(layout.NewFormLayout(), widget.NewRichTextWithText("状态: "), log_view),
|
||||
container.NewStack(start_button, a2)))
|
||||
container.NewStack(start_button, start_button_activity)))
|
||||
|
||||
myWindow.SetCloseIntercept(func() {
|
||||
myWindow.Resize(myWindow.Content().MinSize())
|
||||
|
196
theme/icons.go
Normal file
196
theme/icons.go
Normal file
@@ -0,0 +1,196 @@
|
||||
package theme
|
||||
|
||||
import (
|
||||
"image/color"
|
||||
|
||||
"fyne.io/fyne/v2"
|
||||
"fyne.io/fyne/v2/canvas"
|
||||
"fyne.io/fyne/v2/container"
|
||||
"fyne.io/fyne/v2/theme"
|
||||
"fyne.io/fyne/v2/widget"
|
||||
)
|
||||
|
||||
type iconInfo struct {
|
||||
name string
|
||||
icon fyne.Resource
|
||||
}
|
||||
|
||||
type browser struct {
|
||||
current int
|
||||
icons []iconInfo
|
||||
|
||||
name *widget.Select
|
||||
icon *widget.Icon
|
||||
}
|
||||
|
||||
func (b *browser) setIcon(index int) {
|
||||
if index < 0 || index > len(b.icons)-1 {
|
||||
return
|
||||
}
|
||||
b.current = index
|
||||
|
||||
b.name.SetSelected(b.icons[index].name)
|
||||
b.icon.SetResource(b.icons[index].icon)
|
||||
}
|
||||
|
||||
// iconScreen loads a panel that shows the various icons available in Fyne
|
||||
func iconScreen(_ fyne.Window) fyne.CanvasObject {
|
||||
b := &browser{}
|
||||
b.icons = loadIcons()
|
||||
|
||||
prev := widget.NewButtonWithIcon("", theme.NavigateBackIcon(), func() {
|
||||
b.setIcon(b.current - 1)
|
||||
})
|
||||
next := widget.NewButtonWithIcon("", theme.NavigateNextIcon(), func() {
|
||||
b.setIcon(b.current + 1)
|
||||
})
|
||||
b.name = widget.NewSelect(iconList(b.icons), func(name string) {
|
||||
for i, icon := range b.icons {
|
||||
if icon.name == name {
|
||||
if b.current != i {
|
||||
b.setIcon(i)
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
})
|
||||
b.name.SetSelected(b.icons[b.current].name)
|
||||
buttons := container.NewHBox(prev, next)
|
||||
bar := container.NewBorder(nil, nil, buttons, nil, b.name)
|
||||
|
||||
background := canvas.NewRasterWithPixels(checkerPattern)
|
||||
background.SetMinSize(fyne.NewSize(280, 280))
|
||||
b.icon = widget.NewIcon(b.icons[b.current].icon)
|
||||
|
||||
return container.NewBorder(bar, nil, nil, nil, background, b.icon)
|
||||
}
|
||||
|
||||
func checkerPattern(x, y, _, _ int) color.Color {
|
||||
x /= 20
|
||||
y /= 20
|
||||
|
||||
if x%2 == y%2 {
|
||||
return theme.Color(theme.ColorNameBackground)
|
||||
}
|
||||
|
||||
return theme.Color(theme.ColorNameShadow)
|
||||
}
|
||||
|
||||
func iconList(icons []iconInfo) []string {
|
||||
ret := make([]string, len(icons))
|
||||
for i, icon := range icons {
|
||||
ret[i] = icon.name
|
||||
}
|
||||
|
||||
return ret
|
||||
}
|
||||
|
||||
func loadIcons() []iconInfo {
|
||||
return []iconInfo{
|
||||
{"CancelIcon", theme.CancelIcon()},
|
||||
{"ConfirmIcon", theme.ConfirmIcon()},
|
||||
{"DeleteIcon", theme.DeleteIcon()},
|
||||
{"SearchIcon", theme.SearchIcon()},
|
||||
{"SearchReplaceIcon", theme.SearchReplaceIcon()},
|
||||
|
||||
{"CheckButtonIcon", theme.CheckButtonIcon()},
|
||||
{"CheckButtonFillIcon", theme.CheckButtonFillIcon()},
|
||||
{"CheckButtonCheckedIcon", theme.CheckButtonCheckedIcon()},
|
||||
{"RadioButtonIcon", theme.RadioButtonIcon()},
|
||||
{"RadioButtonFillIcon", theme.RadioButtonFillIcon()},
|
||||
{"RadioButtonCheckedIcon", theme.RadioButtonCheckedIcon()},
|
||||
|
||||
{"ColorAchromaticIcon", theme.ColorAchromaticIcon()},
|
||||
{"ColorChromaticIcon", theme.ColorChromaticIcon()},
|
||||
{"ColorPaletteIcon", theme.ColorPaletteIcon()},
|
||||
|
||||
{"ContentAddIcon", theme.ContentAddIcon()},
|
||||
{"ContentRemoveIcon", theme.ContentRemoveIcon()},
|
||||
{"ContentClearIcon", theme.ContentClearIcon()},
|
||||
{"ContentCutIcon", theme.ContentCutIcon()},
|
||||
{"ContentCopyIcon", theme.ContentCopyIcon()},
|
||||
{"ContentPasteIcon", theme.ContentPasteIcon()},
|
||||
{"ContentRedoIcon", theme.ContentRedoIcon()},
|
||||
{"ContentUndoIcon", theme.ContentUndoIcon()},
|
||||
|
||||
{"InfoIcon", theme.InfoIcon()},
|
||||
{"ErrorIcon", theme.ErrorIcon()},
|
||||
{"QuestionIcon", theme.QuestionIcon()},
|
||||
{"WarningIcon", theme.WarningIcon()},
|
||||
{"BrokenImageIcon", theme.BrokenImageIcon()},
|
||||
|
||||
{"DocumentIcon", theme.DocumentIcon()},
|
||||
{"DocumentCreateIcon", theme.DocumentCreateIcon()},
|
||||
{"DocumentPrintIcon", theme.DocumentPrintIcon()},
|
||||
{"DocumentSaveIcon", theme.DocumentSaveIcon()},
|
||||
|
||||
{"FileIcon", theme.FileIcon()},
|
||||
{"FileApplicationIcon", theme.FileApplicationIcon()},
|
||||
{"FileAudioIcon", theme.FileAudioIcon()},
|
||||
{"FileImageIcon", theme.FileImageIcon()},
|
||||
{"FileTextIcon", theme.FileTextIcon()},
|
||||
{"FileVideoIcon", theme.FileVideoIcon()},
|
||||
{"FolderIcon", theme.FolderIcon()},
|
||||
{"FolderNewIcon", theme.FolderNewIcon()},
|
||||
{"FolderOpenIcon", theme.FolderOpenIcon()},
|
||||
{"ComputerIcon", theme.ComputerIcon()},
|
||||
{"HomeIcon", theme.HomeIcon()},
|
||||
{"HelpIcon", theme.HelpIcon()},
|
||||
{"HistoryIcon", theme.HistoryIcon()},
|
||||
{"SettingsIcon", theme.SettingsIcon()},
|
||||
{"StorageIcon", theme.StorageIcon()},
|
||||
{"DownloadIcon", theme.DownloadIcon()},
|
||||
{"UploadIcon", theme.UploadIcon()},
|
||||
|
||||
{"ViewFullScreenIcon", theme.ViewFullScreenIcon()},
|
||||
{"ViewRestoreIcon", theme.ViewRestoreIcon()},
|
||||
{"ViewRefreshIcon", theme.ViewRefreshIcon()},
|
||||
{"VisibilityIcon", theme.VisibilityIcon()},
|
||||
{"VisibilityOffIcon", theme.VisibilityOffIcon()},
|
||||
{"ViewZoomFitIcon", theme.ZoomFitIcon()},
|
||||
{"ViewZoomInIcon", theme.ZoomInIcon()},
|
||||
{"ViewZoomOutIcon", theme.ZoomOutIcon()},
|
||||
|
||||
{"MoreHorizontalIcon", theme.MoreHorizontalIcon()},
|
||||
{"MoreVerticalIcon", theme.MoreVerticalIcon()},
|
||||
|
||||
{"MoveDownIcon", theme.MoveDownIcon()},
|
||||
{"MoveUpIcon", theme.MoveUpIcon()},
|
||||
|
||||
{"NavigateBackIcon", theme.NavigateBackIcon()},
|
||||
{"NavigateNextIcon", theme.NavigateNextIcon()},
|
||||
|
||||
{"Menu", theme.MenuIcon()},
|
||||
{"MenuExpand", theme.MenuExpandIcon()},
|
||||
{"MenuDropDown", theme.MenuDropDownIcon()},
|
||||
{"MenuDropUp", theme.MenuDropUpIcon()},
|
||||
|
||||
{"MailAttachmentIcon", theme.MailAttachmentIcon()},
|
||||
{"MailComposeIcon", theme.MailComposeIcon()},
|
||||
{"MailForwardIcon", theme.MailForwardIcon()},
|
||||
{"MailReplyIcon", theme.MailReplyIcon()},
|
||||
{"MailReplyAllIcon", theme.MailReplyAllIcon()},
|
||||
{"MailSendIcon", theme.MailSendIcon()},
|
||||
|
||||
{"MediaFastForward", theme.MediaFastForwardIcon()},
|
||||
{"MediaFastRewind", theme.MediaFastRewindIcon()},
|
||||
{"MediaPause", theme.MediaPauseIcon()},
|
||||
{"MediaPlay", theme.MediaPlayIcon()},
|
||||
{"MediaStop", theme.MediaStopIcon()},
|
||||
{"MediaRecord", theme.MediaRecordIcon()},
|
||||
{"MediaReplay", theme.MediaReplayIcon()},
|
||||
{"MediaSkipNext", theme.MediaSkipNextIcon()},
|
||||
{"MediaSkipPrevious", theme.MediaSkipPreviousIcon()},
|
||||
|
||||
{"VolumeDown", theme.VolumeDownIcon()},
|
||||
{"VolumeMute", theme.VolumeMuteIcon()},
|
||||
{"VolumeUp", theme.VolumeUpIcon()},
|
||||
|
||||
{"AccountIcon", theme.AccountIcon()},
|
||||
{"LoginIcon", theme.LoginIcon()},
|
||||
{"LogoutIcon", theme.LogoutIcon()},
|
||||
|
||||
{"ListIcon", theme.ListIcon()},
|
||||
{"GridIcon", theme.GridIcon()},
|
||||
}
|
||||
}
|
@@ -17,7 +17,7 @@ func (n *portEntry) Keyboard() mobile.KeyboardType {
|
||||
}
|
||||
|
||||
func NewPortEntry() *portEntry {
|
||||
content := "请输入1024-65535范围的数字"
|
||||
content := "范围: 1024-65535"
|
||||
e := &portEntry{}
|
||||
e.ExtendBaseWidget(e)
|
||||
e.Validator = func(value string) error {
|
||||
|
Reference in New Issue
Block a user