rtlibs-tui 0.1.4

rtools library: ratatui widgets
Documentation
#[derive(Debug, PartialEq, Eq)]
pub enum ModalKind
{
    FullScreen,
    Large,
    Small,
    Rect(
        u16,
        u16,
    ),
}

#[derive(Debug)]
pub struct ModalConfig
{
    pub kind: ModalKind,
    pub bordered: bool,
    pub title: String,
}

impl std::default::Default for ModalConfig
{
    fn default() -> Self
    {
        Self::new()
    }
}

impl ModalConfig
{
    pub fn new() -> Self
    {
        Self {
            kind: ModalKind::Small,
            bordered: true,
            title: String::new(),
        }
    }

    pub fn large(mut self) -> Self
    {
        self.kind = ModalKind::Large;
        self
    }

    pub fn fullscreen(mut self) -> Self
    {
        self.kind = ModalKind::FullScreen;
        self
    }

    pub fn rect(
        mut self,
        width: u16,
        height: u16,
    ) -> Self
    {
        self.kind = ModalKind::Rect(
            width, height,
        );
        self
    }

    pub fn not_bordered(mut self) -> Self
    {
        self.bordered = false;
        self
    }

    pub fn title<S>(
        mut self,
        title: S,
    ) -> Self
    where
        S: AsRef<str>,
    {
        self.title = title
            .as_ref()
            .to_string();
        self
    }
}