diff --git a/src/app_creation.rs b/src/app_creation.rs index db74bac..425f96d 100644 --- a/src/app_creation.rs +++ b/src/app_creation.rs @@ -1,6 +1,6 @@ use crate::{ app_size_handler::AppSizeHandler, - app_style::{create_custom_style, dark_mode, desktop_font_size, light_mode, mobile_font_size}, + app_style::{add_custom_style, dark_mode, light_mode}, fonts::setup_fonts, storage::DataPath, }; @@ -79,9 +79,5 @@ pub fn setup_cc(ctx: &egui::Context, is_mobile: bool, light: bool) { ctx.set_visuals(dark_mode(is_mobile)); } - ctx.set_style(if is_mobile { - create_custom_style(ctx, mobile_font_size) - } else { - create_custom_style(ctx, desktop_font_size) - }); + ctx.all_styles_mut(|style| add_custom_style(is_mobile, style)); } diff --git a/src/app_style.rs b/src/app_style.rs index 1798a3e..86fc85d 100644 --- a/src/app_style.rs +++ b/src/app_style.rs @@ -6,7 +6,7 @@ use crate::{ use egui::{ epaint::Shadow, style::{Interaction, Selection, WidgetVisuals, Widgets}, - Button, Context, FontFamily, FontId, Rounding, Stroke, Style, TextStyle, Ui, Visuals, + Button, FontFamily, FontId, Rounding, Stroke, Style, TextStyle, Ui, Visuals, }; use strum::IntoEnumIterator; use strum_macros::EnumIter; @@ -52,9 +52,12 @@ pub fn user_requested_visuals_change( } /// Create custom text sizes for any FontSizes -pub fn create_custom_style(ctx: &Context, font_size: fn(&NotedeckTextStyle) -> f32) -> Style { - let mut style = (*ctx.style()).clone(); - +pub fn add_custom_style(is_mobile: bool, style: &mut Style) { + let font_size = if is_mobile { + mobile_font_size + } else { + desktop_font_size + }; style.text_styles = NotedeckTextStyle::iter() .map(|text_style| { ( @@ -75,8 +78,6 @@ pub fn create_custom_style(ctx: &Context, font_size: fn(&NotedeckTextStyle) -> f style.debug.show_interactive_widgets = true; style.debug.debug_on_hover_with_all_modifiers = true; } - - style } pub fn desktop_font_size(text_style: &NotedeckTextStyle) -> f32 {