public void UseMaskTrueDefaultMaskInsersion() { SetMainPage(); var dialogService = CreateDialogService(); DialogMock.ConstructorCallback = v => DialogLayout.SetUseMask(v, true); dialogService.ShowDialog(DialogMockViewName); var useMask = DialogLayout.GetUseMask(DialogMock.Current); Assert.NotNull(useMask); Assert.True(useMask.Value); var mainPage = _currentApp.MainPage as ContentPage; var layout = mainPage.Content as AbsoluteLayout; Assert.Equal(3, layout.Children.Count); }
public void UseMaskTrueDefaultMaskInsersion() { SetMainPage(); var dialogService = CreateDialogService(); DialogMock.ConstructorCallback = v => DialogLayout.SetUseMask(v, true); dialogService.ShowDialog(DialogMockViewName); var useMask = DialogLayout.GetUseMask(DialogMock.Current); Assert.NotNull(useMask); Assert.True(useMask.Value); Assert.Single(_currentApp.MainPage.Navigation.ModalStack); var dialogPage = _currentApp.MainPage.Navigation.ModalStack.First() as DialogPage; Assert.NotNull(dialogPage); var layout = dialogPage.Content as AbsoluteLayout; Assert.Equal(2, layout.Children.Count); }
private void InsertPopupViewInCurrentPage(ContentPage currentPage, View popupView, bool hideOnBackgroundTapped, Action <IDialogParameters> callback) { View mask = DialogLayout.GetMask(popupView); if (mask is null) { Style overlayStyle = GetOverlayStyle(popupView); mask = new BoxView { Style = overlayStyle }; } mask.SetBinding(VisualElement.WidthRequestProperty, new Binding { Path = "Width", Source = currentPage }); mask.SetBinding(VisualElement.HeightRequestProperty, new Binding { Path = "Height", Source = currentPage }); if (hideOnBackgroundTapped) { var dismissCommand = new Command(() => callback(new DialogParameters())); mask.GestureRecognizers.Add(new TapGestureRecognizer { Command = dismissCommand }); } var overlay = new AbsoluteLayout(); overlay.SetValue(IsPopupHostProperty, true); var existingContent = currentPage.Content; var content = new DialogContainer { Padding = currentPage.Padding, HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.FillAndExpand, IsPageContent = true }; currentPage.Padding = new Thickness(0); var popupContainer = new DialogContainer { IsPopupContent = true, HorizontalOptions = LayoutOptions.Center, VerticalOptions = LayoutOptions.Center, Content = popupView, }; var relativeWidth = DialogLayout.GetRelativeWidthRequest(popupView); if (relativeWidth != null) { popupContainer.SetBinding(DialogContainer.WidthRequestProperty, new Binding("Width", BindingMode.OneWay, new RelativeContentSizeConverter { RelativeSize = relativeWidth.Value }, source: currentPage)); } var relativeHeight = DialogLayout.GetRelativeHeightRequest(popupView); if (relativeHeight != null) { popupContainer.SetBinding(DialogContainer.HeightRequestProperty, new Binding("Height", BindingMode.OneWay, new RelativeContentSizeConverter { RelativeSize = relativeHeight.Value }, source: currentPage)); } AbsoluteLayout.SetLayoutFlags(content, AbsoluteLayoutFlags.PositionProportional); AbsoluteLayout.SetLayoutBounds(content, new Rectangle(0f, 0f, currentPage.Width, currentPage.Height)); AbsoluteLayout.SetLayoutFlags(popupContainer, AbsoluteLayoutFlags.PositionProportional); var popupBounds = DialogLayout.GetLayoutBounds(popupView); AbsoluteLayout.SetLayoutBounds(popupContainer, popupBounds); overlay.Children.Add(content); if (DialogLayout.GetUseMask(popupContainer.Content) ?? true) { overlay.Children.Add(mask); } overlay.Children.Add(popupContainer); currentPage.Content = overlay; // The original content needs to be reparented after the Page Content has been reset. content.Content = existingContent; }
private async void PushPopupPage(PopupPage popupPage, View dialogView, Action <IDialogParameters> closeCallback, bool animated = true) { View mask = DialogLayout.GetMask(dialogView); var gesture = new TapGestureRecognizer { NumberOfTapsRequired = 1, Command = new Command <IDialogParameters>(closeCallback), CommandParameter = new DialogParameters() }; if (mask is null) { Style overlayStyle = GetOverlayStyle(dialogView); mask = new BoxView { Style = overlayStyle }; } mask.SetBinding(VisualElement.WidthRequestProperty, new Binding { Path = "Width", Source = popupPage }); mask.SetBinding(VisualElement.HeightRequestProperty, new Binding { Path = "Height", Source = popupPage }); mask.GestureRecognizers.Add(gesture); var overlay = new AbsoluteLayout(); var relativeWidth = DialogLayout.GetRelativeWidthRequest(dialogView); if (relativeWidth != null) { dialogView.SetBinding(View.WidthRequestProperty, new Binding("Width", BindingMode.OneWay, new RelativeContentSizeConverter { RelativeSize = relativeWidth.Value }, source: popupPage)); } var relativeHeight = DialogLayout.GetRelativeHeightRequest(dialogView); if (relativeHeight != null) { dialogView.SetBinding(View.HeightRequestProperty, new Binding("Height", BindingMode.OneWay, new RelativeContentSizeConverter { RelativeSize = relativeHeight.Value }, source: popupPage)); } //AbsoluteLayout.SetLayoutFlags(content, AbsoluteLayoutFlags.PositionProportional); //AbsoluteLayout.SetLayoutBounds(content, new Rectangle(0f, 0f, popupPage.Width, popupPage.Height)); AbsoluteLayout.SetLayoutFlags(dialogView, AbsoluteLayoutFlags.PositionProportional); var popupBounds = DialogLayout.GetLayoutBounds(dialogView); AbsoluteLayout.SetLayoutBounds(dialogView, popupBounds); //overlay.Children.Add(content); if (DialogLayout.GetUseMask(dialogView) ?? true) { overlay.Children.Add(mask); } else { overlay.GestureRecognizers.Add(gesture); } overlay.Children.Add(dialogView); popupPage.Content = overlay; await _popupNavigation.PushAsync(popupPage, animated); }
private void InsertPopupViewInCurrentPage(ContentPage currentPage, DialogPage modalPage, View popupView, bool hideOnBackgroundTapped, Action <IDialogParameters> callback) { View mask = DialogLayout.GetMask(popupView); if (mask is null) { Style overlayStyle = GetOverlayStyle(popupView); mask = new BoxView { Style = overlayStyle }; } mask.SetBinding(VisualElement.WidthRequestProperty, new Binding { Path = "Width", Source = modalPage }); mask.SetBinding(VisualElement.HeightRequestProperty, new Binding { Path = "Height", Source = modalPage }); if (hideOnBackgroundTapped) { var dismissCommand = new Command(() => callback(new DialogParameters())); mask.GestureRecognizers.Add(new TapGestureRecognizer { Command = dismissCommand }); } var overlay = new AbsoluteLayout(); var popupContainer = new DialogContainer { IsPopupContent = true, HorizontalOptions = LayoutOptions.Center, VerticalOptions = LayoutOptions.Center, Content = popupView, }; var relativeWidth = DialogLayout.GetRelativeWidthRequest(popupView); if (relativeWidth != null) { popupContainer.SetBinding(DialogContainer.WidthRequestProperty, new Binding("Width", BindingMode.OneWay, new RelativeContentSizeConverter { RelativeSize = relativeWidth.Value }, source: modalPage)); } var relativeHeight = DialogLayout.GetRelativeHeightRequest(popupView); if (relativeHeight != null) { popupContainer.SetBinding(DialogContainer.HeightRequestProperty, new Binding("Height", BindingMode.OneWay, new RelativeContentSizeConverter { RelativeSize = relativeHeight.Value }, source: modalPage)); } AbsoluteLayout.SetLayoutFlags(popupContainer, AbsoluteLayoutFlags.PositionProportional); var popupBounds = DialogLayout.GetLayoutBounds(popupView); AbsoluteLayout.SetLayoutBounds(popupContainer, popupBounds); if (DialogLayout.GetUseMask(popupContainer.Content) ?? true) { overlay.Children.Add(mask); } overlay.Children.Add(popupContainer); modalPage.Content = overlay; modalPage.DialogView = popupView; currentPage.Navigation.PushModalAsync(modalPage, true); }
private async void PushPopupPage(PopupPage popupPage, View dialogView) { View mask = DialogLayout.GetMask(dialogView); if (mask is null) { Style overlayStyle = GetOverlayStyle(dialogView); mask = new BoxView { Style = overlayStyle }; } mask.SetBinding(VisualElement.WidthRequestProperty, new Binding { Path = "Width", Source = popupPage }); mask.SetBinding(VisualElement.HeightRequestProperty, new Binding { Path = "Height", Source = popupPage }); var overlay = new AbsoluteLayout(); var relativeWidth = DialogLayout.GetRelativeWidthRequest(dialogView); if (relativeWidth != null) { dialogView.SetBinding(View.WidthRequestProperty, new Binding("Width", BindingMode.OneWay, new RelativeContentSizeConverter { RelativeSize = relativeWidth.Value }, source: popupPage)); } var relativeHeight = DialogLayout.GetRelativeHeightRequest(dialogView); if (relativeHeight != null) { dialogView.SetBinding(View.HeightRequestProperty, new Binding("Height", BindingMode.OneWay, new RelativeContentSizeConverter { RelativeSize = relativeHeight.Value }, source: popupPage)); } //AbsoluteLayout.SetLayoutFlags(content, AbsoluteLayoutFlags.PositionProportional); //AbsoluteLayout.SetLayoutBounds(content, new Rectangle(0f, 0f, popupPage.Width, popupPage.Height)); AbsoluteLayout.SetLayoutFlags(dialogView, AbsoluteLayoutFlags.PositionProportional); var popupBounds = DialogLayout.GetLayoutBounds(dialogView); AbsoluteLayout.SetLayoutBounds(dialogView, popupBounds); //overlay.Children.Add(content); if (DialogLayout.GetUseMask(dialogView) ?? true) { overlay.Children.Add(mask); } overlay.Children.Add(dialogView); popupPage.Content = overlay; await _popupNavigation.PushAsync(popupPage); }