-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
adding DialogService #1825
Merged
Merged
adding DialogService #1825
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description of Change
Adds new DialogService for Prism.Forms. This follows a similar pattern to the new DialogService for WPF with a few changes for Xamarin.Forms development. Note that this works by resetting the content of the CurrentPage. It will place the current content within an AbsoluteLayout behind a mask and your Dialog. When the dialog is closed your page content will again be reset back to it's original layout.
fixes #1814
API Changes
Added:
Also adds XAML extension to Show Dialogs as well as extension methods for Registering Dialogs. In addition to the very simple
IDialogService.ShowDialog
, we have several extensions to provide a more robust API. For instance you may not have Dialog Parameters, or a callback that you wish you pass, each of these use cases is accounted for.Styling
The Dialog Service has several defaults including a mask layer that presents an Opaque Black background. This can be overridden globally providing a style
PrismDialogMaskStyle
in the ApplicationResources or on the individual Dialog by adding a style toprism:DialogLayout.MaskStyle
. Either way the style must target a BoxView.For those times where you need a completely custom mask such as you need to use a custom Gradient, this can additionally be supported by providing your own Mask:
Layout Sizing
As indicated this includes a new class called DialogLayout which is available as part of the Prism XML Namespace. This additionally contains Relative Size Request properties for both Width and Height. These values should be a double less or equal to 1 and greater than 0. If provided the Dialog will get a size request equal to the factor of your request and the size of the parent Page. This will also be bound to dynamically update on Page rotation.
The DialogLayout also provides a LayoutBounds property which allows you to override the default placement of the dialog. By default we place the dialog in the center of the page with LayoutBounds "0.5 0.5, -1, -1". This will allow the view to size properly based on it's content, not counting any Relative Width/Height Requests. You by providing your own bounds such as "0.5, 0.3, -1, -1" you can move the dialog to a higher position in the parent if you prefer the dialog not be centered.
Using QueryString Parameters
Dialogs must generally be dismissed by providing button or other interaction in which raises the RequestClose event. For many dialogs however you may wish to allow your user to simply tap the background mask to dismiss the dialog. You can pass the DialogParameter
closeOnBackgroundTapped
to add a behavior to the background mask. This will bypass your RequestClose event and attempt to close the dialog with empty DialogParameters. In order to dismiss CanCloseDialog must still return true.IAutoInitialize
This supports the new IAutoInitialize interface, however properties must use the DialogParameterAttribute instead of the NavigationParameterAttribute if you are providing a custom name or requiring a given parameter.
IActiveAware
IActiveAware is also supported. This will set IsActive to false for the CurrentPage's ViewModel while the Dialog is displayed and back to true when the dialog is closed. This could be useful if you don't care about a callback but simply want to refresh your state when the View becomes active again.
PR Checklist