shell-cell 1.7.1

Shell-Cell. CLI app to spawn and manage containerized shell environments
use ratatui::{
    layout::{Constraint, Layout},
    style::{Color, Modifier, Style},
    text::{Line, Span},
    widgets::{Block, Borders, Paragraph, Widget},
};

use super::LoadingState;

#[allow(clippy::indexing_slicing)]
impl Widget for &LoadingState {
    fn render(
        self,
        area: ratatui::prelude::Rect,
        buf: &mut ratatui::prelude::Buffer,
    ) where
        Self: Sized,
    {
        let vertical = Layout::vertical([
            Constraint::Percentage(40),
            Constraint::Length(3),
            Constraint::Percentage(40),
        ])
        .split(area);

        let horizontal = Layout::horizontal([
            Constraint::Percentage(30),
            Constraint::Percentage(40),
            Constraint::Percentage(30),
        ])
        .split(vertical[1]);

        let loading_text = vec![
            Line::from(vec![
                Span::styled(
                    "Loading",
                    Style::default()
                        .fg(Color::Cyan)
                        .add_modifier(Modifier::BOLD),
                ),
                Span::styled("...", Style::default().fg(Color::Cyan)),
            ]),
            Line::from(""),
            Line::from(Span::styled(
                "Fetching ALL 'Shell-Cell' containers for stopping",
                Style::default().fg(Color::Gray),
            )),
        ];

        let paragraph = Paragraph::new(loading_text)
            .block(
                Block::default()
                    .borders(Borders::ALL)
                    .border_style(Style::default().fg(Color::Cyan)),
            )
            .centered();

        Widget::render(paragraph, horizontal[1], buf);
    }
}