-
Notifications
You must be signed in to change notification settings - Fork 2k
[Android] Implement material3 support for Entry #33673
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
kubaflo
merged 12 commits into
dotnet:inflight/current
from
HarishwaranVijayakumar:material3-Entry
Mar 18, 2026
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
3f7603e
Material 3 for entry control
HarishwaranVijayakumar 33dd4ee
Refactor the code
HarishwaranVijayakumar 23e1daf
Fix for automation
HarishwaranVijayakumar dc21bfb
Add todo comments and replace to entryhandler2
HarishwaranVijayakumar 59592e7
Add comments and remove partial
HarishwaranVijayakumar 6dbc8d6
Address copilot suggestion
HarishwaranVijayakumar c7bad9b
Add UI test and address concern
HarishwaranVijayakumar 322bc98
Address copilot concern
HarishwaranVijayakumar 467dc0b
Update Apphostbuilderextension
HarishwaranVijayakumar 9ade38b
Update AppHostBuilderExtension
HarishwaranVijayakumar 80a5281
Merge branch 'inflight/current' into material3-Entry
sheiksyedm c06d266
Fix formatting for Entry handler registration
sheiksyedm File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file added
BIN
+52.1 KB
...id-notch-36/Material3Entry_CharacterSpacingWithFontFamily_VerifyVisualState.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+49 KB
...oid-notch-36/Material3Entry_CharacterSpacingWithMaxLength_VerifyVisualState.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+50.7 KB
...napshots/android-notch-36/Material3Entry_CharacterSpacing_VerifyVisualState.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+50.6 KB
...s/snapshots/android-notch-36/Material3Entry_FlowDirection_VerifyVisualState.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+50.5 KB
.../snapshots/android-notch-36/Material3Entry_FontAttributes_VerifyVisualState.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+52 KB
...ests/snapshots/android-notch-36/Material3Entry_FontFamily_VerifyVisualState.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+52.3 KB
....Tests/snapshots/android-notch-36/Material3Entry_FontSize_VerifyVisualState.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+50.6 KB
...36/Material3Entry_HorizontalAlignmentWithCharacterSpacing_VerifyVisualState.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+50.6 KB
...id-notch-36/Material3Entry_HorizontalAndVerticalAlignment_VerifyVisualState.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+117 KB
...ts/snapshots/android-notch-36/Material3Entry_InitialState_VerifyVisualState.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+117 KB
...Tests/snapshots/android-notch-36/Material3Entry_IsEnabled_VerifyVisualState.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+49.8 KB
...id-notch-36/Material3Entry_IsPasswordWithCharacterSpacing_VerifyVisualState.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+49.7 KB
...ts/android-notch-36/Material3Entry_IsPasswordWithFontSize_VerifyVisualState.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+49.7 KB
...notch-36/Material3Entry_IsPasswordWithHorizontalAlignment_VerifyVisualState.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+49.5 KB
...s/android-notch-36/Material3Entry_IsPasswordWithMaxLength_VerifyVisualState.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+49.7 KB
...d-notch-36/Material3Entry_IsPasswordWithVerticalAlignment_VerifyVisualState.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+49.7 KB
...ests/snapshots/android-notch-36/Material3Entry_IsPassword_VerifyVisualState.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+112 KB
...roid-notch-36/Material3Entry_PlaceholderColorAndTextColor_VerifyVisualState.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+47.2 KB
...napshots/android-notch-36/Material3Entry_PlaceholderColor_VerifyVisualState.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+48.8 KB
...snapshots/android-notch-36/Material3Entry_PlaceholderText_VerifyVisualState.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+49.3 KB
...oid-notch-36/Material3Entry_PlaceholderWithFontAttributes_VerifyVisualState.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+48.1 KB
...android-notch-36/Material3Entry_PlaceholderWithFontFamily_VerifyVisualState.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+49.9 KB
...s/android-notch-36/Material3Entry_PlaceholderWithFontSize_VerifyVisualState.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+47.8 KB
...otch-36/Material3Entry_PlaceholderWithHorizontalAlignment_VerifyVisualState.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+55 KB
...droid-notch-36/Material3Entry_PlaceholderWithPasswordTrue_VerifyVisualState.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+64.1 KB
...ots/android-notch-36/Material3Entry_PlaceholderWithShadow_VerifyVisualState.png
Oops, something went wrong.
Binary file added
BIN
+47.8 KB
...-notch-36/Material3Entry_PlaceholderWithVerticalAlignment_VerifyVisualState.png
Oops, something went wrong.
Binary file added
BIN
+71.7 KB
...id.Tests/snapshots/android-notch-36/Material3Entry_Shadow_VerifyVisualState.png
Oops, something went wrong.
Binary file added
BIN
+49.9 KB
...Tests/snapshots/android-notch-36/Material3Entry_TextColor_VerifyVisualState.png
Oops, something went wrong.
Binary file added
BIN
+50.6 KB
...droid-notch-36/Material3Entry_TextWithHorizontalAlignment_VerifyVisualState.png
Oops, something went wrong.
Binary file added
BIN
+50.6 KB
...android-notch-36/Material3Entry_TextWithVerticalAlignment_VerifyVisualState.png
Oops, something went wrong.
Binary file added
BIN
+50.7 KB
...h-36/Material3Entry_VerticalAlignmentWithCharacterSpacing_VerifyVisualState.png
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
117 changes: 117 additions & 0 deletions
117
...rols/tests/TestCases.HostApp/FeatureMatrix/EntryMaterial3/Material3_EntryControlPage.xaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,117 @@ | ||
| <?xml version="1.0" encoding="utf-8" ?> | ||
| <ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui" | ||
| xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | ||
| xmlns:local="clr-namespace:Maui.Controls.Sample" | ||
| x:DataType="local:EntryViewModel" | ||
| SafeAreaEdges="Container" | ||
| x:Class="Maui.Controls.Sample.Material3_EntryControlMainPage"> | ||
| <ContentPage.ToolbarItems> | ||
| <ToolbarItem Text="Options" | ||
| Clicked="NavigateToOptionsPage_Clicked" | ||
| AutomationId="Options"/> | ||
| </ContentPage.ToolbarItems> | ||
|
|
||
| <VerticalStackLayout Padding="20" | ||
| Spacing="8"> | ||
| <Label Text="Material3 Entry Control" | ||
| FontSize="20" | ||
| Margin="0,0,0,50" | ||
| HorizontalOptions="Center"/> | ||
|
|
||
| <Entry x:Name="EntryControl" | ||
| Text="{Binding Text}" | ||
| Placeholder="{Binding Placeholder}" | ||
| PlaceholderColor="{Binding PlaceholderColor}" | ||
| TextColor="{Binding TextColor}" | ||
| ClearButtonVisibility="{Binding ClearButtonVisibility}" | ||
| HorizontalTextAlignment="{Binding HorizontalTextAlignment}" | ||
| VerticalTextAlignment="{Binding VerticalTextAlignment}" | ||
| IsPassword="{Binding IsPassword}" | ||
| FontSize="{Binding FontSize}" | ||
| CharacterSpacing="{Binding CharacterSpacing}" | ||
| IsReadOnly="{Binding IsReadOnly}" | ||
| IsTextPredictionEnabled="{Binding IsTextPredictionEnabled}" | ||
| IsSpellCheckEnabled="{Binding IsSpellCheckEnabled}" | ||
| Shadow="{Binding EntryShadow}" | ||
| MaxLength="{Binding MaxLength}" | ||
| SelectionLength="{Binding SelectionLength}" | ||
| CursorPosition="{Binding CursorPosition, Mode=TwoWay}" | ||
| ReturnType="{Binding ReturnType}" | ||
| ReturnCommand="{Binding ReturnCommand}" | ||
| ReturnCommandParameter="{Binding Text}" | ||
| Keyboard="{Binding Keyboard}" | ||
| FontFamily="{Binding FontFamily}" | ||
| IsVisible="{Binding IsVisible}" | ||
| IsEnabled="{Binding IsEnabled}" | ||
| FlowDirection="{Binding FlowDirection}" | ||
| HeightRequest="{Binding HeightRequest}" | ||
| FontAttributes="{Binding FontAttributes}" | ||
| TextTransform="{Binding TextTransform}" | ||
| TextChanged="EntryControl_TextChanged" | ||
| Completed="EntryControl_Completed" | ||
| Focused="EntryControl_Focused" | ||
| Unfocused="EntryControl_Unfocused" | ||
| AutomationId="TestEntry"/> | ||
|
|
||
| <Grid HeightRequest="130"/> | ||
|
|
||
| <Grid ColumnSpacing="10" | ||
| Margin="0,10,0,10"> | ||
| <Grid.RowDefinitions> | ||
| <RowDefinition Height="Auto"/> | ||
| <RowDefinition Height="Auto"/> | ||
| </Grid.RowDefinitions> | ||
| <Grid.ColumnDefinitions> | ||
| <ColumnDefinition Width="*"/> | ||
| <ColumnDefinition Width="*"/> | ||
| </Grid.ColumnDefinitions> | ||
|
|
||
| <Label Text="Selection Length:" | ||
| FontSize="11" | ||
| Grid.Row="0" | ||
| Grid.Column="0"/> | ||
| <Label Text="Cursor position:" | ||
| FontSize="11" | ||
| Grid.Row="0" | ||
| Grid.Column="1"/> | ||
|
|
||
| <local:UITestEntry x:Name="SelectionLengthEntry" | ||
| Text="{Binding SelectionLength}" | ||
| AutomationId="SelectionLengthEntry" | ||
| IsCursorVisible="False" | ||
| TextChanged="SelectionLength_Clicked" | ||
| Grid.Row="1" | ||
| Grid.Column="0"/> | ||
| <local:UITestEntry x:Name="CursorPositionEntry" | ||
| Text="{Binding CursorPosition}" | ||
| AutomationId="CursorPositionEntry" | ||
| IsCursorVisible="False" | ||
| Grid.Row="1" | ||
| Grid.Column="1"/> | ||
| </Grid> | ||
|
|
||
| <Button Text="Update Cursor Selection" | ||
| FontSize="11" | ||
| Clicked="OnUpdateCursorAndSelectionClicked" | ||
| AutomationId="UpdateCursorAndSelectionButton"/> | ||
|
|
||
| <Label Text="Events:" | ||
| FontSize="11"/> | ||
| <Label x:Name="TextChangedLabel" | ||
| Text="{Binding TextChangedText}" | ||
| AutomationId="TextChangedLabel" | ||
| FontSize="11"/> | ||
| <Label x:Name="CompletedLabel" | ||
| Text="{Binding CompletedText}" | ||
| AutomationId="CompletedLabel" | ||
| FontSize="11"/> | ||
| <Label x:Name="FocusedLabel" | ||
| Text="{Binding FocusedText}" | ||
| AutomationId="FocusedLabel" | ||
| FontSize="11"/> | ||
| <Label x:Name="UnfocusedLabel" | ||
| Text="{Binding UnfocusedText}" | ||
| AutomationId="UnfocusedLabel" | ||
| FontSize="11"/> | ||
| </VerticalStackLayout> | ||
| </ContentPage> |
125 changes: 125 additions & 0 deletions
125
...s/tests/TestCases.HostApp/FeatureMatrix/EntryMaterial3/Material3_EntryControlPage.xaml.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,125 @@ | ||
| using System.ComponentModel; | ||
| using Microsoft.Maui.Controls; | ||
|
|
||
| namespace Maui.Controls.Sample; | ||
|
|
||
| public class Material3_EntryControlPage : NavigationPage | ||
| { | ||
| EntryViewModel _viewModel; | ||
|
|
||
| public Material3_EntryControlPage() | ||
| { | ||
| _viewModel = new EntryViewModel(); | ||
| PushAsync(new Material3_EntryControlMainPage(_viewModel)); | ||
| } | ||
| } | ||
|
|
||
| public partial class Material3_EntryControlMainPage : ContentPage | ||
| { | ||
| EntryViewModel _viewModel; | ||
|
|
||
| public Material3_EntryControlMainPage(EntryViewModel viewModel) | ||
| { | ||
| InitializeComponent(); | ||
| _viewModel = viewModel; | ||
| BindingContext = _viewModel; | ||
| EntryControl.PropertyChanged += UpdateEntryControl; | ||
| } | ||
|
|
||
| async void NavigateToOptionsPage_Clicked(object sender, EventArgs e) | ||
| { | ||
| BindingContext = _viewModel = new EntryViewModel(); | ||
| _viewModel.Text = "Test Entry"; | ||
| _viewModel.Placeholder = "Enter text here"; | ||
| _viewModel.CursorPosition = 0; | ||
| _viewModel.SelectionLength = 0; | ||
| await Navigation.PushAsync(new EntryOptionsPage(_viewModel)); | ||
| } | ||
|
|
||
| void CursorPositionButton_Clicked(object sender, EventArgs e) | ||
| { | ||
| if (int.TryParse(CursorPositionEntry.Text, out int cursorPosition)) | ||
| { | ||
| _viewModel.CursorPosition = cursorPosition; | ||
| } | ||
| } | ||
|
|
||
| void SelectionLength_Clicked(object sender, EventArgs e) | ||
| { | ||
| if (int.TryParse(SelectionLengthEntry.Text, out int selectionLength)) | ||
| { | ||
| _viewModel.SelectionLength = selectionLength; | ||
| } | ||
| } | ||
|
|
||
| void OnUpdateCursorAndSelectionClicked(object sender, EventArgs e) | ||
| { | ||
| if (int.TryParse(CursorPositionEntry.Text, out int cursorPosition)) | ||
| { | ||
| EntryControl.Focus(); | ||
| EntryControl.CursorPosition = cursorPosition; | ||
|
|
||
| if (BindingContext is EntryViewModel vm) | ||
| vm.CursorPosition = cursorPosition; | ||
| } | ||
|
|
||
| if (int.TryParse(SelectionLengthEntry.Text, out int selectionLength)) | ||
| { | ||
| EntryControl.Focus(); | ||
| EntryControl.SelectionLength = selectionLength; | ||
|
|
||
| if (BindingContext is EntryViewModel vm) | ||
| vm.SelectionLength = selectionLength; | ||
| } | ||
| CursorPositionEntry.Text = EntryControl.CursorPosition.ToString(); | ||
| SelectionLengthEntry.Text = EntryControl.SelectionLength.ToString(); | ||
| } | ||
|
|
||
| void UpdateEntryControl(object sender, PropertyChangedEventArgs args) | ||
| { | ||
| if (args.PropertyName == Entry.CursorPositionProperty.PropertyName) | ||
| CursorPositionEntry.Text = EntryControl.CursorPosition.ToString(); | ||
| else if (args.PropertyName == Entry.SelectionLengthProperty.PropertyName) | ||
| SelectionLengthEntry.Text = EntryControl.SelectionLength.ToString(); | ||
| } | ||
|
|
||
| void EntryControl_TextChanged(object sender, TextChangedEventArgs e) | ||
| { | ||
| string eventInfo = $"TextChanged: Old='{e.OldTextValue}', New='{e.NewTextValue}'"; | ||
|
|
||
| if (BindingContext is EntryViewModel vm) | ||
| { | ||
| vm.TextChangedText = eventInfo; | ||
| } | ||
| } | ||
|
|
||
| void EntryControl_Completed(object sender, EventArgs e) | ||
| { | ||
| string eventInfo = $"Completed: Event Triggered"; | ||
|
|
||
| if (BindingContext is EntryViewModel vm) | ||
| { | ||
| vm.CompletedText = eventInfo; | ||
| } | ||
| } | ||
|
|
||
| void EntryControl_Focused(object sender, FocusEventArgs e) | ||
| { | ||
| string eventInfo = $"Focused: Event Triggered"; | ||
|
|
||
| if (BindingContext is EntryViewModel vm) | ||
| { | ||
| vm.FocusedText = eventInfo; | ||
| } | ||
| } | ||
|
|
||
| void EntryControl_Unfocused(object sender, FocusEventArgs e) | ||
| { | ||
| string eventInfo = $"Unfocused: Event Triggered"; | ||
|
|
||
| if (BindingContext is EntryViewModel vm) | ||
| { | ||
| vm.UnfocusedText = eventInfo; | ||
| } | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.