import { Box } from '@/components/ui/box';
import { Button, ButtonText } from '@/components/ui/button';
import { Center } from '@/components/ui/center';
import { HStack } from '@/components/ui/hstack';
import { Text } from '@/components/ui/text';
import { VStack } from '@/components/ui/vstack';
import { useCounterDispatch, useCounterState } from '@/states/ConterProvider';

export default function IndexPage() {
  const state = useCounterState();
  const dispatch = useCounterDispatch();

  return (
    <Box className="flex-1 justify-center items-center">
      <Center style={{ width: '50%', height: '30%' }} className="p-3 bg-secondary-500 h-1/2 w-1/2">
        <Text className="text-lg font-semibold">Count: {state.count}</Text>
        <HStack className="gap-2">
          <Button className="w-[200px]" onPress={() => dispatch({ type: 'INCREMENT' })}>
            <ButtonText>+</ButtonText>
          </Button>
          <Button className="w-[150px]" onPress={() => dispatch({ type: 'DECREMENT' })}>
            <ButtonText>-</ButtonText>
          </Button>
        </HStack>
      </Center>
    </Box>
  );
}
