add some debug stuff

This commit is contained in:
SadlyNotSappho 2023-09-15 11:26:10 -07:00
parent 340f3572d5
commit fe00127925
1 changed files with 17 additions and 6 deletions

View File

@ -1,9 +1,9 @@
use clap::Parser;
use ggg::{current_page, get_home, read_config};
use ggg::{current_page, get_home, read_config, update_latest_date};
use iced::widget::{button, column, container, image, row, text};
use iced::{Application, Command, Element, Length, Theme, Settings};
use iced::{Application, Command, Element, Length, Settings, Theme};
#[derive(Parser, Debug)]
#[command(author, version, about, long_about = None)]
@ -85,10 +85,11 @@ impl Application for Reader {
Reader::Loading => column![text("Loading...").size(40),].width(Length::Shrink),
Reader::Loaded { page } => column![
page.view(),
text(page.date.clone()),
row![
// TODO: make these disable/enable if page.next and page.prev are false
button("Next").on_press(Message::NextPage),
button("Prev").on_press(Message::PreviousPage),
button("Next").on_press(Message::NextPage),
]
.spacing(20)
.align_items(iced::Alignment::Center)
@ -109,6 +110,7 @@ impl Application for Reader {
#[derive(Debug, Clone)]
struct Book {
image: image::Handle,
date: String,
// see above todo
next: bool,
prev: bool,
@ -126,14 +128,17 @@ impl Book {
let config = read_config(&args.config_file[..]);
let page = current_page(&config).await;
let date = page.date;
let image = image::Handle::from_path(format!(
"{}/images/{}.jpg",
config.cache_folder.replace('~', &get_home()),
ggg::link_to_datestring(page.date)
ggg::link_to_datestring(date.clone())
));
Book {
image,
date: date.clone(),
next: page.next_page.is_some(),
prev: page.prev_page.is_some(),
}
@ -146,11 +151,14 @@ impl Book {
let image = image::Handle::from_path(format!(
"{}/images/{}.jpg",
config.cache_folder.replace('~', &get_home()),
ggg::link_to_datestring(page.date)
ggg::link_to_datestring(page.date.clone())
));
update_latest_date(&args.config_file, page.date.clone());
Book {
image,
date: page.date.clone(),
next: page.next_page.is_some(),
prev: page.prev_page.is_some(),
}
@ -164,11 +172,14 @@ impl Book {
let image = image::Handle::from_path(format!(
"{}/images/{}.jpg",
config.cache_folder.replace('~', &get_home()),
ggg::link_to_datestring(page.date)
ggg::link_to_datestring(page.date.clone())
));
update_latest_date(&args.config_file, page.date.clone());
Book {
image,
date: page.date.clone(),
next: page.next_page.is_some(),
prev: page.prev_page.is_some(),
}