item.go 311 B

1234567891011121314151617181920212223
  1. package picker
  2. type Item struct {
  3. text string
  4. selected func()
  5. }
  6. func NewItem(text string, selected func()) *Item {
  7. return &Item{
  8. text: text,
  9. selected: selected,
  10. }
  11. }
  12. type Items []*Item
  13. func (is Items) String(i int) string {
  14. return is[i].text
  15. }
  16. func (is Items) Len() int {
  17. return len(is)
  18. }