feat: implemented all features besides wireguard

This commit is contained in:
jb
2026-03-11 11:01:35 -03:00
parent 6870144f39
commit 085cda7251
11 changed files with 539 additions and 73 deletions
+10 -9
View File
@@ -18,12 +18,13 @@ const (
)
type FormField struct {
Id string
Label string
Placeholder string
Default string
Type FieldType
Options []string // for FieldTypeSelect
optionIdx int // for FieldTypeSelect
OptionIdx int // for FieldTypeSelect
CharLimit int
input textinput.Model
}
@@ -41,7 +42,7 @@ func NewFormStep(title string, fields []FormField) FormStep {
for j, opt := range f.Fields[i].Options {
// Apply default option
if opt == f.Fields[i].Default {
f.Fields[i].optionIdx = j
f.Fields[i].OptionIdx = j
break
}
}
@@ -81,13 +82,13 @@ func (f *FormStep) Update(msg tea.Msg) (done bool, cmd tea.Cmd) {
switch msg.String() {
// Select specific inputs
case "left", "h":
if isSelect && focused.optionIdx > 0 {
focused.optionIdx--
if isSelect && focused.OptionIdx > 0 {
focused.OptionIdx--
}
case "right", "l":
if isSelect && focused.optionIdx < len(focused.Options)-1 {
focused.optionIdx++
if isSelect && focused.OptionIdx < len(focused.Options)-1 {
focused.OptionIdx++
}
// Generic inputs
@@ -120,9 +121,9 @@ func (f *FormStep) Values() map[string]string {
out := make(map[string]string)
for _, field := range f.Fields {
if field.Type == FieldTypeSelect {
out[field.Label] = field.Options[field.optionIdx]
out[field.Id] = field.Options[field.OptionIdx]
} else {
out[field.Label] = field.input.Value()
out[field.Id] = field.input.Value()
}
}
return out
@@ -155,7 +156,7 @@ func renderField(field FormField, focused bool) string {
case FieldTypeSelect:
var opts []string
for i, opt := range field.Options {
if i == field.optionIdx {
if i == field.OptionIdx {
opts = append(opts, SelectedStyle.Render("[ "+opt+" ]"))
} else {
opts = append(opts, DimStyle.Render(" "+opt+" "))