Render renders the branch warning dialog.
()
| 221 | |
| 222 | // Render renders the branch warning dialog. |
| 223 | func (b *BranchWarning) Render() string { |
| 224 | // Modal dimensions |
| 225 | modalWidth := min(65, b.width-10) |
| 226 | modalHeight := min(20, b.height-6) |
| 227 | |
| 228 | if modalWidth < 40 { |
| 229 | modalWidth = 40 |
| 230 | } |
| 231 | if modalHeight < 14 { |
| 232 | modalHeight = 14 |
| 233 | } |
| 234 | |
| 235 | // Build modal content |
| 236 | var content strings.Builder |
| 237 | |
| 238 | // Title and message based on context |
| 239 | b.renderHeader(&content, modalWidth) |
| 240 | |
| 241 | // Branch name (shown when any option involves a branch) |
| 242 | b.renderBranchName(&content) |
| 243 | |
| 244 | // Options |
| 245 | b.renderOptions(&content) |
| 246 | |
| 247 | // Footer |
| 248 | content.WriteString("\n") |
| 249 | content.WriteString(DividerStyle.Render(strings.Repeat("─", modalWidth-4))) |
| 250 | content.WriteString("\n") |
| 251 | |
| 252 | footerStyle := lipgloss.NewStyle().Foreground(MutedColor) |
| 253 | if b.editMode { |
| 254 | content.WriteString(footerStyle.Render("Enter: confirm Esc: cancel edit")) |
| 255 | } else { |
| 256 | content.WriteString(footerStyle.Render("↑/↓: Navigate Enter: Select e: Edit branch Esc: Cancel")) |
| 257 | } |
| 258 | |
| 259 | // Modal box style - use warning color for protected branch, primary for others |
| 260 | borderColor := PrimaryColor |
| 261 | if b.context == DialogProtectedBranch { |
| 262 | borderColor = WarningColor |
| 263 | } |
| 264 | |
| 265 | modalStyle := lipgloss.NewStyle(). |
| 266 | Border(lipgloss.RoundedBorder()). |
| 267 | BorderForeground(borderColor). |
| 268 | Padding(1, 2). |
| 269 | Width(modalWidth). |
| 270 | Height(modalHeight) |
| 271 | |
| 272 | modal := modalStyle.Render(content.String()) |
| 273 | |
| 274 | // Center the modal on screen |
| 275 | return b.centerModal(modal) |
| 276 | } |
| 277 | |
| 278 | // renderHeader renders the dialog title and message. |
| 279 | func (b *BranchWarning) renderHeader(content *strings.Builder, modalWidth int) { |