Skip to content

Commit

Permalink
Initial Commit of the new Lottie Renderer V2
Browse files Browse the repository at this point in the history
  • Loading branch information
brandon_withrow committed Jul 28, 2017
1 parent f537ef9 commit 502b18f
Show file tree
Hide file tree
Showing 252 changed files with 7,259 additions and 1,560 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Expand Up @@ -16,4 +16,5 @@ Lottie-Screenshot/Lottie-Screenshot.xcodeproj/xcuserdata/
Lottie-Screenshot/Pods/Pods.xcodeproj/xcuserdata/
Example/.DS_Store
Example/lottie-ios.xcodeproj/xcuserdata
Example/lottie-ios.xcodeproj/xcuserdata
Example/lottie-ios.xcodeproj/xcuserdata
.DS_Store
6 changes: 3 additions & 3 deletions Example/Podfile.lock
@@ -1,15 +1,15 @@
PODS:
- lottie-ios (1.5.0)
- lottie-ios (1.5.2)

DEPENDENCIES:
- lottie-ios (from `../`)

EXTERNAL SOURCES:
lottie-ios:
:path: ../
:path: "../"

SPEC CHECKSUMS:
lottie-ios: 8b959bce82f84e42d832d605f5bab9d9edba8ad2
lottie-ios: 255a0e95973a5c4424e809d7a5c19f7384c73e84

PODFILE CHECKSUM: 6d1e1685b831b9c2307e9f025c2992df8d660bdb

Expand Down
4 changes: 2 additions & 2 deletions Example/Pods/Local Podspecs/lottie-ios.podspec.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions Example/Pods/Manifest.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2,095 changes: 1,261 additions & 834 deletions Example/Pods/Pods.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

Large diffs are not rendered by default.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
372 changes: 191 additions & 181 deletions Example/lottie-ios.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

12 changes: 12 additions & 0 deletions Example/lottie-ios/AnimationExplorerViewController.m
Expand Up @@ -8,6 +8,7 @@

#import "AnimationExplorerViewController.h"
#import "JSONExplorerViewController.h"
#import "LAQRScannerViewController.h"
#import <Lottie/Lottie.h>

typedef enum : NSUInteger {
Expand Down Expand Up @@ -144,6 +145,17 @@ - (void)_setBGColor:(UIBarButtonItem *)button {
}

- (void)_showURLInput {
LAQRScannerViewController *qrVC = [[LAQRScannerViewController alloc] init];
[qrVC setCompletionBlock:^(NSString *selectedAnimation) {
if (selectedAnimation) {
[self _loadAnimationFromURLString:selectedAnimation];
}
[self dismissViewControllerAnimated:YES completion:NULL];
}];
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:qrVC];
[self presentViewController:nav animated:YES completion:NULL];
return;

UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"Load From URL"
message:NULL
preferredStyle:UIAlertControllerStyleAlert];
Expand Down
15 changes: 15 additions & 0 deletions Example/lottie-ios/LAQRScannerViewController.h
@@ -0,0 +1,15 @@
//
// LAQRScannerViewController.h
// lottie-ios
//
// Created by brandon_withrow on 7/27/17.
// Copyright © 2017 Brandon Withrow. All rights reserved.
//

#import <UIKit/UIKit.h>

@interface LAQRScannerViewController : UIViewController

@property (nonatomic, copy) void (^completionBlock)(NSString *jsonURL);

@end
106 changes: 106 additions & 0 deletions Example/lottie-ios/LAQRScannerViewController.m
@@ -0,0 +1,106 @@
//
// LAQRScannerViewController.m
// lottie-ios
//
// Created by brandon_withrow on 7/27/17.
// Copyright © 2017 Brandon Withrow. All rights reserved.
//

#import "LAQRScannerViewController.h"
#import <AVFoundation/AVFoundation.h>

@interface LAQRScannerViewController () <AVCaptureMetadataOutputObjectsDelegate>
@property (nonatomic) BOOL isReading;
@property (strong, nonatomic) UIView *viewPreview;
@property (nonatomic, strong) AVCaptureSession *captureSession;
@property (nonatomic, strong) AVCaptureVideoPreviewLayer *videoPreviewLayer;
@end

@implementation LAQRScannerViewController

- (void)viewDidLoad {
[super viewDidLoad];
self.view.backgroundColor = [UIColor whiteColor];
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Close"
style:UIBarButtonItemStyleDone
target:self
action:@selector(_closePressed)];
self.viewPreview = [[UIView alloc] initWithFrame:self.view.bounds];
self.viewPreview.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
[self.view addSubview:self.viewPreview];
_isReading = NO;

_captureSession = nil;
}

- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
if (!_isReading) {
_isReading = [self startReading];
}
}

- (BOOL)startReading {
NSError *error;

AVCaptureDevice *captureDevice = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];

AVCaptureDeviceInput *input = [AVCaptureDeviceInput deviceInputWithDevice:captureDevice error:&error];
if (!input) {
NSLog(@"%@", [error localizedDescription]);
return NO;
}

_captureSession = [[AVCaptureSession alloc] init];
[_captureSession addInput:input];

AVCaptureMetadataOutput *captureMetadataOutput = [[AVCaptureMetadataOutput alloc] init];
[_captureSession addOutput:captureMetadataOutput];

dispatch_queue_t dispatchQueue;
dispatchQueue = dispatch_queue_create("myQueue", NULL);
[captureMetadataOutput setMetadataObjectsDelegate:self queue:dispatchQueue];
[captureMetadataOutput setMetadataObjectTypes:[NSArray arrayWithObject:AVMetadataObjectTypeQRCode]];

if (_videoPreviewLayer) {
[_videoPreviewLayer removeFromSuperlayer];
_videoPreviewLayer = nil;
}
_videoPreviewLayer = [[AVCaptureVideoPreviewLayer alloc] initWithSession:_captureSession];
[_videoPreviewLayer setVideoGravity:AVLayerVideoGravityResizeAspectFill];
[_videoPreviewLayer setFrame:_viewPreview.layer.bounds];
[_viewPreview.layer addSublayer:_videoPreviewLayer];

[_captureSession startRunning];

return YES;
}

-(void)captureOutput:(AVCaptureOutput *)captureOutput didOutputMetadataObjects:(NSArray *)metadataObjects fromConnection:(AVCaptureConnection *)connection{
if (metadataObjects != nil && [metadataObjects count] > 0) {
AVMetadataMachineReadableCodeObject *metadataObj = [metadataObjects objectAtIndex:0];
if ([[metadataObj type] isEqualToString:AVMetadataObjectTypeQRCode]) {
[self performSelectorOnMainThread:@selector(stopReadingWithString:) withObject:[metadataObj stringValue] waitUntilDone:NO];
}
}
}

- (void)stopReadingWithString:(NSString *)urlString {
if (_isReading) {
_isReading = NO;
[_captureSession stopRunning];
_captureSession = nil;
[_videoPreviewLayer removeFromSuperlayer];
_videoPreviewLayer = nil;
if (self.completionBlock) {
self.completionBlock(urlString);
}
}

}

- (void)_closePressed {
[self stopReadingWithString:nil];
}

@end
2 changes: 2 additions & 0 deletions Example/lottie-ios/lottie-ios-Info.plist
Expand Up @@ -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>Used to scan Barcodes</string>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleDisplayName</key>
Expand Down
Expand Up @@ -37,7 +37,7 @@ - (void)testAnimationProgress:(float)progress {

self.animationView.animationProgress = progress;
[self waitForExpectationsWithTimeout:1 handler:^(NSError * _Nullable error) {
FBSnapshotVerifyView(self.animationView.layer, nil);
FBSnapshotVerifyViewWithOptions(self.animationView.layer, nil, FBSnapshotTestCaseDefaultSuffixes(), 0.005);
}];
}

Expand Down
6 changes: 3 additions & 3 deletions Lottie-Screenshot/Podfile.lock
@@ -1,18 +1,18 @@
PODS:
- FBSnapshotTestCase/Core (2.1.4)
- lottie-ios (1.5.1)
- lottie-ios (1.5.2)

DEPENDENCIES:
- FBSnapshotTestCase/Core
- lottie-ios (from `../`)

EXTERNAL SOURCES:
lottie-ios:
:path: ../
:path: "../"

SPEC CHECKSUMS:
FBSnapshotTestCase: 094f9f314decbabe373b87cc339bea235a63e07a
lottie-ios: f680a7c4cb7a567ecf258fde0f967913aff111b8
lottie-ios: 255a0e95973a5c4424e809d7a5c19f7384c73e84

PODFILE CHECKSUM: 3901ca88392ceeedc459164e7080c5f357e54e04

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Lottie-Screenshot/Pods/Local Podspecs/lottie-ios.podspec.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 502b18f

Please sign in to comment.