Browse Source

设置国家,语言,货币重启app

main
Your Name 2 weeks ago
parent
commit
ddfe408e9f
  1. 4
      app/screens/setting/CountrySetting.tsx
  2. 19
      app/store/useGlobalStore.ts
  3. 49
      package-lock.json
  4. 1
      package.json
  5. 978
      yarn.lock

4
app/screens/setting/CountrySetting.tsx

@ -13,6 +13,8 @@ import Toast from "react-native-toast-message";
import { eventBus } from "../../utils/eventBus";
import { changeLanguage } from "../../i18n";
import { useTranslation } from "react-i18next";
import RNRestart from 'react-native-restart';
// Define CountryList type to match API response
type CountryList = {
@ -84,6 +86,8 @@ export const CountrySetting = () => {
await changeLanguage(language);
}
eventBus.emit("refreshSetting");
RNRestart.Restart();
};
return (
<SafeAreaView style={styles.safeArea}>

19
app/store/useGlobalStore.ts

@ -0,0 +1,19 @@
import { create } from "zustand";
type GlobalState = {
country: string;
language: string;
currency: string;
setGlobalCountry: (region: { country: string }) => void;
setGlobalLanguage: (language: { language: string }) => void;
setGlobalCurrency: (currency: { currency: string }) => void;
};
export const useGlobalStore = create<GlobalState>((set) => ({
country: "",
language: "",
currency: "",
setGlobalCountry: ({ country }) => set({ country }),
setGlobalLanguage: ({ language }) => set({ language }),
setGlobalCurrency: ({ currency }) => set({ currency }),
}));

49
package-lock.json generated

@ -52,6 +52,7 @@
"react-native-reanimated-carousel": "^4.0.2",
"react-native-render-html": "^6.3.4",
"react-native-responsive-fontsize": "^0.5.1",
"react-native-restart": "^0.0.27",
"react-native-safe-area-context": "4.12.0",
"react-native-screens": "~4.4.0",
"react-native-svg": "^15.11.2",
@ -14829,6 +14830,8 @@
},
"node_modules/npm/node_modules/@isaacs/cliui/node_modules/string-width": {
"version": "5.1.2",
"resolved": "https://registry.npmmirror.com/string-width/-/string-width-5.1.2.tgz",
"integrity": "sha512-HnLOCR3vjcY8beoNLtcjZ5/nxn2afmME6lhrDrebokqMap+XbeW8n9TXpPDOqdGK5qcI3oT0GKTW6wC7EMiVqA==",
"inBundle": true,
"license": "MIT",
"dependencies": {
@ -15050,6 +15053,8 @@
},
"node_modules/npm/node_modules/@npmcli/metavuln-calculator/node_modules/pacote": {
"version": "20.0.0",
"resolved": "https://registry.npmmirror.com/pacote/-/pacote-20.0.0.tgz",
"integrity": "sha512-pRjC5UFwZCgx9kUFDVM9YEahv4guZ1nSLqwmWiLUnDbGsjs+U5w7z6Uc8HNR1a6x8qnu5y9xtGE6D1uAuYz+0A==",
"inBundle": true,
"license": "ISC",
"dependencies": {
@ -15396,6 +15401,8 @@
},
"node_modules/npm/node_modules/cacache/node_modules/tar": {
"version": "7.4.3",
"resolved": "https://registry.npmmirror.com/tar/-/tar-7.4.3.tgz",
"integrity": "sha512-5S7Va8hKfV7W5U6g3aYxXmlPoZVAwUMy9AOKyF2fVuZa2UD3qZjg578OrLRt8PcNN1PleVaL/5/yYATNL0ICUw==",
"inBundle": true,
"license": "ISC",
"dependencies": {
@ -15542,6 +15549,8 @@
},
"node_modules/npm/node_modules/cross-spawn/node_modules/which": {
"version": "2.0.2",
"resolved": "https://registry.npmmirror.com/which/-/which-2.0.2.tgz",
"integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==",
"inBundle": true,
"license": "ISC",
"dependencies": {
@ -16155,6 +16164,8 @@
},
"node_modules/npm/node_modules/make-fetch-happen/node_modules/negotiator": {
"version": "1.0.0",
"resolved": "https://registry.npmmirror.com/negotiator/-/negotiator-1.0.0.tgz",
"integrity": "sha512-8Ofs/AUQh8MaEcrlq5xOX0CQ9ypTF5dl78mjlMNfOK08fzpgTHQRQPBxcPlEtIw0yRpws+Zo/3r+5WRby7u3Gg==",
"inBundle": true,
"license": "MIT",
"engines": {
@ -16243,6 +16254,8 @@
},
"node_modules/npm/node_modules/minipass-flush/node_modules/minipass": {
"version": "3.3.6",
"resolved": "https://registry.npmmirror.com/minipass/-/minipass-3.3.6.tgz",
"integrity": "sha512-DxiNidxSEK+tHG6zOIklvNOwm3hvCrbUrdtzY74U6HKTJxvIDfOUL5W5P2Ghd3DTkhhKPYGqeNUIh5qcM4YBfw==",
"inBundle": true,
"license": "ISC",
"dependencies": {
@ -16267,6 +16280,8 @@
},
"node_modules/npm/node_modules/minipass-pipeline/node_modules/minipass": {
"version": "3.3.6",
"resolved": "https://registry.npmmirror.com/minipass/-/minipass-3.3.6.tgz",
"integrity": "sha512-DxiNidxSEK+tHG6zOIklvNOwm3hvCrbUrdtzY74U6HKTJxvIDfOUL5W5P2Ghd3DTkhhKPYGqeNUIh5qcM4YBfw==",
"inBundle": true,
"license": "ISC",
"dependencies": {
@ -16291,6 +16306,8 @@
},
"node_modules/npm/node_modules/minipass-sized/node_modules/minipass": {
"version": "3.3.6",
"resolved": "https://registry.npmmirror.com/minipass/-/minipass-3.3.6.tgz",
"integrity": "sha512-DxiNidxSEK+tHG6zOIklvNOwm3hvCrbUrdtzY74U6HKTJxvIDfOUL5W5P2Ghd3DTkhhKPYGqeNUIh5qcM4YBfw==",
"inBundle": true,
"license": "ISC",
"dependencies": {
@ -16316,6 +16333,8 @@
},
"node_modules/npm/node_modules/minizlib/node_modules/minipass": {
"version": "3.3.6",
"resolved": "https://registry.npmmirror.com/minipass/-/minipass-3.3.6.tgz",
"integrity": "sha512-DxiNidxSEK+tHG6zOIklvNOwm3hvCrbUrdtzY74U6HKTJxvIDfOUL5W5P2Ghd3DTkhhKPYGqeNUIh5qcM4YBfw==",
"inBundle": true,
"license": "ISC",
"dependencies": {
@ -16418,6 +16437,8 @@
},
"node_modules/npm/node_modules/node-gyp/node_modules/tar": {
"version": "7.4.3",
"resolved": "https://registry.npmmirror.com/tar/-/tar-7.4.3.tgz",
"integrity": "sha512-5S7Va8hKfV7W5U6g3aYxXmlPoZVAwUMy9AOKyF2fVuZa2UD3qZjg578OrLRt8PcNN1PleVaL/5/yYATNL0ICUw==",
"inBundle": true,
"license": "ISC",
"dependencies": {
@ -17044,6 +17065,8 @@
},
"node_modules/npm/node_modules/spdx-correct/node_modules/spdx-expression-parse": {
"version": "3.0.1",
"resolved": "https://registry.npmmirror.com/spdx-expression-parse/-/spdx-expression-parse-3.0.1.tgz",
"integrity": "sha512-cbqHunsQWnJNE6KhVSMsMeH5H/L9EpymbzqTQ3uLwNCLZ1Q481oWaofqH7nO6V07xlXwY6PhQdQ2IedWx/ZK4Q==",
"inBundle": true,
"license": "MIT",
"dependencies": {
@ -17185,6 +17208,8 @@
},
"node_modules/npm/node_modules/tar/node_modules/fs-minipass": {
"version": "2.1.0",
"resolved": "https://registry.npmmirror.com/fs-minipass/-/fs-minipass-2.1.0.tgz",
"integrity": "sha512-V/JgOLFCS+R6Vcq0slCuaeWEdNC3ouDlJMNIsacH2VtALiu9mV4LPrHc5cDl8k5aw6J8jwgWWpiTo5RYhmIzvg==",
"inBundle": true,
"license": "ISC",
"dependencies": {
@ -17196,6 +17221,8 @@
},
"node_modules/npm/node_modules/tar/node_modules/fs-minipass/node_modules/minipass": {
"version": "3.3.6",
"resolved": "https://registry.npmmirror.com/minipass/-/minipass-3.3.6.tgz",
"integrity": "sha512-DxiNidxSEK+tHG6zOIklvNOwm3hvCrbUrdtzY74U6HKTJxvIDfOUL5W5P2Ghd3DTkhhKPYGqeNUIh5qcM4YBfw==",
"inBundle": true,
"license": "ISC",
"dependencies": {
@ -17207,6 +17234,8 @@
},
"node_modules/npm/node_modules/tar/node_modules/minipass": {
"version": "5.0.0",
"resolved": "https://registry.npmmirror.com/minipass/-/minipass-5.0.0.tgz",
"integrity": "sha512-3FnjYuehv9k6ovOEbyOswadCDPX1piCfhV8ncmYtHOjuPwylVWsghTLo7rabjC3Rx5xD4HDx8Wm1xnMF7S5qFQ==",
"inBundle": true,
"license": "ISC",
"engines": {
@ -17254,6 +17283,8 @@
},
"node_modules/npm/node_modules/tuf-js/node_modules/@tufjs/models": {
"version": "3.0.1",
"resolved": "https://registry.npmmirror.com/@tufjs/models/-/models-3.0.1.tgz",
"integrity": "sha512-UUYHISyhCU3ZgN8yaear3cGATHb3SMuKHsQ/nVbHXcmnBf+LzQ/cQfhNG+rfaSHgqGKNEm2cOCLVLELStUQ1JA==",
"inBundle": true,
"license": "MIT",
"dependencies": {
@ -17310,6 +17341,8 @@
},
"node_modules/npm/node_modules/validate-npm-package-license/node_modules/spdx-expression-parse": {
"version": "3.0.1",
"resolved": "https://registry.npmmirror.com/spdx-expression-parse/-/spdx-expression-parse-3.0.1.tgz",
"integrity": "sha512-cbqHunsQWnJNE6KhVSMsMeH5H/L9EpymbzqTQ3uLwNCLZ1Q481oWaofqH7nO6V07xlXwY6PhQdQ2IedWx/ZK4Q==",
"inBundle": true,
"license": "MIT",
"dependencies": {
@ -17352,6 +17385,8 @@
},
"node_modules/npm/node_modules/which/node_modules/isexe": {
"version": "3.1.1",
"resolved": "https://registry.npmmirror.com/isexe/-/isexe-3.1.1.tgz",
"integrity": "sha512-LpB/54B+/2J5hqQ7imZHfdU31OlgQqx7ZicVlkm9kzg9/w8GKLEcFfJl/t7DCEDueOyBAD6zCCwTO6Fzs0NoEQ==",
"inBundle": true,
"license": "ISC",
"engines": {
@ -17397,6 +17432,8 @@
},
"node_modules/npm/node_modules/wrap-ansi-cjs/node_modules/ansi-styles": {
"version": "4.3.0",
"resolved": "https://registry.npmmirror.com/ansi-styles/-/ansi-styles-4.3.0.tgz",
"integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==",
"inBundle": true,
"license": "MIT",
"dependencies": {
@ -17431,6 +17468,8 @@
},
"node_modules/npm/node_modules/wrap-ansi/node_modules/string-width": {
"version": "5.1.2",
"resolved": "https://registry.npmmirror.com/string-width/-/string-width-5.1.2.tgz",
"integrity": "sha512-HnLOCR3vjcY8beoNLtcjZ5/nxn2afmME6lhrDrebokqMap+XbeW8n9TXpPDOqdGK5qcI3oT0GKTW6wC7EMiVqA==",
"inBundle": true,
"license": "MIT",
"dependencies": {
@ -19509,6 +19548,16 @@
"react-native": ">=0.42.0"
}
},
"node_modules/react-native-restart": {
"version": "0.0.27",
"resolved": "https://registry.npmmirror.com/react-native-restart/-/react-native-restart-0.0.27.tgz",
"integrity": "sha512-8KScVICrXwcTSJ1rjWkqVTHyEKQIttm5AIMGSK1QG1+RS5owYlE4z/1DykOTdWfVl9l16FIk0w9Xzk9ZO6jxlA==",
"license": "MIT",
"peerDependencies": {
"react": "*",
"react-native": "*"
}
},
"node_modules/react-native-safe-area-context": {
"version": "4.12.0",
"resolved": "https://registry.npmmirror.com/react-native-safe-area-context/-/react-native-safe-area-context-4.12.0.tgz",

1
package.json

@ -54,6 +54,7 @@
"react-native-reanimated-carousel": "^4.0.2",
"react-native-render-html": "^6.3.4",
"react-native-responsive-fontsize": "^0.5.1",
"react-native-restart": "^0.0.27",
"react-native-safe-area-context": "4.12.0",
"react-native-screens": "~4.4.0",
"react-native-svg": "^15.11.2",

978
yarn.lock

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save