renderItems renders the settings items grouped by section.
(modalWidth int)
| 256 | |
| 257 | // renderItems renders the settings items grouped by section. |
| 258 | func (s *SettingsOverlay) renderItems(modalWidth int) string { |
| 259 | var result strings.Builder |
| 260 | |
| 261 | sectionStyle := lipgloss.NewStyle(). |
| 262 | Bold(true). |
| 263 | Foreground(PrimaryColor). |
| 264 | Padding(0, 1) |
| 265 | labelStyle := lipgloss.NewStyle(). |
| 266 | Foreground(TextColor) |
| 267 | selectedLabelStyle := lipgloss.NewStyle(). |
| 268 | Foreground(TextBrightColor). |
| 269 | Bold(true) |
| 270 | valueStyle := lipgloss.NewStyle(). |
| 271 | Foreground(SuccessColor) |
| 272 | valueOffStyle := lipgloss.NewStyle(). |
| 273 | Foreground(MutedColor) |
| 274 | cursorStyle := lipgloss.NewStyle(). |
| 275 | Foreground(PrimaryColor). |
| 276 | Bold(true) |
| 277 | |
| 278 | currentSection := "" |
| 279 | for i, item := range s.items { |
| 280 | // Section header |
| 281 | if item.Section != currentSection { |
| 282 | if currentSection != "" { |
| 283 | result.WriteString("\n") |
| 284 | } |
| 285 | result.WriteString(sectionStyle.Render(item.Section)) |
| 286 | result.WriteString("\n") |
| 287 | currentSection = item.Section |
| 288 | } |
| 289 | |
| 290 | isSelected := i == s.selectedIndex |
| 291 | |
| 292 | // Cursor |
| 293 | if isSelected { |
| 294 | result.WriteString(cursorStyle.Render(" > ")) |
| 295 | } else { |
| 296 | result.WriteString(" ") |
| 297 | } |
| 298 | |
| 299 | // Label |
| 300 | label := item.Label |
| 301 | if isSelected { |
| 302 | result.WriteString(selectedLabelStyle.Render(label)) |
| 303 | } else { |
| 304 | result.WriteString(labelStyle.Render(label)) |
| 305 | } |
| 306 | |
| 307 | // Value (right-aligned) |
| 308 | var valueStr string |
| 309 | switch item.Type { |
| 310 | case SettingsItemBool: |
| 311 | if item.BoolVal { |
| 312 | valueStr = valueStyle.Render("Yes") |
| 313 | } else { |
| 314 | valueStr = valueOffStyle.Render("No") |
| 315 | } |