Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

[Handlers] Map MaxLines and LineBreakMode properties in LabelHandlers #13850

Closed
wants to merge 7 commits into from

Conversation

jsuarezruiz
Copy link
Contributor

Description of Change

Map MaxLines and LineBreakMode property in LabelHandlers.

NOTE: Include directly two properties because are very related ones.

Platforms Affected

  • iOS
  • Android

PR Checklist

  • Targets the correct branch
  • Include handlers tests
  • Tests are passing (or failures are unrelated)

@jsuarezruiz jsuarezruiz changed the title [Handlers] Map MaxLines and LineBreakMode property in LabelHandlers [Handlers] Map MaxLines and LineBreakMode properties in LabelHandlers Feb 24, 2021
@jsuarezruiz jsuarezruiz force-pushed the labelhandler-maxlines branch from d626393 to b513371 Compare February 25, 2021 13:44
@rachelkang rachelkang self-requested a review February 26, 2021 18:35
Copy link
Contributor

@rachelkang rachelkang left a comment

Choose a reason for hiding this comment

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

also need to rebase main-handler again!

@mattleibow
Copy link
Contributor

I updated the PR with some tests. Let me get to fixin' 'em!

Comment on lines +11 to +18
const string longLoremIpsum =
"Lorem ipsum dolor sit amet, consectetur adipiscing elit. " +
"Quisque ut dolor metus. Duis vel iaculis mauris, sit amet finibus mi. " +
"Etiam congue ornare risus, in facilisis libero tempor eget. " +
"Phasellus mattis mollis libero ut semper. In sit amet sapien odio. " +
"Sed interdum ullamcorper dui eu rutrum. Vestibulum non sagittis justo. " +
"Cras rutrum scelerisque elit, et porta est lobortis ac. " +
"Pellentesque eu ornare tortor. Sed bibendum a nisl at laoreet.";
Copy link
Contributor

Choose a reason for hiding this comment

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

@hartez I cant actually use this long text in the vertical stack. As soon as the text lakes the label wider than the screen, it crashes on Android. Something about an index out of bounds in the measure.

@mattleibow
Copy link
Contributor

OK... So I did stuff, hopefully it is correct logic.

I linked the two properties so that they correctly set the native view's values depending on the break mode selected. When setting either of the properties, both native values are changed in the pattern:

wrapping -> use max lines
no wrap -> use 1

max <=0 -> all lines, respecting wrap
max > 0 -> x lines, respecting wrap

With regards to the max lines, this is also a weird case because the docs say an impossibility: https://docs.microsoft.com/en-us/xamarin/xamarin-forms/user-interface/text/label#display-a-specific-number-of-lines

When MaxLines is 0, the Label isn't displayed

The platforms don't reflect this. In fact, the whole system looks weird as they don't respect the break mode really.

0 lines mean all the lines on iOS but only 1 on Android. And, when the max lines are set, the no wrap is ignored.

Look at this with Forms today

Screenshot 2021-02-27 at 04 01 23

@mattleibow
Copy link
Contributor

mattleibow commented Feb 27, 2021

Actually, if you set max lines > 1 and then set a truncation, the platforms are even weirder. Android forces a single line, iOS on the other hand has multiple lines, but applies the truncation on the last line.

In my code, I force to 1 just to be like the old Android, but what should happen? It needs to be 1 line on Android to get the ellipsis to actually work.

All bonkers

@jsuarezruiz
Copy link
Contributor Author

MaxLinesproperty implementation moved to: dotnet/maui#457

@jsuarezruiz
Copy link
Contributor Author

LineBreakMode property implementation moved to dotnet/maui#458

@jsuarezruiz
Copy link
Contributor Author

I close this PR and continue the discussions and review in .NET MAUI repository. cc @mattleibow

@jsuarezruiz jsuarezruiz closed this Mar 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants