Skip to content

Commit 9cad9ba

Browse files
committed
cleanup(notifications): layout, popup size, and i18n
1 parent eb6ac89 commit 9cad9ba

File tree

2 files changed

+17
-26
lines changed

2 files changed

+17
-26
lines changed

cosmic-applet-notifications/i18n/en/cosmic_applet_notifications.ftl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,6 @@ minutes-ago = { NUMBER($duration) ->
66
[1] 1 Minute Ago
77
*[other] {$duration} Minutes Ago
88
}
9-
clear-all = Clear All Notifications
9+
clear-all = Clear All Notifications
10+
do-not-disturb = Do Not Disturb
11+
notification-settings = Notification Settings...

cosmic-applet-notifications/src/main.rs

Lines changed: 14 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use cosmic::cosmic_config::{config_subscription, Config, CosmicConfigEntry};
55
use cosmic::iced::wayland::popup::{destroy_popup, get_popup};
66
use cosmic::iced::Limits;
77
use cosmic::iced::{
8-
widget::{button, column, row, text, Row, Space},
8+
widget::{button, column, row, text, Row},
99
window, Alignment, Application, Color, Command, Length, Subscription,
1010
};
1111
use cosmic::iced_core::alignment::Horizontal;
@@ -15,9 +15,9 @@ use cosmic_applet::{applet_button_theme, CosmicAppletHelper};
1515

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

18-
use cosmic::iced_widget::{scrollable, Column};
18+
use cosmic::iced_widget::{horizontal_rule, scrollable, Column};
1919
use cosmic::theme::{Button, Svg};
20-
use cosmic::widget::{container, divider, icon};
20+
use cosmic::widget::{container, icon};
2121
use cosmic::Renderer;
2222
use cosmic::{Element, Theme};
2323
use cosmic_notifications_config::NotificationsConfig;
@@ -181,7 +181,7 @@ impl Application for Notifications {
181181
);
182182
popup_settings.positioner.size_limits = Limits::NONE
183183
.min_width(1.0)
184-
.max_width(300.0)
184+
.max_width(444.0)
185185
.min_height(100.0)
186186
.max_height(900.0);
187187
get_popup(popup_settings)
@@ -268,15 +268,15 @@ impl Application for Notifications {
268268
let do_not_disturb = row![anim!(
269269
DO_NOT_DISTURB,
270270
&self.timeline,
271-
String::from("Do Not Disturb"),
271+
String::from(fl!("do-not-disturb")),
272272
self.config.do_not_disturb,
273273
Message::DoNotDisturb
274274
)
275275
.width(Length::Fill)]
276276
.padding([0, 24]);
277277

278-
let settings =
279-
row_button(vec!["Notification Settings...".into()]).on_press(Message::Settings);
278+
let settings = row_button(vec![text(fl!("notification-settings")).into()])
279+
.on_press(Message::Settings);
280280

281281
let notifications = if self.notifications.len() == 0 {
282282
row![container(
@@ -390,46 +390,35 @@ impl Application for Notifications {
390390
row!(scrollable(
391391
Column::with_children(notifs)
392392
.spacing(8)
393-
.width(Length::Shrink)
394393
.height(Length::Shrink),
395394
)
396-
.width(Length::Shrink)
397395
.height(Length::Shrink))
398-
.width(Length::Shrink)
399396
};
400397

401-
let main_content = column![
402-
divider::horizontal::light(),
403-
notifications,
404-
divider::horizontal::light()
405-
]
406-
.padding([0, 24])
407-
.spacing(12);
398+
let main_content = column![horizontal_rule(4), notifications, horizontal_rule(4)]
399+
.padding([0, 24])
400+
.spacing(12);
408401

409402
let content = column![do_not_disturb, main_content, settings]
410403
.align_items(Alignment::Start)
411404
.spacing(12)
412-
.padding([12, 0]);
405+
.padding([16, 0]);
413406

414407
self.applet_helper.popup_container(content).into()
415408
}
416409
}
417410
}
418411

419-
// todo put into libcosmic doing so will fix the row_button's boarder radius
420-
fn row_button(
421-
mut content: Vec<Element<Message>>,
422-
) -> cosmic::iced::widget::Button<Message, Renderer> {
423-
content.insert(0, Space::with_width(Length::Fixed(24.0)).into());
424-
content.push(Space::with_width(Length::Fixed(24.0)).into());
425-
412+
// todo put into libcosmic doing so will fix the row_button's border radius
413+
fn row_button(content: Vec<Element<Message>>) -> cosmic::iced::widget::Button<Message, Renderer> {
426414
button(
427415
Row::with_children(content)
428416
.spacing(4)
429417
.align_items(Alignment::Center),
430418
)
431419
.width(Length::Fill)
432420
.height(Length::Fixed(36.0))
421+
.padding([0, 24])
433422
.style(applet_button_theme())
434423
}
435424

0 commit comments

Comments
 (0)