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

Fix: truncate pills if they are too long #7455

Merged
merged 2 commits into from
Mar 30, 2023
Merged

Conversation

nimau
Copy link
Contributor

@nimau nimau commented Mar 28, 2023

This PR fixes #7413

Pull Request Checklist

  • I read the contributing guide
  • UI change has been tested on both light and dark themes, in portrait and landscape orientations and on iPhone and iPad simulators
  • Accessibility has been taken into account.
  • Pull request is based on the develop branch
  • Pull request contains a changelog file in ./changelog.d
  • You've made a self review of your PR
  • Pull request includes screenshots or videos of UI changes
  • Pull request includes a sign off

@nimau nimau requested a review from aringenbach March 28, 2023 10:18
@codecov
Copy link

codecov bot commented Mar 28, 2023

Codecov Report

Patch coverage: 35.29% and no project coverage change.

Comparison is base (6e48692) 12.30% compared to head (9776233) 12.30%.

❗ Current head 9776233 differs from pull request most recent head 334a116. Consider uploading reports for the commit 334a116 to get more accurate results

Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #7455   +/-   ##
========================================
  Coverage    12.30%   12.30%           
========================================
  Files         1645     1645           
  Lines       162982   162992   +10     
  Branches     66914    66916    +2     
========================================
+ Hits         20048    20056    +8     
- Misses      142285   142287    +2     
  Partials       649      649           
Flag Coverage Δ
uitests 55.25% <ø> (+0.01%) ⬆️
unittests 6.19% <35.29%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
Riot/Modules/Pills/PillAttachmentView.swift 4.87% <0.00%> (-0.04%) ⬇️
...iot/Modules/Pills/PillAttachmentViewProvider.swift 0.00% <0.00%> (ø)
Riot/Modules/Pills/PillTextAttachment.swift 68.47% <100.00%> (+0.70%) ⬆️
Riot/Modules/Pills/PillTextAttachmentData.swift 87.83% <100.00%> (+0.51%) ⬆️

... and 1 file with indirect coverage changes

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@nimau nimau requested review from a team and removed request for aringenbach March 29, 2023 13:45
@giomfo giomfo requested review from a team and pixlwave and removed request for a team March 29, 2023 13:46
Copy link
Member

@pixlwave pixlwave left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@@ -108,6 +112,7 @@ struct PillTextAttachmentData: Codable {
case isHighlighted
case alpha
case font
case maxWidth
Copy link
Member

@pixlwave pixlwave Mar 29, 2023

Choose a reason for hiding this comment

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

My only question is about encoding/decoding these pills - I'm not sure where/when we do it.

Does it make sense to encode a computed maxWidth with them? Could it be decoded to be displayed in a different size window (e.g. If the user is now a different split size on iPad)? If so, maybe it would make sense to not encode it, and instead set it back to .greatestFiniteMagnitude?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks @pixlwave, I've updated the code to reflect your suggestions.

@@ -93,12 +95,14 @@ struct PillTextAttachmentData: Codable {
items: [PillTextAttachmentItem],
isHighlighted: Bool,
alpha: CGFloat,
font: UIFont) {
font: UIFont,
maxWidth: CGFloat = CGFloat.greatestFiniteMagnitude) {
Copy link
Member

Choose a reason for hiding this comment

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

Should be able to infer the type of the default here :)

Suggested change
maxWidth: CGFloat = CGFloat.greatestFiniteMagnitude) {
maxWidth: CGFloat = .greatestFiniteMagnitude) {

@sonarcloud
Copy link

sonarcloud bot commented Mar 30, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

@nimau nimau merged commit 45668e6 into develop Mar 30, 2023
@nimau nimau deleted the nimau/7413-pills-max-width branch March 30, 2023 08:12
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.

Long name should be truncated in the pills
2 participants