making a subtext that uses the path of the background
This commit is contained in:
parent
d29e3b0dff
commit
a8f7651164
|
@ -1,7 +1,10 @@
|
|||
use crate::Background;
|
||||
|
||||
use super::{kinds::ServiceItemKind, service_items::ServiceItem};
|
||||
|
||||
pub trait Content {
|
||||
fn title(&self) -> String;
|
||||
fn kind(&self) -> ServiceItemKind;
|
||||
fn to_service_item(&self) -> ServiceItem;
|
||||
fn background(&self) -> Option<Background>;
|
||||
}
|
||||
|
|
|
@ -40,6 +40,16 @@ impl Content for Image {
|
|||
fn to_service_item(&self) -> super::service_items::ServiceItem {
|
||||
self.into()
|
||||
}
|
||||
|
||||
fn background(&self) -> Option<Background> {
|
||||
if let Ok(background) =
|
||||
Background::try_from(self.path.clone())
|
||||
{
|
||||
Some(background)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Value> for Image {
|
||||
|
|
|
@ -54,6 +54,16 @@ impl Content for Presentation {
|
|||
fn to_service_item(&self) -> super::service_items::ServiceItem {
|
||||
self.into()
|
||||
}
|
||||
|
||||
fn background(&self) -> Option<Background> {
|
||||
if let Ok(background) =
|
||||
Background::try_from(self.path.clone())
|
||||
{
|
||||
Some(background)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Value> for Presentation {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use std::{collections::HashMap, path::PathBuf};
|
||||
use std::{collections::HashMap, option::Option, path::PathBuf};
|
||||
|
||||
use cosmic::iced::Executor;
|
||||
use crisp::types::{Keyword, Symbol, Value};
|
||||
|
@ -54,6 +54,10 @@ impl Content for Song {
|
|||
fn to_service_item(&self) -> super::service_items::ServiceItem {
|
||||
self.into()
|
||||
}
|
||||
|
||||
fn background(&self) -> Option<Background> {
|
||||
self.background.clone()
|
||||
}
|
||||
}
|
||||
|
||||
impl ServiceTrait for Song {
|
||||
|
|
|
@ -45,6 +45,16 @@ impl Content for Video {
|
|||
fn to_service_item(&self) -> super::service_items::ServiceItem {
|
||||
self.into()
|
||||
}
|
||||
|
||||
fn background(&self) -> Option<Background> {
|
||||
if let Ok(background) =
|
||||
Background::try_from(self.path.clone())
|
||||
{
|
||||
Some(background)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Value> for Video {
|
||||
|
|
|
@ -265,8 +265,24 @@ impl Library {
|
|||
}
|
||||
}
|
||||
});
|
||||
let subtext = container(responsive(|size| {
|
||||
let background = if let Some(text) = item.background() {
|
||||
text.path.to_string_lossy().to_string()
|
||||
} else {
|
||||
"Background does not exist...".to_string()
|
||||
};
|
||||
text::body(elide_text(background, size.width))
|
||||
.center()
|
||||
.wrapping(textm::Wrapping::None)
|
||||
.into()
|
||||
}))
|
||||
.center_y(25)
|
||||
.center_x(Length::Fill);
|
||||
|
||||
let texts = column([text.into(), subtext.into()]);
|
||||
|
||||
Container::new(
|
||||
rowm![horizontal_space().width(0), icon, text]
|
||||
rowm![horizontal_space().width(0), icon, texts]
|
||||
.spacing(10)
|
||||
.align_y(Vertical::Center),
|
||||
)
|
||||
|
|
Loading…
Reference in a new issue