-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
brandon_withrow
committed
Aug 2, 2017
1 parent
582a876
commit ac25888
Showing
25 changed files
with
367 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 20 additions & 10 deletions
30
Example/Example for lottie-macos/Assets.xcassets/AppIcon.appiconset/Contents.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,63 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"idiom" : "mac", | ||
"size" : "16x16", | ||
"idiom" : "mac", | ||
"filename" : "[email protected]", | ||
"scale" : "1x" | ||
}, | ||
{ | ||
"idiom" : "mac", | ||
"size" : "16x16", | ||
"idiom" : "mac", | ||
"filename" : "[email protected]", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"idiom" : "mac", | ||
"size" : "32x32", | ||
"idiom" : "mac", | ||
"filename" : "[email protected]", | ||
"scale" : "1x" | ||
}, | ||
{ | ||
"idiom" : "mac", | ||
"size" : "32x32", | ||
"idiom" : "mac", | ||
"filename" : "[email protected]", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"idiom" : "mac", | ||
"size" : "128x128", | ||
"idiom" : "mac", | ||
"filename" : "[email protected]", | ||
"scale" : "1x" | ||
}, | ||
{ | ||
"idiom" : "mac", | ||
"size" : "128x128", | ||
"idiom" : "mac", | ||
"filename" : "[email protected]", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"idiom" : "mac", | ||
"size" : "256x256", | ||
"idiom" : "mac", | ||
"filename" : "[email protected]", | ||
"scale" : "1x" | ||
}, | ||
{ | ||
"idiom" : "mac", | ||
"size" : "256x256", | ||
"idiom" : "mac", | ||
"filename" : "[email protected]", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"idiom" : "mac", | ||
"size" : "512x512", | ||
"idiom" : "mac", | ||
"filename" : "[email protected]", | ||
"scale" : "1x" | ||
}, | ||
{ | ||
"idiom" : "mac", | ||
"size" : "512x512", | ||
"idiom" : "mac", | ||
"filename" : "[email protected]", | ||
"scale" : "2x" | ||
} | ||
], | ||
|
Binary file added
BIN
+8.11 KB
Example/Example for lottie-macos/Assets.xcassets/AppIcon.appiconset/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+16.9 KB
Example/Example for lottie-macos/Assets.xcassets/AppIcon.appiconset/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+1 KB
Example/Example for lottie-macos/Assets.xcassets/AppIcon.appiconset/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+1.75 KB
Example/Example for lottie-macos/Assets.xcassets/AppIcon.appiconset/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+16.9 KB
Example/Example for lottie-macos/Assets.xcassets/AppIcon.appiconset/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+36.9 KB
Example/Example for lottie-macos/Assets.xcassets/AppIcon.appiconset/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+1.75 KB
Example/Example for lottie-macos/Assets.xcassets/AppIcon.appiconset/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+3.64 KB
Example/Example for lottie-macos/Assets.xcassets/AppIcon.appiconset/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+36.9 KB
Example/Example for lottie-macos/Assets.xcassets/AppIcon.appiconset/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+83 KB
Example/Example for lottie-macos/Assets.xcassets/AppIcon.appiconset/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// | ||
// LAMainView.h | ||
// lottie-ios | ||
// | ||
// Created by brandon_withrow on 8/1/17. | ||
// Copyright © 2017 Brandon Withrow. All rights reserved. | ||
// | ||
|
||
#import <Cocoa/Cocoa.h> | ||
|
||
@interface LAMainView : NSView | ||
|
||
- (void)setAnimationProgress:(CGFloat)progress; | ||
- (void)playAnimation; | ||
- (void)rewindAnimation; | ||
- (void)toggleLoop; | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
// | ||
// LAMainView.m | ||
// lottie-ios | ||
// | ||
// Created by brandon_withrow on 8/1/17. | ||
// Copyright © 2017 Brandon Withrow. All rights reserved. | ||
// | ||
|
||
#import "LAMainView.h" | ||
#import <Lottie/Lottie.h> | ||
|
||
@interface LAMainView () | ||
|
||
@property (nonatomic, strong) LOTAnimationView *lottieLogo; | ||
|
||
@end | ||
@implementation LAMainView | ||
|
||
- (instancetype)initWithCoder:(NSCoder *)coder { | ||
self = [super initWithCoder:coder]; | ||
if (self) { | ||
[self commonInit]; | ||
} | ||
return self; | ||
} | ||
|
||
- (instancetype)initWithFrame:(NSRect)frame { | ||
self = [super initWithFrame:frame]; | ||
if (self) { | ||
[self commonInit]; | ||
} | ||
return self; | ||
} | ||
|
||
- (void)commonInit { | ||
NSArray *dragTypes = [NSArray arrayWithObjects:NSFilenamesPboardType, nil]; | ||
[self registerForDraggedTypes:dragTypes]; | ||
|
||
self.lottieLogo = [LOTAnimationView animationNamed:@"LottieLogo1"]; | ||
self.lottieLogo.contentMode = LOTViewContentModeScaleAspectFill; | ||
self.lottieLogo.frame = self.bounds; | ||
self.lottieLogo.autoresizingMask = NSViewWidthSizable | NSViewHeightSizable; | ||
self.lottieLogo.layer.zPosition = -10000; | ||
[self addSubview:self.lottieLogo]; | ||
} | ||
|
||
- (void)viewDidMoveToSuperview { | ||
[self.lottieLogo play]; | ||
} | ||
|
||
- (NSDragOperation)draggingEntered:(id <NSDraggingInfo>)sender { | ||
NSPasteboard *pboard; | ||
NSDragOperation sourceDragMask; | ||
|
||
sourceDragMask = [sender draggingSourceOperationMask]; | ||
pboard = [sender draggingPasteboard]; | ||
|
||
if ( [[pboard types] containsObject:NSColorPboardType] ) { | ||
if (sourceDragMask & NSDragOperationGeneric) { | ||
return NSDragOperationGeneric; | ||
} | ||
} | ||
if ( [[pboard types] containsObject:NSFilenamesPboardType] ) { | ||
if (sourceDragMask & NSDragOperationLink) { | ||
return NSDragOperationLink; | ||
} else if (sourceDragMask & NSDragOperationCopy) { | ||
return NSDragOperationCopy; | ||
} | ||
} | ||
return NSDragOperationNone; | ||
} | ||
|
||
- (BOOL)performDragOperation:(id <NSDraggingInfo>)sender { | ||
NSPasteboard *pboard; | ||
NSDragOperation sourceDragMask; | ||
|
||
sourceDragMask = [sender draggingSourceOperationMask]; | ||
pboard = [sender draggingPasteboard]; | ||
|
||
if ( [[pboard types] containsObject:NSColorPboardType] ) { | ||
// Only a copy operation allowed so just copy the data | ||
|
||
} else if ( [[pboard types] containsObject:NSFilenamesPboardType] ) { | ||
NSArray *files = [pboard propertyListForType:NSFilenamesPboardType]; | ||
|
||
NSArray *jsonFiles = [files pathsMatchingExtensions:@[@"json"]]; | ||
if (jsonFiles.count) { | ||
[self _openAnimationFile:jsonFiles.firstObject]; | ||
} | ||
// Depending on the dragging source and modifier keys, | ||
// the file data may be copied or linked | ||
NSLog(@"FILES"); | ||
} | ||
return YES; | ||
} | ||
|
||
- (void)_openAnimationFile:(NSString *)file { | ||
[self.lottieLogo removeFromSuperview]; | ||
self.lottieLogo = nil; | ||
|
||
self.lottieLogo = [LOTAnimationView animationWithFilePath:file]; | ||
self.lottieLogo.contentMode = LOTViewContentModeScaleAspectFill; | ||
self.lottieLogo.frame = self.bounds; | ||
self.lottieLogo.autoresizingMask = NSViewWidthSizable | NSViewHeightSizable; | ||
|
||
[self addSubview:self.lottieLogo]; | ||
[self.lottieLogo play]; | ||
} | ||
|
||
- (void)setAnimationProgress:(CGFloat)progress { | ||
self.lottieLogo.animationProgress = progress; | ||
} | ||
- (void)playAnimation { | ||
if (self.lottieLogo.isAnimationPlaying) { | ||
[self.lottieLogo pause]; | ||
} else { | ||
[self.lottieLogo play]; | ||
} | ||
} | ||
- (void)rewindAnimation { | ||
[self.lottieLogo stop]; | ||
} | ||
- (void)toggleLoop { | ||
self.lottieLogo.loopAnimation = !self.lottieLogo.loopAnimation; | ||
} | ||
|
||
@end |
Oops, something went wrong.