MCPcopy Index your code
hub / github.com/cawfree/react-native-picture-puzzle

github.com/cawfree/react-native-picture-puzzle @main

Chat with this repo
repository ↗ · DeepWiki ↗ · + Follow
7 symbols 17 edges 10 files 0 documented · 0%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

react-native-picture-puzzle

⚛️ 🧩 A picture puzzle component. Supports Android, iOS and the Web.

🎬 demo

🚀 getting started

Using Yarn:

yarn add react-native-picture-puzzle

✍️ usage

import React from 'react';
import { PicturePuzzle, PuzzlePieces } from 'react-native-picture-puzzle';

export default function App() {
  const [hidden, setHidden] = React.useState<number | null>(0); // piece to obscure
  const [pieces, setPieces] = React.useState<PuzzlePieces>([0, 1, 2, 3, 4, 5, 6, 7, 8]);
  const source = React.useMemo(() => ({
    uri: 'https://pbs.twimg.com/profile_images/1180062941162479616/W8XdhKTG_400x400.jpg',
  }), []);
  const renderLoading = React.useCallback((): JSX.Element => <ActivityIndicator />, []);
  const onChange = React.useCallback((nextPieces: PuzzlePieces, nextHidden: number | null): void => {
    setPieces(nextPieces);
    setHidden(nextHidden);
  }, [setPieces, setHidden]);
  return (
    <PicturePuzzle
      size={500}
      pieces={pieces}
      hidden={hidden}
      onChange={onChange}
      source={source}
      renderLoading={renderLoading}
    />
  );
}

🦄 types

export type PuzzlePiece = number;

export type PuzzlePieces = readonly PuzzlePiece[];

export enum MoveDirection {
  BOTTOM = 'bottom',
  LEFT = 'left',
  RIGHT = 'right',
  TOP = 'top',
}

export type PicturePuzzleProps = ImageProps & {
  readonly hidden: number | null;
  readonly size: number;
  readonly pieces: PuzzlePieces;
  readonly source: ImageURISource | number;
  readonly renderLoading?: () => JSX.Element;
  readonly onChange?: (nextPieces: PuzzlePieces, nextHidden: number | null) => void;
};

✌️ license

MIT

Core symbols most depended-on inside this repo

shuffle
called by 1
example/App.tsx
isSquare
called by 1
src/constants/isSquare.ts
throwOnInvalidPuzzlePieces
called by 1
src/constants/throwOnInvalidPuzzlePieces.ts
App
called by 0
example/App.tsx
ObscureView
called by 0
src/components/ObscureView.tsx
PicturePuzzle
called by 0
src/components/PicturePuzzle.tsx

Shape

Function 6
Enum 1

Languages

TypeScript100%

Modules by API surface

example/App.tsx2 symbols
src/types/index.ts1 symbols
src/constants/throwOnInvalidPuzzlePieces.ts1 symbols
src/constants/isSquare.ts1 symbols
src/components/PicturePuzzle.tsx1 symbols
src/components/ObscureView.tsx1 symbols

For agents

$ claude mcp add react-native-picture-puzzle \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page