增加扫码
This commit is contained in:
parent
6db63f34d1
commit
64971f325f
@ -35,7 +35,7 @@
|
||||
|
||||
id<RenderPluginDelegate> _renderDelegate;
|
||||
}
|
||||
+(void)toWallet:(NSString *)url;
|
||||
|
||||
// override it to add your render plugin delegate
|
||||
- (void)shouldAttachRenderDelegate;
|
||||
|
||||
|
@ -148,10 +148,6 @@ static NSString *const kBgTaskName = @"cebg.AppRunInBackground";
|
||||
UnitySetPlayerFocus(1);
|
||||
}
|
||||
|
||||
+(void)toWallet:(NSString *)url{
|
||||
UIApplication *app = [UIApplication sharedApplication];
|
||||
[app openURL:[NSURL URLWithString:url]];
|
||||
}
|
||||
|
||||
extern "C" void UnityDestroyDisplayLink()
|
||||
{
|
||||
|
@ -14,6 +14,7 @@
|
||||
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_MAC)
|
||||
#include "AppDelegate.h"
|
||||
#import "UIViewController+Wallet.h"
|
||||
#endif
|
||||
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
|
||||
@ -220,9 +221,27 @@ bool jsb_wallet_callback(se::State& s) {
|
||||
}
|
||||
SE_BIND_FUNC(jsb_wallet_callback)
|
||||
|
||||
bool jsb_scanQRCode(se::State& s) {
|
||||
const auto& args = s.args();
|
||||
size_t argc = args.size();
|
||||
if (argc >= 1) {
|
||||
bool ok;
|
||||
std::string title;
|
||||
ok = seval_to_std_string(args[0], &title);
|
||||
SE_PRECONDITION2(ok, false, "Error processing arguments");
|
||||
NSString *ntitle = [NSString stringWithCString:title.c_str() encoding:NSUTF8StringEncoding];
|
||||
UIWindow* window = [[[UIApplication sharedApplication] delegate] window];
|
||||
[window.rootViewController scanQRCode:ntitle];
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
SE_BIND_FUNC(jsb_scanQRCode)
|
||||
|
||||
bool jsb_register_walletevent_modules(se::Object* global) {
|
||||
getOrCreatePlainObject_r("jsb", global, &__jsbObj);
|
||||
__jsbObj->defineFunction("jcCallback", _SE(jsb_wallet_callback));
|
||||
__jsbObj->defineFunction("scanQRCode", _SE(jsb_scanQRCode));
|
||||
return true;
|
||||
}
|
||||
|
18
Classes_cocos/UIViewController+Wallet.h
Normal file
18
Classes_cocos/UIViewController+Wallet.h
Normal file
@ -0,0 +1,18 @@
|
||||
//
|
||||
// UIViewController+Wallet.h
|
||||
// Unity-iPhone
|
||||
//
|
||||
// Created by zhl on 2022/9/1.
|
||||
//
|
||||
|
||||
#pragma once
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
|
||||
@interface UIViewController (Wallet)
|
||||
|
||||
+(void)toWallet:(NSString *)url;
|
||||
-(void)scanQRCode:(NSString *)title;
|
||||
|
||||
@end
|
53
Classes_cocos/UIViewController+Wallet.mm
Normal file
53
Classes_cocos/UIViewController+Wallet.mm
Normal file
@ -0,0 +1,53 @@
|
||||
//
|
||||
// UIViewController+Wallet.m
|
||||
// Unity-iPhone
|
||||
//
|
||||
// Created by zhl on 2022/9/1.
|
||||
//
|
||||
|
||||
#import "UIViewController+Wallet.h"
|
||||
#import "QRCodeReaderViewController.h"
|
||||
#import "QRCodeReader.h"
|
||||
#import "QRCodeReaderDelegate.h"
|
||||
|
||||
|
||||
@implementation UIViewController (Wallet)
|
||||
|
||||
+(void)toWallet:(NSString *)url{
|
||||
UIApplication *app = [UIApplication sharedApplication];
|
||||
[app openURL:[NSURL URLWithString:url]];
|
||||
}
|
||||
|
||||
-(void)scanQRCode:(NSString *)title{
|
||||
NSLog(@"scanQRCode: %@", title);
|
||||
if ([QRCodeReader supportsMetadataObjectTypes:@[AVMetadataObjectTypeQRCode]]) {
|
||||
static QRCodeReaderViewController *vc = nil;
|
||||
static dispatch_once_t onceToken;
|
||||
|
||||
// dispatch_once(&onceToken, ^{
|
||||
//
|
||||
// });
|
||||
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
// if we are active again, we don't need to do this anymore
|
||||
QRCodeReader *reader = [QRCodeReader readerWithMetadataObjectTypes:@[AVMetadataObjectTypeQRCode]];
|
||||
vc = [QRCodeReaderViewController readerWithCancelButtonTitle:@"Cancel" codeReader:reader startScanningAtLoad:YES showSwitchCameraButton:YES showTorchButton:YES];
|
||||
vc.modalPresentationStyle = UIModalPresentationFormSheet;
|
||||
|
||||
[vc setCompletionWithBlock:^(NSString *resultAsString) {
|
||||
NSLog(@"Completion with result: %@", resultAsString);
|
||||
[self dismissViewControllerAnimated:YES completion:^{
|
||||
}];
|
||||
}];
|
||||
[self presentViewController:vc animated:YES completion:NULL];
|
||||
});
|
||||
}
|
||||
else {
|
||||
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error" message:@"Reader not supported by the current device" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
|
||||
|
||||
[alert show];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@end
|
@ -2,6 +2,8 @@
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>NSCameraUsageDescription</key>
|
||||
<string>The camera is need to scan QR codes</string>
|
||||
<key>UIApplicationExitsOnSuspend</key>
|
||||
<false/>
|
||||
<key>CADisableMinimumFrameDuration</key>
|
||||
|
66
QRCodeReaderViewController/QRCameraSwitchButton.h
Normal file
66
QRCodeReaderViewController/QRCameraSwitchButton.h
Normal file
@ -0,0 +1,66 @@
|
||||
/*
|
||||
* QRCodeReaderViewController
|
||||
*
|
||||
* Copyright 2014-present Yannick Loriot.
|
||||
* http://yannickloriot.com
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*
|
||||
*/
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
/**
|
||||
* The camera switch button.
|
||||
* @since 2.0.0
|
||||
*/
|
||||
@interface QRCameraSwitchButton : UIButton
|
||||
|
||||
#pragma mark - Managing Properties
|
||||
/** @name Managing Properties */
|
||||
|
||||
/**
|
||||
* @abstract The edge color of the drawing.
|
||||
* @discussion The default color is the white.
|
||||
* @since 2.0.0
|
||||
*/
|
||||
@property (nonatomic, strong) UIColor *edgeColor;
|
||||
|
||||
/**
|
||||
* @abstract The fill color of the drawing.
|
||||
* @discussion The default color is the darkgray.
|
||||
* @since 2.0.0
|
||||
*/
|
||||
@property (nonatomic, strong) UIColor *fillColor;
|
||||
|
||||
/**
|
||||
* @abstract The edge color of the drawing when the button is touched.
|
||||
* @discussion The default color is the white.
|
||||
* @since 2.0.0
|
||||
*/
|
||||
@property (nonatomic, strong) UIColor *edgeHighlightedColor;
|
||||
|
||||
/**
|
||||
* @abstract The fill color of the drawing when the button is touched.
|
||||
* @discussion The default color is the black.
|
||||
* @since 2.0.0
|
||||
*/
|
||||
@property (nonatomic, strong) UIColor *fillHighlightedColor;
|
||||
|
||||
@end
|
197
QRCodeReaderViewController/QRCameraSwitchButton.m
Normal file
197
QRCodeReaderViewController/QRCameraSwitchButton.m
Normal file
@ -0,0 +1,197 @@
|
||||
/*
|
||||
* QRCodeReaderViewController
|
||||
*
|
||||
* Copyright 2014-present Yannick Loriot.
|
||||
* http://yannickloriot.com
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*
|
||||
*/
|
||||
|
||||
#import "QRCameraSwitchButton.h"
|
||||
|
||||
@implementation QRCameraSwitchButton
|
||||
|
||||
- (id)initWithFrame:(CGRect)frame
|
||||
{
|
||||
if ((self = [super initWithFrame:frame])) {
|
||||
_edgeColor = [UIColor whiteColor];
|
||||
_fillColor = [UIColor darkGrayColor];
|
||||
_edgeHighlightedColor = [UIColor whiteColor];
|
||||
_fillHighlightedColor = [UIColor blackColor];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)drawRect:(CGRect)rect
|
||||
{
|
||||
CGFloat width = rect.size.width;
|
||||
CGFloat height = rect.size.height;
|
||||
CGFloat center = width / 2;
|
||||
CGFloat middle = height / 2;
|
||||
|
||||
CGFloat strokeLineWidth = 2;
|
||||
|
||||
// Colors
|
||||
|
||||
UIColor *paintColor = (self.state != UIControlStateHighlighted) ? _fillColor : _fillHighlightedColor;
|
||||
UIColor *strokeColor = (self.state != UIControlStateHighlighted) ? _edgeColor : _edgeHighlightedColor;
|
||||
|
||||
// Camera box
|
||||
|
||||
CGFloat cameraWidth = width * 0.4;
|
||||
CGFloat cameraHeight = cameraWidth * 0.6;
|
||||
CGFloat cameraX = center - cameraWidth / 2;
|
||||
CGFloat cameraY = middle - cameraHeight / 2;
|
||||
CGFloat cameraRadius = cameraWidth / 80;
|
||||
|
||||
UIBezierPath *boxPath = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(cameraX, cameraY, cameraWidth, cameraHeight) cornerRadius:cameraRadius];
|
||||
|
||||
// Camera lens
|
||||
|
||||
CGFloat outerLensSize = cameraHeight * 0.8;
|
||||
CGFloat outerLensX = center - outerLensSize / 2;
|
||||
CGFloat outerLensY = middle - outerLensSize / 2;
|
||||
|
||||
CGFloat innerLensSize = outerLensSize * 0.7;
|
||||
CGFloat innerLensX = center - innerLensSize / 2;
|
||||
CGFloat innerLensY = middle - innerLensSize / 2;
|
||||
|
||||
UIBezierPath *outerLensPath = [UIBezierPath bezierPathWithOvalInRect:CGRectMake(outerLensX, outerLensY, outerLensSize, outerLensSize)];
|
||||
UIBezierPath *innerLensPath = [UIBezierPath bezierPathWithOvalInRect:CGRectMake(innerLensX, innerLensY, innerLensSize, innerLensSize)];
|
||||
|
||||
// Draw flash box
|
||||
|
||||
CGFloat flashBoxWidth = cameraWidth * 0.8;
|
||||
CGFloat flashBoxHeight = cameraHeight * 0.17;
|
||||
CGFloat flashBoxDeltaWidth = flashBoxWidth * 0.14;
|
||||
CGFloat flashLeftMostX = cameraX + (cameraWidth - flashBoxWidth) * 0.5;
|
||||
CGFloat flashBottomMostY = cameraY;
|
||||
|
||||
UIBezierPath *flashPath = [UIBezierPath bezierPath];
|
||||
[flashPath moveToPoint:CGPointMake(flashLeftMostX, flashBottomMostY)];
|
||||
[flashPath addLineToPoint:CGPointMake(flashLeftMostX + flashBoxWidth, flashBottomMostY)];
|
||||
[flashPath addLineToPoint:CGPointMake(flashLeftMostX + flashBoxWidth - flashBoxDeltaWidth, flashBottomMostY - flashBoxHeight)];
|
||||
[flashPath addLineToPoint:CGPointMake(flashLeftMostX + flashBoxDeltaWidth, flashBottomMostY - flashBoxHeight)];
|
||||
[flashPath closePath];
|
||||
|
||||
flashPath.lineCapStyle = kCGLineCapRound;
|
||||
flashPath.lineJoinStyle = kCGLineJoinRound;
|
||||
|
||||
// Arrows
|
||||
|
||||
CGFloat arrowHeadHeigth = cameraHeight * 0.5;
|
||||
CGFloat arrowHeadWidth = ((width - cameraWidth) / 2) * 0.3;
|
||||
CGFloat arrowTailHeigth = arrowHeadHeigth * 0.6;
|
||||
CGFloat arrowTailWidth = ((width - cameraWidth) / 2) * 0.7;
|
||||
|
||||
// Draw left arrow
|
||||
|
||||
CGFloat arrowLeftX = center - cameraWidth * 0.2;
|
||||
CGFloat arrowLeftY = middle + cameraHeight * 0.45;
|
||||
|
||||
UIBezierPath *leftArrowPath = [UIBezierPath bezierPath];
|
||||
[leftArrowPath moveToPoint:CGPointMake(arrowLeftX, arrowLeftY)];
|
||||
[leftArrowPath addLineToPoint:CGPointMake(arrowLeftX - arrowHeadWidth, arrowLeftY - arrowHeadHeigth / 2)];
|
||||
[leftArrowPath addLineToPoint:CGPointMake(arrowLeftX - arrowHeadWidth, arrowLeftY - arrowTailHeigth / 2)];
|
||||
[leftArrowPath addLineToPoint:CGPointMake(arrowLeftX - arrowHeadWidth - arrowTailWidth, arrowLeftY - arrowTailHeigth / 2)];
|
||||
[leftArrowPath addLineToPoint:CGPointMake(arrowLeftX - arrowHeadWidth - arrowTailWidth, arrowLeftY + arrowTailHeigth / 2)];
|
||||
[leftArrowPath addLineToPoint:CGPointMake(arrowLeftX - arrowHeadWidth, arrowLeftY + arrowTailHeigth / 2)];
|
||||
[leftArrowPath addLineToPoint:CGPointMake(arrowLeftX - arrowHeadWidth, arrowLeftY + arrowHeadHeigth / 2)];
|
||||
[leftArrowPath closePath];
|
||||
|
||||
// Right arrow
|
||||
|
||||
CGFloat arrowRightX = center + cameraWidth * 0.2;
|
||||
CGFloat arrowRightY = middle + cameraHeight * 0.60;
|
||||
|
||||
UIBezierPath *rigthArrowPath = [UIBezierPath bezierPath];
|
||||
[rigthArrowPath moveToPoint:CGPointMake(arrowRightX, arrowRightY)];
|
||||
[rigthArrowPath addLineToPoint:CGPointMake(arrowRightX + arrowHeadWidth, arrowRightY - arrowHeadHeigth / 2)];
|
||||
[rigthArrowPath addLineToPoint:CGPointMake(arrowRightX + arrowHeadWidth, arrowRightY - arrowTailHeigth / 2)];
|
||||
[rigthArrowPath addLineToPoint:CGPointMake(arrowRightX + arrowHeadWidth + arrowTailWidth, arrowRightY - arrowTailHeigth / 2)];
|
||||
[rigthArrowPath addLineToPoint:CGPointMake(arrowRightX + arrowHeadWidth + arrowTailWidth, arrowRightY + arrowTailHeigth / 2)];
|
||||
[rigthArrowPath addLineToPoint:CGPointMake(arrowRightX + arrowHeadWidth, arrowRightY + arrowTailHeigth / 2)];
|
||||
[rigthArrowPath addLineToPoint:CGPointMake(arrowRightX + arrowHeadWidth, arrowRightY + arrowHeadHeigth / 2)];
|
||||
[rigthArrowPath closePath];
|
||||
|
||||
// Drawing
|
||||
|
||||
[paintColor setFill];
|
||||
[rigthArrowPath fill];
|
||||
[strokeColor setStroke];
|
||||
rigthArrowPath.lineWidth = strokeLineWidth;
|
||||
[rigthArrowPath stroke];
|
||||
|
||||
[paintColor setFill];
|
||||
[boxPath fill];
|
||||
[strokeColor setStroke];
|
||||
boxPath.lineWidth = strokeLineWidth;
|
||||
[boxPath stroke];
|
||||
|
||||
[strokeColor setFill];
|
||||
[outerLensPath fill];
|
||||
|
||||
[paintColor setFill];
|
||||
[innerLensPath fill];
|
||||
|
||||
[paintColor setFill];
|
||||
[flashPath fill];
|
||||
[strokeColor setStroke];
|
||||
flashPath.lineWidth = strokeLineWidth;
|
||||
[flashPath stroke];
|
||||
|
||||
[paintColor setFill];
|
||||
[leftArrowPath fill];
|
||||
[strokeColor setStroke];
|
||||
leftArrowPath.lineWidth = strokeLineWidth;
|
||||
[leftArrowPath stroke];
|
||||
}
|
||||
|
||||
// MARK: - UIResponder Methods
|
||||
|
||||
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
|
||||
{
|
||||
[super touchesBegan:touches withEvent:event];
|
||||
|
||||
[self setNeedsDisplay];
|
||||
}
|
||||
|
||||
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
|
||||
{
|
||||
[super touchesMoved:touches withEvent:event];
|
||||
|
||||
[self setNeedsDisplay];
|
||||
}
|
||||
|
||||
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
|
||||
{
|
||||
[super touchesEnded:touches withEvent:event];
|
||||
|
||||
[self setNeedsDisplay];
|
||||
}
|
||||
|
||||
- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event
|
||||
{
|
||||
[super touchesCancelled:touches withEvent:event];
|
||||
|
||||
[self setNeedsDisplay];
|
||||
}
|
||||
|
||||
@end
|
203
QRCodeReaderViewController/QRCodeReader.h
Normal file
203
QRCodeReaderViewController/QRCodeReader.h
Normal file
@ -0,0 +1,203 @@
|
||||
/*
|
||||
* QRCodeReader
|
||||
*
|
||||
* Copyright 2014-present Yannick Loriot.
|
||||
* http://yannickloriot.com
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*
|
||||
*/
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <AVFoundation/AVFoundation.h>
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
/**
|
||||
* Reader object base on the `AVCaptureDevice` to read / scan 1D and 2D codes.
|
||||
*/
|
||||
@interface QRCodeReader : NSObject
|
||||
|
||||
#pragma mark - Creating and Inializing QRCode Readers
|
||||
/** @name Creating and Inializing QRCode Readers */
|
||||
|
||||
/**
|
||||
* @abstract Initializes a reader with the `QRCode` metadata object type.
|
||||
* @since 4.1.0
|
||||
*/
|
||||
- (nonnull id)init;
|
||||
|
||||
/**
|
||||
* @abstract Initializes a reader with a list of metadata object types.
|
||||
* @param metadataObjectTypes An array of strings identifying the types of
|
||||
* metadata objects to process.
|
||||
* @since 3.0.0
|
||||
*/
|
||||
- (nonnull id)initWithMetadataObjectTypes:(nonnull NSArray *)metadataObjectTypes;
|
||||
|
||||
/**
|
||||
* @abstract Creates a reader with a list of metadata object types.
|
||||
* @param metadataObjectTypes An array of strings identifying the types of
|
||||
* metadata objects to process.
|
||||
* @see initWithMetadataObjectTypes:
|
||||
* @since 3.0.0
|
||||
*/
|
||||
+ (nonnull instancetype)readerWithMetadataObjectTypes:(nonnull NSArray *)metadataObjectTypes;
|
||||
|
||||
#pragma mark - Checking the Reader Availabilities
|
||||
/** @name Checking the Reader Availabilities */
|
||||
|
||||
/**
|
||||
* @abstract Returns whether the reader is available with the current device.
|
||||
* @return a Boolean value indicating whether the reader is available.
|
||||
* @since 3.0.0
|
||||
*/
|
||||
+ (BOOL)isAvailable;
|
||||
|
||||
/**
|
||||
* @abstract Checks and return whether the given metadata object types are
|
||||
* supported by the current device.
|
||||
* @return a Boolean value indicating whether the given metadata object types
|
||||
* are supported by the current device.
|
||||
* @since 3.2.0
|
||||
*/
|
||||
+ (BOOL)supportsMetadataObjectTypes:(nonnull NSArray *)metadataObjectTypes;
|
||||
|
||||
#pragma mark - Checking the Metadata Items Types
|
||||
/** @name Checking the Metadata Items Types */
|
||||
|
||||
/**
|
||||
* @abstract An array of strings identifying the types of metadata objects to
|
||||
* process.
|
||||
* @since 3.0.0
|
||||
*/
|
||||
@property (strong, nonatomic, readonly) NSArray * _Nonnull metadataObjectTypes;
|
||||
|
||||
#pragma mark - Viewing the Camera
|
||||
/** @name Viewing the Camera */
|
||||
|
||||
/**
|
||||
* @abstract CALayer that you use to display video as it is being captured
|
||||
* by an input device.
|
||||
* @since 3.0.0
|
||||
*/
|
||||
@property (strong, nonatomic, readonly) AVCaptureVideoPreviewLayer * _Nonnull previewLayer;
|
||||
|
||||
#pragma mark - Controlling the Reader
|
||||
/** @name Controlling the Reader */
|
||||
|
||||
/**
|
||||
* @abstract Starts scanning the codes.
|
||||
* @since 3.0.0
|
||||
*/
|
||||
- (void)startScanning;
|
||||
|
||||
/**
|
||||
* @abstract Stops scanning the codes.
|
||||
* @since 3.0.0
|
||||
*/
|
||||
- (void)stopScanning;
|
||||
|
||||
/**
|
||||
* @abstract Indicates whether the session is currently running.
|
||||
* @discussion The value of this property is a Bool indicating whether the
|
||||
* receiver is running.
|
||||
* Clients can key value observe the value of this property to be notified
|
||||
* when the session automatically starts or stops running.
|
||||
* @since 3.3.0
|
||||
*/
|
||||
- (BOOL)running;
|
||||
|
||||
/**
|
||||
* @abstract Switch between the back and the front camera.
|
||||
* @since 3.0.0
|
||||
*/
|
||||
- (void)switchDeviceInput;
|
||||
|
||||
/**
|
||||
* @abstract Returns true whether a front device is available.
|
||||
* @return true whether a front device is available.
|
||||
* @since 3.0.0
|
||||
*/
|
||||
- (BOOL)hasFrontDevice;
|
||||
|
||||
/**
|
||||
* @abstract Returns true whether a torch is available.
|
||||
* @return true if a torch is available.
|
||||
* @since 4.0.0
|
||||
*/
|
||||
- (BOOL)isTorchAvailable;
|
||||
|
||||
/**
|
||||
* @abstract Toggles torch on the default device.
|
||||
* @since 4.0.0
|
||||
*/
|
||||
- (void)toggleTorch;
|
||||
|
||||
#pragma mark - Getting Inputs and Outputs
|
||||
/** @name Getting Inputs and Outputs */
|
||||
|
||||
/**
|
||||
* @abstract Accessing to the `AVCaptureDeviceInput` object representing
|
||||
* the default device input (generally the back camera).
|
||||
* @since 3.5.0
|
||||
*/
|
||||
@property (readonly) AVCaptureDeviceInput * _Nonnull defaultDeviceInput;
|
||||
|
||||
/**
|
||||
* @abstract Accessing to the `AVCaptureDeviceInput` object representing
|
||||
* the front device input.
|
||||
* @since 3.5.0
|
||||
*/
|
||||
@property (readonly) AVCaptureDeviceInput * _Nullable frontDeviceInput;
|
||||
|
||||
/**
|
||||
* @abstract Accessing to the `AVCaptureMetadataOutput` object.
|
||||
* @discussion It allows you to configure the scanner to restrict the area of
|
||||
* the scan to the overlay one for example.
|
||||
* @since 3.5.0
|
||||
*/
|
||||
@property (readonly) AVCaptureMetadataOutput * _Nonnull metadataOutput;
|
||||
|
||||
#pragma mark - Managing the Orientation
|
||||
/** @name Managing the Orientation */
|
||||
|
||||
/**
|
||||
* @abstract Returns the video orientation correspongind to the given interface
|
||||
* orientation.
|
||||
* @param interfaceOrientation An interface orientation.
|
||||
* @return the video orientation correspongind to the given device orientation.
|
||||
* @since 3.1.0
|
||||
*/
|
||||
+ (AVCaptureVideoOrientation)videoOrientationFromInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation;
|
||||
|
||||
#pragma mark - Managing the Block
|
||||
/** @name Managing the Block */
|
||||
|
||||
/**
|
||||
* @abstract Sets the completion with a block that executes when a QRCode
|
||||
* or when the user did stopped the scan.
|
||||
* @param completionBlock The block to be executed. This block has no
|
||||
* return value and takes one argument: the `resultAsString`. If the user
|
||||
* stop the scan and that there is no response the `resultAsString` argument
|
||||
* is nil.
|
||||
* @since 3.0.0
|
||||
*/
|
||||
- (void)setCompletionWithBlock:(nullable void (^) (NSString * _Nullable resultAsString))completionBlock;
|
||||
|
||||
@end
|
265
QRCodeReaderViewController/QRCodeReader.m
Normal file
265
QRCodeReaderViewController/QRCodeReader.m
Normal file
@ -0,0 +1,265 @@
|
||||
/*
|
||||
* QRCodeReader
|
||||
*
|
||||
* Copyright 2014-present Yannick Loriot.
|
||||
* http://yannickloriot.com
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*
|
||||
*/
|
||||
|
||||
#import "QRCodeReader.h"
|
||||
|
||||
@interface QRCodeReader () <AVCaptureMetadataOutputObjectsDelegate>
|
||||
@property (strong, nonatomic) AVCaptureDevice *defaultDevice;
|
||||
@property (strong, nonatomic) AVCaptureDeviceInput *defaultDeviceInput;
|
||||
@property (strong, nonatomic) AVCaptureDevice *frontDevice;
|
||||
@property (strong, nonatomic) AVCaptureDeviceInput *frontDeviceInput;
|
||||
@property (strong, nonatomic) AVCaptureMetadataOutput *metadataOutput;
|
||||
@property (strong, nonatomic) AVCaptureSession *session;
|
||||
@property (strong, nonatomic) AVCaptureVideoPreviewLayer *previewLayer;
|
||||
|
||||
@property (copy, nonatomic) void (^completionBlock) (NSString *);
|
||||
|
||||
@end
|
||||
|
||||
@implementation QRCodeReader
|
||||
|
||||
- (id)init
|
||||
{
|
||||
if ((self = [super init])) {
|
||||
_metadataObjectTypes = @[AVMetadataObjectTypeQRCode];
|
||||
|
||||
[self setupAVComponents];
|
||||
[self configureDefaultComponents];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (id)initWithMetadataObjectTypes:(NSArray *)metadataObjectTypes
|
||||
{
|
||||
if ((self = [super init])) {
|
||||
_metadataObjectTypes = metadataObjectTypes;
|
||||
|
||||
[self setupAVComponents];
|
||||
[self configureDefaultComponents];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
+ (instancetype)readerWithMetadataObjectTypes:(NSArray *)metadataObjectTypes
|
||||
{
|
||||
return [[self alloc] initWithMetadataObjectTypes:metadataObjectTypes];
|
||||
}
|
||||
|
||||
#pragma mark - Initializing the AV Components
|
||||
|
||||
- (void)setupAVComponents
|
||||
{
|
||||
self.defaultDevice = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];
|
||||
|
||||
if (_defaultDevice) {
|
||||
self.defaultDeviceInput = [AVCaptureDeviceInput deviceInputWithDevice:_defaultDevice error:nil];
|
||||
self.metadataOutput = [[AVCaptureMetadataOutput alloc] init];
|
||||
self.session = [[AVCaptureSession alloc] init];
|
||||
self.previewLayer = [AVCaptureVideoPreviewLayer layerWithSession:self.session];
|
||||
|
||||
for (AVCaptureDevice *device in [AVCaptureDevice devicesWithMediaType:AVMediaTypeVideo]) {
|
||||
if (device.position == AVCaptureDevicePositionFront) {
|
||||
self.frontDevice = device;
|
||||
}
|
||||
}
|
||||
|
||||
if (_frontDevice) {
|
||||
self.frontDeviceInput = [AVCaptureDeviceInput deviceInputWithDevice:_frontDevice error:nil];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)configureDefaultComponents
|
||||
{
|
||||
[_session addOutput:_metadataOutput];
|
||||
|
||||
if (_defaultDeviceInput) {
|
||||
[_session addInput:_defaultDeviceInput];
|
||||
}
|
||||
|
||||
[_metadataOutput setMetadataObjectsDelegate:self queue:dispatch_get_main_queue()];
|
||||
NSMutableSet *available = [NSMutableSet setWithArray:[_metadataOutput availableMetadataObjectTypes]];
|
||||
NSSet *desired = [NSSet setWithArray:_metadataObjectTypes];
|
||||
[available intersectSet:desired];
|
||||
[_metadataOutput setMetadataObjectTypes:available.allObjects];
|
||||
[_previewLayer setVideoGravity:AVLayerVideoGravityResizeAspectFill];
|
||||
}
|
||||
|
||||
- (void)switchDeviceInput
|
||||
{
|
||||
if (_frontDeviceInput) {
|
||||
[_session beginConfiguration];
|
||||
|
||||
AVCaptureDeviceInput *currentInput = [_session.inputs firstObject];
|
||||
[_session removeInput:currentInput];
|
||||
|
||||
AVCaptureDeviceInput *newDeviceInput = (currentInput.device.position == AVCaptureDevicePositionFront) ? _defaultDeviceInput : _frontDeviceInput;
|
||||
[_session addInput:newDeviceInput];
|
||||
|
||||
[_session commitConfiguration];
|
||||
}
|
||||
}
|
||||
|
||||
- (BOOL)hasFrontDevice
|
||||
{
|
||||
return _frontDevice != nil;
|
||||
}
|
||||
|
||||
- (BOOL)isTorchAvailable
|
||||
{
|
||||
return _defaultDevice.hasTorch;
|
||||
}
|
||||
|
||||
- (void)toggleTorch
|
||||
{
|
||||
NSError *error = nil;
|
||||
|
||||
[_defaultDevice lockForConfiguration:&error];
|
||||
|
||||
if (error == nil) {
|
||||
AVCaptureTorchMode mode = _defaultDevice.torchMode;
|
||||
|
||||
_defaultDevice.torchMode = mode == AVCaptureTorchModeOn ? AVCaptureTorchModeOff : AVCaptureTorchModeOn;
|
||||
}
|
||||
|
||||
[_defaultDevice unlockForConfiguration];
|
||||
}
|
||||
|
||||
#pragma mark - Controlling Reader
|
||||
|
||||
- (void)startScanning
|
||||
{
|
||||
if (![self.session isRunning]) {
|
||||
[self.session startRunning];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)stopScanning
|
||||
{
|
||||
if ([self.session isRunning]) {
|
||||
[self.session stopRunning];
|
||||
}
|
||||
}
|
||||
|
||||
- (BOOL)running {
|
||||
return self.session.running;
|
||||
}
|
||||
|
||||
#pragma mark - Managing the Orientation
|
||||
|
||||
+ (AVCaptureVideoOrientation)videoOrientationFromInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
|
||||
{
|
||||
switch (interfaceOrientation) {
|
||||
case UIInterfaceOrientationLandscapeLeft:
|
||||
return AVCaptureVideoOrientationLandscapeLeft;
|
||||
case UIInterfaceOrientationLandscapeRight:
|
||||
return AVCaptureVideoOrientationLandscapeRight;
|
||||
case UIInterfaceOrientationPortrait:
|
||||
return AVCaptureVideoOrientationPortrait;
|
||||
default:
|
||||
return AVCaptureVideoOrientationPortraitUpsideDown;
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - Checking the Reader Availabilities
|
||||
|
||||
+ (BOOL)isAvailable
|
||||
{
|
||||
@autoreleasepool {
|
||||
AVCaptureDevice *captureDevice = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];
|
||||
|
||||
if (!captureDevice) {
|
||||
return NO;
|
||||
}
|
||||
|
||||
NSError *error;
|
||||
AVCaptureDeviceInput *deviceInput = [AVCaptureDeviceInput deviceInputWithDevice:captureDevice error:&error];
|
||||
|
||||
if (!deviceInput || error) {
|
||||
return NO;
|
||||
}
|
||||
|
||||
return YES;
|
||||
}
|
||||
}
|
||||
|
||||
+ (BOOL)supportsMetadataObjectTypes:(NSArray *)metadataObjectTypes
|
||||
{
|
||||
if (![self isAvailable]) {
|
||||
return NO;
|
||||
}
|
||||
|
||||
@autoreleasepool {
|
||||
// Setup components
|
||||
AVCaptureDevice *captureDevice = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];
|
||||
AVCaptureDeviceInput *deviceInput = [AVCaptureDeviceInput deviceInputWithDevice:captureDevice error:nil];
|
||||
AVCaptureMetadataOutput *output = [[AVCaptureMetadataOutput alloc] init];
|
||||
AVCaptureSession *session = [[AVCaptureSession alloc] init];
|
||||
|
||||
[session addInput:deviceInput];
|
||||
[session addOutput:output];
|
||||
|
||||
if (metadataObjectTypes == nil || metadataObjectTypes.count == 0) {
|
||||
// Check the QRCode metadata object type by default
|
||||
metadataObjectTypes = @[AVMetadataObjectTypeQRCode];
|
||||
}
|
||||
|
||||
for (NSString *metadataObjectType in metadataObjectTypes) {
|
||||
if (![output.availableMetadataObjectTypes containsObject:metadataObjectType]) {
|
||||
return NO;
|
||||
}
|
||||
}
|
||||
|
||||
return YES;
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - Managing the Block
|
||||
|
||||
- (void)setCompletionWithBlock:(void (^) (NSString *resultAsString))completionBlock
|
||||
{
|
||||
self.completionBlock = completionBlock;
|
||||
}
|
||||
|
||||
#pragma mark - AVCaptureMetadataOutputObjects Delegate Methods
|
||||
|
||||
- (void)captureOutput:(AVCaptureOutput *)captureOutput didOutputMetadataObjects:(NSArray *)metadataObjects fromConnection:(AVCaptureConnection *)connection
|
||||
{
|
||||
for (AVMetadataObject *current in metadataObjects) {
|
||||
if ([current isKindOfClass:[AVMetadataMachineReadableCodeObject class]]
|
||||
&& [_metadataObjectTypes containsObject:current.type]) {
|
||||
NSString *scannedResult = [(AVMetadataMachineReadableCodeObject *)current stringValue];
|
||||
|
||||
if (_completionBlock) {
|
||||
_completionBlock(scannedResult);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
59
QRCodeReaderViewController/QRCodeReaderDelegate.h
Normal file
59
QRCodeReaderViewController/QRCodeReaderDelegate.h
Normal file
@ -0,0 +1,59 @@
|
||||
/*
|
||||
* QRCodeReaderViewController
|
||||
*
|
||||
* Copyright 2014-present Yannick Loriot.
|
||||
* http://yannickloriot.com
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*
|
||||
*/
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
@class QRCodeReaderViewController;
|
||||
|
||||
/**
|
||||
* This protocol defines delegate methods for objects that implements the
|
||||
* `QRCodeReaderDelegate`. The methods of the protocol allow the delegate to be
|
||||
* notified when the reader did scan result and or when the user wants to stop
|
||||
* to read some QRCodes.
|
||||
*/
|
||||
@protocol QRCodeReaderDelegate <NSObject>
|
||||
|
||||
@optional
|
||||
|
||||
#pragma mark - Listening for Reader Status
|
||||
/** @name Listening for Reader Status */
|
||||
|
||||
/**
|
||||
* @abstract Tells the delegate that the reader did scan a QRCode.
|
||||
* @param reader The reader view controller that scanned a QRCode.
|
||||
* @param result The content of the QRCode as a string.
|
||||
* @since 1.0.0
|
||||
*/
|
||||
- (void)reader:(QRCodeReaderViewController *)reader didScanResult:(NSString *)result;
|
||||
|
||||
/**
|
||||
* @abstract Tells the delegate that the user wants to stop scanning QRCodes.
|
||||
* @param reader The reader view controller that the user wants to stop.
|
||||
* @since 1.0.0
|
||||
*/
|
||||
- (void)readerDidCancel:(QRCodeReaderViewController *)reader;
|
||||
|
||||
@end
|
36
QRCodeReaderViewController/QRCodeReaderView.h
Normal file
36
QRCodeReaderViewController/QRCodeReaderView.h
Normal file
@ -0,0 +1,36 @@
|
||||
/*
|
||||
* QRCodeReaderViewController
|
||||
*
|
||||
* Copyright 2014-present Yannick Loriot.
|
||||
* http://yannickloriot.com
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*
|
||||
*/
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
/**
|
||||
* Overlay over the camera view to display the area (a square) where to scan the
|
||||
* code.
|
||||
* @since 2.0.0
|
||||
*/
|
||||
@interface QRCodeReaderView : UIView
|
||||
|
||||
@end
|
80
QRCodeReaderViewController/QRCodeReaderView.m
Normal file
80
QRCodeReaderViewController/QRCodeReaderView.m
Normal file
@ -0,0 +1,80 @@
|
||||
/*
|
||||
* QRCodeReaderViewController
|
||||
*
|
||||
* Copyright 2014-present Yannick Loriot.
|
||||
* http://yannickloriot.com
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*
|
||||
*/
|
||||
|
||||
#import "QRCodeReaderView.h"
|
||||
|
||||
@interface QRCodeReaderView ()
|
||||
@property (nonatomic, strong) CAShapeLayer *overlay;
|
||||
|
||||
@end
|
||||
|
||||
@implementation QRCodeReaderView
|
||||
|
||||
- (id)initWithFrame:(CGRect)frame
|
||||
{
|
||||
if ((self = [super initWithFrame:frame])) {
|
||||
[self addOverlay];
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)drawRect:(CGRect)rect
|
||||
{
|
||||
CGRect innerRect = CGRectInset(rect, 50, 50);
|
||||
|
||||
CGFloat minSize = MIN(innerRect.size.width, innerRect.size.height);
|
||||
if (innerRect.size.width != minSize) {
|
||||
innerRect.origin.x += (innerRect.size.width - minSize) / 2;
|
||||
innerRect.size.width = minSize;
|
||||
}
|
||||
else if (innerRect.size.height != minSize) {
|
||||
innerRect.origin.y += (innerRect.size.height - minSize) / 2;
|
||||
innerRect.size.height = minSize;
|
||||
}
|
||||
|
||||
CGRect offsetRect = CGRectOffset(innerRect, 0, 15);
|
||||
|
||||
|
||||
_overlay.path = [UIBezierPath bezierPathWithRoundedRect:offsetRect cornerRadius:5].CGPath;
|
||||
}
|
||||
|
||||
#pragma mark - Private Methods
|
||||
|
||||
- (void)addOverlay
|
||||
{
|
||||
_overlay = [[CAShapeLayer alloc] init];
|
||||
_overlay.backgroundColor = [UIColor clearColor].CGColor;
|
||||
_overlay.fillColor = [UIColor clearColor].CGColor;
|
||||
_overlay.strokeColor = [UIColor whiteColor].CGColor;
|
||||
_overlay.lineWidth = 3;
|
||||
_overlay.lineDashPattern = @[@7.0, @7.0];
|
||||
_overlay.lineDashPhase = 0;
|
||||
|
||||
[self.layer addSublayer:_overlay];
|
||||
}
|
||||
|
||||
@end
|
219
QRCodeReaderViewController/QRCodeReaderViewController.h
Normal file
219
QRCodeReaderViewController/QRCodeReaderViewController.h
Normal file
@ -0,0 +1,219 @@
|
||||
/*
|
||||
* QRCodeReaderViewController
|
||||
*
|
||||
* Copyright 2014-present Yannick Loriot.
|
||||
* http://yannickloriot.com
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*
|
||||
*/
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import "QRCodeReaderDelegate.h"
|
||||
#import "QRCodeReader.h"
|
||||
|
||||
/**
|
||||
* Convenient controller to display a view to scan/read 1D or 2D bar codes like
|
||||
* the QRCodes. It is based on the `AVFoundation` framework from Apple. It aims
|
||||
* to replace ZXing or ZBar for iOS 7 and over.
|
||||
*/
|
||||
@interface QRCodeReaderViewController : UIViewController
|
||||
|
||||
#pragma mark - Creating and Inializing QRCodeReader Controllers
|
||||
/** @name Creating and Inializing QRCode Reader Controllers */
|
||||
|
||||
/**
|
||||
* @abstract Initializes a view controller to read QRCodes from a displayed
|
||||
* video preview and a cancel button to be go back.
|
||||
* @param cancelTitle The title of the cancel button.
|
||||
* @discussion This convenient method is used to instanciate a reader with
|
||||
* only one supported metadata object types: the QRCode.
|
||||
* @see initWithCancelButtonTitle:metadataObjectTypes:
|
||||
* @since 1.0.0
|
||||
*/
|
||||
- (nonnull id)initWithCancelButtonTitle:(nullable NSString *)cancelTitle;
|
||||
|
||||
/**
|
||||
* @abstract Creates a view controller to read QRCodes from a displayed
|
||||
* video preview and a cancel button to be go back.
|
||||
* @param cancelTitle The title of the cancel button.
|
||||
* @see initWithCancelButtonTitle:
|
||||
* @since 1.0.0
|
||||
*/
|
||||
+ (nonnull instancetype)readerWithCancelButtonTitle:(nullable NSString *)cancelTitle;
|
||||
|
||||
/**
|
||||
* @abstract Initializes a reader view controller with a list of metadata
|
||||
* object types.
|
||||
* @param metadataObjectTypes An array of strings identifying the types of
|
||||
* metadata objects to process.
|
||||
* @see initWithCancelButtonTitle:metadataObjectTypes:
|
||||
* @since 3.0.0
|
||||
*/
|
||||
- (nonnull id)initWithMetadataObjectTypes:(nonnull NSArray *)metadataObjectTypes;
|
||||
|
||||
/**
|
||||
* @abstract Creates a reader view controller with a list of metadata object
|
||||
* types.
|
||||
* @param metadataObjectTypes An array of strings identifying the types of
|
||||
* metadata objects to process.
|
||||
* @see initWithMetadataObjectTypes:
|
||||
* @since 3.0.0
|
||||
*/
|
||||
+ (nonnull instancetype)readerWithMetadataObjectTypes:(nonnull NSArray *)metadataObjectTypes;
|
||||
|
||||
/**
|
||||
* @abstract Initializes a view controller to read wanted metadata object
|
||||
* types from a displayed video preview and a cancel button to be go back.
|
||||
* @param cancelTitle The title of the cancel button.
|
||||
* @param metadataObjectTypes The type (“symbology”) of barcode to scan.
|
||||
* @see initWithCancelButtonTitle:codeReader:
|
||||
* @since 2.0.0
|
||||
*/
|
||||
- (nonnull id)initWithCancelButtonTitle:(nullable NSString *)cancelTitle metadataObjectTypes:(nonnull NSArray *)metadataObjectTypes;
|
||||
|
||||
/**
|
||||
* @abstract Creates a view controller to read wanted metadata object types
|
||||
* from a displayed video preview and a cancel button to be go back.
|
||||
* @param cancelTitle The title of the cancel button.
|
||||
* @param metadataObjectTypes The type (“symbology”) of barcode to scan.
|
||||
* @see initWithCancelButtonTitle:metadataObjectTypes:
|
||||
* @since 2.0.0
|
||||
*/
|
||||
+ (nonnull instancetype)readerWithCancelButtonTitle:(nullable NSString *)cancelTitle metadataObjectTypes:(nonnull NSArray *)metadataObjectTypes;
|
||||
|
||||
/**
|
||||
* @abstract Initializes a view controller using a cancel button title and
|
||||
* a code reader.
|
||||
* @param cancelTitle The title of the cancel button.
|
||||
* @param codeReader The reader to decode the codes.
|
||||
* @see initWithCancelButtonTitle:codeReader:startScanningAtLoad:
|
||||
* @since 3.0.0
|
||||
*/
|
||||
- (nonnull id)initWithCancelButtonTitle:(nullable NSString *)cancelTitle codeReader:(nonnull QRCodeReader *)codeReader;
|
||||
|
||||
/**
|
||||
* @abstract Initializes a view controller using a cancel button title and
|
||||
* a code reader.
|
||||
* @param cancelTitle The title of the cancel button.
|
||||
* @param codeReader The reader to decode the codes.
|
||||
* @see initWithCancelButtonTitle:codeReader:
|
||||
* @since 3.0.0
|
||||
*/
|
||||
+ (nonnull instancetype)readerWithCancelButtonTitle:(nullable NSString *)cancelTitle codeReader:(nonnull QRCodeReader *)codeReader;
|
||||
|
||||
/**
|
||||
* @abstract Initializes a view controller using a cancel button title and
|
||||
* a code reader.
|
||||
* @param cancelTitle The title of the cancel button.
|
||||
* @param codeReader The reader to decode the codes.
|
||||
* @param startScanningAtLoad Flag to know whether the view controller start
|
||||
* scanning the codes when the view will appear.
|
||||
* @see initWithCancelButtonTitle:codeReader:
|
||||
* @since 3.0.0
|
||||
*/
|
||||
- (nonnull id)initWithCancelButtonTitle:(nullable NSString *)cancelTitle codeReader:(nonnull QRCodeReader *)codeReader startScanningAtLoad:(BOOL)startScanningAtLoad;
|
||||
|
||||
/**
|
||||
* @abstract Initializes a view controller using a cancel button title and
|
||||
* a code reader.
|
||||
* @param cancelTitle The title of the cancel button.
|
||||
* @param codeReader The reader to decode the codes.
|
||||
* @param startScanningAtLoad Flag to know whether the view controller start
|
||||
* scanning the codes when the view will appear.
|
||||
* @see initWithCancelButtonTitle:codeReader:startScanningAtLoad:showSwitchCameraButton:showTorchButton:
|
||||
* @since 3.0.0
|
||||
*/
|
||||
+ (nonnull instancetype)readerWithCancelButtonTitle:(nullable NSString *)cancelTitle codeReader:(nonnull QRCodeReader *)codeReader startScanningAtLoad:(BOOL)startScanningAtLoad;
|
||||
|
||||
/**
|
||||
* @abstract Initializes a view controller using a cancel button title and
|
||||
* a code reader.
|
||||
* @param cancelTitle The title of the cancel button.
|
||||
* @param codeReader The reader to decode the codes.
|
||||
* @param startScanningAtLoad Flag to know whether the view controller start
|
||||
* scanning the codes when the view will appear.
|
||||
* @param showSwitchCameraButton Flag to display the switch camera button.
|
||||
* @param showTorchButton Flag to know whether the view controller start
|
||||
* scanning the codes when the view will appear.
|
||||
* @since 4.0.0
|
||||
*/
|
||||
- (nonnull id)initWithCancelButtonTitle:(nullable NSString *)cancelTitle codeReader:(nonnull QRCodeReader *)codeReader startScanningAtLoad:(BOOL)startScanningAtLoad showSwitchCameraButton:(BOOL)showSwitchCameraButton showTorchButton:(BOOL)showTorchButton;
|
||||
|
||||
/**
|
||||
* @abstract Initializes a view controller using a cancel button title and
|
||||
* a code reader.
|
||||
* @param cancelTitle The title of the cancel button.
|
||||
* @param codeReader The reader to decode the codes.
|
||||
* @param startScanningAtLoad Flag to know whether the view controller start
|
||||
* scanning the codes when the view will appear.
|
||||
* @param showSwitchCameraButton Flag to display the switch camera button.
|
||||
* @param showTorchButton Flag to know whether the view controller start
|
||||
* scanning the codes when the view will appear.
|
||||
* @see initWithCancelButtonTitle:codeReader:startScanningAtLoad:showSwitchCameraButton:showTorchButton:
|
||||
* @since 4.0.0
|
||||
*/
|
||||
+ (nonnull instancetype)readerWithCancelButtonTitle:(nullable NSString *)cancelTitle codeReader:(nonnull QRCodeReader *)codeReader startScanningAtLoad:(BOOL)startScanningAtLoad showSwitchCameraButton:(BOOL)showSwitchCameraButton showTorchButton:(BOOL)showTorchButton;
|
||||
|
||||
#pragma mark - Controlling the Reader
|
||||
/** @name Controlling the Reader */
|
||||
|
||||
/**
|
||||
* @abstract Starts scanning the codes.
|
||||
* @since 3.0.0
|
||||
*/
|
||||
- (void)startScanning;
|
||||
|
||||
/**
|
||||
* @abstract Stops scanning the codes.
|
||||
* @since 3.0.0
|
||||
*/
|
||||
- (void)stopScanning;
|
||||
|
||||
#pragma mark - Managing the Delegate
|
||||
/** @name Managing the Delegate */
|
||||
|
||||
/**
|
||||
* @abstract The object that acts as the delegate of the receiving QRCode
|
||||
* reader.
|
||||
* @since 1.0.0
|
||||
*/
|
||||
@property (nonatomic, weak) id<QRCodeReaderDelegate> __nullable delegate;
|
||||
|
||||
/**
|
||||
* @abstract Sets the completion with a block that executes when a QRCode
|
||||
* or when the user did stopped the scan.
|
||||
* @param completionBlock The block to be executed. This block has no
|
||||
* return value and takes one argument: the `resultAsString`. If the user
|
||||
* stop the scan and that there is no response the `resultAsString` argument
|
||||
* is nil.
|
||||
* @since 1.0.1
|
||||
*/
|
||||
- (void)setCompletionWithBlock:(nullable void (^) (NSString * __nullable resultAsString))completionBlock;
|
||||
|
||||
#pragma mark - Managing the Reader
|
||||
/** @name Managing the Reader */
|
||||
|
||||
/**
|
||||
* @abstract The default code reader created with the controller.
|
||||
* @since 3.0.0
|
||||
*/
|
||||
@property (strong, nonatomic, readonly) QRCodeReader * __nonnull codeReader;
|
||||
|
||||
@end
|
329
QRCodeReaderViewController/QRCodeReaderViewController.m
Normal file
329
QRCodeReaderViewController/QRCodeReaderViewController.m
Normal file
@ -0,0 +1,329 @@
|
||||
/*
|
||||
* QRCodeReaderViewController
|
||||
*
|
||||
* Copyright 2014-present Yannick Loriot.
|
||||
* http://yannickloriot.com
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*
|
||||
*/
|
||||
|
||||
#import "QRCodeReaderViewController.h"
|
||||
#import "QRCameraSwitchButton.h"
|
||||
#import "QRCodeReaderView.h"
|
||||
#import "QRToggleTorchButton.h"
|
||||
|
||||
@interface QRCodeReaderViewController ()
|
||||
@property (strong, nonatomic) QRCameraSwitchButton *switchCameraButton;
|
||||
@property (strong, nonatomic) QRToggleTorchButton *toggleTorchButton;
|
||||
@property (strong, nonatomic) QRCodeReaderView *cameraView;
|
||||
@property (strong, nonatomic) UIButton *cancelButton;
|
||||
@property (strong, nonatomic) QRCodeReader *codeReader;
|
||||
@property (assign, nonatomic) BOOL startScanningAtLoad;
|
||||
@property (assign, nonatomic) BOOL showSwitchCameraButton;
|
||||
@property (assign, nonatomic) BOOL showTorchButton;
|
||||
|
||||
@property (copy, nonatomic) void (^completionBlock) (NSString * __nullable);
|
||||
|
||||
@end
|
||||
|
||||
@implementation QRCodeReaderViewController
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
[self stopScanning];
|
||||
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
||||
}
|
||||
|
||||
- (id)init
|
||||
{
|
||||
return [self initWithCancelButtonTitle:nil];
|
||||
}
|
||||
|
||||
- (id)initWithCancelButtonTitle:(NSString *)cancelTitle
|
||||
{
|
||||
return [self initWithCancelButtonTitle:cancelTitle metadataObjectTypes:@[AVMetadataObjectTypeQRCode]];
|
||||
}
|
||||
|
||||
- (id)initWithMetadataObjectTypes:(NSArray *)metadataObjectTypes
|
||||
{
|
||||
return [self initWithCancelButtonTitle:nil metadataObjectTypes:metadataObjectTypes];
|
||||
}
|
||||
|
||||
- (id)initWithCancelButtonTitle:(NSString *)cancelTitle metadataObjectTypes:(NSArray *)metadataObjectTypes
|
||||
{
|
||||
QRCodeReader *reader = [QRCodeReader readerWithMetadataObjectTypes:metadataObjectTypes];
|
||||
|
||||
return [self initWithCancelButtonTitle:cancelTitle codeReader:reader];
|
||||
}
|
||||
|
||||
- (id)initWithCancelButtonTitle:(NSString *)cancelTitle codeReader:(QRCodeReader *)codeReader
|
||||
{
|
||||
return [self initWithCancelButtonTitle:cancelTitle codeReader:codeReader startScanningAtLoad:true];
|
||||
}
|
||||
|
||||
- (id)initWithCancelButtonTitle:(NSString *)cancelTitle codeReader:(QRCodeReader *)codeReader startScanningAtLoad:(BOOL)startScanningAtLoad
|
||||
{
|
||||
return [self initWithCancelButtonTitle:cancelTitle codeReader:codeReader startScanningAtLoad:startScanningAtLoad showSwitchCameraButton:YES showTorchButton:NO];
|
||||
}
|
||||
|
||||
- (id)initWithCancelButtonTitle:(nullable NSString *)cancelTitle codeReader:(nonnull QRCodeReader *)codeReader startScanningAtLoad:(BOOL)startScanningAtLoad showSwitchCameraButton:(BOOL)showSwitchCameraButton showTorchButton:(BOOL)showTorchButton
|
||||
{
|
||||
if ((self = [super init])) {
|
||||
self.view.backgroundColor = [UIColor blackColor];
|
||||
self.codeReader = codeReader;
|
||||
self.startScanningAtLoad = startScanningAtLoad;
|
||||
self.showSwitchCameraButton = showSwitchCameraButton;
|
||||
self.showTorchButton = showTorchButton;
|
||||
|
||||
if (cancelTitle == nil) {
|
||||
cancelTitle = NSLocalizedString(@"Cancel", @"Cancel");
|
||||
}
|
||||
|
||||
[self setupUIComponentsWithCancelButtonTitle:cancelTitle];
|
||||
[self setupAutoLayoutConstraints];
|
||||
|
||||
[_cameraView.layer insertSublayer:_codeReader.previewLayer atIndex:0];
|
||||
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(orientationChanged:) name:UIApplicationDidChangeStatusBarOrientationNotification object:nil];
|
||||
|
||||
__weak __typeof__(self) weakSelf = self;
|
||||
|
||||
[codeReader setCompletionWithBlock:^(NSString *resultAsString) {
|
||||
if (weakSelf.completionBlock != nil) {
|
||||
weakSelf.completionBlock(resultAsString);
|
||||
}
|
||||
|
||||
if (weakSelf.delegate && [weakSelf.delegate respondsToSelector:@selector(reader:didScanResult:)]) {
|
||||
[weakSelf.delegate reader:weakSelf didScanResult:resultAsString];
|
||||
}
|
||||
}];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
+ (instancetype)readerWithCancelButtonTitle:(NSString *)cancelTitle
|
||||
{
|
||||
return [[self alloc] initWithCancelButtonTitle:cancelTitle];
|
||||
}
|
||||
|
||||
+ (instancetype)readerWithMetadataObjectTypes:(NSArray *)metadataObjectTypes
|
||||
{
|
||||
return [[self alloc] initWithMetadataObjectTypes:metadataObjectTypes];
|
||||
}
|
||||
|
||||
+ (instancetype)readerWithCancelButtonTitle:(NSString *)cancelTitle metadataObjectTypes:(NSArray *)metadataObjectTypes
|
||||
{
|
||||
return [[self alloc] initWithCancelButtonTitle:cancelTitle metadataObjectTypes:metadataObjectTypes];
|
||||
}
|
||||
|
||||
+ (instancetype)readerWithCancelButtonTitle:(NSString *)cancelTitle codeReader:(QRCodeReader *)codeReader
|
||||
{
|
||||
return [[self alloc] initWithCancelButtonTitle:cancelTitle codeReader:codeReader];
|
||||
}
|
||||
|
||||
+ (instancetype)readerWithCancelButtonTitle:(NSString *)cancelTitle codeReader:(QRCodeReader *)codeReader startScanningAtLoad:(BOOL)startScanningAtLoad
|
||||
{
|
||||
return [[self alloc] initWithCancelButtonTitle:cancelTitle codeReader:codeReader startScanningAtLoad:startScanningAtLoad];
|
||||
}
|
||||
|
||||
+ (instancetype)readerWithCancelButtonTitle:(NSString *)cancelTitle codeReader:(QRCodeReader *)codeReader startScanningAtLoad:(BOOL)startScanningAtLoad showSwitchCameraButton:(BOOL)showSwitchCameraButton showTorchButton:(BOOL)showTorchButton
|
||||
{
|
||||
return [[self alloc] initWithCancelButtonTitle:cancelTitle codeReader:codeReader startScanningAtLoad:startScanningAtLoad showSwitchCameraButton:showSwitchCameraButton showTorchButton:showTorchButton];
|
||||
}
|
||||
|
||||
- (void)viewWillAppear:(BOOL)animated
|
||||
{
|
||||
[super viewWillAppear:animated];
|
||||
|
||||
if (_startScanningAtLoad) {
|
||||
[self startScanning];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)viewWillDisappear:(BOOL)animated
|
||||
{
|
||||
[self stopScanning];
|
||||
|
||||
[super viewWillDisappear:animated];
|
||||
}
|
||||
|
||||
- (void)viewWillLayoutSubviews
|
||||
{
|
||||
[super viewWillLayoutSubviews];
|
||||
|
||||
_codeReader.previewLayer.frame = self.view.bounds;
|
||||
}
|
||||
|
||||
- (BOOL)shouldAutorotate
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
|
||||
#pragma mark - Controlling the Reader
|
||||
|
||||
- (void)startScanning {
|
||||
[_codeReader startScanning];
|
||||
}
|
||||
|
||||
- (void)stopScanning {
|
||||
[_codeReader stopScanning];
|
||||
}
|
||||
|
||||
#pragma mark - Managing the Orientation
|
||||
|
||||
- (void)orientationChanged:(NSNotification *)notification
|
||||
{
|
||||
[_cameraView setNeedsDisplay];
|
||||
|
||||
if (_codeReader.previewLayer.connection.isVideoOrientationSupported) {
|
||||
UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation];
|
||||
|
||||
_codeReader.previewLayer.connection.videoOrientation = [QRCodeReader videoOrientationFromInterfaceOrientation:
|
||||
orientation];
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - Managing the Block
|
||||
|
||||
- (void)setCompletionWithBlock:(void (^) (NSString *resultAsString))completionBlock
|
||||
{
|
||||
self.completionBlock = completionBlock;
|
||||
}
|
||||
|
||||
#pragma mark - Initializing the AV Components
|
||||
|
||||
- (void)setupUIComponentsWithCancelButtonTitle:(NSString *)cancelButtonTitle
|
||||
{
|
||||
self.cameraView = [[QRCodeReaderView alloc] init];
|
||||
_cameraView.translatesAutoresizingMaskIntoConstraints = NO;
|
||||
_cameraView.clipsToBounds = YES;
|
||||
[self.view addSubview:_cameraView];
|
||||
|
||||
[_codeReader.previewLayer setFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
|
||||
|
||||
if ([_codeReader.previewLayer.connection isVideoOrientationSupported]) {
|
||||
UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation];
|
||||
|
||||
_codeReader.previewLayer.connection.videoOrientation = [QRCodeReader videoOrientationFromInterfaceOrientation:orientation];
|
||||
}
|
||||
|
||||
if (_showSwitchCameraButton && [_codeReader hasFrontDevice]) {
|
||||
_switchCameraButton = [[QRCameraSwitchButton alloc] init];
|
||||
|
||||
[_switchCameraButton setTranslatesAutoresizingMaskIntoConstraints:false];
|
||||
[_switchCameraButton addTarget:self action:@selector(switchCameraAction:) forControlEvents:UIControlEventTouchUpInside];
|
||||
[self.view addSubview:_switchCameraButton];
|
||||
}
|
||||
|
||||
if (_showTorchButton && [_codeReader isTorchAvailable]) {
|
||||
_toggleTorchButton = [[QRToggleTorchButton alloc] init];
|
||||
|
||||
[_toggleTorchButton setTranslatesAutoresizingMaskIntoConstraints:false];
|
||||
[_toggleTorchButton addTarget:self action:@selector(toggleTorchAction:) forControlEvents:UIControlEventTouchUpInside];
|
||||
[self.view addSubview:_toggleTorchButton];
|
||||
}
|
||||
|
||||
self.cancelButton = [[UIButton alloc] init];
|
||||
_cancelButton.translatesAutoresizingMaskIntoConstraints = NO;
|
||||
[_cancelButton setTitle:cancelButtonTitle forState:UIControlStateNormal];
|
||||
[_cancelButton setTitleColor:[UIColor grayColor] forState:UIControlStateHighlighted];
|
||||
[_cancelButton addTarget:self action:@selector(cancelAction:) forControlEvents:UIControlEventTouchUpInside];
|
||||
[self.view addSubview:_cancelButton];
|
||||
}
|
||||
|
||||
- (void)setupAutoLayoutConstraints
|
||||
{
|
||||
NSLayoutYAxisAnchor * topLayoutAnchor;
|
||||
NSLayoutYAxisAnchor * bottomLayoutAnchor;
|
||||
NSLayoutXAxisAnchor * leftLayoutAnchor;
|
||||
NSLayoutXAxisAnchor * rightLayoutAnchor;
|
||||
if (@available(iOS 11.0, *)) {
|
||||
topLayoutAnchor = self.view.safeAreaLayoutGuide.topAnchor;
|
||||
bottomLayoutAnchor = self.view.safeAreaLayoutGuide.bottomAnchor;
|
||||
leftLayoutAnchor = self.view.safeAreaLayoutGuide.leftAnchor;
|
||||
rightLayoutAnchor = self.view.safeAreaLayoutGuide.rightAnchor;
|
||||
} else {
|
||||
topLayoutAnchor = self.topLayoutGuide.topAnchor;
|
||||
bottomLayoutAnchor = self.bottomLayoutGuide.bottomAnchor;
|
||||
leftLayoutAnchor = self.view.leftAnchor;
|
||||
rightLayoutAnchor = self.view.rightAnchor;
|
||||
}
|
||||
|
||||
NSDictionary *views = NSDictionaryOfVariableBindings(_cameraView, _cancelButton);
|
||||
|
||||
[self.view addConstraints:
|
||||
[NSLayoutConstraint constraintsWithVisualFormat:@"V:|[_cameraView][_cancelButton(40)]" options:0 metrics:nil views:views]];
|
||||
[[bottomLayoutAnchor constraintEqualToAnchor:_cancelButton.bottomAnchor] setActive:YES];
|
||||
[self.view addConstraints:
|
||||
[NSLayoutConstraint constraintsWithVisualFormat:@"H:|[_cameraView]|" options:0 metrics:nil views:views]];
|
||||
[self.view addConstraints:
|
||||
[NSLayoutConstraint constraintsWithVisualFormat:@"H:|-[_cancelButton]-|" options:0 metrics:nil views:views]];
|
||||
|
||||
if (_switchCameraButton) {
|
||||
[NSLayoutConstraint activateConstraints:@[
|
||||
[topLayoutAnchor constraintEqualToAnchor:_switchCameraButton.topAnchor],
|
||||
[rightLayoutAnchor constraintEqualToAnchor:_switchCameraButton.rightAnchor],
|
||||
[_switchCameraButton.heightAnchor constraintEqualToConstant:50],
|
||||
[_switchCameraButton.widthAnchor constraintEqualToConstant:70]
|
||||
]];
|
||||
}
|
||||
|
||||
if (_toggleTorchButton) {
|
||||
[NSLayoutConstraint activateConstraints:@[
|
||||
[topLayoutAnchor constraintEqualToAnchor:_toggleTorchButton.topAnchor],
|
||||
[leftLayoutAnchor constraintEqualToAnchor:_toggleTorchButton.leftAnchor],
|
||||
[_toggleTorchButton.heightAnchor constraintEqualToConstant:50],
|
||||
[_toggleTorchButton.widthAnchor constraintEqualToConstant:70]
|
||||
]];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)switchDeviceInput
|
||||
{
|
||||
[_codeReader switchDeviceInput];
|
||||
}
|
||||
|
||||
#pragma mark - Catching Button Events
|
||||
|
||||
- (void)cancelAction:(UIButton *)button
|
||||
{
|
||||
[_codeReader stopScanning];
|
||||
|
||||
if (_completionBlock) {
|
||||
_completionBlock(nil);
|
||||
}
|
||||
|
||||
if (_delegate && [_delegate respondsToSelector:@selector(readerDidCancel:)]) {
|
||||
[_delegate readerDidCancel:self];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)switchCameraAction:(UIButton *)button
|
||||
{
|
||||
[self switchDeviceInput];
|
||||
}
|
||||
|
||||
- (void)toggleTorchAction:(UIButton *)button
|
||||
{
|
||||
[_codeReader toggleTorch];
|
||||
}
|
||||
|
||||
@end
|
66
QRCodeReaderViewController/QRToggleTorchButton.h
Normal file
66
QRCodeReaderViewController/QRToggleTorchButton.h
Normal file
@ -0,0 +1,66 @@
|
||||
/*
|
||||
* QRCodeReaderViewController
|
||||
*
|
||||
* Copyright 2014-present Yannick Loriot.
|
||||
* http://yannickloriot.com
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*
|
||||
*/
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
/**
|
||||
* The toggle toch button.
|
||||
* @since 4.0.0
|
||||
*/
|
||||
@interface QRToggleTorchButton : UIButton
|
||||
|
||||
#pragma mark - Managing Properties
|
||||
/** @name Managing Properties */
|
||||
|
||||
/**
|
||||
* @abstract The edge color of the drawing.
|
||||
* @discussion The default color is the white.
|
||||
* @since 2.0.0
|
||||
*/
|
||||
@property (nonatomic, strong) UIColor *edgeColor;
|
||||
|
||||
/**
|
||||
* @abstract The fill color of the drawing.
|
||||
* @discussion The default color is the darkgray.
|
||||
* @since 2.0.0
|
||||
*/
|
||||
@property (nonatomic, strong) UIColor *fillColor;
|
||||
|
||||
/**
|
||||
* @abstract The edge color of the drawing when the button is touched.
|
||||
* @discussion The default color is the white.
|
||||
* @since 2.0.0
|
||||
*/
|
||||
@property (nonatomic, strong) UIColor *edgeHighlightedColor;
|
||||
|
||||
/**
|
||||
* @abstract The fill color of the drawing when the button is touched.
|
||||
* @discussion The default color is the black.
|
||||
* @since 2.0.0
|
||||
*/
|
||||
@property (nonatomic, strong) UIColor *fillHighlightedColor;
|
||||
|
||||
@end
|
130
QRCodeReaderViewController/QRToggleTorchButton.m
Normal file
130
QRCodeReaderViewController/QRToggleTorchButton.m
Normal file
@ -0,0 +1,130 @@
|
||||
/*
|
||||
* QRCodeReaderViewController
|
||||
*
|
||||
* Copyright 2014-present Yannick Loriot.
|
||||
* http://yannickloriot.com
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*
|
||||
*/
|
||||
|
||||
#import "QRToggleTorchButton.h"
|
||||
|
||||
@implementation QRToggleTorchButton
|
||||
|
||||
- (id)initWithFrame:(CGRect)frame
|
||||
{
|
||||
if ((self = [super initWithFrame:frame])) {
|
||||
_edgeColor = [UIColor whiteColor];
|
||||
_fillColor = [UIColor darkGrayColor];
|
||||
_edgeHighlightedColor = [UIColor whiteColor];
|
||||
_fillHighlightedColor = [UIColor blackColor];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)drawRect:(CGRect)rect
|
||||
{
|
||||
// Colors
|
||||
|
||||
UIColor *paintColor = (self.state != UIControlStateHighlighted) ? _fillColor : _fillHighlightedColor;
|
||||
UIColor *strokeColor = (self.state != UIControlStateHighlighted) ? _edgeColor : _edgeHighlightedColor;
|
||||
|
||||
// Torch box
|
||||
|
||||
CGFloat width = rect.size.width;
|
||||
CGFloat height = rect.size.height;
|
||||
CGFloat centerX = width / 2;
|
||||
CGFloat centerY = height / 2;
|
||||
|
||||
CGFloat strokeLineWidth = 2;
|
||||
CGFloat circleRadius = width / 10;
|
||||
CGFloat lineLength = width / 10;
|
||||
CGFloat lineOffset = width / 10;
|
||||
CGFloat lineOriginFromCenter = circleRadius + lineOffset;
|
||||
|
||||
//Circle
|
||||
UIBezierPath *circlePath = [UIBezierPath bezierPath];
|
||||
[circlePath addArcWithCenter:CGPointMake(centerX, centerY) radius:circleRadius startAngle:0.0 endAngle:M_PI clockwise:YES];
|
||||
[circlePath addArcWithCenter:CGPointMake(centerX, centerY) radius:circleRadius startAngle:M_PI endAngle:M_PI * 2 clockwise:YES];
|
||||
|
||||
// Draw beams
|
||||
[paintColor setFill];
|
||||
|
||||
for (int i = 0; i < 8; i++) {
|
||||
CGFloat angle = ((2 * M_PI) / 8) * i;
|
||||
|
||||
CGPoint startPoint = CGPointMake(centerX + cos(angle) * lineOriginFromCenter, centerY + sin(angle) * lineOriginFromCenter);
|
||||
CGPoint endPoint = CGPointMake(centerX + cos(angle) * (lineOriginFromCenter + lineLength), centerY + sin(angle) * (lineOriginFromCenter + lineLength));
|
||||
|
||||
UIBezierPath *beamPath = [self linePathWithStartPoint:startPoint endPoint:endPoint thickness:strokeLineWidth];
|
||||
[beamPath stroke];
|
||||
}
|
||||
|
||||
// Draw circle
|
||||
[strokeColor setFill];
|
||||
|
||||
circlePath.lineWidth = strokeLineWidth;
|
||||
[circlePath fill];
|
||||
[circlePath stroke];
|
||||
}
|
||||
|
||||
- (UIBezierPath *)linePathWithStartPoint:(CGPoint)startPoint endPoint:(CGPoint)endPoint thickness:(CGFloat)thickness {
|
||||
UIBezierPath *linePath = [UIBezierPath bezierPath];
|
||||
|
||||
[linePath moveToPoint:startPoint];
|
||||
[linePath addLineToPoint:endPoint];
|
||||
|
||||
linePath.lineCapStyle = kCGLineCapRound;
|
||||
linePath.lineWidth = thickness;
|
||||
|
||||
return linePath;
|
||||
}
|
||||
|
||||
// MARK: - UIResponder Methods
|
||||
|
||||
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
|
||||
{
|
||||
[super touchesBegan:touches withEvent:event];
|
||||
|
||||
[self setNeedsDisplay];
|
||||
}
|
||||
|
||||
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
|
||||
{
|
||||
[super touchesMoved:touches withEvent:event];
|
||||
|
||||
[self setNeedsDisplay];
|
||||
}
|
||||
|
||||
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
|
||||
{
|
||||
[super touchesEnded:touches withEvent:event];
|
||||
|
||||
[self setNeedsDisplay];
|
||||
}
|
||||
|
||||
- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event
|
||||
{
|
||||
[super touchesCancelled:touches withEvent:event];
|
||||
|
||||
[self setNeedsDisplay];
|
||||
}
|
||||
|
||||
@end
|
@ -79,6 +79,12 @@
|
||||
D52A8DA1288E6547006574E8 /* libuv_a.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D52A8D9F288E6547006574E8 /* libuv_a.a */; };
|
||||
D5538BA5287E9908000BDFB6 /* WalletEvent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D5538BA3287E9908000BDFB6 /* WalletEvent.cpp */; };
|
||||
D589C9BB28B62D93002CAA34 /* cacert.pem in Resources */ = {isa = PBXBuildFile; fileRef = D589C9B928B62D93002CAA34 /* cacert.pem */; };
|
||||
D5AB1D3328BF782300AA6AFA /* QRToggleTorchButton.m in Sources */ = {isa = PBXBuildFile; fileRef = D5AB1D2928BF782200AA6AFA /* QRToggleTorchButton.m */; };
|
||||
D5AB1D3428BF782300AA6AFA /* QRCameraSwitchButton.m in Sources */ = {isa = PBXBuildFile; fileRef = D5AB1D2B28BF782200AA6AFA /* QRCameraSwitchButton.m */; };
|
||||
D5AB1D3528BF782300AA6AFA /* QRCodeReaderViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = D5AB1D2D28BF782200AA6AFA /* QRCodeReaderViewController.m */; };
|
||||
D5AB1D3628BF782300AA6AFA /* QRCodeReaderView.m in Sources */ = {isa = PBXBuildFile; fileRef = D5AB1D2E28BF782200AA6AFA /* QRCodeReaderView.m */; };
|
||||
D5AB1D3728BF782300AA6AFA /* QRCodeReader.m in Sources */ = {isa = PBXBuildFile; fileRef = D5AB1D3228BF782300AA6AFA /* QRCodeReader.m */; };
|
||||
D5AB1D4328C0539600AA6AFA /* UIViewController+Wallet.mm in Sources */ = {isa = PBXBuildFile; fileRef = D5AB1D4228C0539600AA6AFA /* UIViewController+Wallet.mm */; };
|
||||
D5F2CED6287BE9C4003C2B62 /* Data in Resources */ = {isa = PBXBuildFile; fileRef = D5F2CED5287BE9C4003C2B62 /* Data */; };
|
||||
D5F2CF41287BEC0D003C2B62 /* Bulk_Generics_3.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D5F2CED8287BEC0D003C2B62 /* Bulk_Generics_3.cpp */; };
|
||||
D5F2CF42287BEC0D003C2B62 /* Il2CppMethodPointerTable.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D5F2CED9287BEC0D003C2B62 /* Il2CppMethodPointerTable.cpp */; };
|
||||
@ -185,14 +191,14 @@
|
||||
D5F2CFA7287BEC0D003C2B62 /* Bulk_UnityEngine.UI_2.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D5F2CF3E287BEC0D003C2B62 /* Bulk_UnityEngine.UI_2.cpp */; };
|
||||
D5F2CFA8287BEC0D003C2B62 /* Il2CppCompilerCalculateTypeValues_13Table.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D5F2CF3F287BEC0D003C2B62 /* Il2CppCompilerCalculateTypeValues_13Table.cpp */; };
|
||||
D5F2CFA9287BEC0D003C2B62 /* Il2CppCompilerCalculateTypeValues_12Table.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D5F2CF40287BEC0D003C2B62 /* Il2CppCompilerCalculateTypeValues_12Table.cpp */; };
|
||||
D5F2CFB1287BF3BD003C2B62 /* AppDelegate.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D5F2CFAF287BF3BD003C2B62 /* AppDelegate.cpp */; };
|
||||
D5F2CFB1287BF3BD003C2B62 /* AppDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = D5F2CFAF287BF3BD003C2B62 /* AppDelegate.mm */; };
|
||||
D5F2CFCA287BF7E4003C2B62 /* libicucore.A.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = D5F2CFC9287BF7E4003C2B62 /* libicucore.A.tbd */; };
|
||||
D5F2CFCC287BF7ED003C2B62 /* libsqlite3.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = D5F2CFCB287BF7ED003C2B62 /* libsqlite3.tbd */; };
|
||||
D5F2CFCE287BF7FE003C2B62 /* JavaScriptCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D5F2CFCD287BF7FE003C2B62 /* JavaScriptCore.framework */; };
|
||||
D5F2CFD0287BF80A003C2B62 /* libz.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = D5F2CFCF287BF80A003C2B62 /* libz.tbd */; };
|
||||
D5F2CFD2287BF83C003C2B62 /* js in Resources */ = {isa = PBXBuildFile; fileRef = D5F2CFD1287BF83C003C2B62 /* js */; };
|
||||
D5F2D102287C092D003C2B62 /* libcocos2d.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D5F2CFBA287BF425003C2B62 /* libcocos2d.a */; };
|
||||
D5F2D106287C12DD003C2B62 /* JcWallet.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D5F2D104287C12DD003C2B62 /* JcWallet.cpp */; };
|
||||
D5F2D106287C12DD003C2B62 /* JcWallet.mm in Sources */ = {isa = PBXBuildFile; fileRef = D5F2D104287C12DD003C2B62 /* JcWallet.mm */; };
|
||||
D82DCFC30E8000A5005D6AD8 /* main.mm in Sources */ = {isa = PBXBuildFile; fileRef = D82DCFBB0E8000A5005D6AD8 /* main.mm */; };
|
||||
D8A1C7280E80637F000160D3 /* RegisterMonoModules.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D8A1C7240E80637F000160D3 /* RegisterMonoModules.cpp */; };
|
||||
E9D340DABD2259166E8A82AF /* Metal.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 65204119BF754354B5DD4D0C /* Metal.framework */; settings = {ATTRIBUTES = (Weak, ); }; };
|
||||
@ -352,6 +358,19 @@
|
||||
D5538BA3287E9908000BDFB6 /* WalletEvent.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WalletEvent.cpp; sourceTree = "<group>"; };
|
||||
D5538BA4287E9908000BDFB6 /* WalletEvent.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WalletEvent.h; sourceTree = "<group>"; };
|
||||
D589C9B928B62D93002CAA34 /* cacert.pem */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = cacert.pem; sourceTree = "<group>"; };
|
||||
D5AB1D2828BF782200AA6AFA /* QRCodeReaderView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = QRCodeReaderView.h; sourceTree = "<group>"; };
|
||||
D5AB1D2928BF782200AA6AFA /* QRToggleTorchButton.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = QRToggleTorchButton.m; sourceTree = "<group>"; };
|
||||
D5AB1D2A28BF782200AA6AFA /* QRCodeReaderDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = QRCodeReaderDelegate.h; sourceTree = "<group>"; };
|
||||
D5AB1D2B28BF782200AA6AFA /* QRCameraSwitchButton.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = QRCameraSwitchButton.m; sourceTree = "<group>"; };
|
||||
D5AB1D2C28BF782200AA6AFA /* QRCodeReader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = QRCodeReader.h; sourceTree = "<group>"; };
|
||||
D5AB1D2D28BF782200AA6AFA /* QRCodeReaderViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = QRCodeReaderViewController.m; sourceTree = "<group>"; };
|
||||
D5AB1D2E28BF782200AA6AFA /* QRCodeReaderView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = QRCodeReaderView.m; sourceTree = "<group>"; };
|
||||
D5AB1D2F28BF782300AA6AFA /* QRToggleTorchButton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = QRToggleTorchButton.h; sourceTree = "<group>"; };
|
||||
D5AB1D3028BF782300AA6AFA /* QRCameraSwitchButton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = QRCameraSwitchButton.h; sourceTree = "<group>"; };
|
||||
D5AB1D3128BF782300AA6AFA /* QRCodeReaderViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = QRCodeReaderViewController.h; sourceTree = "<group>"; };
|
||||
D5AB1D3228BF782300AA6AFA /* QRCodeReader.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = QRCodeReader.m; sourceTree = "<group>"; };
|
||||
D5AB1D4128C0539600AA6AFA /* UIViewController+Wallet.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "UIViewController+Wallet.h"; sourceTree = "<group>"; };
|
||||
D5AB1D4228C0539600AA6AFA /* UIViewController+Wallet.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = "UIViewController+Wallet.mm"; sourceTree = "<group>"; };
|
||||
D5F2CED5287BE9C4003C2B62 /* Data */ = {isa = PBXFileReference; lastKnownFileType = folder; name = Data; path = /Users/zhl/Documents/workspace/unity/first/first/target/ios/Data; sourceTree = "<group>"; };
|
||||
D5F2CED8287BEC0D003C2B62 /* Bulk_Generics_3.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Bulk_Generics_3.cpp; sourceTree = "<group>"; };
|
||||
D5F2CED9287BEC0D003C2B62 /* Il2CppMethodPointerTable.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Il2CppMethodPointerTable.cpp; sourceTree = "<group>"; };
|
||||
@ -460,14 +479,14 @@
|
||||
D5F2CF40287BEC0D003C2B62 /* Il2CppCompilerCalculateTypeValues_12Table.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Il2CppCompilerCalculateTypeValues_12Table.cpp; sourceTree = "<group>"; };
|
||||
D5F2CFAC287BF3BD003C2B62 /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
|
||||
D5F2CFAE287BF3BD003C2B62 /* NativeConfig.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NativeConfig.h; sourceTree = "<group>"; };
|
||||
D5F2CFAF287BF3BD003C2B62 /* AppDelegate.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AppDelegate.cpp; sourceTree = "<group>"; };
|
||||
D5F2CFAF287BF3BD003C2B62 /* AppDelegate.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = AppDelegate.mm; sourceTree = "<group>"; };
|
||||
D5F2CFB2287BF425003C2B62 /* cocos2d_libs.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = cocos2d_libs.xcodeproj; path = "../../../../cocos/cocos2d-x/build/cocos2d_libs.xcodeproj"; sourceTree = "<group>"; };
|
||||
D5F2CFC9287BF7E4003C2B62 /* libicucore.A.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libicucore.A.tbd; path = usr/lib/libicucore.A.tbd; sourceTree = SDKROOT; };
|
||||
D5F2CFCB287BF7ED003C2B62 /* libsqlite3.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libsqlite3.tbd; path = usr/lib/libsqlite3.tbd; sourceTree = SDKROOT; };
|
||||
D5F2CFCD287BF7FE003C2B62 /* JavaScriptCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = JavaScriptCore.framework; path = System/Library/Frameworks/JavaScriptCore.framework; sourceTree = SDKROOT; };
|
||||
D5F2CFCF287BF80A003C2B62 /* libz.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libz.tbd; path = usr/lib/libz.tbd; sourceTree = SDKROOT; };
|
||||
D5F2CFD1287BF83C003C2B62 /* js */ = {isa = PBXFileReference; lastKnownFileType = folder; path = js; sourceTree = "<group>"; };
|
||||
D5F2D104287C12DD003C2B62 /* JcWallet.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JcWallet.cpp; sourceTree = "<group>"; };
|
||||
D5F2D104287C12DD003C2B62 /* JcWallet.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = JcWallet.mm; sourceTree = "<group>"; };
|
||||
D5F2D105287C12DD003C2B62 /* JcWallet.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JcWallet.h; sourceTree = "<group>"; };
|
||||
D82DCFBB0E8000A5005D6AD8 /* main.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = main.mm; path = Classes/main.mm; sourceTree = SOURCE_ROOT; };
|
||||
D8A1C7240E80637F000160D3 /* RegisterMonoModules.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = RegisterMonoModules.cpp; path = Libraries/RegisterMonoModules.cpp; sourceTree = SOURCE_ROOT; };
|
||||
@ -539,6 +558,7 @@
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
D589C9B928B62D93002CAA34 /* cacert.pem */,
|
||||
D5AB1D2728BF782200AA6AFA /* QRCodeReaderViewController */,
|
||||
D5F2CFD1287BF83C003C2B62 /* js */,
|
||||
D5F2CFB2287BF425003C2B62 /* cocos2d_libs.xcodeproj */,
|
||||
D5F2CFAB287BF3BD003C2B62 /* Classes_cocos */,
|
||||
@ -707,6 +727,24 @@
|
||||
name = UnityAds;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
D5AB1D2728BF782200AA6AFA /* QRCodeReaderViewController */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
D5AB1D2828BF782200AA6AFA /* QRCodeReaderView.h */,
|
||||
D5AB1D2928BF782200AA6AFA /* QRToggleTorchButton.m */,
|
||||
D5AB1D2A28BF782200AA6AFA /* QRCodeReaderDelegate.h */,
|
||||
D5AB1D2B28BF782200AA6AFA /* QRCameraSwitchButton.m */,
|
||||
D5AB1D2C28BF782200AA6AFA /* QRCodeReader.h */,
|
||||
D5AB1D2D28BF782200AA6AFA /* QRCodeReaderViewController.m */,
|
||||
D5AB1D2E28BF782200AA6AFA /* QRCodeReaderView.m */,
|
||||
D5AB1D2F28BF782300AA6AFA /* QRToggleTorchButton.h */,
|
||||
D5AB1D3028BF782300AA6AFA /* QRCameraSwitchButton.h */,
|
||||
D5AB1D3128BF782300AA6AFA /* QRCodeReaderViewController.h */,
|
||||
D5AB1D3228BF782300AA6AFA /* QRCodeReader.m */,
|
||||
);
|
||||
path = QRCodeReaderViewController;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
D5F2CED7287BEC0D003C2B62 /* Native */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
@ -825,9 +863,11 @@
|
||||
children = (
|
||||
D5F2CFAE287BF3BD003C2B62 /* NativeConfig.h */,
|
||||
D5F2CFAC287BF3BD003C2B62 /* AppDelegate.h */,
|
||||
D5F2CFAF287BF3BD003C2B62 /* AppDelegate.cpp */,
|
||||
D5F2CFAF287BF3BD003C2B62 /* AppDelegate.mm */,
|
||||
D5AB1D4128C0539600AA6AFA /* UIViewController+Wallet.h */,
|
||||
D5AB1D4228C0539600AA6AFA /* UIViewController+Wallet.mm */,
|
||||
D5F2D105287C12DD003C2B62 /* JcWallet.h */,
|
||||
D5F2D104287C12DD003C2B62 /* JcWallet.cpp */,
|
||||
D5F2D104287C12DD003C2B62 /* JcWallet.mm */,
|
||||
D5538BA4287E9908000BDFB6 /* WalletEvent.h */,
|
||||
D5538BA3287E9908000BDFB6 /* WalletEvent.cpp */,
|
||||
);
|
||||
@ -1039,10 +1079,11 @@
|
||||
D5F2CF83287BEC0D003C2B62 /* Il2CppCompilerCalculateTypeValues_0Table.cpp in Sources */,
|
||||
D5F2CF7A287BEC0D003C2B62 /* Bulk_UnityEngine.AudioModule_0.cpp in Sources */,
|
||||
D5F2CF78287BEC0D003C2B62 /* Bulk_Generics_12.cpp in Sources */,
|
||||
D5F2CFB1287BF3BD003C2B62 /* AppDelegate.cpp in Sources */,
|
||||
D5F2CFB1287BF3BD003C2B62 /* AppDelegate.mm in Sources */,
|
||||
D5F2CF5A287BEC0D003C2B62 /* Il2CppGenericInstDefinitions.cpp in Sources */,
|
||||
D5F2CFA6287BEC0D003C2B62 /* Bulk_netstandard_0.cpp in Sources */,
|
||||
D5F2CF53287BEC0D003C2B62 /* GenericMethods0.cpp in Sources */,
|
||||
D5AB1D3628BF782300AA6AFA /* QRCodeReaderView.m in Sources */,
|
||||
D5F2CF95287BEC0D003C2B62 /* Bulk_mscorlib_12.cpp in Sources */,
|
||||
D5F2CF87287BEC0D003C2B62 /* Bulk_UnityEngine.CoreModule_1.cpp in Sources */,
|
||||
D82DCFC30E8000A5005D6AD8 /* main.mm in Sources */,
|
||||
@ -1074,6 +1115,7 @@
|
||||
D5F2CFA1287BEC0D003C2B62 /* Il2CppGenericMethodDefinitions.cpp in Sources */,
|
||||
D5F2CF60287BEC0D003C2B62 /* Bulk_UnityEngine.PhysicsModule_0.cpp in Sources */,
|
||||
D5F2CF93287BEC0D003C2B62 /* Bulk_UnityEngine.AnimationModule_0.cpp in Sources */,
|
||||
D5AB1D3528BF782300AA6AFA /* QRCodeReaderViewController.m in Sources */,
|
||||
D5F2CF82287BEC0D003C2B62 /* Bulk_Mono.Security_0.cpp in Sources */,
|
||||
D5F2CF5D287BEC0D003C2B62 /* Bulk_UnityEngine.SharedInternalsModule_0.cpp in Sources */,
|
||||
D5F2CF4A287BEC0D003C2B62 /* Il2CppCompilerCalculateTypeValues_3Table.cpp in Sources */,
|
||||
@ -1120,11 +1162,13 @@
|
||||
8A16150C1A8E4362006FA788 /* FullScreenVideoPlayer.mm in Sources */,
|
||||
FC85CCBB16C3ED8000BAF7C7 /* CrashReporter.mm in Sources */,
|
||||
8AB3CB3E16D390BB00697AD5 /* VideoPlayer.mm in Sources */,
|
||||
D5AB1D3328BF782300AA6AFA /* QRToggleTorchButton.m in Sources */,
|
||||
8A793A071ED43EE100B44EF1 /* UnityView+tvOS.mm in Sources */,
|
||||
D5F2CF99287BEC0D003C2B62 /* Bulk_UnityEngine.UI_0.cpp in Sources */,
|
||||
D5F2CF4D287BEC0D003C2B62 /* Bulk_UnityEngine.TextRenderingModule_0.cpp in Sources */,
|
||||
8A2AA93516E0978D001FB470 /* CMVideoSampling.mm in Sources */,
|
||||
D5F2CF56287BEC0D003C2B62 /* Il2CppCompilerCalculateTypeValues_22Table.cpp in Sources */,
|
||||
D5AB1D4328C0539600AA6AFA /* UIViewController+Wallet.mm in Sources */,
|
||||
8A851BA716FB2F6D00E911DB /* UnityView.mm in Sources */,
|
||||
8A851BAA16FB3AD000E911DB /* UnityAppController.mm in Sources */,
|
||||
D5F2CF8A287BEC0D003C2B62 /* Bulk_UnityEngine.CoreModule_0.cpp in Sources */,
|
||||
@ -1145,13 +1189,14 @@
|
||||
D5F2CF44287BEC0D003C2B62 /* Il2CppCompilerCalculateTypeValues_9Table.cpp in Sources */,
|
||||
D5F2CF6B287BEC0D003C2B62 /* Bulk_mscorlib_3.cpp in Sources */,
|
||||
D5F2CF92287BEC0D003C2B62 /* Bulk_System.Configuration_0.cpp in Sources */,
|
||||
D5AB1D3728BF782300AA6AFA /* QRCodeReader.m in Sources */,
|
||||
D5F2CF9D287BEC0D003C2B62 /* Il2CppCompilerCalculateTypeValues_19Table.cpp in Sources */,
|
||||
D5F2CF61287BEC0D003C2B62 /* Bulk_mscorlib_6.cpp in Sources */,
|
||||
D5F2CF79287BEC0D003C2B62 /* Il2CppGenericComDefinitions0.cpp in Sources */,
|
||||
D5F2CF67287BEC0D003C2B62 /* Il2CppAttributes.cpp in Sources */,
|
||||
D5F2CF62287BEC0D003C2B62 /* Bulk_mscorlib_7.cpp in Sources */,
|
||||
8A4815C117A28E7F003FBFD5 /* UnityAppController+ViewHandling.mm in Sources */,
|
||||
D5F2D106287C12DD003C2B62 /* JcWallet.cpp in Sources */,
|
||||
D5F2D106287C12DD003C2B62 /* JcWallet.mm in Sources */,
|
||||
D5F2CF8B287BEC0D003C2B62 /* Bulk_System.Diagnostics.StackTrace_0.cpp in Sources */,
|
||||
D5F2CF63287BEC0D003C2B62 /* Il2CppCompilerCalculateTypeValues_10Table.cpp in Sources */,
|
||||
D5F2CF88287BEC0D003C2B62 /* Bulk_UnityEngine.UIModule_0.cpp in Sources */,
|
||||
@ -1161,6 +1206,7 @@
|
||||
D5F2CF84287BEC0D003C2B62 /* Il2CppCompilerCalculateTypeValues_1Table.cpp in Sources */,
|
||||
D5F2CFA3287BEC0D003C2B62 /* Bulk_mscorlib_14.cpp in Sources */,
|
||||
8A25E6D218D767E20006A227 /* Filesystem.mm in Sources */,
|
||||
D5AB1D3428BF782300AA6AFA /* QRCameraSwitchButton.m in Sources */,
|
||||
D5F2CF74287BEC0D003C2B62 /* Il2CppCompilerCalculateTypeValues_20Table.cpp in Sources */,
|
||||
D5F2CF9C287BEC0D003C2B62 /* Bulk_mscorlib_16.cpp in Sources */,
|
||||
999475201A7BC3AE00178130 /* UnityAdsUnityWrapper.mm in Sources */,
|
||||
|
Binary file not shown.
@ -14,8 +14,10 @@
|
||||
filePath = "../../../../cocos/cocos2d-x/cocos/scripting/js-bindings/manual/jsb_global.cpp"
|
||||
startingColumnNumber = "9223372036854775807"
|
||||
endingColumnNumber = "9223372036854775807"
|
||||
startingLineNumber = "881"
|
||||
endingLineNumber = "881">
|
||||
startingLineNumber = "885"
|
||||
endingLineNumber = "885"
|
||||
landmarkName = "jsb_register_global_variables(global)"
|
||||
landmarkType = "9">
|
||||
</BreakpointContent>
|
||||
</BreakpointProxy>
|
||||
<BreakpointProxy
|
||||
@ -28,8 +30,8 @@
|
||||
filePath = "Classes_cocos/JcWallet.cpp"
|
||||
startingColumnNumber = "9223372036854775807"
|
||||
endingColumnNumber = "9223372036854775807"
|
||||
startingLineNumber = "158"
|
||||
endingLineNumber = "158"
|
||||
startingLineNumber = "159"
|
||||
endingLineNumber = "159"
|
||||
landmarkName = "tick(dt)"
|
||||
landmarkType = "9">
|
||||
</BreakpointContent>
|
||||
@ -44,8 +46,8 @@
|
||||
filePath = "Classes_cocos/JcWallet.cpp"
|
||||
startingColumnNumber = "9223372036854775807"
|
||||
endingColumnNumber = "9223372036854775807"
|
||||
startingLineNumber = "120"
|
||||
endingLineNumber = "120"
|
||||
startingLineNumber = "121"
|
||||
endingLineNumber = "121"
|
||||
landmarkName = "JcWallet::tick(dt)"
|
||||
landmarkType = "7">
|
||||
</BreakpointContent>
|
||||
@ -108,8 +110,8 @@
|
||||
filePath = "Classes/UnityAppController.mm"
|
||||
startingColumnNumber = "9223372036854775807"
|
||||
endingColumnNumber = "9223372036854775807"
|
||||
startingLineNumber = "408"
|
||||
endingLineNumber = "408"
|
||||
startingLineNumber = "404"
|
||||
endingLineNumber = "404"
|
||||
landmarkName = "-applicationWillResignActive:"
|
||||
landmarkType = "7">
|
||||
</BreakpointContent>
|
||||
@ -124,44 +126,12 @@
|
||||
filePath = "Classes/UnityAppController.mm"
|
||||
startingColumnNumber = "9223372036854775807"
|
||||
endingColumnNumber = "9223372036854775807"
|
||||
startingLineNumber = "403"
|
||||
endingLineNumber = "403"
|
||||
startingLineNumber = "399"
|
||||
endingLineNumber = "399"
|
||||
landmarkName = "-applicationWillResignActive:"
|
||||
landmarkType = "7">
|
||||
</BreakpointContent>
|
||||
</BreakpointProxy>
|
||||
<BreakpointProxy
|
||||
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
|
||||
<BreakpointContent
|
||||
uuid = "81607144-947B-4C43-9C64-44D7C4827382"
|
||||
shouldBeEnabled = "Yes"
|
||||
ignoreCount = "0"
|
||||
continueAfterRunningActions = "No"
|
||||
filePath = "Classes_cocos/AppDelegate.cpp"
|
||||
startingColumnNumber = "9223372036854775807"
|
||||
endingColumnNumber = "9223372036854775807"
|
||||
startingLineNumber = "83"
|
||||
endingLineNumber = "83"
|
||||
landmarkName = "AppDelegate::onPause()"
|
||||
landmarkType = "7">
|
||||
</BreakpointContent>
|
||||
</BreakpointProxy>
|
||||
<BreakpointProxy
|
||||
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
|
||||
<BreakpointContent
|
||||
uuid = "499D85CB-2D58-41E5-AB4F-66F4DC6B03A2"
|
||||
shouldBeEnabled = "Yes"
|
||||
ignoreCount = "0"
|
||||
continueAfterRunningActions = "No"
|
||||
filePath = "Classes_cocos/AppDelegate.cpp"
|
||||
startingColumnNumber = "9223372036854775807"
|
||||
endingColumnNumber = "9223372036854775807"
|
||||
startingLineNumber = "89"
|
||||
endingLineNumber = "89"
|
||||
landmarkName = "AppDelegate::onResume()"
|
||||
landmarkType = "7">
|
||||
</BreakpointContent>
|
||||
</BreakpointProxy>
|
||||
<BreakpointProxy
|
||||
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
|
||||
<BreakpointContent
|
||||
@ -172,11 +142,123 @@
|
||||
filePath = "Classes_cocos/JcWallet.cpp"
|
||||
startingColumnNumber = "9223372036854775807"
|
||||
endingColumnNumber = "9223372036854775807"
|
||||
startingLineNumber = "159"
|
||||
endingLineNumber = "159"
|
||||
startingLineNumber = "160"
|
||||
endingLineNumber = "160"
|
||||
landmarkName = "tick(dt)"
|
||||
landmarkType = "9">
|
||||
</BreakpointContent>
|
||||
</BreakpointProxy>
|
||||
<BreakpointProxy
|
||||
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
|
||||
<BreakpointContent
|
||||
uuid = "614B1FEA-6B61-4A25-BE89-9EE30D36CBC7"
|
||||
shouldBeEnabled = "No"
|
||||
ignoreCount = "0"
|
||||
continueAfterRunningActions = "No"
|
||||
filePath = "Classes_cocos/JcWallet.mm"
|
||||
startingColumnNumber = "9223372036854775807"
|
||||
endingColumnNumber = "9223372036854775807"
|
||||
startingLineNumber = "225"
|
||||
endingLineNumber = "225"
|
||||
landmarkName = "jsb_scanQRCode(s)"
|
||||
landmarkType = "9">
|
||||
</BreakpointContent>
|
||||
</BreakpointProxy>
|
||||
<BreakpointProxy
|
||||
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
|
||||
<BreakpointContent
|
||||
uuid = "8D9F9587-E7C9-406A-B764-D5BF90564CBA"
|
||||
shouldBeEnabled = "No"
|
||||
ignoreCount = "0"
|
||||
continueAfterRunningActions = "No"
|
||||
filePath = "Classes_cocos/UnityAppController+Wallet.mm"
|
||||
startingColumnNumber = "9223372036854775807"
|
||||
endingColumnNumber = "9223372036854775807"
|
||||
startingLineNumber = "17"
|
||||
endingLineNumber = "17"
|
||||
landmarkName = "-scanQRCode:"
|
||||
landmarkType = "7">
|
||||
</BreakpointContent>
|
||||
</BreakpointProxy>
|
||||
<BreakpointProxy
|
||||
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
|
||||
<BreakpointContent
|
||||
uuid = "AEC6EE3A-8956-46C2-A0A8-228945459762"
|
||||
shouldBeEnabled = "No"
|
||||
ignoreCount = "0"
|
||||
continueAfterRunningActions = "No"
|
||||
filePath = "Classes_cocos/UnityAppController+Wallet.mm"
|
||||
startingColumnNumber = "9223372036854775807"
|
||||
endingColumnNumber = "9223372036854775807"
|
||||
startingLineNumber = "16"
|
||||
endingLineNumber = "16"
|
||||
landmarkName = "-scanQRCode:"
|
||||
landmarkType = "7">
|
||||
</BreakpointContent>
|
||||
</BreakpointProxy>
|
||||
<BreakpointProxy
|
||||
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
|
||||
<BreakpointContent
|
||||
uuid = "E1B1CB90-A31C-4C83-A52E-CB9E520862CE"
|
||||
shouldBeEnabled = "No"
|
||||
ignoreCount = "0"
|
||||
continueAfterRunningActions = "No"
|
||||
filePath = "Classes_cocos/UIViewController+Wallet.mm"
|
||||
startingColumnNumber = "9223372036854775807"
|
||||
endingColumnNumber = "9223372036854775807"
|
||||
startingLineNumber = "46"
|
||||
endingLineNumber = "46"
|
||||
landmarkName = "-scanQRCode:"
|
||||
landmarkType = "7">
|
||||
</BreakpointContent>
|
||||
</BreakpointProxy>
|
||||
<BreakpointProxy
|
||||
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
|
||||
<BreakpointContent
|
||||
uuid = "546581C6-1C99-46B6-A9C2-F3DCBC1C78D4"
|
||||
shouldBeEnabled = "No"
|
||||
ignoreCount = "0"
|
||||
continueAfterRunningActions = "No"
|
||||
filePath = "Classes_cocos/UIViewController+Wallet.mm"
|
||||
startingColumnNumber = "9223372036854775807"
|
||||
endingColumnNumber = "9223372036854775807"
|
||||
startingLineNumber = "23"
|
||||
endingLineNumber = "23"
|
||||
landmarkName = "-scanQRCode:"
|
||||
landmarkType = "7">
|
||||
</BreakpointContent>
|
||||
</BreakpointProxy>
|
||||
<BreakpointProxy
|
||||
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
|
||||
<BreakpointContent
|
||||
uuid = "DACE477D-4E89-42F4-B0DB-F46C7EC5041B"
|
||||
shouldBeEnabled = "No"
|
||||
ignoreCount = "0"
|
||||
continueAfterRunningActions = "No"
|
||||
filePath = "Classes_cocos/UIViewController+Wallet.mm"
|
||||
startingColumnNumber = "9223372036854775807"
|
||||
endingColumnNumber = "9223372036854775807"
|
||||
startingLineNumber = "24"
|
||||
endingLineNumber = "24"
|
||||
landmarkName = "-scanQRCode:"
|
||||
landmarkType = "7">
|
||||
</BreakpointContent>
|
||||
</BreakpointProxy>
|
||||
<BreakpointProxy
|
||||
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
|
||||
<BreakpointContent
|
||||
uuid = "7D77739A-FDDA-4C97-A8EA-DBD76CECA30F"
|
||||
shouldBeEnabled = "No"
|
||||
ignoreCount = "0"
|
||||
continueAfterRunningActions = "No"
|
||||
filePath = "Classes_cocos/UIViewController+Wallet.mm"
|
||||
startingColumnNumber = "9223372036854775807"
|
||||
endingColumnNumber = "9223372036854775807"
|
||||
startingLineNumber = "22"
|
||||
endingLineNumber = "22"
|
||||
landmarkName = "-scanQRCode:"
|
||||
landmarkType = "7">
|
||||
</BreakpointContent>
|
||||
</BreakpointProxy>
|
||||
</Breakpoints>
|
||||
</Bucket>
|
||||
|
File diff suppressed because one or more lines are too long
18
js/main.js
18
js/main.js
@ -16,15 +16,16 @@ function initWallet(funId, type, password) {
|
||||
type = parseInt(type);
|
||||
if (type === 1) {
|
||||
console.log('wallet inited, begin connect')
|
||||
wallet.wConnect.connect()
|
||||
wallet.initThirdPartyWallet()
|
||||
.then(() => {
|
||||
console.log('walletconnect inited')
|
||||
var account = jc.wallet.currentAccount();
|
||||
jsb.jcCallback(funId, JSON.stringify({errcode: 0, data: account}));
|
||||
})
|
||||
.catch(err => {
|
||||
jsb.jcCallback(funId, JSON.stringify({errcode: 1, errmsg: err}));
|
||||
})
|
||||
.catch(err =>{
|
||||
console.log('walletconnect inited error: ' + JSON.stringify(err));
|
||||
jsb.jcCallback(funId, JSON.stringify({errcode: 1, errmsg: err}));
|
||||
})
|
||||
} else {
|
||||
let address = jc.wallet.currentAccount().address
|
||||
jsb.jcCallback(funId, JSON.stringify({errcode: 0, data: address}));
|
||||
@ -231,3 +232,12 @@ function restoreFromMnemonic(funId, mnemonic, password) {
|
||||
}
|
||||
}
|
||||
|
||||
function scanQRCode(funId, title) {
|
||||
try {
|
||||
jsb.scanQRCode(title);
|
||||
return JSON.stringify({errcode: 0});
|
||||
} catch(err) {
|
||||
return JSON.stringify({errcode: 1, errmsg: err});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -8,9 +8,10 @@ window.jumpToWallet = function(url) {
|
||||
url = url || 'wc://';
|
||||
url = `https://metamask.app.link/wc?uri=${encodeURIComponent(url)}`;
|
||||
console.log('open native: ' + url);
|
||||
jsb.reflection.callStaticMethod(
|
||||
'UnityAppController',
|
||||
'toWallet:',
|
||||
url
|
||||
)
|
||||
jsb.toWallet(url);
|
||||
// jsb.reflection.callStaticMethod(
|
||||
// 'UnityAppController',
|
||||
// 'toWallet:',
|
||||
// url
|
||||
// )
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user