Commit f762147a authored by huanglu's avatar huanglu

feat: ios

parent b63715ac
module.exports = { module.exports = {
presets: ['module:metro-react-native-babel-preset'], presets: ['module:metro-react-native-babel-preset'],
plugins: [
[
"babel-plugin-root-import",
{
"paths": [
{
"rootPathSuffix": "./src/",
"rootPathPrefix": "@/"
}
]
}
]
]
}; };
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<FileRef
location = "group:GeekTeacherWork.xcodeproj">
</FileRef>
<FileRef
location = "group:Pods/Pods.xcodeproj">
</FileRef>
</Workspace>
<?xml version="1.0" encoding="UTF-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>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
//
// CACameraSessionDelegate.h
//
// Created by Christopher Cohen & Gabriel Alvarado on 1/23/15.
// Copyright (c) 2015 Gabriel Alvarado. All rights reserved.
//
#import <UIKit/UIKit.h>
@class CameraSessionView;
///Protocol Definition
@protocol CACameraSessionDelegate <NSObject>
@optional
- (void)didCaptureImage:(UIImage *)image;
@optional
- (void)didCaptureImageWithData:(NSData *)imageData;
@optional
- (void)didCloseCamera:(CameraSessionView *)camera;
@end
@interface CameraSessionView : UIView
//Delegate Property
@property (nonatomic, weak) id <CACameraSessionDelegate> delegate;
//API Functions
- (void)setTopBarColor:(UIColor *)topBarColor;
- (void)hideFlashButton;
- (void)hideCameraToggleButton;
- (void)hideDismissButton;
@end
//
// CameraDismissButton.h
// CameraWithAVFoundation
//
// Created by Gabriel Alvarado on 1/24/15.
// Copyright (c) 2015 Gabriel Alvarado. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface CameraDismissButton : UIButton
@end
//
// CameraDismissButton.m
// CameraWithAVFoundation
//
// Created by Gabriel Alvarado on 1/24/15.
// Copyright (c) 2015 Gabriel Alvarado. All rights reserved.
//
#import "CameraDismissButton.h"
#import "CameraStyleKitClass.h"
@implementation CameraDismissButton
- (void)drawRect:(CGRect)rect {
[CameraStyleKitClass drawCameraDismissWithFrame:self.bounds];
}
@end
//
// CameraFlashButton.h
// CameraWithAVFoundation
//
// Created by Gabriel Alvarado on 1/24/15.
// Copyright (c) 2015 Gabriel Alvarado. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface CameraFlashButton : UIButton
@end
//
// CameraFlashButton.m
// CameraWithAVFoundation
//
// Created by Gabriel Alvarado on 1/24/15.
// Copyright (c) 2015 Gabriel Alvarado. All rights reserved.
//
#import "CameraFlashButton.h"
#import "CameraStyleKitClass.h"
@implementation CameraFlashButton
- (void)drawRect:(CGRect)rect {
[CameraStyleKitClass drawCameraFlashWithFrame:self.bounds];
}
@end
//
// CameraFocusIndicator.h
// CameraWithAVFoundation
//
// Created by Gabriel Alvarado on 1/25/15.
// Copyright (c) 2015 Gabriel Alvarado. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface CameraFocalReticule : UIView
@end
//
// CameraFocusIndicator.m
// CameraWithAVFoundation
//
// Created by Gabriel Alvarado on 1/25/15.
// Copyright (c) 2015 Gabriel Alvarado. All rights reserved.
//
#import "CameraFocalReticule.h"
#import "CameraStyleKitClass.h"
@implementation CameraFocalReticule
- (void)drawRect:(CGRect)rect {
[CameraStyleKitClass drawCameraFocusWithFrame:self.bounds];
}
@end
//
// CameraShutterButton.h
// CameraWithAVFoundation
//
// Created by Gabriel Alvarado on 1/24/15.
// Copyright (c) 2015 Gabriel Alvarado. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface CameraShutterButton : UIButton
@end
//
// CameraShutterButton.m
// CameraWithAVFoundation
//
// Created by Gabriel Alvarado on 1/24/15.
// Copyright (c) 2015 Gabriel Alvarado. All rights reserved.
//
#import "CameraShutterButton.h"
#import "CameraStyleKitClass.h"
@implementation CameraShutterButton
- (void)drawRect:(CGRect)rect {
[CameraStyleKitClass drawCameraShutterWithFrame:self.bounds];
}
@end
//
// CameraToggleButton.h
// CameraWithAVFoundation
//
// Created by Gabriel Alvarado on 1/24/15.
// Copyright (c) 2015 Gabriel Alvarado. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface CameraToggleButton : UIButton
@end
//
// CameraToggleButton.m
// CameraWithAVFoundation
//
// Created by Gabriel Alvarado on 1/24/15.
// Copyright (c) 2015 Gabriel Alvarado. All rights reserved.
//
#import "CameraToggleButton.h"
#import "CameraStyleKitClass.h"
@implementation CameraToggleButton
- (void)drawRect:(CGRect)rect {
[CameraStyleKitClass drawCameraToggleWithFrame:self.bounds];
}
@end
//
// LaunchCameraButton.h
// CameraWithAVFoundation
//
// Created by Gabriel Alvarado on 2/18/15.
// Copyright (c) 2015 Gabriel Alvarado. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface LaunchCameraButton : UIButton
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event;
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event;
@end
//
// LaunchCameraButton.m
// CameraWithAVFoundation
//
// Created by Gabriel Alvarado on 2/18/15.
// Copyright (c) 2015 Gabriel Alvarado. All rights reserved.
//
#import "LaunchCameraButton.h"
#import "CameraStyleKitClass.h"
@interface LaunchCameraButton ()
@property BOOL isPressed;
@end
@implementation LaunchCameraButton
- (void)drawRect:(CGRect)rect
{
[CameraStyleKitClass drawLaunchCameraWithFrame:self.bounds pressed:self.isPressed];
}
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
self.isPressed = YES;
[self setNeedsDisplay];
[super touchesBegan:touches withEvent:event];
}
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
self.isPressed = NO;
[self setNeedsDisplay];
[super touchesEnded:touches withEvent:event];
}
@end
//
// CameraStyleKitClass.h
// iOS Cam
//
// Created by Gabriel Alvarado on 2/22/15.
// Copyright (c) 2015 CompanyName. All rights reserved.
//
// Generated by PaintCode (www.paintcodeapp.com)
//
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
@interface CameraStyleKitClass : NSObject
// Drawing Methods
+ (void)drawCameraShutterWithFrame: (CGRect)frame;
+ (void)drawCameraFlashWithFrame: (CGRect)frame;
+ (void)drawCameraToggleWithFrame: (CGRect)frame;
+ (void)drawCameraDismissWithFrame: (CGRect)frame;
+ (void)drawCameraTopBarWithFrame: (CGRect)frame;
+ (void)drawCameraFocusWithFrame: (CGRect)frame;
+ (void)drawLaunchCameraWithFrame: (CGRect)frame pressed: (BOOL)pressed;
@end
//
// CaptureSessionManager.h
// CameraWithAVFoundation
//
// Created by Gabriel Alvarado on 4/16/14.
// Copyright (c) 2014 Gabriel Alvarado. All rights reserved.
//
#define kImageCapturedSuccessfully @"imageCapturedSuccessfully"
#import "Constants.h"
#import <AVFoundation/AVFoundation.h>
#import <Foundation/Foundation.h>
///Protocol Definition
@protocol CaptureSessionManagerDelegate <NSObject>
@required - (void)cameraSessionManagerDidCaptureImage;
@required - (void)cameraSessionManagerFailedToCaptureImage;
@required - (void)cameraSessionManagerDidReportAvailability:(BOOL)deviceAvailability forCameraType:(CameraType)cameraType;
@required - (void)cameraSessionManagerDidReportDeviceStatistics:(CameraStatistics)deviceStatistics; //Report every .125 seconds
@end
@interface CaptureSessionManager : NSObject
//Weak pointers
@property (nonatomic, weak) id<CaptureSessionManagerDelegate>delegate;
@property (nonatomic, weak) AVCaptureDevice *activeCamera;
//Strong Pointers
@property (nonatomic, strong) AVCaptureVideoPreviewLayer *previewLayer;
@property (nonatomic, strong) AVCaptureSession *captureSession;
@property (nonatomic, strong) AVCaptureStillImageOutput *stillImageOutput;
@property (nonatomic, strong) UIImage *stillImage;
@property (nonatomic, strong) NSData *stillImageData;
//Primative Variables
@property (nonatomic,assign,getter=isTorchEnabled) BOOL enableTorch;
//API Methods
- (void)addStillImageOutput;
- (void)captureStillImage;
- (void)addVideoPreviewLayer;
- (void)initiateCaptureSessionForCamera:(CameraType)cameraType;
- (void)stop;
@end
//
// CaptureSessionManager.m
// CameraWithAVFoundation
//
// Created by Gabriel Alvarado on 4/16/14.
// Copyright (c) 2014 Gabriel Alvarado. All rights reserved.
//
#import "CaptureSessionManager.h"
#import <ImageIO/ImageIO.h>
@implementation CaptureSessionManager
#pragma mark Capture Session Configuration
- (id)init {
if ((self = [super init])) {
[self setCaptureSession:[[AVCaptureSession alloc] init]];
_captureSession.sessionPreset = AVCaptureSessionPresetHigh;
}
return self;
}
- (void)addVideoPreviewLayer {
[self setPreviewLayer:[[AVCaptureVideoPreviewLayer alloc] initWithSession:[self captureSession]]];
[[self previewLayer] setVideoGravity:AVLayerVideoGravityResizeAspectFill];
}
- (void)initiateCaptureSessionForCamera:(CameraType)cameraType {
//Iterate through devices and assign 'active camera' per parameter
for (AVCaptureDevice *device in AVCaptureDevice.devices) if ([device hasMediaType:AVMediaTypeVideo]) {
switch (cameraType) {
case RearFacingCamera: if ([device position] == AVCaptureDevicePositionBack) _activeCamera = device; break;
case FrontFacingCamera: if ([device position] == AVCaptureDevicePositionFront) _activeCamera = device; break;
}
}
NSError *error = nil;
BOOL deviceAvailability = YES;
AVCaptureDeviceInput *cameraDeviceInput = [AVCaptureDeviceInput deviceInputWithDevice:_activeCamera error:&error];
if (!error && [[self captureSession] canAddInput:cameraDeviceInput]) [[self captureSession] addInput:cameraDeviceInput];
else deviceAvailability = NO;
//Report camera device availability
if (self.delegate) [self.delegate cameraSessionManagerDidReportAvailability:deviceAvailability forCameraType:cameraType];
// [self initiateStatisticsReportWithInterval:.125];
}
-(void)initiateStatisticsReportWithInterval:(CGFloat)interval {
__block id blockSafeSelf = self;
[[NSOperationQueue new] addOperationWithBlock:^{
do {
[NSThread sleepForTimeInterval:interval];
[[NSOperationQueue mainQueue] addOperationWithBlock:^{
if (self.delegate) [self.delegate cameraSessionManagerDidReportDeviceStatistics:cameraStatisticsMake(_activeCamera.lensAperture, CMTimeGetSeconds(_activeCamera.exposureDuration), _activeCamera.ISO, _activeCamera.lensPosition)];
}];
} while (blockSafeSelf);
}];
}
- (void)addStillImageOutput
{
[self setStillImageOutput:[[AVCaptureStillImageOutput alloc] init]];
NSDictionary *outputSettings = [[NSDictionary alloc] initWithObjectsAndKeys:AVVideoCodecJPEG,AVVideoCodecKey,nil];
[[self stillImageOutput] setOutputSettings:outputSettings];
[self getOrientationAdaptedCaptureConnection];
[[self captureSession] addOutput:[self stillImageOutput]];
AVCaptureDevice *device = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];
if ([device isFocusModeSupported:AVCaptureFocusModeContinuousAutoFocus])
{
[device lockForConfiguration:nil];
[device setFocusMode:AVCaptureFocusModeContinuousAutoFocus];
[device unlockForConfiguration];
}
}
- (void)captureStillImage
{
AVCaptureConnection *videoConnection = [self getOrientationAdaptedCaptureConnection];
if (videoConnection) {
[[self stillImageOutput] captureStillImageAsynchronouslyFromConnection:videoConnection completionHandler:
^(CMSampleBufferRef imageSampleBuffer, NSError *error) {
CFDictionaryRef exifAttachments = CMGetAttachment(imageSampleBuffer, kCGImagePropertyExifDictionary, NULL);
if (exifAttachments) {
//Attachements Found
} else {
//No Attachments
}
NSData *imageData = [AVCaptureStillImageOutput jpegStillImageNSDataRepresentation:imageSampleBuffer];
UIImage *image = [[UIImage alloc] initWithData:imageData];
[self setStillImage:image];
[self setStillImageData:imageData];
if (self.delegate)
[self.delegate cameraSessionManagerDidCaptureImage];
}];
}
//Turn off the flash if on
AVCaptureDevice *device = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];
if ([device hasTorch])
{
[device lockForConfiguration:nil];
[device setTorchMode:AVCaptureTorchModeOff];
[device unlockForConfiguration];
}
}
- (void)setEnableTorch:(BOOL)enableTorch
{
_enableTorch = enableTorch;
AVCaptureDevice *device = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];
if ([device hasTorch] && [device hasFlash])
{
[device lockForConfiguration:nil];
if (enableTorch) { [device setTorchMode:AVCaptureTorchModeOn]; }
else { [device setTorchMode:AVCaptureTorchModeOff]; }
[device unlockForConfiguration];
}
}
#pragma mark - Helper Method(s)
- (void)assignVideoOrienationForVideoConnection:(AVCaptureConnection *)videoConnection
{
AVCaptureVideoOrientation newOrientation;
// switch ([[UIDevice currentDevice] orientation]) {
// case UIDeviceOrientationPortrait:
// newOrientation = AVCaptureVideoOrientationPortrait;
// break;
// case UIDeviceOrientationPortraitUpsideDown:
// newOrientation = AVCaptureVideoOrientationPortraitUpsideDown;
// break;
// case UIDeviceOrientationLandscapeLeft:
// newOrientation = AVCaptureVideoOrientationLandscapeRight;
// break;
// case UIDeviceOrientationLandscapeRight:
// newOrientation = AVCaptureVideoOrientationLandscapeLeft;
// break;
// default:
newOrientation = AVCaptureVideoOrientationPortrait;
// }
[videoConnection setVideoOrientation: newOrientation];
}
- (AVCaptureConnection *)getOrientationAdaptedCaptureConnection
{
AVCaptureConnection *videoConnection = nil;
for (AVCaptureConnection *connection in [[self stillImageOutput] connections]) {
for (AVCaptureInputPort *port in [connection inputPorts]) {
if ([[port mediaType] isEqual:AVMediaTypeVideo] ) {
videoConnection = connection;
[self assignVideoOrienationForVideoConnection:videoConnection];
break;
}
}
if (videoConnection) {
[self assignVideoOrienationForVideoConnection:videoConnection];
break;
}
}
return videoConnection;
}
#pragma mark - Cleanup Functions
// stop the camera, otherwise it will lead to memory crashes
- (void)stop
{
[self.captureSession stopRunning];
if(self.captureSession.inputs.count > 0) {
AVCaptureInput* input = [self.captureSession.inputs objectAtIndex:0];
[self.captureSession removeInput:input];
}
if(self.captureSession.outputs.count > 0) {
AVCaptureVideoDataOutput* output = [self.captureSession.outputs objectAtIndex:0];
[self.captureSession removeOutput:output];
}
}
- (void)dealloc {
[self stop];
}
@end
//
// Constants.h
// CameraWithAVFoundation
//
// Created by Christopher Cohen on 1/24/15.
// Copyright (c) 2015 Gabriel Alvarado. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
@interface Constants : NSObject
///Type Definitions
typedef NS_ENUM(BOOL, CameraType) {
FrontFacingCamera,
RearFacingCamera,
};
typedef NS_ENUM(NSInteger, BarButtonTag) {
ShutterButtonTag,
ToggleButtonTag,
FlashButtonTag,
DismissButtonTag,
};
typedef struct {
CGFloat ISO;
CGFloat exposureDuration;
CGFloat aperture;
CGFloat lensPosition;
} CameraStatistics;
///Function Prototype declarations
CameraStatistics cameraStatisticsMake(float aperture, float exposureDuration, float ISO, float lensPostion);
@end
//
// Constants.m
// CameraWithAVFoundation
//
// Created by Christopher Cohen on 1/29/15.
// Copyright (c) 2015 Gabriel Alvarado. All rights reserved.
//
#import "Constants.h"
@implementation Constants
CameraStatistics cameraStatisticsMake(float aperture, float exposureDuration, float ISO, float lensPostion) {
CameraStatistics cameraStatistics;
cameraStatistics.aperture = aperture;
cameraStatistics.exposureDuration = exposureDuration;
cameraStatistics.ISO = ISO;
cameraStatistics.lensPosition = lensPostion;
return cameraStatistics;
}
@end
//
// GeekCameraVC.h
// GeekWorkCorrection
//
// Created by hl on 2020/9/14.
// Copyright © 2020 Facebook. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "GeekWorkModel.h"
NS_ASSUME_NONNULL_BEGIN
typedef void(^PickerImageBlock)(UIImage *image);
typedef void(^PickerSuccessBlock)(BOOL success, NSArray<GeekWorkResult *> * _Nullable results);
@interface GeekCameraVC : UIViewController
@property (nonatomic, copy) PickerImageBlock imageBlock;
@property (nonatomic, copy) PickerSuccessBlock successBlock;
- (void) showPreviewWork:(NSArray<GeekWorkResult *> *)models image:(NSString *)imgUrl;
- (void) hiddenImagePreview;
@end
NS_ASSUME_NONNULL_END
//
// GeekCameraVC.m
// GeekWorkCorrection
//
// Created by hl on 2020/9/14.
// Copyright © 2020 Facebook. All rights reserved.
//
#import "GeekCameraVC.h"
#import <AVFoundation/AVFoundation.h>
#import <AssetsLibrary/AssetsLibrary.h>
#import "CameraSessionView.h"
#import "GeekImageScannerView.h"
#import "GeekWorkAnswerView.h"
#import <YYModel.h>
#import <Masonry.h>
@interface GeekCameraVC ()<CACameraSessionDelegate>
//预览层
@property (nonatomic , strong) CameraSessionView *cameraView;
@property (weak, nonatomic) IBOutlet UIView *pagerView;
@property (nonatomic, copy) NSArray *models;
@property (nonatomic, strong) GeekImageScannerView *scannerView;
@end
@implementation GeekCameraVC
-(void)viewWillAppear:(BOOL)animated{
[super viewWillAppear:animated];
}
-(void)viewWillDisappear:(BOOL)animated{
[super viewWillDisappear:animated];
}
- (void)viewDidLoad {
[super viewDidLoad];
[self configViews];
}
- (void) hiddenImagePreview {
[self.scannerView removeFromSuperview];
}
#pragma mark - init views
- (void) configViews {
[self.pagerView addSubview:self.cameraView];
}
#pragma mark - lazy
- (CameraSessionView *) cameraView {
if (!_cameraView) {
_cameraView = [[CameraSessionView alloc] initWithFrame:CGRectZero];
_cameraView.delegate = self;
CATransition *applicationLoadViewIn =[CATransition animation];
[applicationLoadViewIn setDuration:0.6];
[applicationLoadViewIn setType:kCATransitionReveal];
[applicationLoadViewIn setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn]];
[[_cameraView layer] addAnimation:applicationLoadViewIn forKey:kCATransitionReveal];
[_cameraView setTopBarColor:[[UIColor whiteColor] colorWithAlphaComponent:0.2]];
[_cameraView hideCameraToggleButton];
}
return _cameraView;
}
-(void)didCaptureImage:(UIImage *)image {
GeekImageScannerView *scannerView = [[GeekImageScannerView alloc] initWithFrame:self.pagerView.bounds];
[self.pagerView addSubview:scannerView];
scannerView.imageView.frame = scannerView.bounds;
[scannerView setImage:image];
scannerView.cancelBlock = ^(GeekImageScannerView *scannerView) {
[scannerView removeFromSuperview];
};
__weak typeof(self) weakSelf = self;
scannerView.okBlock = ^(GeekImageScannerView *scannerView, UIImage *image) {
if (weakSelf.imageBlock) {
weakSelf.imageBlock(image);
}
};
self.scannerView = scannerView;
}
-(void)didCaptureImageWithData:(NSData *)imageData {
NSLog(@"CAPTURED IMAGE DATA");
}
- (void) didCloseCamera:(CameraSessionView *)camera {
[self dismissViewControllerAnimated:true completion:nil];
}
- (void)viewDidLayoutSubviews {
[super viewDidLayoutSubviews];
self.cameraView.frame = self.pagerView.bounds;
}
// 预览图片并修改答案
- (void) showPreviewWork:(NSArray *)models image:(NSString *)imgUrl {
GeekWorkAnswerView *answerView = [[GeekWorkAnswerView alloc] init];
self.models = models;
answerView.results = models;
answerView.imgUrl = imgUrl;
__weak typeof(self) weakSelf = self;
__weak typeof(answerView) weakView = answerView;
answerView.handleBlock = ^(BOOL isOK, NSArray<GeekWorkResult *> * _Nullable results) {
__strong typeof(weakSelf) strongSelf = weakSelf;
__strong typeof(weakView) strongView = weakView;
if (isOK) {
if (self.successBlock) {
strongSelf.successBlock(true, weakView.results);
}
} else {
[strongView removeFromSuperview];
}
};
[self.pagerView addSubview:answerView];
[answerView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(0);
make.bottom.mas_equalTo(0);
make.left.mas_equalTo(0);
make.right.mas_equalTo(0);
}];
}
#pragma mark - 获取通知信息
-(void) handleNotification:(NSNotification *)notification {
NSDictionary *info = notification.userInfo;
NSArray<GeekWorkResult *> *models = [info valueForKey:@"result"];
NSString *imageUrl = [info valueForKey:@"image"];
[self showPreviewWork:models image:imageUrl];
}
@end
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="16097.3" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<device id="retina6_1" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="16087"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="GeekCameraVC">
<connections>
<outlet property="pagerView" destination="aSO-pt-jXy" id="gSc-Vb-mpi"/>
<outlet property="view" destination="i5M-Pr-FkT" id="sfx-zR-JGt"/>
</connections>
</placeholder>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<view clearsContextBeforeDrawing="NO" contentMode="scaleToFill" id="i5M-Pr-FkT">
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="aSO-pt-jXy">
<rect key="frame" x="0.0" y="44" width="414" height="818"/>
<color key="backgroundColor" white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</view>
</subviews>
<color key="backgroundColor" white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstItem="Q5M-cg-NOt" firstAttribute="bottom" secondItem="aSO-pt-jXy" secondAttribute="bottom" id="8c9-hf-rE1"/>
<constraint firstItem="aSO-pt-jXy" firstAttribute="top" secondItem="Q5M-cg-NOt" secondAttribute="top" id="REc-Nn-cSH"/>
<constraint firstItem="Q5M-cg-NOt" firstAttribute="trailing" secondItem="aSO-pt-jXy" secondAttribute="trailing" id="TBe-jA-iRW"/>
<constraint firstItem="aSO-pt-jXy" firstAttribute="leading" secondItem="Q5M-cg-NOt" secondAttribute="leading" id="kd8-ty-wKy"/>
</constraints>
<viewLayoutGuide key="safeArea" id="Q5M-cg-NOt"/>
<point key="canvasLocation" x="139" y="89"/>
</view>
</objects>
</document>
//
// GeekImageScannerView.h
// GeekWorkCorrection
//
// Created by hl on 2020/9/15.
// Copyright © 2020 Facebook. All rights reserved.
//
#import <UIKit/UIKit.h>
@class GeekImageScannerView;
typedef void(^TapCancelBlock)(GeekImageScannerView * _Nullable scannerView);
typedef void(^TapOkBlock)(GeekImageScannerView * _Nullable scannerView, UIImage * _Nullable image);
NS_ASSUME_NONNULL_BEGIN
@interface GeekImageScannerView : UIView
@property (nonatomic, strong) UIImage *image;
@property (nonatomic, strong, readonly) UIImageView *imageView;
@property (nonatomic, copy) TapOkBlock okBlock;
@property (nonatomic, copy) TapCancelBlock cancelBlock;
@end
NS_ASSUME_NONNULL_END
//
// GeekImageScannerView.m
// GeekWorkCorrection
//
// Created by hl on 2020/9/15.
// Copyright © 2020 Facebook. All rights reserved.
//
#import "GeekImageScannerView.h"
@interface GeekImageScannerView ()<UIScrollViewDelegate>
@property (nonatomic, strong) UIImageView *imageView;
@property (nonatomic, strong) UIButton *cancelButton;
@property (nonatomic, strong) UIButton *okButton;
@property (nonatomic, strong) UIScrollView *scrollView;
@end
@implementation GeekImageScannerView
- (instancetype)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
self.layer.masksToBounds = NO;
self.backgroundColor = [UIColor blackColor];
[self addSubview:self.scrollView];
[self addSubview:self.cancelButton];
[self addSubview:self.okButton];
[self.scrollView addSubview:self.imageView];
}
return self;
}
#pragma mark - public
- (void)setImage:(__kindof UIImage *)image {
_image = image;
self.imageView.image = image;
}
- (void)reset {
self.imageView.image = nil;
self.imageView.frame = CGRectZero;
}
#pragma mark - getters
- (UIImageView *)imageView {
if (!_imageView) {
_imageView = [UIImageView new];
_imageView.contentMode = UIViewContentModeScaleAspectFill;
_imageView.layer.masksToBounds = YES;
}
return _imageView;
}
- (UIButton *) cancelButton {
if (!_cancelButton) {
_cancelButton = [UIButton buttonWithType:UIButtonTypeCustom];
[_cancelButton setImage:[UIImage imageNamed:@"close"] forState:UIControlStateNormal];
[_cancelButton addTarget:self action:@selector(handleCancel) forControlEvents:UIControlEventTouchUpInside];
}
return _cancelButton;
}
- (UIButton *) okButton {
if (!_okButton) {
_okButton = [UIButton buttonWithType:UIButtonTypeCustom];
[_okButton setImage:[UIImage imageNamed:@"ok"] forState:UIControlStateNormal];
[_okButton addTarget:self action:@selector(handleOk) forControlEvents:UIControlEventTouchUpInside];
}
return _okButton;
}
- (UIScrollView *)scrollView {
if (!_scrollView) {
_scrollView = [[UIScrollView alloc] initWithFrame:self.bounds];
_scrollView.showsHorizontalScrollIndicator = NO;
_scrollView.showsVerticalScrollIndicator = NO;
_scrollView.decelerationRate = UIScrollViewDecelerationRateFast;
_scrollView.minimumZoomScale = 1;
_scrollView.maximumZoomScale = 3;
_scrollView.alwaysBounceHorizontal = NO;
_scrollView.alwaysBounceVertical = NO;
_scrollView.delegate = self;
if (@available(iOS 11.0, *)) {
_scrollView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
}
}
return _scrollView;
}
#pragma mark -- UIScrollViewDelegate
//返回需要缩放的视图控件 缩放过程中
- (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView {
return self.imageView;
}
//开始缩放
- (void)scrollViewWillBeginZooming:(UIScrollView *)scrollView withView:(UIView *)view{
NSLog(@"开始缩放");
}
//结束缩放
- (void)scrollViewDidEndZooming:(UIScrollView *)scrollView withView:(UIView *)view atScale:(CGFloat)scale{
NSLog(@"结束缩放");
}
//缩放中
- (void)scrollViewDidZoom:(UIScrollView *)scrollView {
// 延中心点缩放
CGRect imageViewFrame = self.imageView.frame;
CGFloat width = imageViewFrame.size.width,
height = imageViewFrame.size.height,
sHeight = scrollView.bounds.size.height,
sWidth = scrollView.bounds.size.width;
if (height > sHeight) {
imageViewFrame.origin.y = 0;
} else {
imageViewFrame.origin.y = (sHeight - height) / 2.0;
}
if (width > sWidth) {
imageViewFrame.origin.x = 0;
} else {
imageViewFrame.origin.x = (sWidth - width) / 2.0;
}
self.imageView.frame = imageViewFrame;
}
- (void) layoutSubviews {
[super layoutSubviews];
self.okButton.frame = CGRectMake(CGRectGetWidth(self.frame) - 55, CGRectGetHeight(self.frame) - 50, 45, 40);
self.cancelButton.frame = CGRectMake(10, CGRectGetHeight(self.frame) - 50, 45, 40);
self.scrollView.frame = self.bounds;
}
#pragma mark - actions
- (void) handleOk {
if (self.okBlock) {
self.okBlock(self, self.image);
}
}
- (void) handleCancel {
if (self.cancelBlock) {
self.cancelBlock(self);
}
}
@end
//
// GeekPickerEventEmitter.h
// GeekWorkCorrection
//
// Created by hl on 2020/9/16.
// Copyright © 2020 Facebook. All rights reserved.
//
#import <React/RCTBridgeModule.h>
#import <React/RCTEventEmitter.h>
NS_ASSUME_NONNULL_BEGIN
@interface GeekPickerEventEmitter : RCTEventEmitter<RCTBridgeModule>
@end
NS_ASSUME_NONNULL_END
//
// GeekPickerEventEmitter.m
// GeekWorkCorrection
//
// Created by hl on 2020/9/16.
// Copyright © 2020 Facebook. All rights reserved.
//
#import "GeekPickerEventEmitter.h"
@implementation GeekPickerEventEmitter
//NSString *NOTIFICATION_IMAGE = @"geek_image_picker";
//NSString *NOTIFICATION_ANSWER = @"geek_image_work_picker";
RCT_EXPORT_MODULE();
- (NSArray<NSString *> *)supportedEvents
{
return @[@"GeekWorkPicker"];
}
- (void) startObserving {
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(workEventReminderReceived:) name:@"home_work_uploaded" object:nil];
}
- (void) stopObserving {
[[NSNotificationCenter defaultCenter] removeObserver:self name:@"home_work_uploaded" object:nil];
}
- (void)workEventReminderReceived:(NSNotification *)notification
{
NSDictionary *info = notification.userInfo;
[self sendEventWithName:@"GeekWorkPicker" body:info];
}
@end
//
// GeekUtil.h
// GeekWorkCorrection
//
// Created by hl on 2020/9/15.
// Copyright © 2020 Facebook. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "GeekWorkModel.h"
NS_ASSUME_NONNULL_BEGIN
typedef void(^GeekPickerImageBlock)(NSString *imgPath);
typedef void(^GeekPickerChangeWorkBlock)(NSArray<GeekWorkResult *> *res);
@interface GeekUtil : NSObject
+ (NSString *) saveImageTosandBox:(UIImage *)image;
+ (void) postNotification:(NSString *)name info:(id)info;
+ (void) postImage:(NSString *)img;
//+ (void) observerWorkImageNotification:(GeekPickerImageBlock)block;
+ (void) postChangeWorkInfo:(NSArray<GeekWorkResult *> *)models image:(NSString *)img;
//+ (void) observerChangeWork:(GeekPickerChangeWorkBlock)block;
@end
NS_ASSUME_NONNULL_END
//
// GeekUtil.m
// GeekWorkCorrection
//
// Created by hl on 2020/9/15.
// Copyright © 2020 Facebook. All rights reserved.
//
#import "GeekUtil.h"
NSString *NOTIFICATION_IMAGE = @"home_work_uploaded";
@implementation GeekUtil
+ (NSString *) saveImageTosandBox:(UIImage *)image {
NSData *data = UIImageJPEGRepresentation(image, 1);
if (!data) {
data = UIImagePNGRepresentation(image);
}
NSString *cachesDir = [NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) firstObject];
NSString *filePath = [cachesDir stringByAppendingPathComponent:
[NSString stringWithFormat:@"%@.png", [[NSUUID UUID] UUIDString]]]; // 保存文件的名称
BOOL result =[data writeToFile:filePath atomically:YES]; // 保存成功会返回YES
if (result == YES) {
NSLog(@"保存成功");
return [NSString stringWithFormat:@"file://%@", filePath];
}
return nil;
}
+ (void) postNotification:(NSString *)name info:(id)info {
[[NSNotificationCenter defaultCenter] postNotificationName:name object:nil userInfo:info];
}
+ (void) postImage:(NSString *)img {
[GeekUtil postNotification:NOTIFICATION_IMAGE info:@{
@"image": img,
@"type": @"uploadImage"
}];
}
+ (void) postChangeWorkInfo:(NSArray<GeekWorkResult *> *)models image:(NSString *)img {
[GeekUtil postNotification:NOTIFICATION_IMAGE info:@{
@"works": [models yy_modelToJSONObject],
@"image": img,
@"type": @"uploadWork"
}];
}
+ (void) observerNotificationHandle:(NSNotification *)notify {
[GeekUtil postNotification:@"home_work_uploaded" info:notify.userInfo];
}
@end
//
// GeekWorkAnswerView.h
// GeekWorkCorrection
//
// Created by hl on 2020/9/15.
// Copyright © 2020 Facebook. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "GeekWorkModel.h"
typedef void(^WorkHandleBlock)(BOOL isOK, NSArray<GeekWorkResult *> * _Nullable results);
NS_ASSUME_NONNULL_BEGIN
@interface GeekWorkAnswerView : UIView
@property (nonatomic, copy) NSString *imgUrl;
@property (nonatomic, strong) NSArray<GeekWorkResult *> *results;
- (void) refreshViews;
@property (nonatomic, copy) WorkHandleBlock handleBlock;
@end
NS_ASSUME_NONNULL_END
//
// GeekWorkAnswerView.m
// GeekWorkCorrection
//
// Created by hl on 2020/9/15.
// Copyright © 2020 Facebook. All rights reserved.
//
#import "GeekWorkAnswerView.h"
#import "GeekWorkItemView.h"
#import <SDWebImage.h>
@interface GeekWorkAnswerView ()
@property (nonatomic, strong) UIImageView *imageView;
@property (nonatomic, strong) UIView *contentView;
@property (nonatomic, strong) NSMutableArray *itemViews;
@property (nonatomic, strong) UIButton *okButton;
@property (nonatomic, strong) UIButton *cancelButton;
@end
@implementation GeekWorkAnswerView
- (instancetype) initWithFrame:(CGRect)frame {
if (self = [super initWithFrame:frame]) {
self.itemViews = [NSMutableArray array];
[self.contentView addSubview:self.imageView];
self.backgroundColor = [UIColor blackColor];
[self addSubview:self.contentView];
[self configToolViews];
}
return self;
}
#pragma mark - lazy
- (UIImageView *) imageView {
if (!_imageView) {
_imageView = [[UIImageView alloc] initWithFrame:self.contentView.bounds];
_imageView.contentMode = UIViewContentModeScaleAspectFill;
}
return _imageView;
}
- (UIButton *) okButton {
if (!_okButton) {
_okButton = [UIButton buttonWithType:UIButtonTypeCustom];
[_okButton setTitle:@"确定" forState:UIControlStateNormal];
[_okButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
[_okButton addTarget:self action:@selector(handleOk) forControlEvents:UIControlEventTouchUpInside];
}
return _okButton;
}
- (UIButton *) cancelButton {
if (!_cancelButton) {
_cancelButton = [UIButton buttonWithType:UIButtonTypeCustom];
[_cancelButton setTitle:@"取消" forState:UIControlStateNormal];
[_cancelButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
[_cancelButton addTarget:self action:@selector(handleCancel) forControlEvents:UIControlEventTouchUpInside];
}
return _cancelButton;
}
- (UIView *) contentView {
if (!_contentView ) {
_contentView = [[UIView alloc] initWithFrame:CGRectZero];
_contentView.center = self.center;
}
return _contentView;
}
#pragma mark - 添加工具栏
- (void) configToolViews {
[self addSubview:self.okButton];
[self addSubview:self.cancelButton];
}
#pragma mark -
- (void) setResults:(NSArray<GeekWorkResult *> *)results {
_results = results;
for (UIView *sView in self.itemViews) {
[sView removeFromSuperview];
}
[self.itemViews removeAllObjects];
for (GeekWorkResult *res in results) {
__weak typeof(self) weakSelf = self;
GeekWorkItemView *itemView = [[GeekWorkItemView alloc] initWithResult:res];
itemView.changeBlock = ^(NSString * _Nonnull result) {
__strong typeof(weakSelf) strongSelf = weakSelf ;
res.answer = result;
strongSelf.results = results;
[strongSelf refreshViews];
};
[self.itemViews addObject:itemView];
[self.contentView addSubview:itemView];
}
}
- (void) refreshViews {
for (GeekWorkItemView *itmView in self.itemViews) {
[itmView layoutSelf];
}
}
- (void) setImgUrl:(NSString *)imgUrl {
_imgUrl = imgUrl;
NSURL *img = [NSURL URLWithString:imgUrl];
[self.imageView sd_setImageWithURL: img];
}
#pragma mark -
- (void) layoutSubviews {
[super layoutSubviews];
self.contentView.frame = CGRectMake(0, 0, CGRectGetWidth(self.frame), CGRectGetHeight(self.frame) * 210.0 / 297.0);
self.contentView.center = self.center;
self.imageView.frame = self.contentView.bounds;
for (GeekWorkItemView *itemView in self.itemViews) {
[itemView layoutSelf];
}
self.okButton.frame = CGRectMake(10, CGRectGetHeight(self.frame) - 50, 45, 40);
self.cancelButton.frame = CGRectMake(CGRectGetWidth(self.frame) - 55, CGRectGetHeight(self.frame) - 50, 45, 40);
}
#pragma mark - actions
- (void) handleOk {
if (self.handleBlock) {
self.handleBlock(true, self.results);
}
}
- (void) handleCancel {
if (self.handleBlock) {
self.handleBlock(false, self.results);
}
}
@end
//
// GeekWorkItemView.h
// GeekWorkCorrection
//
// Created by hl on 2020/9/15.
// Copyright © 2020 Facebook. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "GeekWorkModel.h"
NS_ASSUME_NONNULL_BEGIN
typedef void(^ChangeResultBlock)(NSString *result);
@interface GeekWorkItemView : UIView
- (instancetype) initWithResult:(GeekWorkResult *)model;
- (void) setWorkResult:(GeekWorkResult *)result;
- (void) layoutSelf;
@property (nonatomic , copy) ChangeResultBlock changeBlock;
@property (nonatomic, strong) UIColor *borderColor;
@end
NS_ASSUME_NONNULL_END
//
// GeekWorkItemView.m
// GeekWorkCorrection
//
// Created by hl on 2020/9/15.
// Copyright © 2020 Facebook. All rights reserved.
//
#import "GeekWorkItemView.h"
#import <LCActionSheet.h>
@interface GeekWorkItemView ()<LCActionSheetDelegate>
@property (nonatomic, strong) UIView *seperateView;
@property (nonatomic, strong) GeekWorkResult *result;
@property (nonatomic, strong) UILabel *answerLabel;
@end
@implementation GeekWorkItemView
- (instancetype) initWithResult:(GeekWorkResult *)model {
if (self = [super init]) {
self.result = model;
}
return self;
}
- (instancetype) initWithFrame:(CGRect)frame {
if (self = [super initWithFrame:frame]) {
[self addSubview:self.seperateView];
[self addSubview:self.answerLabel];
}
return self;
}
- (void) addSelfToTargetView:(UIView *)taget result:(GeekWorkResult* )result {
UIView *parentView = taget;
if (result && parentView) {
}
}
- (void) setWorkResult:(GeekWorkResult *)result {
self.result = result;
}
#pragma mark - lazy
- (UIView *) seperateView {
if (!_seperateView) {
_seperateView = [[UIView alloc] initWithFrame:CGRectZero];
_seperateView.backgroundColor = [UIColor blueColor];
}
return _seperateView;
}
- (UILabel *) answerLabel {
if (!_answerLabel) {
_answerLabel = [[UILabel alloc] init];
_answerLabel.textColor = [UIColor greenColor];
_answerLabel.font = [UIFont systemFontOfSize:18];
_answerLabel.textAlignment = NSTextAlignmentCenter;
_answerLabel.layer.borderWidth = 1.f;
_answerLabel.layer.borderColor = [[UIColor blueColor] CGColor];
_answerLabel.userInteractionEnabled = true;
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(changeAnswer:)];
[_answerLabel addGestureRecognizer:tap];
}
return _answerLabel;
}
- (void) setResult:(GeekWorkResult *)result {
_result = result;
}
- (void) layoutSubviews {
[super layoutSubviews];
[self subViewsLayout];
}
- (void) layoutSelf {
[self setNeedsLayout];
[self layoutIfNeeded];
}
- (void) subViewsLayout {
self.answerLabel.text = self.result.answer;
CGRect frame = CGRectZero;
CGSize pSize = self.superview.frame.size;
CGFloat xPoint = 10;
CGFloat yPoint = self.result.y1 / 297.0 * pSize.height;
CGFloat height = self.result.y2 / 297.0 * pSize.height - self.result.y1 / 297.0 * pSize.height;
frame.origin.y = yPoint;
frame.origin.x = xPoint;
frame.size.height = height;
frame.size.width = pSize.width - xPoint * 2;
self.frame = frame;
self.answerLabel.text = self.result.answer;
// 将parentView 的坐标转到 当前视图
CGRect labelFrame = CGRectZero;
CGFloat answerStartX = self.result.sAnserX / 210.0 * pSize.width - frame.origin.x;
CGFloat answerStartY = self.result.sAnserY / 297.0 * pSize.height - frame.origin.y;
CGFloat answerEndX = self.result.eAnserX / 210.0 * pSize.width - frame.origin.x;
CGFloat answerEndY = self.result.eAnserY / 297.0 * pSize.height - frame.origin.y;
labelFrame = CGRectMake(answerStartX, answerStartY, answerEndX - answerStartX, answerEndY - answerStartY);
self.answerLabel.frame = labelFrame;
self.seperateView.frame = CGRectMake(0, CGRectGetHeight(self.frame) - 1, CGRectGetWidth(self.frame), 1);
}
#pragma mark -
- (void) changeAnswer:(id) sender {
LCActionSheet *actionSheet = [LCActionSheet sheetWithTitle:@"选择要更改的答案"
cancelButtonTitle:@"取消" clicked:^(LCActionSheet * _Nonnull actionSheet, NSInteger buttonIndex) {
if (buttonIndex - 1 < self.result.chooses.count) {
if (self.changeBlock) {
self.changeBlock(self.result.chooses[buttonIndex - 1]);
}
}
}
otherButtonTitleArray:self.result.chooses];
[actionSheet show];
}
@end
//
// GeekWorkModel.h
// GeekWorkCorrection
//
// Created by hl on 2020/9/15.
// Copyright © 2020 Facebook. All rights reserved.
//
#ifndef GeekWorkModel_h
#define GeekWorkModel_h
#import <YYModel.h>
#import "GeekWorkResult.h"
#endif /* GeekWorkModel_h */
//
// GeekWorkPicker.h
// GeekWorkCorrection
//
// Created by hl on 2020/9/14.
// Copyright © 2020 Facebook. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <React/RCTBridgeModule.h>
NS_ASSUME_NONNULL_BEGIN
@interface GeekWorkPicker : NSObject <RCTBridgeModule>
@end
NS_ASSUME_NONNULL_END
//
// GeekWorkPicker.m
// GeekWorkCorrection
//
// Created by hl on 2020/9/14.
// Copyright © 2020 Facebook. All rights reserved.
//
#import "GeekWorkPicker.h"
#import <UIKit/UIKit.h>
#import "GeekCameraVC.h"
#import "GeekWorkModel.h"
#import "GeekWorkAnswerView.h"
#import "GeekUtil.h"
#import <SVProgressHUD.h>
@interface GeekWorkPicker ()<UINavigationControllerDelegate, UIImagePickerControllerDelegate>
@property (nonatomic, strong) GeekCameraVC *picker;
@end
@implementation GeekWorkPicker
RCT_EXPORT_MODULE();
RCT_EXPORT_METHOD(openWorkPicker) {
[self showPicker];
}
RCT_EXPORT_METHOD(showWorkResult:(NSString *)imageUrl
result:(id)result){
[SVProgressHUD dismiss];
[self.picker hiddenImagePreview];
NSArray<GeekWorkResult *> *models = [NSArray yy_modelArrayWithClass:[GeekWorkResult class] json:result];
if (self.picker) {
[self.picker showPreviewWork:models image:imageUrl];
__weak typeof(self) weakSelf = self;
self.picker.successBlock = ^(BOOL success, NSArray<GeekWorkResult *> *results) {
if (success) {
[GeekUtil postChangeWorkInfo:results image:@""];
[weakSelf.picker dismissViewControllerAnimated:true completion:nil];
}
};
}
}
- (dispatch_queue_t)methodQueue
{
return dispatch_get_main_queue();
}
- (void) showPicker {
// self.picker = [[GeekCameraVC alloc] init];
// self.picker.modalPresentationStyle = UIModalPresentationFullScreen;
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
picker.delegate = self;
[[UIApplication sharedApplication].keyWindow.rootViewController presentViewController:picker animated:YES completion:nil];
// self.picker.imageBlock = ^(UIImage * _Nonnull image) {
// NSString *imgPath = [GeekUtil saveImageTosandBox:image];
// [GeekUtil postImage:imgPath];
// [SVProgressHUD showWithStatus:@"正在上传图片"];
// };
}
- (void) imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary<UIImagePickerControllerInfoKey,id> *)info {
// NSString *imgPath = [GeekUtil saveImageTosandBox:image];
// [GeekUtil postImage:imgPath];
// [SVProgressHUD showWithStatus:@"正在上传图片"];
[picker dismissViewControllerAnimated:true completion:nil];
UIImage *img = [info valueForKey:UIImagePickerControllerOriginalImage];
NSString *imgPath = [GeekUtil saveImageTosandBox:img];
[GeekUtil postImage:imgPath];
[SVProgressHUD showWithStatus:@"正在上传图片"];
}
@end
//
// GeekWorkResult.h
// GeekWorkCorrection
//
// Created by hl on 2020/9/15.
// Copyright © 2020 Facebook. All rights reserved.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
typedef enum : NSUInteger {
WorkResultTypeChoose,
WorkResultTypeText,
WorkResultTypeInput,
} WorkResultType;
@interface GeekWorkResult : NSObject
@property (nonatomic, assign) WorkResultType workType;
@property (nonatomic, copy) NSArray *chooses;
@property (nonatomic, strong) NSString *answer;
@property (nonatomic, assign) CGFloat y1;
@property (nonatomic, assign) CGFloat y2;
@property (nonatomic , assign) CGFloat sAnserX;
@property (nonatomic , assign) CGFloat sAnserY;
@property (nonatomic , assign) CGFloat eAnserX;
@property (nonatomic , assign) CGFloat eAnserY;
@end
NS_ASSUME_NONNULL_END
//
// GeekWorkResult.m
// GeekWorkCorrection
//
// Created by hl on 2020/9/15.
// Copyright © 2020 Facebook. All rights reserved.
//
#import "GeekWorkResult.h"
@implementation GeekWorkResult
+ (NSDictionary *)modelContainerPropertyGenericClass {
return @{
@"chooses" : [NSString class]
};
}
@end
{
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "back.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "close.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "focus.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "ok (2).png",
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
This diff is collapsed.
...@@ -7,7 +7,13 @@ ...@@ -7,7 +7,13 @@
"ios": "react-native run-ios", "ios": "react-native run-ios",
"start": "react-native start", "start": "react-native start",
"test": "jest", "test": "jest",
"lint": "eslint ." "lint": "eslint .",
"codepushserver": "sed -ig 's#BuildConfig.DEBUG#BuildConfig.DEBUG,https://hot.jkwljy.com#g' node_modules/react-native-code-push/package.json",
"codepushsdk": "npm run script.sh",
"geek": "node ./script.js",
"postinstall": "npm run geek",
"build-ios": "react-native bundle --platform ios --entry-file index.js --bundle-output ./bundle/ios/main.jsbundle --assets-dest ./bundle/ios --dev false",
"build-android": "cd android && ./gradlew assembleRelease"
}, },
"dependencies": { "dependencies": {
"@geek/request": "^1.0.0", "@geek/request": "^1.0.0",
...@@ -47,7 +53,6 @@ ...@@ -47,7 +53,6 @@
"babel-jest": "^26.3.0", "babel-jest": "^26.3.0",
"babel-plugin-root-import": "^6.5.0", "babel-plugin-root-import": "^6.5.0",
"eslint": "^7.9.0", "eslint": "^7.9.0",
"jest": "^26.4.2",
"metro-react-native-babel-preset": "^0.63.0", "metro-react-native-babel-preset": "^0.63.0",
"react-test-renderer": "16.9.0", "react-test-renderer": "16.9.0",
"typescript": "^4.0.2" "typescript": "^4.0.2"
......
const fs = require('fs')
const path = require('path')
const CODE_PUSH_ENDPOINT = 'https://hot.jkwljy.com'
function replaceFile (relativePath) {
const realPath = path.resolve(__dirname, ...relativePath.split('/'))
fs.writeFileSync(
realPath,
fs.readFileSync(realPath, { encoding: 'utf-8' })
// .replace(/BuildConfig\.DEBUG\)/, `BuildConfig.DEBUG, \\"${CODE_PUSH_ENDPOINT}\\")`)
.replace(/(BuildConfig\.DEBUG, \\\"http\:\/\/119\.27\.181\.101\:3000\\\"\))|(BuildConfig\.DEBUG\))/, `BuildConfig.DEBUG, \\"${CODE_PUSH_ENDPOINT}\\")`)
)
}
replaceFile('node_modules/react-native-code-push/package.json')
replaceFile('node_modules/react-native-code-push/react-native.config.js')
\ No newline at end of file
...@@ -2,7 +2,7 @@ import React, { useEffect, useState } from 'react' ...@@ -2,7 +2,7 @@ import React, { useEffect, useState } from 'react'
import { View, Text } from "react-native"; import { View, Text } from "react-native";
import { TouchableHighlight } from 'react-native-gesture-handler'; import { TouchableHighlight } from 'react-native-gesture-handler';
import { withStackScreen } from '@/hooks'; import { withStackScreen } from '@/hooks';
// import { showWorkPicker } from '@/rn-module/work-correct'; import { showWorkPicker } from '@/rn-module/work-correct';
const Home = (props: any) => { const Home = (props: any) => {
...@@ -14,7 +14,7 @@ const Home = (props: any) => { ...@@ -14,7 +14,7 @@ const Home = (props: any) => {
return ( return (
<View style={{ flex: 1 }}> <View style={{ flex: 1 }}>
<TouchableHighlight onPress={() => { <TouchableHighlight onPress={() => {
// showWorkPicker(123) showWorkPicker(123)
}}> }}>
<View> <View>
<Text style={{ height: 60, backgroundColor: 'blue' }}>tap ll</Text> <Text style={{ height: 60, backgroundColor: 'blue' }}>tap ll</Text>
......
{
"compilerOptions": {
"allowJs": true,
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
"isolatedModules": true,
"jsx": "react",
"lib": ["es6"],
"moduleResolution": "node",
"noEmit": true,
"strict": true,
"target": "esnext",
"baseUrl": ".",
"paths": {
"@/*": ["./src/*"]
}
},
"exclude": [
"node_modules",
"babel.config.js",
"metro.config.js",
"jest.config.js"
]
}
This source diff could not be displayed because it is too large. You can view the blob instead.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment