예제 #1
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            // this is the default blue color; OWA does not seem to allow you to change themes,
            // but we will nevertheless fetch this value again from CSS when it's loaded
            UpdateTheme(UIColor.FromRGB(0, 120, 215));

            var webView = new WKWebView(
                CGRect.Empty,
                new WKWebViewConfiguration {
                UserContentController = new ContentController(this)
            })
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                AllowsBackForwardNavigationGestures       = false,
                UIDelegate = this
            };

            View.AddSubview(webView);

            var layoutGuide = View.SafeAreaLayoutGuide;

            webView.LeadingAnchor.ConstraintEqualTo(layoutGuide.LeadingAnchor).Active   = true;
            webView.TrailingAnchor.ConstraintEqualTo(layoutGuide.TrailingAnchor).Active = true;
            webView.TopAnchor.ConstraintEqualTo(layoutGuide.TopAnchor).Active           = true;
            webView.BottomAnchor.ConstraintEqualTo(layoutGuide.BottomAnchor).Active     = true;

            // OWA does not behave well with main-frame scrolling in Safari,
            // so disable it here ... all of the scrolling we care about will
            // come from an overflow div, etc.
            webView.ScrollView.ScrollEnabled = false;
            webView.ScrollView.Bounces       = false;

            webView.LoadRequest(new NSUrlRequest(new NSUrl("https://outlook.office.com/owa")));

            webView.AddGestureRecognizer(new UIScreenEdgePanGestureRecognizer(gesture => {
                if (gesture.State == UIGestureRecognizerState.Ended)
                {
                    webView.EvaluateJavaScript("_showa_goBack()", (result, error) => { });
                }
            })
            {
                Edges = UIRectEdge.Left
            });
        }