Работа над стилями, работа над модальными окнами, изменение списка приложений, работа с размерами окон
This commit is contained in:
parent
5203032b83
commit
ada7db46cf
12 changed files with 1161 additions and 130 deletions
108
setup/final.go
108
setup/final.go
|
|
@ -37,9 +37,9 @@ func (m *FinalModel) Init() tea.Cmd {
|
|||
}
|
||||
|
||||
func (m *FinalModel) initViewport(width, height int) {
|
||||
m.viewport = viewport.New(width, height-4)
|
||||
m.viewport.Width = width - 4
|
||||
m.viewport.Height = height - 6
|
||||
m.viewport = viewport.New(width, height-8)
|
||||
m.viewport.Width = width
|
||||
m.viewport.Height = height - 10
|
||||
m.ready = true
|
||||
m.rebuildTable(m.viewport.Width)
|
||||
m.viewport.SetContent(m.table.Render())
|
||||
|
|
@ -50,22 +50,22 @@ func (m *FinalModel) rebuildTable(width int) {
|
|||
m.table = table.New().Headers("Нет переменных")
|
||||
return
|
||||
}
|
||||
availableWidth := width - 8 // примерно: 2 (отступы) + 4 (бордер) + запас
|
||||
if availableWidth < 60 {
|
||||
availableWidth = 60
|
||||
availableWidth := width - 12 // примерно: 2 (отступы) + 4 (бордер) + запас
|
||||
if availableWidth < 70 {
|
||||
availableWidth = 70
|
||||
}
|
||||
t := table.New().
|
||||
Border(lipgloss.ThickBorder()).
|
||||
BorderStyle(ui.TableBorderStyle).
|
||||
Border(lipgloss.RoundedBorder()).
|
||||
BorderStyle(ui.TableBorder).
|
||||
StyleFunc(func(row, col int) lipgloss.Style {
|
||||
var style lipgloss.Style
|
||||
switch {
|
||||
case row == table.HeaderRow:
|
||||
return ui.TableHeaderStyle
|
||||
return ui.TableHeader
|
||||
case row%2 == 0:
|
||||
style = ui.TableEvenRowStyle
|
||||
style = ui.TableRowEven.Padding(0, 2)
|
||||
default:
|
||||
style = ui.TableOddRowStyle
|
||||
style = ui.TableRowOdd.Padding(0, 2)
|
||||
}
|
||||
switch col {
|
||||
case 0, 1:
|
||||
|
|
@ -125,26 +125,76 @@ func (m *FinalModel) View() string {
|
|||
if !m.ready {
|
||||
return "Загрузка таблицы"
|
||||
}
|
||||
header := lipgloss.NewStyle().
|
||||
Width(m.viewport.Width).
|
||||
Align(lipgloss.Center).
|
||||
Bold(true).
|
||||
Background(ui.ColorPurple).
|
||||
Foreground(ui.ColorWhite).
|
||||
Padding(1).
|
||||
Render("Итоговые значения переменных")
|
||||
|
||||
footer := lipgloss.NewStyle().
|
||||
Width(m.viewport.Width).
|
||||
Align(lipgloss.Center).
|
||||
Foreground(ui.ColorGrey).
|
||||
Padding(0, 1).
|
||||
Render(fmt.Sprintf("Строк: %d • q — выход • ↑↓ / jk — скролл", len(m.variables)))
|
||||
contentWidth := ui.ContentWidth(m.width)
|
||||
m.rebuildTable(contentWidth)
|
||||
|
||||
header := ui.HeaderStyle.Width(contentWidth).Render("Итоговые значения переменных")
|
||||
footer := ui.FooterStyle.Width(contentWidth).Render(fmt.Sprintf("Строк: %d • q — выход • ↑↓ / jk — скролл", len(m.variables)))
|
||||
|
||||
m.viewport.Width = contentWidth - 8
|
||||
m.viewport.Height = m.height - 12
|
||||
m.viewport.SetContent(m.table.Render())
|
||||
|
||||
body := m.viewport.View()
|
||||
return lipgloss.JoinVertical(lipgloss.Center,
|
||||
header,
|
||||
body,
|
||||
footer,
|
||||
|
||||
content := lipgloss.JoinVertical(lipgloss.Left, header, body, footer)
|
||||
container := ui.AppContainer.Width(contentWidth).Render(content)
|
||||
|
||||
return lipgloss.Place(m.width, m.height,
|
||||
lipgloss.Center, lipgloss.Center,
|
||||
container,
|
||||
lipgloss.WithWhitespaceChars("░"),
|
||||
lipgloss.WithWhitespaceForeground(ui.ColorGrey),
|
||||
)
|
||||
|
||||
//contentWidth := ui.AppContentWidth(m.width)
|
||||
//m.viewport.Width = contentWidth - 6
|
||||
//m.viewport.Height = m.height - 12
|
||||
//m.rebuildTable(contentWidth)
|
||||
//
|
||||
//header := ui.AppHeaderStyle.
|
||||
// Width(contentWidth).
|
||||
// Render("Итоговые значения переменных")
|
||||
//
|
||||
//footer := ui.AppFooterStyle.
|
||||
// Width(contentWidth).
|
||||
// Render(fmt.Sprintf("Строк: %d • q — выход • ↑↓ / jk — скролл", len(m.variables)))
|
||||
//
|
||||
//body := m.viewport.View()
|
||||
//content := lipgloss.JoinVertical(lipgloss.Left, header, body, footer)
|
||||
//
|
||||
//container := ui.AppContainerStyle.
|
||||
// Width(contentWidth).
|
||||
// Render(content)
|
||||
//
|
||||
//return lipgloss.Place(m.width, m.height,
|
||||
// lipgloss.Center, lipgloss.Center,
|
||||
// container,
|
||||
// lipgloss.WithWhitespaceChars("░"),
|
||||
// lipgloss.WithWhitespaceForeground(ui.ColorGrey),
|
||||
//)
|
||||
|
||||
//header := lipgloss.NewStyle().
|
||||
// Width(m.viewport.Width).
|
||||
// Align(lipgloss.Center).
|
||||
// Bold(true).
|
||||
// Background(ui.ColorPurple).
|
||||
// Foreground(ui.ColorWhite).
|
||||
// Padding(1).
|
||||
// Render("Итоговые значения переменных")
|
||||
//
|
||||
//footer := lipgloss.NewStyle().
|
||||
// Width(m.viewport.Width).
|
||||
// Align(lipgloss.Center).
|
||||
// Foreground(ui.ColorGrey).
|
||||
// Padding(0, 1).
|
||||
// Render(fmt.Sprintf("Строк: %d • q — выход • ↑↓ / jk — скролл", len(m.variables)))
|
||||
//
|
||||
//body := m.viewport.View()
|
||||
//return lipgloss.JoinVertical(lipgloss.Center,
|
||||
// header,
|
||||
// body,
|
||||
// footer,
|
||||
//)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue