()
| 195 | } |
| 196 | |
| 197 | func (m Settings) View() string { |
| 198 | titleLine := Styles.TitleRule(m.width, m.app.Settings.Host, strings.ToLower(m.section.Title())) |
| 199 | |
| 200 | var contentView string |
| 201 | switch m.state { |
| 202 | case settingsStateForm: |
| 203 | var statusLine string |
| 204 | if m.err != nil { |
| 205 | statusLine = lipgloss.NewStyle().Foreground(Colors.Error).Width(m.width).Align(lipgloss.Center).Render(docker.ErrorMessage(m.err)) |
| 206 | } else if line := m.section.StatusLine(); line != "" { |
| 207 | statusLine = lipgloss.NewStyle().Foreground(Colors.Muted).Render(line) |
| 208 | } |
| 209 | contentView = lipgloss.JoinVertical(lipgloss.Center, statusLine, "", m.section.View()) |
| 210 | case settingsStateActionComplete: |
| 211 | contentView = m.renderActionComplete() |
| 212 | default: |
| 213 | contentView = m.progress.View() |
| 214 | } |
| 215 | |
| 216 | var helpLine string |
| 217 | if m.state == settingsStateForm { |
| 218 | helpLine = Styles.CenteredLine(m.width, m.help.View()) |
| 219 | } |
| 220 | |
| 221 | titleHeight := 2 // title + blank line |
| 222 | helpHeight := lipgloss.Height(helpLine) |
| 223 | middleHeight := m.height - titleHeight - helpHeight |
| 224 | |
| 225 | centeredContent := lipgloss.Place( |
| 226 | m.width, |
| 227 | middleHeight, |
| 228 | lipgloss.Center, |
| 229 | lipgloss.Center, |
| 230 | contentView, |
| 231 | ) |
| 232 | |
| 233 | return titleLine + "\n\n" + centeredContent + helpLine |
| 234 | } |
| 235 | |
| 236 | // Private |
| 237 |
nothing calls this directly
no test coverage detected