Permalink
Browse files

Initial commit

  • Loading branch information...
0 parents commit 956f929d3216bd38e390912557cd18527eac7726 David Pitman committed Dec 7, 2011
@@ -0,0 +1,3 @@
+[submodule "RestKit"]
+ path = RestKit
+ url = git://github.com/RestKit/RestKit.git

Large diffs are not rendered by default.

Oops, something went wrong.
0 README
No changes.
Submodule RestKit added at ec13fb

Large diffs are not rendered by default.

Oops, something went wrong.

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
@@ -0,0 +1,10 @@
+<?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>IDEWorkspaceUserSettings_HasAskedToTakeAutomaticSnapshotBeforeSignificantChanges</key>
+ <true/>
+ <key>IDEWorkspaceUserSettings_SnapshotAutomaticallyBeforeSignificantChanges</key>
+ <false/>
+</dict>
+</plist>
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Bucket
+ type = "1"
+ version = "1.0">
+</Bucket>
@@ -0,0 +1,84 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Scheme
+ version = "1.3">
+ <BuildAction
+ parallelizeBuildables = "YES"
+ buildImplicitDependencies = "YES">
+ <BuildActionEntries>
+ <BuildActionEntry
+ buildForTesting = "YES"
+ buildForRunning = "YES"
+ buildForProfiling = "YES"
+ buildForArchiving = "YES"
+ buildForAnalyzing = "YES">
+ <BuildableReference
+ BuildableIdentifier = "primary"
+ BlueprintIdentifier = "AE6CB11B148EC9C100BAAE24"
+ BuildableName = "Streammmer.app"
+ BlueprintName = "Streammmer"
+ ReferencedContainer = "container:Streammmer.xcodeproj">
+ </BuildableReference>
+ </BuildActionEntry>
+ </BuildActionEntries>
+ </BuildAction>
+ <TestAction
+ selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.GDB"
+ selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.GDB"
+ shouldUseLaunchSchemeArgsEnv = "YES"
+ buildConfiguration = "Debug">
+ <Testables>
+ </Testables>
+ <MacroExpansion>
+ <BuildableReference
+ BuildableIdentifier = "primary"
+ BlueprintIdentifier = "AE6CB11B148EC9C100BAAE24"
+ BuildableName = "Streammmer.app"
+ BlueprintName = "Streammmer"
+ ReferencedContainer = "container:Streammmer.xcodeproj">
+ </BuildableReference>
+ </MacroExpansion>
+ </TestAction>
+ <LaunchAction
+ selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.GDB"
+ selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.GDB"
+ launchStyle = "0"
+ useCustomWorkingDirectory = "NO"
+ buildConfiguration = "Debug"
+ debugDocumentVersioning = "YES"
+ allowLocationSimulation = "YES">
+ <BuildableProductRunnable>
+ <BuildableReference
+ BuildableIdentifier = "primary"
+ BlueprintIdentifier = "AE6CB11B148EC9C100BAAE24"
+ BuildableName = "Streammmer.app"
+ BlueprintName = "Streammmer"
+ ReferencedContainer = "container:Streammmer.xcodeproj">
+ </BuildableReference>
+ </BuildableProductRunnable>
+ <AdditionalOptions>
+ </AdditionalOptions>
+ </LaunchAction>
+ <ProfileAction
+ shouldUseLaunchSchemeArgsEnv = "YES"
+ savedToolIdentifier = ""
+ useCustomWorkingDirectory = "NO"
+ buildConfiguration = "Release"
+ debugDocumentVersioning = "YES">
+ <BuildableProductRunnable>
+ <BuildableReference
+ BuildableIdentifier = "primary"
+ BlueprintIdentifier = "AE6CB11B148EC9C100BAAE24"
+ BuildableName = "Streammmer.app"
+ BlueprintName = "Streammmer"
+ ReferencedContainer = "container:Streammmer.xcodeproj">
+ </BuildableReference>
+ </BuildableProductRunnable>
+ </ProfileAction>
+ <AnalyzeAction
+ buildConfiguration = "Debug">
+ </AnalyzeAction>
+ <ArchiveAction
+ buildConfiguration = "Release"
+ revealArchiveInOrganizer = "YES">
+ </ArchiveAction>
+</Scheme>
@@ -0,0 +1,22 @@
+<?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>SchemeUserState</key>
+ <dict>
+ <key>Streammmer.xcscheme</key>
+ <dict>
+ <key>orderHint</key>
+ <integer>0</integer>
+ </dict>
+ </dict>
+ <key>SuppressBuildableAutocreation</key>
+ <dict>
+ <key>AE6CB11B148EC9C100BAAE24</key>
+ <dict>
+ <key>primary</key>
+ <true/>
+ </dict>
+ </dict>
+</dict>
+</plist>
@@ -0,0 +1,17 @@
+//
+// SMAppDelegate.h
+// Streammmer
+//
+// Created by David Pitman on 12/6/11.
+// Copyright (c) 2011 __MyCompanyName__. All rights reserved.
+//
+
+#import <Cocoa/Cocoa.h>
+
+@interface SMAppDelegate : NSObject <NSApplicationDelegate>
+
+@property (assign) IBOutlet NSWindow *window;
+
+@property(retain) IBOutlet NSView* scrollView;
+
+@end
@@ -0,0 +1,85 @@
+//
+// SMAppDelegate.m
+// Streammmer
+//
+// Created by David Pitman on 12/6/11.
+// Copyright (c) 2011 __MyCompanyName__. All rights reserved.
+//
+
+#import "SMAppDelegate.h"
+#import <RestKit/RestKit.h>
+#import <QuartzCore/QuartzCore.h>
+#import "Shot.h"
+#import "ShotsGalleryView.h"
+
+@implementation SMAppDelegate
+
+@synthesize window = _window;
+@synthesize scrollView = _scrollView;
+
+- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
+{
+ RKClient *client = [RKClient clientWithBaseURL:@"http://api.dribbble.com/"];
+ RKObjectMapping *shotMapping = [RKObjectMapping mappingForClass:[Shot class]];
+ [shotMapping mapKeyPath:@"id" toAttribute:@"identifier"];
+ [shotMapping mapKeyPath:@"title" toAttribute:@"title"];
+ [shotMapping mapKeyPath:@"url" toAttribute:@"url"];
+ [shotMapping mapKeyPath:@"short_url" toAttribute:@"shortURL"];
+ [shotMapping mapKeyPath:@"image_url" toAttribute:@"imageURL"];
+ [shotMapping mapKeyPath:@"image_teaser_url" toAttribute:@"imageTeaserURL"];
+ [shotMapping mapKeyPath:@"width" toAttribute:@"width"];
+ [shotMapping mapKeyPath:@"height" toAttribute:@"height"];
+ [shotMapping mapKeyPath:@"views_count" toAttribute:@"viewsCount"];
+ [shotMapping mapKeyPath:@"likes_count" toAttribute:@"likesCount"];
+ [shotMapping mapKeyPath:@"comments_count" toAttribute:@"commentsCount"];
+ [shotMapping mapKeyPath:@"rebounds_count" toAttribute:@"reboundsCount"];
+ [shotMapping mapKeyPath:@"rebound_source_id" toAttribute:@"reboundSourceID"];
+ [shotMapping mapKeyPath:@"created_at" toAttribute:@"createdAt"];
+
+
+ RKObjectManager* manager = [RKObjectManager objectManagerWithBaseURL:@"http://localhost:8000"];
+ [[RKObjectManager sharedManager].mappingProvider setMapping:shotMapping forKeyPath:@"shots"];
+
+ [[RKObjectManager sharedManager] loadObjectsAtResourcePath:@"/following.json" delegate:self];
+}
+
+// RKObjectLoaderDelegate methods
+
+- (void)objectLoader:(RKObjectLoader *)objectLoader didLoadObjects:(NSArray *)objects {
+ Shot *shot = [objects objectAtIndex:0];
+ NSLog(@"Loaded Shot ID #%@ -> Title: %@, URL: %@", shot.identifier, shot.title, shot.url);
+ CALayer* superLayer = [CALayer layer];
+ superLayer.layoutManager=[CAConstraintLayoutManager layoutManager];
+ [superLayer setBackgroundColor:CGColorCreateGenericRGB(0.0, 0.0, 0.0, 0.4)];
+ NSString* previousLayer = @"superlayer";
+ CAConstraintAttribute relativeYPosition = kCAConstraintMaxY;
+ for (int i = 0; i < 10; i++) {
+ Shot* shot = (Shot*)[objects objectAtIndex:i];
+ CALayer* shotLayer = [CALayer layer];
+ shotLayer.name = [shot.identifier stringValue];
+ //NSLog(@"URL %@", shot.imageURL);
+ NSImage* shotImage = [[NSImage alloc] initWithContentsOfURL:shot.imageTeaserURL];
+ //shotLayer.bounds = CGRectMake(0, 0, [shot.width floatValue], [shot.height floatValue]);
+ shotLayer.bounds = CGRectMake(0, 0, shotImage.size.width, shotImage.size.height);
+ shotLayer.contents = shotImage;
+ [shotLayer addConstraint:[CAConstraint constraintWithAttribute:kCAConstraintMaxY
+ relativeTo:previousLayer
+ attribute:relativeYPosition]];
+ [shotLayer addConstraint:[CAConstraint constraintWithAttribute:kCAConstraintMidX
+ relativeTo:@"superlayer"
+ attribute:kCAConstraintMidX]];
+ NSLog(@"Layer: %@ %@ <- %@", shotLayer, shotLayer.name, previousLayer);
+ previousLayer = shotLayer.name;
+ [superLayer addSublayer:shotLayer];
+ relativeYPosition = kCAConstraintMinY;
+ }
+ [_scrollView setWantsLayer:YES];
+ [_scrollView setLayer:superLayer];
+ [_scrollView setNeedsLayout:YES];
+}
+
+- (void)objectLoader:(RKObjectLoader *)objectLoader didFailWithError:(NSError *)error {
+ NSLog(@"Encountered an error: %@", error);
+}
+
+@end
@@ -0,0 +1,32 @@
+//
+// Shots.h
+// Streammmer
+//
+// Created by David Pitman on 12/6/11.
+// Copyright (c) 2011 __MyCompanyName__. All rights reserved.
+//
+
+#import <Foundation/Foundation.h>
+#import <Cocoa/Cocoa.h>
+
+@interface Shot : NSObject
+
+// Mapping out the Dribbbl API
+@property(retain) NSNumber* identifier;
+@property(retain) NSString* title;
+
+@property(retain) NSURL* url;
+@property(retain) NSURL* shortURL;
+@property(retain) NSURL* imageURL;
+@property(retain) NSURL* imageTeaserURL;
+
+@property(retain) NSNumber* width;
+@property(retain) NSNumber* height;
+@property(retain) NSNumber* viewsCount;
+@property(retain) NSNumber* likesCount;
+@property(retain) NSNumber* commentsCount;
+@property(retain) NSNumber* reboundsCount;
+@property(retain) NSNumber* reboundSourceID;
+@property(retain) NSDate* createdAt;
+
+@end
@@ -0,0 +1,30 @@
+//
+// Shots.m
+// Streammmer
+//
+// Created by David Pitman on 12/6/11.
+// Copyright (c) 2011 __MyCompanyName__. All rights reserved.
+//
+
+#import "Shot.h"
+
+@implementation Shot
+
+@synthesize identifier;
+@synthesize title;
+
+@synthesize url;
+@synthesize shortURL;
+@synthesize imageURL;
+@synthesize imageTeaserURL;
+
+@synthesize width;
+@synthesize height;
+@synthesize viewsCount;
+@synthesize likesCount;
+@synthesize commentsCount;
+@synthesize reboundsCount;
+@synthesize reboundSourceID;
+@synthesize createdAt;
+
+@end
@@ -0,0 +1,15 @@
+//
+// ShotsGalleryView.h
+// Streammmer
+//
+// Created by David Pitman on 12/6/11.
+// Copyright (c) 2011 __MyCompanyName__. All rights reserved.
+//
+
+#import <Cocoa/Cocoa.h>
+
+@interface ShotsGalleryView : NSView
+
+-(void)loadShots:(NSArray*)shots;
+
+@end
@@ -0,0 +1,58 @@
+//
+// ShotsGalleryView.m
+// Streammmer
+//
+// Created by David Pitman on 12/6/11.
+// Copyright (c) 2011 __MyCompanyName__. All rights reserved.
+//
+
+#import "ShotsGalleryView.h"
+#import <QuartzCore/QuartzCore.h>
+#import "Shot.h"
+
+@implementation ShotsGalleryView
+
+- (id)initWithFrame:(NSRect)frame
+{
+ self = [super initWithFrame:frame];
+ if (self) {
+
+ }
+
+ return self;
+}
+
+//- (void)drawRect:(NSRect)dirtyRect
+//{
+// [super drawRect:dirtyRect];
+// // Drawing code here.
+//}
+
+-(void)loadShots:(NSArray*)shots{
+ CALayer* superLayer = [self layer];
+ superLayer.layoutManager=[CAConstraintLayoutManager layoutManager];
+ [superLayer setBackgroundColor:CGColorCreateGenericRGB(0.0, 0.0, 0.0, 0.4)];
+ NSString* previousLayer = @"superlayer";
+ for (int i = 0; i < 10; i++) {
+ Shot* shot = (Shot*)[shots objectAtIndex:i];
+ CALayer* shotLayer = [CALayer layer];
+ shotLayer.borderWidth = 2;
+ shotLayer.borderColor = CGColorCreateGenericRGB(255, 0, 0, 0.5);
+ shotLayer.name = [shot.identifier stringValue];
+ NSLog(@"URL %@", shot.imageURL);
+ shotLayer.bounds = CGRectMake(0, 0, [shot.width floatValue], [shot.height floatValue]);
+ NSImage* shotImage = [[NSImage alloc] initWithContentsOfURL:shot.imageURL];
+ //shotLayer.contents = shotImage;
+ [shotLayer addConstraint:[CAConstraint constraintWithAttribute:kCAConstraintMaxY
+ relativeTo:previousLayer
+ attribute:kCAConstraintMaxY]];
+ NSLog(@"Layer: %@ %@ <- %@", shotLayer, shotLayer.name, previousLayer);
+ previousLayer = shotLayer.name;
+ [superLayer addSublayer:shotLayer];
+ }
+ [self setLayer:superLayer];
+ [self setNeedsLayout:YES];
+ [self setNeedsDisplay:YES];
+}
+
+@end
Oops, something went wrong.

0 comments on commit 956f929

Please sign in to comment.