-
Notifications
You must be signed in to change notification settings - Fork 0
/
header.go
82 lines (73 loc) · 1.88 KB
/
header.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
package header
import (
tea "github.com/charmbracelet/bubbletea"
"github.com/charmbracelet/lipgloss"
"github.com/deemkeen/stegodon/domain"
"github.com/deemkeen/stegodon/ui/common"
"github.com/deemkeen/stegodon/util"
)
type Model struct {
Width int
Acc *domain.Account
}
func (m Model) Init() tea.Cmd {
return nil
}
func (m Model) Update(tea.Msg) (Model, tea.Cmd) {
return m, nil
}
func (m Model) View() string {
return GetHeaderStyle(m.Acc, m.Width)
}
func GetHeaderStyle(acc *domain.Account, width int) string {
username := lipgloss.
NewStyle().
SetString(acc.Username).
Align(lipgloss.Left).
Background(lipgloss.Color(common.COLOR_PURPLE)).
Padding(1).
Height(2).
Width(width).
MaxWidth(15).
Border(lipgloss.NormalBorder(), true, false, true, false).
BorderForeground(lipgloss.Color(common.COLOR_MAGENTA)).
String()
at := lipgloss.
NewStyle().
SetString("@").
Background(lipgloss.NoColor{}).
Foreground(lipgloss.Color(common.COLOR_MAGENTA)).
Padding(1).
Height(2).
Border(lipgloss.NormalBorder(), true, false, true, false).
BorderForeground(lipgloss.Color(common.COLOR_MAGENTA)).
String()
created := lipgloss.
NewStyle().
SetString("registered: "+acc.CreatedAt.Format(util.DateTimeFormat())).
Background(lipgloss.Color(common.COLOR_MAGENTA)).
Padding(1).
Align(lipgloss.Left).
Height(2).
Width(width).
MaxWidth(75).
Border(lipgloss.NormalBorder(), true, false, true, false).
BorderForeground(lipgloss.Color(common.COLOR_MAGENTA)).
String()
return lipgloss.JoinHorizontal(
lipgloss.Center,
username,
at,
lipgloss.NewStyle().
SetString(util.GetNameAndVersion()).
Width(65).
MaxWidth(45).
Height(2).
Background(lipgloss.Color(common.COLOR_GREY)).
Padding(1).
Border(lipgloss.NormalBorder(), true, false, true, false).
BorderForeground(lipgloss.Color(common.COLOR_MAGENTA)).
String(),
created,
)
}