Split status UI into focused menu modules

This commit is contained in:
Samuel Onoja committed 2026-10-01 12:18:30 +01:00
1 parent 4ea1f1f222
commit 2c95e5e80f
11 files changed
+1664 -1450

No files matched your search

+61
View File
@@ -0,0 +1,61 @@
use cosmic::iced::{Alignment, Length};
use cosmic::widget::{column, row};
use cosmic::{Element, theme};
use super::bar::audio_icon;
use super::controls::{control_card, shell_switch, slider_row};
use super::{MenuRows, MenuStyle};
use crate::status::Action;
use crate::{FereseShell, Message, color_with_opacity, text};
pub(super) fn view<'a>(
shell: &'a FereseShell,
mut rows: MenuRows<'a>,
style: MenuStyle,
combined: bool,
) -> MenuRows<'a> {
let MenuStyle {
theme,
primary,
muted,
opacity: p,
} = style;
if let Some(a) = &shell.status.audio {
let mut volume_heading = row![text("Volume").size(13).width(Length::Fill)].align_y(Alignment::Center);
if combined {
volume_heading = volume_heading.push(shell_switch("Mute", a.muted, Action::Mute(!a.muted), theme, p));
}
let audio = column![
volume_heading,
text(&a.output).size(12).class(theme::Text::Color(muted)),
slider_row(
audio_icon(a.volume, a.muted),
a.volume,
false,
primary,
color_with_opacity(theme.accent, p),
p,
)
]
.spacing(4);
let audio: Element<'_, cosmic::Action<Message>> = if combined {
control_card(audio.into(), primary, p)
} else {
audio.into()
};
rows = rows.push(audio);
}
rows
}
pub(super) fn heading<'a>(
shell: &'a FereseShell,
mut heading: super::MenuHeading<'a>,
style: MenuStyle,
) -> super::MenuHeading<'a> {
let MenuStyle { theme, opacity: p, .. } = style;
if let Some(audio) = &shell.status.audio {
heading = heading.push(shell_switch("Mute", audio.muted, Action::Mute(!audio.muted), theme, p));
}
heading
}