Пример #1
0
        public static FadeInImage assetNetwork(
            string placeholder,
            string image,
            ImageErrorWidgetBuilder placeholderErrorBuilder = null,
            ImageErrorWidgetBuilder imageErrorBuilder       = null,
            AssetBundle bundle       = null,
            float?placeholderScale   = null,
            float imageScale         = 1.0f,
            TimeSpan?fadeOutDuration = null,
            Curve fadeOutCurve       = null,
            TimeSpan?fadeInDuration  = null,
            Curve fadeInCurve        = null,
            float?width  = null,
            float?height = null,
            BoxFit?fit   = null,
            AlignmentGeometry alignment = null,
            ImageRepeat repeat          = ImageRepeat.noRepeat,
            bool matchTextDirection     = false,
            Key key = null,
            int?placeholderCacheWidth  = null,
            int?placeholderCacheHeight = null,
            int?imageCacheWidth        = null,
            int?imageCacheHeight       = null
            )
        {
            fadeOutDuration = fadeOutDuration ?? new TimeSpan(0, 0, 0, 0, 300);
            fadeOutCurve    = fadeOutCurve ?? Curves.easeOut;
            fadeInDuration  = fadeInDuration ?? new TimeSpan(0, 0, 0, 0, 700);
            fadeInCurve     = Curves.easeIn;
            alignment       = alignment ?? Alignment.center;
            var holder       = placeholderScale ?? 1.0f;
            var _placeholder = placeholderScale != null
                ? ResizeImage.resizeIfNeeded(placeholderCacheWidth, placeholderCacheHeight,
                                             new ExactAssetImage(placeholder, bundle : bundle, scale : holder))
                               : ResizeImage.resizeIfNeeded(placeholderCacheWidth, placeholderCacheHeight,
                                                            new AssetImage(placeholder, bundle : bundle));

            return(new FadeInImage(
                       placeholder: _placeholder,
                       placeholderErrorBuilder: placeholderErrorBuilder,
                       image: ResizeImage.resizeIfNeeded(imageCacheWidth, imageCacheHeight, new NetworkImage(image, scale: imageScale)),
                       imageErrorBuilder: imageErrorBuilder,
                       fadeOutDuration: fadeOutDuration,
                       fadeOutCurve: fadeOutCurve,
                       fadeInDuration: fadeInDuration,
                       fadeInCurve: fadeInCurve,
                       width: width, height: height,
                       fit: fit,
                       alignment: alignment,
                       repeat: repeat,
                       matchTextDirection: matchTextDirection,
                       key: key
                       ));
        }
Пример #2
0
        public static FadeInImage memoryNetwork(
            byte[] placeholder,
            string image,
            Key key = null,
            ImageErrorWidgetBuilder placeholderErrorBuilder = null,
            ImageErrorWidgetBuilder imageErrorBuilder       = null,
            float placeholderScale   = 1.0f,
            float imageScale         = 1.0f,
            TimeSpan?fadeOutDuration = null,
            Curve fadeOutCurve       = null,
            TimeSpan?fadeInDuration  = null,
            Curve fadeInCurve        = null,
            float?width  = null,
            float?height = null,
            BoxFit?fit   = null,
            AlignmentGeometry alignment = null,
            ImageRepeat repeat          = ImageRepeat.noRepeat,
            bool matchTextDirection     = false,
            int?placeholderCacheWidth   = null,
            int?placeholderCacheHeight  = null,
            int?imageCacheWidth         = null,
            int?imageCacheHeight        = null
            )
        {
            alignment       = alignment ?? Alignment.center;
            fadeOutDuration = fadeOutDuration ?? TimeSpan.FromMilliseconds(300);
            fadeOutCurve    = fadeOutCurve ?? Curves.easeOut;
            fadeInDuration  = fadeInDuration ?? TimeSpan.FromMilliseconds(700);
            fadeInCurve     = fadeInCurve ?? Curves.easeIn;
            ImageProvider memoryImage  = new MemoryImage(placeholder, placeholderScale);
            ImageProvider networkImage = new NetworkImage(image, imageScale);

            //placeholder = ResizeImage.resizeIfNeeded(placeholderCacheWidth, placeholderCacheHeight, memoryImage);
            //image = ResizeImage.resizeIfNeeded(imageCacheWidth, imageCacheHeight, networkImage);
            return(new FadeInImage(
                       placeholder: ResizeImage.resizeIfNeeded(placeholderCacheWidth, placeholderCacheHeight, memoryImage),
                       placeholderErrorBuilder: placeholderErrorBuilder,
                       image: ResizeImage.resizeIfNeeded(imageCacheWidth, imageCacheHeight, networkImage),
                       imageErrorBuilder: imageErrorBuilder,
                       fadeOutDuration: fadeOutDuration,
                       fadeOutCurve: fadeOutCurve,
                       fadeInDuration: fadeInDuration,
                       fadeInCurve: fadeInCurve,
                       width: width, height: height,
                       fit: fit,
                       alignment: alignment,
                       repeat: repeat,
                       matchTextDirection: matchTextDirection,
                       key: key
                       ));
        }
Пример #3
0
        public static Image asset(
            string name,
            Key key                              = null,
            AssetBundle bundle                   = null,
            ImageFrameBuilder frameBuilder       = null,
            ImageErrorWidgetBuilder errorBuilder = null,
            float?scale                          = null,
            float?width                          = null,
            float?height                         = null,
            Color color                          = null,
            BlendMode colorBlendMode             = BlendMode.srcIn,
            BoxFit?fit                           = null,
            Alignment alignment                  = null,
            ImageRepeat repeat                   = ImageRepeat.noRepeat,
            Rect centerSlice                     = null,
            bool matchTextDirection              = false,
            bool gaplessPlayback                 = false,
            string package                       = null,
            FilterQuality filterQuality          = FilterQuality.low,
            int?cacheWidth                       = default,
            int?cacheHeight                      = null
            )
        {
            var _scale = scale ?? 1.0f;
            var _image = scale != null
                ? (AssetBundleImageProvider) new ExactAssetImage(assetName: name, bundle: bundle, scale: _scale)
                : new AssetImage(assetName: name, bundle: bundle);
            var _Image = ResizeImage.resizeIfNeeded(cacheWidth: cacheWidth, cacheHeight: cacheHeight, provider: _image);

            return(new Image(
                       key: key,
                       image: _Image,
                       frameBuilder: frameBuilder,
                       null,
                       errorBuilder: errorBuilder,
                       width: width,
                       height: height,
                       color: color,
                       colorBlendMode: colorBlendMode,
                       fit: fit,
                       alignment: alignment,
                       repeat: repeat,
                       centerSlice: centerSlice,
                       matchTextDirection: matchTextDirection,
                       gaplessPlayback: gaplessPlayback,
                       filterQuality: filterQuality
                       ));
        }
Пример #4
0
        public static Image network(
            string src,
            Key key     = null,
            float scale = 1.0f,
            ImageFrameBuilder frameBuilder       = null,
            ImageLoadingBuilder loadingBuilder   = null,
            ImageErrorWidgetBuilder errorBuilder = null,
            float?width              = null,
            float?height             = null,
            Color color              = null,
            BlendMode colorBlendMode = BlendMode.srcIn,
            BoxFit?fit = null,
            AlignmentGeometry alignment          = null,
            ImageRepeat repeat                   = ImageRepeat.noRepeat,
            Rect centerSlice                     = null,
            bool gaplessPlayback                 = false,
            bool matchTextDirection              = false,
            FilterQuality filterQuality          = FilterQuality.low,
            IDictionary <string, string> headers = null,
            int?cacheWidth  = null,
            int?cacheHeight = null
            )
        {
            var image = ResizeImage.resizeIfNeeded(cacheWidth: cacheWidth, cacheHeight: cacheHeight,
                                                   new NetworkImage(url: src, scale: scale, headers: headers));

            return(new Image(
                       key: key,
                       image: image,
                       frameBuilder: frameBuilder,
                       loadingBuilder: loadingBuilder,
                       errorBuilder: errorBuilder,
                       width: width,
                       height: height,
                       color: color,
                       colorBlendMode: colorBlendMode,
                       fit: fit,
                       alignment: alignment,
                       repeat: repeat,
                       centerSlice: centerSlice,
                       matchTextDirection: matchTextDirection,
                       gaplessPlayback: gaplessPlayback,
                       filterQuality: filterQuality
                       ));
        }
Пример #5
0
        public static Image memory(
            byte[] bytes,
            Key key     = null,
            float scale = 1.0f,
            ImageFrameBuilder frameBuilder       = null,
            ImageErrorWidgetBuilder errorBuilder = null,
            float?width              = null,
            float?height             = null,
            Color color              = null,
            BlendMode colorBlendMode = BlendMode.srcIn,
            BoxFit?fit                  = null,
            Alignment alignment         = null,
            ImageRepeat repeat          = ImageRepeat.noRepeat,
            Rect centerSlice            = null,
            bool matchTextDirection     = false,
            bool gaplessPlayback        = false,
            FilterQuality filterQuality = FilterQuality.low,
            int?cacheWidth              = default,
            int?cacheHeight             = null
            )
        {
            // ResizeImage.resizeIfNeeded(cacheWidth, cacheHeight, MemoryImage(bytes, scale: scale));
            var memoryImage = new MemoryImage(bytes: bytes, scale: scale);

            return(new Image(
                       key: key,
                       ResizeImage.resizeIfNeeded(cacheWidth: cacheWidth, cacheHeight: cacheHeight,
                                                  new MemoryImage(bytes: bytes, scale: scale)),
                       frameBuilder: frameBuilder,
                       null,
                       errorBuilder: errorBuilder,
                       width: width,
                       height: height,
                       color: color,
                       colorBlendMode: colorBlendMode,
                       fit: fit,
                       alignment: alignment,
                       repeat: repeat,
                       centerSlice: centerSlice,
                       matchTextDirection: matchTextDirection,
                       gaplessPlayback: gaplessPlayback,
                       filterQuality: filterQuality
                       ));
        }