notedeck

One damus client to rule them all
git clone git://jb55.com/notedeck
Log | Files | Refs | README | LICENSE

commit 8467de2b5d8772ba291bc1526752402dccfdd106
parent 33f570678dce9eb57eda2007767d6a0ac14d24ca
Author: William Casarin <jb55@jb55.com>
Date:   Tue, 11 Mar 2025 10:45:26 -0700

android: attempt initial keyboard visibility fix

This isn't the right approach, but I keep it here as a reminder
of what we need to do next

Signed-off-by: William Casarin <jb55@jb55.com>

Diffstat:
Mcrates/notedeck/src/app.rs | 32+++++++++++++++++++++++++-------
Mcrates/notedeck/src/platform/mod.rs | 10++++++++++
2 files changed, 35 insertions(+), 7 deletions(-)

diff --git a/crates/notedeck/src/app.rs b/crates/notedeck/src/app.rs @@ -48,6 +48,30 @@ fn main_panel(style: &egui::Style) -> egui::CentralPanel { }) } +fn render_notedeck(notedeck: &mut Notedeck, ctx: &egui::Context) { + main_panel(&ctx.style()).show(ctx, |ui| { + // render app + let Some(app) = &notedeck.app else { + return; + }; + + let app = app.clone(); + app.borrow_mut().update(&mut notedeck.app_context(), ui); + + // Move the screen up when we have a virtual keyboard + // NOTE: actually, we only want to do this if the keyboard is covering the focused element? + /* + let keyboard_height = crate::platform::virtual_keyboard_height() as f32; + if keyboard_height > 0.0 { + ui.ctx().transform_layer_shapes( + ui.layer_id(), + egui::emath::TSTransform::from_translation(egui::Vec2::new(0.0, -(keyboard_height/2.0))), + ); + } + */ + }); +} + impl eframe::App for Notedeck { fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) { #[cfg(feature = "profiling")] @@ -56,13 +80,7 @@ impl eframe::App for Notedeck { // handle account updates self.accounts.update(&mut self.ndb, &mut self.pool, ctx); - main_panel(&ctx.style()).show(ctx, |ui| { - // render app - if let Some(app) = &self.app { - let app = app.clone(); - app.borrow_mut().update(&mut self.app_context(), ui); - } - }); + render_notedeck(self, ctx); self.zoom.try_save_zoom_factor(ctx); self.app_size.try_save_app_size(ctx); diff --git a/crates/notedeck/src/platform/mod.rs b/crates/notedeck/src/platform/mod.rs @@ -1,2 +1,12 @@ #[cfg(target_os = "android")] pub mod android; + +#[cfg(target_os = "android")] +pub fn virtual_keyboard_height() -> i32 { + android::virtual_keyboard_height() +} + +#[cfg(not(target_os = "android"))] +pub fn virtual_keyboard_height() -> i32 { + 0 +}