fix crash on AccountsView
It appears that Context::set_style doesn't keep the style changes from the Damus constructor to the update method, but `Context::all_styles_mut` does Closes: https://github.com/damus-io/notedeck/issues/555 Closes: https://github.com/damus-io/notedeck/pull/560 Signed-off-by: kernelkind <kernelkind@gmail.com> Signed-off-by: William Casarin <jb55@jb55.com>
This commit is contained in:
committed by
William Casarin
parent
35138cd951
commit
a24bd4cc43
@@ -1,6 +1,6 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
app_size_handler::AppSizeHandler,
|
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,
|
fonts::setup_fonts,
|
||||||
storage::DataPath,
|
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_visuals(dark_mode(is_mobile));
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx.set_style(if is_mobile {
|
ctx.all_styles_mut(|style| add_custom_style(is_mobile, style));
|
||||||
create_custom_style(ctx, mobile_font_size)
|
|
||||||
} else {
|
|
||||||
create_custom_style(ctx, desktop_font_size)
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ use crate::{
|
|||||||
use egui::{
|
use egui::{
|
||||||
epaint::Shadow,
|
epaint::Shadow,
|
||||||
style::{Interaction, Selection, WidgetVisuals, Widgets},
|
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::IntoEnumIterator;
|
||||||
use strum_macros::EnumIter;
|
use strum_macros::EnumIter;
|
||||||
@@ -52,9 +52,12 @@ pub fn user_requested_visuals_change(
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Create custom text sizes for any FontSizes
|
/// Create custom text sizes for any FontSizes
|
||||||
pub fn create_custom_style(ctx: &Context, font_size: fn(&NotedeckTextStyle) -> f32) -> Style {
|
pub fn add_custom_style(is_mobile: bool, style: &mut Style) {
|
||||||
let mut style = (*ctx.style()).clone();
|
let font_size = if is_mobile {
|
||||||
|
mobile_font_size
|
||||||
|
} else {
|
||||||
|
desktop_font_size
|
||||||
|
};
|
||||||
style.text_styles = NotedeckTextStyle::iter()
|
style.text_styles = NotedeckTextStyle::iter()
|
||||||
.map(|text_style| {
|
.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.show_interactive_widgets = true;
|
||||||
style.debug.debug_on_hover_with_all_modifiers = true;
|
style.debug.debug_on_hover_with_all_modifiers = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
style
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn desktop_font_size(text_style: &NotedeckTextStyle) -> f32 {
|
pub fn desktop_font_size(text_style: &NotedeckTextStyle) -> f32 {
|
||||||
|
|||||||
Reference in New Issue
Block a user