Skip to content

Commit

Permalink
chore: update libcosmic
Browse files Browse the repository at this point in the history
  • Loading branch information
edfloreshz committed Oct 5, 2024
1 parent 776ef0a commit 74c624f
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 39 deletions.
50 changes: 32 additions & 18 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,8 @@ impl Tasks {
AppTheme::Light => 2,
AppTheme::System => 0,
};
widget::settings::view_column(vec![widget::settings::view_section(fl!("appearance"))
widget::settings::view_column(vec![widget::settings::section()
.title(fl!("appearance"))
.add(
widget::settings::item::builder(fl!("theme")).control(widget::dropdown(
&self.app_themes,
Expand Down Expand Up @@ -339,7 +340,7 @@ impl Application for Tasks {
DialogPage::Icon(icon) => {
let icon_buttons: Vec<Element<_>> = emojis::iter()
.map(|emoji| {
widget::button(
widget::button::custom(
widget::container(widget::text(emoji.to_string()))
.width(spacing.space_l)
.height(spacing.space_l)
Expand Down
9 changes: 9 additions & 0 deletions src/app/icon_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,13 @@ impl IconCache {
let mut icon_cache = ICON_CACHE.get().unwrap().lock().unwrap();
icon_cache.get_icon(name, size)
}

pub fn get_handle(name: &'static str, size: u16) -> icon::Handle {
let mut icon_cache = ICON_CACHE.get().unwrap().lock().unwrap();
icon_cache
.cache
.entry(IconCacheKey { name, size })
.or_insert_with(|| icon::from_name(name).size(size).handle())
.clone()
}
}
22 changes: 12 additions & 10 deletions src/content.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ impl Content {

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

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

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

let task_item_text = widget::editable_input(
"",
Expand Down Expand Up @@ -168,7 +170,7 @@ impl Content {
.on_submit(Message::AddTask)
.width(Length::Fill)
.into(),
widget::button(IconCache::get("mail-send-symbolic", 18))
widget::button::icon(IconCache::get_handle("mail-send-symbolic", 18))
.padding(spacing.space_xxs)
.style(theme::Button::Suggested)
.on_press(Message::AddTask)
Expand Down
23 changes: 14 additions & 9 deletions src/details.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,10 +189,11 @@ impl Details {
.on_input(move |title| Message::SetSubTaskTitle(id, title))
.on_submit(Message::SubTaskEditDone);

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

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

return widget::settings::view_column(vec![
widget::settings::view_section(fl!("details"))
widget::settings::section()
.title(fl!("details"))
.add(
widget::column::with_children(vec![
widget::text::body(fl!("title")).into(),
Expand Down Expand Up @@ -263,14 +265,17 @@ impl Details {
.padding([0, 15, 0, 15]),
)
.into(),
widget::settings::view_section(fl!("sub-tasks"))
widget::settings::section()
.title(fl!("sub-tasks"))
.add(widget::column::with_children(sub_tasks).spacing(spacing.space_xs))
.into(),
])
.into();
}
widget::settings::view_column(vec![widget::settings::view_section(fl!("details")).into()])
.into()
widget::settings::view_column(vec![widget::settings::section()
.title(fl!("details"))
.into()])
.into()
}

fn sub_task_input(&self) -> Element<Message> {
Expand All @@ -283,7 +288,7 @@ impl Details {
.on_submit(Message::AddTask)
.width(Length::Fill)
.into(),
widget::button(IconCache::get("mail-send-symbolic", 18))
widget::button::icon(IconCache::get_handle("mail-send-symbolic", 18))
.padding(spacing.space_xxs)
.on_press(Message::AddTask)
.into(),
Expand Down

0 comments on commit 74c624f

Please sign in to comment.