Skip to content

Commit 74c624f

Browse files
committed
chore: update libcosmic
1 parent 776ef0a commit 74c624f

File tree

5 files changed

+70
-39
lines changed

5 files changed

+70
-39
lines changed

Cargo.lock

+32-18
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/app.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,8 @@ impl Tasks {
202202
AppTheme::Light => 2,
203203
AppTheme::System => 0,
204204
};
205-
widget::settings::view_column(vec![widget::settings::view_section(fl!("appearance"))
205+
widget::settings::view_column(vec![widget::settings::section()
206+
.title(fl!("appearance"))
206207
.add(
207208
widget::settings::item::builder(fl!("theme")).control(widget::dropdown(
208209
&self.app_themes,
@@ -339,7 +340,7 @@ impl Application for Tasks {
339340
DialogPage::Icon(icon) => {
340341
let icon_buttons: Vec<Element<_>> = emojis::iter()
341342
.map(|emoji| {
342-
widget::button(
343+
widget::button::custom(
343344
widget::container(widget::text(emoji.to_string()))
344345
.width(spacing.space_l)
345346
.height(spacing.space_l)

src/app/icon_cache.rs

+9
Original file line numberDiff line numberDiff line change
@@ -73,4 +73,13 @@ impl IconCache {
7373
let mut icon_cache = ICON_CACHE.get().unwrap().lock().unwrap();
7474
icon_cache.get_icon(name, size)
7575
}
76+
77+
pub fn get_handle(name: &'static str, size: u16) -> icon::Handle {
78+
let mut icon_cache = ICON_CACHE.get().unwrap().lock().unwrap();
79+
icon_cache
80+
.cache
81+
.entry(IconCacheKey { name, size })
82+
.or_insert_with(|| icon::from_name(name).size(size).handle())
83+
.clone()
84+
}
7685
}

src/content.rs

+12-10
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ impl Content {
5757

5858
fn list_header<'a>(&'a self, list: &'a List) -> Element<'a, Message> {
5959
let spacing = theme::active().cosmic().spacing;
60-
let export_button = widget::button(IconCache::get("share-symbolic", 18))
60+
let export_button = widget::button::icon(IconCache::get_handle("share-symbolic", 18))
6161
.style(theme::Button::Suggested)
6262
.padding(spacing.space_xxs)
6363
.on_press(Message::Export(self.tasks.values().cloned().collect()));
@@ -92,15 +92,17 @@ impl Content {
9292
Message::Complete(id, value)
9393
});
9494

95-
let delete_button = widget::button(IconCache::get("user-trash-full-symbolic", 18))
96-
.padding(spacing.space_xxs)
97-
.style(theme::Button::Destructive)
98-
.on_press(Message::Delete(id));
95+
let delete_button =
96+
widget::button::icon(IconCache::get_handle("user-trash-full-symbolic", 18))
97+
.padding(spacing.space_xxs)
98+
.style(theme::Button::Destructive)
99+
.on_press(Message::Delete(id));
99100

100-
let details_button = widget::button(IconCache::get("info-outline-symbolic", 18))
101-
.padding(spacing.space_xxs)
102-
.style(theme::Button::Standard)
103-
.on_press(Message::Select(item.clone()));
101+
let details_button =
102+
widget::button::icon(IconCache::get_handle("info-outline-symbolic", 18))
103+
.padding(spacing.space_xxs)
104+
.style(theme::Button::Standard)
105+
.on_press(Message::Select(item.clone()));
104106

105107
let task_item_text = widget::editable_input(
106108
"",
@@ -168,7 +170,7 @@ impl Content {
168170
.on_submit(Message::AddTask)
169171
.width(Length::Fill)
170172
.into(),
171-
widget::button(IconCache::get("mail-send-symbolic", 18))
173+
widget::button::icon(IconCache::get_handle("mail-send-symbolic", 18))
172174
.padding(spacing.space_xxs)
173175
.style(theme::Button::Suggested)
174176
.on_press(Message::AddTask)

src/details.rs

+14-9
Original file line numberDiff line numberDiff line change
@@ -189,10 +189,11 @@ impl Details {
189189
.on_input(move |title| Message::SetSubTaskTitle(id, title))
190190
.on_submit(Message::SubTaskEditDone);
191191

192-
let delete_button = widget::button(IconCache::get("user-trash-full-symbolic", 18))
193-
.padding(spacing.space_xxs)
194-
.style(widget::button::Style::Destructive)
195-
.on_press(Message::DeleteSubTask(id));
192+
let delete_button =
193+
widget::button::icon(IconCache::get_handle("user-trash-full-symbolic", 18))
194+
.padding(spacing.space_xxs)
195+
.style(widget::button::Style::Destructive)
196+
.on_press(Message::DeleteSubTask(id));
196197

197198
let row = widget::row::with_capacity(3)
198199
.align_items(Alignment::Center)
@@ -208,7 +209,8 @@ impl Details {
208209
sub_tasks.push(self.sub_task_input());
209210

210211
return widget::settings::view_column(vec![
211-
widget::settings::view_section(fl!("details"))
212+
widget::settings::section()
213+
.title(fl!("details"))
212214
.add(
213215
widget::column::with_children(vec![
214216
widget::text::body(fl!("title")).into(),
@@ -263,14 +265,17 @@ impl Details {
263265
.padding([0, 15, 0, 15]),
264266
)
265267
.into(),
266-
widget::settings::view_section(fl!("sub-tasks"))
268+
widget::settings::section()
269+
.title(fl!("sub-tasks"))
267270
.add(widget::column::with_children(sub_tasks).spacing(spacing.space_xs))
268271
.into(),
269272
])
270273
.into();
271274
}
272-
widget::settings::view_column(vec![widget::settings::view_section(fl!("details")).into()])
273-
.into()
275+
widget::settings::view_column(vec![widget::settings::section()
276+
.title(fl!("details"))
277+
.into()])
278+
.into()
274279
}
275280

276281
fn sub_task_input(&self) -> Element<Message> {
@@ -283,7 +288,7 @@ impl Details {
283288
.on_submit(Message::AddTask)
284289
.width(Length::Fill)
285290
.into(),
286-
widget::button(IconCache::get("mail-send-symbolic", 18))
291+
widget::button::icon(IconCache::get_handle("mail-send-symbolic", 18))
287292
.padding(spacing.space_xxs)
288293
.on_press(Message::AddTask)
289294
.into(),

0 commit comments

Comments
 (0)