@momo-kits/qrcode 0.0.1-beta → 0.0.1

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/BarCodeView.js ADDED
@@ -0,0 +1,21 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import { ViewPropTypes, PixelRatio } from 'react-native';
4
+ import { RCTBarCode } from '@momo-kits/core';
5
+
6
+ const ratio = PixelRatio.get();
7
+ function BarCodeView(props) {
8
+ return (
9
+ <RCTBarCode ratio={ratio} {...props} />
10
+ );
11
+ }
12
+
13
+ BarCodeView.propTypes = {
14
+ code: PropTypes.string,
15
+ width: PropTypes.number,
16
+ height: PropTypes.number,
17
+ ratio: PropTypes.number,
18
+ ...ViewPropTypes,
19
+ };
20
+
21
+ export default BarCodeView;
package/QRCodeView.js ADDED
@@ -0,0 +1,40 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import { ViewPropTypes, PixelRatio, Image } from 'react-native';
4
+ import { RCTQRCode } from '@momo-kits/core';
5
+
6
+ const ratio = PixelRatio.get();
7
+ const ic_logo = 'https://img.mservice.io/momo_app_v2/new_version/img/appx_image/ic_momo.png';
8
+
9
+ function QRCodeView(props) {
10
+ const { showLogo, size = 0 } = props || {};
11
+ return (
12
+ <>
13
+ <RCTQRCode ratio={ratio} {...props} />
14
+ {showLogo
15
+ ? (
16
+ <Image
17
+ source={{ uri: ic_logo }}
18
+ style={{
19
+ width: size / 6,
20
+ height: size / 6,
21
+ position: 'absolute',
22
+ marginTop: size / 2 - size / 12,
23
+ marginLeft: size / 2 - size / 12
24
+ }}
25
+ />
26
+ ) : null}
27
+ </>
28
+
29
+ );
30
+ }
31
+
32
+ QRCodeView.propTypes = {
33
+ code: PropTypes.string,
34
+ size: PropTypes.number,
35
+ ratio: PropTypes.number,
36
+ showLogo: PropTypes.bool,
37
+ ...ViewPropTypes,
38
+ };
39
+
40
+ export default QRCodeView;
package/index.js CHANGED
@@ -1,5 +1,6 @@
1
- import QRCodeScannerView from './QRCodeScannerView';
1
+ import BarCodeView from './BarCodeView';
2
+ import QRCodeView from './QRCodeView';
2
3
 
3
4
  export {
4
- QRCodeScannerView
5
+ BarCodeView, QRCodeView
5
6
  };
package/package.json CHANGED
@@ -1,19 +1,15 @@
1
1
  {
2
- "name": "@momo-kits/qrcode",
3
- "version": "0.0.1-beta",
4
- "private": false,
5
- "scripts": {
6
- "publish": "bash publish.sh"
7
- },
8
- "dependencies": {
9
- "prop-types": "^15.7.2",
10
- "react": "16.9.0"
11
- },
12
- "peerDependencies": {
13
- "react": "16.9.0",
14
- "react-native": ">=0.55"
15
- },
16
- "devDependencies": {},
17
- "license": "MOMO"
18
- }
19
-
2
+ "name": "@momo-kits/qrcode",
3
+ "version": "0.0.1",
4
+ "private": false,
5
+ "main": "index.js",
6
+ "dependencies": {},
7
+ "peerDependencies": {
8
+ "react-native": ">=0.55",
9
+ "prop-types": "^15.7.2",
10
+ "react": "16.9.0",
11
+ "@momo-kits/core": "latest"
12
+ },
13
+ "devDependencies": {},
14
+ "license": "MoMo"
15
+ }
package/publish.sh CHANGED
@@ -4,10 +4,15 @@ mkdir dist
4
4
 
5
5
  cp . ./dist
6
6
 
7
+ # GET VERSION from mck_package.json
8
+ VERSIONSTRING=( v$(jq .version package.json) )
9
+ VERSION=(${VERSIONSTRING//[\"]/})
10
+ echo VERSION: $VERSION
11
+
7
12
  rsync -r --verbose --exclude '*.mdx' --exclude '*Demo.js' --exclude 'props-type.js' --exclude 'prop-types.js' ./* dist
8
13
 
9
14
  # #babel component to dist
10
- babel ./dist -d dist --copy-files
15
+ #babel ./dist -d dist --copy-files
11
16
 
12
17
  #copy option
13
18
  #cp -r ./src/ dist
@@ -18,4 +23,7 @@ babel ./dist -d dist --copy-files
18
23
  cd dist
19
24
  npm publish --access=public
20
25
  cd ..
21
- rm -rf dist
26
+ rm -rf dist
27
+
28
+
29
+ curl -X POST -H 'Content-Type: application/json' 'https://chat.googleapis.com/v1/spaces/AAAAbP8987c/messages?key=AIzaSyDdI0hCZtE6vySjMm-WEfRq3CPzqKqqsHI&token=UGSFRvk_oYb9uGsAgs31bVvMm6jDkmD8zihGm3eyaQA%3D&threadKey=JoaXTEYaNNkl' -d '{"text": "@momo-kits/qrcode new version release: '*"$VERSION"*' https://www.npmjs.com/package/@momo-kits/qrcode"}'
@@ -1,139 +0,0 @@
1
- import React, { Component } from 'react';
2
- import {
3
- requireNativeComponent,
4
- ViewPropTypes,
5
- findNodeHandle,
6
- UIManager
7
- } from 'react-native';
8
- import PropTypes from 'prop-types';
9
-
10
- const RCTCodeScannerConfig = UIManager.getViewManagerConfig('RCTCodeScanner');
11
- const RCTCodeScannerConstants = RCTCodeScannerConfig.Constants;
12
- const RCTCodeScannerCommands = RCTCodeScannerConfig.Commands;
13
- const RCTCodeScannerView = requireNativeComponent('RCTCodeScanner');
14
-
15
- /** Define QRCodeScanner wrapper to native */
16
- class QRCodeScanner extends Component {
17
- constructor(props) {
18
- super(props);
19
- }
20
-
21
- _setRef = (component) => {
22
- this._component = component;
23
- };
24
-
25
- readImageQRCode = (base64) => {
26
- const obj = findNodeHandle(this);
27
- const commandId = RCTCodeScannerCommands.readImageQRCode;
28
- if (obj != null && commandId != null) {
29
- UIManager.dispatchViewManagerCommand(
30
- obj,
31
- commandId,
32
- [base64],
33
- );
34
- }
35
- }
36
-
37
- startCamera = () => {
38
- const obj = findNodeHandle(this);
39
- const commandId = RCTCodeScannerCommands.startCamera;
40
- if (obj != null && commandId != null) {
41
- UIManager.dispatchViewManagerCommand(
42
- obj,
43
- commandId,
44
- [],
45
- );
46
- }
47
- }
48
-
49
- stopCamera = () => {
50
- const obj = findNodeHandle(this);
51
- const commandId = RCTCodeScannerCommands.stopCamera;
52
- if (obj != null && commandId != null) {
53
- UIManager.dispatchViewManagerCommand(
54
- obj,
55
- commandId,
56
- [],
57
- );
58
- }
59
- }
60
-
61
- setNativeProps = (props) => {
62
- const nativeProps = convertNativeProps(props);
63
- if (this._component) {
64
- this._component.setNativeProps(nativeProps);
65
- }
66
- }
67
-
68
- onBarCodeRead = ({ nativeEvent }) => {
69
- if (
70
- this._lastEvent
71
- && JSON.stringify(nativeEvent) === this._lastEvent
72
- && new Date() - this._lastEventTime < EventThrottleMs
73
- ) {
74
- return;
75
- }
76
- const { onBarCodeRead } = this.props;
77
- if (typeof onBarCodeRead === 'function') {
78
- onBarCodeRead(nativeEvent);
79
- this._lastEvent = JSON.stringify(nativeEvent);
80
- this._lastEventTime = new Date();
81
- }
82
- };
83
-
84
- onPressFlash = (torchMode) => {
85
- this.setNativeProps({
86
- torchMode
87
- });
88
- };
89
-
90
- render() {
91
- const { customFinder } = this.props;
92
- const nativeProps = convertNativeProps(this.props);
93
- return (
94
- <RCTCodeScannerView
95
- {...nativeProps}
96
- ref={this._setRef}
97
- onBarCodeRead={this.onBarCodeRead}
98
- >
99
- {customFinder && customFinder()}
100
- </RCTCodeScannerView>
101
- );
102
- }
103
- }
104
-
105
- const convertNativeProps = (props) => {
106
- const newProps = { ...props };
107
- if (typeof props.torchMode === 'string') {
108
- newProps.torchMode = QRCodeScanner.Constants.TorchMode[props.torchMode];
109
- }
110
- if (typeof props.type === 'string') {
111
- newProps.type = QRCodeScanner.Constants.Type[props.type];
112
- }
113
- return newProps;
114
- };
115
-
116
- QRCodeScanner.propTypes = {
117
- ...ViewPropTypes,
118
- onBarCodeRead: PropTypes.func,
119
- barCodeTypes: PropTypes.array,
120
- torchMode: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
121
- type: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
122
- };
123
-
124
- QRCodeScanner.Constants = {
125
- BarCodeType: RCTCodeScannerConstants.BarCodeType,
126
- Type: RCTCodeScannerConstants.Type,
127
- TorchMode: RCTCodeScannerConstants.TorchMode,
128
- };
129
-
130
- QRCodeScanner.defaultProps = {
131
- type: RCTCodeScannerConstants.Type.back,
132
- torchMode: RCTCodeScannerConstants.TorchMode.off,
133
- barCodeTypes: Object.values(RCTCodeScannerConstants.BarCodeType),
134
- };
135
-
136
- /** Define throttlems variables or constants */
137
- const EventThrottleMs = 500;
138
-
139
- export default QRCodeScanner;