Работа над стилями, работа над модальными окнами, изменение списка приложений, работа с размерами окон

This commit is contained in:
XeRo 2025-12-29 17:46:48 +05:00
parent 5203032b83
commit ada7db46cf
12 changed files with 1161 additions and 130 deletions

View file

@ -2,35 +2,164 @@ package ui
import "github.com/charmbracelet/lipgloss"
const (
AppMaxWidth = 110
AppMinWidth = 80
AppSidePadding = 4
ModalMaxWidth = 80
ModalMaxHeight = 30
ListWithRatio = 0.4
)
func AppContentWidth(screenWidth int) int {
w := screenWidth - 2*AppSidePadding
if w > AppMaxWidth {
return AppMaxWidth
}
if w < AppMinWidth {
return AppMinWidth
}
return w
}
var (
ColorWhite = lipgloss.Color("#ffffff")
ColorGrey = lipgloss.Color("#626262")
ColorBlack = lipgloss.Color("#000000")
ColorRed = lipgloss.Color("#FF0000")
ColorGreen = lipgloss.Color("#00FF00")
ColorBlue = lipgloss.Color("#0000FF")
ColorPurple = lipgloss.Color("#6f03fc")
ColorGreenCyan = lipgloss.Color("#11CAAA")
ColorFg = lipgloss.Color("#eeeeee")
ColorBg = lipgloss.Color("#0d1117")
ColorAccent = lipgloss.Color("#a6e3a1")
ColorAccent2 = lipgloss.Color("#747cec")
ColorWarning = lipgloss.Color("#f9e2af")
ColorError = lipgloss.Color("#f38ba8")
ColorPurple = lipgloss.Color("#cba6f7")
ColorGrey = lipgloss.Color("#585b70")
ColorDarkGrey = lipgloss.Color("#313244")
TableHeaderStyle = lipgloss.NewStyle().Foreground(ColorPurple).Bold(true).Align(lipgloss.Center)
TableCellStyle = lipgloss.NewStyle().Padding(0, 1).Width(14)
TableOddRowStyle = TableCellStyle.Foreground(ColorWhite).Background(ColorGrey)
TableEvenRowStyle = TableCellStyle.Foreground(ColorWhite)
TableBorderStyle = lipgloss.NewStyle().Foreground(ColorPurple)
AppContainer = lipgloss.NewStyle().
Padding(2, 4).
Border(lipgloss.RoundedBorder()).
BorderForeground(ColorPurple)
HeaderStyle = lipgloss.NewStyle().
Bold(true).
Foreground(ColorPurple).
Background(ColorDarkGrey).
Padding(1, 2).
MarginBottom(1).
Align(lipgloss.Center)
FooterStyle = lipgloss.NewStyle().
Foreground(ColorGrey).
Padding(0, 2).
MarginTop(1).
Align(lipgloss.Center)
ListContainer = lipgloss.NewStyle().
Padding(1, 3).
Border(lipgloss.RoundedBorder()).
BorderForeground(ColorAccent)
ListTitleStyle = lipgloss.NewStyle().Foreground(ColorPurple).Italic(true).Bold(true)
ListSelectedStyle = lipgloss.NewStyle().Foreground(ColorError).Bold(true)
ListDescriptionStyle = lipgloss.NewStyle().Foreground(ColorAccent2).MarginTop(1)
ModalBorderError = lipgloss.NewStyle().BorderForeground(ColorError)
ModalBorderWarning = lipgloss.NewStyle().BorderForeground(ColorWarning)
ModalBorderConfirm = lipgloss.NewStyle().BorderForeground(ColorPurple)
ModalBorderInfo = lipgloss.NewStyle().BorderForeground(ColorAccent)
ModalTitleError = lipgloss.NewStyle().BorderForeground(ColorError).Bold(true)
ModalTitleWarning = lipgloss.NewStyle().BorderForeground(ColorWarning).Bold(true)
ModalTitleDefault = lipgloss.NewStyle().BorderForeground(ColorPurple).Bold(true)
ModalButtonNormal = lipgloss.NewStyle().
Padding(0, 3).
Border(lipgloss.RoundedBorder()).
BorderForeground(ColorGrey).
Foreground(ColorAccent2)
ModalButtonFocused = lipgloss.NewStyle().
Padding(0, 3).
Border(lipgloss.RoundedBorder()).
BorderForeground(ColorError).
Foreground(ColorError).
Bold(true)
FormContainer = lipgloss.NewStyle().
Padding(2, 4).
Border(lipgloss.RoundedBorder()).
BorderForeground(ColorAccent)
FormFieldFocused = lipgloss.NewStyle().Foreground(ColorError).Bold(true)
FormFieldUnfocused = lipgloss.NewStyle().Foreground(ColorAccent2)
FormNextButton = lipgloss.NewStyle().Foreground(ColorPurple).Bold(true)
TableBorder = lipgloss.NewStyle().Foreground(ColorPurple)
TableHeader = lipgloss.NewStyle().Foreground(ColorPurple).Bold(true).Align(lipgloss.Center)
TableRowEven = lipgloss.NewStyle().Foreground(ColorFg).Background(ColorDarkGrey)
TableRowOdd = lipgloss.NewStyle().Foreground(ColorFg)
TableCell = lipgloss.NewStyle().Padding(0, 2)
//ColorWhite = lipgloss.Color("#ffffff")
//ColorGrey = lipgloss.Color("#626262")
//ColorBlack = lipgloss.Color("#000000")
//ColorRed = lipgloss.Color("#FF0000")
//ColorGreen = lipgloss.Color("#00FF00")
//ColorBlue = lipgloss.Color("#0000FF")
//ColorPurple = lipgloss.Color("#6f03fc")
//ColorGreenCyan = lipgloss.Color("#11CAAA")
//
//AppContainerStyle = lipgloss.NewStyle().
// Padding(1, 3).
// Border(lipgloss.RoundedBorder()).
// BorderForeground(ColorPurple)
//
//AppHeaderStyle = lipgloss.NewStyle().
// Bold(true).
// Foreground(ColorPurple).
// Align(lipgloss.Center).
// Padding(1, 0).
// Background(ColorWhite).
// Foreground(ColorBlack)
//
//AppFooterStyle = lipgloss.NewStyle().
// Foreground(ColorGrey).
// Align(lipgloss.Center).
// Padding(0, 1)
//
//TableHeaderStyle = lipgloss.NewStyle().Foreground(ColorPurple).Bold(true).Align(lipgloss.Center)
//TableCellStyle = lipgloss.NewStyle().Padding(0, 1).Width(14)
//TableOddRowStyle = TableCellStyle.Foreground(ColorWhite).Background(ColorGrey)
//TableEvenRowStyle = TableCellStyle.Foreground(ColorWhite)
//TableBorderStyle = lipgloss.NewStyle().Foreground(ColorPurple)
//
SelectFileDirDeniedStyle = lipgloss.NewStyle().Foreground(ColorGrey)
SelectFileDirParentStyle = lipgloss.NewStyle().Foreground(ColorPurple)
SelectFileStyle = lipgloss.NewStyle().Foreground(ColorGreenCyan)
SelectDirStyle = lipgloss.NewStyle().Foreground(ColorBlue)
SelectStyle = lipgloss.NewStyle().Foreground(ColorGreenCyan)
InputStyle = lipgloss.NewStyle().Foreground(ColorGreenCyan)
ComputeStyle = lipgloss.NewStyle().Foreground(ColorGrey)
CheckboxStyle = lipgloss.NewStyle().Foreground(ColorGreenCyan)
FormFocusedStyle = lipgloss.NewStyle().Foreground(ColorRed).Bold(true).
Border(lipgloss.NormalBorder(), false, false, false, true).BorderForeground(ColorRed)
FormUnfocusedStyle = lipgloss.NewStyle().Foreground(ColorGreenCyan)
FormStyle = lipgloss.NewStyle().Padding(1, 2).Foreground(ColorBlack).
Border(lipgloss.RoundedBorder()).BorderForeground(ColorRed)
SelectFileStyle = lipgloss.NewStyle().Foreground(ColorAccent)
SelectDirStyle = lipgloss.NewStyle().Foreground(ColorAccent2)
//
//SelectStyle = lipgloss.NewStyle().Foreground(ColorGreenCyan)
//InputStyle = lipgloss.NewStyle().Foreground(ColorGreenCyan)
//ComputeStyle = lipgloss.NewStyle().Foreground(ColorGrey)
//CheckboxStyle = lipgloss.NewStyle().Foreground(ColorGreenCyan)
//
//FormFocusedStyle = lipgloss.NewStyle().Foreground(ColorRed).Bold(true).
// Border(lipgloss.NormalBorder(), false, false, false, true).BorderForeground(ColorRed)
//FormUnfocusedStyle = lipgloss.NewStyle().Foreground(ColorGreenCyan)
//FormStyle = lipgloss.NewStyle().Padding(1, 2).Foreground(ColorBlack).
// Border(lipgloss.RoundedBorder()).BorderForeground(ColorRed)
//
//ListStyle = lipgloss.NewStyle().Padding(1, 3).Border(lipgloss.RoundedBorder()).BorderForeground(ColorRed)
//ListSelectedItemStyle = lipgloss.NewStyle().Foreground(ColorRed).Bold(true)
//ListTitleStyle = lipgloss.NewStyle().Foreground(ColorPurple).Italic(true)
//ListDescriptionStyle = lipgloss.NewStyle().Foreground(ColorGreenCyan).MarginTop(1)
)
func ContentWidth(screenWidth int) int {
w := screenWidth - 2*AppSidePadding
if w > AppMaxWidth {
return AppMaxWidth
}
if w < AppMinWidth {
return AppMinWidth
}
return w
}