make it possible to switch between panels

This commit is contained in:
2021-07-04 14:49:36 -04:00
parent a6f958ccfb
commit 3bff06aad7
2 changed files with 64 additions and 14 deletions

View File

@@ -3,6 +3,7 @@ package ui
import (
"strings"
"git.yetaga.in/alazyreader/library/book"
"github.com/gdamore/tcell"
)
@@ -266,6 +267,32 @@ func (l *List) ListMembers() []string {
return l.listItems
}
// A List is a scrollable, pageable list with a selector token.
type BookDetails struct {
x, y int
h, w int
selected int
book book.Book
}
func NewBookDetails() *BookDetails {
return &BookDetails{}
}
func (l *BookDetails) SetSize(x, y, h, w int) {
l.x, l.y, l.h, l.w = x, y, h, w
}
func (l *BookDetails) Draw(s tcell.Screen) {
items := []string{"title", "authors", "isbn-10", "isbn-13"}
for i := range items {
for j, r := range items[i] {
s.SetContent(l.x+j, l.y+i, r, nil, tcell.StyleDefault)
}
s.SetContent(l.x+len(items[i]), l.y+i, ':', nil, tcell.StyleDefault)
}
}
// PaddedText outputs strings with a space on both sides.
// Useful for generating headings, footers, etc. Used by Box.
type PaddedText struct {