Skip to content
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

[Housekeeping] Including pending fixes from Xamarin.Forms SRs #8702

Closed
wants to merge 9 commits into from
Original file line number Diff line number Diff line change
Expand Up @@ -138,13 +138,12 @@ bool AActionMode.ICallback.OnPrepareActionMode(AActionMode mode, IMenu menu)

public void OnItemClick(AdapterView parent, AView view, int position, long id)
{
var listView = parent as AListView;
if (listView != null)
position -= listView.HeaderViewsCount;

if (_actionMode != null || _supportActionMode != null)
{
var listView = parent as AListView;
if (listView != null)
position -= listView.HeaderViewsCount;
HandleContextMode(view, position);
}
else
HandleItemClick(parent, view, position, id);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -514,9 +514,6 @@ protected override void HandleItemClick(AdapterView parent, AView view, int posi
cell = (Cell)(cellOwner as INativeElementView)?.Element;
}

// All our ListView's have called AddHeaderView. This effectively becomes index 0, so our index 0 is index 1 to the listView.
position--;

if (position < 0 || position >= Count)
return;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,14 @@ void UpdateFooter()
}

if (footer == null)
jsuarezruiz marked this conversation as resolved.
Show resolved Hide resolved
{
if (_footerView.ChildCount == 0)
{
AListView nativeListView = Control;
nativeListView.RemoveFooterView(_adapter.FooterView);
}
return;
}

if (_footerRenderer != null)
_footerRenderer.SetVirtualView(footer);
Expand Down Expand Up @@ -435,7 +442,14 @@ void UpdateHeader()
}

if (header == null)
{
if (_headerView.ChildCount == 0)
{
AListView nativeListView = Control;
nativeListView.RemoveHeaderView(_adapter.HeaderView);
}
return;
}

if (_headerRenderer != null)
_headerRenderer.SetVirtualView(header);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@ protected UITableViewRowAnimation ReloadSectionsAnimation
set { _dataSource.ReloadSectionsAnimation = value; }
}

[Internals.Preserve(Conditional = true)]
public ListViewRenderer(IntPtr handle)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could fix this exception #7799

{

}

public ListViewRenderer() : base(Mapper, CommandMapper)
{
AutoPackage = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,7 @@ void HandlePropertyChanged(object sender, PropertyChangedEventArgs e)
e.PropertyName == NavigationPage.BarBackgroundProperty.PropertyName)
{
UpdateBarBackground();
UpdateHideNavigationBarSeparator();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

}
else if (e.PropertyName == NavigationPage.BarTextColorProperty.PropertyName
|| e.PropertyName == StatusBarTextColorModeProperty.PropertyName)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ void CheckForEmptySource()
// If we're going from empty to having stuff, it's possible that we've never actually measured
// a prototype cell and our itemSize or estimatedItemSize are wrong/unset
// So trigger a constraint update; if we need a measurement, that will make it happen
ItemsViewLayout.ConstrainTo(CollectionView.Bounds.Size);
ConstrainToItemsView();
jsuarezruiz marked this conversation as resolved.
Show resolved Hide resolved
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#nullable enable
Microsoft.Maui.Controls.Handlers.Compatibility.ListViewRenderer.ListViewRenderer(System.IntPtr handle) -> void
override Microsoft.Maui.Controls.ContentPresenter.ArrangeOverride(Microsoft.Maui.Graphics.Rect bounds) -> Microsoft.Maui.Graphics.Size
override Microsoft.Maui.Controls.ContentPresenter.MeasureOverride(double widthConstraint, double heightConstraint) -> Microsoft.Maui.Graphics.Size
override Microsoft.Maui.Controls.FlyoutPage.OnDisappearing() -> void
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#nullable enable
Microsoft.Maui.Controls.Handlers.Compatibility.ListViewRenderer.ListViewRenderer(System.IntPtr handle) -> void
override Microsoft.Maui.Controls.ContentPresenter.ArrangeOverride(Microsoft.Maui.Graphics.Rect bounds) -> Microsoft.Maui.Graphics.Size
override Microsoft.Maui.Controls.ContentPresenter.MeasureOverride(double widthConstraint, double heightConstraint) -> Microsoft.Maui.Graphics.Size
override Microsoft.Maui.Controls.FlyoutPage.OnDisappearing() -> void
Expand Down
27 changes: 25 additions & 2 deletions src/Controls/src/Core/RadioButton.cs
Original file line number Diff line number Diff line change
Expand Up @@ -439,12 +439,35 @@ void HandleRadioButtonGroupSelectionChanged(RadioButton selected, RadioButtonGro

void HandleRadioButtonGroupValueChanged(Element layout, RadioButtonGroupValueChanged args)
{
if (IsChecked || string.IsNullOrEmpty(GroupName) || GroupName != args.GroupName || !object.Equals(Value, args.Value) || !MatchesScope(args))
if (IsChecked || string.IsNullOrEmpty(GroupName) || GroupName != args.GroupName || !MatchesScope(args))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

{
return;
}

IsChecked = true;
// If both value and args value are null, we consider it good.
if (Value == null && args.Value == null)
{
IsChecked = true;
return;
}
else if (args.Value is bool && bool.TryParse(Value.ToString(), out bool boolRes))
{
// If it is a boolean value, compare as bool
if ((bool)args.Value == boolRes)
{
IsChecked = true;
return;
}
}

// Other values we can probably safely compare as string (int, string, enum)
if (Value != null && Value.ToString().Equals(args.Value.ToString(), StringComparison.Ordinal))
{
IsChecked = true;
return;
}

IsChecked = false;
}

static void BindToTemplatedParent(BindableObject bindableObject, params BindableProperty[] properties)
Expand Down
9 changes: 8 additions & 1 deletion src/Controls/src/Core/VisualElement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,14 @@ void NotifyBackgroundChanges()
{
if (Background != null)
{
Background.Parent = this;
Dispatcher.DispatchIfRequiredAsync(() =>
{
if (Background != null)
{
Background.Parent = this;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

}
});

Background.PropertyChanged += OnBackgroundChanged;

if (Background is GradientBrush gradientBrush)
Expand Down
18 changes: 13 additions & 5 deletions src/Core/src/Handlers/Editor/EditorHandler.iOS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -156,12 +156,20 @@ void OnStarted(object? sender, EventArgs eventArgs)

void OnEnded(object? sender, EventArgs eventArgs)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

{
if (VirtualView != null)
{
VirtualView.IsFocused = false;
if (VirtualView == null || PlatformView == null)
return;

VirtualView.Completed();
}
// Typing aid changes don't always raise EditingChanged event
// Normalizing nulls to string.Empty allows us to ensure that a change from null to "" doesn't result in a change event.
// While technically this is a difference it serves no functional good.
var platformText = PlatformView.Text ?? string.Empty;
var virtualText = VirtualView.Text ?? string.Empty;

if (platformText != virtualText)
VirtualView.Text = platformText;

VirtualView.IsFocused = false;
VirtualView.Completed();
}

void OnTextPropertySet(object? sender, EventArgs e) =>
Expand Down