mirror of
https://gitcode.com/gh_mirrors/re/react-native-pushy.git
synced 2025-09-16 13:01:38 +08:00
Compare commits
5 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
90fee03c45 | ||
![]() |
7243512d3c | ||
![]() |
11b383d10b | ||
![]() |
af65b2660c | ||
![]() |
28b8e122af |
@@ -2,6 +2,8 @@
|
||||
package="com.awesomeproject">
|
||||
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.CAMERA" />
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
|
||||
|
||||
<application
|
||||
android:name=".MainApplication"
|
||||
|
@@ -5,10 +5,11 @@ import org.apache.tools.ant.taskdefs.condition.Os
|
||||
buildscript {
|
||||
ext {
|
||||
buildToolsVersion = "31.0.0"
|
||||
minSdkVersion = 21
|
||||
minSdkVersion = 23
|
||||
compileSdkVersion = 31
|
||||
targetSdkVersion = 31
|
||||
kotlinVersion = '1.6.10'
|
||||
kotlinVersion = '1.7.20'
|
||||
kotlin_version = '1.7.20'
|
||||
|
||||
if (System.properties['os.arch'] == "aarch64") {
|
||||
// For M1 Users we need to use the NDK 24 which added support for aarch64
|
||||
|
@@ -53,5 +53,10 @@
|
||||
</array>
|
||||
<key>UIViewControllerBasedStatusBarAppearance</key>
|
||||
<false/>
|
||||
<key>NSCameraUsageDescription</key>
|
||||
<string>For taking photos</string>
|
||||
|
||||
<key>NSPhotoLibraryUsageDescription</key>
|
||||
<string>For saving photos</string>
|
||||
</dict>
|
||||
</plist>
|
||||
|
@@ -222,17 +222,17 @@ PODS:
|
||||
- glog
|
||||
- react-native-safe-area-context (4.8.2):
|
||||
- React-Core
|
||||
- react-native-update (10.7.1):
|
||||
- react-native-update (10.10.0):
|
||||
- React
|
||||
- React-Core
|
||||
- react-native-update/HDiffPatch (= 10.7.1)
|
||||
- react-native-update/RCTPushy (= 10.7.1)
|
||||
- react-native-update/HDiffPatch (= 10.10.0)
|
||||
- react-native-update/RCTPushy (= 10.10.0)
|
||||
- SSZipArchive
|
||||
- react-native-update/HDiffPatch (10.7.1):
|
||||
- react-native-update/HDiffPatch (10.10.0):
|
||||
- React
|
||||
- React-Core
|
||||
- SSZipArchive
|
||||
- react-native-update/RCTPushy (10.7.1):
|
||||
- react-native-update/RCTPushy (10.10.0):
|
||||
- React
|
||||
- React-Core
|
||||
- SSZipArchive
|
||||
@@ -302,6 +302,8 @@ PODS:
|
||||
- React-jsi (= 0.69.8)
|
||||
- React-logger (= 0.69.8)
|
||||
- React-perflogger (= 0.69.8)
|
||||
- ReactNativeCameraKit (14.0.0-beta9):
|
||||
- React-Core
|
||||
- RNVectorIcons (10.0.3):
|
||||
- React-Core
|
||||
- SSZipArchive (2.4.3)
|
||||
@@ -342,6 +344,7 @@ DEPENDENCIES:
|
||||
- React-RCTVibration (from `../node_modules/react-native/Libraries/Vibration`)
|
||||
- React-runtimeexecutor (from `../node_modules/react-native/ReactCommon/runtimeexecutor`)
|
||||
- ReactCommon/turbomodule/core (from `../node_modules/react-native/ReactCommon`)
|
||||
- ReactNativeCameraKit (from `../node_modules/react-native-camera-kit`)
|
||||
- RNVectorIcons (from `../node_modules/react-native-vector-icons`)
|
||||
- Yoga (from `../node_modules/react-native/ReactCommon/yoga`)
|
||||
|
||||
@@ -417,6 +420,8 @@ EXTERNAL SOURCES:
|
||||
:path: "../node_modules/react-native/ReactCommon/runtimeexecutor"
|
||||
ReactCommon:
|
||||
:path: "../node_modules/react-native/ReactCommon"
|
||||
ReactNativeCameraKit:
|
||||
:path: "../node_modules/react-native-camera-kit"
|
||||
RNVectorIcons:
|
||||
:path: "../node_modules/react-native-vector-icons"
|
||||
Yoga:
|
||||
@@ -444,7 +449,7 @@ SPEC CHECKSUMS:
|
||||
React-jsinspector: 0eda09e9cf22bbb5dbb1d23143b03a31acf37d67
|
||||
React-logger: 5997ab008583826c10ffe4e1ff990363e975639d
|
||||
react-native-safe-area-context: 0ee144a6170530ccc37a0fd9388e28d06f516a89
|
||||
react-native-update: 04844fca9567508fa79649e23e7209904d9d7a5a
|
||||
react-native-update: a7f136a3c87183b13c7ff5c4f9d2b614930968ad
|
||||
React-perflogger: ad1416a715d86b32f456e5d0aed99c3b52f1de37
|
||||
React-RCTActionSheet: cbf7c6a953982562418ee72a1084ff7b9447b558
|
||||
React-RCTAnimation: 33df3e25824dd7313edec28dded2745542f9352b
|
||||
@@ -457,6 +462,7 @@ SPEC CHECKSUMS:
|
||||
React-RCTVibration: 5462287ee85304ba1a00474665ab292e63a41663
|
||||
React-runtimeexecutor: 9df680f18497367bcf5c15b6b6406c0f2dfa2b6a
|
||||
ReactCommon: c10f046f3ef8561e7c8e7e9b9dae2ecc9ffc48ef
|
||||
ReactNativeCameraKit: 4bec78d688adcd68772af2834d5c30a6a8e2a384
|
||||
RNVectorIcons: bc7ee28cadf39c77a49232a14738dfce690f66cd
|
||||
SSZipArchive: fe6a26b2a54d5a0890f2567b5cc6de5caa600aef
|
||||
Yoga: d3820731e0ca3a4933f061ad29defaf7726e3251
|
||||
|
@@ -9,16 +9,18 @@
|
||||
"test": "jest",
|
||||
"test:e2e": "detox test --configuration android.emu.debug",
|
||||
"lint": "eslint .",
|
||||
"postinstall": "patch-package"
|
||||
"postinstall": "patch-package",
|
||||
"apk": "cd android && ./gradlew assembleRelease"
|
||||
},
|
||||
"dependencies": {
|
||||
"patch-package": "^6.5.1",
|
||||
"postinstall-postinstall": "^2.1.0",
|
||||
"react": "18.0.0",
|
||||
"react-native": "0.69.8",
|
||||
"react-native-camera-kit": "^14.0.0-beta15",
|
||||
"react-native-paper": "^5.12.1",
|
||||
"react-native-safe-area-context": "^4.8.2",
|
||||
"react-native-update": "^10.7.1",
|
||||
"react-native-update": "^10.10.0",
|
||||
"react-native-vector-icons": "^10.0.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
@@ -10,7 +10,16 @@ import {
|
||||
Image,
|
||||
Switch,
|
||||
} from 'react-native';
|
||||
import {Icon, PaperProvider, Snackbar, Banner} from 'react-native-paper';
|
||||
import {
|
||||
Icon,
|
||||
PaperProvider,
|
||||
Snackbar,
|
||||
Banner,
|
||||
Button,
|
||||
Modal,
|
||||
Portal,
|
||||
} from 'react-native-paper';
|
||||
import {Camera} from 'react-native-camera-kit';
|
||||
|
||||
import TestConsole from './TestConsole';
|
||||
|
||||
@@ -28,6 +37,7 @@ function App() {
|
||||
updateInfo,
|
||||
packageVersion,
|
||||
currentHash,
|
||||
parseTestPayload,
|
||||
progress: {received, total} = {},
|
||||
} = usePushy();
|
||||
const [useDefaultAlert, setUseDefaultAlert] = useState(true);
|
||||
@@ -36,6 +46,7 @@ function App() {
|
||||
const [showUpdateSnackbar, setShowUpdateSnackbar] = useState(false);
|
||||
const snackbarVisible =
|
||||
!useDefaultAlert && showUpdateSnackbar && updateInfo?.update;
|
||||
const [showCamera, setShowCamera] = useState(false);
|
||||
|
||||
return (
|
||||
<View style={styles.container}>
|
||||
@@ -55,6 +66,23 @@ function App() {
|
||||
}}
|
||||
/>
|
||||
</View>
|
||||
<Button onPress={() => setShowCamera(true)}>打开相机</Button>
|
||||
<Portal>
|
||||
<Modal visible={showCamera} onDismiss={() => setShowCamera(false)}>
|
||||
<Camera
|
||||
style={{minHeight: 320}}
|
||||
scanBarcode={true}
|
||||
onReadCode={({nativeEvent: {codeStringValue}}) => {
|
||||
console.log(codeStringValue);
|
||||
parseTestPayload(codeStringValue);
|
||||
setShowCamera(false);
|
||||
}} // optional
|
||||
showFrame={true} // (default false) optional, show frame with transparent layer (qr code or barcode will be read on this area ONLY), start animation for scanner, that stops when a code has been found. Frame always at center of the screen
|
||||
laserColor="red" // (default red) optional, color of laser in scanner frame
|
||||
frameColor="white" // (default white) optional, color of border of scanner frame
|
||||
/>
|
||||
</Modal>
|
||||
</Portal>
|
||||
<Image
|
||||
resizeMode={'contain'}
|
||||
source={require('./assets/shezhi.png')}
|
||||
|
@@ -6202,6 +6202,11 @@ react-is@^17.0.1:
|
||||
resolved "https://registry.yarnpkg.com/react-is/-/react-is-17.0.2.tgz#e691d4a8e9c789365655539ab372762b0efb54f0"
|
||||
integrity sha512-w2GsyukL62IJnlaff/nRegPQR94C/XXamvMWmSHRJ4y7Ts/4ocGRmTHvOs8PSE6pB3dWOrD/nueuU5sduBsQ4w==
|
||||
|
||||
react-native-camera-kit@^14.0.0-beta15:
|
||||
version "14.0.0-beta9"
|
||||
resolved "https://registry.yarnpkg.com/react-native-camera-kit/-/react-native-camera-kit-14.0.0-beta9.tgz#fa00aceeedd4fbc7ab82d94cb7e64de471165554"
|
||||
integrity sha512-OPRyJMmJibfVxrMvpbDgprhsrKlKWGvtLgkV+tY97HnEmTuW4in7qx/RC5wMKMZDwgBxgLtFhO7rYAMylIpH2A==
|
||||
|
||||
react-native-codegen@^0.69.2:
|
||||
version "0.69.2"
|
||||
resolved "https://registry.yarnpkg.com/react-native-codegen/-/react-native-codegen-0.69.2.tgz#e33ac3b1486de59ddae687b731ddbfcef8af0e4e"
|
||||
@@ -6231,10 +6236,10 @@ react-native-safe-area-context@^4.8.2:
|
||||
resolved "https://registry.yarnpkg.com/react-native-safe-area-context/-/react-native-safe-area-context-4.8.2.tgz#e6b3d8acf3c6afcb4b5db03a97f9c37df7668f65"
|
||||
integrity sha512-ffUOv8BJQ6RqO3nLml5gxJ6ab3EestPiyWekxdzO/1MQ7NF8fW1Mzh1C5QE9yq573Xefnc7FuzGXjtesZGv7cQ==
|
||||
|
||||
react-native-update@^10.7.1:
|
||||
version "10.7.1"
|
||||
resolved "https://registry.yarnpkg.com/react-native-update/-/react-native-update-10.7.1.tgz#f89075b69b4a397ce6d3457837018fb6cfabe0ab"
|
||||
integrity sha512-Lru/8qunNjggvjzfe6uzWi4HWsFmNjtwdLXC3lD+1hWQpJ8ln5bwQlYoXyz0n8GwNJiS8Z/w8oPXVxs323ls3g==
|
||||
react-native-update@^10.10.0:
|
||||
version "10.10.0"
|
||||
resolved "https://registry.yarnpkg.com/react-native-update/-/react-native-update-10.10.0.tgz#5861f0c217d1ed194e1a8aba81fed5430178795c"
|
||||
integrity sha512-qZd5kJ9UlNh5Y0zU5vLdIviYwLvTPqdgIynmt4DQ1wEUu2/F6RrI17dICq54em5ValQWB6ua/tdj2lyTVPvADg==
|
||||
dependencies:
|
||||
nanoid "^3.3.3"
|
||||
|
||||
|
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "react-native-update",
|
||||
"version": "10.9.0",
|
||||
"version": "10.10.2",
|
||||
"description": "react-native hot update",
|
||||
"main": "src/index",
|
||||
"scripts": {
|
||||
|
@@ -14,6 +14,7 @@ export const defaultContext = {
|
||||
downloadUpdate: asyncNoop,
|
||||
downloadAndInstallApk: asyncNoop,
|
||||
getCurrentVersionInfo: () => Promise.resolve({}),
|
||||
parseTestPayload: () => Promise.resolve(false),
|
||||
currentHash: '',
|
||||
packageVersion: '',
|
||||
};
|
||||
@@ -31,6 +32,7 @@ export const PushyContext = createContext<{
|
||||
description?: string;
|
||||
metaInfo?: string;
|
||||
}>;
|
||||
parseTestPayload: (code: string) => Promise<boolean>;
|
||||
currentHash: string;
|
||||
packageVersion: string;
|
||||
client?: Pushy;
|
||||
|
@@ -19,7 +19,7 @@ import {
|
||||
packageVersion,
|
||||
getCurrentVersionInfo,
|
||||
} from './core';
|
||||
import { CheckResult, ProgressData } from './type';
|
||||
import { CheckResult, ProgressData, PushyTestPayload } from './type';
|
||||
import { PushyContext } from './context';
|
||||
|
||||
export const PushyProvider = ({
|
||||
@@ -262,6 +262,38 @@ export const PushyProvider = ({
|
||||
};
|
||||
}, [checkUpdate, options, dismissError, markSuccess]);
|
||||
|
||||
const parseTestPayload = useCallback(
|
||||
async (code: string) => {
|
||||
let payload: PushyTestPayload;
|
||||
try {
|
||||
payload = JSON.parse(code);
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
if (payload && payload.type && payload.type.startsWith('__rnPushy')) {
|
||||
const logger = options.logger || (() => {});
|
||||
options.logger = ({ type, data }) => {
|
||||
logger({ type, data });
|
||||
Alert.alert(type, JSON.stringify(data));
|
||||
};
|
||||
if (payload.type === '__rnPushyVersionHash') {
|
||||
checkUpdate({ toHash: payload.data }).then(() => {
|
||||
if (updateInfoRef.current && updateInfoRef.current.upToDate) {
|
||||
Alert.alert(
|
||||
'提示',
|
||||
'当前尚未检测到更新版本,如果是首次扫码,请等待服务器端生成补丁包后再试(约10秒)',
|
||||
);
|
||||
}
|
||||
options.logger = logger;
|
||||
});
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
},
|
||||
[checkUpdate, options],
|
||||
);
|
||||
|
||||
return (
|
||||
<PushyContext.Provider
|
||||
value={{
|
||||
@@ -279,6 +311,7 @@ export const PushyProvider = ({
|
||||
progress,
|
||||
downloadAndInstallApk,
|
||||
getCurrentVersionInfo,
|
||||
parseTestPayload,
|
||||
}}>
|
||||
{children}
|
||||
</PushyContext.Provider>
|
||||
|
@@ -81,3 +81,8 @@ export interface PushyOptions {
|
||||
debug?: boolean;
|
||||
throwError?: boolean;
|
||||
}
|
||||
|
||||
export interface PushyTestPayload {
|
||||
type: '__rnPushyVersionHash';
|
||||
data: any;
|
||||
}
|
||||
|
Reference in New Issue
Block a user