public UIKit.UIViewController GetViewControllerForAdaptivePresentation (UIPresentationController controller, UIModalPresentationStyle style)
		{
			/*
			Load and return the adapted view controller from the Detail storyboard. 
			That storyboard is stored within the same bundle that contains this 
			class.
			*/

			var adaptableFormSheetSegueBundle = NSBundle.FromClass (new Class (typeof(AdaptableFormSheetSegue)));
			return UIStoryboard.FromName ("Detail", adaptableFormSheetSegueBundle).InstantiateViewController ("Adapted");
		}
Example #2
0
 public static Task ShowModal(
     UIViewController parentViewController,
     UIView view,
     UIModalPresentationStyle presentationStyle = UIModalPresentationStyle.FormSheet,
     UIModalTransitionStyle transitionStyle     = UIModalTransitionStyle.CoverVertical,
     Action completionHandler = null,
     bool dismissOnTapOutside = true,
     bool disposeOnFinish     = false
     )
 {
     return(ShowModal(
                parentViewController,
                new UIViewController {
         View = view
     },
                presentationStyle,
                transitionStyle,
                completionHandler,
                dismissOnTapOutside,
                disposeOnFinish
                ));
 }
Example #3
0
 public static Task ShowModal <TViewController>(
     UIViewController parentViewController,
     TViewController viewController,
     Action <TViewController, Action> dismissSubscriber,
     UIModalPresentationStyle presentationStyle = UIModalPresentationStyle.FormSheet,
     UIModalTransitionStyle transitionStyle     = UIModalTransitionStyle.CoverVertical,
     Action completionHandler = null,
     bool dismissOnTapOutside = true,
     bool disposeOnFinish     = false
     ) where TViewController : UIViewController
 {
     return(ShowModal <TViewController, object>(
                parentViewController,
                viewController,
                dismissSubscriber,
                presentationStyle,
                transitionStyle,
                completionHandler,
                (vc) => null,
                dismissOnTapOutside,
                disposeOnFinish
                ));
 }
Example #4
0
 public static Task ShowModal(
     UIViewController parentViewController,
     UIViewController viewController,
     UIModalPresentationStyle presentationStyle = UIModalPresentationStyle.FormSheet,
     UIModalTransitionStyle transitionStyle     = UIModalTransitionStyle.CoverVertical,
     Action completionHandler = null,
     bool dismissOnTapOutside = true,
     bool disposeOnFinish     = false
     )
 {
     return(ShowModal <ModalFrameController>(
                parentViewController,
                new ModalFrameController(viewController),
                (mfc, dismissAction) => {
         mfc.DoneAction = dismissAction;
     },
                presentationStyle,
                transitionStyle,
                completionHandler,
                dismissOnTapOutside,
                disposeOnFinish
                ));
 }
Example #5
0
File: Page.cs Project: sung-su/maui
 static void SetModalPresentationStyle(BindableObject element, UIModalPresentationStyle value)
 {
     element.SetValue(ModalPresentationStyleProperty, value);
 }
Example #6
0
File: Page.cs Project: sung-su/maui
 /// <include file="../../../../docs/Microsoft.Maui.Controls.PlatformConfiguration.iOSSpecific/Page.xml" path="//Member[@MemberName='SetModalPresentationStyle']/Docs" />
 public static IPlatformElementConfiguration <iOS, FormsElement> SetModalPresentationStyle(this IPlatformElementConfiguration <iOS, FormsElement> config, UIModalPresentationStyle value)
 {
     SetModalPresentationStyle(config.Element, value);
     return(config);
 }
Example #7
0
 public static UIViewController GetAdaptivePresentationStyle(IUIAdaptivePresentationControllerDelegate This, UIPresentationController controller, UIModalPresentationStyle style)
 {
     return(null);
 }
Example #8
0
 public override UIViewController GetAdaptivePresentationStyle(UIPresentationController controller, UIModalPresentationStyle style)
 {
     return(null);
 }
Example #9
0
 /// <summary>
 /// Creates a new instance of <see cref="UIViewControllerSectionsTransitionInfo"/>.
 /// </summary>
 /// <param name="allowDismissFromGesture">See <see cref="AllowDismissFromGesture"/>.</param>
 /// <param name="modalPresentationStyle">See <see cref="ModalPresentationStyle"/>.</param>
 /// <param name="modalTransitionStyle">See <see cref="ModalTransitionStyle"/>.</param>
 public UIViewControllerSectionsTransitionInfo(bool allowDismissFromGesture = true, UIModalPresentationStyle modalPresentationStyle = UIModalPresentationStyle.PageSheet, UIModalTransitionStyle modalTransitionStyle = UIModalTransitionStyle.CoverVertical)
 {
     AllowDismissFromGesture = allowDismissFromGesture;
     ModalPresentationStyle  = modalPresentationStyle;
     ModalTransitionStyle    = modalTransitionStyle;
 }
 public override UIViewController GetViewControllerForAdaptivePresentation(UIPresentationController controller, UIModalPresentationStyle style)
 {
     return(new UINavigationController(controller.PresentedViewController));
 }
Example #11
0
        public static async Task <TResult> ShowModal <TViewController, TResult>(
            UIViewController parentViewController,
            TViewController viewController,
            Action <TViewController, Action> dismissSubscriber = null,
            UIModalPresentationStyle presentationStyle         = UIModalPresentationStyle.FormSheet,
            UIModalTransitionStyle transitionStyle             = UIModalTransitionStyle.CoverVertical,
            Action completionHandler = null,
            Func <TViewController, TResult> resultGetter = null,
            bool dismissOnTapOutside = true,
            bool disposeOnFinish     = false
            ) where TViewController : UIViewController
        {
            try {
                if (completionHandler == null)
                {
                    completionHandler = Tools.Lambda.NoOp;
                }

                if (dismissOnTapOutside && presentationStyle.IsIn(UIModalPresentationStyle.FullScreen, UIModalPresentationStyle.OverFullScreen))
                {
                    dismissOnTapOutside = false;
                }

                if (dismissSubscriber == null && dismissOnTapOutside == false)
                {
                    throw new ArgumentException("dismissSubscriber is null and dismissOnTapOutside is effectively false, this will result in an unclosable modal screen");
                }


                var signal = new ManualResetEventSlim();
                viewController.ModalPresentationStyle = presentationStyle;
                viewController.ModalTransitionStyle   = transitionStyle;
                Action dismissModalDialogAction = signal.Set;
                dismissSubscriber(viewController, dismissModalDialogAction);
                var currentPresentedController = parentViewController.FindPresentedViewController();
                if (currentPresentedController != null)
                {
                    parentViewController = currentPresentedController;
                }

                viewController.ProvidesPresentationContextTransitionStyle = true;
                viewController.DefinesPresentationContext = true;
                await parentViewController.PresentViewControllerAsync(viewController, true);

                completionHandler();

                var window = parentViewController.View.Window;
                UITapGestureRecognizerEx tapOutsideGesture = null;
                if (dismissOnTapOutside)
                {
                    tapOutsideGesture = new UITapGestureRecognizerEx(async(x) => {
                        if (x.State == UIGestureRecognizerState.Ended)
                        {
                            var location = x.LocationInView(null);//Passing nil gives us coordinates in the window
                            if (!viewController.View.PointInside(viewController.View.ConvertPointFromView(location, window), null))
                            {
                                //Convert tap location into the local view's coordinate system. If outside, dismiss the view.
                                signal.Set();
                            }
                        }
                    });
                    tapOutsideGesture.NumberOfTapsRequired = 1;
                    tapOutsideGesture.CancelsTouchesInView = false;
                    window.AddGestureRecognizer(tapOutsideGesture);
                }

                await Task.Run(() => signal.Wait());

                if (dismissOnTapOutside)
                {
                    window.RemoveGestureRecognizer(tapOutsideGesture);
                }

                if (!viewController.IsBeingDismissed && parentViewController.ModalViewController == viewController)
                {
                    await viewController.DismissViewControllerAsync(true);
                }
                return(resultGetter == null ? default(TResult) : resultGetter(viewController));
            } finally {
                if (disposeOnFinish)
                {
                    viewController.Dispose();
                }
            }
        }
Example #12
0
        public UIKit.UIViewController GetViewControllerForAdaptivePresentation(UIPresentationController controller, UIModalPresentationStyle style)
        {
            /*
             * Load and return the adapted view controller from the Detail storyboard.
             * That storyboard is stored within the same bundle that contains this
             * class.
             */

            var adaptableFormSheetSegueBundle = NSBundle.FromClass(new Class(typeof(AdaptableFormSheetSegue)));

            return(UIStoryboard.FromName("Detail", adaptableFormSheetSegueBundle).InstantiateViewController("Adapted"));
        }
Example #13
0
        public UIViewController GetViewControllerForAdaptivePresentation(UIPresentationController controller, UIModalPresentationStyle style)
        {
            var navController = new UINavigationController(controller.PresentedViewController);

            if (navController != null)
            {
                var closeText = GetPopoverCloseText(navController.TopViewController);
                doneItem          = new UIBarButtonItem(closeText, UIBarButtonItemStyle.Done, null);
                doneItem.Clicked += DoneTapped;
                navController.TopViewController.NavigationItem.RightBarButtonItem = doneItem;
            }

            return(navController);
        }
Example #14
0
 public static UIViewController GetAdaptivePresentationStyle(IUIAdaptivePresentationControllerDelegate This, UIPresentationController controller, UIModalPresentationStyle style)
 {
     return null;
 }
Example #15
0
 public virtual UIViewController GetAdaptivePresentationStyle(UIPresentationController controller, UIModalPresentationStyle style)
 {
     return null;
 }