line up layout
This commit is contained in:
parent
3a3e3e73a2
commit
91e44b9c8d
|
@ -97,16 +97,22 @@ func (m baseModel) View() string {
|
|||
return "\n Initializing..."
|
||||
}
|
||||
|
||||
logWindow := windowStyle.Width(m.contentSize.Width).Height(logLineCount).Render(m.logViewport.View())
|
||||
return docStyle.Render(fmt.Sprintf("%s\n%s", m.tabs.View(), logWindow))
|
||||
logWindow := windowStyle.
|
||||
Width(m.contentSize.Width).
|
||||
Height(logLineCount).
|
||||
//Background(lipgloss.ANSIColor(termenv.ANSIYellow)).
|
||||
Render(m.logViewport.View())
|
||||
|
||||
return fmt.Sprintf("%s\n%s", m.tabs.View(), logWindow)
|
||||
}
|
||||
|
||||
func (m *baseModel) setSize() {
|
||||
logHeight := logLineCount + docStyle.GetVerticalFrameSize()
|
||||
logHeight := logLineCount
|
||||
menuHeight := 1
|
||||
|
||||
m.contentSize.Width = m.windowSize.Width - windowStyle.GetHorizontalFrameSize() - docStyle.GetHorizontalFrameSize()
|
||||
m.contentSize.Height = m.windowSize.Height - windowStyle.GetVerticalFrameSize() - docStyle.GetVerticalFrameSize() - logHeight - menuHeight
|
||||
m.contentSize.Width = m.windowSize.Width - windowStyle.GetHorizontalFrameSize()
|
||||
m.contentSize.Height = m.windowSize.Height - windowStyle.GetVerticalFrameSize() - logHeight - menuHeight
|
||||
//m.Log(fmt.Sprintf("contentheight: %d = windowheight %d - windowframeheight %d - logheight %d - menuheight %d", m.contentSize.Height, m.windowSize.Height, windowStyle.GetVerticalFrameSize(), logHeight, menuHeight))
|
||||
|
||||
m.logViewport.Width = m.contentSize.Width
|
||||
m.logViewport.Height = logLineCount
|
||||
|
|
|
@ -93,7 +93,7 @@ func (m tabEMDB) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
|||
}
|
||||
m.colWidth = msg.Width / 2
|
||||
m.colHeight = msg.Height
|
||||
m.list.SetSize(m.colWidth-4, msg.Height-4)
|
||||
m.list.SetSize(m.colWidth, msg.Height-4)
|
||||
m.list, cmd = m.list.Update(msg)
|
||||
cmds = append(cmds, cmd)
|
||||
case Movies:
|
||||
|
@ -149,14 +149,12 @@ func (m tabEMDB) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
|||
|
||||
func (m tabEMDB) View() string {
|
||||
colLeft := lipgloss.NewStyle().
|
||||
Width(m.colWidth - 2).
|
||||
Height(m.colHeight - 2).
|
||||
Padding(1).
|
||||
Width(m.colWidth).
|
||||
Height(m.colHeight).
|
||||
Render(m.list.View())
|
||||
colRight := lipgloss.NewStyle().
|
||||
Width(m.colWidth - 2).
|
||||
Height(m.colHeight - 2).
|
||||
Padding(1).
|
||||
Width(m.colWidth).
|
||||
Height(m.colHeight).
|
||||
Render(m.ViewForm())
|
||||
|
||||
return lipgloss.JoinHorizontal(lipgloss.Top, colLeft, colRight)
|
||||
|
|
|
@ -109,13 +109,13 @@ func (m *tabReview) View() string {
|
|||
colRateWidth := m.width - colReviewWidth
|
||||
|
||||
colReview := lipgloss.NewStyle().
|
||||
Width(colReviewWidth - 2).
|
||||
Width(colReviewWidth).
|
||||
Height(m.height).
|
||||
Padding(1).
|
||||
MaxHeight(m.height).
|
||||
Render(m.ViewReview())
|
||||
colRate := lipgloss.NewStyle().
|
||||
Width(colRateWidth - 2).
|
||||
Width(colRateWidth).
|
||||
Height(m.height).
|
||||
Padding(1).
|
||||
Render(m.ViewForm())
|
||||
|
|
|
@ -93,8 +93,12 @@ func (t *TabSet) View() string {
|
|||
Render(fmt.Sprintf(" %s ", t.title[name])))
|
||||
}
|
||||
menu := lipgloss.JoinHorizontal(lipgloss.Top, items...)
|
||||
pane := t.tabs[t.order[t.active]].View()
|
||||
lipgloss.PlaceHorizontal(t.size.Width, lipgloss.Left, menu)
|
||||
menu = lipgloss.PlaceHorizontal(t.size.Width, lipgloss.Left, menu)
|
||||
|
||||
pane := lipgloss.NewStyle().
|
||||
// Background(lipgloss.ANSIColor(termenv.ANSIBlue)).
|
||||
Render(t.tabs[t.order[t.active]].View())
|
||||
pane = lipgloss.PlaceVertical(t.size.Height, lipgloss.Top, pane)
|
||||
|
||||
return fmt.Sprintf("%s\n%s", menu, pane)
|
||||
}
|
||||
|
|
|
@ -40,10 +40,10 @@ func (m tabTMDB) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
|||
switch msg := msg.(type) {
|
||||
case TabSizeMsg:
|
||||
if !m.initialized {
|
||||
m.initialModel(msg.Width, msg.Height)
|
||||
m.initialModel(msg.Width, msg.Height-2)
|
||||
}
|
||||
m.initialized = true
|
||||
m.searchResults.SetSize(msg.Width, msg.Height)
|
||||
m.searchResults.SetSize(msg.Width, msg.Height-2)
|
||||
case TabResetMsg:
|
||||
m.searchInput.SetValue("")
|
||||
m.searchResults.SetItems([]list.Item{})
|
||||
|
@ -107,7 +107,7 @@ func (m *tabTMDB) initialModel(width, height int) {
|
|||
m.searchInput = si
|
||||
m.searchInput.Focus()
|
||||
|
||||
m.searchResults = list.New([]list.Item{}, list.NewDefaultDelegate(), width, height-50)
|
||||
m.searchResults = list.New([]list.Item{}, list.NewDefaultDelegate(), width, height-1)
|
||||
m.searchResults.Title = "Search results"
|
||||
m.searchResults.SetShowHelp(false)
|
||||
|
||||
|
|
|
@ -9,13 +9,11 @@ import (
|
|||
)
|
||||
|
||||
var (
|
||||
docStyle = lipgloss.NewStyle().Padding(1)
|
||||
colorNormalForeground = lipgloss.ANSIColor(termenv.ANSIWhite)
|
||||
colorHighLightForeGround = lipgloss.ANSIColor(termenv.ANSIBrightWhite)
|
||||
windowStyle = lipgloss.NewStyle().
|
||||
BorderForeground(colorHighLightForeGround).
|
||||
Foreground(colorNormalForeground).
|
||||
Padding(0, 1).
|
||||
Border(lipgloss.NormalBorder(), true)
|
||||
logLineCount = 10
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue