feat: add settings toggle button to hide/show toolbar buttons
This commit is contained in:
@@ -280,6 +280,9 @@ pub fn reading_view(
|
||||
let sidebar_tab_id = ui.make_persistent_id("sidebar_tab");
|
||||
let mut sidebar_tab: usize = ui.data_mut(|d| *d.get_temp_mut_or_default::<usize>(sidebar_tab_id));
|
||||
|
||||
let settings_visible_id = ui.make_persistent_id("settings_visible");
|
||||
let mut settings_visible: bool = ui.data_mut(|d| *d.get_temp_mut_or_default::<bool>(settings_visible_id));
|
||||
|
||||
if *sidebar_open {
|
||||
egui::SidePanel::left("toc_sidebar")
|
||||
.resizable(true)
|
||||
@@ -325,6 +328,11 @@ pub fn reading_view(
|
||||
ui.label(format!("《{}》", &book.title));
|
||||
ui.label(format!("[{}]", book.layout.label()));
|
||||
ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| {
|
||||
let toggle_label = if settings_visible { "⚙ ▲" } else { "⚙" };
|
||||
if ui.button(toggle_label).on_hover_text("显示/隐藏设置").clicked() {
|
||||
settings_visible = !settings_visible;
|
||||
}
|
||||
if settings_visible {
|
||||
let (theme_icon, theme_hint) = match theme {
|
||||
Theme::Dark => ("🌞", "切换到浅色主题"),
|
||||
Theme::Light => ("🌙", "切换到夜间主题"),
|
||||
@@ -355,7 +363,7 @@ pub fn reading_view(
|
||||
}
|
||||
}
|
||||
});
|
||||
egui::ComboBox::from_id_salt("bg_type_selector")
|
||||
egui::ComboBox::from_id_salt("bg_type_selector")
|
||||
.width(100.0)
|
||||
.selected_text(bg_type.label())
|
||||
.show_ui(ui, |ui| {
|
||||
@@ -377,6 +385,7 @@ egui::ComboBox::from_id_salt("bg_type_selector")
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
if ui.button("☰").on_hover_text("打开/关闭目录").clicked() {
|
||||
*sidebar_open = !*sidebar_open;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user