Skip to content

Commit

Permalink
update loading screen
Browse files Browse the repository at this point in the history
  • Loading branch information
Simon-Busch committed Nov 21, 2023
1 parent 304a546 commit ddb9173
Showing 1 changed file with 40 additions and 24 deletions.
64 changes: 40 additions & 24 deletions src/render_items/render_waiting_screen.rs
Original file line number Diff line number Diff line change
@@ -1,32 +1,48 @@
use tui::{
layout::Alignment,
style::{Modifier, Style},
text::{Span, Spans},
widgets::{Block, BorderType, Borders, Paragraph},
Terminal
layout::Alignment,
style::{ Modifier, Style, Color },
text::Span,
widgets::{ Block, BorderType, Borders, Paragraph },
};


pub fn render_waiting_screen<B: tui::backend::Backend>(
terminal: &mut Terminal<B>,
terminal: &mut tui::Terminal<B>
) -> Result<(), Box<dyn std::error::Error>> {
let loading_screen = vec![
Spans::from(Span::styled("Loading GitHub data...", Style::default().add_modifier(Modifier::BOLD))),
Spans::from(Span::raw("")),
Spans::from(Span::styled("Please wait while we fetch the data from GitHub...", Style::default())),
];
let loading_text =
r#"
██████╗ ██╗████████╗██╗ ██╗██╗ ██╗██████╗
██╔════╝ ██║╚══██╔══╝██║ ██║██║ ██║██╔══██╗
██║ ███╗██║ ██║ ███████║██║ ██║██████╔╝
██║ ██║██║ ██║ ██╔══██║██║ ██║██╔══██╗
╚██████╔╝██║ ██║ ██║ ██║╚██████╔╝██████╔╝
╚═════╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═════╝
█████╗ ███████╗███████╗██╗███████╗████████╗ █████╗ ███╗ ██╗████████╗
██╔══██╗██╔════╝██╔════╝██║██╔════╝╚══██╔══╝██╔══██╗████╗ ██║╚══██╔══╝
███████║███████╗███████╗██║███████╗ ██║ ███████║██╔██╗ ██║ ██║
██╔══██║╚════██║╚════██║██║╚════██║ ██║ ██╔══██║██║╚██╗██║ ██║
██║ ██║███████║███████║██║███████║ ██║ ██║ ██║██║ ╚████║ ██║
╚═╝ ╚═╝╚══════╝╚══════╝╚═╝╚══════╝ ╚═╝ ╚═╝ ╚═╝╚═╝ ╚═══╝ ╚═╝
"#;

let loading_screen_paragraph = Paragraph::new(loading_text)
.alignment(Alignment::Center)
.block(
Block::default()
.title(
Span::styled("GitHub Assistant", Style::default().add_modifier(Modifier::BOLD))
)
.borders(Borders::ALL)
.border_style(Style::default().fg(Color::White).bg(Color::DarkGray))
.border_type(BorderType::Rounded)
);

terminal.draw(|f| {
let size = f.size();
let loading_screen_paragraph = Paragraph::new(loading_screen.clone())
.alignment(Alignment::Center)
.block(
Block::default()
.title(Span::styled("GitHub Assistant", Style::default().add_modifier(Modifier::BOLD)))
.borders(Borders::ALL).border_type(BorderType::Rounded),
);
f.render_widget(loading_screen_paragraph, size);
})?;
terminal.draw(|f| {
let size = f.size();
f.render_widget(loading_screen_paragraph, size);
})?;

Ok(())
Ok(())
}

0 comments on commit ddb9173

Please sign in to comment.