Add code to apply the wifi config in the main ui

This commit is contained in:
KemoNine 2020-09-01 20:11:27 -04:00
parent 48d757a6b6
commit e3008a6d43

View file

@ -13,6 +13,8 @@ import (
"github.com/gdamore/tcell" "github.com/gdamore/tcell"
"github.com/guillermo/go.procmeminfo" "github.com/guillermo/go.procmeminfo"
"github.com/rivo/tview" "github.com/rivo/tview"
"git.kemonine.info/PiFrame/wifi"
) )
const ( const (
@ -130,9 +132,19 @@ func main() {
// WiFi Config Form // WiFi Config Form
wifiConfigForm := tview.NewForm() wifiConfigForm := tview.NewForm()
wifiConfigForm.AddInputField("Access Point", "", 0, nil, nil) wifiConfigAccessPoint := ""
wifiConfigForm.AddPasswordField("Password", "", 0, '*', nil) wifiConfigPassword := ""
wifiConfigForm.AddButton("Apply", nil) wifiConfigForm.AddInputField("Access Point", "", 0, nil, func(value string) {
wifiConfigAccessPoint = value
})
wifiConfigForm.AddPasswordField("Password", "", 0, '*', func(value string) {
wifiConfigPassword = value
})
wifiConfigForm.AddButton("Apply", func() {
// Cleanup old wifi configs and apply new one
nmWifi := wifi.New(wifiConfigAccessPoint, wifiConfigPassword)
nmWifi.ApplyConfig()
})
wifiConfigForm.AddButton("Cancel", func() { wifiConfigForm.AddButton("Cancel", func() {
main.Clear() main.Clear()
app.SetFocus(menu) app.SetFocus(menu)