Skip to content

[net7.0] Cache the dynamic AppTheme value in Controls (and not Essentials) (#11200)#13963

Merged
PureWeen merged 1 commit intonet7.0from
backport/pr-11200-to-net7.0
Mar 16, 2023
Merged

[net7.0] Cache the dynamic AppTheme value in Controls (and not Essentials) (#11200)#13963
PureWeen merged 1 commit intonet7.0from
backport/pr-11200-to-net7.0

Conversation

@mattleibow
Copy link
Member

…1200)

Previously, the RequestedAppTheme and RequestedLayoutDiection values were cached on first access and this was incorrect as they can change at runtime - both by the OS and the user.

This PR makes a few changes:

Don't cache the theme and layout in Essentials as there is no way to update the cache
Don't cache the layout anywhere because this is only accessed once when the window is [re]created
Cache the theme in the Controls Application where the events can actually handle.

---------

Co-authored-by: Rui Marinho <me@ruimarinho.net>
Co-authored-by: Matthew Leibowitz <mattleibow@live.com>
# Conflicts:
#	src/Essentials/src/AppInfo/AppInfo.android.cs
@mattleibow mattleibow requested a review from a team as a code owner March 15, 2023 15:25
@mattleibow mattleibow changed the base branch from main to net7.0 March 15, 2023 15:26
Copy link
Contributor

@jsuarezruiz jsuarezruiz left a comment

Choose a reason for hiding this comment

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

Passing the Build. LGTM.

Copy link
Contributor

@mandel-macaque mandel-macaque left a comment

Choose a reason for hiding this comment

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

minor changes.

}

public void NotifyThemeChanged() =>
(this as IApplication).ThemeChanged();
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we really need the 'as'?

Copy link
Member

Choose a reason for hiding this comment

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

If we want these changes we should do a PR to main and not lose the changes in this backport PR.

I don't think we need to block the backport PR on this, but perhaps we get a PR to main with the fixes before we complete this backport PR?

_ => AppTheme.Unspecified
};
var config = Application.Context.Resources?.Configuration;
if (config == null)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
if (config == null)
if (config is null)

Copy link
Contributor

@mandel-macaque mandel-macaque left a comment

Choose a reason for hiding this comment

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

Approving based on the fact that it is a backport.

@PureWeen PureWeen merged commit c49403b into net7.0 Mar 16, 2023
@PureWeen PureWeen deleted the backport/pr-11200-to-net7.0 branch March 16, 2023 16:30
@rmarinho
Copy link
Member

/backport to release/7.0.2xx

@github-actions
Copy link
Contributor

Started backporting to release/7.0.2xx: https://github.com/dotnet/maui/actions/runs/4469159124

@github-actions github-actions bot locked and limited conversation to collaborators Dec 13, 2023
@samhouts samhouts added the fixed-in-7.0.92 Look for this fix in 7.0.92! label Aug 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

fixed-in-7.0.92 Look for this fix in 7.0.92! t/housekeeping ♻︎

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants