lib: Improve boxed property conversion

This commit is contained in:
Erik Kundt
2024-04-20 18:11:13 +02:00
parent e2346edc6f
commit 86811000e8
4 changed files with 7 additions and 7 deletions
+2 -2
View File
@@ -193,7 +193,7 @@ where
use ratatui::widgets::Table;
let props = props
.and_then(|props| ShortcutsProps::from_boxed_any(props))
.and_then(ShortcutsProps::from_boxed_any)
.unwrap_or(self.props.clone());
let mut shortcuts = props.shortcuts.iter().peekable();
@@ -471,7 +471,7 @@ where
{
fn render(&self, frame: &mut ratatui::Frame, area: Rect, props: Option<Box<dyn Any>>) {
let props = props
.and_then(|props| TableProps::<'_, R>::from_boxed_any(props))
.and_then(TableProps::<'_, R>::from_boxed_any)
.unwrap_or(self.props.clone());
let widths: Vec<Constraint> = self
+3 -3
View File
@@ -121,7 +121,7 @@ where
{
fn render(&self, frame: &mut ratatui::Frame, area: Rect, props: Option<Box<dyn Any>>) {
let props = props
.and_then(|props| HeaderProps::from_boxed_any(props))
.and_then(HeaderProps::from_boxed_any)
.unwrap_or(self.props.clone());
let widths: Vec<Constraint> = props
@@ -309,7 +309,7 @@ where
{
fn render(&self, frame: &mut ratatui::Frame, area: Rect, props: Option<Box<dyn Any>>) {
let props = props
.and_then(|props| FooterProps::from_boxed_any(props))
.and_then(FooterProps::from_boxed_any)
.unwrap_or(self.props.clone());
let widths = props
@@ -465,7 +465,7 @@ where
{
fn render(&self, frame: &mut ratatui::Frame, area: Rect, props: Option<Box<dyn Any>>) {
let props = props
.and_then(|props| ContainerProps::from_boxed_any(props))
.and_then(ContainerProps::from_boxed_any)
.unwrap_or(self.props.clone());
let header_h = if self.header.is_some() { 3 } else { 0 };
+1 -1
View File
@@ -200,7 +200,7 @@ where
{
fn render(&self, frame: &mut ratatui::Frame, area: Rect, props: Option<Box<dyn Any>>) {
let props = props
.and_then(|props| TextFieldProps::from_boxed_any(props))
.and_then(TextFieldProps::from_boxed_any)
.unwrap_or(self.props.clone());
let layout = Layout::vertical(Constraint::from_lengths([1, 1])).split(area);
+1 -1
View File
@@ -218,7 +218,7 @@ where
{
fn render(&self, frame: &mut ratatui::Frame, area: Rect, props: Option<Box<dyn Any>>) {
let props = props
.and_then(|props| ParagraphProps::from_boxed_any(props))
.and_then(ParagraphProps::from_boxed_any)
.unwrap_or(self.props.clone());
let [content_area] = Layout::horizontal([Constraint::Min(1)])