split up settings if screen too small
parent
c5d8ba06ae
commit
b5f44bd6c9
|
@ -2,6 +2,7 @@ package app
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"math"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
|
@ -25,11 +26,11 @@ func (view *Settings) Event(state *ui.State, event vaxis.Event) (processed bool)
|
|||
view.index--
|
||||
}
|
||||
case "Down":
|
||||
if view.index < 3 {
|
||||
if view.index < 4 {
|
||||
view.index++
|
||||
}
|
||||
case "Enter":
|
||||
if view.index == 3 {
|
||||
if view.index == 4 {
|
||||
pronouns := strings.TrimSpace(view.inputs[0].String())
|
||||
birthday := strings.TrimSpace(view.inputs[1].String())
|
||||
timezone := strings.TrimSpace(view.inputs[2].String())
|
||||
|
@ -49,19 +50,19 @@ func (view *Settings) Event(state *ui.State, event vaxis.Event) (processed bool)
|
|||
|
||||
ui.ViewChange <- &Shell{}
|
||||
}
|
||||
if view.index < 3 {
|
||||
if view.index < 4 {
|
||||
view.index++
|
||||
}
|
||||
default:
|
||||
if view.index != 3 {
|
||||
view.inputs[view.index].Update(event)
|
||||
if view.index != 4 && view.index != 0 {
|
||||
view.inputs[view.index-1].Update(event)
|
||||
}
|
||||
}
|
||||
processed = true
|
||||
}
|
||||
|
||||
enterStyle := vaxis.AttributeMask(vaxis.AttrNone)
|
||||
if view.index == 3 {
|
||||
if view.index == 4 {
|
||||
enterStyle = vaxis.AttrReverse
|
||||
}
|
||||
|
||||
|
@ -101,13 +102,59 @@ it should look something like America/New_York.
|
|||
vaxis.Segment{Text: " press ↲ to continue ", Style: vaxis.Style{Attribute: enterStyle}},
|
||||
)
|
||||
|
||||
if q1+q2+q3 < win.Height {
|
||||
if view.index == 0 {
|
||||
view.index++
|
||||
}
|
||||
rows := [3]int{q1, q1 + q2, q1 + q2 + q3 - 2}
|
||||
for i, input := range view.inputs {
|
||||
input.Draw(vaxis.Window{win.Vx, &win, 5, rows[i], 74, 1})
|
||||
if i == view.index {
|
||||
input.Draw(vaxis.Window{win.Vx, &win, 5, rows[i], int(math.Min(73.0, float64(win.Width)-7)), 1})
|
||||
if i == view.index-1 {
|
||||
win.SetStyle(3, rows[i], vaxis.Style{Attribute: vaxis.AttrReverse})
|
||||
}
|
||||
}
|
||||
} else {
|
||||
win.Clear()
|
||||
switch view.index {
|
||||
case 0:
|
||||
win.Wrap(vaxis.Segment{Text: `──── initial settings ────
|
||||
|
||||
`, Style: vaxis.Style{Foreground: vaxis.IndexColor(5)}}, vaxis.Segment{Text: `let's get you set up with some useful settings. you can press ↑ or ↓ to move between the inputs. feel free to leave any of them empty! you can always set them later, or leave them unset.`})
|
||||
case 1:
|
||||
_, h := win.Wrap(vaxis.Segment{Text: `1. `}, vaxis.Segment{Text: "what are your pronouns?", Style: vaxis.Style{Foreground: vaxis.IndexColor(1)}}, vaxis.Segment{Text: ` this is useful information for folks to be able to refer to you in the third person. common pronoun sets are he/him, she/her, and they/them.
|
||||
|
||||
>`})
|
||||
view.inputs[0].Draw(vaxis.Window{win.Vx, &win, 5, h, int(math.Min(73.0, float64(win.Width)-7)), 1})
|
||||
win.SetStyle(3, h, vaxis.Style{Attribute: vaxis.AttrReverse})
|
||||
case 2:
|
||||
_, h := win.Wrap(vaxis.Segment{Text: `2. `}, vaxis.Segment{Text: "when's your birthday?", Style: vaxis.Style{Foreground: vaxis.IndexColor(1)}}, vaxis.Segment{Text: ` this will show up in certain places, so people can wish you a happy birthday :) format is MM/DD.
|
||||
|
||||
>`})
|
||||
view.inputs[1].Draw(vaxis.Window{win.Vx, &win, 5, h, int(math.Min(73.0, float64(win.Width)-7)), 1})
|
||||
win.SetStyle(3, h, vaxis.Style{Attribute: vaxis.AttrReverse})
|
||||
case 3:
|
||||
_, h := win.Wrap(vaxis.Segment{Text: `3. `}, vaxis.Segment{Text: "what's your timezone?", Style: vaxis.Style{Foreground: vaxis.IndexColor(1)}}, vaxis.Segment{Text: ` this will change all times you view in town to your local timezone, so you don't have to convert from utc in your head. the format for timezones can be found here:
|
||||
|
||||
`},
|
||||
vaxis.Segment{
|
||||
Text: "https://en.wikipedia.org/wiki/List_of_tz_database_time_zones#List",
|
||||
Style: vaxis.Style{
|
||||
Foreground: vaxis.IndexColor(4),
|
||||
UnderlineStyle: vaxis.UnderlineSingle,
|
||||
},
|
||||
},
|
||||
vaxis.Segment{Text: `
|
||||
|
||||
it should look something like America/New_York.
|
||||
|
||||
>`})
|
||||
view.inputs[2].Draw(vaxis.Window{win.Vx, &win, 5, h, int(math.Min(73.0, float64(win.Width)-7)), 1})
|
||||
win.SetStyle(3, h, vaxis.Style{Attribute: vaxis.AttrReverse})
|
||||
case 4:
|
||||
win.Wrap(vaxis.Segment{Text: " press ↲ to continue ", Style: vaxis.Style{Attribute: enterStyle}})
|
||||
}
|
||||
}
|
||||
|
||||
state.HideCursor()
|
||||
return
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue