MCPcopy
hub / github.com/basecamp/once / View

Method View

internal/ui/settings.go:197–234  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

195}
196
197func (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

Callers

nothing calls this directly

Calls 8

renderActionCompleteMethod · 0.95
ErrorMessageFunction · 0.92
TitleRuleMethod · 0.80
CenteredLineMethod · 0.80
TitleMethod · 0.65
StatusLineMethod · 0.65
ViewMethod · 0.65
HeightMethod · 0.45

Tested by

no test coverage detected