steer_tui/tui/widgets/setup/
completion.rs1use crate::tui::state::{AuthStatus, SetupState};
2use crate::tui::theme::{Component, Theme};
3use ratatui::{
4 buffer::Buffer,
5 layout::{Alignment, Rect},
6 style::Modifier,
7 text::{Line, Span},
8 widgets::{Block, Borders, Paragraph, Widget},
9};
10
11pub struct CompletionWidget;
12
13impl CompletionWidget {
14 pub fn render(area: Rect, buf: &mut Buffer, state: &SetupState, theme: &Theme) {
15 let mut lines = vec![];
16
17 let vertical_padding = (area.height.saturating_sub(12)) / 2;
19 for _ in 0..vertical_padding {
20 lines.push(Line::from(""));
21 }
22
23 lines.push(Line::from(Span::styled(
25 "✓ Setup Complete!",
26 theme.style(Component::SetupSuccessIcon),
27 )));
28 lines.push(Line::from(""));
29
30 let authenticated_providers: Vec<_> = state
32 .auth_providers
33 .iter()
34 .filter(|(_, status)| {
35 matches!(status, AuthStatus::ApiKeySet | AuthStatus::OAuthConfigured)
36 })
37 .filter_map(|(provider_id, _)| {
38 state
39 .registry
40 .get(provider_id)
41 .map(|config| config.name.clone())
42 })
43 .collect();
44
45 if authenticated_providers.is_empty() {
46 lines.push(Line::from("No providers authenticated yet."));
47 } else {
48 lines.push(Line::from(Span::styled(
49 "Authenticated Providers:",
50 theme
51 .style(Component::SetupHeader)
52 .add_modifier(Modifier::BOLD),
53 )));
54 for provider in authenticated_providers {
55 lines.push(Line::from(format!(" • {provider}")));
56 }
57 }
58
59 lines.push(Line::from(""));
60 lines.push(Line::from("Your authentication has been configured."));
61 lines.push(Line::from(""));
62
63 lines.push(Line::from(vec![
65 Span::raw("Press "),
66 Span::styled("Enter", theme.style(Component::SetupKeyBinding)),
67 Span::raw(" to start using Steer"),
68 ]));
69
70 let paragraph = Paragraph::new(lines)
71 .block(
72 Block::default()
73 .borders(Borders::ALL)
74 .border_style(theme.style(Component::SetupBorder))
75 .title(" Setup Complete "),
76 )
77 .alignment(Alignment::Center);
78
79 Widget::render(paragraph, area, buf);
80 }
81}