@momo-kits/qrcode 0.150.2-beta.5 → 0.150.2-beta.test.5
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 +0 -1
- package/ios/RCTQRCode.mm +76 -36
- package/ios/RCTQRCodeManager.mm +25 -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
package/ios/RCTQRCode.mm
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
#import "RCTQRCode.h"
|
|
2
|
-
|
|
3
|
-
#import <react/renderer/components/
|
|
4
|
-
#import <react/renderer/components/
|
|
5
|
-
#import <react/renderer/components/
|
|
6
|
-
#import
|
|
7
|
-
#import <React/RCTLog.h>
|
|
2
|
+
|
|
3
|
+
#import <react/renderer/components/QrcodeViewManager/ComponentDescriptors.h>
|
|
4
|
+
#import <react/renderer/components/QrcodeViewManager/EventEmitters.h>
|
|
5
|
+
#import <react/renderer/components/QrcodeViewManager/Props.h>
|
|
6
|
+
#import <react/renderer/components/QrcodeViewManager/RCTComponentViewHelpers.h>
|
|
8
7
|
|
|
9
8
|
#import "RCTFabricComponentsPlugins.h"
|
|
9
|
+
#import <React/RCTConversions.h>
|
|
10
|
+
#import <CoreImage/CoreImage.h>
|
|
10
11
|
|
|
11
12
|
using namespace facebook::react;
|
|
12
13
|
|
|
@@ -14,53 +15,92 @@ using namespace facebook::react;
|
|
|
14
15
|
@end
|
|
15
16
|
|
|
16
17
|
@implementation RCTQRCode {
|
|
17
|
-
|
|
18
|
+
UIImageView *_qrImageView;
|
|
18
19
|
}
|
|
19
20
|
|
|
20
|
-
|
|
21
|
+
+ (ComponentDescriptorProvider)componentDescriptorProvider
|
|
21
22
|
{
|
|
22
|
-
|
|
23
|
-
// Create and embed your existing UIImageView-based QRCodeView
|
|
24
|
-
_qrView = [QRCodeView new];
|
|
25
|
-
[self addSubview:_qrView];
|
|
26
|
-
}
|
|
27
|
-
return self;
|
|
23
|
+
return concreteComponentDescriptorProvider<RCTQRCodeComponentDescriptor>();
|
|
28
24
|
}
|
|
29
25
|
|
|
30
|
-
- (
|
|
31
|
-
oldProps:(Props::Shared const &)oldProps
|
|
26
|
+
- (instancetype)initWithFrame:(CGRect)frame
|
|
32
27
|
{
|
|
33
|
-
|
|
34
|
-
|
|
28
|
+
if (self = [super initWithFrame:frame]) {
|
|
29
|
+
static const auto defaultProps = std::make_shared<const RCTQRCodeProps>();
|
|
30
|
+
_props = defaultProps;
|
|
35
31
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
_qrView.code = nsCode;
|
|
32
|
+
_qrImageView = [[UIImageView alloc] init];
|
|
33
|
+
_qrImageView.contentMode = UIViewContentModeScaleAspectFit;
|
|
34
|
+
[self addSubview:_qrImageView];
|
|
40
35
|
}
|
|
41
|
-
_qrView.ratio = qrProps.ratio;
|
|
42
|
-
_qrView.size = qrProps.size;
|
|
43
|
-
NSLog(@"[QRCodeView] setCode: %@", _qrView.code);
|
|
44
36
|
|
|
45
|
-
|
|
37
|
+
return self;
|
|
46
38
|
}
|
|
47
39
|
|
|
48
|
-
- (void)
|
|
40
|
+
- (void)updateProps:(Props::Shared const &)props oldProps:(Props::Shared const &)oldProps
|
|
49
41
|
{
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
42
|
+
const auto &oldViewProps = *std::static_pointer_cast<RCTQRCodeProps const>(_props);
|
|
43
|
+
const auto &newViewProps = *std::static_pointer_cast<RCTQRCodeProps const>(props);
|
|
44
|
+
|
|
45
|
+
if (oldViewProps.code != newViewProps.code ||
|
|
46
|
+
oldViewProps.size != newViewProps.size ||
|
|
47
|
+
oldViewProps.ratio != newViewProps.ratio) {
|
|
48
|
+
[self generateQRCode];
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
[super updateProps:props oldProps:oldProps];
|
|
53
52
|
}
|
|
54
53
|
|
|
55
|
-
|
|
54
|
+
- (void)layoutSubviews
|
|
56
55
|
{
|
|
57
|
-
|
|
58
|
-
|
|
56
|
+
[super layoutSubviews];
|
|
57
|
+
_qrImageView.frame = self.bounds;
|
|
59
58
|
}
|
|
60
59
|
|
|
61
|
-
|
|
60
|
+
- (void)generateQRCode
|
|
61
|
+
{
|
|
62
|
+
const auto &props = *std::static_pointer_cast<RCTQRCodeProps const>(_props);
|
|
63
|
+
|
|
64
|
+
NSString *code = RCTNSStringFromString(props.code);
|
|
65
|
+
CGFloat size = props.size;
|
|
66
|
+
CGFloat ratio = props.ratio.value_or(1.0);
|
|
67
|
+
|
|
68
|
+
if (!code || code.length == 0) {
|
|
69
|
+
_qrImageView.image = nil;
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// Generate QR Code
|
|
74
|
+
CIFilter *filter = [CIFilter filterWithName:@"CIQRCodeGenerator"];
|
|
75
|
+
[filter setDefaults];
|
|
76
|
+
|
|
77
|
+
NSData *data = [code dataUsingEncoding:NSUTF8StringEncoding];
|
|
78
|
+
[filter setValue:data forKey:@"inputMessage"];
|
|
79
|
+
|
|
80
|
+
CIImage *ciImage = [filter outputImage];
|
|
81
|
+
|
|
82
|
+
if (!ciImage) {
|
|
83
|
+
_qrImageView.image = nil;
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
62
86
|
|
|
63
|
-
|
|
87
|
+
// Scale the image
|
|
88
|
+
CGFloat scaleX = size * ratio / ciImage.extent.size.width;
|
|
89
|
+
CGFloat scaleY = size * ratio / ciImage.extent.size.height;
|
|
90
|
+
CIImage *scaledImage = [ciImage imageByApplyingTransform:CGAffineTransformMakeScale(scaleX, scaleY)];
|
|
91
|
+
|
|
92
|
+
// Convert to UIImage
|
|
93
|
+
CIContext *context = [CIContext context];
|
|
94
|
+
CGImageRef cgImage = [context createCGImage:scaledImage fromRect:scaledImage.extent];
|
|
95
|
+
UIImage *qrImage = [UIImage imageWithCGImage:cgImage];
|
|
96
|
+
CGImageRelease(cgImage);
|
|
97
|
+
|
|
98
|
+
_qrImageView.image = qrImage;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
Class<RCTComponentViewProtocol> RCTQRCodeCls(void)
|
|
64
102
|
{
|
|
65
|
-
|
|
103
|
+
return RCTQRCode.class;
|
|
66
104
|
}
|
|
105
|
+
|
|
106
|
+
@end
|
package/ios/RCTQRCodeManager.mm
CHANGED
|
@@ -1,15 +1,31 @@
|
|
|
1
1
|
#import <React/RCTViewManager.h>
|
|
2
|
-
#import <
|
|
3
|
-
#import "
|
|
2
|
+
#import <React/RCTUIManager.h>
|
|
3
|
+
#import "RCTFabricComponentsPlugins.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
|
+
- (UIView *)view
|
|
13
|
+
{
|
|
14
|
+
return [RCTQRCodeCls() new];
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
@end
|
|
18
|
+
|
|
19
|
+
Class<RCTComponentViewProtocol> RCTQRCodeCls(void);
|
|
20
|
+
|
|
21
|
+
@interface RCTQRCodeManager (Fabric) <RCTFabricViewManager>
|
|
22
|
+
@end
|
|
23
|
+
|
|
24
|
+
@implementation RCTQRCodeManager (Fabric)
|
|
25
|
+
|
|
26
|
+
- (Class<RCTComponentViewProtocol>)componentViewClass
|
|
27
|
+
{
|
|
28
|
+
return RCTQRCodeCls();
|
|
14
29
|
}
|
|
30
|
+
|
|
15
31
|
@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.5",
|
|
3
|
+
"version": "0.150.2-beta.test.5",
|
|
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');
|