-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathviews.go
92 lines (75 loc) · 2.4 KB
/
views.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
83
84
85
86
87
88
89
90
91
92
package main
import (
"fmt"
"github.com/charmbracelet/lipgloss"
)
func GenerateEntryView(m *Model) string {
centerText := lipgloss.JoinVertical(
lipgloss.Center,
"Hey There!",
"This is Ritu's Termfolio",
"A Terminal based Portfolio over SSH !!",
)
centerText = EntryTextStyle.Render(centerText)
blinkText := EntryBlinkStyle.Width(m.Window.Width).Render("Press Enter to continue...")
centerDisplay := lipgloss.
NewStyle().
Width(m.Window.Width).
Height(m.Window.Height).
AlignHorizontal(lipgloss.Center).
AlignVertical(lipgloss.Center)
render := lipgloss.JoinVertical(lipgloss.Center, centerText, blinkText)
if m.EntryView.showLoader {
render = lipgloss.JoinVertical(lipgloss.Center, centerText, m.EntryView.progress.View())
}
return centerDisplay.Render(render)
}
func GenerateHomeView(m *Model) string {
leftContainer := GetHomeScreenLeftContainerStyle(m)
rightContainer := GetHomeScreenRightContainerStyle(m)
if m.HomeView.pane == LeftPane {
leftContainer = leftContainer.BorderForeground(lipgloss.Color("#FF00FF"))
rightContainer = rightContainer.BorderForeground(lipgloss.Color("#404040"))
} else {
leftContainer = leftContainer.BorderForeground(lipgloss.Color("#404040"))
rightContainer = rightContainer.BorderForeground(lipgloss.Color("#FF00FF"))
}
leftContainerContents := ""
for i, item := range m.HomeView.LeftPane.items {
menuStyle := lipgloss.
NewStyle()
cursor := " "
if i == m.HomeView.LeftPane.cursor {
cursor = ">"
menuStyle = menuStyle.
Bold(true).
Foreground(lipgloss.Color("#FF00FF")).
Background(lipgloss.Color("#060606")).
Width(m.Window.Width/4 - 2)
}
leftContainerContents += menuStyle.Render(fmt.Sprintf("\n%s %s\n", cursor, item))
}
rightContainerContents := GenerateTabView(m)
row1 := lipgloss.NewStyle().Faint(true).Render(" ↑/k: Move Up \t|\tTab/Enter: Switch Panes\t")
row2 := lipgloss.NewStyle().Faint(true).Render(" ↓/j: Move down\t|\tEsc : Back to Left Pane\t")
helpText := lipgloss.JoinVertical(
lipgloss.Left,
row1,
row2,
)
return lipgloss.JoinVertical(
lipgloss.Left,
lipgloss.JoinHorizontal(
lipgloss.Left,
HomeScreenName.Render("Rituparna Warwatkar"),
" ",
HomeScreenHref.Render("https://rituparnawarwatkar.com"),
),
lipgloss.JoinHorizontal(
lipgloss.Center,
leftContainer.Render(leftContainerContents),
rightContainer.Render(rightContainerContents),
),
helpText,
)
}