Skip to content

[Android] InputTransparent="true" on a Layout breaks child controls - Fix#22345

Merged
PureWeen merged 6 commits into
dotnet:mainfrom
kubaflo:fix-22289
Jul 4, 2024
Merged

[Android] InputTransparent="true" on a Layout breaks child controls - Fix#22345
PureWeen merged 6 commits into
dotnet:mainfrom
kubaflo:fix-22289

Conversation

@kubaflo
Copy link
Copy Markdown
Contributor

@kubaflo kubaflo commented May 11, 2024

Issues Fixed

Fixes #22289
Fixes #20264
Fixes #23344

Before After
bug.mov
fixed.mov

@kubaflo kubaflo requested a review from a team as a code owner May 11, 2024 14:38
@kubaflo kubaflo requested review from PureWeen and rmarinho May 11, 2024 14:38
@dotnet-policy-service dotnet-policy-service Bot added the community ✨ Community Contribution label May 11, 2024
@dotnet-policy-service
Copy link
Copy Markdown
Contributor

Hey there @kubaflo! Thank you so much for your PR! Someone from the team will get assigned to your PR shortly and we'll get it reviewed.

@PureWeen
Copy link
Copy Markdown
Member

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 3 pipeline(s).

Comment thread src/Core/src/Handlers/View/ViewHandler.cs Outdated
@jsuarezruiz jsuarezruiz added platform/android area-layout StackLayout, GridLayout, ContentView, AbsoluteLayout, FlexLayout, ContentPresenter labels May 13, 2024
@jsuarezruiz jsuarezruiz requested a review from mattleibow May 13, 2024 11:12
@mattleibow
Copy link
Copy Markdown
Member

mattleibow commented May 16, 2024

We got a few issues with the changing container view that I tried to look at here #13114

I don't think my PR is right and needs to be done differently, but this container view issue is all over the properties.

@PureWeen
Copy link
Copy Markdown
Member

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 3 pipeline(s).

handler.UpdateValue(nameof(IView.Visibility));

#if WINDOWS
handler.UpdateValue(nameof(IView.Opacity));
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Do we know if it is just windows only? Somehow I feel opacity is such a basic feature it affects more and we just saw it with windows first.

If we don't want to move the cheese to much in the PR, maybe just make this comment an issue and I can have a look when I get back to my keyboard.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

else
handler.HasContainer = view.NeedsContainer();

handler.UpdateValue(nameof(IView.Visibility));
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can we set this so it only fires if the value of HasContainer has changed?

@mattleibow
Copy link
Copy Markdown
Member

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 3 pipeline(s).

else
handler.HasContainer = view.NeedsContainer();

if(hasContainerOldValue != handler.HasContainer)
Copy link
Copy Markdown
Member

@mattleibow mattleibow Jul 3, 2024

Choose a reason for hiding this comment

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

I wonder if this should be a command? We can keep it "internal" for now, but just a command that is triggered when the container view changes? I think there are a few places that this is important to track:

Just looking at the Core layer in my PR: https://github.com/dotnet/maui/pull/13114/files#diff-e802e21561b0e99ffbb055b9ea43d833899fc9f06d91a64c5a9067c9427b7bcc there are several things I was adding to the ContainerAffectingProperties: IView.Background, ILabel.VerticalTextAlignment, IView.Visibility, IView.Opacity, IView.Clip, IView.Shadow, IBorder.Border, IView.InputTransparent. Basically, anything that would trigger a container view also needs to be re-triggered when the container view changes.

Just like you are fixing here, if the opacity changes, we need to trigger some logic so opacity can be correctly mapped to the correct view if the visibility happens and secretly adds a container. And the same is true if you add a container because of the opacity, the visibility of both the container and platform view is managed.

I think what you have here is much better than my PR - no need to collect everything in a list - but if the command fires, each handler can control what it does when the container changes.

@PureWeen not sure if this is just abusing the system even more and we really should just do it right with a method? Maybe the view handler can get an internal OnContainerViewChanged(PlatformView oldValue, PlatformView newValue)?

All we need is a way for a handler to decide to re-fire mappers if the container changes. Commands are nice as they can be extended via third parties without having to derive from the existing handler. But, will anyone ever extend the mappers? Maybe we can have an internal virtual for now and think about it some more and maybe move to a command later?

I don't think this PR should fix everything, I would really want to add the tests for that. But if this PR can setup the base/correct/current plan for doing this with the container view, then we can add new PRs to fix things.

@PureWeen
Copy link
Copy Markdown
Member

PureWeen commented Jul 3, 2024

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 3 pipeline(s).

@PureWeen PureWeen merged commit 5e6bd05 into dotnet:main Jul 4, 2024
@samhouts samhouts added fixed-in-8.0.70 fixed-in-net9.0-nightly This may be available in a nightly release! labels Aug 2, 2024
@github-actions github-actions Bot locked and limited conversation to collaborators Sep 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-layout StackLayout, GridLayout, ContentView, AbsoluteLayout, FlexLayout, ContentPresenter community ✨ Community Contribution fixed-in-8.0.70 fixed-in-net9.0-nightly This may be available in a nightly release! platform/android

Projects

None yet

5 participants