use kanban_core::InputState;
pub struct SearchState {
pub input: InputState,
pub is_active: bool,
}
impl SearchState {
pub fn new() -> Self {
Self {
input: InputState::new(),
is_active: false,
}
}
pub fn activate(&mut self) {
self.is_active = true;
self.input.clear();
}
pub fn deactivate(&mut self) {
self.is_active = false;
self.input.clear();
}
pub fn query(&self) -> &str {
self.input.as_str()
}
pub fn is_empty(&self) -> bool {
self.input.as_str().is_empty()
}
pub fn active_query(&self) -> Option<&str> {
if self.is_active {
Some(self.query())
} else {
None
}
}
}
impl Default for SearchState {
fn default() -> Self {
Self::new()
}
}