-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinitial_model.go
More file actions
101 lines (90 loc) · 3.44 KB
/
initial_model.go
File metadata and controls
101 lines (90 loc) · 3.44 KB
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
93
94
95
96
97
98
99
100
101
package main
import (
"github.com/charmbracelet/bubbles/table"
"github.com/charmbracelet/bubbles/textinput"
"github.com/charmbracelet/lipgloss"
)
func initialModel() model {
// models means objects made from structs
columns := []table.Column{
{Title: "No", Width: 5},
{Title: "Service", Width: 12},
{Title: "Username", Width: 20},
{Title: "Password", Width: 16}, // Its perfect dont change
}
columns2 := []table.Column{
{Title: "ID", Width: 5},
{Title: "Service", Width: 10},
}
rows := []table.Row{}
// table styles
t := table.New(
table.WithColumns(columns),
table.WithRows(rows),
table.WithFocused(true),
table.WithHeight(17),
table.WithStyles(TableStyles),
)
t2 := table.New(
table.WithColumns(columns2),
table.WithRows(rows),
table.WithFocused(true),
table.WithHeight(10),
table.WithStyles(TableStyles2),
)
ti := textinput.New()
ti.Placeholder = "Service"
ti.Focus()
ti.CharLimit = 156
ti.Width = 20
ti.Cursor.Style = lipgloss.NewStyle().Background(lipgloss.Color("#0A0118FF")).Foreground(lipgloss.Color("#0FF74D"))
ti.Cursor.TextStyle = lipgloss.NewStyle().Background(lipgloss.Color("#0A0118FF")).Foreground(lipgloss.Color("#0FF74D"))
ti.PlaceholderStyle = lipgloss.NewStyle().Background(lipgloss.Color("#0A0118FF")).Faint(true)
ti.TextStyle = lipgloss.NewStyle().Background(lipgloss.Color("#0A0118FF")).Foreground(lipgloss.Color("#0FF74D"))
ti2 := textinput.New()
ti2.Placeholder = "Username"
ti2.CharLimit = 156
ti2.Blur()
ti2.Width = 20
ti2.Cursor.Style = lipgloss.NewStyle().Background(lipgloss.Color("#0A0118FF")).Foreground(lipgloss.Color("#0FF74D"))
ti2.Cursor.TextStyle = lipgloss.NewStyle().Background(lipgloss.Color("#0A0118FF")).Foreground(lipgloss.Color("#0FF74D"))
ti2.PlaceholderStyle = lipgloss.NewStyle().Background(lipgloss.Color("#0A0118FF")).Faint(true)
ti2.TextStyle = lipgloss.NewStyle().Background(lipgloss.Color("#0A0118FF")).Foreground(lipgloss.Color("#0FF74D"))
ti3 := textinput.New()
ti3.Placeholder = "Password"
ti3.CharLimit = 156
ti3.Blur()
ti3.Width = 20
ti3.EchoMode = textinput.EchoPassword
ti3.EchoCharacter = '•'
ti3.Cursor.TextStyle = lipgloss.NewStyle().Background(lipgloss.Color("#0A0118FF")).Foreground(lipgloss.Color("#0FF74D"))
ti3.Cursor.Style = lipgloss.NewStyle().Background(lipgloss.Color("#0A0118FF")).Foreground(lipgloss.Color("#0FF74D"))
ti3.PlaceholderStyle = lipgloss.NewStyle().Background(lipgloss.Color("#0A0118FF")).Faint(true)
ti3.TextStyle = lipgloss.NewStyle().Background(lipgloss.Color("#0A0118FF")).Foreground(lipgloss.Color("#0FF74D"))
ti4 := textinput.New()
ti4.Placeholder = "ID"
ti4.CharLimit = 156
ti4.Blur()
ti4.Width = 20
ti4.Cursor.TextStyle = lipgloss.NewStyle().Background(lipgloss.Color("#0A0118FF")).Foreground(lipgloss.Color("#0FF74D"))
ti4.Cursor.Style = lipgloss.NewStyle().Background(lipgloss.Color("#0A0118FF")).Foreground(lipgloss.Color("#0FF74D"))
ti4.PlaceholderStyle = lipgloss.NewStyle().Background(lipgloss.Color("#0A0118FF")).Faint(true)
ti4.TextStyle = lipgloss.NewStyle().Background(lipgloss.Color("#0A0118FF")).Foreground(lipgloss.Color("#0FF74D"))
return model{
choices: []string{"Display Passwords", "Manage Passwords"},
choices2: []string{"Create", "Delete"},
page: -1,
table: t,
table2: t2,
value: "",
state: tableView,
textInput: ti,
textInput2: ti2,
textInput3: ti3,
textInput4: ti4,
err: nil,
option: "",
createIndex: 0,
dbOpMsg: "",
}
}