{"id":18369846,"url":"https://github.com/cawfree/react-native-picture-puzzle","last_synced_at":"2025-04-06T18:32:35.292Z","repository":{"id":57339094,"uuid":"329755157","full_name":"cawfree/react-native-picture-puzzle","owner":"cawfree","description":"⚛️ 🧩  A picture puzzle component.","archived":false,"fork":false,"pushed_at":"2023-10-11T20:23:39.000Z","size":841,"stargazers_count":44,"open_issues_count":6,"forks_count":16,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-18T13:13:52.365Z","etag":null,"topics":["game","picture","puzzle","react-native"],"latest_commit_sha":null,"homepage":"https://twitter.com/cawfree","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cawfree.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-01-14T23:02:07.000Z","updated_at":"2024-12-07T02:35:21.000Z","dependencies_parsed_at":"2024-11-05T23:45:05.167Z","dependency_job_id":null,"html_url":"https://github.com/cawfree/react-native-picture-puzzle","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cawfree%2Freact-native-picture-puzzle","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cawfree%2Freact-native-picture-puzzle/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cawfree%2Freact-native-picture-puzzle/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cawfree%2Freact-native-picture-puzzle/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cawfree","download_url":"https://codeload.github.com/cawfree/react-native-picture-puzzle/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247531339,"owners_count":20953937,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["game","picture","puzzle","react-native"],"created_at":"2024-11-05T23:32:33.636Z","updated_at":"2025-04-06T18:32:33.787Z","avatar_url":"https://github.com/cawfree.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# react-native-picture-puzzle\n⚛️ 🧩  A picture puzzle component. Supports [**Android**](https://reactnative.dev), [**iOS**](https://reactnative.dev) and the [**Web**](https://github.com/necolas/react-native-web).\n\n[🎬 **demo**](https://twitter.com/cawfree/status/1350268277143068673)\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"./public/logo.png\" width=\"250\" height=\"250\"\u003e\u003c/img\u003e\n\u003c/p\u003e\n\n\n## 🚀 getting started\n\nUsing [**Yarn**](https://yarnpkg.com):\n\n```sh\nyarn add react-native-picture-puzzle\n```\n\n## ✍️ usage\n\n```typescript\nimport React from 'react';\nimport { PicturePuzzle, PuzzlePieces } from 'react-native-picture-puzzle';\n\nexport default function App() {\n  const [hidden, setHidden] = React.useState\u003cnumber | null\u003e(0); // piece to obscure\n  const [pieces, setPieces] = React.useState\u003cPuzzlePieces\u003e([0, 1, 2, 3, 4, 5, 6, 7, 8]);\n  const source = React.useMemo(() =\u003e ({\n    uri: 'https://pbs.twimg.com/profile_images/1180062941162479616/W8XdhKTG_400x400.jpg',\n  }), []);\n  const renderLoading = React.useCallback((): JSX.Element =\u003e \u003cActivityIndicator /\u003e, []);\n  const onChange = React.useCallback((nextPieces: PuzzlePieces, nextHidden: number | null): void =\u003e {\n    setPieces(nextPieces);\n    setHidden(nextHidden);\n  }, [setPieces, setHidden]);\n  return (\n    \u003cPicturePuzzle\n      size={500}\n      pieces={pieces}\n      hidden={hidden}\n      onChange={onChange}\n      source={source}\n      renderLoading={renderLoading}\n    /\u003e\n  );\n}\n```\n\n## 🦄 types\n\n```typescript\nexport type PuzzlePiece = number;\n\nexport type PuzzlePieces = readonly PuzzlePiece[];\n\nexport enum MoveDirection {\n  BOTTOM = 'bottom',\n  LEFT = 'left',\n  RIGHT = 'right',\n  TOP = 'top',\n}\n\nexport type PicturePuzzleProps = ImageProps \u0026 {\n  readonly hidden: number | null;\n  readonly size: number;\n  readonly pieces: PuzzlePieces;\n  readonly source: ImageURISource | number;\n  readonly renderLoading?: () =\u003e JSX.Element;\n  readonly onChange?: (nextPieces: PuzzlePieces, nextHidden: number | null) =\u003e void;\n};\n```\n\n## ✌️ license\n[**MIT**](./LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcawfree%2Freact-native-picture-puzzle","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcawfree%2Freact-native-picture-puzzle","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcawfree%2Freact-native-picture-puzzle/lists"}