Skip to content

Commit 94becdd

Browse files
committed
cleanup: adjust the layout and styles to more closely match the mockup
1 parent 44146f8 commit 94becdd

File tree

1 file changed

+20
-22
lines changed
  • cosmic-applet-notifications/src

1 file changed

+20
-22
lines changed

cosmic-applet-notifications/src/main.rs

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,19 @@ mod subscriptions;
33

44
use cosmic::cosmic_config::{config_subscription, Config, CosmicConfigEntry};
55
use cosmic::iced::wayland::popup::{destroy_popup, get_popup};
6+
use cosmic::iced::Limits;
67
use cosmic::iced::{
78
widget::{button, column, row, text, Row, Space},
89
window, Alignment, Application, Color, Command, Length, Subscription,
910
};
1011
use cosmic::iced_core::alignment::Horizontal;
11-
use cosmic::iced_core::{image, Widget};
12-
use cosmic::iced_futures::subscription;
12+
use cosmic::iced_core::image;
1313
use cosmic::iced_widget::button::StyleSheet;
1414
use cosmic_applet::{applet_button_theme, CosmicAppletHelper};
1515

1616
use cosmic::iced_style::application::{self, Appearance};
1717

18-
use cosmic::iced_widget::{horizontal_space, scrollable, Column};
18+
use cosmic::iced_widget::{scrollable, Column};
1919
use cosmic::theme::{Button, Svg};
2020
use cosmic::widget::{container, divider, icon};
2121
use cosmic::Renderer;
@@ -172,13 +172,18 @@ impl Application for Notifications {
172172
let new_id = window::Id(self.id_ctr);
173173
self.popup.replace(new_id);
174174

175-
let popup_settings = self.applet_helper.get_popup_settings(
175+
let mut popup_settings = self.applet_helper.get_popup_settings(
176176
window::Id(0),
177177
new_id,
178178
None,
179179
None,
180180
None,
181181
);
182+
popup_settings.positioner.size_limits = Limits::NONE
183+
.min_width(1.0)
184+
.max_width(300.0)
185+
.min_height(100.0)
186+
.max_height(600.0);
182187
get_popup(popup_settings)
183188
}
184189
}
@@ -287,9 +292,11 @@ impl Application for Notifications {
287292
column![cosmic::widget::button(Button::Text)
288293
.custom(vec![text(fl!("clear-all")).size(14).into()])
289294
.on_press(Message::ClearAll)]
295+
.align_items(Alignment::End)
296+
.width(Length::Fill)
290297
.into(),
291298
);
292-
for n in &self.notifications {
299+
for n in self.notifications.iter().rev() {
293300
let app_name = text(if n.app_name.len() > 24 {
294301
Cow::from(format!(
295302
"{:.26}...",
@@ -312,12 +319,8 @@ impl Application for Notifications {
312319
} else {
313320
Button::Secondary
314321
};
315-
let cosmic = t.cosmic();
316322
let mut a = t.active(&style);
317323
a.border_radius = 8.0.into();
318-
a.background = Some(Color::from(cosmic.bg_color()).into());
319-
a.border_color = Color::from(cosmic.bg_divider());
320-
a.border_width = 1.0;
321324
a
322325
}),
323326
hover: Box::new(move |t| {
@@ -326,12 +329,8 @@ impl Application for Notifications {
326329
} else {
327330
Button::Secondary
328331
};
329-
let cosmic = t.cosmic();
330332
let mut a = t.hovered(&style);
331333
a.border_radius = 8.0.into();
332-
a.background = Some(Color::from(cosmic.bg_color()).into());
333-
a.border_color = Color::from(cosmic.bg_divider());
334-
a.border_width = 1.0;
335334
a
336335
}),
337336
})
@@ -368,7 +367,8 @@ impl Application for Notifications {
368367
} else {
369368
Cow::from(&n.summary)
370369
})
371-
.size(14),
370+
.size(14)
371+
.width(Length::Fixed(300.0)),
372372
text(if n.body.len() > 77 {
373373
Cow::from(format!(
374374
"{:.80}...",
@@ -377,11 +377,12 @@ impl Application for Notifications {
377377
} else {
378378
Cow::from(&n.body)
379379
})
380-
.size(12),
381-
horizontal_space(Length::Fixed(300.0)),
380+
.size(12)
381+
.width(Length::Fixed(300.0)),
382382
)
383383
.spacing(8)
384384
.into()])
385+
.padding(16)
385386
.on_press(Message::Dismissed(n.id))
386387
.into(),
387388
);
@@ -393,7 +394,7 @@ impl Application for Notifications {
393394
.height(Length::Shrink),
394395
)
395396
.width(Length::Shrink)
396-
.height(Length::Fixed(400.0)))
397+
.height(Length::Shrink))
397398
.width(Length::Shrink)
398399
};
399400

@@ -405,13 +406,10 @@ impl Application for Notifications {
405406
.padding([0, 24])
406407
.spacing(12);
407408

408-
let content = column![]
409+
let content = column![do_not_disturb, main_content, settings]
409410
.align_items(Alignment::Start)
410411
.spacing(12)
411-
.padding([12, 0])
412-
.push(do_not_disturb)
413-
.push(main_content)
414-
.push(settings);
412+
.padding([12, 0]);
415413

416414
self.applet_helper.popup_container(content).into()
417415
}

0 commit comments

Comments
 (0)