Files
cloudsave/cmd/gui/window/credential/credential.go
Aurélie DELHAIE b36142c309
Some checks failed
CloudSave/pipeline/head There was a failure building this commit
wip
2025-09-12 19:06:52 +02:00

54 lines
1.1 KiB
Go

package credential
import (
"image/color"
"fyne.io/fyne/v2"
"fyne.io/fyne/v2/canvas"
"fyne.io/fyne/v2/dialog"
"fyne.io/fyne/v2/widget"
)
type (
CredentialDialog struct {
*dialog.FormDialog
inputUsername *widget.Entry
inputPassword *widget.Entry
}
)
func Make(remoteHostname string, callback func(ok bool, username, password string), w fyne.Window) *CredentialDialog {
label := canvas.NewText(remoteHostname, color.Black)
inputUsername := widget.NewEntry()
inputUsername.SetPlaceHolder("Username")
inputPassword := widget.NewEntry()
inputPassword.Password = true
inputPassword.SetPlaceHolder("Password")
formItems := []*widget.FormItem{
{
Text: "Connexion to ",
Widget: label,
},
{
Text: "Username",
Widget: inputUsername,
},
{
Text: "Password",
Widget: inputPassword,
},
}
d := &CredentialDialog{
inputUsername: inputUsername,
inputPassword: inputPassword,
}
d.FormDialog = dialog.NewForm("Syncing", "Connexion", "Cancel", formItems, func(b bool) {
callback(b, d.inputUsername.Text, d.inputPassword.Text)
}, w)
return d
}