mirror of
https://github.com/bitwarden/mobile
synced 2026-01-02 00:23:15 +00:00
PM-3349 PM-3350 Workaround to fix issues with text getting cropped/truncated when a Label has both Multiline and LinebreakMode set
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
using Bit.App.Controls;
|
||||
using Microsoft.Maui.Handlers;
|
||||
using UIKit;
|
||||
|
||||
namespace Bit.iOS.Core.Handlers
|
||||
{
|
||||
@@ -13,6 +15,23 @@ namespace Bit.iOS.Core.Handlers
|
||||
handler.PlatformView.AccessibilityIdentifier = customLabel.AutomationId;
|
||||
}
|
||||
});
|
||||
|
||||
// WORKAROUND: There is an issue causing Multiline Labels that also have a LineBreakMode to not display text properly. (it truncates text on first line even with space available)
|
||||
// MAUI Github Issue: https://github.com/dotnet/maui/issues/14125 and https://github.com/dotnet/maui/pull/14918
|
||||
// When this gets fixed by MAUI these two Mapping below can be deleted, same for the UpdateMaxLines, TruncatedMultilineCustomLabel class and the equivalent Mappings on Android
|
||||
Microsoft.Maui.Handlers.LabelHandler.Mapper.AppendToMapping(nameof(Label.LineBreakMode), UpdateMaxLines);
|
||||
Microsoft.Maui.Handlers.LabelHandler.Mapper.AppendToMapping(nameof(Label.MaxLines), UpdateMaxLines);
|
||||
}
|
||||
|
||||
private static void UpdateMaxLines(ILabelHandler handler, ILabel label)
|
||||
{
|
||||
var textView = handler.PlatformView;
|
||||
if(label is TruncatedMultilineCustomLabel controlsLabel
|
||||
&& textView.LineBreakMode == UILineBreakMode.TailTruncation
|
||||
&& controlsLabel.MaxLines != -1)
|
||||
{
|
||||
textView.Lines = controlsLabel.MaxLines;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user