notedeck

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

commit dbc56ac09810cde15cf74312b6a64f941a01960b
parent 12a6c647788c3e1433e9b4aed9fd0bae5d720fe4
Author: William Casarin <jb55@jb55.com>
Date:   Wed, 15 May 2024 18:01:04 -0700

mobile: simplify is_mobile

we don't need context anymore

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

Diffstat:
Msrc/app.rs | 4++--
Msrc/app_creation.rs | 4++--
Msrc/ui/account_login_view.rs | 2+-
Msrc/ui/account_management.rs | 2+-
Msrc/ui/mod.rs | 3+--
Msrc/ui/note/mod.rs | 2+-
6 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/app.rs b/src/app.rs @@ -413,7 +413,7 @@ fn process_message(damus: &mut Damus, relay: &str, msg: &RelayMessage) { } fn render_damus(damus: &mut Damus, ctx: &Context) { - if is_mobile(ctx) { + if is_mobile() { render_damus_mobile(ctx, damus); } else { render_damus_desktop(ctx, damus); @@ -557,7 +557,7 @@ fn render_panel(ctx: &egui::Context, app: &mut Damus, timeline_ind: usize) { ui.visuals_mut().button_frame = false; if let Some(new_visuals) = - user_requested_visuals_change(is_mobile(ctx), ctx.style().visuals.dark_mode, ui) + user_requested_visuals_change(is_mobile(), ctx.style().visuals.dark_mode, ui) { ctx.set_visuals(new_visuals) } diff --git a/src/app_creation.rs b/src/app_creation.rs @@ -48,9 +48,9 @@ pub fn setup_cc(cc: &eframe::CreationContext<'_>) { egui_extras::install_image_loaders(ctx); - ctx.set_visuals(dark_mode(is_mobile(ctx))); + ctx.set_visuals(dark_mode(is_mobile())); - ctx.set_style(if is_mobile(ctx) { + ctx.set_style(if is_mobile() { create_custom_style(ctx, mobile_font_size) } else { create_custom_style(ctx, desktop_font_size) diff --git a/src/ui/account_login_view.rs b/src/ui/account_login_view.rs @@ -16,7 +16,7 @@ pub struct AccountLoginView<'a> { impl<'a> View for AccountLoginView<'a> { fn ui(&mut self, ui: &mut egui::Ui) { - let is_mobile = ui::is_mobile(ui.ctx()); + let is_mobile = ui::is_mobile(); if let Some(key) = self.manager.check_for_successful_login() { // TODO: route to "home" println!("successful login with key: {:?}", key); diff --git a/src/ui/account_management.rs b/src/ui/account_management.rs @@ -16,7 +16,7 @@ pub struct AccountManagementView<'a> { impl<'a> View for AccountManagementView<'a> { fn ui(&mut self, ui: &mut egui::Ui) { - if ui::is_mobile(ui.ctx()) { + if ui::is_mobile() { self.show_mobile(ui); } else { self.show(ui); diff --git a/src/ui/mod.rs b/src/ui/mod.rs @@ -48,8 +48,7 @@ pub fn hline(ui: &egui::Ui) { } #[inline] -#[allow(unreachable_code)] -pub fn is_mobile(_ctx: &egui::Context) -> bool { +pub fn is_mobile() -> bool { #[cfg(feature = "emulate_mobile")] { return true; diff --git a/src/ui/note/mod.rs b/src/ui/note/mod.rs @@ -207,7 +207,7 @@ impl<'a> Note<'a> { let profile_key = profile.as_ref().unwrap().record().note_key(); let note_key = note_key.as_u64(); - if is_mobile(ui.ctx()) { + if is_mobile() { ui.add(ui::ProfilePic::new(&mut self.app.img_cache, pic)); } else { let (rect, size) = ui::anim::hover_expand(