-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Merge the BackgroundImageSource into Background #6819
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
Conversation
Enhances #3396 and fixes the issue where windows did not support initial backgrounds anymore
| namespace Microsoft.Maui.Controls | ||
| { | ||
| [ContentProperty(nameof(ImageSource))] | ||
| class ImageBrush : Brush |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is internal for now, but after a few tests and some additional tweaks in other places, this will work for all things.
| public static void MapBackgroundImageSource(IViewHandler handler, IView view) | ||
| { | ||
| if (view is not IViewBackgroundImagePart viewBackgroundImagePart) | ||
| return; | ||
|
|
||
| if (handler.PlatformView is not PlatformView platformView) | ||
| return; | ||
|
|
||
| var provider = handler.GetRequiredService<IImageSourceServiceProvider>(); | ||
|
|
||
| platformView.UpdateBackgroundImageSourceAsync(viewBackgroundImagePart, provider) | ||
| .FireAndForget(handler); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved all these into the common file.
| if (view.Background is ImageSourcePaint image) | ||
| { | ||
| var provider = handler.GetRequiredService<IImageSourceServiceProvider>(); | ||
|
|
||
| platformView.UpdateBackgroundImageSourceAsync(image.ImageSource, provider) | ||
| .FireAndForget(handler); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This if block here is not so great, but still is good enough. Since this logic lives here and not in the extension method, none of the controls that re-define the background mapping - such as image, label, entry - get this enhanced background support.
To fully realize this new feature, we will need to move this logic into the UpdateBackground method and make it async and all that. Also, we probably need to consolidate the several UpdateBackground methods and variants scattered about.
|
|
||
| namespace Microsoft.Maui | ||
| { | ||
| class ImageSourcePaint : Paint |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can't really be moved into Maui.Graphics as it wraps a Maui UI type. This is fine here - either public or internal - as it is not actually used by Maui.Graphics at all.
There is the ImagePaint still, but that represents an image already loaded into memory. The pixel bits. This new type represents the potential image and something must load it.
| } | ||
|
|
||
| public static async Task UpdateBackgroundImageSourceAsync(this AView platformView, IViewBackgroundImagePart viewBackgroundImagePart, IImageSourceServiceProvider? provider) | ||
| public static async Task UpdateBackgroundImageSourceAsync(this AView platformView, IImageSource? imageSource, IImageSourceServiceProvider? provider) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is technically a breaking change, but I don't think it is used in RC3 by anyone and will be quickly replaced by RC4/GA.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Page BackgroundColor appears to be propagating properly again!
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
- I'm not seeing the TypeConverter changes. am I still low on coffee, or is this missing ?
|
No type converters yet. I also kept everything internal. I tried making it public, but xamlc was not so happy. So, all internal for rc3 but we can add this in when there is more that 10 mins to launch. |
Description of Change
This PR moves the bits towards a single, unified
Backgroundproperty like all the other XAML flavours. Currently, the new types are internal until we can figure out the best way - maybe just make it public later and add XamlC?Issues Fixed
Fixes an issue where windows did not set the page background color as the background image would unset things.