-
-
Notifications
You must be signed in to change notification settings - Fork 8
rev: Swift/Kotlin code analogy, new features, bug fixes. #9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
@gev2002 Hey thanks for this well written package. Can you review the changes here? |
…vised shared utility.
…rrect ios for now.
…tion is good, other orientations to be tested.
…pescript structure and type fixes.
feat: Both platform structure arrangements, orientation support.
feat: New supports, orientation, limitations, layout, architectural improvements.
|
Hi @HyopeR, thanks for pull request, I will review as soon as possible and if everything works fine, I'll merge it. |
|
Hey hello. This pull request includes some new feature support and code fixes. I'm still working on the module. I'll post details and usage examples when I'm done. At first I just added a few fixes. But then I needed more and had to do some development. So now it actually includes more than the title of this pull request. |
feat: ViewSize support added, pixel perfect ui support.
About New Features@gev2002 Hello, here is a copy of types with new features and their descriptions. TypesBarcodeType = 'aztec' | 'code_128' | 'code_39' | 'code_93' | 'codabar' | 'ean_13' | 'ean_8' | 'pdf_417' | 'qr' | 'upc_e' | 'upc_a' | 'itf' | 'data_matrix' | 'all' Orientation: 'portrait' | 'landscape-left' | 'portrait-upside-down' | 'landscape-right' formatsRequired: false const formats = ['code_128', 'qr']
// Now only QR and Code 128 can be scanned.
const {scanBarcodes} = useBarcodeScanner({formats});
<View style={{flex: 1}}>
<Camera style={StyleSheet.absoluteFill} />
</View>ratioRequired: false const ratio = {width: 0.8, height: 0.5}
const viewSize = {width: 300, height: 600};
// Now the area with 80% width and 50% height in the central area of the image will be scanned.
// The ratio and viewSize values together give PixelPerfect results.
const {scanBarcodes} = useBarcodeScanner({ratio, viewSize});
<View style={{width: viewSize.width, height: viewSize.height}}>
<Camera style={StyleSheet.absoluteFill} />
</View>orientationRequired: false const [orientation, setOrientation] = useState<any>('portrait');
// Now the coordinates will work in all orientations.
const {scanBarcodes} = useBarcodeScanner({orientation});
<View style={{flex: 1}}>
<Camera
style={StyleSheet.absoluteFill}
onPreviewOrientationChanged={previewOrientation => {
setOrientation(previewOrientation);
}}
/>
</View>viewSizeRequired: false The camera image detected by MLKit and the user's View screen image are in different sizes. It is recommended to provide this value so that the user can see a "Pixel Perferct" result on the UI side. viewSize should directly reflect the dimensions in which the user uses the camera component. Using these values, MLKit's coordinate calculations are resized. const viewSize = {width: 300, height: 600};
// Now the coordinates will be more accurate.
const {scanBarcodes} = useBarcodeScanner({viewSize});
<View style={{width: viewSize.width, height: viewSize.height}}>
<Camera style={StyleSheet.absoluteFill} />
</View>Sample AppYou can use the sample application here to test the new features. Sample VideosIn this example, all features are used. As can be seen, when QR goes outside the area specified with Ratio, the scanning process returns empty. In addition, coordinate tracking is successfully performed in various orientations.
|
fix: Scanner instance singleton create
|
If there's anything I can help with here let me know. |
These changes include a few fixes and a few crash measures.
Android:
Android & Ios:
Prevent crashes in inappropriate inputs.
Similarity in Swift and Kotlin codes.
Added getSafeBarcodeOptions() function to get the barcodeOptions parameter received from the user as a safe list in Swift and Kotlin codes.
Reorganized the installation of init() functions in Swift and Kotlin codes to be similar to each other.