-
Notifications
You must be signed in to change notification settings - Fork 0
/
book.go
64 lines (57 loc) · 1.39 KB
/
book.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package main
import (
"fmt"
libgen "github.com/irth/golibgen"
ui "github.com/irth/regenesis/pkg/simple"
)
type BookScreen struct {
r *Regenesis
Book libgen.Book
}
func NewBookScreen(r *Regenesis, b libgen.Book) ui.Scene {
return &BookScreen{r, b}
}
func (b *BookScreen) Render() (ui.Widget, error) {
return ui.WidgetList{
Header(),
ui.FontSize(64),
ui.Label(
ui.Pos(ui.Abs(100), ui.Abs(300), ui.Percent(100), ui.Abs(100)),
"Book details",
),
ui.FontSize(48),
ui.Label(
ui.Pos(ui.Abs(150), ui.Abs(430), ui.Abs(0), ui.Abs(0)),
b.Book.Title(),
),
ui.FontSize(32),
ui.Label(
ui.Pos(ui.Abs(150), ui.Abs(480), ui.Abs(0), ui.Abs(0)),
b.Book.Author(),
),
ui.Label(
ui.Pos(ui.Abs(150), ui.Abs(550), ui.Abs(0), ui.Abs(0)),
fmt.Sprintf("%s, %s / %s", b.Book.Language(), b.Book.Size(), b.Book.Format()),
),
ui.FontSize(64),
ui.Button(
"download",
ui.Pos(ui.Abs(150), ui.Abs(630), ui.Abs(325), ui.Abs(75)),
"[download]",
nil, // TODO: actually download
),
ui.FontSize(38),
ui.TextInput(
"location",
ui.Pos(ui.Abs(150), ui.Abs(730), ui.Abs(b.r.app.ScreenWidth()-2*150), ui.Abs(50)),
b.r.BookLocation,
b.updateLocation,
),
BackButton(b.r),
}, nil
}
func (b *BookScreen) updateLocation(a *ui.App, t *ui.TextInputWidget, newValue string) error {
b.r.BookLocation = newValue
// TODO: store this somewhere permanently
return nil
}