Maui
Maui copied to clipboard
[Popup] Add `DefaultPopupOptionsSettings` and `DefaultPopupSettings` to `.UseMauiCommunityToolkit(Options)`
Description of Change
This PR grants developers the capability to set global default values for every popup in their app using DefaultPopupOptionsSettings and DefaultPopupSettings in.UseMauiCommunityToolkit(Options):
.UseMauiCommunityToolkit(static options =>
{
options.SetPopupDefaults(new DefaultPopupSettings
{
CanBeDismissedByTappingOutsideOfPopup = true,
BackgroundColor = Colors.Orange,
HorizontalOptions = LayoutOptions.End,
VerticalOptions = LayoutOptions.Start,
Margin = 72,
Padding = 4
});
options.SetPopupOptionsDefaults(new DefaultPopupOptionsSettings
{
CanBeDismissedByTappingOutsideOfPopup = true,
OnTappingOutsideOfPopup = () => hasOnTappingOutsideOfPopupExecuted = true,
PageOverlayColor = Colors.Orange,
Shadow = null,
Shape = null
});
})
PR Checklist
- [x] Has a linked Issue, and the Issue has been
approved(bug) orChampioned(feature/proposal) - [x] Has tests (if omitted, state reason in description)
- [x] Has samples (if omitted, state reason in description)
- [x] Rebased on top of
mainat time of PR - [x] Changes adhere to coding standard
- [ ] Documentation created or updated: https://github.com/MicrosoftDocs/CommunityToolkit/pulls
Additional information
This PR also fixes a bug where View.Padding was improperly being passed through to PopupBorder.Padding
I know I initiated this thought process but I wanted to play devils advocate a little before we go further. I do like the idea of allowing developers to define defaults but I want to float some thoughts by you all to see what you think:
- We should allow developers to control values through a
Stylewhich I believe is currently broken (#2747). I am not suggesting we fix it in this PR but I don't want this PR to make it any more difficult to fix - ~Perhaps a way to reduce the complexity of multiple possible values for things like
CanDismiss...is to acceptPopupOptionswhen passing in aViewto theShowPopupmethods and not when passing in aPopup? I know this breaks some symmetry but withPopupbut that might not be a bad thing.~ - I originally considered this but have struck it through because I think it causes more issues than it solves. - I would like us to make it possible for properties like
BackgroundColorandPageOverlayColorto be set using anAppThemeBinding- yes it would be possible via aStylebut should it be possible as a default too?