/* eslint-disable react-native/no-inline-styles */
import React from 'react';
import { View, StyleSheet, Text } from 'react-native';
import { useChessboardProps } from '../context/props-context/hooks';
const styles = StyleSheet.create({
container: {
flex: 1,
flexDirection: 'row',
},
});
type BackgroundProps = {
letters: boolean;
numbers: boolean;
};
interface BaseProps extends BackgroundProps {
white: boolean;
}
interface RowProps extends BaseProps {
row: number;
}
interface SquareProps extends RowProps {
col: number;
}
const Square = React.memo(
({ white, row, col, letters, numbers }: SquareProps) => {
const { colors } = useChessboardProps();
const backgroundColor = white ? colors.black : colors.white;
const color = white ? colors.white : colors.black;
const textStyle = { fontWeight: '500' as const, fontSize: 10, color };
const newLocal = col === 0;
return (
{numbers && (
{'' + (8 - row)}
)}
{row === 7 && letters && (
{String.fromCharCode(97 + col)}
)}
);
}
);
const Row = React.memo(({ white, row, ...rest }: RowProps) => {
const offset = white ? 0 : 1;
return (
{new Array(8).fill(0).map((_, i) => (
))}
);
});
const Background: React.FC = React.memo(() => {
const { withLetters, withNumbers } = useChessboardProps();
return (
{new Array(8).fill(0).map((_, i) => (
))}
);
});
export default Background;