diff --git a/pkg/posts/news.go b/pkg/posts/news.go index 4fd7e82..d996415 100644 --- a/pkg/posts/news.go +++ b/pkg/posts/news.go @@ -34,10 +34,11 @@ func GetNews() { } list := tview.NewList() + list.Box.SetBorder(true) + app := tview.NewApplication() for ind, post := range posts.Posts { - list = list.AddItem(post.Title, post.Brief, rune(strconv.Itoa(ind)[0]), nil) } @@ -53,7 +54,7 @@ func GetNews() { app.Stop() panic(err) } - + list.Box.Blur() openPost(app, posts.Posts[n].Cuid, list) } diff --git a/pkg/posts/post.go b/pkg/posts/post.go index 6109988..0e8da9f 100644 --- a/pkg/posts/post.go +++ b/pkg/posts/post.go @@ -28,20 +28,22 @@ func openPost(app *tview.Application, postcuid string, list *tview.List) { textView.SetBorder(true) go func() { - if err := app.SetRoot(textView, true).SetFocus(textView).Run(); err != nil { + }() + + modal := tview.NewModal().SetText("Loading....") + go func() { + if err := app.SetRoot(modal, false).SetFocus(modal).Run(); err != nil { app.Stop() panic(err) } }() var singlePost Post - textView.Write([]byte("[:green:l]Loading....[-:-:-]")) b, err := makeRequest(fmt.Sprintf("%s/%s", postAPI, postcuid)) if err != nil { app.Stop() log.Fatal(err) } - textView.Clear() err = json.Unmarshal(b, &singlePost) if err != nil { @@ -101,7 +103,6 @@ func openPost(app *tview.Application, postcuid string, list *tview.List) { } } - textView.ScrollToBeginning() textView.SetDoneFunc(func(key tcell.Key) { if key == tcell.KeyEscape { @@ -112,6 +113,11 @@ func openPost(app *tview.Application, postcuid string, list *tview.List) { } }) + if err := app.SetRoot(textView, true).SetFocus(textView).Run(); err != nil { + app.Stop() + panic(err) + } + } func writeToTextView(t *tview.TextView, contents ...string) {