-
Notifications
You must be signed in to change notification settings - Fork 1.9k
[Handlers] Map MaxLines and LineBreakMode properties in LabelHandlers #13850
Conversation
d626393
to
b513371
Compare
There was a problem hiding this 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!
src/Core/tests/DeviceTests/Handlers/Label/LabelHandlerTests.Android.cs
Outdated
Show resolved
Hide resolved
I updated the PR with some tests. Let me get to fixin' 'em! |
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."; |
There was a problem hiding this comment.
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.
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 max <=0 -> all 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
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 |
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 |
|
|
I close this PR and continue the discussions and review in .NET MAUI repository. cc @mattleibow |
Description of Change
Map
MaxLines
andLineBreakMode
property in LabelHandlers.NOTE: Include directly two properties because are very related ones.
Platforms Affected
PR Checklist