table-select: have got a basic loading indicator built

This commit is contained in:
Leon Mika 2022-03-27 22:43:36 +11:00
parent 5d213c4ee8
commit 8b743351dd
3 changed files with 50 additions and 17 deletions

View file

@ -24,6 +24,7 @@ import (
"github.com/lmika/gopkgs/cli"
"log"
"os"
"time"
)
func main() {
@ -135,9 +136,18 @@ func newTestModel(descr string) tea.Model {
OnKeyPressed: func(k string) tea.Cmd {
log.Println("got key press: " + k)
if k == "enter" {
return tableselect.ShowTableSelect(func(n string) tea.Cmd {
return statusandprompt.SetStatus("New table = " + n)
})
return tea.Batch(
tableselect.IndicateLoadingTables(),
tea.Sequentially(
func() tea.Msg {
<-time.After(2 * time.Second)
return nil
},
tableselect.ShowTableSelect(func(n string) tea.Cmd {
return statusandprompt.SetStatus("New table = " + n)
}),
),
)
} else if k == "k" {
return modal.PopMode
}