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

Function draw_choose_method

crates/openshell-tui/src/ui/create_provider.rs:106–186  ·  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

104// ---------------------------------------------------------------------------
105
106fn draw_choose_method(
107 frame: &mut Frame<'_>,
108 form: &crate::app::CreateProviderForm,
109 area: Rect,
110 theme: &crate::theme::Theme,
111) {
112 let t = theme;
113 let modal_width = 55u16.min(area.width.saturating_sub(4));
114 // header(1) + spacer(1) + type_label(1) + spacer(1) + 2 options + spacer(1) + hint(1)
115 let content_height = 1 + 1 + 1 + 1 + 2 + 1 + 1;
116 let modal_height = (content_height + 4).min(area.height.saturating_sub(2));
117 let popup_area = centered_rect(modal_width, modal_height, area);
118
119 frame.render_widget(Clear, popup_area);
120
121 let block = Block::default()
122 .title(Span::styled(" Create Provider ", t.heading))
123 .borders(Borders::ALL)
124 .border_style(t.accent)
125 .padding(Padding::new(2, 2, 1, 1));
126
127 let inner = block.inner(popup_area);
128 frame.render_widget(block, popup_area);
129
130 let chunks = Layout::default()
131 .direction(Direction::Vertical)
132 .constraints([
133 Constraint::Length(1), // header
134 Constraint::Length(1), // spacer
135 Constraint::Length(1), // type label
136 Constraint::Length(1), // spacer
137 Constraint::Length(2), // options
138 Constraint::Length(1), // spacer
139 Constraint::Length(1), // hint
140 Constraint::Min(0),
141 ])
142 .split(inner);
143
144 frame.render_widget(
145 Paragraph::new(Line::from(Span::styled(
146 "How would you like to provide credentials?",
147 t.text,
148 ))),
149 chunks[0],
150 );
151
152 let selected_type = &form.types[form.type_cursor];
153 frame.render_widget(
154 Paragraph::new(Line::from(vec![
155 Span::styled("Type: ", t.muted),
156 Span::styled(selected_type.as_str(), t.heading),
157 ])),
158 chunks[2],
159 );
160
161 let options = ["Autodetect from environment", "Enter key manually"];
162 let lines: Vec<Line<'_>> = options
163 .iter()

Callers 1

drawFunction · 0.85

Calls 1

centered_rectFunction · 0.85

Tested by

no test coverage detected