import * as React from 'react';
import { View, StyleSheet } from 'react-native';
import { Button, PrimaryButton, Text, StealthButton } from '@fluentui/react-native';
import { THEME_TESTPAGE } from '@fluentui-react-native/e2e-testing';
import { useTheme } from '@fluentui-react-native/theme-types';
import { themedStyleSheet } from '@fluentui-react-native/themed-stylesheet';
import { commonTestStyles } from '../Common/styles';
import { Test } from '../Test';
const getThemedStyles = themedStyleSheet((theme) => {
    return {
        swatch: {
            width: 80,
            height: 20,
            marginRight: 5,
            borderWidth: 2,
            borderColor: theme.colors.bodyText,
        },
    };
});
const styles = StyleSheet.create({
    swatchItem: {
        flexDirection: 'row',
        alignItems: 'center',
        marginVertical: 5,
    },
    panel: {
        ...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(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 })));
};
const getSwatchColorStyle = (name, color) => {
    styles[name] = styles[name] || { backgroundColor: color };
    return styles[name];
};
const SemanticColor = (p) => {
    const 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)));
};
const SwatchList = () => {
    const theme = 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(View, { style: commonTestStyles.view },
        React.createElement(Text, null, "getHostSettingsWin32(theme: ITheme).palette"),
        React.createElement(View, { style: styles.stackStyle }, paletteAsArray.map((item) => renderSwatch(item)))));
};
const themeSections = [
    {
        name: 'Component Examples',
        testID: THEME_TESTPAGE,
        component: Panel,
    },
    {
        name: 'Theme.colors',
        component: () => React.createElement(SwatchList, null),
    },
];
export 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, { name: "Theme Test", description: description, sections: themeSections, status: status });
};
//# sourceMappingURL=ThemeTest.js.map