Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
3314e14
Fixed Keyboard Scrolling in editors with Center or End VerticalTextAl…
NirmalKumarYuvaraj Mar 23, 2025
61991e6
[XC] better support for nullable props and BPs (#28550)
StephaneDelcroix Mar 23, 2025
4c09dd7
[iOS] Changing carousel view orientation with disabled loop - fix (#2…
kubaflo Mar 23, 2025
ef98fa4
Fixed ScrollView Orientation Neither issue (#27231)
Vignesh-SF3580 Mar 24, 2025
055d9ec
Fix HideSoftInputOnTapped Not Working Net9 (#28534)
SuthiYuvaraj Mar 24, 2025
99f3cc5
[Testing] Migration of Compatibility.Core platform-specific unit test…
Mar 26, 2025
d0c2ac6
Fix mistake in RadioButtonTests.Windows.cs
jsuarezruiz Mar 27, 2025
a9108aa
[Windows] Flyout Menu Icon disappears from Window Title Bar after Nav…
NirmalKumarYuvaraj Mar 28, 2025
559da79
[Android, iOS] Dynamically setting SearchHandler Query property does …
HarishwaranVijayakumar Mar 28, 2025
589fd52
[Catalyst] Fixed the CanMixGroups Set to False Still Allows Reorderin…
Ahamed-Ali Mar 30, 2025
7127454
[Android] Fix for SearchHandler Placeholder did not update when chang…
Tamilarasan-Paranthaman Apr 3, 2025
5b10625
[Testing] Migration of Compatibility.Core platform-specific unit test…
TamilarasanSF4853 Apr 3, 2025
2266e0d
Fixed Test case failure in PR 28486 (#28780)
Vignesh-SF3580 Apr 8, 2025
62b699e
Revert "Fix HideSoftInputOnTapped Not Working Net9 (#28534)" (#28802)
SuthiYuvaraj Apr 8, 2025
7e09fc7
Fixed testcase failures in PR28867. (#28889)
Vignesh-SF3580 Apr 10, 2025
767307c
[Testing] Feature Matrix UITest Cases for CollectionView Header/Foote…
LogishaSelvarajSF4525 Apr 14, 2025
fc724b0
Fixed Test case failure in PR 28867 (#28964)
Ahamed-Ali Apr 15, 2025
74fabd6
Fixed Test case failure in PR 28867 - MAC Screenshot (#29009)
PureWeen Apr 15, 2025
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
61 changes: 43 additions & 18 deletions src/Controls/src/Build.Tasks/SetPropertiesVisitor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1410,6 +1410,25 @@ static IEnumerable<Instruction> SetBinding(VariableDefinition parent, FieldRefer

static bool CanSetValue(FieldReference bpRef, bool attached, INode node, IXmlLineInfo iXmlLineInfo, ILContext context)
{
static bool CanSetValue (TypeReference bpTypeRef, VariableDefinition varValue, ILContext context, IXmlLineInfo iXmlLineInfo)
{
// If it's an attached BP, there's no second chance to handle IMarkupExtensions, so we try here.
// Worst case scenario ? InvalidCastException at runtime
if (varValue.VariableType.FullName == "System.Object")
return true;
var implicitOperator = varValue.VariableType.GetImplicitOperatorTo(context.Cache, bpTypeRef, context.Body.Method.Module);
if (implicitOperator != null)
return true;

//as we're in the SetValue Scenario, we can accept value types, they'll be boxed
if (varValue.VariableType.IsValueType && bpTypeRef.FullName == "System.Object")
return true;

if (varValue.VariableType.InheritsFromOrImplements(context.Cache, bpTypeRef) || varValue.VariableType.FullName == "System.Object")
return true;
return false;
}

var module = context.Body.Method.Module;

if (bpRef == null)
Expand All @@ -1424,22 +1443,23 @@ static bool CanSetValue(FieldReference bpRef, bool attached, INode node, IXmlLin
if (!context.Variables.TryGetValue(elementNode, out VariableDefinition varValue))
return false;


var bpTypeRef = bpRef.GetBindablePropertyType(context.Cache, iXmlLineInfo, module);
// If it's an attached BP, there's no second chance to handle IMarkupExtensions, so we try here.
// Worst case scenario ? InvalidCastException at runtime
if (varValue.VariableType.FullName == "System.Object")
return true;
var implicitOperator = varValue.VariableType.GetImplicitOperatorTo(context.Cache, bpTypeRef, module);
if (implicitOperator != null)
return true;

//as we're in the SetValue Scenario, we can accept value types, they'll be boxed
if (varValue.VariableType.IsValueType && bpTypeRef.FullName == "System.Object")
if (CanSetValue(bpTypeRef, varValue, context, iXmlLineInfo))
return true;

return varValue.VariableType.InheritsFromOrImplements(context.Cache, bpTypeRef) || varValue.VariableType.FullName == "System.Object";
if (bpTypeRef.ResolveCached(context.Cache).FullName == "System.Nullable`1")
{
bpTypeRef = ((GenericInstanceType)bpTypeRef).GenericArguments[0];
if (CanSetValue(bpTypeRef, varValue, context, iXmlLineInfo))
return true;
}

return false;
}


static bool CanGetValue(VariableDefinition parent, FieldReference bpRef, bool attached, IXmlLineInfo iXmlLineInfo, ILContext context, out TypeReference propertyType)
{
var module = context.Body.Method.Module;
Expand Down Expand Up @@ -1483,32 +1503,37 @@ static IEnumerable<Instruction> SetValue(VariableDefinition parent, FieldReferen
var @else = Create(OpCodes.Nop);
var endif = Create(OpCodes.Nop);

if (context.Variables[elementNode].VariableType.FullName == "System.Object")

var varValue = context.Variables[elementNode];
if (varValue.VariableType.FullName == "System.Object")
{
//if(value != null && value.GetType().IsAssignableFrom(typeof(BindingBase)))
yield return Create(Ldloc, context.Variables[elementNode]);
yield return Create(Ldloc, varValue);
yield return Create(Brfalse, @else);

yield return Create(Ldtoken, module.ImportReference(context.Cache, ("Microsoft.Maui.Controls", "Microsoft.Maui.Controls", "BindingBase")));
yield return Create(Call, module.ImportMethodReference(context.Cache, ("mscorlib", "System", "Type"), methodName: "GetTypeFromHandle", parameterTypes: new[] { ("mscorlib", "System", "RuntimeTypeHandle") }, isStatic: true));
yield return Create(Ldloc, context.Variables[elementNode]);
yield return Create(Ldloc, varValue);
yield return Create(Callvirt, module.ImportMethodReference(context.Cache, ("mscorlib", "System", "Object"), methodName: "GetType", paramCount: 0));
yield return Create(Callvirt, module.ImportMethodReference(context.Cache, ("mscorlib", "System", "Type"), methodName: "IsAssignableFrom", parameterTypes: new[] { ("mscorlib", "System", "Type") }));
yield return Create(Brfalse, @else);
//then
yield return Create(Ldloc, context.Variables[elementNode]);
yield return Create(Ldloc, varValue);
yield return Create(Br, endif);
//else
yield return @else;
}
var bpTypeRef = bpRef.GetBindablePropertyType(context.Cache, iXmlLineInfo, module);
foreach (var instruction in context.Variables[elementNode].LoadAs(context.Cache, bpTypeRef, module))
foreach (var instruction in varValue.LoadAs(context.Cache, bpTypeRef, module))
yield return instruction;
if (bpTypeRef.IsValueType)
{
if ( bpTypeRef.ResolveCached(context.Cache).FullName == "System.Nullable`1"
&& TypeRefComparer.Default.Equals(varValue.VariableType, ((GenericInstanceType)bpTypeRef).GenericArguments[0]))
bpTypeRef = ((GenericInstanceType)bpTypeRef).GenericArguments[0];
yield return Create(Box, module.ImportReference(bpTypeRef));

}
//endif
if (context.Variables[elementNode].VariableType.FullName == "System.Object")
if (varValue.VariableType.FullName == "System.Object")
yield return endif;

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ protected virtual void SearchHandlerPropertyChanged(object sender, System.Compon
{
UpdateTextTransform();
}
else if (e.Is(SearchHandler.PlaceholderProperty))
{
UpdatePlaceholder();
}
else if (e.Is(SearchHandler.PlaceholderColorProperty))
{
UpdatePlaceholderColor();
Expand Down Expand Up @@ -82,6 +86,28 @@ protected virtual void SearchHandlerPropertyChanged(object sender, System.Compon
{
UpdateAutomationId();
}
else if (e.Is(SearchHandler.QueryProperty))
{
UpdateText();
}
}

void UpdateText()
{
int cursorPosition = _editText.SelectionStart;
bool selectionExists = _editText.HasSelection;

_editText.Text = _searchHandler.Query ?? string.Empty;

UpdateTextTransform();

// If we had a selection, place the cursor at the end of text
// Otherwise try to maintain the cursor at its previous position
int textLength = _editText.Text?.Length ?? 0;
int newPosition = selectionExists ? textLength : Math.Min(cursorPosition, textLength);

// Prevents the cursor from resetting to position zero when text is set programmatically
_editText.SetSelection(newPosition);
}

void EditTextFocusChange(object s, AView.FocusChangeEventArgs args)
Expand Down Expand Up @@ -115,6 +141,11 @@ void UpdateFont()
_editText.SetTextSize(ComplexUnitType.Sp, (float)_searchHandler.FontSize);
}

void UpdatePlaceholder()
{
_editText.Hint = _searchHandler.Placeholder;
}

void UpdatePlaceholderColor()
{
_editText.UpdatePlaceholderColor(_searchHandler.PlaceholderColor);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,19 @@ void SearchHandlerPropertyChanged(object sender, System.ComponentModel.PropertyC
{
UpdateSearchBarVerticalTextAlignment(_uiSearchBar.FindDescendantView<UITextField>());
}
else if (e.Is(SearchHandler.QueryProperty))
{
UpdateText(_uiSearchBar.FindDescendantView<UITextField>());
}
}

void UpdateText(UITextField uiTextField)
{
if (uiTextField is null)
return;

uiTextField.Text = _searchHandler.Query;
UpdateTextTransform(uiTextField);
}

void GetDefaultSearchBarColors(UISearchBar searchBar)
Expand Down
14 changes: 14 additions & 0 deletions src/Controls/src/Core/Handlers/Items/iOS/CarouselViewController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,20 @@ public class CarouselViewController : ItemsViewController<CarouselView>

bool _isRotating;

public override void TraitCollectionDidChange(UITraitCollection previousTraitCollection)
{
if (previousTraitCollection.VerticalSizeClass == TraitCollection.VerticalSizeClass)
{
return;
}

if (ItemsView?.Loop == false || _carouselViewLoopManager is null)
{
CollectionView.ReloadData();
InitialPositionSet = false;
}
}

public CarouselViewController(CarouselView itemsView, ItemsViewLayout layout) : base(itemsView, layout)
{
CollectionView.AllowsSelection = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ public ReorderableItemsViewController(TItemsView reorderableItemsView, ItemsView
// For some reason it only seemed to work when the CollectionView was inside the Flyout section of a FlyoutPage.
// The UILongPressGestureRecognizer is simple enough to set up so let's just add our own.
InstallsStandardGestureForInteractiveMovement = false;
#if MACCATALYST
// On Mac Catalyst, the default normal press and drag interactions occur, causing the CanMixGroups = false logic to not work.
// Since all reordering logic is handled exclusively by UILongPressGestureRecognizer, we can set DragInteractionEnabled to false, ensuring that only the long press gesture is used.
CollectionView.DragInteractionEnabled = false;
#endif
}

public override bool CanMoveItem(UICollectionView collectionView, NSIndexPath indexPath)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ public ReorderableItemsViewController2(TItemsView reorderableItemsView, UICollec
// For some reason it only seemed to work when the CollectionView was inside the Flyout section of a FlyoutPage.
// The UILongPressGestureRecognizer is simple enough to set up so let's just add our own.
InstallsStandardGestureForInteractiveMovement = false;
#if MACCATALYST
// On Mac Catalyst, the default normal press and drag interactions occur, causing the CanMixGroups = false logic to not work.
// Since all reordering logic is handled exclusively by UILongPressGestureRecognizer, we can set DragInteractionEnabled to false, ensuring that only the long press gesture is used.
CollectionView.DragInteractionEnabled = false;
#endif
}

public override bool CanMoveItem(UICollectionView collectionView, NSIndexPath indexPath)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,11 @@ void UpdateBackButton()

// Set this before BackButtonVisible triggers an update to the handler
// This way all useful information is present
if (Parent is FlyoutPage flyout && flyout.ShouldShowToolbarButton() && !anyPagesPushed.Value)
if (Parent is FlyoutPage flyout && flyout.ShouldShowToolbarButton()
#if !WINDOWS // TODO NET 10 : Move this logic to ShouldShowToolbarButton
&& !anyPagesPushed.Value
#endif
)
_drawerToggleVisible = true;
else
_drawerToggleVisible = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,9 @@ public static void UpdateToolbarDynamicOverflowEnabled(this MauiToolbar platform

private static void UpdateBackButtonVisibility(MauiToolbar platformToolbar, Toolbar toolbar)
{
platformToolbar.IsBackButtonVisible =
toolbar.BackButtonVisible
? NavigationViewBackButtonVisible.Visible
platformToolbar.IsBackButtonVisible =
toolbar.BackButtonVisible
? NavigationViewBackButtonVisible.Visible
: NavigationViewBackButtonVisible.Collapsed;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ Microsoft.Maui.Controls.HybridWebView.SetInvokeJavaScriptTarget<T>(T! target) ->
~Microsoft.Maui.Controls.Xaml.IXamlTypeResolver.Resolve(string qualifiedTypeName, System.IServiceProvider serviceProvider = null, bool expandToExtension = true) -> System.Type
~Microsoft.Maui.Controls.Xaml.RequireServiceAttribute.RequireServiceAttribute(System.Type[] serviceTypes) -> void
~Microsoft.Maui.Controls.Xaml.RequireServiceAttribute.ServiceTypes.get -> System.Type[]
~override Microsoft.Maui.Controls.Handlers.Items.CarouselViewController.TraitCollectionDidChange(UIKit.UITraitCollection previousTraitCollection) -> void
~override Microsoft.Maui.Controls.Handlers.Items2.CarouselViewController2.CreateDelegator() -> UIKit.UICollectionViewDelegateFlowLayout
~override Microsoft.Maui.Controls.Handlers.Items2.CarouselViewController2.CreateItemsViewSource() -> Microsoft.Maui.Controls.Handlers.Items.IItemsViewSource
~override Microsoft.Maui.Controls.Handlers.Items2.CarouselViewController2.DetermineCellReuseId(Foundation.NSIndexPath indexPath) -> string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ Microsoft.Maui.Controls.HybridWebView.SetInvokeJavaScriptTarget<T>(T! target) ->
~Microsoft.Maui.Controls.Xaml.IXamlTypeResolver.Resolve(string qualifiedTypeName, System.IServiceProvider serviceProvider = null, bool expandToExtension = true) -> System.Type
~Microsoft.Maui.Controls.WebViewProcessTerminatedEventArgs.PlatformArgs.get -> Microsoft.Maui.Controls.PlatformWebViewProcessTerminatedEventArgs
~Microsoft.Maui.Controls.Xaml.RequireServiceAttribute.RequireServiceAttribute(System.Type[] serviceTypes) -> void
~override Microsoft.Maui.Controls.Handlers.Items.CarouselViewController.TraitCollectionDidChange(UIKit.UITraitCollection previousTraitCollection) -> void
~Microsoft.Maui.Controls.Xaml.RequireServiceAttribute.ServiceTypes.get -> System.Type[]
~override Microsoft.Maui.Controls.Handlers.Items2.CarouselViewController2.CreateDelegator() -> UIKit.UICollectionViewDelegateFlowLayout
~override Microsoft.Maui.Controls.Handlers.Items2.CarouselViewController2.CreateItemsViewSource() -> Microsoft.Maui.Controls.Handlers.Items.IItemsViewSource
Expand Down
4 changes: 4 additions & 0 deletions src/Controls/src/Core/ShellToolbar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,11 @@ internal void ApplyChanges()
}

var flyoutBehavior = (_shell as IFlyoutView).FlyoutBehavior;
#if WINDOWS
_drawerToggleVisible = flyoutBehavior is FlyoutBehavior.Flyout;
#else
_drawerToggleVisible = stack.Count <= 1 && flyoutBehavior is FlyoutBehavior.Flyout;
#endif
BackButtonVisible = backButtonVisible && stack.Count > 1;
BackButtonEnabled = _backButtonBehavior?.IsEnabled ?? true;
ToolbarItems = _toolbarTracker.ToolbarItems;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@
using System.ComponentModel;
using System.Threading.Tasks;
using Microsoft.Maui.Controls;
using Microsoft.Maui.Controls.Handlers;
using Microsoft.Maui.Graphics;
using Microsoft.Maui.Handlers;
using Microsoft.Maui.Platform;
using Xunit;


namespace Microsoft.Maui.DeviceTests
{
public partial class BoxViewTests
Expand Down Expand Up @@ -96,6 +98,25 @@ public async Task RotationConsistent()
var platformRotation = await InvokeOnMainThreadAsync(() => platformBoxView.Rotation);
Assert.Equal(expected, platformRotation);
}

[Fact]
[Description("The IsEnabled property of a BoxView should match with native IsEnabled")]
public async Task VerifyBoxViewIsEnabledProperty()
{
var boxView = new BoxView
{
IsEnabled = false
};
var expectedValue = boxView.IsEnabled;

var handler = await CreateHandlerAsync<BoxViewHandler>(boxView);
var nativeView = GetNativeBoxView(handler);
await InvokeOnMainThreadAsync(() =>
{
var isEnabled = nativeView.Enabled;
Assert.Equal(expectedValue, isEnabled);
});
}

Task<bool> GetPlatformIsVisible(ShapeViewHandler boxViewViewHandler)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
using Microsoft.Maui.Graphics.Platform;
using Microsoft.Maui.Graphics.Win2D;
using Microsoft.Maui.Handlers;
using Xunit;
using System.ComponentModel;
using Microsoft.Maui.Controls;
using Microsoft.Maui.Controls.Handlers;

namespace Microsoft.Maui.DeviceTests
{
Expand All @@ -20,6 +24,25 @@ Task<float> GetPlatformOpacity(ShapeViewHandler handler)
});
}

[Fact]
[Description("The IsEnabled property of a BoxView should match with native IsEnabled")]
public async Task BoxViewIsEnabled()
{
var boxView = new BoxView
{
IsEnabled = false
};
var expectedValue = boxView.IsEnabled;

var handler = await CreateHandlerAsync<BoxViewHandler>(boxView);
var nativeView = GetNativeBoxView(handler);
await InvokeOnMainThreadAsync(() =>
{
var isEnabled = nativeView.IsEnabled;
Assert.Equal(expectedValue, isEnabled);
});
}

Task<bool> GetPlatformIsVisible(ShapeViewHandler boxViewHandler)
{
return InvokeOnMainThreadAsync(() =>
Expand Down
17 changes: 16 additions & 1 deletion src/Controls/tests/DeviceTests/Elements/BoxView/BoxViewTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
using Microsoft.Maui.Controls;
using Microsoft.Maui.Graphics;
using Microsoft.Maui.Handlers;
using Microsoft.Maui.Controls.Handlers;
using Microsoft.Maui.Hosting;
using Xunit;
using Microsoft.Maui.Controls.Handlers;

namespace Microsoft.Maui.DeviceTests
{
Expand Down Expand Up @@ -47,6 +47,21 @@ public async Task BoxViewBackgroundColorConsistent()
await ValidateHasColor(boxView, expected, typeof(ShapeViewHandler));
}

[Fact]
[Description("The Background of a BoxView should match with native Background")]
public async Task BoxViewBackgroundConsistent()
{
var boxView = new BoxView
{
HeightRequest = 100,
WidthRequest = 200,
Background = Brush.Red
};
var expected = (boxView.Background as SolidColorBrush)?.Color;

await ValidateHasColor(boxView, expected, typeof(BoxViewHandler));
}

[Fact]
[Description("The Opacity property of a BoxView should match with native Opacity")]
public async Task VerifyBoxViewOpacityProperty()
Expand Down
Loading
Loading