Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improvements to About #697

Merged
merged 8 commits into from
Nov 10, 2024
Merged

Improvements to About #697

merged 8 commits into from
Nov 10, 2024

Conversation

edfloreshz
Copy link
Contributor

@edfloreshz edfloreshz commented Nov 9, 2024

This PR makes several improvements to the about section.

  • Per @wiiznokes suggestion in Feedback on About feature #696, the about section code was moved to a widget.
  • Simplifies builder methods.
  • Properties are now private.
  • Removed the URL specific methods and made method links public, letting anyone pass an array of label/link pairs.
  • Added the license crate to handle licenses.
  • Removed license_type and replaced it with a link to the license page (https://spdx.org/licenses).
  • Add spacing between content and scrollbar.

Closes #696

mmstick
mmstick previously approved these changes Nov 9, 2024
@mmstick
Copy link
Member

mmstick commented Nov 9, 2024

Some tests are failing with an unresolved import for about

@edfloreshz
Copy link
Contributor Author

Sorry, should be fixed.

src/widget/mod.rs Outdated Show resolved Hide resolved
src/widget/about.rs Outdated Show resolved Hide resolved
src/widget/about.rs Outdated Show resolved Hide resolved
@wiiznokes
Copy link
Contributor

some nitpicks:

  • would be nice if the fields were private, and the set_ prefix were removed.
  • some data are duplicated. For example, repository_url is stored in a dedicated field and the links BtreeMap. I can see the value of having dedicated fields, for example, to add custom icons in the future
  • would be nice to add a method add_link(self, name, link) -> Self
  • set_support_url is ambigus imo, for example, i have this value set in metainfo.xml: bugtracker, donation, vcs-browser, homepage
  • maybe switch license with license_type, and rename license_type to licence_text

wdyt @edfloreshz ?

@edfloreshz
Copy link
Contributor Author

Those are great suggestions, I'll make the changes in the next couple of hours.

@wiiznokes
Copy link
Contributor

here are some ideas of urls we can add https://docs.flathub.org/docs/for-app-authors/metainfo-guidelines/#url

@edfloreshz
Copy link
Contributor Author

edfloreshz commented Nov 9, 2024

  • Properties are now private.
  • Removed the URL specific methods and made method links public, letting anyone pass an array of label/link pairs.
  • Added the license crate to handle licenses.
  • Removed license_type and replaced it with a link to the license page (https://spdx.org/licenses).

This is what it looks like now:

About::default()
  .name("About Demo")
  .icon(Self::APP_ID)
  .version("0.1.0")
  .author("System 76")
  .license("GPL-3.0-only")
  .developers([("Michael Murphy", "mmstick@system76.com")])
  .links([
      ("Website", "https://system76.com/cosmic"),
      ("Repository", "https://github.com/pop-os/libcosmic)"),
      ("Support", "https://github.com/pop-os/libcosmic/issues"),
  ])

@wiiznokes

Copy link
Contributor

@wiiznokes wiiznokes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the new api!
Just some minor doc issues

src/widget/about.rs Outdated Show resolved Hide resolved
src/widget/about.rs Show resolved Hide resolved
src/widget/about.rs Show resolved Hide resolved
@wiiznokes
Copy link
Contributor

wiiznokes commented Nov 9, 2024

Could you add this method to support the fl! macro ?

pub fn link(mut self, name: impl Into<String>, link: &'a str) -> Self {
    self.links.insert(name.into(), link.to_string());
    self
}

Edit: or smtg like this

@edfloreshz
Copy link
Contributor Author

I'm thinking of the best way to support localization with the existing set of methods.

@wiiznokes
Copy link
Contributor

wiiznokes commented Nov 9, 2024

I'm thinking of the best way to support localization with the existing set of methods.

smtg like that could work:

pub fn links<const N: usize>(
    mut self,
    links: [(impl Into<String>, impl Into<String>); N],
) -> Self {
    self.links = links
        .into_iter()
        .map(|(k, v)| (k.into(), v.into()))
        .collect();
    self
}

@edfloreshz
Copy link
Contributor Author

edfloreshz commented Nov 9, 2024

Decided to do this instead given that URLs don't really require localization, only labels.

pub fn links<T: Into<String>>(mut self, links: impl Into<Vec<(T, &'a str)>>) -> Self {
    let links: Vec<(T, &'a str)> = links.into();
    self.links = links
        .into_iter()
        .map(|(k, v)| (k.into(), v.to_string()))
        .collect();
    self
}

@wiiznokes Let me know if this works for you.

@wiiznokes
Copy link
Contributor

Yeah, it works. The Vec also make probably more sense.

I noticed that the scrollbar is a bit off, but idk if it's related or not. Maybe we need to adjust the padding.

Capture d’écran du 2024-11-09 21-08-58

@edfloreshz
Copy link
Contributor Author

Yeah we could give it some right padding

@edfloreshz
Copy link
Contributor Author

@wiiznokes Please confirm if I can ask Michael to review.

@git-f0x
Copy link
Contributor

git-f0x commented Nov 9, 2024

Is there a reason that the scrollable was removed from the drawer? Since now it isn't possible to make the scrollbar be at the right edge (to match designs), and that spacing that's required to make the scrollbar not cover content makes things off-center.
Though I guess the container padding can be removed in the widget, and then that padding could be applied in every app separately, and then a scrollable applied. But that seems a bit cumbersome.

@wiiznokes
Copy link
Contributor

@wiiznokes Please confirm if I can ask Michael to review.

Yeah, go ahead

@edfloreshz
Copy link
Contributor Author

@mmstick This should be ready for review now.

@git-f0x
Copy link
Contributor

git-f0x commented Nov 10, 2024

If #698 gets merged, the scrollbar spacing can be removed, but .padding([0, space_l, space_l, space_l]) should be applied to the column (before the scrollable).

@mmstick mmstick merged commit d8357d0 into pop-os:master Nov 10, 2024
14 checks passed
@edfloreshz edfloreshz changed the title Move About to a widget Improvements to About Nov 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feedback on About feature
4 participants