Skip to content

Commit

Permalink
refactor: moved vertical padding to the main model
Browse files Browse the repository at this point in the history
  • Loading branch information
TypicalAM committed Jan 8, 2023
1 parent 6ca701a commit 30b5474
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
3 changes: 2 additions & 1 deletion internal/model/main/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,8 @@ func (m Model) View() string {
sections = append(sections, m.renderTabBar())

// Render the tab content and the status bar
sections = append(sections, m.tabs[m.activeTab].View())
constrainHeight := lipgloss.NewStyle().Height(m.windowHeight - 3)
sections = append(sections, constrainHeight.Render(m.tabs[m.activeTab].View()))

// Render the status bar
sections = append(sections, m.renderStatusBar())
Expand Down
5 changes: 2 additions & 3 deletions internal/model/simplelist/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package simplelist

import (
"strconv"
"strings"
"unicode"

"github.com/TypicalAM/goread/internal/style"
Expand All @@ -11,6 +10,7 @@ import (
"github.com/charmbracelet/lipgloss"
)

// TODO: Add vertical scrolling
// Model contains state of the list
type Model struct {
title string
Expand Down Expand Up @@ -92,8 +92,7 @@ func (m Model) View() string {
// Append a blank line at the end
sections = append(sections, "")

// Add padding
sections = append(sections, strings.Repeat("\n", m.height-len(sections)))
// Join the sections and return the view
return lipgloss.JoinVertical(lipgloss.Top, sections...)
}

Expand Down
6 changes: 2 additions & 4 deletions internal/model/tab/feed/feed.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package feed

import (
"fmt"
"strings"

"github.com/TypicalAM/goread/internal/backend"
"github.com/TypicalAM/goread/internal/model/simplelist"
Expand Down Expand Up @@ -259,7 +258,6 @@ func (m Model) showLoading() string {
)
}

// Pad the message with empty lines
padding := m.height - lipgloss.Height(loadingMsg)
return loadingMsg + strings.Repeat("\n", padding)
// Render the message
return loadingMsg
}

0 comments on commit 30b5474

Please sign in to comment.