use ratatui::text::Text;
use crate::widgets::ListItem;
#[derive(Debug)]
pub struct InputSelectOption
{
pub text: String,
}
impl InputSelectOption
{
pub fn new<S>(text: S) -> Self
where
S: AsRef<str>,
{
Self {
text: text
.as_ref()
.to_string(),
}
}
}
impl ListItem for InputSelectOption
{
fn to_listitem(
&self,
_width: u16,
_index: usize,
_active: bool,
) -> ratatui::widgets::ListItem
{
let text = Text::raw(
self.text
.as_str(),
);
ratatui::widgets::ListItem::from(text)
}
fn filter<S>(
&self,
_filter: Option<S>,
) -> bool
where
S: AsRef<str>,
{
true
}
fn sort_by(
c1: &Self,
c2: &Self,
) -> std::cmp::Ordering
{
c1.text
.cmp(&c2.text)
}
}