-
Notifications
You must be signed in to change notification settings - Fork 5
/
cover.go
62 lines (54 loc) · 1.99 KB
/
cover.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
package main
import (
"fmt"
"strings"
"github.com/gdamore/tcell/v2"
"github.com/rivo/tview"
)
const logo = `
________ ________ ________ _______ ________ ________ ___ ___
|\ ____\|\ __ \|\ _____\\ ___ \ |\ __ \|\ __ \ |\ \ / /|
\ \ \___|\ \ \|\ \ \ \__/\ \ __/|\ \ \|\ /\ \ \|\ \ \ \ \/ / /
\ \_____ \ \ __ \ \ __\\ \ \_|/_\ \ __ \ \ \\\ \ \ \ / /
\|____|\ \ \ \ \ \ \ \_| \ \ \_|\ \ \ \|\ \ \ \\\ \ / \/
____\_\ \ \__\ \__\ \__\ \ \_______\ \_______\ \_______\/ /\ \
|\_________\|__|\|__|\|__| \|_______|\|_______|\|_______/__/ /\ __\
\|_________| |__|/ \|__|
`
const (
subtitle = `[::]:: An unified key management system ::`
navigation = `[::bl]Press any key to continue...[-:-:-]`
author = `[::]https://github.com/xtaci/safebox[-:-:-]`
)
// coverPage returns the coverPage page.
func coverPage() *tview.Flex {
// What's the size of the logo?
lines := strings.Split(logo, "\n")
logoWidth := 0
logoHeight := len(lines)
for _, line := range lines {
if len(line) > logoWidth {
logoWidth = len(line)
}
}
logoBox := tview.NewTextView().
SetTextColor(tcell.ColorDarkCyan)
fmt.Fprint(logoBox, logo)
// Create a frame for the subtitle and navigation infos.
frame := tview.NewFrame(tview.NewBox()).
SetBorders(0, 0, 0, 0, 0, 0).
AddText(subtitle, true, tview.AlignCenter, tcell.ColorDarkOrange).
AddText("", true, tview.AlignCenter, tcell.ColorGold).
AddText(author, true, tview.AlignCenter, tcell.ColorLightGray).
AddText(navigation, true, tview.AlignCenter, tcell.ColorWhite)
// Create a Flex layout that centers the logo and subtitle.
flex := tview.NewFlex().
SetDirection(tview.FlexRow).
AddItem(tview.NewBox(), 0, 7, false).
AddItem(tview.NewFlex().
AddItem(tview.NewBox(), 0, 1, false).
AddItem(logoBox, logoWidth, 1, true).
AddItem(tview.NewBox(), 0, 1, false), logoHeight, 1, true).
AddItem(frame, 0, 10, false)
return flex
}