├── .eslintignore ├── .eslintrc ├── .github └── workflows │ ├── publish.yml │ └── tests.yml ├── .gitignore ├── .husky ├── .gitignore ├── commit-msg └── pre-commit ├── .importsortrc ├── .nvmrc ├── .prettierignore ├── .prettierrc ├── .releaserc ├── CHANGELOG.md ├── LICENSE ├── README.md ├── babel.config.js ├── commitlint.config.js ├── demo.gif ├── example ├── .gitignore ├── App.tsx ├── app.json ├── assets │ ├── adaptive-icon.png │ ├── favicon.png │ ├── icon.png │ └── splash.png ├── metro.config.js ├── package.json ├── tsconfig.json └── yarn.lock ├── jest.setup-after-env.js ├── lint-staged.config.js ├── package.json ├── src ├── HudProvider.test.tsx ├── HudProvider.tsx ├── __snapshots__ │ └── HudProvider.test.tsx.snap └── index.ts ├── tsconfig.build.json ├── tsconfig.json └── yarn.lock /.eslintignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | dist/ 3 | CHANGELOG.md 4 | -------------------------------------------------------------------------------- /.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "root": true, 3 | "env": { "browser": false, "es6": true, "node": true }, 4 | "parser": "@babel/eslint-parser", 5 | "parserOptions": { 6 | "ecmaVersion": 2020, 7 | "sourceType": "module", 8 | "requireConfigFile": false 9 | }, 10 | "settings": { "react": { "version": "detect" } }, 11 | "plugins": [ 12 | "react", 13 | "react-native", 14 | "sort-keys-fix", 15 | "sort-destructure-keys" 16 | ], 17 | "extends": [ 18 | "eslint:recommended", 19 | "plugin:react/recommended", 20 | "plugin:react-hooks/recommended", 21 | "plugin:prettier/recommended" 22 | ], 23 | "rules": { 24 | "react/prop-types": "off", 25 | "react/jsx-uses-react": "off", 26 | "react/react-in-jsx-scope": "off", 27 | "react-hooks/exhaustive-deps": "error", 28 | "react/jsx-sort-props": "error", 29 | "sort-keys": ["error", "asc"], 30 | "sort-keys-fix/sort-keys-fix": "error", 31 | "func-style": ["error", "expression"], 32 | "sort-destructure-keys/sort-destructure-keys": "error" 33 | }, 34 | "overrides": [ 35 | { 36 | "files": ["**/*.ts?(x)"], 37 | "parser": "@typescript-eslint/parser", 38 | "plugins": ["@typescript-eslint", "typescript-sort-keys"], 39 | "extends": ["plugin:@typescript-eslint/recommended"], 40 | "rules": { 41 | "@typescript-eslint/explicit-function-return-type": "off", 42 | "@typescript-eslint/explicit-module-boundary-types": "off", 43 | "typescript-sort-keys/interface": "error", 44 | "typescript-sort-keys/string-enum": "error" 45 | } 46 | } 47 | ] 48 | } 49 | 50 | -------------------------------------------------------------------------------- /.github/workflows/publish.yml: -------------------------------------------------------------------------------- 1 | name: Publish package 2 | on: 3 | workflow_dispatch: 4 | push: 5 | branches: [master] 6 | 7 | env: 8 | HUSKY: 0 9 | 10 | jobs: 11 | build: 12 | runs-on: ubuntu-latest 13 | 14 | steps: 15 | - name: Checkout 16 | uses: actions/checkout@v2 17 | 18 | - name: Use Node.js 19 | uses: actions/setup-node@v3 20 | with: 21 | node-version: '18.15' 22 | registry-url: 'https://npm.pkg.github.com/' 23 | 24 | - name: Cache node modules 25 | uses: actions/cache@v3 26 | with: 27 | path: '**/node_modules' 28 | key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }} 29 | 30 | - name: Install packages 31 | run: yarn install --frozen-lockfile 32 | 33 | - name: Run build 34 | run: yarn build 35 | 36 | - name: Run tests 37 | run: yarn test:ci 38 | 39 | - name: Run typecheck 40 | run: yarn typecheck 41 | 42 | - name: Run linter 43 | run: yarn lint:ci 44 | 45 | - name: Semantic Release 46 | run: yarn run semantic-release 47 | env: 48 | NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} 49 | NPM_TOKEN: ${{ secrets.NPM_TOKEN }} 50 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 51 | -------------------------------------------------------------------------------- /.github/workflows/tests.yml: -------------------------------------------------------------------------------- 1 | name: Run tests and verify code 2 | on: [pull_request] 3 | 4 | jobs: 5 | run-tests: 6 | runs-on: ubuntu-latest 7 | 8 | steps: 9 | - name: Checkout 10 | uses: actions/checkout@v2 11 | 12 | - name: Setup npm registry 13 | uses: actions/setup-node@v3 14 | with: 15 | node-version: '18.15' 16 | 17 | - name: Cache node modules 18 | uses: actions/cache@v3 19 | with: 20 | path: '**/node_modules' 21 | key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }} 22 | 23 | - name: Install packages 24 | run: yarn install --frozen-lockfile 25 | 26 | - name: Run tests 27 | run: yarn test:ci 28 | 29 | - name: Run typecheck 30 | run: yarn typecheck 31 | 32 | - name: Run linter 33 | run: yarn lint:ci 34 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | dist 2 | node_modules 3 | .eslintcache 4 | .history 5 | .vscode 6 | yarn-error.log 7 | .jest 8 | -------------------------------------------------------------------------------- /.husky/.gitignore: -------------------------------------------------------------------------------- 1 | _ 2 | -------------------------------------------------------------------------------- /.husky/commit-msg: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | . "$(dirname "$0")/_/husky.sh" 3 | 4 | yarn commitlint --edit "$1" 5 | -------------------------------------------------------------------------------- /.husky/pre-commit: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | . "$(dirname "$0")/_/husky.sh" 3 | 4 | yarn lint-staged --config lint-staged.config.js 5 | -------------------------------------------------------------------------------- /.importsortrc: -------------------------------------------------------------------------------- 1 | { 2 | ".ts, .js": { 3 | "style": "import-sort-style-eslint-typescript-hero", 4 | "options": { 5 | "tsHeroGroupsConfig": [ 6 | "/request-context/", 7 | "Plains", 8 | "/@nestjs/", 9 | "Modules", 10 | "Workspace" 11 | ] 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /.nvmrc: -------------------------------------------------------------------------------- 1 | 18.15 2 | -------------------------------------------------------------------------------- /.prettierignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | dist/ 3 | CHANGELOG.md 4 | -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "singleQuote": true, 3 | "trailingComma": "es5" 4 | } 5 | -------------------------------------------------------------------------------- /.releaserc: -------------------------------------------------------------------------------- 1 | { 2 | "debug": true, 3 | "plugins": [ 4 | "@semantic-release/commit-analyzer", 5 | "@semantic-release/release-notes-generator", 6 | "@semantic-release/npm", 7 | "@semantic-release/changelog", 8 | [ 9 | "@semantic-release/github", 10 | { 11 | "successComment": false, 12 | "failComment": false 13 | } 14 | ], 15 | [ 16 | "@semantic-release/git", 17 | { 18 | "assets": [ 19 | "CHANGELOG.md", 20 | "package.json", 21 | "yarn.lock" 22 | ] 23 | } 24 | ] 25 | ] 26 | } 27 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # [2.1.0](https://github.com/mohammedhammoud/react-native-hud-view/compare/v2.0.1...v2.1.0) (2024-05-06) 2 | 3 | 4 | ### Bug Fixes 5 | 6 | * export types ([b947786](https://github.com/mohammedhammoud/react-native-hud-view/commit/b947786b3dc9a2c1bf041222eaeaa461291854de)) 7 | * make it possibile to click background items when active ([85bef70](https://github.com/mohammedhammoud/react-native-hud-view/commit/85bef70c96fbe701cca4504d228985cdaba00d92)) 8 | 9 | 10 | ### Features 11 | 12 | * add possibility to pass global color ([9eb65e1](https://github.com/mohammedhammoud/react-native-hud-view/commit/9eb65e126a4d7757e4b202e354733715d51e0bc0)) 13 | 14 | ## [2.0.1](https://github.com/mohammedhammoud/react-native-hud-view/compare/v2.0.0...v2.0.1) (2023-04-26) 15 | 16 | 17 | ### Bug Fixes 18 | 19 | * fix broken IconComponent type on HudProviderProps ([8695636](https://github.com/mohammedhammoud/react-native-hud-view/commit/8695636bca0900f99535c8a6d789830a35aae06a)) 20 | 21 | # [2.0.0](https://github.com/mohammedhammoud/react-native-hud-view/compare/v1.2.2...v2.0.0) (2023-04-26) 22 | 23 | 24 | ### Features 25 | 26 | * rewrite codebase to align with latest react ([64f1fbe](https://github.com/mohammedhammoud/react-native-hud-view/commit/64f1fbe0f297db1aff40f64918b046e344a69edd)) 27 | 28 | 29 | ### BREAKING CHANGES 30 | 31 | * The codebase has been completely rewritten to align with the latest version of React. This includes major changes to the API, so existing code will need to be updated accordingly. 32 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 Mohammed Hammoud 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # react-native-hud-view 2 | 3 | `react-native-hud-view` is a lightweight, flexible, and customizable progress indicator library for React Native. The library provides an easy way to show a HUD (Heads-up Display) when you need to indicate progress or loading in your application. 4 | 5 | `react-native-hud-view` is a standalone library and does not have any dependencies. However, you will need to provide your own icon component to use with the library. The icon component should accept the following props: `color`, `name`, and `size`. 6 | 7 | We recommend using the `react-native-vector-icons` library with `react-native-hud-view`, as it is guaranteed to work with the library. To use a different icon library, simply provide the appropriate icon component to the `HudProvider` component. 8 | 9 | 10 | 11 | ## Installation 12 | 13 | - `yarn add react-native-hud-view` or `npm install react-native-hud-view` 14 | 15 | ## Usage 16 | 17 | ### Wrap your app with HudProvider 18 | 19 | You can use the `HudProvider` component at the root of your application to provide the context for showing the HUD. This component should wrap your application's main component. 20 | 21 | ```tsx 22 | import { HudProvider } from 'react-native-hud-view'; 23 | import FontAwesomeIcon from 'react-native-vector-icons/FontAwesome'; 24 | 25 | const App = () => { 26 | return ( 27 | 28 | 29 | 30 | ); 31 | }; 32 | ``` 33 | 34 | ### Show and hide the HUD 35 | 36 | You can use the `useHudContext` hook to access the `show` and `hide` methods of the HUD context. 37 | 38 | ```tsx 39 | import { useHudContext } from 'react-native-hud-view'; 40 | 41 | const MyComponent = () => { 42 | const { show, hide } = useHudContext(); 43 | 44 | const handlePress = async () => { 45 | show({ name: 'rocket' }); 46 | await performAsyncOperation(); 47 | hide(); 48 | }; 49 | 50 | return