2025-07-19 20:42:07 -04:00
|
|
|
use crate::db::FeedItem;
|
|
|
|
|
2025-07-03 20:57:37 -04:00
|
|
|
use super::db;
|
|
|
|
use super::ui;
|
2025-07-19 20:42:07 -04:00
|
|
|
use iced::widget::scrollable;
|
|
|
|
use rss_content::Content;
|
2025-07-03 20:57:37 -04:00
|
|
|
use ui::Message;
|
2025-07-19 20:42:07 -04:00
|
|
|
use rss_content;
|
2025-07-03 20:57:37 -04:00
|
|
|
use iced::{
|
|
|
|
widget::{button, column, container, text},
|
|
|
|
Element,
|
|
|
|
};
|
|
|
|
|
|
|
|
pub fn list_feeds() -> iced::widget::Column<'static, Message> {
|
|
|
|
let feeds = db::get_feeds();
|
|
|
|
column(
|
|
|
|
feeds
|
|
|
|
.iter()
|
|
|
|
.map(|f| {
|
|
|
|
button(text(f.title.clone())).on_press(Message::LoadFeed(f.feed_id))
|
|
|
|
})
|
|
|
|
.map(Element::from),
|
|
|
|
)
|
|
|
|
.align_x(iced::Alignment::Start)
|
|
|
|
.spacing(5)
|
2025-07-04 11:38:49 -04:00
|
|
|
.padding(15)
|
2025-07-03 20:57:37 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
pub fn list_items(feed_id: usize) -> iced::widget::Column<'static,Message> {
|
|
|
|
let items: Vec<db::FeedItem> = db::get_feed_items(feed_id);
|
|
|
|
column(
|
|
|
|
items.iter()
|
|
|
|
.map(|i| {
|
2025-07-19 20:42:07 -04:00
|
|
|
button(text(i.title.clone())).on_press(Message::LoadItem(i.item_id))
|
2025-07-03 20:57:37 -04:00
|
|
|
})
|
|
|
|
.map(Element::from),
|
|
|
|
)
|
|
|
|
.align_x(iced::Alignment::Start)
|
|
|
|
.spacing(5)
|
2025-07-04 11:38:49 -04:00
|
|
|
.padding(15)
|
2025-07-19 20:42:07 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
pub fn content_area(cnt: String) -> iced::widget::Container<'static,Message>{
|
|
|
|
let content = rss_content::parse_content(&cnt);
|
|
|
|
container(
|
|
|
|
column(
|
|
|
|
content.into_iter().map(|c: Content|{
|
|
|
|
match c {
|
|
|
|
Content::Markdown(md) => {
|
|
|
|
text(md)
|
|
|
|
},
|
|
|
|
Content::Image(_) => {text("Image goes here")},
|
|
|
|
Content::Audio(_) => {text("Audio widget here")},
|
|
|
|
Content::Video(_) => {text("video player here")},
|
|
|
|
_ => {text("")}
|
|
|
|
}
|
|
|
|
}).map(Element::from)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn content_view(item: FeedItem) -> iced::widget::Scrollable<'static, Message> {
|
|
|
|
|
|
|
|
scrollable(
|
|
|
|
column!(
|
|
|
|
text(item.title).size(34),
|
|
|
|
match item.description {
|
|
|
|
Some(d) => {
|
|
|
|
content_area(d)
|
|
|
|
},
|
|
|
|
None => {container(text("No description found"))}
|
|
|
|
},
|
|
|
|
match item.content {
|
|
|
|
Some(c) => {
|
|
|
|
content_area(c)
|
|
|
|
}
|
|
|
|
None => {container(text("No content found"))}
|
|
|
|
}
|
|
|
|
|
|
|
|
)
|
|
|
|
)
|
2025-07-03 20:57:37 -04:00
|
|
|
}
|