Permalink
Browse files

adds demo project

  • Loading branch information...
1 parent 8397169 commit 07a74243937c3e40ff301a476fc1d6063c22e405 @andrewroycarter committed Apr 28, 2013

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -0,0 +1,38 @@
+<?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>CFBundleDevelopmentRegion</key>
+ <string>en</string>
+ <key>CFBundleDisplayName</key>
+ <string>${PRODUCT_NAME}</string>
+ <key>CFBundleExecutable</key>
+ <string>${EXECUTABLE_NAME}</string>
+ <key>CFBundleIdentifier</key>
+ <string>com.pinchstudios.${PRODUCT_NAME:rfc1034identifier}</string>
+ <key>CFBundleInfoDictionaryVersion</key>
+ <string>6.0</string>
+ <key>CFBundleName</key>
+ <string>${PRODUCT_NAME}</string>
+ <key>CFBundlePackageType</key>
+ <string>APPL</string>
+ <key>CFBundleShortVersionString</key>
+ <string>1.0</string>
+ <key>CFBundleSignature</key>
+ <string>????</string>
+ <key>CFBundleVersion</key>
+ <string>1.0</string>
+ <key>LSRequiresIPhoneOS</key>
+ <true/>
+ <key>UIRequiredDeviceCapabilities</key>
+ <array>
+ <string>armv7</string>
+ </array>
+ <key>UISupportedInterfaceOrientations</key>
+ <array>
+ <string>UIInterfaceOrientationPortrait</string>
+ <string>UIInterfaceOrientationLandscapeLeft</string>
+ <string>UIInterfaceOrientationLandscapeRight</string>
+ </array>
+</dict>
+</plist>
@@ -0,0 +1,14 @@
+//
+// Prefix header for all source files of the 'ACTimeScrollerDemo' target in the 'ACTimeScrollerDemo' project
+//
+
+#import <Availability.h>
+
+#ifndef __IPHONE_3_0
+#warning "This project uses features only available in iOS SDK 3.0 and later."
+#endif
+
+#ifdef __OBJC__
+ #import <UIKit/UIKit.h>
+ #import <Foundation/Foundation.h>
+#endif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -0,0 +1,15 @@
+//
+// PSAppDelegate.h
+// ACTimeScrollerDemo
+//
+// Created by Andrew Carter on 4/28/13.
+// Copyright (c) 2013 Pinch Studios. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+
+@interface PSAppDelegate : UIResponder <UIApplicationDelegate>
+
+@property (strong, nonatomic) UIWindow *window;
+
+@end
@@ -0,0 +1,26 @@
+//
+// PSAppDelegate.m
+// ACTimeScrollerDemo
+//
+// Created by Andrew Carter on 4/28/13.
+// Copyright (c) 2013 Pinch Studios. All rights reserved.
+//
+
+#import "PSAppDelegate.h"
+
+#import "PSRootViewController.h"
+
+@implementation PSAppDelegate
+
+- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
+{
+ self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
+
+ PSRootViewController *rootViewController = [[PSRootViewController alloc] initWithStyle:UITableViewStylePlain];
+ [[self window] setRootViewController:rootViewController];
+
+ [self.window makeKeyAndVisible];
+ return YES;
+}
+
+@end
@@ -0,0 +1,13 @@
+//
+// PSRootViewController.h
+// ACTimeScrollerDemo
+//
+// Created by Andrew Carter on 4/28/13.
+// Copyright (c) 2013 Pinch Studios. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+
+@interface PSRootViewController : UITableViewController
+
+@end
@@ -0,0 +1,119 @@
+//
+// PSRootViewController.m
+// ACTimeScrollerDemo
+//
+// Created by Andrew Carter on 4/28/13.
+// Copyright (c) 2013 Pinch Studios. All rights reserved.
+//
+
+#import "PSRootViewController.h"
+
+#import "ACTimeScroller.h"
+
+NSString * const PSTableViewCellIdentifier = @"PSTableViewCellIdentifier";
+
+@interface PSRootViewController () <ACTimeScrollerDelegate>
+{
+ NSMutableArray *_datasource;
+ ACTimeScroller *_timeScroller;
+}
+
+@end
+
+@implementation PSRootViewController
+
+#pragma mark - UITableViewController Overrides
+
+- (id)initWithStyle:(UITableViewStyle)style
+{
+ self = [super initWithStyle:style];
+ if (self)
+ {
+ [self setupDatasource];
+ }
+ return self;
+}
+
+- (void)viewDidLoad
+{
+ _timeScroller = [[ACTimeScroller alloc] initWithDelegate:self];
+ [[self tableView] registerClass:[UITableViewCell class] forCellReuseIdentifier:PSTableViewCellIdentifier];
+}
+
+#pragma mark - Instance Methods
+
+- (void)setupDatasource
+{
+ _datasource = [NSMutableArray new];
+
+ NSCalendar *calendar = [NSCalendar currentCalendar];
+ NSDateComponents *components = [[NSDateComponents alloc] init];
+ NSDate *today = [NSDate date];
+ NSDateComponents *todayComponents = [calendar components:NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit fromDate:today];
+
+ for (int i = [todayComponents day]; i >= -15; i--)
+ {
+ [components setYear:[todayComponents year]];
+ [components setMonth:[todayComponents month]];
+ [components setDay:i];
+ [components setHour:arc4random() % 23];
+ [components setMinute:arc4random() % 59];
+
+ NSDate *date = [calendar dateFromComponents:components];
+ [_datasource addObject:date];
+ }
+}
+
+#pragma mark - ACTimeScrollerDelegate Methods
+
+- (UITableView *)tableViewForTimeScroller:(ACTimeScroller *)timeScroller
+{
+ return [self tableView];
+}
+
+- (NSDate *)timeScroller:(ACTimeScroller *)timeScroller dateForCell:(UITableViewCell *)cell
+{
+ NSIndexPath *indexPath = [[self tableView] indexPathForCell:cell];
+ return _datasource[[indexPath row]];
+}
+
+#pragma mark - UITableViewDatasource Methods
+
+- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
+{
+ UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:PSTableViewCellIdentifier];
+
+ NSDate *date = _datasource[[indexPath row]];
+ [[cell textLabel] setText:[date description]];
+
+ return cell;
+}
+
+- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
+{
+ return [_datasource count];
+}
+
+- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
+{
+ return 1;
+}
+
+#pragma mark - UIScrollViewDelegate Methods
+
+- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView
+{
+ [_timeScroller scrollViewWillBeginDragging];
+}
+
+- (void)scrollViewDidScroll:(UIScrollView *)scrollView
+{
+ [_timeScroller scrollViewDidScroll];
+}
+
+- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
+{
+ [_timeScroller scrollViewDidEndDecelerating];
+}
+
+@end
@@ -0,0 +1,2 @@
+/* Localized versions of Info.plist keys */
+
@@ -0,0 +1,18 @@
+//
+// main.m
+// ACTimeScrollerDemo
+//
+// Created by Andrew Carter on 4/28/13.
+// Copyright (c) 2013 Pinch Studios. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+
+#import "PSAppDelegate.h"
+
+int main(int argc, char *argv[])
+{
+ @autoreleasepool {
+ return UIApplicationMain(argc, argv, nil, NSStringFromClass([PSAppDelegate class]));
+ }
+}

0 comments on commit 07a7424

Please sign in to comment.