From 3cb38fdc2ebe0d8090d2d73e166ac04f55b279f3 Mon Sep 17 00:00:00 2001 From: lovegaoshi <106490582+lovegaoshi@users.noreply.github.com> Date: Tue, 12 Nov 2024 09:05:06 -0800 Subject: [PATCH 01/14] chore: dep upg --- package.json | 2 +- patches/react-native-tab-view+4.0.1.patch | 13 +---- yarn.lock | 70 ++++++++++++++++------- 3 files changed, 50 insertions(+), 35 deletions(-) diff --git a/package.json b/package.json index 5bd72b631..42efc7ba8 100644 --- a/package.json +++ b/package.json @@ -61,7 +61,7 @@ "deepmerge": "^4.3.1", "dropbox": "git+https://lovegaoshi@github.com/lovegaoshi/dropbox-sdk-js.git", "event-target-polyfill": "^0.0.4", - "expo": "^52.0.2", + "expo": "^52.0.3", "expo-auth-session": "~6.0.0", "expo-clipboard": "~7.0.0", "expo-crypto": "~14.0.1", diff --git a/patches/react-native-tab-view+4.0.1.patch b/patches/react-native-tab-view+4.0.1.patch index 9b3394140..2b8439ccf 100644 --- a/patches/react-native-tab-view+4.0.1.patch +++ b/patches/react-native-tab-view+4.0.1.patch @@ -11,15 +11,4 @@ index 2b6be5a..aa099b7 100644 + position.setValue(index); } else { pagerRef.current?.setPageWithoutAnimation(index); - position.setValue(index); -@@ -115,8 +116,10 @@ function PagerViewAdapter({ - }), - onPageSelected: e => { - const index = e.nativeEvent.position; -+ setTimeout(() => { - indexRef.current = index; - onIndexChange(index); -+}, 100) - }, - onPageScrollStateChanged: onPageScrollStateChanged, - scrollEnabled: swipeEnabled, \ No newline at end of file + position.setValue(index); \ No newline at end of file diff --git a/yarn.lock b/yarn.lock index cd5d7585a..82426e087 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1783,9 +1783,9 @@ __metadata: languageName: node linkType: hard -"@expo/cli@npm:0.20.6": - version: 0.20.6 - resolution: "@expo/cli@npm:0.20.6" +"@expo/cli@npm:0.21.0": + version: 0.21.0 + resolution: "@expo/cli@npm:0.21.0" dependencies: "@0no-co/graphql.web": "npm:^1.0.8" "@babel/runtime": "npm:^7.20.0" @@ -1860,7 +1860,7 @@ __metadata: ws: "npm:^8.12.1" bin: expo-internal: build/bin/cli - checksum: 10c0/45823b513b627bf1253acd32ef979e2364f1f26f374638534b08ec97369e46f51100b8c0bc5d6a6f7556cd65176f5f6e1914838743955262e8808268a8aa2870 + checksum: 10c0/2d5d1653befad468915671b1554473bc25ebc5f636c2614541e5278b46e87119a69b54db56d436b1630e84f46cf47d4e84aa2ffcbe4a1bc2e390e2b53375e179 languageName: node linkType: hard @@ -1874,9 +1874,9 @@ __metadata: languageName: node linkType: hard -"@expo/config-plugins@npm:9.0.8": - version: 9.0.8 - resolution: "@expo/config-plugins@npm:9.0.8" +"@expo/config-plugins@npm:9.0.9": + version: 9.0.9 + resolution: "@expo/config-plugins@npm:9.0.9" dependencies: "@expo/config-types": "npm:^52.0.0" "@expo/json-file": "npm:~9.0.0" @@ -1892,7 +1892,7 @@ __metadata: slugify: "npm:^1.6.6" xcode: "npm:^3.0.1" xml2js: "npm:0.6.0" - checksum: 10c0/b0ed70b973f64c7bf8c15a3c4997a4c07538f6da3d96d33ae7b40df11670555e64d20baf5ebed591e31fd4565c51d098ff91d9e386ef400018f34e3c6b21733c + checksum: 10c0/ca38b671327ab5d0a58466a96bfc8f64d71890687c5d0a46515553b9a451e6bd81f6eedba783a1d81d8c0542bd49c031d53797d234ad1283ec9e67517da8b5c7 languageName: node linkType: hard @@ -2056,7 +2056,33 @@ __metadata: languageName: node linkType: hard -"@expo/metro-config@npm:0.19.0, @expo/metro-config@npm:~0.19.0": +"@expo/metro-config@npm:0.19.1": + version: 0.19.1 + resolution: "@expo/metro-config@npm:0.19.1" + dependencies: + "@babel/core": "npm:^7.20.0" + "@babel/generator": "npm:^7.20.5" + "@babel/parser": "npm:^7.20.0" + "@babel/types": "npm:^7.20.0" + "@expo/config": "npm:~10.0.0" + "@expo/env": "npm:~0.4.0" + "@expo/json-file": "npm:~9.0.0" + "@expo/spawn-async": "npm:^1.7.2" + chalk: "npm:^4.1.0" + debug: "npm:^4.3.2" + fs-extra: "npm:^9.1.0" + getenv: "npm:^1.0.0" + glob: "npm:^10.4.2" + jsc-safe-url: "npm:^0.2.4" + lightningcss: "npm:~1.27.0" + minimatch: "npm:^3.0.4" + postcss: "npm:~8.4.32" + resolve-from: "npm:^5.0.0" + checksum: 10c0/b0e062f19b2b366af4c461d2d9f61740643e32e391ae6e8c4568ae7b5b831174d2232d2119b14eff4f62b215e0f2690983a4d1634c0134797d4344f48d471c41 + languageName: node + linkType: hard + +"@expo/metro-config@npm:~0.19.0": version: 0.19.0 resolution: "@expo/metro-config@npm:0.19.0" dependencies: @@ -5259,7 +5285,7 @@ __metadata: eslint-plugin-react: "npm:^7.37.2" eslint-plugin-react-hooks: "npm:^5.0.0" event-target-polyfill: "npm:^0.0.4" - expo: "npm:^52.0.2" + expo: "npm:^52.0.3" expo-auth-session: "npm:~6.0.0" expo-clipboard: "npm:~7.0.0" expo-crypto: "npm:~14.0.1" @@ -8475,12 +8501,12 @@ __metadata: languageName: node linkType: hard -"expo-modules-core@npm:2.0.0": - version: 2.0.0 - resolution: "expo-modules-core@npm:2.0.0" +"expo-modules-core@npm:2.0.1": + version: 2.0.1 + resolution: "expo-modules-core@npm:2.0.1" dependencies: invariant: "npm:^2.2.4" - checksum: 10c0/be4f96a4f76293e3ae7365da2d91bf0e7b7156ced70602105826113a67c867dfe506cce6c6e826072417e9a54da215a921cf6ea716f315a96b5d435676b97ad7 + checksum: 10c0/3e18165d01e6e396957b0e128bc619aef81b7997c725283a17e049c6fdff554ac134701692f392d2ef9e089fcdfc9ebaffcbd6607a2107cc512b9882a33c3faa languageName: node linkType: hard @@ -8503,16 +8529,16 @@ __metadata: languageName: node linkType: hard -"expo@npm:^52.0.2": - version: 52.0.2 - resolution: "expo@npm:52.0.2" +"expo@npm:^52.0.3": + version: 52.0.3 + resolution: "expo@npm:52.0.3" dependencies: "@babel/runtime": "npm:^7.20.0" - "@expo/cli": "npm:0.20.6" + "@expo/cli": "npm:0.21.0" "@expo/config": "npm:10.0.3" - "@expo/config-plugins": "npm:9.0.8" + "@expo/config-plugins": "npm:9.0.9" "@expo/fingerprint": "npm:0.11.2" - "@expo/metro-config": "npm:0.19.0" + "@expo/metro-config": "npm:0.19.1" "@expo/vector-icons": "npm:^14.0.0" babel-preset-expo: "npm:~12.0.0" expo-asset: "npm:~11.0.1" @@ -8521,7 +8547,7 @@ __metadata: expo-font: "npm:~13.0.1" expo-keep-awake: "npm:~14.0.1" expo-modules-autolinking: "npm:2.0.0" - expo-modules-core: "npm:2.0.0" + expo-modules-core: "npm:2.0.1" fbemitter: "npm:^3.0.0" web-streams-polyfill: "npm:^3.3.2" whatwg-url-without-unicode: "npm:8.0.0-3" @@ -8540,7 +8566,7 @@ __metadata: optional: true bin: expo: bin/cli - checksum: 10c0/e468a0ee9f2afe496c34416cfcc448be582b2cf5ecb1f6cfc65bde7efe31cbccc2fe05ab4efd65080e7f2d411801d06da692f4eccefd243cd75d31705d3d1bb4 + checksum: 10c0/5f338389650d58483482655c240ce91d84ce767658aed31d24f8b32064eb947f68065035a75fe5828822c756540dca02affc93e1753dc2a759c2997f9d9e528d languageName: node linkType: hard From 7505bfd7ba9068dbda0e103466cdd6dbc2d5cd5e Mon Sep 17 00:00:00 2001 From: lovegaoshi <106490582+lovegaoshi@users.noreply.github.com> Date: Tue, 12 Nov 2024 09:41:06 -0800 Subject: [PATCH 02/14] chore: disable newarch garbage --- android/gradle.properties | 2 +- patches/react-native-tab-view+4.0.1.patch | 14 -------------- 2 files changed, 1 insertion(+), 15 deletions(-) delete mode 100644 patches/react-native-tab-view+4.0.1.patch diff --git a/android/gradle.properties b/android/gradle.properties index 952ab614f..005807b44 100644 --- a/android/gradle.properties +++ b/android/gradle.properties @@ -35,7 +35,7 @@ reactNativeArchitectures=armeabi-v7a,arm64-v8a,x86,x86_64 # your application. You should enable this flag either if you want # to write custom TurboModules/Fabric components OR use libraries that # are providing them. -newArchEnabled=true +newArchEnabled=false # Use this property to enable or disable the Hermes JS engine. # If set to false, you will be using JSC instead. diff --git a/patches/react-native-tab-view+4.0.1.patch b/patches/react-native-tab-view+4.0.1.patch deleted file mode 100644 index 2b8439ccf..000000000 --- a/patches/react-native-tab-view+4.0.1.patch +++ /dev/null @@ -1,14 +0,0 @@ -diff --git a/node_modules/react-native-tab-view/lib/commonjs/PagerViewAdapter.js b/node_modules/react-native-tab-view/lib/commonjs/PagerViewAdapter.js -index 2b6be5a..aa099b7 100644 ---- a/node_modules/react-native-tab-view/lib/commonjs/PagerViewAdapter.js -+++ b/node_modules/react-native-tab-view/lib/commonjs/PagerViewAdapter.js -@@ -54,7 +54,8 @@ function PagerViewAdapter({ - } - if (indexRef.current !== index) { - if (animationEnabled) { -- pagerRef.current?.setPage(index); -+ pagerRef.current?.setPageWithoutAnimation(index); -+ position.setValue(index); - } else { - pagerRef.current?.setPageWithoutAnimation(index); - position.setValue(index); \ No newline at end of file From 69eeaa4c8c846dc8086e9641745bacb28356210e Mon Sep 17 00:00:00 2001 From: lovegaoshi <106490582+lovegaoshi@users.noreply.github.com> Date: Tue, 12 Nov 2024 11:12:38 -0800 Subject: [PATCH 03/14] feat: billing --- src/App.tsx | 4 ++-- src/components/billing/View.tsx | 1 + src/hooks/useVIP.ts | 30 +++++++++++++++++++++++++++++- 3 files changed, 32 insertions(+), 3 deletions(-) create mode 100644 src/components/billing/View.tsx diff --git a/src/App.tsx b/src/App.tsx index 7d16ca0eb..daccaeb4d 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -16,7 +16,7 @@ import MainBackground from './components/background/MainBackground'; import useTheme from './hooks/useTheme'; // eslint-disable-next-line import/no-unresolved import { TRACKING } from '@env'; -import useVIP from './hooks/useVIP'; +import { useSetupVIP } from './hooks/useVIP'; if (TRACKING) { Sentry.init({ @@ -52,7 +52,7 @@ const APM = ({ PIP, isLandscape }: { PIP: boolean; isLandscape: boolean }) => { }; export default function App(appProps: NoxComponent.AppProps) { - const { vip } = useVIP(); + const { vip } = useSetupVIP(); const isSplashReady = useSplash( __DEV__ || appProps.intentData || vip ? 1 : 2500, ); diff --git a/src/components/billing/View.tsx b/src/components/billing/View.tsx new file mode 100644 index 000000000..2d1ec2382 --- /dev/null +++ b/src/components/billing/View.tsx @@ -0,0 +1 @@ +export default () => {}; diff --git a/src/hooks/useVIP.ts b/src/hooks/useVIP.ts index dbd4fec2f..c39d10871 100644 --- a/src/hooks/useVIP.ts +++ b/src/hooks/useVIP.ts @@ -1,5 +1,10 @@ import * as SecureStore from 'expo-secure-store'; -import { useState } from 'react'; +import { useEffect, useState } from 'react'; +import Purchases from 'react-native-purchases'; + +import { isAndroid } from '@utils/RNUtils'; +// eslint-disable-next-line import/no-unresolved +import { APPSTORE } from '@env'; const VIPKey = 'APMVIP'; @@ -17,4 +22,27 @@ const useVIP = () => { return { vip }; }; +export const useSetupVIP = () => { + const { vip } = useVIP(); + + const init = async () => { + if (!APPSTORE) { + return; + } + if (isAndroid) { + Purchases.configure({ apiKey: 'goog_XXAuAgmqFMypeJIGHTlyRZNdoGh' }); + } + try { + console.log('purhcase', await Purchases.getCustomerInfo()); + } catch (e) { + console.error(e); + } + }; + + useEffect(() => { + init(); + }, []); + return { vip }; +}; + export default useVIP; From 1e49929709b7bf19996b7f0fa53f37e6f45a6f9a Mon Sep 17 00:00:00 2001 From: lovegaoshi <106490582+lovegaoshi@users.noreply.github.com> Date: Tue, 12 Nov 2024 12:51:11 -0800 Subject: [PATCH 04/14] feat: billing --- src/components/billing/View.tsx | 93 +++++++++++++++++++- src/components/billing/bill.ts | 4 - src/components/setting/DeveloperSettings.tsx | 8 -- src/components/setting/View.tsx | 17 +++- src/components/style.ts | 1 + src/hooks/useVIP.ts | 46 +++++++--- src/localization/en/translation.json | 14 ++- src/localization/zhcn/translation.json | 14 ++- src/utils/Bilibili/BiliUser.ts | 15 +++- 9 files changed, 177 insertions(+), 35 deletions(-) delete mode 100644 src/components/billing/bill.ts diff --git a/src/components/billing/View.tsx b/src/components/billing/View.tsx index 2d1ec2382..388fe1f6a 100644 --- a/src/components/billing/View.tsx +++ b/src/components/billing/View.tsx @@ -1 +1,92 @@ -export default () => {}; +import { View } from 'react-native'; +import React, { useState } from 'react'; +import { Text, Button, ActivityIndicator } from 'react-native-paper'; +import { useTranslation } from 'react-i18next'; +import Purchases from 'react-native-purchases'; + +import useVIP, { checkGuardVIP } from '@hooks/useVIP'; +import { styles } from '../style'; +import { StyleSheet } from 'react-native'; + +interface LoadingChildrenProps { + setLoading: React.Dispatch>; +} +interface LoadingWrapperProps { + Child: (p: LoadingChildrenProps) => JSX.Element; +} + +const LoadingIconWrapper = ({ Child }: LoadingWrapperProps) => { + const [loading, setLoading] = useState(false); + if (loading) { + return ; + } + return ; +}; + +const BiliVIP = ({ setLoading }: LoadingChildrenProps) => { + const { t } = useTranslation(); + + const checkBiliVIP = async () => { + setLoading(true); + await checkGuardVIP(); + setLoading(false); + }; + + return ; +}; + +const RevenueCatVIP = ({ setLoading }: LoadingChildrenProps) => { + const { t } = useTranslation(); + const checkRevenueCatVIP = async () => { + setLoading(true); + try { + console.log('purhcase', await Purchases.getOfferings()); + } catch (e) { + console.error(JSON.stringify(e)); + } + setLoading(false); + }; + + return ( + + ); +}; + +const PurchaseVIPScreen = () => { + const { t } = useTranslation(); + return ( + + {t('Billing.PremiumFeaturesIntro')} + + + + + {t('Billing.NoxFans')} + + ); +}; + +const VIPScreen = () => { + const { t } = useTranslation(); + + return ( + + {t('Billing.thankU')} + {t('Billing.godBlessU')} + {t('Billing.urVeryVeryGorgeous')} + + ); +}; + +export default () => { + const vip = useVIP(state => state.VIP); + + if (vip) { + return ; + } + return ; +}; + +const mStyle = StyleSheet.create({ + container: { flex: 1, paddingHorizontal: 10, paddingTop: 10 }, +}); diff --git a/src/components/billing/bill.ts b/src/components/billing/bill.ts deleted file mode 100644 index 21b39dd77..000000000 --- a/src/components/billing/bill.ts +++ /dev/null @@ -1,4 +0,0 @@ -import { getHasGuard } from '@utils/Bilibili/BiliUser'; - -//暗精灵和小孩梓尊享APM VIP服务 -const getBiliVIPStatus = () => getHasGuard([529249, 7706705]); diff --git a/src/components/setting/DeveloperSettings.tsx b/src/components/setting/DeveloperSettings.tsx index 36f6c2643..00baa7b17 100644 --- a/src/components/setting/DeveloperSettings.tsx +++ b/src/components/setting/DeveloperSettings.tsx @@ -32,7 +32,6 @@ import { enableTanaka, } from '@hooks/useTanakaAmazingCommodities'; import { isAndroid } from '@utils/RNUtils'; -import { purchaseVIP } from '@hooks/useVIP'; enum Icons { setlog = 'console', @@ -45,7 +44,6 @@ enum Icons { fade = 'cosine-wave', plugins = 'puzzle', Tanaka = 'emoticon-devil', - VIP = 'cash', } enum VIEW { @@ -324,12 +322,6 @@ const Home = ({ navigation }: NoxComponent.StackNavigationProps) => { } settingCategory="DeveloperSettings" /> - { onPress={() => navigation.navigate(NoxView.DEVELOPER)} settingCategory="Settings" /> + navigation.navigate(NoxView.PREMIUM)} + settingCategory="Settings" + /> { /> + ); }; diff --git a/src/components/style.ts b/src/components/style.ts index 615ee1685..e19477f3c 100644 --- a/src/components/style.ts +++ b/src/components/style.ts @@ -148,6 +148,7 @@ export const replaceStyleColor = ({ export const styles = StyleSheet.create({ flex: { flex: 1 }, + centerText: { textAlign: 'center' }, screenContainer: { flex: 1, backgroundColor: 'white', diff --git a/src/hooks/useVIP.ts b/src/hooks/useVIP.ts index c39d10871..b42a7bc69 100644 --- a/src/hooks/useVIP.ts +++ b/src/hooks/useVIP.ts @@ -1,29 +1,53 @@ import * as SecureStore from 'expo-secure-store'; import { useEffect, useState } from 'react'; import Purchases from 'react-native-purchases'; +import { create } from 'zustand'; import { isAndroid } from '@utils/RNUtils'; +import { getHasGuard } from '@utils/Bilibili/BiliUser'; // eslint-disable-next-line import/no-unresolved import { APPSTORE } from '@env'; const VIPKey = 'APMVIP'; -export const purchaseVIP = () => { +export const checkGuardVIP = async () => { + if (await getHasGuard([529249, 7706705])) { + return purchaseVIP(); + } +}; + +export const checkVIP = async () => { + const customer = await Purchases.getCustomerInfo(); + if ( + customer.entitlements.active.vip || + (await getHasGuard([529249, 7706705])) + ) { + return purchaseVIP(); + } + return loseVIP(); +}; + +const purchaseVIP = () => { SecureStore.setItemAsync(VIPKey, '1'); + useVIP.setState({ VIP: true }); }; -export const loseVIP = () => { +const loseVIP = () => { SecureStore.deleteItemAsync(VIPKey); + useVIP.setState({ VIP: false }); }; -const useVIP = () => { - const [vip, setVip] = useState(SecureStore.getItem(VIPKey) !== null); +interface VIPStore { + VIP: boolean; +} +const useVIP = create((set, get) => ({ + VIP: SecureStore.getItem(VIPKey) !== null, +})); - return { vip }; -}; +export default useVIP; export const useSetupVIP = () => { - const { vip } = useVIP(); + const vip = useVIP(state => state.VIP); const init = async () => { if (!APPSTORE) { @@ -32,11 +56,7 @@ export const useSetupVIP = () => { if (isAndroid) { Purchases.configure({ apiKey: 'goog_XXAuAgmqFMypeJIGHTlyRZNdoGh' }); } - try { - console.log('purhcase', await Purchases.getCustomerInfo()); - } catch (e) { - console.error(e); - } + checkVIP(); }; useEffect(() => { @@ -44,5 +64,3 @@ export const useSetupVIP = () => { }, []); return { vip }; }; - -export default useVIP; diff --git a/src/localization/en/translation.json b/src/localization/en/translation.json index be02d9df5..d9febe5cd 100644 --- a/src/localization/en/translation.json +++ b/src/localization/en/translation.json @@ -1,10 +1,20 @@ { "_comment": "src/localization/en/translation.json", + "Billing": { + "PremiumFeaturesIntro": "Thank you for considering supporting APM with real money. All funds will go towards buying a copy of Buldur's Gate 3. In return, APM will hide the app start splash ad.", + "NoxAuth": "Authenticate through Bilibili", + "RevenueCat": "Purchase via RevenueCat", + "NoxFans": "Bilibili users that are currently \"guards\" to Azusa and Nox will be granted premium access for free. Please click the Bilibili Auth button above to authenticate.", + "thankU": "Thank you!", + "godBlessU": "God bless you!", + "urVeryVeryGorgeous": "You are very very gorgeous." + }, "appDrawer": { "homeScreenName": "Home", "exploreScreenName": "Discover", "settingScreenName": "Settings", - "LoginName": "User Login" + "LoginName": "User Login", + "PremiumName": "Premium Content" }, "Dialog": { "ok": "Done", @@ -200,6 +210,8 @@ "SplashSettingDesc": "View APM's splash ads", "DeveloperOptionsName": "Developer Options", "DeveloperOptionsDesc": "Experimental Options in pre-release versions of APM", + "PremiumSettingName": "Premium APM", + "PremiumSettingDesc": "Buy Premium features", "AListOptionsName": "AList", "AListOptionsDesc": "Set up AList creds", "DownloadOptionsName": "Download", diff --git a/src/localization/zhcn/translation.json b/src/localization/zhcn/translation.json index 3f04aceae..d4d172db7 100644 --- a/src/localization/zhcn/translation.json +++ b/src/localization/zhcn/translation.json @@ -1,5 +1,14 @@ { "_comment": "src/localization/en/translation.json", + "Billing": { + "PremiumFeaturesIntro": "感谢你对中国管人事业的支持。您赞助的每一分钱将用于购买《博德之门3》。在返回时,APM将隐藏启动广告。", + "NoxAuth": "b站认证", + "RevenueCat": "Purchase via RevenueCat", + "NoxFans": "暗精灵和小孩梓当月舰长尊享APM VIP服务。点击上方b站认证即可。", + "thankU": "又要到饭了兄弟们", + "godBlessU": "又要到饭了兄弟们", + "urVeryVeryGorgeous": "又要到饭了兄弟们" + }, "BiliCategory": { "top": "b站全站音乐榜", "ranking": "b站音乐区排行榜", @@ -16,7 +25,8 @@ "homeScreenName": "音乐", "exploreScreenName": "发现", "settingScreenName": "设置", - "LoginName": "b站登录" + "LoginName": "b站登录", + "PremiumName": "高级播放器" }, "Dialog": { "ok": "好的", @@ -214,6 +224,8 @@ "SplashSettingDesc": "观赏管人播放器的开屏广告", "DeveloperOptionsName": "开发者选项", "DeveloperOptionsDesc": "正在测试的功能", + "PremiumSettingName": "高级播放器", + "PremiumSettingDesc": "购买高级播放器", "AListOptionsName": "AList", "AListOptionsDesc": "AList密钥设置", "DownloadOptionsName": "下载", diff --git a/src/utils/Bilibili/BiliUser.ts b/src/utils/Bilibili/BiliUser.ts index 4133cf09b..c05484005 100644 --- a/src/utils/Bilibili/BiliUser.ts +++ b/src/utils/Bilibili/BiliUser.ts @@ -30,10 +30,17 @@ const getUserGuard = async () => { // simple function that filters is user has guard > 0. export const getHasGuard = async (hasGuard: number[] = []) => { - const guards = await getUserGuard(); - return guards.filter( - (guard: any) => guard.guard_level > 0 && hasGuard.includes(guard.target_id), - ); + try { + const guards = await getUserGuard(); + return ( + guards.filter( + (guard: any) => + guard.guard_level > 0 && hasGuard.includes(guard.target_id), + ).length > 0 + ); + } catch { + return false; + } }; export default getUser; From 1a4956e36e27a8c119f5347ee828e41a8e780126 Mon Sep 17 00:00:00 2001 From: lovegaoshi <106490582+lovegaoshi@users.noreply.github.com> Date: Tue, 12 Nov 2024 12:55:33 -0800 Subject: [PATCH 05/14] Update translation.json --- src/localization/zhcn/translation.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/localization/zhcn/translation.json b/src/localization/zhcn/translation.json index d4d172db7..3c1d0f4f9 100644 --- a/src/localization/zhcn/translation.json +++ b/src/localization/zhcn/translation.json @@ -5,9 +5,9 @@ "NoxAuth": "b站认证", "RevenueCat": "Purchase via RevenueCat", "NoxFans": "暗精灵和小孩梓当月舰长尊享APM VIP服务。点击上方b站认证即可。", - "thankU": "又要到饭了兄弟们", - "godBlessU": "又要到饭了兄弟们", - "urVeryVeryGorgeous": "又要到饭了兄弟们" + "thankU": "又要到饭了兄弟们!", + "godBlessU": "太破费了太破费了,好久没有收到这么贵重的礼物了", + "urVeryVeryGorgeous": "最后祝您身体健康万事如意,股票upup" }, "BiliCategory": { "top": "b站全站音乐榜", From dbb064e8882c3f52af7db8812ce2b16c825e880b Mon Sep 17 00:00:00 2001 From: lovegaoshi <106490582+lovegaoshi@users.noreply.github.com> Date: Tue, 12 Nov 2024 13:38:53 -0800 Subject: [PATCH 06/14] feat: billing --- src/components/billing/View.tsx | 26 +++++++++++++++ src/components/setting/AboutSettings.tsx | 42 ++++++++---------------- 2 files changed, 39 insertions(+), 29 deletions(-) diff --git a/src/components/billing/View.tsx b/src/components/billing/View.tsx index 388fe1f6a..934102642 100644 --- a/src/components/billing/View.tsx +++ b/src/components/billing/View.tsx @@ -2,6 +2,7 @@ import { View } from 'react-native'; import React, { useState } from 'react'; import { Text, Button, ActivityIndicator } from 'react-native-paper'; import { useTranslation } from 'react-i18next'; +import { Image } from 'expo-image'; import Purchases from 'react-native-purchases'; import useVIP, { checkGuardVIP } from '@hooks/useVIP'; @@ -56,6 +57,12 @@ const PurchaseVIPScreen = () => { const { t } = useTranslation(); return ( + {t('Billing.PremiumFeaturesIntro')} @@ -71,6 +78,12 @@ const VIPScreen = () => { return ( + {t('Billing.thankU')} {t('Billing.godBlessU')} {t('Billing.urVeryVeryGorgeous')} @@ -89,4 +102,17 @@ export default () => { const mStyle = StyleSheet.create({ container: { flex: 1, paddingHorizontal: 10, paddingTop: 10 }, + text: { + fontSize: 20, + }, + azusaBeg: { + width: '100%', + height: '40%', + alignSelf: 'center', + }, + azusaMock: { + width: '100%', + height: '30%', + alignSelf: 'center', + }, }); diff --git a/src/components/setting/AboutSettings.tsx b/src/components/setting/AboutSettings.tsx index 210f45efe..1b9b0a8dd 100644 --- a/src/components/setting/AboutSettings.tsx +++ b/src/components/setting/AboutSettings.tsx @@ -1,4 +1,4 @@ -import { View, ScrollView, Linking } from 'react-native'; +import { View, ScrollView, Linking, StyleSheet } from 'react-native'; import { Text, Button } from 'react-native-paper'; import { useTranslation } from 'react-i18next'; @@ -17,36 +17,12 @@ export default () => { > {''} - - {t('About.Disclaimer1')} - + {t('About.Disclaimer1')} {''} - - {t('About.Disclaimer2')} - + {t('About.Disclaimer2')} {''} - - {t('About.About1')} - - + {t('About.About1')} +