MCPcopy Create free account
hub / github.com/NVIDIA/OpenShell / draw_creating

Function draw_creating

crates/openshell-tui/src/ui/create_provider.rs:430–478  ·  view source on GitHub ↗
(
    frame: &mut Frame<'_>,
    form: &crate::app::CreateProviderForm,
    area: Rect,
    theme: &crate::theme::Theme,
)

Source from the content-addressed store, hash-verified

428// ---------------------------------------------------------------------------
429
430fn draw_creating(
431 frame: &mut Frame<'_>,
432 form: &crate::app::CreateProviderForm,
433 area: Rect,
434 theme: &crate::theme::Theme,
435) {
436 let t = theme;
437 let modal_width = 55u16.min(area.width.saturating_sub(4));
438 // header(1) + spacer(1) + animation(1)
439 let content_height = 1 + 1 + 1;
440 let modal_height = (content_height + 4).min(area.height.saturating_sub(2));
441 let popup_area = centered_rect(modal_width, modal_height, area);
442
443 frame.render_widget(Clear, popup_area);
444
445 let block = Block::default()
446 .title(Span::styled(" Creating Provider ", t.heading))
447 .borders(Borders::ALL)
448 .border_style(t.accent)
449 .padding(Padding::new(2, 2, 1, 1));
450
451 let inner = block.inner(popup_area);
452 frame.render_widget(block, popup_area);
453
454 let chunks = Layout::default()
455 .direction(Direction::Vertical)
456 .constraints([
457 Constraint::Length(1), // header
458 Constraint::Length(1), // spacer
459 Constraint::Length(1), // animation
460 Constraint::Min(0),
461 ])
462 .split(inner);
463
464 let (header, header_style) = match &form.create_result {
465 Some(Ok(name)) => (format!("Created provider: {name}"), t.status_ok),
466 Some(Err(msg)) => (format!("Failed: {msg}"), t.status_err),
467 None => ("Creating provider...".to_string(), t.text),
468 };
469 frame.render_widget(
470 Paragraph::new(Line::from(Span::styled(header, header_style))),
471 chunks[0],
472 );
473
474 let elapsed_ms = form.anim_start.map_or(0, |s| s.elapsed().as_millis());
475 let track_width = chunks[2].width.saturating_sub(1) as usize;
476 let anim_line = super::create_sandbox::render_chase(track_width, elapsed_ms, t);
477 frame.render_widget(Paragraph::new(anim_line), chunks[2]);
478}
479
480// ---------------------------------------------------------------------------
481// Provider detail modal (Get)

Callers 1

drawFunction · 0.70

Calls 2

centered_rectFunction · 0.85
render_chaseFunction · 0.85

Tested by

no test coverage detected