2023-12-22 15:50:42 +01:00
|
|
|
package tui
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
|
2023-12-23 12:08:58 +01:00
|
|
|
"ewintr.nl/emdb/model"
|
2023-12-24 10:16:11 +01:00
|
|
|
"github.com/charmbracelet/bubbles/list"
|
2023-12-22 15:50:42 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
type Movie struct {
|
2023-12-23 12:08:58 +01:00
|
|
|
m model.Movie
|
2023-12-22 15:50:42 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
func (m Movie) FilterValue() string {
|
|
|
|
return m.m.Title
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m Movie) Title() string {
|
2023-12-22 16:31:40 +01:00
|
|
|
return fmt.Sprintf("%s (%d)", m.m.Title, m.m.Year)
|
2023-12-22 15:50:42 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
func (m Movie) Description() string {
|
2023-12-22 16:31:40 +01:00
|
|
|
return fmt.Sprintf("%s", m.m.Summary)
|
2023-12-22 15:50:42 +01:00
|
|
|
}
|
2023-12-24 10:16:11 +01:00
|
|
|
|
|
|
|
type Movies []model.Movie
|
|
|
|
|
|
|
|
func (ms Movies) listItems() []list.Item {
|
|
|
|
items := []list.Item{}
|
|
|
|
for _, m := range ms {
|
|
|
|
items = append(items, Movie{m: m})
|
|
|
|
}
|
|
|
|
return items
|
|
|
|
}
|