fix(notifications): text size adjustments and spacing

This commit is contained in:
Ashley Wulber 2023-10-25 12:30:06 -04:00 committed by Ashley Wulber
parent a406ec9bf0
commit 12ac3e7e2f
2 changed files with 15 additions and 12 deletions

View file

@ -6,6 +6,7 @@ minutes-ago = { NUMBER($duration) ->
[1] 1 Minute Ago [1] 1 Minute Ago
*[other] {$duration} Minutes Ago *[other] {$duration} Minutes Ago
} }
show-less = Show Less
show-more = Show {$more} More show-more = Show {$more} More
clear-all = Clear All Notifications clear-all = Clear All Notifications
do-not-disturb = Do Not Disturb do-not-disturb = Do Not Disturb

View file

@ -39,6 +39,7 @@ pub async fn main() -> cosmic::iced::Result {
} }
static DO_NOT_DISTURB: Lazy<id::Toggler> = Lazy::new(id::Toggler::unique); static DO_NOT_DISTURB: Lazy<id::Toggler> = Lazy::new(id::Toggler::unique);
#[derive(Default)] #[derive(Default)]
struct Notifications { struct Notifications {
core: cosmic::app::Core, core: cosmic::app::Core,
@ -50,12 +51,12 @@ struct Notifications {
// notifications: Vec<Notification>, // notifications: Vec<Notification>,
timeline: Timeline, timeline: Timeline,
dbus_sender: Option<Sender<subscriptions::dbus::Input>>, dbus_sender: Option<Sender<subscriptions::dbus::Input>>,
cards: Vec<(id::Cards, Vec<Notification>, bool, String)>, cards: Vec<(id::Cards, Vec<Notification>, bool, String, String, String)>,
} }
impl Notifications { impl Notifications {
fn update_cards(&mut self, id: id::Cards) { fn update_cards(&mut self, id: id::Cards) {
if let Some((id, _, card_value, _)) = self.cards.iter_mut().find(|c| c.0 == id) { if let Some((id, _, card_value, ..)) = self.cards.iter_mut().find(|c| c.0 == id) {
let chain = if *card_value { let chain = if *card_value {
chain::Cards::on(id.clone(), 1.) chain::Cards::on(id.clone(), 1.)
} else { } else {
@ -233,6 +234,8 @@ impl cosmic::Application for Notifications {
vec![n], vec![n],
false, false,
fl!("show-more", HashMap::from_iter(vec![("more", "1")])), fl!("show-more", HashMap::from_iter(vec![("more", "1")])),
fl!("show-less"),
fl!("clear-all"),
)); ));
} }
} }
@ -291,7 +294,7 @@ impl cosmic::Application for Notifications {
} }
} }
Message::CardsToggled(name, expanded) => { Message::CardsToggled(name, expanded) => {
let id = if let Some((id, _, n_expanded, _)) = self let id = if let Some((id, _, n_expanded, ..)) = self
.cards .cards
.iter_mut() .iter_mut()
.find(|c| c.1.iter().any(|notif| name == notif.app_name)) .find(|c| c.1.iter().any(|notif| name == notif.app_name))
@ -329,15 +332,17 @@ impl cosmic::Application for Notifications {
self.config.do_not_disturb, self.config.do_not_disturb,
Message::DoNotDisturb Message::DoNotDisturb
) )
.text_size(14)
.width(Length::Fill)]); .width(Length::Fill)]);
let settings = menu_button(text(fl!("notification-settings"))).on_press(Message::Settings); let settings =
menu_button(text(fl!("notification-settings")).size(14)).on_press(Message::Settings);
let notifications = if self.cards.is_empty() { let notifications = if self.cards.is_empty() {
row![container( row![container(
column![ column![
text_icon("cosmic-applet-notification-symbolic", 40), text_icon("cosmic-applet-notification-symbolic", 40),
text(&fl!("no-notifications")) text(&fl!("no-notifications")).size(14)
] ]
.align_items(Alignment::Center) .align_items(Alignment::Center)
) )
@ -368,7 +373,7 @@ impl cosmic::Application for Notifications {
.size(12) .size(12)
.width(Length::Fill); .width(Length::Fill);
let duration_since = text(duration_ago_msg(n)).size(12); let duration_since = text(duration_ago_msg(n)).size(10);
let close_notif = button( let close_notif = button(
icon::from_name("window-close-symbolic") icon::from_name("window-close-symbolic")
@ -469,9 +474,8 @@ impl cosmic::Application for Notifications {
Message::ClearAll(name.clone()), Message::ClearAll(name.clone()),
move |_, e| Message::CardsToggled(name.clone(), e), move |_, e| Message::CardsToggled(name.clone(), e),
&c.3, &c.3,
"Show Less", &c.4,
// &format!("Show {} More", c.1.len().saturating_sub(1)), &c.5,
"Clear All",
show_more_icon, show_more_icon,
c.2, c.2,
); );
@ -491,12 +495,10 @@ impl cosmic::Application for Notifications {
padded_control(divider::horizontal::default()), padded_control(divider::horizontal::default()),
notifications, notifications,
padded_control(divider::horizontal::default()) padded_control(divider::horizontal::default())
] ];
.spacing(12);
let content = column![do_not_disturb, main_content, settings] let content = column![do_not_disturb, main_content, settings]
.align_items(Alignment::Start) .align_items(Alignment::Start)
.spacing(12)
.padding([8, 0]); .padding([8, 0]);
self.core.applet.popup_container(content).into() self.core.applet.popup_container(content).into()