diff --git a/src/ui/widget.rs b/src/ui/widget.rs index 7715a064..f3620474 100644 --- a/src/ui/widget.rs +++ b/src/ui/widget.rs @@ -13,7 +13,10 @@ use termion::event::Key; use ratatui::prelude::*; -use self::input::{TextAreaState, TextViewState}; +use self::{ + container::SectionGroupState, + input::{TextAreaState, TextViewState}, +}; pub type BoxedView = Box>; pub type UpdateCallback = fn(&S) -> ViewProps; @@ -69,6 +72,7 @@ pub enum ViewState { Tree(Vec), TextView(TextViewState), TextArea(TextAreaState), + SectionGroup(SectionGroupState), } impl ViewState { @@ -107,6 +111,13 @@ impl ViewState { } } + pub fn unwrap_section_group(&self) -> Option { + match self { + ViewState::SectionGroup(state) => Some(state.clone()), + _ => None, + } + } + pub fn unwrap_tree(&self) -> Option> { match self { ViewState::Tree(value) => Some(value.clone().to_vec()), @@ -119,14 +130,18 @@ impl ViewState { pub enum PredefinedLayout { #[default] None, - Expandable3, + Expandable3 { + left_only: bool, + }, } impl PredefinedLayout { pub fn split(&self, area: Rect) -> Rc<[Rect]> { match self { - Self::Expandable3 => { - if area.width <= 140 { + Self::Expandable3 { left_only } => { + if *left_only { + [area].into() + } else if area.width <= 140 { let [left, right] = Layout::horizontal([ Constraint::Percentage(50), Constraint::Percentage(50),