import React, { useContext } from 'react';
import { StyleSheet, View } from 'react-native';
import { useFonts } from 'expo-font';
import { Txt6 } from '@proximus/react-native-common-ui/lib/texts/Txt';
import { useTheme, Colors } from '@proximus/react-native-common-ui/lib/styling';
import { e2eID, a11y } from '@proximus/react-native-common-ui/lib/common/utils';

export default function App() {
  const loaded = useFonts({
    'Proximus-Bold': require('@proximus/react-native-font-icons/lib/assets/fonts/Proximus-Bold.ttf'),
  });

  if (!loaded) {
    return <View />;
  }

  return (
    <View style={styles.container}>
      <PxCard
        wrapperStyle={{
          backgroundColor: Colors.brand.purple,
          padding: 15,
        }}
      >
        <Txt6
          style={{
            color: Colors.shadesOfGrey.white,
          }}
        >
          Lorem ipsum ...
        </Txt6>
      </PxCard>
    </View>
  );
}

export function PxCard(props: IPxCardProps) {
  const { theme } = useTheme();

  const { children, wrapperStyle, testId, wrapperA11yProps, ...viewProps } =
    props;

  return (
    <View
      style={[
        styles.container,
        {
          backgroundColor: theme.card,
        },
        wrapperStyle,
      ]}
      {...e2eID(testId)}
      {...a11y({
        ...wrapperA11yProps,
      })}
      {...viewProps}
    >
      {children}
    </View>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: '#fff',
    justifyContent: 'center',
    padding: 20,
  },
});
