-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Upload images #662
Upload images #662
Conversation
c625315
to
8ca5d35
Compare
Subject: [PATCH notedeck 5/8] use rfd for desktop file selection
Rusty File Dialogs is a cross platform Rust library for using native file open/save dialogs. It provides both asynchronous and synchronous APIs. Supported platforms:
Windows
macOS
Linux & BSDs (GTK3 or XDG Desktop Portal)
WASM32 (async only)
Kind of sucks we're moving further away from android portability which I
wanted to launch soon. I guess we need some code to disable this on
android for now?
|
On Sun, Jan 19, 2025 at 08:37:20PM GMT, kernelkind wrote:
Signed-off-by: kernelkind ***@***.***>
---
assets/icons/media_upload_dark_4x.png | Bin 0 -> 1501 bytes
crates/notedeck_columns/src/ui/note/post.rs | 41 ++++++++++++++++++++
2 files changed, 41 insertions(+)
create mode 100644 assets/icons/media_upload_dark_4x.png
Reviewed-by: William Casarin ***@***.***>
…diff --git a/crates/notedeck_columns/src/ui/note/post.rs b/crates/notedeck_columns/src/ui/note/post.rs
index cd6c3618..5ed7870e 100644
--- a/crates/notedeck_columns/src/ui/note/post.rs
+++ b/crates/notedeck_columns/src/ui/note/post.rs
@@ -203,6 +203,15 @@ impl<'a> PostView<'a> {
});
}
+ ui.with_layout(
+ egui::Layout::left_to_right(egui::Align::BOTTOM),
+ |ui| {
+ if ui.add(media_upload_button()).clicked() {
+ // TODO: implement media upload
+ }
+ },
+ );
+
ui.with_layout(egui::Layout::right_to_left(egui::Align::BOTTOM), |ui| {
if ui
.add_sized(
@@ -252,6 +261,38 @@ fn post_button(interactive: bool) -> impl egui::Widget {
}
}
+fn media_upload_button() -> impl egui::Widget {
+ |ui: &mut egui::Ui| -> egui::Response {
+ let resp = ui.allocate_response(egui::vec2(32.0, 32.0), egui::Sense::click());
+ let painter = ui.painter();
+ let (fill_color, stroke) = if resp.hovered() {
+ (
+ ui.visuals().widgets.hovered.bg_fill,
+ ui.visuals().widgets.hovered.bg_stroke,
+ )
+ } else if resp.clicked() {
+ (
+ ui.visuals().widgets.active.bg_fill,
+ ui.visuals().widgets.active.bg_stroke,
+ )
+ } else {
+ (
+ ui.visuals().widgets.inactive.bg_fill,
+ ui.visuals().widgets.inactive.bg_stroke,
+ )
+ };
+
+ painter.rect_filled(resp.rect, 8.0, fill_color);
+ painter.rect_stroke(resp.rect, 8.0, stroke);
+ egui::Image::new(egui::include_image!(
+ "../../../../../assets/icons/media_upload_dark_4x.png"
+ ))
+ .max_size(egui::vec2(16.0, 16.0))
+ .paint_at(ui, resp.rect.shrink(8.0));
+ resp
+ }
+}
+
mod preview {
use super::*;
use notedeck::{App, AppContext};
|
man I hate github reviews. gotta start a nip34 notedeck app soon |
Yeah I conditionally use rfd to select media for desktop here but I can also add the condition to only compile rfd for those same targets. I can add a way to select files for android next |
Signed-off-by: kernelkind <[email protected]>
Signed-off-by: kernelkind <[email protected]>
Signed-off-by: kernelkind <[email protected]>
Signed-off-by: kernelkind <[email protected]>
Signed-off-by: kernelkind <[email protected]>
Signed-off-by: kernelkind <[email protected]>
Signed-off-by: kernelkind <[email protected]>
Signed-off-by: kernelkind <[email protected]>
8ca5d35
to
7abf1c9
Compare
and rebased with master |
closes: #168