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; }
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(); }
public static WebView Config(this WebView webView, WebViewSource source, CookieContainer container) { webView.Source = source; webView.Cookies = container; return(webView); }
private void Authenticate() { _mode = LoginPageMode.Authentication; Url = new UrlWebViewSource { Url = "https://checkiepy.com/login/github/" }; UpdateUi(); }
/// <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; }
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) { } }
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; } }
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."); }
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); }
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("/")); } } }
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>(); }
public WebNavigatedEventArgs(WebNavigationEvent navigationEvent, WebViewSource source, string url, WebNavigationResult result) : base(navigationEvent, source, url) { Result = result; }
public WebNavigatingEventArgs(WebNavigationEvent navigationEvent, WebViewSource source, string url) : base(navigationEvent, source, url) { }
public void LoadRandomArticle() { WebViewSource newSource = getRandomArticle(); webView.Source = newSource; }
public static WebView Source(this WebView webView, WebViewSource source) { webView.Source = source; return(webView); }
public static T Source <T>(this T webview, WebViewSource source) where T : IRxWebView { webview.Source = source; return(webview); }
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"); } }