diff --git a/hamy-vpn-client.exe b/hamy-vpn-client.exe new file mode 100644 index 0000000..ab4fb78 Binary files /dev/null and b/hamy-vpn-client.exe differ diff --git a/main.go b/main.go index 7ec7bf8..6bcd651 100644 --- a/main.go +++ b/main.go @@ -222,11 +222,16 @@ func main() { configWindow.Resize(fyne.NewSize(400, 300)) configWindow.SetFixedSize(true) + // Declare variables before use + var listContainer *widget.List + var scrollContainer *container.Scroll + var refreshList func() + // Entry for importing new configuration importEntry := widget.NewEntry() importEntry.PlaceHolder = "vless://..." - // Import button + // Import button - define after all necessary variables importButton := widget.NewButtonWithIcon("", theme.ContentAddIcon(), func() { url := importEntry.Text if url != "" && isValidVLESS(url) { @@ -244,15 +249,9 @@ func main() { } }) - // Container for import field and button - importContainer := container.NewBorder(nil, nil, importEntry, importButton) - - // Create a list of config titles for selection - var listContainer *widget.List - - refreshList := func() { + refreshList = func() { // Need to recreate the list since we can't refresh it directly - listContainer = widget.NewList( + newListContainer := widget.NewList( func() int { return len(configs) }, @@ -314,16 +313,24 @@ func main() { }, ) - listContainer.OnSelected = func(id widget.ListItemID) { + newListContainer.OnSelected = func(id widget.ListItemID) { activeConfig = id dialog.ShowInformation("Config Selected", fmt.Sprintf("Active config: %s", configs[id].Title), configWindow) configWindow.Close() } + + // Replace the list container content + scrollContainer.Content = newListContainer + scrollContainer.Refresh() + listContainer = newListContainer } refreshList() - scrollContainer := container.NewScroll(listContainer) + scrollContainer = container.NewScroll(listContainer) + + // Container for import field and button - use HBox to allow proper expansion + importContainer := container.NewHBox(importEntry, importButton) // Main content for the config window configContent := container.NewVBox(