@momo-kits/qrcode 0.150.2-beta.5 → 0.150.2-beta.test.6
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/Qrcode.podspec +24 -12
- package/ios/RCTQRCode.h +5 -2
- package/ios/RCTQRCode.mm +65 -45
- package/ios/RCTQRCodeManager.mm +20 -9
- package/lib/module/RCTQRCodeNativeComponent.ts +7 -10
- package/lib/typescript/src/RCTQRCodeNativeComponent.d.ts +6 -5
- package/lib/typescript/src/RCTQRCodeNativeComponent.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/RCTQRCodeNativeComponent.ts +7 -10
package/Qrcode.podspec
CHANGED
|
@@ -3,19 +3,31 @@ require "json"
|
|
|
3
3
|
package = JSON.parse(File.read(File.join(__dir__, "package.json")))
|
|
4
4
|
|
|
5
5
|
Pod::Spec.new do |s|
|
|
6
|
-
s.name
|
|
7
|
-
s.version
|
|
8
|
-
s.summary
|
|
9
|
-
s.
|
|
10
|
-
s.
|
|
11
|
-
s.
|
|
6
|
+
s.name = "Qrcode"
|
|
7
|
+
s.version = package["version"]
|
|
8
|
+
s.summary = package["description"]
|
|
9
|
+
s.description = package["description"]
|
|
10
|
+
s.homepage = package["homepage"]
|
|
11
|
+
s.license = package["license"]
|
|
12
|
+
s.platforms = { :ios => "11.0" }
|
|
13
|
+
s.author = package["author"]
|
|
14
|
+
s.source = { :git => package["repository"]["url"], :tag => "#{s.version}" }
|
|
12
15
|
|
|
13
|
-
s.
|
|
14
|
-
s.
|
|
16
|
+
s.source_files = "ios/**/*.{h,m,mm,swift}"
|
|
17
|
+
s.requires_arc = true
|
|
15
18
|
|
|
16
|
-
s.
|
|
17
|
-
s.private_header_files = "ios/**/*.h"
|
|
19
|
+
s.dependency "React-Core"
|
|
18
20
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
+
# Use install_modules_dependencies helper to install the dependencies if React Native version >=0.71.0.
|
|
22
|
+
# See https://github.com/facebook/react-native/blob/febf6b7f33fdb4904669f99d795eba4c0f95d7bf/scripts/cocoapods/new_architecture.rb#L79.
|
|
23
|
+
if respond_to?(:install_modules_dependencies, true)
|
|
24
|
+
install_modules_dependencies(s)
|
|
25
|
+
else
|
|
26
|
+
s.dependency "React-RCTFabric", "~> 0.72.0" # This dependency is managed by React Native.
|
|
27
|
+
s.dependency "React-Codegen", "~> 0.72.0"
|
|
28
|
+
s.dependency "RCT-Folly", "~> 2021.07.22.00"
|
|
29
|
+
s.dependency "RCTRequired", "~> 0.72.0"
|
|
30
|
+
s.dependency "RCTTypeSafety", "~> 0.72.0"
|
|
31
|
+
s.dependency "ReactCommon", "~> 0.72.0"
|
|
32
|
+
end
|
|
21
33
|
end
|
package/ios/RCTQRCode.h
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
#import <React/RCTViewComponentView.h>
|
|
2
1
|
#import <UIKit/UIKit.h>
|
|
3
2
|
|
|
4
3
|
NS_ASSUME_NONNULL_BEGIN
|
|
5
4
|
|
|
6
|
-
@interface RCTQRCode :
|
|
5
|
+
@interface RCTQRCode : UIView
|
|
6
|
+
|
|
7
|
+
@property (nonatomic, copy) NSString *code;
|
|
8
|
+
@property (nonatomic, strong) NSNumber *size;
|
|
9
|
+
@property (nonatomic, strong) NSNumber *ratio;
|
|
7
10
|
|
|
8
11
|
@end
|
|
9
12
|
|
package/ios/RCTQRCode.mm
CHANGED
|
@@ -1,66 +1,86 @@
|
|
|
1
1
|
#import "RCTQRCode.h"
|
|
2
|
-
#import <
|
|
3
|
-
#import <react/renderer/components/QrcodeViewSpec/Props.h>
|
|
4
|
-
#import <react/renderer/components/QrcodeViewSpec/RCTComponentViewHelpers.h>
|
|
5
|
-
#import <react/renderer/components/QrcodeViewSpec/EventEmitters.h>
|
|
6
|
-
#import "QRCodeView.h"
|
|
7
|
-
#import <React/RCTLog.h>
|
|
8
|
-
|
|
9
|
-
#import "RCTFabricComponentsPlugins.h"
|
|
10
|
-
|
|
11
|
-
using namespace facebook::react;
|
|
12
|
-
|
|
13
|
-
@interface RCTQRCode () <RCTRCTQRCodeViewProtocol>
|
|
14
|
-
@end
|
|
2
|
+
#import <CoreImage/CoreImage.h>
|
|
15
3
|
|
|
16
4
|
@implementation RCTQRCode {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
{
|
|
22
|
-
if (self = [super init]) {
|
|
23
|
-
// Create and embed your existing UIImageView-based QRCodeView
|
|
24
|
-
_qrView = [QRCodeView new];
|
|
25
|
-
[self addSubview:_qrView];
|
|
26
|
-
}
|
|
27
|
-
return self;
|
|
5
|
+
UIImageView *_qrImageView;
|
|
6
|
+
NSString *_code;
|
|
7
|
+
NSNumber *_size;
|
|
8
|
+
NSNumber *_ratio;
|
|
28
9
|
}
|
|
29
10
|
|
|
30
|
-
- (
|
|
31
|
-
oldProps:(Props::Shared const &)oldProps
|
|
11
|
+
- (instancetype)initWithFrame:(CGRect)frame
|
|
32
12
|
{
|
|
33
|
-
|
|
34
|
-
|
|
13
|
+
if (self = [super initWithFrame:frame]) {
|
|
14
|
+
_qrImageView = [[UIImageView alloc] init];
|
|
15
|
+
_qrImageView.contentMode = UIViewContentModeScaleAspectFit;
|
|
16
|
+
[self addSubview:_qrImageView];
|
|
35
17
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
NSString *nsCode = [NSString stringWithUTF8String:qrProps.code.c_str()];
|
|
39
|
-
_qrView.code = nsCode;
|
|
18
|
+
_size = @200;
|
|
19
|
+
_ratio = @1.0;
|
|
40
20
|
}
|
|
41
|
-
_qrView.ratio = qrProps.ratio;
|
|
42
|
-
_qrView.size = qrProps.size;
|
|
43
|
-
NSLog(@"[QRCodeView] setCode: %@", _qrView.code);
|
|
44
21
|
|
|
45
|
-
|
|
22
|
+
return self;
|
|
46
23
|
}
|
|
47
24
|
|
|
48
25
|
- (void)layoutSubviews
|
|
49
26
|
{
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
_qrView.frame = self.bounds;
|
|
27
|
+
[super layoutSubviews];
|
|
28
|
+
_qrImageView.frame = self.bounds;
|
|
53
29
|
}
|
|
54
30
|
|
|
55
|
-
|
|
31
|
+
- (void)setCode:(NSString *)code
|
|
56
32
|
{
|
|
57
|
-
|
|
58
|
-
|
|
33
|
+
_code = code;
|
|
34
|
+
[self generateQRCode];
|
|
59
35
|
}
|
|
60
36
|
|
|
61
|
-
|
|
37
|
+
- (void)setSize:(NSNumber *)size
|
|
38
|
+
{
|
|
39
|
+
_size = size;
|
|
40
|
+
[self generateQRCode];
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
- (void)setRatio:(NSNumber *)ratio
|
|
44
|
+
{
|
|
45
|
+
_ratio = ratio;
|
|
46
|
+
[self generateQRCode];
|
|
47
|
+
}
|
|
62
48
|
|
|
63
|
-
|
|
49
|
+
- (void)generateQRCode
|
|
64
50
|
{
|
|
65
|
-
|
|
51
|
+
if (!_code || _code.length == 0) {
|
|
52
|
+
_qrImageView.image = nil;
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// Generate QR Code
|
|
57
|
+
CIFilter *filter = [CIFilter filterWithName:@"CIQRCodeGenerator"];
|
|
58
|
+
[filter setDefaults];
|
|
59
|
+
|
|
60
|
+
NSData *data = [_code dataUsingEncoding:NSUTF8StringEncoding];
|
|
61
|
+
[filter setValue:data forKey:@"inputMessage"];
|
|
62
|
+
|
|
63
|
+
CIImage *ciImage = [filter outputImage];
|
|
64
|
+
|
|
65
|
+
if (!ciImage) {
|
|
66
|
+
_qrImageView.image = nil;
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// Scale the image
|
|
71
|
+
CGFloat size = [_size floatValue];
|
|
72
|
+
CGFloat ratio = [_ratio floatValue];
|
|
73
|
+
CGFloat scaleX = size * ratio / ciImage.extent.size.width;
|
|
74
|
+
CGFloat scaleY = size * ratio / ciImage.extent.size.height;
|
|
75
|
+
CIImage *scaledImage = [ciImage imageByApplyingTransform:CGAffineTransformMakeScale(scaleX, scaleY)];
|
|
76
|
+
|
|
77
|
+
// Convert to UIImage
|
|
78
|
+
CIContext *context = [CIContext context];
|
|
79
|
+
CGImageRef cgImage = [context createCGImage:scaledImage fromRect:scaledImage.extent];
|
|
80
|
+
UIImage *qrImage = [UIImage imageWithCGImage:cgImage];
|
|
81
|
+
CGImageRelease(cgImage);
|
|
82
|
+
|
|
83
|
+
_qrImageView.image = qrImage;
|
|
66
84
|
}
|
|
85
|
+
|
|
86
|
+
@end
|
package/ios/RCTQRCodeManager.mm
CHANGED
|
@@ -1,15 +1,26 @@
|
|
|
1
1
|
#import <React/RCTViewManager.h>
|
|
2
|
-
#import <
|
|
3
|
-
#import "
|
|
2
|
+
#import <React/RCTUIManager.h>
|
|
3
|
+
#import "RCTQRCode.h"
|
|
4
4
|
|
|
5
|
-
@
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
@interface RCTQRCodeManager : RCTViewManager
|
|
6
|
+
@end
|
|
7
|
+
|
|
8
|
+
@implementation RCTQRCodeManager
|
|
9
9
|
|
|
10
10
|
RCT_EXPORT_MODULE(RCTQRCode)
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
|
|
12
|
+
RCT_EXPORT_VIEW_PROPERTY(code, NSString)
|
|
13
|
+
RCT_EXPORT_VIEW_PROPERTY(size, NSNumber)
|
|
14
|
+
RCT_EXPORT_VIEW_PROPERTY(ratio, NSNumber)
|
|
15
|
+
|
|
16
|
+
- (UIView *)view
|
|
17
|
+
{
|
|
18
|
+
return [[RCTQRCode alloc] init];
|
|
14
19
|
}
|
|
20
|
+
|
|
21
|
+
+ (BOOL)requiresMainQueueSetup
|
|
22
|
+
{
|
|
23
|
+
return NO;
|
|
24
|
+
}
|
|
25
|
+
|
|
15
26
|
@end
|
|
@@ -1,14 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import
|
|
4
|
-
import { codegenNativeComponent } from 'react-native';
|
|
1
|
+
import type { ViewProps } from 'react-native';
|
|
2
|
+
import type { Double, Int32 } from 'react-native/Libraries/Types/CodegenTypes';
|
|
3
|
+
import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent';
|
|
5
4
|
|
|
6
5
|
export interface QRCodeNativeComponentProps extends ViewProps {
|
|
7
|
-
code
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
code: string;
|
|
7
|
+
size: Int32;
|
|
8
|
+
ratio?: Double;
|
|
10
9
|
}
|
|
11
10
|
|
|
12
|
-
export default codegenNativeComponent<QRCodeNativeComponentProps>(
|
|
13
|
-
'RCTQRCode'
|
|
14
|
-
) as HostComponent<QRCodeNativeComponentProps>;
|
|
11
|
+
export default codegenNativeComponent<QRCodeNativeComponentProps>('RCTQRCode');
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ViewProps } from 'react-native';
|
|
2
|
+
import type { Double, Int32 } from 'react-native/Libraries/Types/CodegenTypes';
|
|
2
3
|
export interface QRCodeNativeComponentProps extends ViewProps {
|
|
3
|
-
code
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
code: string;
|
|
5
|
+
size: Int32;
|
|
6
|
+
ratio?: Double;
|
|
6
7
|
}
|
|
7
|
-
declare const _default:
|
|
8
|
+
declare const _default: import("react-native/Libraries/Utilities/codegenNativeComponent").NativeComponentType<QRCodeNativeComponentProps>;
|
|
8
9
|
export default _default;
|
|
9
10
|
//# sourceMappingURL=RCTQRCodeNativeComponent.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RCTQRCodeNativeComponent.d.ts","sourceRoot":"","sources":["../../../src/RCTQRCodeNativeComponent.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"RCTQRCodeNativeComponent.d.ts","sourceRoot":"","sources":["../../../src/RCTQRCodeNativeComponent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,2CAA2C,CAAC;AAG/E,MAAM,WAAW,0BAA2B,SAAQ,SAAS;IAC3D,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,KAAK,CAAC;IACZ,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;;AAED,wBAA+E"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@momo-kits/qrcode",
|
|
3
|
-
"version": "0.150.2-beta.
|
|
3
|
+
"version": "0.150.2-beta.test.6",
|
|
4
4
|
"description": "A simple and customizable QR code generator component for React Native apps.",
|
|
5
5
|
"main": "./lib/module/index.js",
|
|
6
6
|
"types": "./lib/typescript/src/index.d.ts",
|
|
@@ -1,14 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import
|
|
4
|
-
import { codegenNativeComponent } from 'react-native';
|
|
1
|
+
import type { ViewProps } from 'react-native';
|
|
2
|
+
import type { Double, Int32 } from 'react-native/Libraries/Types/CodegenTypes';
|
|
3
|
+
import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent';
|
|
5
4
|
|
|
6
5
|
export interface QRCodeNativeComponentProps extends ViewProps {
|
|
7
|
-
code
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
code: string;
|
|
7
|
+
size: Int32;
|
|
8
|
+
ratio?: Double;
|
|
10
9
|
}
|
|
11
10
|
|
|
12
|
-
export default codegenNativeComponent<QRCodeNativeComponentProps>(
|
|
13
|
-
'RCTQRCode'
|
|
14
|
-
) as HostComponent<QRCodeNativeComponentProps>;
|
|
11
|
+
export default codegenNativeComponent<QRCodeNativeComponentProps>('RCTQRCode');
|