diff --git a/crates/notedeck/src/app.rs b/crates/notedeck/src/app.rs index bc02e2af..2715ea50 100644 --- 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) = ¬edeck.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 index fd704ab0..7c425a35 100644 --- 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 +}