From f47f94602dd47d356d22be27de33fe7492a110a2 Mon Sep 17 00:00:00 2001 From: Nkgohil007 Date: Thu, 16 Jan 2025 11:55:32 +0530 Subject: [PATCH 01/11] refactor: replace husky with lefthook and clean up scripts in package.json --- .husky/_/pre-commit | 57 ++++++++++++++++++++++++ .husky/_/prepare-commit-msg | 57 ++++++++++++++++++++++++ .husky/commit-msg | 4 -- .husky/pre-commit | 3 -- lefthook.yml | 14 ++++++ package.json | 5 +-- templates/ExpoTemplate/.husky/commit-msg | 4 -- templates/ExpoTemplate/.husky/pre-commit | 4 -- templates/ExpoTemplate/lefthook.yml | 5 +++ templates/ExpoTemplate/package.json | 3 +- 10 files changed, 136 insertions(+), 20 deletions(-) create mode 100755 .husky/_/pre-commit create mode 100755 .husky/_/prepare-commit-msg delete mode 100755 .husky/commit-msg delete mode 100755 .husky/pre-commit create mode 100644 lefthook.yml delete mode 100755 templates/ExpoTemplate/.husky/commit-msg delete mode 100755 templates/ExpoTemplate/.husky/pre-commit create mode 100644 templates/ExpoTemplate/lefthook.yml diff --git a/.husky/_/pre-commit b/.husky/_/pre-commit new file mode 100755 index 0000000..4855f61 --- /dev/null +++ b/.husky/_/pre-commit @@ -0,0 +1,57 @@ +#!/bin/sh + +if [ "$LEFTHOOK_VERBOSE" = "1" -o "$LEFTHOOK_VERBOSE" = "true" ]; then + set -x +fi + +if [ "$LEFTHOOK" = "0" ]; then + exit 0 +fi + +call_lefthook() +{ + if test -n "$LEFTHOOK_BIN" + then + "$LEFTHOOK_BIN" "$@" + elif lefthook -h >/dev/null 2>&1 + then + lefthook "$@" + else + dir="$(git rev-parse --show-toplevel)" + osArch=$(uname | tr '[:upper:]' '[:lower:]') + cpuArch=$(uname -m | sed 's/aarch64/arm64/;s/x86_64/x64/') + if test -f "$dir/node_modules/lefthook-${osArch}-${cpuArch}/bin/lefthook" + then + "$dir/node_modules/lefthook-${osArch}-${cpuArch}/bin/lefthook" "$@" + elif test -f "$dir/node_modules/@evilmartians/lefthook/bin/lefthook-${osArch}-${cpuArch}/lefthook" + then + "$dir/node_modules/@evilmartians/lefthook/bin/lefthook-${osArch}-${cpuArch}/lefthook" "$@" + elif test -f "$dir/node_modules/@evilmartians/lefthook-installer/bin/lefthook" + then + "$dir/node_modules/@evilmartians/lefthook-installer/bin/lefthook" "$@" + elif test -f "$dir/node_modules/lefthook/bin/index.js" + then + "$dir/node_modules/lefthook/bin/index.js" "$@" + + elif bundle exec lefthook -h >/dev/null 2>&1 + then + bundle exec lefthook "$@" + elif yarn lefthook -h >/dev/null 2>&1 + then + yarn lefthook "$@" + elif pnpm lefthook -h >/dev/null 2>&1 + then + pnpm lefthook "$@" + elif swift package plugin lefthook >/dev/null 2>&1 + then + swift package --disable-sandbox plugin lefthook "$@" + elif command -v mint >/dev/null 2>&1 + then + mint run csjones/lefthook-plugin "$@" + else + echo "Can't find lefthook in PATH" + fi + fi +} + +call_lefthook run "pre-commit" "$@" diff --git a/.husky/_/prepare-commit-msg b/.husky/_/prepare-commit-msg new file mode 100755 index 0000000..2655902 --- /dev/null +++ b/.husky/_/prepare-commit-msg @@ -0,0 +1,57 @@ +#!/bin/sh + +if [ "$LEFTHOOK_VERBOSE" = "1" -o "$LEFTHOOK_VERBOSE" = "true" ]; then + set -x +fi + +if [ "$LEFTHOOK" = "0" ]; then + exit 0 +fi + +call_lefthook() +{ + if test -n "$LEFTHOOK_BIN" + then + "$LEFTHOOK_BIN" "$@" + elif lefthook -h >/dev/null 2>&1 + then + lefthook "$@" + else + dir="$(git rev-parse --show-toplevel)" + osArch=$(uname | tr '[:upper:]' '[:lower:]') + cpuArch=$(uname -m | sed 's/aarch64/arm64/;s/x86_64/x64/') + if test -f "$dir/node_modules/lefthook-${osArch}-${cpuArch}/bin/lefthook" + then + "$dir/node_modules/lefthook-${osArch}-${cpuArch}/bin/lefthook" "$@" + elif test -f "$dir/node_modules/@evilmartians/lefthook/bin/lefthook-${osArch}-${cpuArch}/lefthook" + then + "$dir/node_modules/@evilmartians/lefthook/bin/lefthook-${osArch}-${cpuArch}/lefthook" "$@" + elif test -f "$dir/node_modules/@evilmartians/lefthook-installer/bin/lefthook" + then + "$dir/node_modules/@evilmartians/lefthook-installer/bin/lefthook" "$@" + elif test -f "$dir/node_modules/lefthook/bin/index.js" + then + "$dir/node_modules/lefthook/bin/index.js" "$@" + + elif bundle exec lefthook -h >/dev/null 2>&1 + then + bundle exec lefthook "$@" + elif yarn lefthook -h >/dev/null 2>&1 + then + yarn lefthook "$@" + elif pnpm lefthook -h >/dev/null 2>&1 + then + pnpm lefthook "$@" + elif swift package plugin lefthook >/dev/null 2>&1 + then + swift package --disable-sandbox plugin lefthook "$@" + elif command -v mint >/dev/null 2>&1 + then + mint run csjones/lefthook-plugin "$@" + else + echo "Can't find lefthook in PATH" + fi + fi +} + +call_lefthook run "prepare-commit-msg" "$@" diff --git a/.husky/commit-msg b/.husky/commit-msg deleted file mode 100755 index 988eb59..0000000 --- a/.husky/commit-msg +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/env sh -. "$(dirname -- "$0")/_/husky.sh" - -npx --no -- commitlint --edit diff --git a/.husky/pre-commit b/.husky/pre-commit deleted file mode 100755 index 64778a1..0000000 --- a/.husky/pre-commit +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env sh -. "$(dirname -- "$0")/_/husky.sh" - diff --git a/lefthook.yml b/lefthook.yml new file mode 100644 index 0000000..88fdd0e --- /dev/null +++ b/lefthook.yml @@ -0,0 +1,14 @@ +pre-commit: + parallel: true # Run scripts in parallel for better performance + scripts: + lint: + # Run ESLint to lint your JavaScript/TypeScript files + run: "eslint . --ext .js,.jsx,.ts,.tsx" + include: "src/**/*.{js,jsx,ts,tsx}" # Include files in the src directory + exclude: "node_modules/**/*" # Exclude node_modules folder + + prettier: + # Run Prettier to format your code + run: "prettier --write ." + include: "src/**/*.{js,jsx,ts,tsx}" + exclude: "node_modules/**/*" diff --git a/package.json b/package.json index 44358bd..56e7038 100644 --- a/package.json +++ b/package.json @@ -9,8 +9,7 @@ "private": false, "scripts": { "android": "cd MIBoilerplate/ && npx react-native run-android", - "ios": "cd MIBoilerplate/ && npx react-native run-ios", - "prepare": "husky" + "ios": "cd MIBoilerplate/ && npx react-native run-ios" }, "bin": { "@mindinventory/react-native-boilerplate": "./bin/index.js" @@ -39,7 +38,7 @@ "devDependencies": { "@commitlint/cli": "^19.5.0", "@commitlint/config-conventional": "^19.5.0", - "husky": "^9.1.6" + "lefthook": "^1.10.4" }, "dependencies": { "chalk": "^5.3.0", diff --git a/templates/ExpoTemplate/.husky/commit-msg b/templates/ExpoTemplate/.husky/commit-msg deleted file mode 100755 index 4002db7..0000000 --- a/templates/ExpoTemplate/.husky/commit-msg +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/env sh -. "$(dirname -- "$0")/_/husky.sh" - -npx --no -- commitlint --edit diff --git a/templates/ExpoTemplate/.husky/pre-commit b/templates/ExpoTemplate/.husky/pre-commit deleted file mode 100755 index a6bc6ac..0000000 --- a/templates/ExpoTemplate/.husky/pre-commit +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/env sh -. "$(dirname -- "$0")/_/husky.sh" - -yarn lint & npx yarn typescript diff --git a/templates/ExpoTemplate/lefthook.yml b/templates/ExpoTemplate/lefthook.yml new file mode 100644 index 0000000..e22fb43 --- /dev/null +++ b/templates/ExpoTemplate/lefthook.yml @@ -0,0 +1,5 @@ +pre-commit: + # Add your specific scripts or commands you want to run before a commit + scripts: + # Linting with ESLint for JavaScript/TypeScript projects + run: yarn lint & npx yarn typescript diff --git a/templates/ExpoTemplate/package.json b/templates/ExpoTemplate/package.json index 357e228..7be904a 100644 --- a/templates/ExpoTemplate/package.json +++ b/templates/ExpoTemplate/package.json @@ -11,7 +11,6 @@ "ios": "expo start --ios", "web": "expo start --web", "typescript": "tsc --noEmit", - "prepare": "husky install", "lint": "eslint . --ext .js,.jsx,.ts,.tsx", "fix:lint": "yarn lint --fix && yarn typescript", "icons": "cd scripts && node icons.js", @@ -73,8 +72,8 @@ "eslint-plugin-react-native": "^4.1.0", "eslint-plugin-sort-destructure-keys": "^2.0.0", "eslint-plugin-sort-keys-fix": "^1.1.2", - "husky": "^9.1.6", "jest": "^29.7.0", + "lefthook": "^1.10.5", "prettier": "^3.3.3", "react-native-dotenv": "^3.4.11", "react-native-svg-transformer": "^1.5.0", From cf42c3456ab6bdc58ddb1c2239b149f0a966c6c7 Mon Sep 17 00:00:00 2001 From: Nkgohil007 Date: Thu, 16 Jan 2025 15:47:12 +0530 Subject: [PATCH 02/11] feat:added lefthook configuration --- .husky/_/pre-commit | 57 ------------------ .husky/_/prepare-commit-msg | 57 ------------------ .vscode/settings.json | 2 +- lefthook.yml | 14 ----- script.js | 74 +++++++++++++----------- templates/CliTemplate/lefthook.yml | 9 +++ templates/CliTemplate/package.json | 3 +- templates/ExpoTemplate/.eslintrc.js | 13 ----- templates/ExpoTemplate/declarations.d.ts | 8 +++ templates/ExpoTemplate/lefthook.yml | 10 +++- templates/ExpoTemplate/package.json | 2 +- templates/ExpoTemplate/src/MainApp.tsx | 2 +- 12 files changed, 67 insertions(+), 184 deletions(-) delete mode 100755 .husky/_/pre-commit delete mode 100755 .husky/_/prepare-commit-msg delete mode 100644 lefthook.yml create mode 100644 templates/CliTemplate/lefthook.yml create mode 100644 templates/ExpoTemplate/declarations.d.ts diff --git a/.husky/_/pre-commit b/.husky/_/pre-commit deleted file mode 100755 index 4855f61..0000000 --- a/.husky/_/pre-commit +++ /dev/null @@ -1,57 +0,0 @@ -#!/bin/sh - -if [ "$LEFTHOOK_VERBOSE" = "1" -o "$LEFTHOOK_VERBOSE" = "true" ]; then - set -x -fi - -if [ "$LEFTHOOK" = "0" ]; then - exit 0 -fi - -call_lefthook() -{ - if test -n "$LEFTHOOK_BIN" - then - "$LEFTHOOK_BIN" "$@" - elif lefthook -h >/dev/null 2>&1 - then - lefthook "$@" - else - dir="$(git rev-parse --show-toplevel)" - osArch=$(uname | tr '[:upper:]' '[:lower:]') - cpuArch=$(uname -m | sed 's/aarch64/arm64/;s/x86_64/x64/') - if test -f "$dir/node_modules/lefthook-${osArch}-${cpuArch}/bin/lefthook" - then - "$dir/node_modules/lefthook-${osArch}-${cpuArch}/bin/lefthook" "$@" - elif test -f "$dir/node_modules/@evilmartians/lefthook/bin/lefthook-${osArch}-${cpuArch}/lefthook" - then - "$dir/node_modules/@evilmartians/lefthook/bin/lefthook-${osArch}-${cpuArch}/lefthook" "$@" - elif test -f "$dir/node_modules/@evilmartians/lefthook-installer/bin/lefthook" - then - "$dir/node_modules/@evilmartians/lefthook-installer/bin/lefthook" "$@" - elif test -f "$dir/node_modules/lefthook/bin/index.js" - then - "$dir/node_modules/lefthook/bin/index.js" "$@" - - elif bundle exec lefthook -h >/dev/null 2>&1 - then - bundle exec lefthook "$@" - elif yarn lefthook -h >/dev/null 2>&1 - then - yarn lefthook "$@" - elif pnpm lefthook -h >/dev/null 2>&1 - then - pnpm lefthook "$@" - elif swift package plugin lefthook >/dev/null 2>&1 - then - swift package --disable-sandbox plugin lefthook "$@" - elif command -v mint >/dev/null 2>&1 - then - mint run csjones/lefthook-plugin "$@" - else - echo "Can't find lefthook in PATH" - fi - fi -} - -call_lefthook run "pre-commit" "$@" diff --git a/.husky/_/prepare-commit-msg b/.husky/_/prepare-commit-msg deleted file mode 100755 index 2655902..0000000 --- a/.husky/_/prepare-commit-msg +++ /dev/null @@ -1,57 +0,0 @@ -#!/bin/sh - -if [ "$LEFTHOOK_VERBOSE" = "1" -o "$LEFTHOOK_VERBOSE" = "true" ]; then - set -x -fi - -if [ "$LEFTHOOK" = "0" ]; then - exit 0 -fi - -call_lefthook() -{ - if test -n "$LEFTHOOK_BIN" - then - "$LEFTHOOK_BIN" "$@" - elif lefthook -h >/dev/null 2>&1 - then - lefthook "$@" - else - dir="$(git rev-parse --show-toplevel)" - osArch=$(uname | tr '[:upper:]' '[:lower:]') - cpuArch=$(uname -m | sed 's/aarch64/arm64/;s/x86_64/x64/') - if test -f "$dir/node_modules/lefthook-${osArch}-${cpuArch}/bin/lefthook" - then - "$dir/node_modules/lefthook-${osArch}-${cpuArch}/bin/lefthook" "$@" - elif test -f "$dir/node_modules/@evilmartians/lefthook/bin/lefthook-${osArch}-${cpuArch}/lefthook" - then - "$dir/node_modules/@evilmartians/lefthook/bin/lefthook-${osArch}-${cpuArch}/lefthook" "$@" - elif test -f "$dir/node_modules/@evilmartians/lefthook-installer/bin/lefthook" - then - "$dir/node_modules/@evilmartians/lefthook-installer/bin/lefthook" "$@" - elif test -f "$dir/node_modules/lefthook/bin/index.js" - then - "$dir/node_modules/lefthook/bin/index.js" "$@" - - elif bundle exec lefthook -h >/dev/null 2>&1 - then - bundle exec lefthook "$@" - elif yarn lefthook -h >/dev/null 2>&1 - then - yarn lefthook "$@" - elif pnpm lefthook -h >/dev/null 2>&1 - then - pnpm lefthook "$@" - elif swift package plugin lefthook >/dev/null 2>&1 - then - swift package --disable-sandbox plugin lefthook "$@" - elif command -v mint >/dev/null 2>&1 - then - mint run csjones/lefthook-plugin "$@" - else - echo "Can't find lefthook in PATH" - fi - fi -} - -call_lefthook run "prepare-commit-msg" "$@" diff --git a/.vscode/settings.json b/.vscode/settings.json index d618a2c..499df69 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,7 +1,7 @@ { "eslint.options": {}, "editor.codeActionsOnSave": { - "source.fixAll.eslint": "explicit" + "source.fixAll.eslint": "always" }, "eslint.run": "onSave", "editor.defaultFormatter": "esbenp.prettier-vscode", diff --git a/lefthook.yml b/lefthook.yml deleted file mode 100644 index 88fdd0e..0000000 --- a/lefthook.yml +++ /dev/null @@ -1,14 +0,0 @@ -pre-commit: - parallel: true # Run scripts in parallel for better performance - scripts: - lint: - # Run ESLint to lint your JavaScript/TypeScript files - run: "eslint . --ext .js,.jsx,.ts,.tsx" - include: "src/**/*.{js,jsx,ts,tsx}" # Include files in the src directory - exclude: "node_modules/**/*" # Exclude node_modules folder - - prettier: - # Run Prettier to format your code - run: "prettier --write ." - include: "src/**/*.{js,jsx,ts,tsx}" - exclude: "node_modules/**/*" diff --git a/script.js b/script.js index e9fd8b7..500f6f5 100755 --- a/script.js +++ b/script.js @@ -1,29 +1,33 @@ #!/usr/bin/env node -console.log("Welcome to Mindinventory React native boilerplate"); +console.log("Welcome to Mindinventory React native boilerplate") -const { execSync } = require("child_process"); +const { execSync } = require("child_process") const installDependencies = () => { - console.log("\n\n"); + console.log("\n\n") console.log( "@mindinventory/react-native-boilerplate initialized with success! 🚀\n" - ); + ) - console.log("Installing dependencies... 🛠️\n"); - execSync(`yarn`, { stdio: "inherit" }); - console.log("Dependencies installed successfully. 🚀\n"); + console.log("Installing dependencies... 🛠️\n") + execSync(`yarn`, { stdio: "inherit" }) + console.log("Dependencies installed successfully. 🚀\n") - console.log("bundle Installing 🛠️\n"); - execSync(`bundle`, { stdio: "inherit" }); - console.log("bundle installed successfully.🚀\n"); + console.log("Installing lefthook... 🛠️\n") + execSync(`npx lefthook install`, { stdio: "inherit" }) + console.log("lefthook installed successfully. 🚀\n") - console.log("pod-install Installing 🛠️\n"); - execSync(`npx pod-install`, { stdio: "inherit" }); - console.log("pod-install installed successfully.🚀\n"); -}; -const fs = require("fs"); + console.log("bundle Installing 🛠️\n") + execSync(`bundle`, { stdio: "inherit" }) + console.log("bundle installed successfully.🚀\n") + + console.log("pod-install Installing 🛠️\n") + execSync(`npx pod-install`, { stdio: "inherit" }) + console.log("pod-install installed successfully.🚀\n") +} +const fs = require("fs") const initializeGit = () => { const gitignoreContent = ` @@ -50,47 +54,47 @@ const initializeGit = () => { npm-debug.log* yarn-debug.log* yarn-error.log* - `; + ` - fs.writeFileSync(".gitignore", gitignoreContent); - console.log(".gitignore file created successfully. 🚀\n"); + fs.writeFileSync(".gitignore", gitignoreContent) + console.log(".gitignore file created successfully. 🚀\n") try { - execSync("git add .", { stdio: "inherit", shell: true }); + execSync("git add .", { stdio: "inherit", shell: true }) execSync(`git commit -m 'Initial commit'`, { stdio: "inherit", shell: true, - }); + }) } catch (error) { - console.error(`🚨 An error occurred while initializing git: ${error}`); + console.error(`🚨 An error occurred while initializing git: ${error}`) } -}; +} const main = async () => { - execSync("git init", { stdio: "inherit" }); - installDependencies(); - initializeGit(); -}; + execSync("git init", { stdio: "inherit" }) + installDependencies() + initializeGit() +} new Promise((resolve) => { - main(); - resolve(); + main() + resolve() }) .then(() => { console.log( "- 🎉 Congrats! Your project is ready with @mindinventory/react-native-boilerplate! 🎉\n" - ); + ) console.log( "- 📚 If you need to read more about this boilerplate : https://github.com/Mindinventory/react-native-boilerplate/blob/master/README.md\n" - ); + ) console.log( "- 🤕 If you have some troubles : https://github.com/Mindinventory/react-native-boilerplate/issues\n" - ); + ) console.log( "- ⭐ If you love this boilerplate, give us a star, you will be a ray of sunshine in our lives :) https://github.com/Mindinventory/react-native-boilerplate\n" - ); + ) }) .catch((error) => { - console.error(`🚨 An error occurred with post init script: ${error}`); - throw new Error(); - }); + console.error(`🚨 An error occurred with post init script: ${error}`) + throw new Error() + }) diff --git a/templates/CliTemplate/lefthook.yml b/templates/CliTemplate/lefthook.yml new file mode 100644 index 0000000..242a8a6 --- /dev/null +++ b/templates/CliTemplate/lefthook.yml @@ -0,0 +1,9 @@ +pre-commit: + parallel: false # Ensures commands run sequentially to catch errors properly + scripts: + lint: + # Run ESLint linting command + run: 'yarn lint' + typescript-check: + # Run TypeScript type-checking + run: 'npx tsc --noEmit' # Ensures TypeScript doesn't emit files diff --git a/templates/CliTemplate/package.json b/templates/CliTemplate/package.json index 94cc238..39f18c7 100644 --- a/templates/CliTemplate/package.json +++ b/templates/CliTemplate/package.json @@ -14,7 +14,6 @@ "ios": "react-native run-ios", "lint": "eslint . --ext .js,.jsx,.ts,.tsx", "postinstall": "npx pod-install", - "prepare": "husky", "refresh": "bash ./scripts/refresh.sh", "start": "NODE_ENV=default APP_ENV=default npx react-native start --reset-cache", "start:development": "NODE_ENV=development APP_ENV=development npx react-native start --reset-cache", @@ -76,8 +75,8 @@ "eslint-plugin-react-native": "^4.1.0", "eslint-plugin-sort-destructure-keys": "^2.0.0", "eslint-plugin-sort-keys-fix": "^1.1.2", - "husky": "^9.1.6", "jest": "^29.7.0", + "lefthook": "^1.10.5", "prettier": "3.3.3", "react-native-dotenv": "^3.4.11", "react-native-svg-transformer": "^1.5.0", diff --git a/templates/ExpoTemplate/.eslintrc.js b/templates/ExpoTemplate/.eslintrc.js index bbe6684..e3b20e9 100644 --- a/templates/ExpoTemplate/.eslintrc.js +++ b/templates/ExpoTemplate/.eslintrc.js @@ -78,19 +78,6 @@ module.exports = { }, ], 'no-shadow': 'off', - 'prettier/prettier': [ - 'error', - { - arrowParens: 'avoid', - bracketSameLine: true, - bracketSpacing: true, - quoteProps: 'consistent', - singleQuote: true, - tabWidth: 2, - trailingComma: 'es5', - useTabs: false, - }, - ], 'react-hooks/exhaustive-deps': 'error', 'react-hooks/rules-of-hooks': 'error', 'sort-destructure-keys/sort-destructure-keys': [ diff --git a/templates/ExpoTemplate/declarations.d.ts b/templates/ExpoTemplate/declarations.d.ts new file mode 100644 index 0000000..5ddeddc --- /dev/null +++ b/templates/ExpoTemplate/declarations.d.ts @@ -0,0 +1,8 @@ +declare module '*.svg' { + import React from 'react'; + + import { SvgProps } from 'react-native-svg'; + + const content: React.FC; + export default content; +} diff --git a/templates/ExpoTemplate/lefthook.yml b/templates/ExpoTemplate/lefthook.yml index e22fb43..242a8a6 100644 --- a/templates/ExpoTemplate/lefthook.yml +++ b/templates/ExpoTemplate/lefthook.yml @@ -1,5 +1,9 @@ pre-commit: - # Add your specific scripts or commands you want to run before a commit + parallel: false # Ensures commands run sequentially to catch errors properly scripts: - # Linting with ESLint for JavaScript/TypeScript projects - run: yarn lint & npx yarn typescript + lint: + # Run ESLint linting command + run: 'yarn lint' + typescript-check: + # Run TypeScript type-checking + run: 'npx tsc --noEmit' # Ensures TypeScript doesn't emit files diff --git a/templates/ExpoTemplate/package.json b/templates/ExpoTemplate/package.json index 7be904a..b10a27e 100644 --- a/templates/ExpoTemplate/package.json +++ b/templates/ExpoTemplate/package.json @@ -62,7 +62,7 @@ "@typescript-eslint/parser": "^8.7.0", "babel-jest": "^29.7.0", "babel-plugin-module-resolver": "^5.0.2", - "eslint": "^9.11.1", + "eslint": "8.57.1", "eslint-config-prettier": "^9.1.0", "eslint-plugin-import": "^2.30.0", "eslint-plugin-import-order-autofix": "^0.8.3", diff --git a/templates/ExpoTemplate/src/MainApp.tsx b/templates/ExpoTemplate/src/MainApp.tsx index 9a6c609..ef3aec4 100644 --- a/templates/ExpoTemplate/src/MainApp.tsx +++ b/templates/ExpoTemplate/src/MainApp.tsx @@ -25,7 +25,7 @@ export const MainApp = () => { */} - + From 79f17c5990f35e3ed56103aa8a649c5a6dd817c3 Mon Sep 17 00:00:00 2001 From: nkgohil Date: Thu, 16 Jan 2025 18:17:12 +0530 Subject: [PATCH 03/11] feat:change the lefthook.yml file configuration --- script.js | 8 +++++--- src/gitHandler.js | 4 ++++ templates/CliTemplate/lefthook.yml | 14 +++++++------- templates/ExpoTemplate/babel.config.js | 2 +- templates/ExpoTemplate/lefthook.yml | 14 +++++++------- 5 files changed, 24 insertions(+), 18 deletions(-) diff --git a/script.js b/script.js index 500f6f5..a80340a 100755 --- a/script.js +++ b/script.js @@ -15,9 +15,7 @@ const installDependencies = () => { execSync(`yarn`, { stdio: "inherit" }) console.log("Dependencies installed successfully. 🚀\n") - console.log("Installing lefthook... 🛠️\n") - execSync(`npx lefthook install`, { stdio: "inherit" }) - console.log("lefthook installed successfully. 🚀\n") + console.log("bundle Installing 🛠️\n") execSync(`bundle`, { stdio: "inherit" }) @@ -64,6 +62,10 @@ yarn-error.log* stdio: "inherit", shell: true, }) + + console.log("Installing lefthook... 🛠️\n") + execSync(`lefthook install`, { stdio: "inherit" }) + console.log("lefthook installed successfully. 🚀\n") } catch (error) { console.error(`🚨 An error occurred while initializing git: ${error}`) } diff --git a/src/gitHandler.js b/src/gitHandler.js index abf3084..1d045b4 100644 --- a/src/gitHandler.js +++ b/src/gitHandler.js @@ -1,5 +1,6 @@ const { exec } = require('child_process'); var util = require('util') +const {loading} = require("./helper"); const execAsync = util.promisify(exec) @@ -7,6 +8,9 @@ async function gitInitialize() { await execAsync("git init", { stdio: "inherit" }); await execAsync("git add ."); await execAsync(`git commit -m 'Initial commit'`); + let installingLeftHook = await loading('🛠️\u00A0Installing LeftHook...') + await execAsync(`npx lefthook install`); + installingLeftHook.succeed("LeftHook installed successfully"); } module.exports = { diff --git a/templates/CliTemplate/lefthook.yml b/templates/CliTemplate/lefthook.yml index 242a8a6..c876085 100644 --- a/templates/CliTemplate/lefthook.yml +++ b/templates/CliTemplate/lefthook.yml @@ -1,9 +1,9 @@ pre-commit: - parallel: false # Ensures commands run sequentially to catch errors properly - scripts: + parallel: true + commands: + type-check: + glob: '*.{ts,tsx}' + run: yarn typescript lint: - # Run ESLint linting command - run: 'yarn lint' - typescript-check: - # Run TypeScript type-checking - run: 'npx tsc --noEmit' # Ensures TypeScript doesn't emit files + glob: '*.{js,ts,jsx,tsx}' + run: yarn lint diff --git a/templates/ExpoTemplate/babel.config.js b/templates/ExpoTemplate/babel.config.js index d43b1ee..f45cd22 100644 --- a/templates/ExpoTemplate/babel.config.js +++ b/templates/ExpoTemplate/babel.config.js @@ -6,11 +6,11 @@ module.exports = function (api) { [ 'module:react-native-dotenv', { + allowUndefined: false, envName: 'APP_ENV', moduleName: '@env', path: './.env', safe: true, - allowUndefined: false, }, ], [ diff --git a/templates/ExpoTemplate/lefthook.yml b/templates/ExpoTemplate/lefthook.yml index 242a8a6..c876085 100644 --- a/templates/ExpoTemplate/lefthook.yml +++ b/templates/ExpoTemplate/lefthook.yml @@ -1,9 +1,9 @@ pre-commit: - parallel: false # Ensures commands run sequentially to catch errors properly - scripts: + parallel: true + commands: + type-check: + glob: '*.{ts,tsx}' + run: yarn typescript lint: - # Run ESLint linting command - run: 'yarn lint' - typescript-check: - # Run TypeScript type-checking - run: 'npx tsc --noEmit' # Ensures TypeScript doesn't emit files + glob: '*.{js,ts,jsx,tsx}' + run: yarn lint From d012547f62c3b75fda0a8757e2f08b103696b5b1 Mon Sep 17 00:00:00 2001 From: nkgohil Date: Thu, 23 Jan 2025 10:45:51 +0530 Subject: [PATCH 04/11] feat: add app store and play store URLs to environment configurations and update navigation structure --- .idea/.gitignore | 5 ++ lefthook.yml | 42 ++++++++++ templates/CliTemplate/env.d.ts | 2 + templates/CliTemplate/src/constants/config.ts | 4 +- .../src/screens/ForceUpdate/useForceUpdate.ts | 4 +- templates/ExpoTemplate/.env | 2 + templates/ExpoTemplate/env.d.ts | 2 + templates/ExpoTemplate/package.json | 2 + templates/ExpoTemplate/src/MainApp.tsx | 8 +- .../ExpoTemplate/src/assets/svgIcons/index.ts | 7 +- .../ExpoTemplate/src/assets/svgIcons/news.svg | 1 + .../src/assets/svgIcons/setting.svg | 4 +- .../ExpoTemplate/src/constants/config.ts | 4 +- .../src/navigation/AppNavigation.tsx | 79 +++++++++++-------- .../src/navigation/NewsListNavigation.tsx | 38 +++++++++ .../src/screens/Login/useLogin.ts | 8 +- .../src/screens/NewsList/useNewsList.ts | 21 ++--- .../src/screens/Setting/useSetting.ts | 24 +++--- templates/ExpoTemplate/tsconfig.json | 2 +- 19 files changed, 191 insertions(+), 68 deletions(-) create mode 100644 .idea/.gitignore create mode 100644 lefthook.yml create mode 100644 templates/ExpoTemplate/src/assets/svgIcons/news.svg create mode 100644 templates/ExpoTemplate/src/navigation/NewsListNavigation.tsx diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..b58b603 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,5 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ diff --git a/lefthook.yml b/lefthook.yml new file mode 100644 index 0000000..e18689e --- /dev/null +++ b/lefthook.yml @@ -0,0 +1,42 @@ +# EXAMPLE USAGE: +# +# Refer for explanation to following link: +# https://evilmartians.github.io/lefthook/configuration/ +# +# pre-push: +# jobs: +# - name: packages audit +# tags: +# - frontend +# - security +# run: yarn audit +# +# - name: gems audit +# tags: +# - backend +# - security +# run: bundle audit +# +# pre-commit: +# parallel: true +# jobs: +# - run: yarn eslint {staged_files} +# glob: "*.{js,ts,jsx,tsx}" +# +# - name: rubocop +# glob: "*.rb" +# exclude: +# - config/application.rb +# - config/routes.rb +# run: bundle exec rubocop --force-exclusion {all_files} +# +# - name: govet +# files: git ls-files -m +# glob: "*.go" +# run: go vet {files} +# +# - script: "hello.js" +# runner: node +# +# - script: "hello.go" +# runner: go run diff --git a/templates/CliTemplate/env.d.ts b/templates/CliTemplate/env.d.ts index 221cce8..15e4984 100644 --- a/templates/CliTemplate/env.d.ts +++ b/templates/CliTemplate/env.d.ts @@ -1,4 +1,6 @@ declare module '@env' { export const API_URL: string; export const ENV: string; + export const APP_STORE_URL: string; + export const PLAY_STORE_URL: string; } diff --git a/templates/CliTemplate/src/constants/config.ts b/templates/CliTemplate/src/constants/config.ts index b810ff3..83a1dc6 100644 --- a/templates/CliTemplate/src/constants/config.ts +++ b/templates/CliTemplate/src/constants/config.ts @@ -1,6 +1,8 @@ -import { API_URL, ENV } from '@env'; +import { API_URL, APP_STORE_URL, ENV, PLAY_STORE_URL } from '@env'; export const AppConfig = { API_URL, ENV, + APP_STORE_URL, + PLAY_STORE_URL }; diff --git a/templates/CliTemplate/src/screens/ForceUpdate/useForceUpdate.ts b/templates/CliTemplate/src/screens/ForceUpdate/useForceUpdate.ts index d112491..6df841b 100644 --- a/templates/CliTemplate/src/screens/ForceUpdate/useForceUpdate.ts +++ b/templates/CliTemplate/src/screens/ForceUpdate/useForceUpdate.ts @@ -20,10 +20,10 @@ const useForceUpdate = () => { ? AppConfig.APP_STORE_URL : AppConfig.PLAY_STORE_URL; Linking.canOpenURL(URLToOpen) - .then(res => { + .then((res: any) => { res && Linking.openURL(URLToOpen); }) - .catch(error => { + .catch((error: any) => { logger(`Error:: ${error}`); }); } catch (error) { diff --git a/templates/ExpoTemplate/.env b/templates/ExpoTemplate/.env index 5ddc388..f819d74 100644 --- a/templates/ExpoTemplate/.env +++ b/templates/ExpoTemplate/.env @@ -1,2 +1,4 @@ ENV = default API_URL = https://min-api.cryptocompare.com/data/v2 +APP_STORE_URL="" +PLAY_STORE_URL="" diff --git a/templates/ExpoTemplate/env.d.ts b/templates/ExpoTemplate/env.d.ts index 221cce8..748a091 100644 --- a/templates/ExpoTemplate/env.d.ts +++ b/templates/ExpoTemplate/env.d.ts @@ -1,4 +1,6 @@ declare module '@env' { export const API_URL: string; + export const APP_STORE_URL: string; export const ENV: string; + export const PLAY_STORE_URL: string; } diff --git a/templates/ExpoTemplate/package.json b/templates/ExpoTemplate/package.json index b10a27e..8eef997 100644 --- a/templates/ExpoTemplate/package.json +++ b/templates/ExpoTemplate/package.json @@ -21,6 +21,7 @@ "dependencies": { "@react-native-async-storage/async-storage": "1.23.1", "@react-native-community/netinfo": "11.3.1", + "@react-navigation/bottom-tabs": "6.6.1", "@react-navigation/native": "^6.1.18", "@react-navigation/native-stack": "^6.11.0", "@reduxjs/toolkit": "^2.2.7", @@ -58,6 +59,7 @@ "@types/i18n-js": "^3.8.9", "@types/jest": "^29.5.13", "@types/react": "~18.2.79", + "@types/react-native": "^0.73.0", "@types/react-test-renderer": "^18.3.0", "@typescript-eslint/parser": "^8.7.0", "babel-jest": "^29.7.0", diff --git a/templates/ExpoTemplate/src/MainApp.tsx b/templates/ExpoTemplate/src/MainApp.tsx index ef3aec4..d9edc4b 100644 --- a/templates/ExpoTemplate/src/MainApp.tsx +++ b/templates/ExpoTemplate/src/MainApp.tsx @@ -1,16 +1,22 @@ import React from 'react'; import { IndicatorView } from '@app/blueprints'; +import { createBottomTabNavigator } from '@react-navigation/bottom-tabs'; import { NavigationContainer } from '@react-navigation/native'; import { Provider } from 'react-redux'; import { PersistGate } from 'redux-persist/integration/react'; import { LocalizationProvider, ThemeProvider } from './context'; import { AppNavigation, navigationRef } from './navigation/AppNavigation'; +import { Screen } from './navigation/appNavigation.type'; +import { NewsListScreen, SettingScreen } from './screens'; import store, { persistor } from './store'; import { loader } from './utils'; +import App from '../App'; export const MainApp = () => { + const Tab = createBottomTabNavigator(); + return ( @@ -25,7 +31,7 @@ export const MainApp = () => { */} - + diff --git a/templates/ExpoTemplate/src/assets/svgIcons/index.ts b/templates/ExpoTemplate/src/assets/svgIcons/index.ts index 3735737..c4d4bba 100644 --- a/templates/ExpoTemplate/src/assets/svgIcons/index.ts +++ b/templates/ExpoTemplate/src/assets/svgIcons/index.ts @@ -1,9 +1,12 @@ +import NEWS_ICON from './news.svg'; import SETTING_ICON from './setting.svg'; export enum SVGIcons { - SETTING = 1, + SETTING = 'SETTING', + NEWS = 'NEWS', } export const SVGIconsMapper = { - 1: SETTING_ICON, + NEWS: NEWS_ICON, + SETTING: SETTING_ICON, }; diff --git a/templates/ExpoTemplate/src/assets/svgIcons/news.svg b/templates/ExpoTemplate/src/assets/svgIcons/news.svg new file mode 100644 index 0000000..02e6258 --- /dev/null +++ b/templates/ExpoTemplate/src/assets/svgIcons/news.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/templates/ExpoTemplate/src/assets/svgIcons/setting.svg b/templates/ExpoTemplate/src/assets/svgIcons/setting.svg index ca0de71..e17441f 100644 --- a/templates/ExpoTemplate/src/assets/svgIcons/setting.svg +++ b/templates/ExpoTemplate/src/assets/svgIcons/setting.svg @@ -1,3 +1 @@ - - - + \ No newline at end of file diff --git a/templates/ExpoTemplate/src/constants/config.ts b/templates/ExpoTemplate/src/constants/config.ts index b810ff3..1355ecd 100644 --- a/templates/ExpoTemplate/src/constants/config.ts +++ b/templates/ExpoTemplate/src/constants/config.ts @@ -1,6 +1,8 @@ -import { API_URL, ENV } from '@env'; +import { API_URL, APP_STORE_URL, ENV, PLAY_STORE_URL } from '@env'; export const AppConfig = { API_URL, + APP_STORE_URL, ENV, + PLAY_STORE_URL, }; diff --git a/templates/ExpoTemplate/src/navigation/AppNavigation.tsx b/templates/ExpoTemplate/src/navigation/AppNavigation.tsx index 3cc9f3e..7433d68 100644 --- a/templates/ExpoTemplate/src/navigation/AppNavigation.tsx +++ b/templates/ExpoTemplate/src/navigation/AppNavigation.tsx @@ -1,57 +1,74 @@ import React from 'react'; -import { NavigationContainerRef } from '@react-navigation/native'; import { - createNativeStackNavigator, - NativeStackNavigationOptions, -} from '@react-navigation/native-stack'; + BottomTabNavigationOptions, + createBottomTabNavigator, +} from '@react-navigation/bottom-tabs'; +import { NavigationContainerRef } from '@react-navigation/native'; import { useSelector } from 'react-redux'; -import { - LoginScreen, - NetworkLoggerScreen, - NewsDetailScreen, - NewsListScreen, - SettingScreen, -} from '@src/screens'; +import { SVGIcons } from '@src/assets'; +import { SvgIcon } from '@src/components'; +import { useAppContext } from '@src/context'; +import { NewsListScreen, SettingScreen } from '@src/screens'; import { isForceUpdate } from '@src/store'; import { NavStackParams, Screen } from './appNavigation.type'; import { ForUpdateStack } from './ForceupdateStack'; +import { NewsListNavigation } from './NewsListNavigation'; export const navigationRef = React.createRef>(); -const Stack = createNativeStackNavigator(); +export const AppNavigation = () => { + const { color } = useAppContext(); -const screenOptions: NativeStackNavigationOptions = { - animation: 'slide_from_right', - headerShown: false, -}; + const screenOptions: BottomTabNavigationOptions = { + headerShown: false, + tabBarStyle: { backgroundColor: color.backgroundColor }, + }; -export const AppNavigation = () => { const isForceUpdateApp = useSelector(isForceUpdate); + const Tab = createBottomTabNavigator(); + return ( <> {isForceUpdateApp ? ( ) : ( - - - + ( + + ), + title: 'News', + }} + /> + ( + + ), + title: 'Setting', + }} /> - - - {__DEV__ && ( - - )} - + )} ); diff --git a/templates/ExpoTemplate/src/navigation/NewsListNavigation.tsx b/templates/ExpoTemplate/src/navigation/NewsListNavigation.tsx new file mode 100644 index 0000000..b260674 --- /dev/null +++ b/templates/ExpoTemplate/src/navigation/NewsListNavigation.tsx @@ -0,0 +1,38 @@ +import React from 'react'; + +import { + createNativeStackNavigator, + NativeStackNavigationOptions, +} from '@react-navigation/native-stack'; + +import { + NetworkLoggerScreen, + NewsDetailScreen, + NewsListScreen, +} from '@src/screens'; + +import { NavStackParams, Screen } from './appNavigation.type'; + +const Stack = createNativeStackNavigator(); + +const screenOptions: NativeStackNavigationOptions = { + animation: 'slide_from_right', + headerShown: false, +}; + +export const NewsListNavigation = () => { + return ( + <> + + + + {__DEV__ && ( + + )} + + + ); +}; diff --git a/templates/ExpoTemplate/src/screens/Login/useLogin.ts b/templates/ExpoTemplate/src/screens/Login/useLogin.ts index 66b6fa8..0cd2403 100644 --- a/templates/ExpoTemplate/src/screens/Login/useLogin.ts +++ b/templates/ExpoTemplate/src/screens/Login/useLogin.ts @@ -1,15 +1,19 @@ import { useCallback, useRef, useState } from 'react'; import { TextInput } from 'react-native'; +import { NavigationProp, useNavigation } from '@react-navigation/native'; import * as yup from 'yup'; import { useAppContext } from '@src/context'; +import { NavStackParams, Screen } from '@src/navigation/appNavigation.type'; import { logger } from '@src/utils'; import { loginStyles } from './Login.style'; const useLogin = () => { - const { color, navigation } = useAppContext(); + const { color } = useAppContext(); + const { navigate } = + useNavigation>(); const [disabled, setDisabled] = useState(false); const passwordRef = useRef(null); @@ -39,7 +43,7 @@ const useLogin = () => { fieldValidation, handleButtonSubmit, initialValues, - navigation, + navigate, passwordRef, styles: loginStyles(color), }; diff --git a/templates/ExpoTemplate/src/screens/NewsList/useNewsList.ts b/templates/ExpoTemplate/src/screens/NewsList/useNewsList.ts index 97a2d5a..b792388 100644 --- a/templates/ExpoTemplate/src/screens/NewsList/useNewsList.ts +++ b/templates/ExpoTemplate/src/screens/NewsList/useNewsList.ts @@ -1,5 +1,6 @@ import { useCallback, useEffect } from 'react'; +import { NavigationProp, useNavigation } from '@react-navigation/native'; import { useSelector } from 'react-redux'; import { contents, useAppContext } from '@src/context'; @@ -8,10 +9,12 @@ import { getNewsData as newsData, setNews, useAppDispatch } from '@src/store'; import { logger } from '@src/utils'; import { newsListStyles } from './NewsList.style'; -import { Screen } from '../../navigation/appNavigation.type'; +import { NavStackParams, Screen } from '../../navigation/appNavigation.type'; const useNewsList = () => { - const { color, loader, navigation, services } = useAppContext(); + const { color, loader, services } = useAppContext(); + const { navigate } = + useNavigation>(); const dispatch = useAppDispatch(); const data = useSelector(newsData); @@ -29,21 +32,19 @@ const useNewsList = () => { }, [loader, services, dispatch]); const handleNavigationNetwork = useCallback(() => { - navigation.navigate(Screen.NETWORK_CHECK); - }, [navigation]); + navigate(Screen.NETWORK_CHECK); + }, [navigate]); const handleNavigationNewsItem = useCallback( (item: NewsResult) => () => { - navigation.navigate(Screen.NEWS_DETAIL, { - item, - }); + navigate(Screen.NEWS_DETAIL, { item }); }, - [navigation] + [navigate] ); const handleSetting = useCallback(() => { - navigation.navigate(Screen.SETTING); - }, [navigation]); + navigate(Screen.SETTING); + }, [navigate]); useEffect(() => { getNewsData(); diff --git a/templates/ExpoTemplate/src/screens/Setting/useSetting.ts b/templates/ExpoTemplate/src/screens/Setting/useSetting.ts index 8b6ec31..4b92e14 100644 --- a/templates/ExpoTemplate/src/screens/Setting/useSetting.ts +++ b/templates/ExpoTemplate/src/screens/Setting/useSetting.ts @@ -1,25 +1,23 @@ import { useCallback } from 'react'; +import { NavigationProp, useNavigation } from '@react-navigation/native'; + import { useAppContext } from '@src/context'; import { ContentLanguage } from '@src/i18n'; import { Theme } from '@src/utils'; import { settingStyles } from './Setting.style'; -import { Screen } from '../../navigation/appNavigation.type'; +import { NavStackParams, Screen } from '../../navigation/appNavigation.type'; const themes = ['Dark', 'Light', 'Theme1', 'Theme2', 'Theme3']; const languages = Object.keys(ContentLanguage); const useSetting = () => { - const { - appTheme, - color, - language, - navigation, - setAppTheme, - setLanguageInApp, - } = useAppContext(); + const { appTheme, color, language, setAppTheme, setLanguageInApp } = + useAppContext(); + const { navigate } = + useNavigation>(); const handleChangeTheme = useCallback( (m: string) => () => { @@ -38,10 +36,8 @@ const useSetting = () => { ); const handleLogin = useCallback(() => { - navigation.navigate(Screen.LOGIN); - }, [navigation]); - - // add your code here + navigate(Screen.LOGIN); + }, [navigate]); return { appTheme, @@ -51,7 +47,7 @@ const useSetting = () => { handleLogin, language, languages, - navigation, + navigate, styles: settingStyles(color), themes, }; diff --git a/templates/ExpoTemplate/tsconfig.json b/templates/ExpoTemplate/tsconfig.json index 5206b5a..2c03be5 100644 --- a/templates/ExpoTemplate/tsconfig.json +++ b/templates/ExpoTemplate/tsconfig.json @@ -26,7 +26,7 @@ "noImplicitUseStrict": false, "noStrictGenericChecks": false, "noUncheckedIndexedAccess": true, - "types": ["react-native", "jest", "node"], + "types": ["jest", "node"], "typeRoots": ["@types", "./node_modules/@types"], "allowSyntheticDefaultImports": true /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */, "esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */, From 43f2079c9af4f425745e02499dced782cac70cbb Mon Sep 17 00:00:00 2001 From: nkgohil Date: Thu, 23 Jan 2025 16:37:08 +0530 Subject: [PATCH 05/11] feat: integrate bottom tab navigation and add news list navigation --- templates/CliTemplate/ios/Podfile.lock | 166 ++++++++++-------- templates/CliTemplate/package.json | 1 + .../CliTemplate/src/assets/svgIcons/index.ts | 7 +- .../CliTemplate/src/assets/svgIcons/news.svg | 1 + .../src/assets/svgIcons/setting.svg | 4 +- .../src/navigation/AppNavigation.tsx | 79 +++++---- .../src/navigation/NewsListNavigation.tsx | 38 ++++ .../CliTemplate/src/screens/Login/useLogin.ts | 6 +- .../src/screens/NewsList/useNewsList.ts | 7 +- 9 files changed, 194 insertions(+), 115 deletions(-) create mode 100644 templates/CliTemplate/src/assets/svgIcons/news.svg create mode 100644 templates/CliTemplate/src/navigation/NewsListNavigation.tsx diff --git a/templates/CliTemplate/ios/Podfile.lock b/templates/CliTemplate/ios/Podfile.lock index dd61375..549b6b3 100644 --- a/templates/CliTemplate/ios/Podfile.lock +++ b/templates/CliTemplate/ios/Podfile.lock @@ -19,9 +19,9 @@ PODS: - libwebp/sharpyuv (1.3.2) - libwebp/webp (1.3.2): - libwebp/sharpyuv - - MMKV (1.3.5): - - MMKVCore (~> 1.3.5) - - MMKVCore (1.3.5) + - MMKV (2.0.2): + - MMKVCore (~> 2.0.2) + - MMKVCore (2.0.2) - RCT-Folly (2024.01.01.00): - boost - DoubleConversion @@ -1252,10 +1252,6 @@ PODS: - ReactCommon/turbomodule/bridging - ReactCommon/turbomodule/core - Yoga - - react-native-config (1.5.3): - - react-native-config/App (= 1.5.3) - - react-native-config/App (1.5.3): - - React-Core - react-native-mmkv (2.12.2): - DoubleConversion - glog @@ -1280,7 +1276,7 @@ PODS: - Yoga - react-native-netinfo (11.4.1): - React-Core - - react-native-safe-area-context (4.11.0): + - react-native-safe-area-context (4.14.1): - React-Core - React-nativeconfig (0.75.3) - React-NativeModulesApple (0.75.3): @@ -1546,7 +1542,7 @@ PODS: - React-Core - SDWebImage (~> 5.11.1) - SDWebImageWebPCoder (~> 0.8.4) - - RNGestureHandler (2.20.0): + - RNGestureHandler (2.22.0): - DoubleConversion - glog - hermes-engine @@ -1567,9 +1563,32 @@ PODS: - ReactCommon/turbomodule/bridging - ReactCommon/turbomodule/core - Yoga - - RNLocalize (3.2.1): + - RNLocalize (3.4.1): - React-Core - - RNReanimated (3.15.3): + - RNReanimated (3.16.7): + - DoubleConversion + - glog + - hermes-engine + - RCT-Folly (= 2024.01.01.00) + - RCTRequired + - RCTTypeSafety + - React-Core + - React-debug + - React-Fabric + - React-featureflags + - React-graphics + - React-ImageManager + - React-NativeModulesApple + - React-RCTFabric + - React-rendererdebug + - React-utils + - ReactCodegen + - ReactCommon/turbomodule/bridging + - ReactCommon/turbomodule/core + - RNReanimated/reanimated (= 3.16.7) + - RNReanimated/worklets (= 3.16.7) + - Yoga + - RNReanimated/reanimated (3.16.7): - DoubleConversion - glog - hermes-engine @@ -1589,10 +1608,9 @@ PODS: - ReactCodegen - ReactCommon/turbomodule/bridging - ReactCommon/turbomodule/core - - RNReanimated/reanimated (= 3.15.3) - - RNReanimated/worklets (= 3.15.3) + - RNReanimated/reanimated/apple (= 3.16.7) - Yoga - - RNReanimated/reanimated (3.15.3): + - RNReanimated/reanimated/apple (3.16.7): - DoubleConversion - glog - hermes-engine @@ -1613,7 +1631,7 @@ PODS: - ReactCommon/turbomodule/bridging - ReactCommon/turbomodule/core - Yoga - - RNReanimated/worklets (3.15.3): + - RNReanimated/worklets (3.16.7): - DoubleConversion - glog - hermes-engine @@ -1634,7 +1652,7 @@ PODS: - ReactCommon/turbomodule/bridging - ReactCommon/turbomodule/core - Yoga - - RNScreens (3.34.0): + - RNScreens (3.35.0): - DoubleConversion - glog - hermes-engine @@ -1656,7 +1674,7 @@ PODS: - ReactCommon/turbomodule/bridging - ReactCommon/turbomodule/core - Yoga - - RNSVG (15.7.1): + - RNSVG (15.11.1): - React-Core - SDWebImage (5.11.1): - SDWebImage/Core (= 5.11.1) @@ -1705,7 +1723,6 @@ DEPENDENCIES: - React-logger (from `../node_modules/react-native/ReactCommon/logger`) - React-Mapbuffer (from `../node_modules/react-native/ReactCommon`) - React-microtasksnativemodule (from `../node_modules/react-native/ReactCommon/react/nativemodule/microtasks`) - - react-native-config (from `../node_modules/react-native-config`) - react-native-mmkv (from `../node_modules/react-native-mmkv`) - "react-native-netinfo (from `../node_modules/@react-native-community/netinfo`)" - react-native-safe-area-context (from `../node_modules/react-native-safe-area-context`) @@ -1824,8 +1841,6 @@ EXTERNAL SOURCES: :path: "../node_modules/react-native/ReactCommon" React-microtasksnativemodule: :path: "../node_modules/react-native/ReactCommon/react/nativemodule/microtasks" - react-native-config: - :path: "../node_modules/react-native-config" react-native-mmkv: :path: "../node_modules/react-native-mmkv" react-native-netinfo: @@ -1904,76 +1919,75 @@ SPEC CHECKSUMS: DoubleConversion: 76ab83afb40bddeeee456813d9c04f67f78771b5 FBLazyVector: 7b438dceb9f904bd85ca3c31d64cce32a035472b fmt: 4c2741a687cc09f0634a2e2c72a838b99f1ff120 - glog: fdfdfe5479092de0c4bdbebedd9056951f092c4f + glog: 69ef571f3de08433d766d614c73a9838a06bf7eb hermes-engine: 8d2103d6c0176779aea4e25df6bb1410f9946680 libwebp: 1786c9f4ff8a279e4dac1e8f385004d5fc253009 - MMKV: 506311d0494023c2f7e0b62cc1f31b7370fa3cfb - MMKVCore: 9e2e5fd529b64a9fe15f1a7afb3d73b2e27b4db9 - RCT-Folly: 02617c592a293bd6d418e0a88ff4ee1f88329b47 + MMKV: 3eacda84cd1c4fc95cf848d3ecb69d85ed56006c + MMKVCore: 508b4d3a8ce031f1b5c8bd235f0517fb3f4c73a9 + RCT-Folly: 34124ae2e667a0e5f0ea378db071d27548124321 RCTDeprecation: 4191f6e64b72d9743f6fe1a8a16e89e868f5e9e7 RCTRequired: 9bb589570f2bb3abc6518761e3fd1ad9b7f7f06c RCTTypeSafety: 1c1a8741c86df0a0ac1a99cf3fb0e29eedbc2c88 React: b6810a201ee11e69ae8bfd4eb4aaab86610600bf React-callinvoker: d6c7898b63e6a2d37bc308f17c05be0ba3630b10 - React-Core: 2fc97900b68e7568233698c6113ca9d64ed8b520 - React-CoreModules: 2d68c251bc4080028f2835fa47504e8f20669a21 - React-cxxreact: 5f233f8ac7ea4772e49462e0ab2b0a15a4f80ab7 + React-Core: 411ef2293ba0c9147e04ee89324bc1575b38a089 + React-CoreModules: 30c44229d249317498dac4a984925c56e06f61c2 + React-cxxreact: 1ba92740ea3ed5be86898dec22f6548aa843da16 React-debug: fd0ed8ecd5f8a23c7daf5ceaca8aa722a4d083fd - React-defaultsnativemodule: 10f0f8bc38d8dc7d2273572cd85ed0b71298ecdd - React-domnativemodule: bfef3dda59e7030b498d0d78628f4adf414ab8e4 - React-Fabric: 3d0f5e2735d2f77a897ee684edeff7bb0e061919 - React-FabricComponents: 68032a85a3c25c9c8d6ce676d8af9a85e2370f24 - React-FabricImage: f8ac2df576703097b5b2f8d972b162cdca855aa3 + React-defaultsnativemodule: 33038152921d2f3fdef66ba1f8ef32e9ee68a834 + React-domnativemodule: 6e79b766cda4b3a447aa59aaf04473d257b0c5bb + React-Fabric: da5caca65022dcbbb95d12cebcde7770fdd44ff0 + React-FabricComponents: 19e0eb8be8d8f2afa1a921705a87d8818eba14cf + React-FabricImage: 50df9e6aace1781cf23e130171631d7674b4072c React-featureflags: cf78861db9318ae29982fa8953c92d31b276c9ac - React-featureflagsnativemodule: d04eb5c3f0ac33fe70b060d97e8649bfd69c5f1e - React-graphics: 7572851bca7242416b648c45d6af87d93d29281e - React-hermes: 95c27801c60615345ee6256eafa6d597ce983b8b - React-idlecallbacksnativemodule: f5f0b760ec2739b30e315e1afee3dd3a5a93c3b6 - React-ImageManager: aedf54d34d4475c66f4c3da6b8359b95bee904e4 - React-jserrorhandler: 0c8949672a00f2a502c767350e591e3ec3d82fb3 - React-jsi: d77bb442a4b0849063f2bd22d3c1fa71918713b7 - React-jsiexecutor: 3b9c6334b7b0f42d4c4aae950132766e63a7809f - React-jsinspector: e1bb5816869507527c30213cc1ed60eae9e3e9c4 - React-jsitracing: 3935b092f85bb1e53b8cf8a00f572413648af46b - React-logger: 4072f39df335ca443932e0ccece41fbeb5ca8404 - React-Mapbuffer: 714f2fae68edcabfc332b754e9fbaa8cfc68fdd4 - React-microtasksnativemodule: 4943ad8f99be8ccf5a63329fa7d269816609df9e - react-native-config: 8f7283449bbb048902f4e764affbbf24504454af - react-native-mmkv: 7d0b6c2a79e73100b933f2947a9c8741d664e18b - react-native-netinfo: f0a9899081c185db1de5bb2fdc1c88c202a059ac - react-native-safe-area-context: 851c62c48dce80ccaa5637b6aa5991a1bc36eca9 + React-featureflagsnativemodule: 3ff0c243e064a252293afb24aa0a6ee36b0149e4 + React-graphics: 7ed2dc99f706228448b870882729a8303343b5a5 + React-hermes: 167b427c2106b92ac47add9b35ca024d42453518 + React-idlecallbacksnativemodule: 6b917d089d3beaa096c6c95bcb428c4577fe65de + React-ImageManager: 9970421c57b6458d3a4d6ce319c9067217c4882f + React-jserrorhandler: 6764a4b7abd617332fb0935c9ba63a6369207a15 + React-jsi: 7713fae6d70c49a1b1b12d7e65ca62a50cd820d2 + React-jsiexecutor: 67260e3eb3d1f3d3fd41ff15e89ce4027ae9c36a + React-jsinspector: a0f1febb0bcf5770ff135444a6afee7520ee42f7 + React-jsitracing: bf77e00063522e4fd6d84fa129f0caaf360d275e + React-logger: 7e56c9eceafd7f45e98c16cb42ff3c9966c67119 + React-Mapbuffer: e68dd904f0f3a84dd35989288ed3bcf5e37f9737 + React-microtasksnativemodule: ca8806e64625be04b8f3d9f31f66508d02c42555 + react-native-mmkv: f84bf6f48c906911695f9cd16d39d4fb78fcd5a4 + react-native-netinfo: cec9c4e86083cb5b6aba0e0711f563e2fbbff187 + react-native-safe-area-context: 758e894ca5a9bd1868d2a9cfbca7326a2b6bf9dc React-nativeconfig: 4a9543185905fe41014c06776bf126083795aed9 - React-NativeModulesApple: 0506da59fc40d2e1e6e12a233db5e81c46face27 + React-NativeModulesApple: f6b6dc0998c945dd113858f1fc12e5e5f0da0990 React-perflogger: 3bbb82f18e9ac29a1a6931568e99d6305ef4403b - React-performancetimeline: d15a723422ed500f47cb271f3175abbeb217f5ba + React-performancetimeline: 05c0372923c2f3a9e8a5ae954258f0436003bffb React-RCTActionSheet: cb2b38a53d03ec22f1159c89667b86c2c490d92d - React-RCTAnimation: 6836c87c7364f471e9077fda80b7349bc674be33 - React-RCTAppDelegate: 2f11edfa7302451c792591f9a7838ca86cdcec34 - React-RCTBlob: 516dbbd38397f5013394fdd1cc65408cc82e37a1 - React-RCTFabric: b281a52c2b9726b0c64880e1535f2100013d5f7c - React-RCTImage: 1b2c2c1716db859ffff2d7a06a30b0ec5c677fc5 - React-RCTLinking: 59c07577767e705b0ab95d11e5ad74c61bf2a022 - React-RCTNetwork: f9a827e7d6bc428e0d99cd1fbe0427854354b8c1 - React-RCTSettings: 614252fecc24840f61590c016aca1664a52cfb0f - React-RCTText: 424549f68867265aa25969f50e7b9bf8bd70ae55 - React-RCTVibration: c8d156e6cce18f00b0310db7670fa997c7cda407 + React-RCTAnimation: c8be4f58eabb487d6346247ee8e7bac434737ed7 + React-RCTAppDelegate: d34bc2eeddc4d3f2a23275bf45e915d0d5df5284 + React-RCTBlob: 7a64271f64a60390a2e73edecaca2735be8044ff + React-RCTFabric: dc41b0a646666b7e8db159c26eeda20af8b6328f + React-RCTImage: 4fb571875362a78ccc01aded76b94a71ae466b8b + React-RCTLinking: e825182eaf7f4047f6bb11bb6cd2ae5858008e66 + React-RCTNetwork: 0e07b83395b6ff5016f7cea4ac99426a893a1438 + React-RCTSettings: bd68792732f116994e992cf48e5bb70c4eb3910e + React-RCTText: c3cfce62ddb887cdd86403a6130a58a1f8fed9f3 + React-RCTVibration: 32a10228b7affa8de6401dba6f0d73b5a8433342 React-rendererconsistency: 993f54bb0df644df2922cd87ea55238d510d992b - React-rendererdebug: 7a8cbb632b68d666ad0fc01b3f9dc1a1bcc9a9f9 + React-rendererdebug: 9cd1f3e6d12c1d9b99fce6ceb373495b29b3d9ee React-rncore: 1df26fe0ae861c599f9f2896f45e8834ef4b85f9 - React-RuntimeApple: b5b14b09e3be4058f9fe7ab4925e1ee343f03310 - React-RuntimeCore: 2073fb33da2aec6ce6c1c9d3d53898ed1f1d806d + React-RuntimeApple: 5fb9053ae46ec14407f24547afd903ec8f0c0b9a + React-RuntimeCore: f6af8417106c1ce5b494edd99e86b0d0069ad6c3 React-runtimeexecutor: 9a668b94ad5d93755443311715bd57680330286a - React-RuntimeHermes: b37c62718d6920ac2958a0052bdc1b01aca842b8 - React-runtimescheduler: e25750a18cbb7469e0513f1ace834d14e8c1a202 - React-utils: f2afa6acd905ca2ce7bb8ffb4a22f7f8a12534e8 - ReactCodegen: ff95a93d5ab5d9b2551571886271478eaa168565 - ReactCommon: 289214026502e6a93484f4a46bcc0efa4f3f2864 - RNFastImage: 5c9c9fed9c076e521b3f509fe79e790418a544e8 - RNGestureHandler: 6dfe7692a191ee224748964127114edf057a1475 - RNLocalize: 4f22418187ecd5ca693231093ff1d912d1b3c9bc - RNReanimated: c543567b3482ea54dec3216811d2360e581d35d0 - RNScreens: 19719a9c326e925498ac3b2d35c4e50fe87afc06 - RNSVG: 4590aa95758149fa27c5c83e54a6a466349a1688 + React-RuntimeHermes: 6c6053fb5aca5558b071cfbce2868ca50a3b8fc7 + React-runtimescheduler: 5d1a32712d441c38e6d5815069e1810d38ed26f7 + React-utils: 3c815e7d3abb801930a3df2db870c92855429fea + ReactCodegen: 3d11bcf0cac47a77042a3476a1c2f7058bfd6880 + ReactCommon: c65f7049a542669dcc7bff6b7a8071a039c7d0dd + RNFastImage: 462a183c4b0b6b26fdfd639e1ed6ba37536c3b87 + RNGestureHandler: 43970f04f34f186b4a5b2057cbf99c3039753c36 + RNLocalize: 15463c4d79c7da45230064b4adcf5e9bb984667e + RNReanimated: fea25bf524c62b2e7167edef63a398ca16a157fd + RNScreens: 35bb8e81aeccf111baa0ea01a54231390dbbcfd9 + RNSVG: 46769c92d1609e617dbf9326ad8a0cff912d0982 SDWebImage: a7f831e1a65eb5e285e3fb046a23fcfbf08e696d SDWebImageWebPCoder: 908b83b6adda48effe7667cd2b7f78c897e5111d SocketRocket: abac6f5de4d4d62d24e11868d7a2f427e0ef940d @@ -1981,4 +1995,4 @@ SPEC CHECKSUMS: PODFILE CHECKSUM: 5e17b38168c3ecd0174088728d32ea46a5eeb764 -COCOAPODS: 1.15.2 +COCOAPODS: 1.16.2 diff --git a/templates/CliTemplate/package.json b/templates/CliTemplate/package.json index 39f18c7..9b6f610 100644 --- a/templates/CliTemplate/package.json +++ b/templates/CliTemplate/package.json @@ -45,6 +45,7 @@ "redux": "^5.0.1", "redux-persist": "^6.0.0", "redux-thunk": "^3.1.0", + "@react-navigation/bottom-tabs": "6.6.1", "yup": "^1.4.0" }, "devDependencies": { diff --git a/templates/CliTemplate/src/assets/svgIcons/index.ts b/templates/CliTemplate/src/assets/svgIcons/index.ts index 3735737..c4d4bba 100644 --- a/templates/CliTemplate/src/assets/svgIcons/index.ts +++ b/templates/CliTemplate/src/assets/svgIcons/index.ts @@ -1,9 +1,12 @@ +import NEWS_ICON from './news.svg'; import SETTING_ICON from './setting.svg'; export enum SVGIcons { - SETTING = 1, + SETTING = 'SETTING', + NEWS = 'NEWS', } export const SVGIconsMapper = { - 1: SETTING_ICON, + NEWS: NEWS_ICON, + SETTING: SETTING_ICON, }; diff --git a/templates/CliTemplate/src/assets/svgIcons/news.svg b/templates/CliTemplate/src/assets/svgIcons/news.svg new file mode 100644 index 0000000..02e6258 --- /dev/null +++ b/templates/CliTemplate/src/assets/svgIcons/news.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/templates/CliTemplate/src/assets/svgIcons/setting.svg b/templates/CliTemplate/src/assets/svgIcons/setting.svg index ca0de71..e17441f 100644 --- a/templates/CliTemplate/src/assets/svgIcons/setting.svg +++ b/templates/CliTemplate/src/assets/svgIcons/setting.svg @@ -1,3 +1 @@ - - - + \ No newline at end of file diff --git a/templates/CliTemplate/src/navigation/AppNavigation.tsx b/templates/CliTemplate/src/navigation/AppNavigation.tsx index 3cc9f3e..d86d21d 100644 --- a/templates/CliTemplate/src/navigation/AppNavigation.tsx +++ b/templates/CliTemplate/src/navigation/AppNavigation.tsx @@ -1,57 +1,74 @@ import React from 'react'; -import { NavigationContainerRef } from '@react-navigation/native'; import { - createNativeStackNavigator, - NativeStackNavigationOptions, -} from '@react-navigation/native-stack'; + BottomTabNavigationOptions, + createBottomTabNavigator, +} from '@react-navigation/bottom-tabs'; +import { NavigationContainerRef } from '@react-navigation/native'; import { useSelector } from 'react-redux'; -import { - LoginScreen, - NetworkLoggerScreen, - NewsDetailScreen, - NewsListScreen, - SettingScreen, -} from '@src/screens'; +import { SVGIcons } from '@src/assets'; +import { SvgIcon } from '@src/components'; +import { useAppContext } from '@src/context'; +import { SettingScreen } from '@src/screens'; import { isForceUpdate } from '@src/store'; import { NavStackParams, Screen } from './appNavigation.type'; import { ForUpdateStack } from './ForceupdateStack'; +import { NewsListNavigation } from './NewsListNavigation'; export const navigationRef = React.createRef>(); -const Stack = createNativeStackNavigator(); +export const AppNavigation = () => { + const { color } = useAppContext(); -const screenOptions: NativeStackNavigationOptions = { - animation: 'slide_from_right', - headerShown: false, -}; + const screenOptions: BottomTabNavigationOptions = { + headerShown: false, + tabBarStyle: { backgroundColor: color.backgroundColor }, + }; -export const AppNavigation = () => { const isForceUpdateApp = useSelector(isForceUpdate); + const Tab = createBottomTabNavigator(); + return ( <> {isForceUpdateApp ? ( ) : ( - - - + ( + + ), + title: 'News', + }} + /> + ( + + ), + title: 'Setting', + }} /> - - - {__DEV__ && ( - - )} - + )} ); diff --git a/templates/CliTemplate/src/navigation/NewsListNavigation.tsx b/templates/CliTemplate/src/navigation/NewsListNavigation.tsx new file mode 100644 index 0000000..b260674 --- /dev/null +++ b/templates/CliTemplate/src/navigation/NewsListNavigation.tsx @@ -0,0 +1,38 @@ +import React from 'react'; + +import { + createNativeStackNavigator, + NativeStackNavigationOptions, +} from '@react-navigation/native-stack'; + +import { + NetworkLoggerScreen, + NewsDetailScreen, + NewsListScreen, +} from '@src/screens'; + +import { NavStackParams, Screen } from './appNavigation.type'; + +const Stack = createNativeStackNavigator(); + +const screenOptions: NativeStackNavigationOptions = { + animation: 'slide_from_right', + headerShown: false, +}; + +export const NewsListNavigation = () => { + return ( + <> + + + + {__DEV__ && ( + + )} + + + ); +}; diff --git a/templates/CliTemplate/src/screens/Login/useLogin.ts b/templates/CliTemplate/src/screens/Login/useLogin.ts index 66b6fa8..dc73ed8 100644 --- a/templates/CliTemplate/src/screens/Login/useLogin.ts +++ b/templates/CliTemplate/src/screens/Login/useLogin.ts @@ -7,9 +7,13 @@ import { useAppContext } from '@src/context'; import { logger } from '@src/utils'; import { loginStyles } from './Login.style'; +import { NavigationProp, useNavigation } from '@react-navigation/native'; +import { NavStackParams, Screen } from '@src/navigation/appNavigation.type'; const useLogin = () => { - const { color, navigation } = useAppContext(); + const { color } = useAppContext(); + const navigation = + useNavigation>(); const [disabled, setDisabled] = useState(false); const passwordRef = useRef(null); diff --git a/templates/CliTemplate/src/screens/NewsList/useNewsList.ts b/templates/CliTemplate/src/screens/NewsList/useNewsList.ts index 279223f..0ceb320 100644 --- a/templates/CliTemplate/src/screens/NewsList/useNewsList.ts +++ b/templates/CliTemplate/src/screens/NewsList/useNewsList.ts @@ -8,10 +8,13 @@ import { getNewsData as newsData, setNews, useAppDispatch } from '@src/store'; import { logger } from '@src/utils'; import { newsListStyles } from './NewsList.style'; -import { Screen } from '../../navigation/appNavigation.type'; +import { NavStackParams, Screen } from '../../navigation/appNavigation.type'; +import { NavigationProp, useNavigation } from '@react-navigation/native'; const useNewsList = () => { - const { color, loader, navigation, services } = useAppContext(); + const { color, loader, services } = useAppContext(); + const navigation = + useNavigation>(); const dispatch = useAppDispatch(); const data = useSelector(newsData); From fb70819257859825e5f6c84ea4a38db403d16229 Mon Sep 17 00:00:00 2001 From: nkgohil Date: Thu, 23 Jan 2025 16:39:12 +0530 Subject: [PATCH 06/11] refactor: remove unused imports and clean up navigation structure in MainApp and AppNavigation --- templates/ExpoTemplate/src/MainApp.tsx | 5 ----- templates/ExpoTemplate/src/navigation/AppNavigation.tsx | 2 +- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/templates/ExpoTemplate/src/MainApp.tsx b/templates/ExpoTemplate/src/MainApp.tsx index d9edc4b..feb1b96 100644 --- a/templates/ExpoTemplate/src/MainApp.tsx +++ b/templates/ExpoTemplate/src/MainApp.tsx @@ -1,21 +1,16 @@ import React from 'react'; import { IndicatorView } from '@app/blueprints'; -import { createBottomTabNavigator } from '@react-navigation/bottom-tabs'; import { NavigationContainer } from '@react-navigation/native'; import { Provider } from 'react-redux'; import { PersistGate } from 'redux-persist/integration/react'; import { LocalizationProvider, ThemeProvider } from './context'; import { AppNavigation, navigationRef } from './navigation/AppNavigation'; -import { Screen } from './navigation/appNavigation.type'; -import { NewsListScreen, SettingScreen } from './screens'; import store, { persistor } from './store'; import { loader } from './utils'; -import App from '../App'; export const MainApp = () => { - const Tab = createBottomTabNavigator(); return ( diff --git a/templates/ExpoTemplate/src/navigation/AppNavigation.tsx b/templates/ExpoTemplate/src/navigation/AppNavigation.tsx index 7433d68..d86d21d 100644 --- a/templates/ExpoTemplate/src/navigation/AppNavigation.tsx +++ b/templates/ExpoTemplate/src/navigation/AppNavigation.tsx @@ -10,7 +10,7 @@ import { useSelector } from 'react-redux'; import { SVGIcons } from '@src/assets'; import { SvgIcon } from '@src/components'; import { useAppContext } from '@src/context'; -import { NewsListScreen, SettingScreen } from '@src/screens'; +import { SettingScreen } from '@src/screens'; import { isForceUpdate } from '@src/store'; import { NavStackParams, Screen } from './appNavigation.type'; From d09a9f12c354b694684828439c4ad5b8f95aecd9 Mon Sep 17 00:00:00 2001 From: nkgohil Date: Mon, 27 Jan 2025 09:12:16 +0530 Subject: [PATCH 07/11] feat: implement SettingNavigation and update various screens for consistency --- templates/CliTemplate/Gemfile.lock | 105 +++++++ .../CliTemplate/blueprints/Button/Button.tsx | 2 +- .../blueprints/Indicator/Indicator.tsx | 20 +- .../CliTemplate/blueprints/Text/Text.tsx | 116 ++----- .../src/navigation/AppNavigation.tsx | 3 +- .../src/navigation/SettingNavigation.tsx | 34 +++ .../screens/ForceUpdate/ForceUpdateScreen.tsx | 2 +- .../src/screens/Login/LoginScreen.tsx | 2 +- .../screens/NewsDetail/NewsDetailScreen.tsx | 12 +- .../src/screens/NewsList/NewsListScreen.tsx | 6 +- .../src/screens/Setting/SettingScreen.tsx | 14 +- .../ExpoTemplate/blueprints/Button/Button.tsx | 283 ++++++++++++++++-- .../ExpoTemplate/blueprints/Text/Text.tsx | 116 ++----- .../blueprints/TextInput/TextInput.tsx | 247 +++++++++++++-- .../src/navigation/AppNavigation.tsx | 3 +- .../src/navigation/SettingNavigation.tsx | 34 +++ .../screens/ForceUpdate/ForceUpdateScreen.tsx | 2 +- .../src/screens/Login/LoginScreen.tsx | 6 +- .../src/screens/Login/useLogin.ts | 2 +- .../screens/NewsDetail/NewsDetailScreen.tsx | 12 +- .../src/screens/NewsList/NewsListScreen.tsx | 6 +- .../src/screens/Setting/SettingScreen.tsx | 51 +++- .../src/screens/Setting/useSetting.ts | 1 + 23 files changed, 777 insertions(+), 302 deletions(-) create mode 100644 templates/CliTemplate/Gemfile.lock create mode 100644 templates/CliTemplate/src/navigation/SettingNavigation.tsx create mode 100644 templates/ExpoTemplate/src/navigation/SettingNavigation.tsx diff --git a/templates/CliTemplate/Gemfile.lock b/templates/CliTemplate/Gemfile.lock new file mode 100644 index 0000000..786d924 --- /dev/null +++ b/templates/CliTemplate/Gemfile.lock @@ -0,0 +1,105 @@ +GEM + remote: https://rubygems.org/ + specs: + CFPropertyList (3.0.7) + base64 + nkf + rexml + activesupport (6.1.7.10) + concurrent-ruby (~> 1.0, >= 1.0.2) + i18n (>= 1.6, < 2) + minitest (>= 5.1) + tzinfo (~> 2.0) + zeitwerk (~> 2.3) + addressable (2.8.7) + public_suffix (>= 2.0.2, < 7.0) + algoliasearch (1.27.5) + httpclient (~> 2.8, >= 2.8.3) + json (>= 1.5.1) + atomos (0.1.3) + base64 (0.2.0) + claide (1.1.0) + cocoapods (1.16.2) + addressable (~> 2.8) + claide (>= 1.0.2, < 2.0) + cocoapods-core (= 1.16.2) + cocoapods-deintegrate (>= 1.0.3, < 2.0) + cocoapods-downloader (>= 2.1, < 3.0) + cocoapods-plugins (>= 1.0.0, < 2.0) + cocoapods-search (>= 1.0.0, < 2.0) + cocoapods-trunk (>= 1.6.0, < 2.0) + cocoapods-try (>= 1.1.0, < 2.0) + colored2 (~> 3.1) + escape (~> 0.0.4) + fourflusher (>= 2.3.0, < 3.0) + gh_inspector (~> 1.0) + molinillo (~> 0.8.0) + nap (~> 1.0) + ruby-macho (>= 2.3.0, < 3.0) + xcodeproj (>= 1.27.0, < 2.0) + cocoapods-core (1.16.2) + activesupport (>= 5.0, < 8) + addressable (~> 2.8) + algoliasearch (~> 1.0) + concurrent-ruby (~> 1.1) + fuzzy_match (~> 2.0.4) + nap (~> 1.0) + netrc (~> 0.11) + public_suffix (~> 4.0) + typhoeus (~> 1.0) + cocoapods-deintegrate (1.0.5) + cocoapods-downloader (2.1) + cocoapods-plugins (1.0.0) + nap + cocoapods-search (1.0.1) + cocoapods-trunk (1.6.0) + nap (>= 0.8, < 2.0) + netrc (~> 0.11) + cocoapods-try (1.2.0) + colored2 (3.1.2) + concurrent-ruby (1.3.5) + escape (0.0.4) + ethon (0.16.0) + ffi (>= 1.15.0) + ffi (1.17.1) + fourflusher (2.3.1) + fuzzy_match (2.0.4) + gh_inspector (1.1.3) + httpclient (2.8.3) + i18n (1.14.7) + concurrent-ruby (~> 1.0) + json (2.7.6) + minitest (5.25.4) + molinillo (0.8.0) + nanaimo (0.4.0) + nap (1.1.0) + netrc (0.11.0) + nkf (0.2.0) + public_suffix (4.0.7) + rexml (3.4.0) + ruby-macho (2.5.1) + typhoeus (1.4.1) + ethon (>= 0.9.0) + tzinfo (2.0.6) + concurrent-ruby (~> 1.0) + xcodeproj (1.27.0) + CFPropertyList (>= 2.3.3, < 4.0) + atomos (~> 0.1.3) + claide (>= 1.0.2, < 2.0) + colored2 (~> 3.1) + nanaimo (~> 0.4.0) + rexml (>= 3.3.6, < 4.0) + zeitwerk (2.6.18) + +PLATFORMS + ruby + +DEPENDENCIES + activesupport (>= 6.1.7.5, != 7.1.0) + cocoapods (>= 1.13, != 1.15.1, != 1.15.0) + +RUBY VERSION + ruby 2.6.10p210 + +BUNDLED WITH + 1.17.2 diff --git a/templates/CliTemplate/blueprints/Button/Button.tsx b/templates/CliTemplate/blueprints/Button/Button.tsx index 0a8df5b..853fe5f 100644 --- a/templates/CliTemplate/blueprints/Button/Button.tsx +++ b/templates/CliTemplate/blueprints/Button/Button.tsx @@ -79,7 +79,7 @@ export const Button = React.memo((props: ButtonProps) => { {...props}> {props.leftIcon} - + {title} {props.rightIcon} diff --git a/templates/CliTemplate/blueprints/Indicator/Indicator.tsx b/templates/CliTemplate/blueprints/Indicator/Indicator.tsx index eeccacb..174b2c2 100644 --- a/templates/CliTemplate/blueprints/Indicator/Indicator.tsx +++ b/templates/CliTemplate/blueprints/Indicator/Indicator.tsx @@ -43,16 +43,12 @@ export const IndicatorViewRef = ( } }, []); - useImperativeHandle( - ref, - () => { - return { - hide, - show, - }; - }, - [hide, show] - ); + useImperativeHandle(ref, () => { + return { + hide, + show, + }; + }, [hide, show]); const styles = indicatorStyles(color); @@ -66,9 +62,7 @@ export const IndicatorViewRef = ( color={color.primaryColor} style={styles.loaderStyle} /> - - Please wait ... - + Please wait ... ); diff --git a/templates/CliTemplate/blueprints/Text/Text.tsx b/templates/CliTemplate/blueprints/Text/Text.tsx index eb897c2..621b55b 100644 --- a/templates/CliTemplate/blueprints/Text/Text.tsx +++ b/templates/CliTemplate/blueprints/Text/Text.tsx @@ -8,105 +8,37 @@ import { } from 'react-native'; import { useColor } from '@src/context'; -import { scaledSize } from '@src/utils'; export enum Fonts { Poppins = 'Poppins', } -const BASE_TEXT: TextStyle = { - fontSize: scaledSize(7), -}; - -export const presets = { - default: BASE_TEXT, - font400: { - ...BASE_TEXT, - //add your font normal for weight 400 - fontFamily: Fonts.Poppins, - } as TextStyle, - font500: { - ...BASE_TEXT, - //add your font medium for weight 500 - fontFamily: Fonts.Poppins, - } as TextStyle, - font600: { - ...BASE_TEXT, - //add your font semi-bold for weight 600 - fontFamily: Fonts.Poppins, - } as TextStyle, - font700: { - ...BASE_TEXT, - //add your font bold for weight 700 - fontFamily: Fonts.Poppins, - } as TextStyle, - h1: { - ...BASE_TEXT, - fontFamily: Fonts.Poppins, - fontSize: scaledSize(24), - fontWeight: '700', - } as TextStyle, - h2: { - ...BASE_TEXT, - fontFamily: Fonts.Poppins, - fontSize: scaledSize(21), - fontWeight: '700', - } as TextStyle, - h3: { - ...BASE_TEXT, - fontFamily: Fonts.Poppins, - fontSize: scaledSize(18), - fontWeight: '500', - } as TextStyle, - h4: { - ...BASE_TEXT, - fontFamily: Fonts.Poppins, - fontSize: scaledSize(15), - fontWeight: '500', - } as TextStyle, - h5: { - ...BASE_TEXT, - fontFamily: Fonts.Poppins, - fontSize: scaledSize(12), - fontWeight: '400', - } as TextStyle, - h6: { - ...BASE_TEXT, - fontFamily: Fonts.Poppins, - fontSize: scaledSize(9), - fontWeight: '400', - } as TextStyle, - small: { - ...BASE_TEXT, - fontFamily: Fonts.Poppins, - fontSize: scaledSize(6), - fontWeight: '300', - } as TextStyle, - title: { - ...BASE_TEXT, - fontFamily: Fonts.Poppins, - fontSize: scaledSize(13), - fontWeight: '700', - } as TextStyle, -}; - -export type TextPresets = keyof typeof presets; - export interface TextProps extends TextProperties { style?: StyleProp; - preset?: TextPresets; color?: string; textAlign?: 'auto' | 'left' | 'right' | 'center' | 'justify'; + fontSize?: number; + fontWeight?: + | 'normal' + | 'bold' + | '100' + | '200' + | '300' + | '400' + | '500' + | '600' + | '700' + | '800' + | '900'; } -export const Text = ({ children, ...props }: TextProps) => { - const { - color, - preset = 'default', - style: styleOverride, - textAlign = 'auto', - ...rest - } = props; +export const Text = ({ + children, + fontSize = 16, + fontWeight = 'normal', + ...props +}: TextProps) => { + const { color, style: styleOverride, textAlign = 'auto', ...rest } = props; const { color: palette } = useColor(); @@ -114,8 +46,12 @@ export const Text = ({ children, ...props }: TextProps) => { {children} diff --git a/templates/CliTemplate/src/navigation/AppNavigation.tsx b/templates/CliTemplate/src/navigation/AppNavigation.tsx index d86d21d..4cca652 100644 --- a/templates/CliTemplate/src/navigation/AppNavigation.tsx +++ b/templates/CliTemplate/src/navigation/AppNavigation.tsx @@ -16,6 +16,7 @@ import { isForceUpdate } from '@src/store'; import { NavStackParams, Screen } from './appNavigation.type'; import { ForUpdateStack } from './ForceupdateStack'; import { NewsListNavigation } from './NewsListNavigation'; +import { SettingNavigation } from './SettingNavigation'; export const navigationRef = React.createRef>(); @@ -55,7 +56,7 @@ export const AppNavigation = () => { /> ( (); + +const screenOptions: NativeStackNavigationOptions = { + animation: 'slide_from_right', + headerShown: false, +}; + +export const SettingNavigation = () => { + return ( + <> + + + + + + ); +}; diff --git a/templates/CliTemplate/src/screens/ForceUpdate/ForceUpdateScreen.tsx b/templates/CliTemplate/src/screens/ForceUpdate/ForceUpdateScreen.tsx index 6128026..dd021e2 100644 --- a/templates/CliTemplate/src/screens/ForceUpdate/ForceUpdateScreen.tsx +++ b/templates/CliTemplate/src/screens/ForceUpdate/ForceUpdateScreen.tsx @@ -12,7 +12,7 @@ const ForceUpdateScreen = () => { return ( - + {contents('forceUpdate.updateMessage')}