Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 1 addition & 12 deletions src/Controls/src/Core/Button/Button.Mapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public partial class Button
#endif
ButtonHandler.Mapper.ReplaceMapping<Button, IButtonHandler>(nameof(Text), MapText);

ButtonHandler.Mapper.ReplaceMapping<Button, IButtonHandler>(nameof(TextTransform), MapTextTransform);
ButtonHandler.Mapper.ReplaceMapping<Button, IButtonHandler>(nameof(TextTransform), MapText);
ButtonHandler.Mapper.ReplaceMapping<Button, IButtonHandler>(nameof(Button.LineBreakMode), MapLineBreakMode);
}

Expand All @@ -44,16 +44,5 @@ public static void MapContentLayout(IButtonHandler handler, Button button)

public static void MapContentLayout(ButtonHandler handler, Button button) =>
MapContentLayout((IButtonHandler)handler, button);

static void MapTextTransform(IButtonHandler handler, Button button)
{
if (button.IsConnectingHandler())
{
// If we're connecting the handler, we don't want to map the text multiple times.
return;
}

MapText(handler, button);
}
}
}
6 changes: 0 additions & 6 deletions src/Controls/src/Core/Button/Button.iOS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -449,12 +449,6 @@ private static void MapPadding(IButtonHandler handler, Button button)
public static void MapText(IButtonHandler handler, Button button)
{
handler.PlatformView?.UpdateText(button);

if (!handler.IsConnectingHandler())
{
// Any text update requires that we update any attributed string formatting
ButtonHandler.MapFormatting(handler, button);
}
}

internal static void MapBorderWidth(IButtonHandler handler, Button button)
Expand Down
12 changes: 0 additions & 12 deletions src/Controls/src/Core/Editor/Editor.Android.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,5 @@ public static void MapText(EditorHandler2 handler, Editor editor)

Platform.EditTextExtensions.UpdateText(handler.PlatformView, editor);
}

// Material3 specific overload for EditorHandler2
internal static void MapTextTransform(EditorHandler2 handler, Editor editor)
{
if (editor.IsConnectingHandler())
{
// If we're connecting the handler, we don't want to map the text multiple times.
return;
}

MapText(handler, editor);
}
}
}
17 changes: 3 additions & 14 deletions src/Controls/src/Core/Editor/Editor.Mapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ public partial class Editor
EditorHandler.Mapper.ReplaceMapping<Editor, IEditorHandler>(PlatformConfiguration.WindowsSpecific.InputView.DetectReadingOrderFromContentProperty.PropertyName, MapDetectReadingOrderFromContent);
#endif
EditorHandler.Mapper.ReplaceMapping<Editor, IEditorHandler>(nameof(Text), MapText);
EditorHandler.Mapper.ReplaceMapping<Editor, IEditorHandler>(nameof(TextTransform), MapTextTransform);
EditorHandler.Mapper.ReplaceMapping<Editor, IEditorHandler>(nameof(TextTransform), MapText);

#if ANDROID
if (RuntimeFeature.IsMaterial3Enabled)
{
EditorHandler2.Mapper.ReplaceMapping<Editor, EditorHandler2>(nameof(Text), MapText);
EditorHandler2.Mapper.ReplaceMapping<Editor, EditorHandler2>(nameof(TextTransform), MapTextTransform);
EditorHandler2.Mapper.ReplaceMapping<Editor, EditorHandler2>(nameof(TextTransform), MapText);
EditorHandler2.Mapper.AppendToMapping<Editor, EditorHandler2>(nameof(VisualElement.IsFocused), InputView.MapIsFocused);
EditorHandler2.CommandMapper.PrependToMapping<Editor, EditorHandler2>(nameof(IEditor.Focus), InputView.MapFocus);
}
Expand All @@ -38,16 +38,5 @@ public partial class Editor
EditorHandler.CommandMapper.PrependToMapping(nameof(IEditor.Focus), InputView.MapFocus);
#endif
}

static void MapTextTransform(IEditorHandler handler, Editor editor)
{
if (editor.IsConnectingHandler())
{
// If we're connecting the handler, we don't want to map the text multiple times.
return;
}

MapText(handler, editor);
}
}
}
}
7 changes: 2 additions & 5 deletions src/Controls/src/Core/Editor/Editor.iOS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,8 @@ public static void MapText(IEditorHandler handler, Editor editor)
{
Platform.TextExtensions.UpdateText(handler.PlatformView, editor);

if (!handler.IsConnectingHandler())
{
// Any text changes in the editor field require recalculating the CharacterSpacing by regenerating the attributed string to properly apply the spacing and override the current text formatting.
handler?.UpdateValue(nameof(CharacterSpacing));
}
// Any text changes in the editor field require recalculating the CharacterSpacing by regenerating the attributed string to properly apply the spacing and override the current text formatting.
handler?.UpdateValue(nameof(CharacterSpacing));
}
}
}
12 changes: 0 additions & 12 deletions src/Controls/src/Core/Entry/Entry.Android.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,17 +56,5 @@ public static void MapText(EntryHandler2 handler, Entry entry)

Platform.EditTextExtensions.UpdateText(handler.PlatformView.EditText, entry);
}

// Material3 specific overload for EntryHandler2
internal static void MapTextTransform(EntryHandler2 handler, Entry entry)
{
if (entry.IsConnectingHandler())
{
// If we're connecting the handler, we don't want to map the text multiple times.
return;
}

MapText(handler, entry);
}
}
}
15 changes: 2 additions & 13 deletions src/Controls/src/Core/Entry/Entry.Mapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ public partial class Entry
EntryHandler.Mapper.ReplaceMapping<Entry, IEntryHandler>(PlatformConfiguration.iOSSpecific.Entry.AdjustsFontSizeToFitWidthProperty.PropertyName, MapAdjustsFontSizeToFitWidth);
#endif
EntryHandler.Mapper.ReplaceMapping<Entry, IEntryHandler>(nameof(Text), MapText);
EntryHandler.Mapper.ReplaceMapping<Entry, IEntryHandler>(nameof(TextTransform), MapTextTransform);
EntryHandler.Mapper.ReplaceMapping<Entry, IEntryHandler>(nameof(TextTransform), MapText);

// Material3 Entry Handler mappings
#if ANDROID
if (RuntimeFeature.IsMaterial3Enabled)
{
EntryHandler2.Mapper.ReplaceMapping<Entry, EntryHandler2>(PlatformConfiguration.AndroidSpecific.Entry.ImeOptionsProperty.PropertyName, MapImeOptions);
EntryHandler2.Mapper.ReplaceMapping<Entry, EntryHandler2>(nameof(Text), MapText);
EntryHandler2.Mapper.ReplaceMapping<Entry, EntryHandler2>(nameof(TextTransform), MapTextTransform);
EntryHandler2.Mapper.ReplaceMapping<Entry, EntryHandler2>(nameof(TextTransform), MapText);
EntryHandler2.Mapper.AppendToMapping(nameof(VisualElement.IsFocused), InputView.MapIsFocused);
EntryHandler2.Mapper.AppendToMapping(nameof(VisualElement.IsVisible), InputView.MapIsVisible);
EntryHandler2.CommandMapper.PrependToMapping(nameof(IEntry.Focus), InputView.MapFocus);
Expand All @@ -42,16 +42,5 @@ public partial class Entry
EntryHandler.CommandMapper.PrependToMapping(nameof(IEntry.Focus), InputView.MapFocus);
#endif
}

static void MapTextTransform(IEntryHandler handler, Entry entry)
{
if (entry.IsConnectingHandler())
{
// If we're connecting the handler, we don't want to map the text multiple times.
return;
}

MapText(handler, entry);
}
}
}
9 changes: 1 addition & 8 deletions src/Controls/src/Core/Entry/Entry.iOS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,7 @@ public static void MapAdjustsFontSizeToFitWidth(IEntryHandler handler, Entry ent
public static void MapText(IEntryHandler handler, Entry entry)
{
Platform.TextExtensions.UpdateText(handler.PlatformView, entry);

if (!handler.IsConnectingHandler())
{
// If we're not connecting the handler, we need to update the text formatting
// This is because the text may have changed, and we need to ensure that
// any attributed string formatting is applied correctly.
EntryHandler.MapFormatting(handler, entry);
}
EntryHandler.MapFormatting(handler, entry);
}

public static void MapCursorColor(EntryHandler handler, Entry entry) =>
Expand Down
8 changes: 1 addition & 7 deletions src/Controls/src/Core/Label/Label.Mapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,7 @@ static void MapTextTransform(ILabelHandler handler, Label label) =>
static void MapFormattedText(ILabelHandler handler, Label label)
{
if (label.IsConnectingHandler())
{
// If we're connecting the handler, we don't want to map the text multiple times.
return;
}

MapText(handler, label);
}
Expand Down Expand Up @@ -170,10 +167,7 @@ static void MapTextColor(ILabelHandler handler, Label label, Action<IElementHand
{
// if there is formatted text,
// then we re-apply the whole formatted text
if (!handler.IsConnectingHandler())
{
handler.UpdateValue(nameof(FormattedText));
}
handler.UpdateValue(nameof(FormattedText));
}
else if (label.TextType == TextType.Text || !label.TextColor.IsDefault())
{
Expand Down
7 changes: 2 additions & 5 deletions src/Controls/src/Core/Label/Label.iOS.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#nullable disable
using System;
using Microsoft.Maui.Controls.Platform;
using Microsoft.Maui.Graphics;
using UIKit;
Expand All @@ -22,11 +23,7 @@ public static void MapText(ILabelHandler handler, Label label)
{
Platform.LabelExtensions.UpdateText(handler.PlatformView, label);

if (!handler.IsConnectingHandler())
{
// Any text update requires that we update any attributed string formatting
MapFormatting(handler, label);
}
MapFormatting(handler, label);
}

public static void MapLineBreakMode(ILabelHandler handler, Label label)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,7 @@ public static NSAttributedString ToNSAttributedString(
Font? defaultFont = null,
Color? defaultColor = null,
TextTransform defaultTextTransform = TextTransform.Default)
=> formattedString.ToNSAttributedString(fontManager, LineBreakMode.WordWrap, defaultLineHeight, defaultHorizontalAlignment, defaultFont, defaultColor, defaultTextTransform);

internal static NSAttributedString ToNSAttributedString(
this FormattedString formattedString,
IFontManager fontManager,
LineBreakMode defaultLineBreakMode,
double defaultLineHeight = -1,
TextAlignment defaultHorizontalAlignment = TextAlignment.Start,
Font? defaultFont = null,
Color? defaultColor = null,
TextTransform defaultTextTransform = TextTransform.Default)
=> formattedString.ToNSAttributedString(fontManager, defaultLineHeight, defaultHorizontalAlignment, defaultFont, defaultColor, defaultTextTransform, defaultLineBreakMode, defaultCharacterSpacing: 0d);
=> formattedString.ToNSAttributedString(fontManager, defaultLineHeight, defaultHorizontalAlignment, defaultFont, defaultColor, defaultTextTransform, LineBreakMode.WordWrap, defaultCharacterSpacing: 0d);

internal static NSAttributedString ToNSAttributedString(
this FormattedString formattedString,
Expand Down Expand Up @@ -93,18 +82,7 @@ public static NSAttributedString ToNSAttributedString(
Font? defaultFont = null,
Color? defaultColor = null,
TextTransform defaultTextTransform = TextTransform.Default)
=> span.ToNSAttributedString(fontManager, defaultLineHeight, defaultHorizontalAlignment, defaultFont, defaultColor, defaultTextTransform, defaultLineBreakMode: LineBreakMode.WordWrap);

internal static NSAttributedString ToNSAttributedString(
this Span span,
IFontManager fontManager,
LineBreakMode defaultLineBreakMode,
double defaultLineHeight = -1,
TextAlignment defaultHorizontalAlignment = TextAlignment.Start,
Font? defaultFont = null,
Color? defaultColor = null,
TextTransform defaultTextTransform = TextTransform.Default)
=> span.ToNSAttributedString(fontManager, defaultLineHeight, defaultHorizontalAlignment, defaultFont, defaultColor, defaultTextTransform, defaultLineBreakMode, defaultCharacterSpacing: 0d);
=> span.ToNSAttributedString(fontManager, defaultLineHeight, defaultHorizontalAlignment, defaultFont, defaultColor, defaultTextTransform, LineBreakMode.WordWrap, defaultCharacterSpacing: 0d);

internal static NSAttributedString ToNSAttributedString(
this Span span,
Expand All @@ -114,7 +92,7 @@ internal static NSAttributedString ToNSAttributedString(
Font? defaultFont,
Color? defaultColor,
TextTransform defaultTextTransform,
LineBreakMode defaultLineBreakMode,
LineBreakMode lineBreakMode,
double defaultCharacterSpacing = 0d)
{
var defaultFontSize = defaultFont?.Size ?? fontManager.DefaultFontSize;
Expand Down Expand Up @@ -145,13 +123,14 @@ internal static NSAttributedString ToNSAttributedString(
_ => UITextAlignment.Left
};

style.LineBreakMode = defaultLineBreakMode switch
style.LineBreakMode = lineBreakMode switch
{
LineBreakMode.NoWrap => UILineBreakMode.Clip,
LineBreakMode.WordWrap => UILineBreakMode.WordWrap,
LineBreakMode.CharacterWrap => UILineBreakMode.CharacterWrap,
LineBreakMode.HeadTruncation => UILineBreakMode.HeadTruncation,
LineBreakMode.MiddleTruncation => UILineBreakMode.MiddleTruncation,
LineBreakMode.TailTruncation => UILineBreakMode.TailTruncation,
LineBreakMode.MiddleTruncation => UILineBreakMode.MiddleTruncation,
_ => UILineBreakMode.WordWrap
};

Expand Down
12 changes: 0 additions & 12 deletions src/Controls/src/Core/SearchBar/SearchBar.Android.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,5 @@ public static void MapText(SearchBarHandler2 handler, SearchBar searchBar)

Platform.EditTextExtensions.UpdateText(handler.PlatformView.EditText, searchBar);
}

// Material3 specific overload for SearchBarHandler2
internal static void MapTextTransform(SearchBarHandler2 handler, SearchBar searchBar)
{
if (searchBar.IsConnectingHandler())
{
// If we're connecting the handler, we don't want to map the text multiple times.
return;
}

MapText(handler, searchBar);
}
}
}
17 changes: 3 additions & 14 deletions src/Controls/src/Core/SearchBar/SearchBar.Mapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,16 @@ static SearchBar()
{
// Material3 SearchBar handler mappings
SearchBarHandler2.Mapper.ReplaceMapping<SearchBar, SearchBarHandler2>(nameof(Text), MapText);
SearchBarHandler2.Mapper.ReplaceMapping<SearchBar, SearchBarHandler2>(nameof(TextTransform), MapTextTransform);
SearchBarHandler2.Mapper.ReplaceMapping<SearchBar, SearchBarHandler2>(nameof(TextTransform), MapText);
}
else
{
SearchBarHandler.Mapper.ReplaceMapping<SearchBar, ISearchBarHandler>(nameof(Text), MapText);
SearchBarHandler.Mapper.ReplaceMapping<SearchBar, ISearchBarHandler>(nameof(TextTransform), MapTextTransform);
SearchBarHandler.Mapper.ReplaceMapping<SearchBar, ISearchBarHandler>(nameof(TextTransform), MapText);
}
#else
SearchBarHandler.Mapper.ReplaceMapping<SearchBar, ISearchBarHandler>(nameof(Text), MapText);
SearchBarHandler.Mapper.ReplaceMapping<SearchBar, ISearchBarHandler>(nameof(TextTransform), MapTextTransform);
SearchBarHandler.Mapper.ReplaceMapping<SearchBar, ISearchBarHandler>(nameof(TextTransform), MapText);
#endif

#if IOS || ANDROID
Expand All @@ -47,16 +47,5 @@ static SearchBar()
SearchBarHandler.CommandMapper.PrependToMapping(nameof(ISearchBar.Focus), InputView.MapFocus);
#endif
}

static void MapTextTransform(ISearchBarHandler handler, SearchBar searchBar)
{
if (searchBar.IsConnectingHandler())
{
// If we're connecting the handler, we don't want to map the text multiple times.
return;
}

MapText(handler, searchBar);
}
}
}
8 changes: 1 addition & 7 deletions src/Controls/src/Core/SearchBar/SearchBar.iOS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,7 @@ public static void MapSearchBarStyle(ISearchBarHandler handler, SearchBar search
public static void MapText(ISearchBarHandler handler, SearchBar searchBar)
{
Platform.SearchBarExtensions.UpdateText(handler.PlatformView, searchBar);

// Any text update requires that we update any attributed string formatting.
// During handler connection these properties are applied by the normal mapper sweep after Text.
if (!handler.IsConnectingHandler())
{
SearchBarHandler.MapFormatting(handler, searchBar);
}
SearchBarHandler.MapFormatting(handler, searchBar);
}

internal static void MapUserInteraction(ISearchBarHandler handler, SearchBar searchBar)
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,7 @@
</Button>

<Label Grid.Row="1"
Text="Clicked Event: "
AutomationId="MainLabel">
<Label.GestureRecognizers>
<TapGestureRecognizer Tapped="MainLabel_Tapped"/>
</Label.GestureRecognizers>
</Label>
Text="Clicked Event: "/>
<Label Grid.Row="1"
Grid.Column="1"
x:Name="ClickedEventLabel"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using Microsoft.Maui.Controls.Internals;

namespace Maui.Controls.Sample;

public class ButtonControlPage : NavigationPage
Expand Down Expand Up @@ -54,17 +52,4 @@ public void OnButtonReleased(object sender, EventArgs e)
ReleasedEventLabel.Text = "Released Event Executed";
}
}

void MainLabel_Tapped(object sender, TappedEventArgs e)
{
// Recreate the page to verify initial mappers
ToolbarItems.Clear();
Content = new ContentView();
INameScope scope = this;
scope.UnregisterName("ClickedEventLabel");
scope.UnregisterName("ReleasedEventLabel");
scope.UnregisterName("PressedEventLabel");
scope.UnregisterName("ButtonShadow");
InitializeComponent();
}
}
Loading
Loading