Improve style of properties

This commit is contained in:
Jeremy Soller 2024-01-05 14:58:50 -07:00
parent b8239ce608
commit 5806c420a8
No known key found for this signature in database
GPG key ID: DCFCA852D3906975
2 changed files with 41 additions and 34 deletions

View file

@ -242,7 +242,7 @@ impl App {
if let Some(ref items) = tab.items_opt { if let Some(ref items) = tab.items_opt {
for item in items.iter() { for item in items.iter() {
if item.select_time.is_some() { if item.select_time.is_some() {
children.push(item.property_view()); children.push(item.property_view(&self.core));
} }
} }
} }
@ -359,6 +359,10 @@ impl Application for App {
if let Some(ref mut items) = tab.items_opt { if let Some(ref mut items) = tab.items_opt {
let select_time = Instant::now(); let select_time = Instant::now();
for item in items.iter_mut() { for item in items.iter_mut() {
if item.hidden {
//TODO: option to show hidden files
continue;
}
item.select_time = Some(select_time); item.select_time = Some(select_time);
} }
} }

View file

@ -231,14 +231,14 @@ pub struct Item {
} }
impl Item { impl Item {
pub fn property_view(&self) -> Element<crate::Message> { pub fn property_view(&self, core: &Core) -> Element<crate::Message> {
let mut children = Vec::new(); let mut section = widget::settings::view_section("");
children.push( section = section.add(widget::settings::item::item_row(vec![
widget::icon::icon(self.icon_handle_grid.clone()) widget::icon::icon(self.icon_handle_list.clone())
.size(ICON_SIZE_GRID) .size(ICON_SIZE_LIST)
.into(), .into(),
); widget::text(self.name.clone()).into(),
children.push(widget::text(self.name.clone()).into()); ]));
//TODO: translate! //TODO: translate!
//TODO: correct display of folder size? //TODO: correct display of folder size?
@ -262,43 +262,46 @@ impl Item {
} }
} }
children section = section.add(widget::settings::item::item(
.push(widget::text(format!("Size: {}", format_size(self.metadata.len()))).into()); "Size",
widget::text(format_size(self.metadata.len())),
));
} }
if let Ok(time) = self.metadata.accessed() { if let Ok(time) = self.metadata.accessed() {
children.push( section = section.add(widget::settings::item(
widget::text(format!( "Accessed",
"Accessed: {}", widget::text(
chrono::DateTime::<chrono::Local>::from(time).format("%c") chrono::DateTime::<chrono::Local>::from(time)
)) .format("%c")
.into(), .to_string(),
); ),
));
} }
if let Ok(time) = self.metadata.modified() { if let Ok(time) = self.metadata.modified() {
children.push( section = section.add(widget::settings::item(
widget::text(format!( "Modified",
"Modified: {}", widget::text(
chrono::DateTime::<chrono::Local>::from(time).format("%c") chrono::DateTime::<chrono::Local>::from(time)
)) .format("%c")
.into(), .to_string(),
); ),
));
} }
if let Ok(time) = self.metadata.created() { if let Ok(time) = self.metadata.created() {
children.push( section = section.add(widget::settings::item(
widget::text(format!( "Created",
"Created: {}", widget::text(
chrono::DateTime::<chrono::Local>::from(time).format("%c") chrono::DateTime::<chrono::Local>::from(time)
)) .format("%c")
.into(), .to_string(),
); ),
));
} }
widget::column::with_children(children) section.into()
.width(Length::Fill)
.into()
} }
} }