[Android] Use a GeneralWrapperView for a Flyout View#26461
[Android] Use a GeneralWrapperView for a Flyout View#26461kubaflo wants to merge 1 commit intodotnet:mainfrom
Conversation
rmarinho
left a comment
There was a problem hiding this comment.
Can we add a test ? There/s no override for this ? we need to add the listener ?
Don t we need t clear the listener on dispose?
|
@rmarinho This is from the default Android studio template: But we use a view which is of type LayoutGroup - ContentPage is converted to it after Also when I replaced But @PureWeen wrote that setting I wonder if setting the listener is the right approach then |
e064adf to
ec7e41d
Compare
| platformHandler.UpdateFlyoutBehavior(); | ||
| } | ||
|
|
||
| internal class FlyoutContainer : ContentViewGroup |
There was a problem hiding this comment.
Maybe this?
And we can reuse this various places.
I think also in the flyoutview code you'll want to remove the _flyoutView from the wrapper view
class GeneralWrapperView : ContentViewGroup, ICrossPlatformLayout
{
public WeakReference<IView>? ChildView { get; private set; }
public GeneralWrapperView(Context context, IView childView, IMauiContext mauiContext) : base(context)
{
CrossPlatformLayout = this;
UpdatePlatformView(childView, mauiContext);
}
public void Disconnect()
{
if (ChildView == null || !ChildView.TryGetTarget(out var childView))
{
return;
}
if (ChildCount > 0)
{
GetChildAt(0)?.RemoveFromParent();
}
childView.DisconnectHandlers();
}
public void UpdatePlatformView(IView? newChildView, IMauiContext mauiContext)
{
if (ChildCount > 0)
{
GetChildAt(0)?.RemoveFromParent();
}
if (newChildView is null)
{
ChildView = null;
return;
}
ChildView = new (newChildView);
var nativeView = newChildView.ToPlatform(mauiContext);
AddView(nativeView);
}
Graphics.Size ICrossPlatformLayout.CrossPlatformMeasure(double widthConstraint, double heightConstraint)
{
if (ChildView == null || !ChildView.TryGetTarget(out var childView))
return Graphics.Size.Zero;
return childView.Arrange(new Graphics.Rect(0, 0, widthConstraint, heightConstraint));
}
public Graphics.Size CrossPlatformArrange(Graphics.Rect bounds)
{
if (ChildView == null || !ChildView.TryGetTarget(out var childView))
return Graphics.Size.Zero;
return childView.Measure(bounds.Width, bounds.Height);
}
}There was a problem hiding this comment.
Yea, it looks good, but I switched
return childView.Arrange(new Graphics.Rect(0, 0, widthConstraint, heightConstraint));
with
return childView.Measure(bounds.Width, bounds.Height);
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
There was a problem hiding this comment.
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
Comments suppressed due to low confidence (1)
src/Core/src/Handlers/FlyoutView/FlyoutViewHandler.Android.cs:383
- The OnTouchEvent method override in the FlyoutContainer class should be covered by a test case to ensure that clicks on the flyout do not propagate to the views behind it.
public override bool OnTouchEvent(MotionEvent? e)
There was a problem hiding this comment.
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
Comments suppressed due to low confidence (1)
src/Core/src/Handlers/FlyoutView/FlyoutViewHandler.Android.cs:383
- The new OnTouchEvent method in the FlyoutContainer class should be covered by a unit test to ensure that it correctly disables click-through on items behind the drawer.
public override bool OnTouchEvent(MotionEvent? e)
|
Hello, it looks like this PR has been inactive for a while. I’d really appreciate this being wrapped up, as the issue it addresses is still relevant. Is there any chance this will be fixed in near future? Thanks a lot. |

Description of Change
Introduction of
GeneralWrapperView:Added a new GeneralWrapperView class in src/Controls/src/Core/Platform/Android/GeneralWrapperView.cs to handle the wrapping of views, enabling better measurement and arrangement. Like in this PR: #26513
Issues Fixed
Fixes #26392
Screen.Recording.2024-12-08.at.14.51.08.mov
Screen.Recording.2024-12-08.at.14.50.14.mov