@momo-kits/qrcode 0.150.2-beta.11 → 0.150.2-beta.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/Qrcode.podspec +43 -0
- package/README.md +4 -8
- package/android/build.gradle +10 -3
- package/android/gradle.properties +8 -5
- package/android/src/main/java/com/momokits/qrcode/MomoBarCodeViewManager.kt +111 -0
- package/android/src/main/java/com/momokits/qrcode/MomoQrCodeUtils.kt +23 -0
- package/android/src/main/java/com/momokits/qrcode/MomoQrCodeViewManager.kt +96 -0
- package/android/src/main/java/com/momokits/qrcode/{RCTQRCodePackage.kt → MomoQrCodeViewPackage.kt} +9 -10
- package/ios/BarCodeView.h +20 -0
- package/ios/BarCodeView.m +65 -0
- package/ios/QRCodeView.h +19 -0
- package/ios/QRCodeView.m +74 -0
- package/ios/RNBarCode.h +11 -0
- package/ios/RNBarCode.mm +63 -0
- package/ios/RNQRCode.h +10 -0
- package/ios/RNQRCode.mm +66 -0
- package/lib/module/BarCodeView.js +16 -0
- package/lib/module/BarCodeView.js.map +1 -0
- package/lib/module/QRCodeView.js +42 -0
- package/lib/module/QRCodeView.js.map +1 -0
- package/lib/module/RNBarCodeNativeComponent.ts +15 -0
- package/lib/module/RNQRCodeNativeComponent.ts +10 -0
- package/lib/module/index.js +5 -2
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/src/BarCodeView.d.ts +10 -0
- package/lib/typescript/src/BarCodeView.d.ts.map +1 -0
- package/lib/typescript/src/QRCodeView.d.ts +14 -0
- package/lib/typescript/src/QRCodeView.d.ts.map +1 -0
- package/lib/typescript/src/RNBarCodeNativeComponent.d.ts +15 -0
- package/lib/typescript/src/RNBarCodeNativeComponent.d.ts.map +1 -0
- package/lib/typescript/src/RNQRCodeNativeComponent.d.ts +10 -0
- package/lib/typescript/src/RNQRCodeNativeComponent.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +5 -2
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/package.json +160 -159
- package/src/BarCodeView.tsx +15 -0
- package/src/QRCodeView.tsx +63 -0
- package/src/RNBarCodeNativeComponent.ts +15 -0
- package/src/RNQRCodeNativeComponent.ts +10 -0
- package/src/index.tsx +6 -2
- package/RCTQRCode.podspec +0 -21
- package/android/src/main/java/com/momokits/qrcode/RCTQRCodeView.kt +0 -99
- package/android/src/main/java/com/momokits/qrcode/RCTQRCodeViewManager.kt +0 -52
- package/ios/RCTQRCodeComponentView.mm +0 -11
- package/ios/RCTQRCodeView.h +0 -19
- package/ios/RCTQRCodeView.mm +0 -142
- package/ios/RCTQRCodeViewManager.mm +0 -21
- package/lib/module/RCTQRCodeViewNativeComponent.ts +0 -10
- package/lib/typescript/src/RCTQRCodeViewNativeComponent.d.ts +0 -10
- package/lib/typescript/src/RCTQRCodeViewNativeComponent.d.ts.map +0 -1
- package/src/RCTQRCodeViewNativeComponent.ts +0 -10
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { Image, PixelRatio } from 'react-native';
|
|
2
|
+
import RNQRCode from './RNQRCodeNativeComponent';
|
|
3
|
+
import type { CodegenTypes } from 'react-native';
|
|
4
|
+
|
|
5
|
+
const ratio = PixelRatio.get();
|
|
6
|
+
const ic_logo =
|
|
7
|
+
'https://img.mservice.io/momo_app_v2/new_version/img/appx_image/ic_momo.png';
|
|
8
|
+
|
|
9
|
+
type QRCodeViewProps = {
|
|
10
|
+
code: string;
|
|
11
|
+
size: CodegenTypes.Int32;
|
|
12
|
+
ratio?: CodegenTypes.Float;
|
|
13
|
+
icon?: string;
|
|
14
|
+
showLogo?: boolean;
|
|
15
|
+
iconSize?: CodegenTypes.Int32;
|
|
16
|
+
iconStyle?: any;
|
|
17
|
+
style?: any;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
const QRCodeView = ({
|
|
21
|
+
code,
|
|
22
|
+
showLogo = false,
|
|
23
|
+
ratio: customRatio,
|
|
24
|
+
icon = ic_logo,
|
|
25
|
+
iconSize = 32,
|
|
26
|
+
size,
|
|
27
|
+
iconStyle,
|
|
28
|
+
style,
|
|
29
|
+
...rest
|
|
30
|
+
}: QRCodeViewProps) => {
|
|
31
|
+
return (
|
|
32
|
+
<>
|
|
33
|
+
<RNQRCode
|
|
34
|
+
code={code}
|
|
35
|
+
ratio={customRatio ?? ratio}
|
|
36
|
+
size={size}
|
|
37
|
+
{...rest}
|
|
38
|
+
style={[
|
|
39
|
+
{
|
|
40
|
+
width: size,
|
|
41
|
+
height: size,
|
|
42
|
+
},
|
|
43
|
+
style,
|
|
44
|
+
]}
|
|
45
|
+
/>
|
|
46
|
+
{showLogo ? (
|
|
47
|
+
<Image
|
|
48
|
+
source={{ uri: icon }}
|
|
49
|
+
style={[
|
|
50
|
+
{
|
|
51
|
+
width: iconSize,
|
|
52
|
+
height: iconSize,
|
|
53
|
+
position: 'absolute',
|
|
54
|
+
},
|
|
55
|
+
iconStyle,
|
|
56
|
+
]}
|
|
57
|
+
/>
|
|
58
|
+
) : null}
|
|
59
|
+
</>
|
|
60
|
+
);
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
export default QRCodeView;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ViewProps } from 'react-native';
|
|
2
|
+
import { codegenNativeComponent, CodegenTypes } from 'react-native';
|
|
3
|
+
|
|
4
|
+
export interface BarCodeNativeComponentProps extends ViewProps {
|
|
5
|
+
/** the data string to encode */
|
|
6
|
+
code?: string;
|
|
7
|
+
/** scale-factor for the raw CIImage */
|
|
8
|
+
ratio?: CodegenTypes.Float;
|
|
9
|
+
/** pixel width of the final barcode */
|
|
10
|
+
width?: CodegenTypes.Int32;
|
|
11
|
+
/** pixel height of the final barcode */
|
|
12
|
+
height?: CodegenTypes.Int32;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export default codegenNativeComponent<BarCodeNativeComponentProps>('RNBarCode');
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ViewProps } from 'react-native';
|
|
2
|
+
import { codegenNativeComponent, CodegenTypes } from 'react-native';
|
|
3
|
+
|
|
4
|
+
export interface QRCodeNativeComponentProps extends ViewProps {
|
|
5
|
+
code?: string;
|
|
6
|
+
ratio?: CodegenTypes.Float;
|
|
7
|
+
size?: CodegenTypes.Int32;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export default codegenNativeComponent<QRCodeNativeComponentProps>('RNQRCode');
|
package/src/index.tsx
CHANGED
|
@@ -1,2 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import RNQRCode from './RNQRCodeNativeComponent';
|
|
2
|
+
import RNBarCode from './RNBarCodeNativeComponent';
|
|
3
|
+
import BarCodeView from './BarCodeView';
|
|
4
|
+
import QRCodeView from './QRCodeView';
|
|
5
|
+
|
|
6
|
+
export { BarCodeView, QRCodeView, RNQRCode, RNBarCode };
|
package/RCTQRCode.podspec
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
require "json"
|
|
2
|
-
|
|
3
|
-
package = JSON.parse(File.read(File.join(__dir__, "package.json")))
|
|
4
|
-
|
|
5
|
-
Pod::Spec.new do |s|
|
|
6
|
-
s.name = "RCTQRCode"
|
|
7
|
-
s.version = package["version"]
|
|
8
|
-
s.summary = package["description"]
|
|
9
|
-
s.homepage = package["homepage"]
|
|
10
|
-
s.license = package["license"]
|
|
11
|
-
s.authors = package["author"]
|
|
12
|
-
|
|
13
|
-
s.platforms = { :ios => min_ios_version_supported }
|
|
14
|
-
s.source = { :git => "https://momo-kits.github.io.git", :tag => "#{s.version}" }
|
|
15
|
-
|
|
16
|
-
s.source_files = "ios/**/*.{h,m,mm,cpp}"
|
|
17
|
-
s.private_header_files = "ios/**/*.h"
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
install_modules_dependencies(s)
|
|
21
|
-
end
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
package com.momokits.qrcode
|
|
2
|
-
|
|
3
|
-
import android.content.Context
|
|
4
|
-
import android.graphics.*
|
|
5
|
-
import android.util.AttributeSet
|
|
6
|
-
import android.widget.ImageView
|
|
7
|
-
import com.google.zxing.BarcodeFormat
|
|
8
|
-
import com.google.zxing.EncodeHintType
|
|
9
|
-
import com.google.zxing.WriterException
|
|
10
|
-
import com.google.zxing.qrcode.QRCodeWriter
|
|
11
|
-
import java.util.*
|
|
12
|
-
|
|
13
|
-
class RCTQRCodeView : ImageView {
|
|
14
|
-
private var qrValue: String? = null
|
|
15
|
-
private var qrColor: Int = Color.BLACK
|
|
16
|
-
private var qrBackgroundColor: Int = Color.WHITE
|
|
17
|
-
|
|
18
|
-
constructor(context: Context?) : super(context) {
|
|
19
|
-
init()
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
constructor(context: Context?, attrs: AttributeSet?) : super(context, attrs) {
|
|
23
|
-
init()
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
constructor(context: Context?, attrs: AttributeSet?, defStyleAttr: Int) : super(
|
|
27
|
-
context,
|
|
28
|
-
attrs,
|
|
29
|
-
defStyleAttr
|
|
30
|
-
) {
|
|
31
|
-
init()
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
private fun init() {
|
|
35
|
-
scaleType = ScaleType.FIT_CENTER
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
override fun onSizeChanged(w: Int, h: Int, oldw: Int, oldh: Int) {
|
|
39
|
-
super.onSizeChanged(w, h, oldw, oldh)
|
|
40
|
-
if (w > 0 && h > 0) {
|
|
41
|
-
generateQRCode()
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
fun setValue(value: String?) {
|
|
46
|
-
qrValue = value
|
|
47
|
-
generateQRCode()
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
fun setQRColor(color: Int) {
|
|
51
|
-
qrColor = color
|
|
52
|
-
generateQRCode()
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
fun setQRBackgroundColor(color: Int) {
|
|
56
|
-
qrBackgroundColor = color
|
|
57
|
-
generateQRCode()
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
private fun generateQRCode() {
|
|
61
|
-
if (qrValue.isNullOrEmpty()) {
|
|
62
|
-
setImageBitmap(null)
|
|
63
|
-
return
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
// Use view dimensions, with fallback to default size
|
|
67
|
-
val size = if (width > 0 && height > 0) {
|
|
68
|
-
minOf(width, height)
|
|
69
|
-
} else {
|
|
70
|
-
200 // Default size
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
try {
|
|
74
|
-
val writer = QRCodeWriter()
|
|
75
|
-
val hints = EnumMap<EncodeHintType, Any>(EncodeHintType::class.java)
|
|
76
|
-
hints[EncodeHintType.CHARACTER_SET] = "UTF-8"
|
|
77
|
-
hints[EncodeHintType.MARGIN] = 1
|
|
78
|
-
|
|
79
|
-
val bitMatrix = writer.encode(qrValue, BarcodeFormat.QR_CODE, size, size, hints)
|
|
80
|
-
val width = bitMatrix.width
|
|
81
|
-
val height = bitMatrix.height
|
|
82
|
-
val bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.RGB_565)
|
|
83
|
-
|
|
84
|
-
for (x in 0 until width) {
|
|
85
|
-
for (y in 0 until height) {
|
|
86
|
-
bitmap.setPixel(x, y, if (bitMatrix[x, y]) qrColor else qrBackgroundColor)
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
post {
|
|
91
|
-
setImageBitmap(bitmap)
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
} catch (e: WriterException) {
|
|
95
|
-
e.printStackTrace()
|
|
96
|
-
setImageBitmap(null)
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
package com.momokits.qrcode
|
|
2
|
-
|
|
3
|
-
import android.graphics.Color
|
|
4
|
-
import com.facebook.react.module.annotations.ReactModule
|
|
5
|
-
import com.facebook.react.uimanager.SimpleViewManager
|
|
6
|
-
import com.facebook.react.uimanager.ThemedReactContext
|
|
7
|
-
import com.facebook.react.uimanager.annotations.ReactProp
|
|
8
|
-
|
|
9
|
-
@ReactModule(name = RCTQRCodeViewManager.NAME)
|
|
10
|
-
class RCTQRCodeViewManager : SimpleViewManager<RCTQRCodeView>() {
|
|
11
|
-
|
|
12
|
-
override fun getName(): String {
|
|
13
|
-
return NAME
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
public override fun createViewInstance(context: ThemedReactContext): RCTQRCodeView {
|
|
17
|
-
return RCTQRCodeView(context)
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
@ReactProp(name = "value")
|
|
21
|
-
fun setValue(view: RCTQRCodeView, value: String?) {
|
|
22
|
-
view.setValue(value)
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
@ReactProp(name = "color")
|
|
26
|
-
fun setColor(view: RCTQRCodeView, color: String?) {
|
|
27
|
-
color?.let {
|
|
28
|
-
try {
|
|
29
|
-
view.setQRColor(Color.parseColor(it))
|
|
30
|
-
} catch (e: IllegalArgumentException) {
|
|
31
|
-
// Invalid color format, use default
|
|
32
|
-
view.setQRColor(Color.BLACK)
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
@ReactProp(name = "backgroundColor")
|
|
38
|
-
fun setBackgroundColor(view: RCTQRCodeView, backgroundColor: String?) {
|
|
39
|
-
backgroundColor?.let {
|
|
40
|
-
try {
|
|
41
|
-
view.setQRBackgroundColor(Color.parseColor(it))
|
|
42
|
-
} catch (e: IllegalArgumentException) {
|
|
43
|
-
// Invalid color format, use default
|
|
44
|
-
view.setQRBackgroundColor(Color.WHITE)
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
companion object {
|
|
50
|
-
const val NAME = "RCTQRCodeView"
|
|
51
|
-
}
|
|
52
|
-
}
|
package/ios/RCTQRCodeView.h
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
#import <React/RCTViewComponentView.h>
|
|
2
|
-
#import <UIKit/UIKit.h>
|
|
3
|
-
|
|
4
|
-
#ifndef RCTQRCodeView_h
|
|
5
|
-
#define RCTQRCodeView_h
|
|
6
|
-
|
|
7
|
-
NS_ASSUME_NONNULL_BEGIN
|
|
8
|
-
|
|
9
|
-
@interface RCTQRCodeView : RCTViewComponentView
|
|
10
|
-
|
|
11
|
-
- (void)setValue:(NSString *)value;
|
|
12
|
-
- (void)setColor:(NSString *)color;
|
|
13
|
-
- (void)setBackgroundColor:(NSString *)backgroundColor;
|
|
14
|
-
|
|
15
|
-
@end
|
|
16
|
-
|
|
17
|
-
NS_ASSUME_NONNULL_END
|
|
18
|
-
|
|
19
|
-
#endif /* RCTQRCodeView_h */
|
package/ios/RCTQRCodeView.mm
DELETED
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
#import "RCTQRCodeView.h"
|
|
2
|
-
#import <React/RCTConversions.h>
|
|
3
|
-
#import <CoreImage/CoreImage.h>
|
|
4
|
-
|
|
5
|
-
@implementation RCTQRCodeView {
|
|
6
|
-
UIImageView *_qrImageView;
|
|
7
|
-
NSString *_value;
|
|
8
|
-
UIColor *_qrColor;
|
|
9
|
-
UIColor *_qrBackgroundColor;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
- (instancetype)initWithFrame:(CGRect)frame
|
|
13
|
-
{
|
|
14
|
-
if (self = [super initWithFrame:frame]) {
|
|
15
|
-
_qrImageView = [[UIImageView alloc] init];
|
|
16
|
-
_qrImageView.contentMode = UIViewContentModeScaleAspectFit;
|
|
17
|
-
[self addSubview:_qrImageView];
|
|
18
|
-
|
|
19
|
-
// Default colors
|
|
20
|
-
_qrColor = [UIColor blackColor];
|
|
21
|
-
_qrBackgroundColor = [UIColor whiteColor];
|
|
22
|
-
}
|
|
23
|
-
return self;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
- (void)layoutSubviews
|
|
27
|
-
{
|
|
28
|
-
[super layoutSubviews];
|
|
29
|
-
_qrImageView.frame = self.bounds;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
// Override the updateProps method to handle props without generated specs
|
|
33
|
-
- (void)updateProps:(facebook::react::Props::Shared const &)props oldProps:(facebook::react::Props::Shared const &)oldProps
|
|
34
|
-
{
|
|
35
|
-
[super updateProps:props oldProps:oldProps];
|
|
36
|
-
|
|
37
|
-
// Since we don't have generated props, we'll handle them through the bridge
|
|
38
|
-
// The actual prop handling will be done via the view manager
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
- (void)prepareForRecycle
|
|
42
|
-
{
|
|
43
|
-
[super prepareForRecycle];
|
|
44
|
-
_qrImageView.image = nil;
|
|
45
|
-
_value = nil;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
// Public methods for setting props
|
|
49
|
-
- (void)setValue:(NSString *)value
|
|
50
|
-
{
|
|
51
|
-
if (![_value isEqualToString:value]) {
|
|
52
|
-
_value = value;
|
|
53
|
-
[self generateQRCode];
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
- (void)setColor:(NSString *)color
|
|
58
|
-
{
|
|
59
|
-
if (color) {
|
|
60
|
-
_qrColor = [self colorFromHexString:color] ?: [UIColor blackColor];
|
|
61
|
-
[self generateQRCode];
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
- (void)setBackgroundColor:(NSString *)backgroundColor
|
|
66
|
-
{
|
|
67
|
-
if (backgroundColor) {
|
|
68
|
-
_qrBackgroundColor = [self colorFromHexString:backgroundColor] ?: [UIColor whiteColor];
|
|
69
|
-
[self generateQRCode];
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
- (UIColor *)colorFromHexString:(NSString *)hexString
|
|
74
|
-
{
|
|
75
|
-
if (!hexString) return nil;
|
|
76
|
-
|
|
77
|
-
NSString *cleanString = [hexString stringByReplacingOccurrencesOfString:@"#" withString:@""];
|
|
78
|
-
if ([cleanString length] != 6) return nil;
|
|
79
|
-
|
|
80
|
-
NSScanner *scanner = [NSScanner scannerWithString:cleanString];
|
|
81
|
-
unsigned hexValue = 0;
|
|
82
|
-
if (![scanner scanHexInt:&hexValue]) return nil;
|
|
83
|
-
|
|
84
|
-
return [UIColor colorWithRed:((hexValue & 0xFF0000) >> 16) / 255.0
|
|
85
|
-
green:((hexValue & 0xFF00) >> 8) / 255.0
|
|
86
|
-
blue:(hexValue & 0xFF) / 255.0
|
|
87
|
-
alpha:1.0];
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
- (void)generateQRCode
|
|
91
|
-
{
|
|
92
|
-
if (!_value || _value.length == 0) {
|
|
93
|
-
_qrImageView.image = nil;
|
|
94
|
-
return;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
NSData *stringData = [_value dataUsingEncoding:NSUTF8StringEncoding];
|
|
98
|
-
|
|
99
|
-
CIFilter *qrFilter = [CIFilter filterWithName:@"CIQRCodeGenerator"];
|
|
100
|
-
[qrFilter setValue:stringData forKey:@"inputMessage"];
|
|
101
|
-
[qrFilter setValue:@"M" forKey:@"inputCorrectionLevel"];
|
|
102
|
-
|
|
103
|
-
CIImage *qrImage = qrFilter.outputImage;
|
|
104
|
-
|
|
105
|
-
if (!qrImage) {
|
|
106
|
-
return;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
// Use the view's bounds for sizing, with a minimum scale
|
|
110
|
-
CGFloat viewSize = MIN(self.bounds.size.width, self.bounds.size.height);
|
|
111
|
-
if (viewSize == 0) {
|
|
112
|
-
viewSize = 200.0; // Default size
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
CGFloat scale = viewSize / qrImage.extent.size.width;
|
|
116
|
-
|
|
117
|
-
CIFilter *scaleFilter = [CIFilter filterWithName:@"CILanczosScaleTransform"];
|
|
118
|
-
[scaleFilter setValue:qrImage forKey:@"inputImage"];
|
|
119
|
-
[scaleFilter setValue:@(scale) forKey:@"inputScale"];
|
|
120
|
-
[scaleFilter setValue:@1.0 forKey:@"inputAspectRatio"];
|
|
121
|
-
|
|
122
|
-
CIImage *scaledImage = scaleFilter.outputImage;
|
|
123
|
-
|
|
124
|
-
// Apply colors using CIFilter
|
|
125
|
-
CIFilter *colorFilter = [CIFilter filterWithName:@"CIFalseColor"];
|
|
126
|
-
[colorFilter setValue:scaledImage forKey:@"inputImage"];
|
|
127
|
-
[colorFilter setValue:[CIColor colorWithCGColor:_qrColor.CGColor] forKey:@"inputColor0"];
|
|
128
|
-
[colorFilter setValue:[CIColor colorWithCGColor:_qrBackgroundColor.CGColor] forKey:@"inputColor1"];
|
|
129
|
-
|
|
130
|
-
CIImage *coloredImage = colorFilter.outputImage;
|
|
131
|
-
|
|
132
|
-
CIContext *context = [CIContext context];
|
|
133
|
-
CGImageRef cgImage = [context createCGImage:coloredImage fromRect:coloredImage.extent];
|
|
134
|
-
UIImage *qrCodeImage = [UIImage imageWithCGImage:cgImage];
|
|
135
|
-
CGImageRelease(cgImage);
|
|
136
|
-
|
|
137
|
-
dispatch_async(dispatch_get_main_queue(), ^{
|
|
138
|
-
self->_qrImageView.image = qrCodeImage;
|
|
139
|
-
});
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
@end
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
#import <React/RCTViewManager.h>
|
|
2
|
-
#import <React/RCTUIManager.h>
|
|
3
|
-
#import "RCTQRCodeView.h"
|
|
4
|
-
|
|
5
|
-
@interface RCTQRCodeViewManager : RCTViewManager
|
|
6
|
-
@end
|
|
7
|
-
|
|
8
|
-
@implementation RCTQRCodeViewManager
|
|
9
|
-
|
|
10
|
-
RCT_EXPORT_MODULE(RCTQRCodeView)
|
|
11
|
-
|
|
12
|
-
- (UIView *)view
|
|
13
|
-
{
|
|
14
|
-
return [[RCTQRCodeView alloc] init];
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
RCT_EXPORT_VIEW_PROPERTY(value, NSString)
|
|
18
|
-
RCT_EXPORT_VIEW_PROPERTY(color, NSString)
|
|
19
|
-
RCT_EXPORT_VIEW_PROPERTY(backgroundColor, NSString)
|
|
20
|
-
|
|
21
|
-
@end
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { codegenNativeComponent, type ViewProps } from 'react-native';
|
|
2
|
-
import type { ColorValue } from 'react-native';
|
|
3
|
-
|
|
4
|
-
export interface NativeProps extends ViewProps {
|
|
5
|
-
value?: string;
|
|
6
|
-
backgroundColor?: ColorValue;
|
|
7
|
-
color?: ColorValue;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export default codegenNativeComponent<NativeProps>('RCTQRCodeView');
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { type ViewProps } from 'react-native';
|
|
2
|
-
import type { ColorValue } from 'react-native';
|
|
3
|
-
export interface NativeProps extends ViewProps {
|
|
4
|
-
value?: string;
|
|
5
|
-
backgroundColor?: ColorValue;
|
|
6
|
-
color?: ColorValue;
|
|
7
|
-
}
|
|
8
|
-
declare const _default: import("react-native/types_generated/Libraries/Utilities/codegenNativeComponent").NativeComponentType<NativeProps>;
|
|
9
|
-
export default _default;
|
|
10
|
-
//# sourceMappingURL=RCTQRCodeViewNativeComponent.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"RCTQRCodeViewNativeComponent.d.ts","sourceRoot":"","sources":["../../../src/RCTQRCodeViewNativeComponent.ts"],"names":[],"mappings":"AAAA,OAAO,EAA0B,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AACtE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE/C,MAAM,WAAW,WAAY,SAAQ,SAAS;IAC5C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,eAAe,CAAC,EAAE,UAAU,CAAC;IAC7B,KAAK,CAAC,EAAE,UAAU,CAAC;CACpB;;AAED,wBAAoE"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { codegenNativeComponent, type ViewProps } from 'react-native';
|
|
2
|
-
import type { ColorValue } from 'react-native';
|
|
3
|
-
|
|
4
|
-
export interface NativeProps extends ViewProps {
|
|
5
|
-
value?: string;
|
|
6
|
-
backgroundColor?: ColorValue;
|
|
7
|
-
color?: ColorValue;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export default codegenNativeComponent<NativeProps>('RCTQRCodeView');
|