protected override void OnAppearing()
        {
            base.OnAppearing();

            if (Device.RuntimePlatform == Device.Android)
            {
                _GifHolder.IsVisible = false;
            }

            if (!IsFreshLoad)
            {
                URL = App.BaseURL + App.Stories;

                _ParentStack.Children.RemoveAt(1);
            }

            if (Device.RuntimePlatform == Device.iOS)
            {
                _ParentStack.Margin = new Thickness(0, DependencyService.Get <IStatusBar>().GetHeight(), 0, 0);
            }

            _Error.Source = ImageSource.FromResource("ScenicPlots.Assets.error404.png", typeof(StoriesPage));

            if (_ParentStack.Children.Count >= 2)
            {
                ContainerPage.CheckConnection(URL, _Frame, _WebViewer, _ParentStack, _Error, _GifHolder, AndroidLoadingLabel);
            }

            _WebViewer.Source = URL;
        }
예제 #2
0
 public WebPage(WebViewSource webpage)
 {
     InitializeComponent();
     ViewModel      = new ViewModels.PrintListViewModel();
     BindingContext = ViewModel;
     webView.Source = webpage;
 }
        protected virtual void Load()
        {
            if (_ignoreSourceChanges)
            {
                return;
            }

            WebViewSource    source = Element.Source;
            UrlWebViewSource uri    = source as UrlWebViewSource;

            if (uri != null)
            {
                Control.LoadRequest(new NSUrlRequest(new NSUrl(uri.Url)));
            }
            else
            {
                HtmlWebViewSource html = source as HtmlWebViewSource;
                if (html != null)
                {
                    Control.LoadHtmlString(html.Html, new NSUrl("/"));
                }
            }

            UpdateCanGoBackForward();
        }
예제 #4
0
        public static WebView Config(this WebView webView, WebViewSource source, CookieContainer container)
        {
            webView.Source  = source;
            webView.Cookies = container;

            return(webView);
        }
예제 #5
0
 private void Authenticate()
 {
     _mode = LoginPageMode.Authentication;
     Url   = new UrlWebViewSource {
         Url = "https://checkiepy.com/login/github/"
     };
     UpdateUi();
 }
예제 #6
0
        /// <summary>
        /// Sets up WebView control
        /// </summary>
        /// <returns>task to wait on</returns>
        private async Task SetupWebViewAsync()
        {
            this.taskCompletionSourcePageLoaded = new TaskCompletionSource <bool>();

            var platform = DependencyService.Get <IPlatform>();

            WebViewSource webViewSource = null;

            if (Device.RuntimePlatform == Device.Android)
            {
                string htmlText = platform.LoadAssetText("map/map3D.html");

                webViewSource = new HtmlWebViewSource
                {
                    Html    = htmlText,
                    BaseUrl = platform.WebViewBasePath + "map/"
                };
            }

            if (Device.RuntimePlatform == Device.UWP)
            {
                webViewSource = new UrlWebViewSource
                {
                    Url = platform.WebViewBasePath + "map/map3D.html"
                };
            }

            var webView = new WebView
            {
                Source = webViewSource,

                VerticalOptions   = LayoutOptions.FillAndExpand,
                HorizontalOptions = LayoutOptions.FillAndExpand
            };

            webView.AutomationId = "ExploreMapWebView";

            webView.Navigating += this.OnNavigating_WebView;
            webView.Navigated  += this.OnNavigated_WebView;

            this.mapView = new MapView(webView);

            this.mapView.ShowLocationDetails += async(locationId) => await this.OnMapView_ShowLocationDetails(locationId);

            this.mapView.NavigateToLocation += async(locationId) => await this.OnMapView_NavigateToLocation(locationId);

            this.mapView.ShareMyLocation += async() => await this.OnMapView_ShareMyLocation();

            this.mapView.AddFindResult += async(name, point) => await this.OnMapView_AddFindResult(name, point);

            this.mapView.LongTap += async(point) => await this.OnMapView_LongTap(point);

            this.mapView.AddTourPlanLocation += async(locationId) => await this.OnMapView_AddTourPlanLocation(locationId);

            this.Content = webView;

            await this.taskCompletionSourcePageLoaded.Task;
        }
예제 #7
0
 public FacebookLoginPageViewModel(INavigationService navigationService, IEventAggregator ea, IPageDialogService pageDialogService)
 {
     _navigationService = navigationService;
     _ea = ea;
     this.pageDialogService = pageDialogService;
     ApiRequest             = "https://www.facebook.com/dialog/oauth?client_id="
                              + _clientId
                              + "&display=popup&response_type=token&redirect_uri=https://www.facebook.com/connect/login_success.html";
 }
 private void HandleElementNavigating(object sender, WebNavigatingEventArgs e)
 {
     try
     {
         _lastNavigationEvent = e.NavigationEvent;
         _lastSource          = e.Source;
         _lastUrl             = e.Url;
     }
     catch (Exception)
     {
     }
 }
예제 #9
0
 public override void Initialize(INavigationParameters parameters)
 {
     IsBusy = true;
     try
     {
         WebViewSource = Xamarin.Forms.DependencyService.Get <IBaseURLService>().Get() + "/info.html";
     }
     catch (Exception ex)
     {
         Dialog.Toast(ex.Message, TimeSpan.FromSeconds(5));
     }
     finally
     {
         IsBusy = false;
     }
 }
예제 #10
0
        static Uri GetSourceUrl(WebViewSource source)
        {
            Debug.Assert(source != null, "source cannot be null.");

            var urlWebViewSource = source as UrlWebViewSource;

            if (urlWebViewSource != null)
            {
                if (urlWebViewSource.Url.IsValidAbsoluteUrl())
                {
                    return(new Uri(urlWebViewSource.Url));
                }
            }

            throw new InvalidOperationException("WebViewSource is Invalid. Only UrlWebViewSource is accepted.");
        }
예제 #11
0
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            WebViewSource webviewSource = null;

            if (value == null)
            {
                return(webviewSource);
            }


            webviewSource = new UrlWebViewSource()
            {
                Url = value.ToString()
            };

            return(webviewSource);
        }
예제 #12
0
        protected virtual void Load()
        {
            WebViewSource    source = Element.Source;
            UrlWebViewSource uri    = source as UrlWebViewSource;

            if (uri != null)
            {
                Control.LoadRequest(new NSUrlRequest(new NSUrl(uri.Url)));
            }
            else
            {
                HtmlWebViewSource html = source as HtmlWebViewSource;
                if (html != null)
                {
                    Control.LoadHtmlString(html.Html, new NSUrl("/"));
                }
            }
        }
예제 #13
0
        public ViewArticlePage(WebViewSource webViewSource, string actionText, Command actionCommand)
        {
            InitializeComponent();
            webView.Source = webViewSource;
            GoBackCommand  = new Command(GoBack);
            backButton.GestureRecognizers.Add(new TapGestureRecognizer {
                Command = GoBackCommand
            });

            ActionCommand     = actionCommand;
            actionButton.Text = actionText;
            actionButton.GestureRecognizers.Add(new TapGestureRecognizer {
                Command = actionCommand
            });

            randomButton.IsVisible = false;

            localArticlesService = DependencyService.Resolve <ILocalArticlesService>();
            hTMLService          = DependencyService.Resolve <IHTMLService>();
        }
예제 #14
0
		public WebNavigatedEventArgs(WebNavigationEvent navigationEvent, WebViewSource source, string url, WebNavigationResult result) : base(navigationEvent, source, url)
		{
			Result = result;
		}
예제 #15
0
 public WebNavigatingEventArgs(WebNavigationEvent navigationEvent, WebViewSource source, string url) : base(navigationEvent, source, url)
 {
 }
예제 #16
0
        public void LoadRandomArticle()
        {
            WebViewSource newSource = getRandomArticle();

            webView.Source = newSource;
        }
예제 #17
0
 public static WebView Source(this WebView webView, WebViewSource source)
 {
     webView.Source = source;
     return(webView);
 }
예제 #18
0
 public static T Source <T>(this T webview, WebViewSource source) where T : IRxWebView
 {
     webview.Source = source;
     return(webview);
 }
예제 #19
0
		public WebNavigatingEventArgs(WebNavigationEvent navigationEvent, WebViewSource source, string url) : base(navigationEvent, source, url)
		{
		}
예제 #20
0
        public static void CheckConnection(WebViewSource Url, Frame ErrorFrame, WebView PageWebView, StackLayout ParentStack, Image _Error, WebView GifHolder, Label AndroidLoadingLabel = null)
        {
            try
            {
                ///init check if app is connected to the internet
                if (CrossConnectivity.IsSupported && !CrossConnectivity.Current.IsConnected)
                {
                    ErrorFrame.IsVisible = true;
                    if (PageWebView != null && ParentStack.Children.Contains(PageWebView))
                    {
                        PageWebView.IsVisible = false;
                        ParentStack.Children.Remove(PageWebView);
                        PageWebView = null;

                        _Error.IsVisible = true;
                    }
                }
                else
                {
                    ErrorFrame.IsVisible = false;

                    if (ParentStack.Children.Count > 2 && Device.RuntimePlatform != Device.Android)
                    {
                        ParentStack.Children.Remove(PageWebView);
                    }
                    else if (ParentStack.Children.Count > 2 && Device.RuntimePlatform == Device.Android)
                    {
                        ParentStack.Children.Remove(PageWebView);
                        if (ParentStack.Children.Count > 2)
                        {
                            ParentStack.Children.Add(AndroidLoadingLabel);
                        }
                    }

                    PageWebView = new WebView
                    {
                        HorizontalOptions = LayoutOptions.FillAndExpand,
                        VerticalOptions   = LayoutOptions.FillAndExpand,
                        Source            = Url,
                    };

                    PageWebView.Navigated += (sender, e) =>
                    {
                        GifHolder.IsVisible = false;
                        if (AndroidLoadingLabel != null && ParentStack.Children.Contains(AndroidLoadingLabel))
                        {
                            AndroidLoadingLabel.IsVisible = false;
                        }

                        PageWebView.IsVisible = true;
                    };

                    PageWebView.Navigating += (sender, e) =>
                    {
                        PageWebView.IsVisible = false;
                        //if (Device.RuntimePlatform != Device.Android)
                        //{
                        //    GifHolder.IsVisible = true;
                        //}
                        //else
                        //{
                        //    if (AndroidLoadingLabel != null && ParentStack.Children.Contains(AndroidLoadingLabel))
                        //    {
                        //        AndroidLoadingLabel.IsVisible = true;
                        //    }
                        //    else
                        //    {
                        //        if (AndroidLoadingLabel != null) ParentStack.Children.Add(AndroidLoadingLabel);
                        //    }
                        //}
                        //secondary check during navigation
                        if (!CrossConnectivity.Current.IsConnected)
                        {
                            ErrorFrame.IsVisible = true;

                            if (PageWebView != null && ParentStack.Children.Contains(PageWebView))
                            {
                                PageWebView      = null;
                                _Error.IsVisible = true;
                            }
                        }



                        //App.Current.MainPage.DisplayAlert("Alert", e.Url + "\n" + App.BaseURL + "/signin\n" + NavPage.PageInstance.CurrentPage + "\n" + NavPage.PageInstance.Children[2], "Ok");

                        if (e.Url.Contains(Signout))
                        {
                            e.Cancel = true;
                            DependencyService.Get <ICookieHandler>().CookieHandler(true);
                            App.Current.MainPage.Navigation.PushAsync(new LoginPage());
                        }
                        else if (e.Url == App.BaseURL & !IsFromThisPage)
                        {
                            e.Cancel = true;

                            if (NavPage.PageInstance.CurrentPage == NavPage.PageInstance.Children[1])
                            {
                                StoriesPage.IsFreshLoad = false;                                                                       ///refresh stories page on return to page
                            }
                            if (NavPage.PageInstance.CurrentPage != NavPage.PageInstance.Children[0])
                            {
                                NavPage.PageInstance.CurrentPage = NavPage.PageInstance.Children[0];                                                                       // switch pages
                            }
                        }
                        else if ((e.Url.Contains(App.Signin) && !e.Url.Contains(Signin_Web)) && (NavPage.PageInstance.CurrentPage != NavPage.PageInstance.Children[2]))
                        {
                            e.Cancel = true;
                            App.Current.MainPage.Navigation.PushAsync(new LoginPage());
                        }
                        else if (e.Url.Contains(App.Signup) && !IsFromThisPage)
                        {
                            e.Cancel = true;
                            App.Current.MainPage.Navigation.PushAsync(new SlidePage1());
                        }
                    };

                    if (ParentStack.Children.Count < 3)
                    {
                        ParentStack.Children.Add(PageWebView);
                    }
                }
            }
            catch
            {
                App.Current.MainPage.DisplayAlert("Alert", "An error occured.", "Okay");
            }
        }
예제 #21
0
 public WebNavigatedEventArgs(WebNavigationEvent navigationEvent, WebViewSource source, string url, WebNavigationResult result) : base(navigationEvent, source, url)
 {
     Result = result;
 }