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