-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
1,337 additions
and
687 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
use dioxus::prelude::*; | ||
|
||
#[component] | ||
pub fn Commands( | ||
max_page: usize, | ||
nb_loaded_pages: ReadOnlySignal<usize>, | ||
current_page: Signal<usize>, | ||
on_prev_page_request: EventHandler, | ||
on_next_page_request: EventHandler, | ||
) -> Element { | ||
rsx! { | ||
div { class: "flex flex-row items-center justify-center gap-1 h-8 mb-2", | ||
button { | ||
class: "btn btn-outline-primary btn-sm", | ||
onclick: move |_evt| on_prev_page_request.call(()), | ||
"Prev" | ||
} | ||
span { class: "flex flex-row items-center justify-center bg-backgroundSecondary h-8 px-2 rounded-sm", | ||
"{current_page} / {nb_loaded_pages}" | ||
} | ||
button { | ||
class: "btn btn-outline-primary btn-sm", | ||
onclick: move |_evt| on_next_page_request.call(()), | ||
"Next" | ||
} | ||
} | ||
div { class: "w-full flex flex-row items-center justify-center gap-1 h-8 mb-2", | ||
input { | ||
class: "w-11/12", | ||
r#type: "range", | ||
min: "1", | ||
value: "{current_page}", | ||
max: "{max_page}", | ||
oninput: move |evt| { current_page.set(evt.value().parse().unwrap_or(1)) } | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,23 @@ | ||
use dioxus::prelude::*; | ||
|
||
use crate::doc::{Doc, SharedDoc}; | ||
use crate::FileType; | ||
|
||
#[allow(clippy::module_name_repetitions)] | ||
#[derive(Props)] | ||
pub struct DocPageProps<'a> { | ||
doc: SharedDoc, | ||
content: &'a str, | ||
} | ||
|
||
pub fn DocPage<'a, 'b: 'a>(cx: Scope<'a, DocPageProps<'b>>) -> Element<'a> { | ||
let content = cx.props.content; | ||
#[component] | ||
pub fn DocPage(content: ReadOnlySignal<String>) -> Element { | ||
let file_type = use_context::<FileType>(); | ||
|
||
match *cx.props.doc.lock().unwrap() { | ||
Doc::Cbz { .. } => cx.render(rsx!(img { | ||
match file_type { | ||
FileType::Cbz => rsx!(img { | ||
class: "h-px grow", | ||
src: "data:image/png;base64,{content}" | ||
})), | ||
Doc::Epub { .. } => cx.render(rsx!(div { | ||
class: "h-px grow spect-[12/16]", | ||
iframe { | ||
class: "h-full w-full", | ||
src: "data:text/html;charset=utf-8,{content}" | ||
}), | ||
FileType::Epub => rsx!( | ||
div { class: "h-px grow spect-[12/16]", | ||
iframe { | ||
class: "h-full w-full", | ||
src: "data:text/html;charset=utf-8,{content}" | ||
} | ||
} | ||
})), | ||
), | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
pub mod commands; | ||
pub mod doc_page; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.