"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ThemeTest = void 0;
const tslib_1 = require("tslib");
const React = tslib_1.__importStar(require("react"));
const react_native_1 = require("react-native");
const react_native_2 = require("@fluentui/react-native");
const e2e_testing_1 = require("@fluentui-react-native/e2e-testing");
const theme_types_1 = require("@fluentui-react-native/theme-types");
const themed_stylesheet_1 = require("@fluentui-react-native/themed-stylesheet");
const styles_1 = require("../Common/styles");
const Test_1 = require("../Test");
const getThemedStyles = (0, themed_stylesheet_1.themedStyleSheet)((theme) => {
    return {
        swatch: {
            width: 80,
            height: 20,
            marginRight: 5,
            borderWidth: 2,
            borderColor: theme.colors.bodyText,
        },
    };
});
const styles = react_native_1.StyleSheet.create({
    swatchItem: {
        flexDirection: 'row',
        alignItems: 'center',
        marginVertical: 5,
    },
    panel: {
        ...styles_1.commonTestStyles.view,
        borderWidth: 2,
        padding: 12,
        margin: 8,
    },
    pickerContainer: {
        flexDirection: 'row',
        justifyContent: 'space-evenly',
    },
    stackStyle: {
        borderWidth: 2,
        padding: 12,
        margin: 8,
    },
});
const Panel = () => {
    const [disabled, setDisabled] = React.useState(false);
    const onClick = React.useCallback(() => setDisabled(!disabled), [disabled, setDisabled]);
    return (React.createElement(react_native_1.View, { style: styles.panel },
        React.createElement(react_native_2.PrimaryButton, { onClick: onClick, content: "Primary Button", disabled: disabled }),
        React.createElement(react_native_2.Button, { onClick: onClick, content: "Default Button", disabled: disabled }),
        React.createElement(react_native_2.StealthButton, { onClick: onClick, content: "Stealth Button", disabled: disabled }),
        React.createElement(react_native_2.Text, null, "This is a text element"),
        React.createElement(react_native_2.Button, { onClick: onClick, content: "This button has longer text", disabled: disabled })));
};
const getSwatchColorStyle = (name, color) => {
    styles[name] = styles[name] || { backgroundColor: color };
    return styles[name];
};
const SemanticColor = (p) => {
    const themedStyles = getThemedStyles((0, theme_types_1.useTheme)());
    return (React.createElement(react_native_1.View, { style: styles.swatchItem },
        React.createElement(react_native_1.View, { style: [getSwatchColorStyle(p.name, p.color), themedStyles.swatch] }),
        React.createElement(react_native_2.Text, null, p.name)));
};
const SwatchList = () => {
    const theme = (0, theme_types_1.useTheme)();
    const palette = theme.colors;
    const aggregator = React.useCallback((key) => {
        return { key: key + ' (' + palette[key] + ')', color: palette[key] };
    }, [palette]);
    const flattenArray = React.useCallback(() => {
        return Object.keys(palette).sort().map(aggregator);
    }, [palette, aggregator]);
    const paletteAsArray = React.useMemo(flattenArray, [flattenArray]);
    const renderSwatch = React.useCallback((item) => {
        const { color, key } = item;
        return React.createElement(SemanticColor, { key: key, color: color, name: key });
    }, []);
    return (React.createElement(react_native_1.View, { style: styles_1.commonTestStyles.view },
        React.createElement(react_native_2.Text, null, "getHostSettingsWin32(theme: ITheme).palette"),
        React.createElement(react_native_1.View, { style: styles.stackStyle }, paletteAsArray.map((item) => renderSwatch(item)))));
};
const themeSections = [
    {
        name: 'Component Examples',
        testID: e2e_testing_1.THEME_TESTPAGE,
        component: Panel,
    },
    {
        name: 'Theme.colors',
        component: () => React.createElement(SwatchList, null),
    },
];
const ThemeTest = () => {
    const status = {
        win32Status: 'Production',
        uwpStatus: 'Beta',
        iosStatus: 'Production',
        macosStatus: 'Production',
        androidStatus: 'Production',
    };
    const description = 'The entire color palette of the controls is themeable. We provide a set of sensible defaults, but you can override all colors individually.';
    return React.createElement(Test_1.Test, { name: "Theme Test", description: description, sections: themeSections, status: status });
};
exports.ThemeTest = ThemeTest;
//# sourceMappingURL=ThemeTest.js.map