1
0
mirror of https://github.com/taigrr/wtf synced 2025-01-18 04:03:14 -08:00
wtf/checklist/checklist_item.go
Chris Cummer f0ca3b8a58
Another actions test (#889)
* Another actions test

Signed-off-by: Chris Cummer <chriscummer@me.com>

* Add BuildTest action

Signed-off-by: Chris Cummer <chriscummer@me.com>

* Remove lint check for the time being (so many issues)

Signed-off-by: Chris Cummer <chriscummer@me.com>

* Fix issues found by errcheck

Signed-off-by: Chris Cummer <chriscummer@me.com>

* Fix errors found by staticcheck

Signed-off-by: Chris Cummer <chriscummer@me.com>

* Fix issues found by goimports

Signed-off-by: Chris Cummer <chriscummer@me.com>

* Comment out the  action for the time being

Signed-off-by: Chris Cummer <chriscummer@me.com>

* Fix shadowed variables

Signed-off-by: Chris Cummer <chriscummer@me.com>

* go mod tidy

Signed-off-by: Chris Cummer <chriscummer@me.com>

* Remove buildtest.yml

Signed-off-by: Chris Cummer <chriscummer@me.com>

* go mod tidy

Signed-off-by: Chris Cummer <chriscummer@me.com>
2020-05-09 12:51:08 -07:00

51 lines
1.2 KiB
Go

package checklist
// ChecklistItem is a module for creating generic checklist implementations
// See 'Todo' for an implementation example
type ChecklistItem struct {
Checked bool
CheckedIcon string
Text string
UncheckedIcon string
}
func NewChecklistItem(checked bool, text string, checkedIcon, uncheckedIcon string) *ChecklistItem {
item := &ChecklistItem{
Checked: checked,
CheckedIcon: checkedIcon,
Text: text,
UncheckedIcon: uncheckedIcon,
}
return item
}
// CheckMark returns the string used to indicate a ChecklistItem is checked or unchecked
func (item *ChecklistItem) CheckMark() string {
item.ensureItemIcons()
if item.Checked {
return item.CheckedIcon
}
return item.UncheckedIcon
}
// Toggle changes the checked state of the ChecklistItem
// If checked, it is unchecked. If unchecked, it is checked
func (item *ChecklistItem) Toggle() {
item.Checked = !item.Checked
}
/* -------------------- Unexported Functions -------------------- */
func (item *ChecklistItem) ensureItemIcons() {
if item.CheckedIcon == "" {
item.CheckedIcon = "x"
}
if item.UncheckedIcon == "" {
item.UncheckedIcon = " "
}
}