diff --git a/hamy-vpn-client-updated.exe b/hamy-vpn-client-updated.exe new file mode 100644 index 0000000..4bcb37e Binary files /dev/null and b/hamy-vpn-client-updated.exe differ diff --git a/main.go b/main.go index 6bcd651..6dc16df 100644 --- a/main.go +++ b/main.go @@ -227,11 +227,11 @@ func main() { var scrollContainer *container.Scroll var refreshList func() - // Entry for importing new configuration + // Entry for importing new configuration - fixed to expand properly importEntry := widget.NewEntry() importEntry.PlaceHolder = "vless://..." - // Import button - define after all necessary variables + // Container for import field and button - use HBox to allow proper expansion importButton := widget.NewButtonWithIcon("", theme.ContentAddIcon(), func() { url := importEntry.Text if url != "" && isValidVLESS(url) { @@ -240,17 +240,16 @@ func main() { dialog.ShowInformation("Успешно", "Конфиг добавлен", configWindow) // Refresh the list - if listContainer != nil { - refreshList() - } + refreshList() importEntry.SetText("") } else if url != "" { dialog.ShowError(errors.New("Невалидная ссылка"), configWindow) } }) + // Fixed the order of operations to avoid nil reference refreshList = func() { - // Need to recreate the list since we can't refresh it directly + // Create the list first newListContainer := widget.NewList( func() int { return len(configs) @@ -303,13 +302,13 @@ func main() { } // Allow clicking on the whole row to select the config - box.Objects[0] = container.NewStack( - widget.NewButton("", func() { - activeConfig = id - dialog.ShowInformation("Config Selected", fmt.Sprintf("Active config: %s", configs[id].Title), configWindow) - configWindow.Close() - }), - ) + selectButton := widget.NewButton("", func() { + activeConfig = id + dialog.ShowInformation("Config Selected", fmt.Sprintf("Active config: %s", configs[id].Title), configWindow) + configWindow.Close() + }) + selectButton.Hidden = true + box.Objects[0] = container.NewStack(selectButton) }, ) @@ -319,18 +318,24 @@ func main() { configWindow.Close() } - // Replace the list container content - scrollContainer.Content = newListContainer - scrollContainer.Refresh() + // Assign to the variable before using it in the scroll container listContainer = newListContainer + + // Create scroll container only once + if scrollContainer == nil { + scrollContainer = container.NewScroll(listContainer) + } else { + scrollContainer.Content = listContainer + scrollContainer.Refresh() + } } + // Call refreshList to initialize the list first refreshList() - scrollContainer = container.NewScroll(listContainer) - // Container for import field and button - use HBox to allow proper expansion - importContainer := container.NewHBox(importEntry, importButton) + // Using container.NewBorder to make the entry expand properly + importContainer := container.NewBorder(nil, nil, nil, importButton, importEntry) // Main content for the config window configContent := container.NewVBox(