Skip to content

Commit

Permalink
add CloseOnBackgroundTapped property
Browse files Browse the repository at this point in the history
  • Loading branch information
dansiegel committed Jun 30, 2019
1 parent d9c170f commit 2c195c2
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
12 changes: 10 additions & 2 deletions Source/Xamarin/Prism.Forms/Services/Dialogs/DialogService.cs
Expand Up @@ -70,8 +70,16 @@ void DialogAware_RequestClose(IDialogParameters outParameters)
}
}

parameters.TryGetValue<bool>(KnownDialogParameters.CloseOnBackgroundTapped, out var hideOnBackgroundTapped);
InsertPopupViewInCurrentPage(currentPage as ContentPage, view, hideOnBackgroundTapped, DialogAware_RequestClose);
if(!parameters.TryGetValue<bool>(KnownDialogParameters.CloseOnBackgroundTapped, out var closeOnBackgroundTapped))
{
var dialogLayoutCloseOnBackgroundTapped = DialogLayout.GetCloseOnBackgroundTapped(view);
if(dialogLayoutCloseOnBackgroundTapped.HasValue)
{
closeOnBackgroundTapped = dialogLayoutCloseOnBackgroundTapped.Value;
}
}

InsertPopupViewInCurrentPage(currentPage as ContentPage, view, closeOnBackgroundTapped, DialogAware_RequestClose);

PageUtilities.InvokeViewAndViewModelAction<IActiveAware>(currentPage, aa => aa.IsActive = false);
PageUtilities.InvokeViewAndViewModelAction<IActiveAware>(view, aa => aa.IsActive = true);
Expand Down
Expand Up @@ -52,5 +52,13 @@ public static class DialogLayout
public static void SetMask(BindableObject bindable, View value) =>
bindable.SetValue(MaskProperty, value);

public static readonly BindableProperty CloseOnBackgroundTappedProperty =
BindableProperty.CreateAttached("CloseOnBackgroundTapped", typeof(bool?), typeof(DialogLayout), null);

public static bool? GetCloseOnBackgroundTapped(BindableObject bindable) =>
(bool?)bindable.GetValue(CloseOnBackgroundTappedProperty);

public static void SetCloseOnBackgroundTapped(BindableObject bindable, bool? value) =>
bindable.SetValue(CloseOnBackgroundTappedProperty, value);
}
}

0 comments on commit 2c195c2

Please sign in to comment.