Compare commits
2 Commits
0adaf9e90c
...
8f1eacab87
Author | SHA1 | Date | |
---|---|---|---|
|
8f1eacab87 | ||
|
92b6d030a6 |
@ -11,9 +11,7 @@ import (
|
|||||||
"git.tilde.town/nbsp/welcome/ui"
|
"git.tilde.town/nbsp/welcome/ui"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Editor struct {
|
type Editor struct{}
|
||||||
loaded bool
|
|
||||||
}
|
|
||||||
|
|
||||||
func (view *Editor) Draw(state *ui.State) {
|
func (view *Editor) Draw(state *ui.State) {
|
||||||
win := state.Window()
|
win := state.Window()
|
||||||
@ -55,11 +53,6 @@ like before, when you're done, type `},
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (view *Editor) Event(state *ui.State, event vaxis.Event) (processed bool) {
|
func (view *Editor) Event(state *ui.State, event vaxis.Event) (processed bool) {
|
||||||
if view.loaded {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
view.loaded = true
|
|
||||||
|
|
||||||
win := state.Window().New(0, 16, 80, 80)
|
win := state.Window().New(0, 16, 80, 80)
|
||||||
view.Draw(state)
|
view.Draw(state)
|
||||||
|
|
||||||
|
@ -1,10 +1,6 @@
|
|||||||
package app
|
package app
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
"strings"
|
|
||||||
|
|
||||||
"git.sr.ht/~rockorager/vaxis"
|
"git.sr.ht/~rockorager/vaxis"
|
||||||
"git.sr.ht/~rockorager/vaxis/widgets/textinput"
|
"git.sr.ht/~rockorager/vaxis/widgets/textinput"
|
||||||
"git.tilde.town/nbsp/welcome/ui"
|
"git.tilde.town/nbsp/welcome/ui"
|
||||||
@ -30,23 +26,7 @@ func (view *Settings) Event(state *ui.State, event vaxis.Event) (processed bool)
|
|||||||
}
|
}
|
||||||
case "Enter":
|
case "Enter":
|
||||||
if view.index == 3 {
|
if view.index == 3 {
|
||||||
pronouns := strings.TrimSpace(view.inputs[0].String())
|
// TODO: save settings
|
||||||
birthday := strings.TrimSpace(view.inputs[1].String())
|
|
||||||
timezone := strings.TrimSpace(view.inputs[2].String())
|
|
||||||
|
|
||||||
// XXX: this assumes nothing will break
|
|
||||||
if pronouns != "" {
|
|
||||||
os.WriteFile(".pronouns", []byte(pronouns), 0644)
|
|
||||||
}
|
|
||||||
if birthday != "" {
|
|
||||||
os.WriteFile(".birthday", []byte(pronouns), 0644)
|
|
||||||
}
|
|
||||||
if timezone != "" {
|
|
||||||
f, _ := os.OpenFile(".bashrc", os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)
|
|
||||||
f.Write([]byte(fmt.Sprintf("export TZ='%s'\n", timezone)))
|
|
||||||
f.Close()
|
|
||||||
}
|
|
||||||
|
|
||||||
ui.ViewChange <- &Shell{}
|
ui.ViewChange <- &Shell{}
|
||||||
}
|
}
|
||||||
if view.index < 3 {
|
if view.index < 3 {
|
||||||
|
@ -9,9 +9,7 @@ import (
|
|||||||
"git.tilde.town/nbsp/welcome/ui"
|
"git.tilde.town/nbsp/welcome/ui"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Shell struct {
|
type Shell struct{}
|
||||||
loaded bool
|
|
||||||
}
|
|
||||||
|
|
||||||
func (view *Shell) Draw(state *ui.State) {
|
func (view *Shell) Draw(state *ui.State) {
|
||||||
win := state.Window()
|
win := state.Window()
|
||||||
@ -46,11 +44,6 @@ you're ready.`},
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (view *Shell) Event(state *ui.State, event vaxis.Event) (processed bool) {
|
func (view *Shell) Event(state *ui.State, event vaxis.Event) (processed bool) {
|
||||||
if view.loaded {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
view.loaded = true
|
|
||||||
|
|
||||||
win := state.Window().New(0, 16, 80, 80)
|
win := state.Window().New(0, 16, 80, 80)
|
||||||
view.Draw(state)
|
view.Draw(state)
|
||||||
|
|
||||||
|
2
ui/ui.go
2
ui/ui.go
@ -15,7 +15,7 @@ type View interface {
|
|||||||
|
|
||||||
var Events = make(chan vaxis.Event)
|
var Events = make(chan vaxis.Event)
|
||||||
var Quit = make(chan struct{})
|
var Quit = make(chan struct{})
|
||||||
var ViewChange = make(chan View, 1)
|
var ViewChange = make(chan View, 10)
|
||||||
|
|
||||||
type State struct {
|
type State struct {
|
||||||
content View
|
content View
|
||||||
|
Loading…
x
Reference in New Issue
Block a user