void OnSetImageSource(UIImage?image)
        {
            if (image == null)
            {
                PlatformView.SetImage(null, UIControlState.Normal);
            }
            else
            {
                var maxWidth  = PlatformView.Frame.Width * 0.5f;
                var maxHeight = PlatformView.Frame.Height * 0.5f;

                var resizedImage = MaxResizeSwipeItemIconImage(image, maxWidth, maxHeight);

                try
                {
                    PlatformView.SetImage(resizedImage.ImageWithRenderingMode(UIImageRenderingMode.AlwaysTemplate), UIControlState.Normal);
                    var tintColor = VirtualView.GetTextColor();

                    if (tintColor != null)
                    {
                        PlatformView.TintColor = tintColor.ToPlatform();
                    }
                }
                catch (Exception)
                {
                    // UIImage ctor throws on file not found if MonoTouch.ObjCRuntime.Class.ThrowOnInitFailure is true;
                    MauiContext?.CreateLogger <SwipeItemMenuItemHandler>()?.LogWarning("Can not load SwipeItem Icon");
                }
            }
        }
示例#2
0
        internal async Task FirstLoadUrlAsync(string url)
        {
            try
            {
                var uri = new Uri(url);

                var          safeHostUri     = new Uri($"{uri.Scheme}://{uri.Authority}", UriKind.Absolute);
                var          safeRelativeUri = new Uri($"{uri.PathAndQuery}{uri.Fragment}", UriKind.Relative);
                NSUrlRequest request         = new NSUrlRequest(new Uri(safeHostUri, safeRelativeUri));

                if (HasCookiesToLoad(url) && !PlatformVersion.IsAtLeast(11))
                {
                    return;
                }

                await SyncPlatformCookiesAsync(url);

                PlatformView?.LoadRequest(request);
            }
            catch (UriFormatException)
            {
                // If we got a format exception trying to parse the URI, it might be because
                // someone is passing in a local bundled file page. If we can find a better way
                // to detect that scenario, we should use it; until then, we'll fall back to
                // local file loading here and see if that works:
                if (!LoadFile(url))
                {
                    MauiContext?.CreateLogger <WebViewHandler>()?.LogWarning($"Unable to Load Url {url}");
                }
            }
            catch (Exception)
            {
                MauiContext?.CreateLogger <WebViewHandler>()?.LogWarning($"Unable to Load Url {url}");
            }
        }
示例#3
0
        internal async Task ProcessNavigatedAsync(string url)
        {
            if (VirtualView == null)
            {
                return;
            }

            try
            {
                if (VirtualView.Cookies != null)
                {
                    await SyncPlatformCookiesToVirtualViewAsync(url);
                }
            }
            catch
            {
                MauiContext?.CreateLogger <WebViewHandler>()?.LogWarning("Failed to Sync Cookies");
            }

            PlatformView?.UpdateCanGoBackForward(VirtualView);
        }
示例#4
0
 protected virtual void OnImageFailed(object sender, ExceptionRoutedEventArgs exceptionRoutedEventArgs)
 {
     MauiContext?.CreateLogger <ImageButtonHandler>()?.LogWarning("Image failed to load: {exceptionRoutedEventArgs.ErrorMessage}", exceptionRoutedEventArgs.ErrorMessage);
     VirtualView?.UpdateIsLoading(false);
 }