65 lines
1.6 KiB
Go
65 lines
1.6 KiB
Go
|
package main
|
||
|
|
||
|
import (
|
||
|
"fmt"
|
||
|
// "github.com/charmbracelet/bubbles/list"
|
||
|
"github.com/charmbracelet/lipgloss"
|
||
|
"github.com/charmbracelet/bubbles/list"
|
||
|
"github.com/charmbracelet/bubbletea"
|
||
|
"io"
|
||
|
"strings"
|
||
|
// "github.com/charmbracelet/lipgloss"
|
||
|
)
|
||
|
|
||
|
var ( //Calendars choose
|
||
|
titleStyle = lipgloss.NewStyle().MarginLeft(2)
|
||
|
itemStyle = lipgloss.NewStyle().PaddingLeft(4)
|
||
|
selectedItemStyle = lipgloss.NewStyle().PaddingLeft(2).Foreground(lipgloss.Color("170"))
|
||
|
paginationStyle = list.DefaultStyles().PaginationStyle.PaddingLeft(4)
|
||
|
helpStyle = list.DefaultStyles().HelpStyle.PaddingLeft(4).PaddingBottom(1)
|
||
|
quitTextStyle = lipgloss.NewStyle().Margin(1, 0, 2, 4)
|
||
|
)
|
||
|
|
||
|
|
||
|
func (m model) RenderCalendarChooser() string {
|
||
|
return m.calendarList.View()
|
||
|
}
|
||
|
|
||
|
type item string
|
||
|
|
||
|
func (i item) FilterValue() string { return "" }
|
||
|
|
||
|
type itemDelegate struct{}
|
||
|
|
||
|
func (d itemDelegate) Height() int { return 1 }
|
||
|
func (d itemDelegate) Spacing() int { return 0 }
|
||
|
func (d itemDelegate) Update(_ tea.Msg, _ *list.Model) tea.Cmd { return nil }
|
||
|
func (d itemDelegate) Render(w io.Writer, m list.Model, index int, listItem list.Item) {
|
||
|
i, ok := listItem.(item)
|
||
|
if !ok {
|
||
|
return
|
||
|
}
|
||
|
|
||
|
str := fmt.Sprintf("%d. %s", index+1, i)
|
||
|
|
||
|
fn := itemStyle.Render
|
||
|
if index == m.Index() {
|
||
|
fn = func(s ...string) string {
|
||
|
return selectedItemStyle.Render("> " + strings.Join(s, " "))
|
||
|
}
|
||
|
}
|
||
|
|
||
|
fmt.Fprint(w, fn(str))
|
||
|
}
|
||
|
|
||
|
|
||
|
func (m *model) CalendarToTodo() (err error) {
|
||
|
|
||
|
m.LoggedIn = true
|
||
|
m.GatherTodos()
|
||
|
m.ActiveWindow = "today"
|
||
|
|
||
|
|
||
|
return nil
|
||
|
}
|