public MapViewPage() { Padding = new Thickness(0); _customWeb = new CustomWebView { HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.FillAndExpand }; if (Device.RuntimePlatform == Device.Android) { _customWeb.On <Android>().EnableZoomControls(true); } BackgroundColor = Color.Transparent; titleLabel = new Label { Text = "", FontSize = GlobalVars.sizeLarge, FontAttributes = FontAttributes.Bold, TextColor = GlobalVars.ThemeColorsText[(int)GlobalVars.ThemeColors.Primary], HorizontalOptions = LayoutOptions.FillAndExpand, VerticalTextAlignment = TextAlignment.Center }; var titleBar = new StackLayout { Orientation = StackOrientation.Horizontal, Children = { new CloseEventPageToolbarItem(), titleLabel }, BackgroundColor = GlobalVars.ThemeColorsBG[(int)GlobalVars.ThemeColors.Primary], }; if (Device.RuntimePlatform == Device.iOS) { var leftBar = new BoxView { }; var innerHolder = new RelativeLayout { BackgroundColor = Color.White }; innerHolder.Children.Add(_customWeb, Constraint.RelativeToParent((parent) => { return(0); }), Constraint.RelativeToParent((parent) => { return(0); }), Constraint.RelativeToParent((parent) => { return(parent.Width); }), Constraint.RelativeToParent((parent) => { return(parent.Height); })); innerHolder.Children.Add(leftBar, Constraint.RelativeToParent((parent) => { return(0); }), Constraint.RelativeToParent((parent) => { return(0); }), Constraint.RelativeToParent((parent) => { return(parent.Width * .02); }), Constraint.RelativeToParent((parent) => { return(parent.Height); })); var holder = new StackLayout { Children = { titleBar, innerHolder }, Spacing = 0 }; var rightSwipeGesture = new SwipeGestureRecognizer { Direction = SwipeDirection.Right, Threshold = 10000 }; rightSwipeGesture.Swiped += OnSwiped; leftBar.GestureRecognizers.Add(rightSwipeGesture); Content = holder; } else { Content = new StackLayout { Children = { titleBar, _customWeb }, Spacing = 0, VerticalOptions = LayoutOptions.FillAndExpand }; } }
public MapViewPage() { Padding = new Thickness(0, 20, 0, 0); customWeb = new CustomWebView { HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.FillAndExpand }; Content = new StackLayout { Children = { customWeb } }; //var browser = new BaseUrlWebView(); //var htmlSource = new HtmlWebViewSource(); //// do not set the BaseUrl on iOS because of the bug //if (Device.OS != TargetPlatform.iOS) //{ // // the BaseUrlWebViewRenderer does this for iOS, until bug is fixed // htmlSource.BaseUrl = DependencyService.Get<IBaseURL>().Get(); //} //Image boundImage = new Image { Aspect = Aspect.AspectFit }; //boundImage.SetBinding(Image.SourceProperty, "dataImage"); //Content = new Grid //{ // Padding = new Thickness(20), // Children = // { // new PinchToZoomContainer // { // Content = boundImage // } // } //}; //PROBLEM IS HERE //var data = ((DetailChoice)this.BindingContext).data; //if (data.ToLower().EndsWith(".html") || data.ToLower().EndsWith(".htm")) //{ // Content = new Grid // { // Padding = new Thickness(20), // Children = // { // new PinchToZoomContainer // { // Content = new Image() // } // } // }; //} //Otherwise we pull in the image and encode to base64 and plunk it into the webview. stupid i know. //else //{ //var data = "conventioncenter1.png"; //var htmlSource = new HtmlWebViewSource(); //var extension = Path.GetExtension(data).ToLower().Replace(".", ""); //if (extension == "jpg") //{ // extension = "jpeg"; //} //var assembly = typeof(GlobalVars).GetTypeInfo().Assembly; //Stream stream = assembly.GetManifestResourceStream("ConventionMobile.Resources." + data); //if (extension == "html" || extension == "htm") //{ // string text = ""; // using (var reader = new StreamReader(stream)) // { // text = reader.ReadToEnd(); // } // htmlSource.Html = text; //} //else //{ // byte[] byteData = getByteData(stream); // String encodedImageData = Convert.ToBase64String(byteData); // string fart = String.Format("<html><head></head><body><img src=\"data:image/{0};base64,{1}\" /></body></html>", extension, encodedImageData); // htmlSource.Html = fart; //} //htmlSource.Html = "fart"; //htmlSource.SetBinding(HtmlWebViewSource.HtmlProperty, "formattedHTMLEmbeddedImageData"); //} ////works but doesn't work //var htmlSource = new HtmlWebViewSource(); //var browser = new WebView { Source = htmlSource }; //Content = browser; //htmlSource.SetBinding(HtmlWebViewSource.HtmlProperty, "formattedHTMLEmbeddedImageData"); }