Skip to content

Commit f895a14

Browse files
Added TODO comment and refactored class and file names
1 parent b705532 commit f895a14

5 files changed

Lines changed: 31 additions & 27 deletions

File tree

src/Controls/src/Core/Editor/Editor.Android.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ public static void MapText(IEditorHandler handler, Editor editor)
1919
Platform.EditTextExtensions.UpdateText(handler.PlatformView, editor);
2020
}
2121

22-
// MaterialEditorHandler-specific overloads
23-
internal static void MapText(MaterialEditorHandler handler, Editor editor)
22+
// TODO: Material3 - make it public in .net 11
23+
internal static void MapText(EditorHandler2 handler, Editor editor)
2424
{
2525
if (handler.PlatformView is null)
2626
{

src/Controls/src/Core/Editor/Editor.Mapper.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,10 @@ public partial class Editor
1818
#if ANDROID
1919
if (RuntimeFeature.IsMaterial3Enabled)
2020
{
21-
MaterialEditorHandler.Mapper.ReplaceMapping<Editor, MaterialEditorHandler>(nameof(Text), MapText);
22-
MaterialEditorHandler.Mapper.ReplaceMapping<Editor, MaterialEditorHandler>(nameof(TextTransform), MapText);
21+
EditorHandler2.Mapper.ReplaceMapping<Editor, EditorHandler2>(nameof(Text), MapText);
22+
EditorHandler2.Mapper.ReplaceMapping<Editor, EditorHandler2>(nameof(TextTransform), MapText);
23+
EditorHandler2.Mapper.AppendToMapping<Editor, EditorHandler2>(nameof(VisualElement.IsFocused), InputView.MapIsFocused);
24+
EditorHandler2.CommandMapper.PrependToMapping<Editor, EditorHandler2>(nameof(IEditor.Focus), InputView.MapFocus);
2325
}
2426
#endif
2527

src/Controls/src/Core/Hosting/AppHostBuilderExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ internal static IMauiHandlersCollection AddControlsHandlers(this IMauiHandlersCo
7373
#if ANDROID
7474
if (RuntimeFeature.IsMaterial3Enabled)
7575
{
76-
handlersCollection.AddHandler<Editor, MaterialEditorHandler>();
76+
handlersCollection.AddHandler<Editor, EditorHandler2>();
7777
}
7878
else
7979
{

src/Core/src/Handlers/Editor/MaterialEditorHandler.Android.cs renamed to src/Core/src/Handlers/Editor/EditorHandler2.Android.cs

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,12 @@
77

88
namespace Microsoft.Maui.Handlers;
99

10-
internal class MaterialEditorHandler : ViewHandler<IEditor, MauiMaterialEditText>
10+
// TODO: Material3 - make it public in .net 11
11+
internal class EditorHandler2 : ViewHandler<IEditor, MauiMaterialEditText>
1112
{
1213
bool _set;
1314

14-
public static PropertyMapper<IEditor, MaterialEditorHandler> Mapper =
15+
public static PropertyMapper<IEditor, EditorHandler2> Mapper =
1516
new(ViewMapper)
1617
{
1718
[nameof(IEditor.Background)] = MapBackground,
@@ -32,13 +33,13 @@ internal class MaterialEditorHandler : ViewHandler<IEditor, MauiMaterialEditText
3233
[nameof(IEditor.SelectionLength)] = MapSelectionLength,
3334
};
3435

35-
public static CommandMapper<IEditor, MaterialEditorHandler> CommandMapper =
36+
public static CommandMapper<IEditor, EditorHandler2> CommandMapper =
3637
new(ViewCommandMapper)
3738
{
3839
[nameof(IEditor.Focus)] = MapFocus
3940
};
4041

41-
public MaterialEditorHandler() : base(Mapper, CommandMapper)
42+
public EditorHandler2() : base(Mapper, CommandMapper)
4243
{
4344
}
4445

@@ -88,89 +89,89 @@ protected override void DisconnectHandler(MauiMaterialEditText platformView)
8889
_set = false;
8990
}
9091

91-
public static void MapBackground(MaterialEditorHandler handler, IEditor editor)
92+
public static void MapBackground(EditorHandler2 handler, IEditor editor)
9293
{
9394
handler.PlatformView?.UpdateBackground(editor);
9495
}
9596

96-
public static void MapText(MaterialEditorHandler handler, IEditor editor)
97+
public static void MapText(EditorHandler2 handler, IEditor editor)
9798
{
9899
handler.PlatformView?.UpdateText(editor);
99100
}
100101

101-
public static void MapTextColor(MaterialEditorHandler handler, IEditor editor)
102+
public static void MapTextColor(EditorHandler2 handler, IEditor editor)
102103
{
103104
handler.PlatformView?.UpdateTextColor(editor);
104105
}
105106

106-
public static void MapPlaceholder(MaterialEditorHandler handler, IEditor editor)
107+
public static void MapPlaceholder(EditorHandler2 handler, IEditor editor)
107108
{
108109
handler.PlatformView?.UpdatePlaceholder(editor);
109110
}
110111

111-
public static void MapPlaceholderColor(MaterialEditorHandler handler, IEditor editor)
112+
public static void MapPlaceholderColor(EditorHandler2 handler, IEditor editor)
112113
{
113114
handler.PlatformView?.UpdatePlaceholderColor(editor);
114115
}
115116

116-
public static void MapCharacterSpacing(MaterialEditorHandler handler, IEditor editor)
117+
public static void MapCharacterSpacing(EditorHandler2 handler, IEditor editor)
117118
{
118119
handler.PlatformView?.UpdateCharacterSpacing(editor);
119120
}
120121

121-
public static void MapMaxLength(MaterialEditorHandler handler, IEditor editor)
122+
public static void MapMaxLength(EditorHandler2 handler, IEditor editor)
122123
{
123124
handler.PlatformView?.UpdateMaxLength(editor);
124125
}
125126

126-
public static void MapIsReadOnly(MaterialEditorHandler handler, IEditor editor)
127+
public static void MapIsReadOnly(EditorHandler2 handler, IEditor editor)
127128
{
128129
handler.PlatformView?.UpdateIsReadOnly(editor);
129130
}
130131

131-
public static void MapIsTextPredictionEnabled(MaterialEditorHandler handler, IEditor editor)
132+
public static void MapIsTextPredictionEnabled(EditorHandler2 handler, IEditor editor)
132133
{
133134
handler.PlatformView?.UpdateIsTextPredictionEnabled(editor);
134135
}
135136

136-
public static void MapIsSpellCheckEnabled(MaterialEditorHandler handler, IEditor editor)
137+
public static void MapIsSpellCheckEnabled(EditorHandler2 handler, IEditor editor)
137138
{
138139
handler.PlatformView?.UpdateIsSpellCheckEnabled(editor);
139140
}
140141

141-
public static void MapFont(MaterialEditorHandler handler, IEditor editor)
142+
public static void MapFont(EditorHandler2 handler, IEditor editor)
142143
{
143144
handler.PlatformView?.UpdateFont(editor, handler.GetRequiredService<IFontManager>());
144145
}
145146

146-
public static void MapHorizontalTextAlignment(MaterialEditorHandler handler, IEditor editor)
147+
public static void MapHorizontalTextAlignment(EditorHandler2 handler, IEditor editor)
147148
{
148149
handler.PlatformView?.UpdateHorizontalTextAlignment(editor);
149150
}
150151

151-
public static void MapVerticalTextAlignment(MaterialEditorHandler handler, IEditor editor)
152+
public static void MapVerticalTextAlignment(EditorHandler2 handler, IEditor editor)
152153
{
153154
handler.PlatformView?.UpdateVerticalTextAlignment(editor);
154155
}
155156

156-
public static void MapKeyboard(MaterialEditorHandler handler, IEditor editor)
157+
public static void MapKeyboard(EditorHandler2 handler, IEditor editor)
157158
{
158159
handler.UpdateValue(nameof(IEditor.Text));
159160

160161
handler.PlatformView?.UpdateKeyboard(editor);
161162
}
162163

163-
public static void MapCursorPosition(MaterialEditorHandler handler, ITextInput editor)
164+
public static void MapCursorPosition(EditorHandler2 handler, ITextInput editor)
164165
{
165166
handler.PlatformView?.UpdateCursorPosition(editor);
166167
}
167168

168-
public static void MapSelectionLength(MaterialEditorHandler handler, ITextInput editor)
169+
public static void MapSelectionLength(EditorHandler2 handler, ITextInput editor)
169170
{
170171
handler.PlatformView?.UpdateSelectionLength(editor);
171172
}
172173

173-
static void MapFocus(MaterialEditorHandler handler, IEditor editor, object? args)
174+
static void MapFocus(EditorHandler2 handler, IEditor editor, object? args)
174175
{
175176
if (args is FocusRequest request)
176177
{
@@ -188,7 +189,7 @@ void OnTextChanged(object? sender, TextChangedEventArgs e)
188189
DataFlowDirection = DataFlowDirection.ToPlatform;
189190
}
190191

191-
private void OnFocusChange(object? sender, FocusChangeEventArgs e)
192+
void OnFocusChange(object? sender, FocusChangeEventArgs e)
192193
{
193194
if (!e.HasFocus)
194195
{

src/Core/src/Platform/Android/Material3Controls/MauiMaterialEditText.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
namespace Microsoft.Maui.Platform;
88

9+
// TODO: Material3 - make it public in .net 11
910
internal class MauiMaterialEditText : TextInputEditText
1011
{
1112
public event EventHandler? SelectionChanged;

0 commit comments

Comments
 (0)