import { __assign } from "tslib";
import * as React from 'react';
import { View, StyleSheet } from 'react-native';
import { Button, PrimaryButton, Text, StealthButton } from '@fluentui/react-native';
import { useTheme } from '@fluentui-react-native/theme-types';
import { themedStyleSheet } from '@fluentui-react-native/themed-stylesheet';
import { THEME_TESTPAGE } from '../../../../E2E/src/Theme/consts';
import { commonTestStyles } from '../Common/styles';
import { Test } from '../Test';
var getThemedStyles = themedStyleSheet(function (theme) {
    return {
        swatch: {
            width: 80,
            height: 20,
            marginRight: 5,
            borderWidth: 2,
            borderColor: theme.colors.bodyText,
        },
    };
});
var styles = StyleSheet.create({
    swatchItem: {
        flexDirection: 'row',
        alignItems: 'center',
        marginVertical: 5,
    },
    panel: __assign(__assign({}, commonTestStyles.view), { borderWidth: 2, padding: 12, margin: 8 }),
    pickerContainer: {
        flexDirection: 'row',
        justifyContent: 'space-evenly',
    },
    stackStyle: {
        borderWidth: 2,
        padding: 12,
        margin: 8,
    },
});
var Panel = function () {
    var _a = React.useState(false), disabled = _a[0], setDisabled = _a[1];
    var onClick = React.useCallback(function () { return setDisabled(!disabled); }, [disabled, setDisabled]);
    return (React.createElement(View, { style: styles.panel },
        React.createElement(PrimaryButton, { onClick: onClick, content: "Primary Button", disabled: disabled }),
        React.createElement(Button, { onClick: onClick, content: "Default Button", disabled: disabled }),
        React.createElement(StealthButton, { onClick: onClick, content: "Stealth Button", disabled: disabled }),
        React.createElement(Text, null, "This is a text element"),
        React.createElement(Button, { onClick: onClick, content: "This button has longer text", disabled: disabled })));
};
var getSwatchColorStyle = function (name, color) {
    styles[name] = styles[name] || { backgroundColor: color };
    return styles[name];
};
var SemanticColor = function (p) {
    var themedStyles = getThemedStyles(useTheme());
    return (React.createElement(View, { style: styles.swatchItem },
        React.createElement(View, { style: [getSwatchColorStyle(p.name, p.color), themedStyles.swatch] }),
        React.createElement(Text, null, p.name)));
};
var SwatchList = function () {
    var theme = useTheme();
    var palette = theme.colors;
    var aggregator = React.useCallback(function (key) {
        return { key: key + ' (' + palette[key] + ')', color: palette[key] };
    }, [palette]);
    var flattenArray = React.useCallback(function () {
        return Object.keys(palette).sort().map(aggregator);
    }, [palette, aggregator]);
    var paletteAsArray = React.useMemo(flattenArray, [flattenArray]);
    var renderSwatch = React.useCallback(function (item) {
        var color = item.color, key = item.key;
        return React.createElement(SemanticColor, { key: key, color: color, name: key });
    }, []);
    return (React.createElement(View, { style: commonTestStyles.view },
        React.createElement(Text, null, "getHostSettingsWin32(theme: ITheme).palette"),
        React.createElement(View, { style: styles.stackStyle }, paletteAsArray.map(function (item) { return renderSwatch(item); }))));
};
var themeSections = [
    {
        name: 'Component Examples',
        testID: THEME_TESTPAGE,
        component: Panel,
    },
    {
        name: 'Theme.colors',
        component: function () { return React.createElement(SwatchList, null); },
    },
];
export var ThemeTest = function () {
    var status = {
        win32Status: 'Production',
        uwpStatus: 'Beta',
        iosStatus: 'Production',
        macosStatus: 'Production',
        androidStatus: 'Production',
    };
    var 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, { name: "Theme Test", description: description, sections: themeSections, status: status });
};
//# sourceMappingURL=ThemeTest.js.map