Changed the file structure

This commit is contained in:
Eduardo Flores 2022-10-12 19:44:44 -07:00 committed by Michael Murphy
parent 7743d0d084
commit 420d3c3dfc
22 changed files with 409 additions and 395 deletions

View file

@ -1,6 +1,6 @@
use std::vec;
use crate::list_box_row;
use crate::{list_box_row, widget::ListRow};
use apply::Apply;
use derive_setters::Setters;
use iced::{
@ -20,7 +20,7 @@ pub struct Expander<'a, Message> {
icon: Option<String>,
expansible: bool,
#[setters(skip)]
rows: Option<Vec<ExpanderRow<'a>>>,
rows: Option<Vec<ListRow<'a>>>,
#[setters(strip_option)]
on_row_selected: Option<Box<dyn Fn(usize) -> Message + 'a>>,
}
@ -36,23 +36,6 @@ pub fn expander<'a, Message>() -> Expander<'a, Message> {
}
}
#[derive(Setters, Default, Debug, Clone)]
pub struct ExpanderRow<'a> {
pub(crate) title: &'a str,
#[setters(strip_option)]
pub subtitle: Option<&'a str>,
#[setters(strip_option)]
pub icon: Option<String>,
}
pub fn expander_row<'a>() -> ExpanderRow<'a> {
ExpanderRow {
title: "",
subtitle: None,
icon: None,
}
}
pub struct ExpanderState {
pub expanded: bool,
}
@ -70,13 +53,13 @@ pub enum ExpanderEvent {
}
impl<'a, Message> Expander<'a, Message> {
pub fn rows(mut self, rows: Vec<ExpanderRow<'a>>) -> Self {
pub fn rows(mut self, rows: Vec<ListRow<'a>>) -> Self {
self.rows = Some(rows);
self.expansible = true;
self
}
pub fn push(&mut self, row: ExpanderRow<'a>) {
pub fn push(&mut self, row: ListRow<'a>) {
if self.rows.is_none() {
self.rows = Some(vec![])
}