Ejemplo n.º 1
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            Title = "Connect Account";
            View.BackgroundColor = ColorHelper.Background0.ToPlatformColor();

            var config = new WKWebViewConfiguration();

            config.ApplicationNameForUserAgent = "Version/8.0.2 Safari/600.2.5";

            // Create the webview
            _webView = new WKWebView(View.Frame, config);

            _urlObs = _webView.AddObserver("URL", NSKeyValueObservingOptions.New, async(o) =>
            {
                var newUrl = _webView.Url.ToString();
                await ViewModel.HandleRequestCommand.ExecuteAsync(newUrl);
            });

            View.AddSubview(_webView);

            // Navigate to the request url
            var url     = new NSUrl(ViewModel.AuthenticationDetails.ConnectUrl);
            var request = new NSUrlRequest(url);

            _webView.LoadRequest(request);

            // Cancel button
            NavigationItem.LeftBarButtonItem = new UIBarButtonItem("Cancel", UIBarButtonItemStyle.Plain, delegate { ViewModel.CloseCommand.Execute(); });
        }
Ejemplo n.º 2
0
        ///-------------------------------------------------------------------------------------------------
        /// Pull Request - manually added/fixed
        ///		Added IsAuthenticated check #88
        ///		https://github.com/xamarin/Xamarin.Auth/pull/88
        public override void ViewDidAppear(bool animated)
        {
            base.ViewDidAppear(animated);

            if (authenticator.AllowCancel && authenticator.IsAuthenticated())
            {
                Cancel();
            }

            // COSMOS
            // note, key is "loading" rather than "isLoading" which the property is exported as
            wk_loading_observer = wk_web_view.AddObserver("loading", NSKeyValueObservingOptions.New, (observedchange) =>
            {
                System.Diagnostics.Debug.WriteLine($"loading: {wk_web_view.IsLoading}");
                if (wk_web_view.IsLoading)
                {
                    this.activity.StartAnimating();
                }
                else
                {
                    this.activity.StopAnimating();
                }
            });
        }
Ejemplo n.º 3
0
        public override void ViewWillAppear(bool animated)
        {
            base.ViewWillAppear(animated);

            _webView.AddObserver(this, "estimatedProgress", NSKeyValueObservingOptions.New, IntPtr.Zero);
        }