bin: Use trait for properties

This commit is contained in:
Erik Kundt
2024-04-17 15:23:06 +02:00
parent ab6584f6b7
commit 4f29b65060
3 changed files with 16 additions and 9 deletions
+8 -5
View File
@@ -20,8 +20,8 @@ use tui::ui::widget::input::{TextField, TextFieldProps};
use tui::ui::widget::text::{Paragraph, ParagraphProps};
use tui::ui::widget::{self, TableUtils};
use tui::ui::widget::{
Column, EventCallback, Shortcuts, ShortcutsProps, Table, TableProps, UpdateCallback, View,
Widget,
Column, EventCallback, Properties, Shortcuts, ShortcutsProps, Table, TableProps,
UpdateCallback, View, Widget,
};
use tui::Selection;
@@ -214,6 +214,8 @@ impl<'a> From<&State> for NotificationsProps<'a> {
}
}
impl<'a> Properties for NotificationsProps<'a> {}
struct Notifications<'a, B: Backend> {
/// Internal properties
props: NotificationsProps<'a>,
@@ -273,14 +275,13 @@ where
.on_update(|state| {
let props = NotificationsProps::from(state);
Box::<TableProps<'_, NotificationItem>>::new(
TableProps::default()
.columns(props.columns)
.items(state.notifications())
.footer(!state.ui.show_search)
.page_size(state.ui.page_size)
.cutoff(props.cutoff, props.cutoff_after),
)
.cutoff(props.cutoff, props.cutoff_after)
.to_boxed()
}),
),
footer: Footer::new(state, action_tx).to_boxed(),
@@ -689,6 +690,8 @@ impl<'a> From<&State> for HelpProps<'a> {
}
}
impl<'a> Properties for HelpProps<'a> {}
pub struct Help<'a, B: Backend> {
/// Internal properties
props: HelpProps<'a>,
+2 -2
View File
@@ -22,8 +22,8 @@ use tui::ui::widget::input::{TextField, TextFieldProps};
use tui::ui::widget::text::{Paragraph, ParagraphProps};
use tui::ui::widget::{self, TableUtils};
use tui::ui::widget::{
Column, EventCallback, Shortcuts, ShortcutsProps, Table, TableProps, UpdateCallback, View,
Widget,
Column, EventCallback, Properties, Shortcuts, ShortcutsProps, Table, TableProps,
UpdateCallback, View, Widget,
};
use tui::Selection;
+6 -2
View File
@@ -23,8 +23,8 @@ use tui::ui::widget::input::{TextField, TextFieldProps};
use tui::ui::widget::text::{Paragraph, ParagraphProps};
use tui::ui::widget::{self, TableUtils};
use tui::ui::widget::{
Column, EventCallback, Shortcuts, ShortcutsProps, Table, TableProps, UpdateCallback, View,
Widget,
Column, EventCallback, Properties, Shortcuts, ShortcutsProps, Table, TableProps,
UpdateCallback, View, Widget,
};
use tui::Selection;
@@ -228,6 +228,8 @@ impl<'a> From<&State> for PatchesProps<'a> {
}
}
impl<'a> Properties for PatchesProps<'a> {}
struct Patches<'a, B> {
/// Internal properties
props: PatchesProps<'a>,
@@ -750,6 +752,8 @@ impl<'a> From<&State> for HelpProps<'a> {
}
}
impl<'a> Properties for HelpProps<'a> {}
pub struct Help<'a, B: Backend> {
/// Internal properties
props: HelpProps<'a>,