Skip to content

Commit 30dc375

Browse files
committed
saving work
1 parent 83a7ca3 commit 30dc375

File tree

2 files changed

+21
-7
lines changed

2 files changed

+21
-7
lines changed

main.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,6 @@ func (m mainModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
105105

106106
if err == nil && m.State == shared.TableView {
107107
row := m.Table.SelectedRow()
108-
// print(row[0], row[1], row[2])
109108

110109
db.UpdateInventoryItem(row[0], count)
111110
rows := m.Table.Rows()

shared/ui/ui.go

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -144,10 +144,18 @@ func GetTabUI(m shared.MainModel) string {
144144
gap)
145145
}
146146

147-
func enumerateList(items list.Items, i int) string {
147+
func enumerateSmallList(items list.Items, i int) string {
148148
return "\t\t\t ✓ "
149149
}
150150

151+
func enumerateCheckedList(items list.Items, i int) string {
152+
return "\t\t\t [✓] "
153+
}
154+
155+
func enumerateUnCheckedList(items list.Items, i int) string {
156+
return "\t\t\t [ ] "
157+
}
158+
151159
func GetWelcomeUI(m shared.MainModel) string {
152160
if m.CurrentTab != 0 {
153161
return ""
@@ -182,7 +190,7 @@ func GetWelcomeUI(m shared.MainModel) string {
182190
"Check your inventory",
183191
"Make a grocery list",
184192
"Support James",
185-
).ItemStyle(itemStyle).Enumerator(enumerateList)
193+
).ItemStyle(itemStyle).Enumerator(enumerateSmallList)
186194

187195
spacer := lipgloss.NewStyle().
188196
Height(3).Render(" ")
@@ -254,20 +262,27 @@ func GetListUI(m shared.MainModel) string {
254262

255263
items := db.GetGroceryItems()
256264

257-
var listStrings []string
265+
var checkedListItems []string
266+
var unCheckedListItems []string
258267

259268
for _, item := range items {
260-
listStrings = append(listStrings, item.Name)
269+
if item.Checked {
270+
checkedListItems = append(checkedListItems, item.Name)
271+
} else {
272+
unCheckedListItems = append(unCheckedListItems, item.Name)
273+
}
261274
}
262275

263-
listItems := list.New(listStrings).ItemStyle(itemStyle).Enumerator(enumerateList)
276+
unCheckedList := list.New(unCheckedListItems).ItemStyle(itemStyle).Enumerator(enumerateUnCheckedList)
277+
278+
checkedList := list.New(checkedListItems).ItemStyle(itemStyle).Enumerator(enumerateCheckedList)
264279

265280
spacer := lipgloss.NewStyle().
266281
Height(3).Render(" ")
267282

268283
homeHelperText := tipContainerStyle.MarginLeft(6).Width(60).Padding(1).Render("i: go to inventory • g: go to list • s: go to settings")
269284

270-
return lipgloss.JoinVertical(lipgloss.Top, lipgloss.JoinHorizontal(lipgloss.Center, titleStyle, descriptionStyle), line, listItems.String(), spacer, homeHelperText, spacer)
285+
return lipgloss.JoinVertical(lipgloss.Top, lipgloss.JoinHorizontal(lipgloss.Center, titleStyle, descriptionStyle), line, unCheckedList.String(), checkedList.String(), spacer, homeHelperText, spacer)
271286
}
272287

273288
func GetSettingsUI(m shared.MainModel) string {

0 commit comments

Comments
 (0)