Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,9 @@ dependencies {
} else {
implementation jscFlavor
}
implementation (project(':react-native-device-info')) {
exclude group: 'com.google.android.gms'
}
}

apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)
Expand Down
5 changes: 4 additions & 1 deletion android/app/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,7 @@
}
-keep enum org.greenrobot.eventbus.ThreadMode { *; }
-keep class com.facebook.hermes.unicode.** { *; }
-keep class com.facebook.jni.** { *; }
-keep class com.facebook.jni.** { *; }
-keep class com.google.android.gms.common.** {*;}

-dontwarn com.google.errorprone.annotations.Immutable
4 changes: 0 additions & 4 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,5 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

<meta-data
android:name="com.google.mlkit.vision.DEPENDENCIES"
android:value="barcode" />
</application>
</manifest>
1 change: 1 addition & 0 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ buildscript {
google()
mavenCentral()
}

dependencies {
classpath("com.android.tools.build:gradle")
classpath("com.facebook.react:react-native-gradle-plugin")
Expand Down
1 change: 1 addition & 0 deletions android/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,5 @@ newArchEnabled=false
# If set to false, you will be using JSC instead.
hermesEnabled=true

VisionCamera_enableCodeScanner=true
VisionCamera_disableFrameProcessors=true
4,396 changes: 2,401 additions & 1,995 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
"react-i18next": "14.0.0",
"react-native": "0.73.3",
"react-native-animated-linear-gradient": "1.3.0",
"react-native-barcode-zxing-scan": "1.0.2",
"react-native-bars": "2.3.0",
"react-native-biometrics": "3.0.1",
"react-native-blur-effect": "1.1.3",
Expand All @@ -88,7 +89,7 @@
"react-native-svg": "14.1.0",
"react-native-toast-notifications": "3.4.0",
"react-native-use-keyboard": "1.0.0",
"react-native-vision-camera": "3.6.16",
"react-native-vision-camera": "4.0.1",
"react-native-web": "0.19.9",
"react-native-web-linear-gradient": "1.1.2",
"react-native-webview": "13.6.4",
Expand All @@ -99,6 +100,7 @@
"react-use-websocket": "4.5.0",
"stream-browserify": "3.0.0",
"styled-components": "6.0.9",
"vm-browserify": "1.1.2",
"xpub-converter": "1.0.2"
},
"browserslist": {
Expand Down
40 changes: 40 additions & 0 deletions patches/react-native-barcode-zxing-scan+1.0.2.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
diff --git a/node_modules/react-native-barcode-zxing-scan/android/src/main/java/com/reactlibrary/BarcodeZxingScanModule.java b/node_modules/react-native-barcode-zxing-scan/android/src/main/java/com/reactlibrary/BarcodeZxingScanModule.java
index 5e570e7..e83690f 100644
--- a/node_modules/react-native-barcode-zxing-scan/android/src/main/java/com/reactlibrary/BarcodeZxingScanModule.java
+++ b/node_modules/react-native-barcode-zxing-scan/android/src/main/java/com/reactlibrary/BarcodeZxingScanModule.java
@@ -12,10 +12,12 @@ import com.facebook.react.bridge.ReactContextBaseJavaModule;
import com.facebook.react.bridge.ReactMethod;
import com.facebook.react.bridge.Callback;
import com.google.zxing.integration.android.IntentIntegrator;
+import com.google.zxing.integration.android.IntentResult;

public class BarcodeZxingScanModule extends ReactContextBaseJavaModule implements ActivityEventListener {

private final ReactApplicationContext reactContext;
+ private Callback mcallback;

public BarcodeZxingScanModule(ReactApplicationContext reactContext) {
super(reactContext);
@@ -41,9 +43,10 @@ public class BarcodeZxingScanModule extends ReactContextBaseJavaModule implement

@ReactMethod
public void showQrReader(Callback callback) {
- Callback mCallback = callback;
+ mcallback = callback;
IntentIntegrator integrator = new IntentIntegrator(getCurrentActivity());
integrator.setOrientationLocked(true);
+ integrator.setBeepEnabled(false);
integrator.setCaptureActivity(ContinuousCaptureActivity.class);
integrator.initiateScan();
reactContext.addActivityEventListener(this);
@@ -52,7 +55,9 @@ public class BarcodeZxingScanModule extends ReactContextBaseJavaModule implement

@Override
public void onActivityResult(Activity activity, int requestCode, int resultCode, Intent data) {
-
+ IntentResult result = IntentIntegrator.parseActivityResult(requestCode,resultCode, data);
+ mcallback.invoke(result.getContents(),result.getBarcodeImagePath());
+ reactContext.removeActivityEventListener(this);
}

@Override
2 changes: 2 additions & 0 deletions scripts/build-android.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ cd ..

source .env

npm remove react-native-vision-camera

npx react-native bundle --minify --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res/merged/release/

cd android
Expand Down
11 changes: 11 additions & 0 deletions src/components/QRCamera/QRCamera.android.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { useEffect } from "react";
import { QRScannerProps } from "./QRCamera";
// @ts-ignore
import BarcodeZxingScan from "react-native-barcode-zxing-scan";

export const QRCamera = ({ onScan }: QRScannerProps) => {
useEffect(() => {
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
BarcodeZxingScan.showQrReader(onScan);
}, []);
};
105 changes: 0 additions & 105 deletions src/components/QrScanModal/QrScanModal.tsx

This file was deleted.

1 change: 0 additions & 1 deletion src/components/QrScanModal/index.ts

This file was deleted.

72 changes: 72 additions & 0 deletions src/components/QrScanWindow/QrScanWindow.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
import { useCallback, useState } from "react";
import { CamerasConfig } from "@components/QRCamera/types";
import { faTimes } from "@fortawesome/free-solid-svg-icons";
import * as S from "./styled";

type QrScanWindowProps = {
isOpen: boolean;
onScan: (value: string) => void;
onClose: () => void;
};

export const QrScanWindow = ({
onScan,
onClose,
isOpen
}: QrScanWindowProps) => {
const [config, setConfig] = useState<CamerasConfig>();
const [isCameraActive, setIsCameraActive] = useState(true);
const [deviceIndex, setDeviceIndex] = useState<number>();

const _setConfig = useCallback(
(newConfig: Partial<CamerasConfig>) => {
if (deviceIndex === undefined) {
setDeviceIndex(newConfig?.defaultIndex || 0);
}
setIsCameraActive(true);
setConfig({
...(config || {
hasTorch: false,
devicesNumber: 0,
defaultIndex: -1
}),
...newConfig
});
},
[config, deviceIndex]
);

const _onClose = useCallback(() => {
setIsCameraActive(false);
setTimeout(() => {
onClose();
}, 0);
}, [onClose]);

const _onScan = useCallback(
(value: string) => {
onScan(value);
setIsCameraActive(false);
onClose();
},
[onClose, onScan]
);

return (
isOpen && (
<S.WindowContainer>
<S.Camera
isActive={isCameraActive}
deviceIndex={deviceIndex}
isTorchOn
style={{}}
setConfig={_setConfig}
onScan={_onScan}
videoHeight={300}
resizeMode="contain"
/>
<S.CloseButton icon={faTimes} onPress={_onClose} />
</S.WindowContainer>
)
);
};
1 change: 1 addition & 0 deletions src/components/QrScanWindow/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { QrScanWindow } from "./QrScanWindow";
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
import styled from "styled-components";
import { QRCamera, View, Button, Text, ComponentStack } from "@components";
import { Platform } from "react-native";

export const ContainerContent = styled(View)`
height: 100%;
width: 100%;
flex-direction: column;
align-items: center;
justify-content: flex-end;
const WINDOW_SIZE = 300;
const BORDER_SIZE = 4;

export const WindowContainer = styled(View)`
height: ${WINDOW_SIZE}px;
width: ${WINDOW_SIZE}px;
position: absolute;
overflow: hidden;

bottom: 110%;
border-radius: 20px;
right: 16px;
border: ${BORDER_SIZE}px solid white;
${Platform.OS === "android" ? "opacity: 0;" : ""}
`;

export const VerticialPart = styled(View)<{ isItemsBottom?: boolean }>`
Expand All @@ -30,19 +39,15 @@ export const BottomButtons = styled(ComponentStack)`

export const Camera = styled(QRCamera)`
position: relative;
height: ${WINDOW_SIZE}px;
width: ${WINDOW_SIZE - BORDER_SIZE * 2}px;
overflow: hidden;
border-radius: 20px;
`;

export const BottomButton = styled(Button)<{ position?: "left" | "right" }>`
${({ position }) => {
if (!position) return "";

const distance = 74 + 18;
const CLOSE_BUTTON_PADDING = 12;

return `
position: absolute;
${position === "left" ? "right" : "left"}: ${distance}px;
`;
}}
export const CloseButton = styled(Button)`
position: absolute;
top: ${CLOSE_BUTTON_PADDING}px;
right: ${CLOSE_BUTTON_PADDING}px;
`;
5 changes: 2 additions & 3 deletions src/components/TextField/TextField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
useState
} from "react";
import { TextInput } from "react-native";
import { BaseField, QrScanModal, QrModal, Text } from "@components";
import { BaseField, QrScanWindow, QrModal, Text } from "@components";
import { BaseFieldProps } from "@components/BaseField";
import { StyledComponentComponentProps } from "@types";
import { Clipboard, tupulize } from "@utils";
Expand Down Expand Up @@ -144,8 +144,7 @@ export const TextField = forwardRef<TextInput, TextFieldProps>(
return (
<S.TextFieldContainer style={style}>
{isCameraAvailable && qrScannable && (
<QrScanModal
title={label}
<QrScanWindow
isOpen={isScanModalOpen}
onClose={onToggleScanQrModal}
onScan={onScanQr}
Expand Down
2 changes: 1 addition & 1 deletion src/components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export { Modal } from "./Modal";
export { QRCamera } from "./QRCamera";
export { QR } from "./QR";
export { QrModal } from "./QrModal";
export { QrScanModal } from "./QrScanModal";
export { QrScanWindow } from "./QrScanWindow";
export { BaseField } from "./BaseField";
export { TextInput } from "./TextInput";
export { TextField } from "./TextField";
Expand Down
Loading