Skip to content

Commit

Permalink
feat!: don't expose readingModel
Browse files Browse the repository at this point in the history
  • Loading branch information
isabelroses committed Apr 12, 2024
1 parent 4410fde commit 0290580
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions cmd/readingModal.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import (
"github.com/isabelroses/izrss/lib"
)

type ReadingModel struct {
Post Post
type readingModel struct {
Post lib.Post
viewport viewport.Model
ready bool
}
Expand All @@ -23,9 +23,9 @@ func max(a, b int) int {
return b
}

func (m ReadingModel) Init() tea.Cmd { return nil }
func (m readingModel) Init() tea.Cmd { return nil }

func (m ReadingModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
func (m readingModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
var (
cmd tea.Cmd
cmds []tea.Cmd
Expand Down Expand Up @@ -69,21 +69,21 @@ func (m ReadingModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
return m, tea.Batch(cmds...)
}

func (m ReadingModel) View() string {
func (m readingModel) View() string {
if !m.ready {
return "\n Initializing..."
}

return fmt.Sprintf("%s\n%s\n%s", m.headerView(), m.viewport.View(), m.footerView())
}

func (m ReadingModel) headerView() string {
func (m readingModel) headerView() string {
title := lib.MainStyle().Render(m.Post.Title)
line := strings.Repeat("─", max(0, m.viewport.Width-lipgloss.Width(title)))
return lipgloss.JoinHorizontal(lipgloss.Center, title, line)
}

func (m ReadingModel) footerView() string {
func (m readingModel) footerView() string {
info := lib.MainStyle().Render(fmt.Sprintf("%3.f%%", m.viewport.ScrollPercent()*100))
line := strings.Repeat("─", max(0, m.viewport.Width-lipgloss.Width(info)))
return lipgloss.JoinHorizontal(lipgloss.Center, line, info)
Expand Down

0 comments on commit 0290580

Please sign in to comment.