Added table function for generic table view creation
This commit is contained in:
parent
dd9d1c0c2f
commit
2401c2a4ec
3 changed files with 17 additions and 3 deletions
|
|
@ -6,8 +6,8 @@
|
||||||
use chrono::Datelike;
|
use chrono::Datelike;
|
||||||
use cosmic::app::{Core, Settings, Task};
|
use cosmic::app::{Core, Settings, Task};
|
||||||
use cosmic::iced_core::Size;
|
use cosmic::iced_core::Size;
|
||||||
use cosmic::widget::nav_bar;
|
|
||||||
use cosmic::widget::table;
|
use cosmic::widget::table;
|
||||||
|
use cosmic::widget::{self, nav_bar};
|
||||||
use cosmic::{executor, iced, Element};
|
use cosmic::{executor, iced, Element};
|
||||||
|
|
||||||
#[derive(Debug, Default, PartialEq, Eq, Clone, Copy)]
|
#[derive(Debug, Default, PartialEq, Eq, Clone, Copy)]
|
||||||
|
|
@ -194,12 +194,12 @@ impl cosmic::Application for App {
|
||||||
fn view(&self) -> Element<Self::Message> {
|
fn view(&self) -> Element<Self::Message> {
|
||||||
cosmic::widget::responsive(|size| {
|
cosmic::widget::responsive(|size| {
|
||||||
if size.width < 600.0 {
|
if size.width < 600.0 {
|
||||||
table::SingleSelectTableView::new(&self.table_model)
|
widget::table(&self.table_model)
|
||||||
.on_item_select(Message::ItemSelect)
|
.on_item_select(Message::ItemSelect)
|
||||||
.on_category_select(Message::CategorySelect)
|
.on_category_select(Message::CategorySelect)
|
||||||
.element_compact()
|
.element_compact()
|
||||||
} else {
|
} else {
|
||||||
table::SingleSelectTableView::new(&self.table_model)
|
widget::table(&self.table_model)
|
||||||
.on_item_select(Message::ItemSelect)
|
.on_item_select(Message::ItemSelect)
|
||||||
.on_category_select(Message::CategorySelect)
|
.on_category_select(Message::CategorySelect)
|
||||||
.element_standard()
|
.element_standard()
|
||||||
|
|
|
||||||
|
|
@ -316,6 +316,7 @@ pub use spin_button::{spin_button, vertical as vertical_spin_button, SpinButton}
|
||||||
pub mod tab_bar;
|
pub mod tab_bar;
|
||||||
|
|
||||||
pub mod table;
|
pub mod table;
|
||||||
|
pub use table::table;
|
||||||
|
|
||||||
pub mod text;
|
pub mod text;
|
||||||
#[doc(inline)]
|
#[doc(inline)]
|
||||||
|
|
|
||||||
|
|
@ -18,3 +18,16 @@ pub type SingleSelectModel<Item, Category> = Model<SingleSelect, Item, Category>
|
||||||
pub type MultiSelectTableView<'a, Item, Category, Message> =
|
pub type MultiSelectTableView<'a, Item, Category, Message> =
|
||||||
TableView<'a, MultiSelect, Item, Category, Message>;
|
TableView<'a, MultiSelect, Item, Category, Message>;
|
||||||
pub type MultiSelectModel<Item, Category> = Model<MultiSelect, Item, Category>;
|
pub type MultiSelectModel<Item, Category> = Model<MultiSelect, Item, Category>;
|
||||||
|
|
||||||
|
pub fn table<'a, SelectionMode, Item, Category, Message>(
|
||||||
|
model: &'a Model<SelectionMode, Item, Category>,
|
||||||
|
) -> TableView<'a, SelectionMode, Item, Category, Message>
|
||||||
|
where
|
||||||
|
Message: Clone,
|
||||||
|
SelectionMode: Default,
|
||||||
|
Category: ItemCategory,
|
||||||
|
Item: ItemInterface<Category>,
|
||||||
|
Model<SelectionMode, Item, Category>: model::selection::Selectable,
|
||||||
|
{
|
||||||
|
TableView::new(model)
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue