'use strict';

var doric = require('doric');

const colors = [
    "#70a1ff",
    "#7bed9f",
    "#ff6b81",
    "#a4b0be",
    "#f0932b",
    "#eb4d4b",
    "#6ab04c",
    "#e056fd",
    "#686de0",
    "#30336b",
].map(e => doric.Color.parse(e));
function label(str) {
    return doric.text({
        text: str,
        textSize: 16,
    });
}

const img_base64 = 'data:image/jpeg;base64,[encoded data, 166212 characters]';

var __decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
const imageUrl = 'https://img.zcool.cn/community/01e75b5da933daa801209e1ffa4649.jpg@1280w_1l_2o_100sh.jpg';
let ImageDemo = class ImageDemo extends doric.Panel {
    build(rootView) {
        let imageView;
        doric.scroller(doric.vlayout([
            doric.text({
                text: "Image Demo",
                layoutConfig: doric.layoutConfig().configWidth(doric.LayoutSpec.MOST),
                textSize: 30,
                textColor: doric.Color.WHITE,
                backgroundColor: colors[5],
                textAlignment: doric.gravity().center(),
                height: 50,
            }),
            label('Gif'),
            doric.image({
                imageUrl: "https://misc.aotu.io/ONE-SUNDAY/world-cup_2014_42.gif",
                scaleType: doric.ScaleType.ScaleToFill,
                loadCallback: function (ret) {
                    doric.log('this');
                    doric.log('loadCallback', ret);
                }
            }),
            label('APNG'),
            doric.image({
                imageUrl: "https://misc.aotu.io/ONE-SUNDAY/world_cup_2014_42.png",
                loadCallback: (ret) => {
                }
            }),
            label('Animated WebP'),
            doric.image({
                imageUrl: "https://p.upyun.com/demo/webp/webp/animated-gif-0.webp",
                loadCallback: (ret) => {
                }
            }),
            label('WebP'),
            imageView = doric.image({
                imageUrl: "https://p.upyun.com/demo/webp/webp/jpg-0.webp",
                loadCallback: (ret) => {
                    if (ret) {
                        imageView.width = ret.width;
                        imageView.height = ret.height;
                    }
                }
            }),
            label('ScaleToFill'),
            doric.image({
                imageUrl,
                width: 300,
                height: 300,
                isBlur: true,
                border: {
                    width: 2,
                    color: doric.Color.GRAY,
                },
                scaleType: doric.ScaleType.ScaleToFill,
                layoutConfig: doric.layoutConfig().just(),
                loadCallback: (ret) => {
                }
            }),
            label('ScaleAspectFit'),
            doric.image({
                imageUrl,
                width: 300,
                height: 300,
                border: {
                    width: 2,
                    color: doric.Color.GRAY,
                },
                scaleType: doric.ScaleType.ScaleAspectFit,
                layoutConfig: doric.layoutConfig().just(),
            }),
            label('ScaleAspectFill'),
            doric.image({
                imageUrl,
                width: 300,
                height: 300,
                border: {
                    width: 2,
                    color: doric.Color.GRAY,
                },
                scaleType: doric.ScaleType.ScaleAspectFill,
                layoutConfig: doric.layoutConfig().just(),
            }),
            label('ImageBase64'),
            doric.image({
                imageBase64: img_base64,
                width: 300,
                height: 300,
                border: {
                    width: 2,
                    color: doric.Color.GRAY,
                },
                scaleType: doric.ScaleType.ScaleAspectFill,
                layoutConfig: doric.layoutConfig().just(),
            }),
        ]).apply({
            layoutConfig: doric.layoutConfig().most().configHeight(doric.LayoutSpec.FIT),
            gravity: doric.gravity().center(),
            space: 10,
        })).apply({
            layoutConfig: doric.layoutConfig().most(),
        }).in(rootView);
    }
};
ImageDemo = __decorate([
    Entry
], ImageDemo);
//# sourceMappingURL=ImageDemo.js.map
