-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Handlers should not implement IImageSourcePartSetter
directly
#16901
Conversation
IImageSourcePartSetter
directly
public partial class ButtonHandler : IButtonHandler, IImageSourcePartSetter | ||
public partial class ButtonHandler : IButtonHandler |
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.
Removed the interface from the handler here.
public virtual ImageSourcePartLoader ImageSourceLoader => | ||
_imageSourcePartLoader ??= new ImageSourcePartLoader(new ButtonImageSourcePartSetter(this)); |
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.
Made this virtual so derived types can actually do something different.
static Microsoft.Maui.Handlers.SwipeItemMenuItemHandler.MapSource(Microsoft.Maui.Handlers.ISwipeItemMenuItemHandler! handler, Microsoft.Maui.ISwipeItemMenuItem! view) -> void | ||
static Microsoft.Maui.Handlers.SwipeItemMenuItemHandler.MapSource(Microsoft.Maui.Handlers.ISwipeItemMenuItemHandler! handler, Microsoft.Maui.ISwipeItemMenuItem! image) -> void |
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.
Vote on this. The param name changed so I am letting it slide, but technically breaking if the dev used named params, but that is a bit hard to do in this case.
The alternative is to duplicate the code in windows with a new param name...
src/Core/src/Handlers/SwipeItemMenuItem/ISwipeItemMenuItemHandler.cs
Outdated
Show resolved
Hide resolved
/rebase |
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.
Approving on behalf of Shane ✅
Description of Change
Handlers should not implement the
IImageSourcePartSetter
interface directly because this prevents any customization as well as does not support handlers with multiple image sources.As of today, there is no handler yet with multiple image sources and technically we can implement the interface directly on the handler, but it is not best practice. A hander should be re-usable and connecting a specific implementation to a handler is not recommended.
This PR does a few things:
IImageSourcePartSetter
interface from the handlers (button, image, image button and swipe items)ImageSourcePartLoader SourceLoader { get; }
to theISwipeItemMenuItemHandler
handler interfaceIImageSourcePartSetter
type