Permalink
Browse files

Initial Project Commit

  • Loading branch information...
0 parents commit 40384977627df539381ea1f208982d8d229aa153 Eric Crichlow committed Sep 1, 2011
Showing with 2,352 additions and 0 deletions.
  1. +44 −0 .gitignore
  2. +355 −0 Dynamic Table Demo.xcodeproj/project.pbxproj
  3. +7 −0 Dynamic Table Demo.xcodeproj/project.xcworkspace/contents.xcworkspacedata
  4. +25 −0 Dynamic Table Demo/AppDelegate.h
  5. +40 −0 Dynamic Table Demo/AppDelegate.m
  6. +58 −0 Dynamic Table Demo/DemoTableViewController.h
  7. +203 −0 Dynamic Table Demo/DemoTableViewController.m
  8. +37 −0 Dynamic Table Demo/Dynamic Table Demo-Info.plist
  9. +15 −0 Dynamic Table Demo/Dynamic Table Demo-Prefix.pch
  10. BIN Dynamic Table Demo/Images/camera.png
  11. BIN Dynamic Table Demo/Images/cameraSelected.png
  12. BIN Dynamic Table Demo/Images/checkBox.png
  13. BIN Dynamic Table Demo/Images/checkBoxChecked.png
  14. BIN Dynamic Table Demo/Images/comboBox.png
  15. BIN Dynamic Table Demo/Images/comboBoxSelected.png
  16. BIN Dynamic Table Demo/Images/popupButton.png
  17. BIN Dynamic Table Demo/Images/popupButtonSelected.png
  18. +30 −0 Dynamic Table Demo/MockDataManager.h
  19. +77 −0 Dynamic Table Demo/MockDataManager.m
  20. +47 −0 Dynamic Table Demo/Reusable Dynamic Table Cell Classes/EditableTableDataRow.h
  21. +216 −0 Dynamic Table Demo/Reusable Dynamic Table Cell Classes/EditableTableDataRow.m
  22. +75 −0 Dynamic Table Demo/Reusable Dynamic Table Cell Classes/EditableTableDataRowItem.h
  23. +405 −0 Dynamic Table Demo/Reusable Dynamic Table Cell Classes/EditableTableDataRowItem.m
  24. +405 −0 Dynamic Table Demo/en.lproj/DemoTableViewController.xib
  25. +2 −0 Dynamic Table Demo/en.lproj/InfoPlist.strings
  26. +25 −0 Dynamic Table Demo/main.m
  27. +286 −0 ReadMe.rtf
@@ -0,0 +1,44 @@
+# taken from http://blog.illuminex.com/2009/10/better-sample-gitignore-file-for-xcode.html
+
+# Mac OS X Finder and whatnot
+.DS_Store
+
+
+# Sparkle distribution Private Key (Don't check me in!)
+dsa_priv.pem
+
+
+# XCode (and ancestors) per-user config (very noisy, and not relevant)
+*.mode1
+*.mode1v3
+*.mode2v3
+*.perspective
+*.perspectivev3
+*.pbxuser
+
+# Xcode 4 http://stackoverflow.com/questions/49478/git-ignore-file-for-xcode-projects
+xcuserdata
+
+
+# Generated files
+VersionX-revision.h
+
+
+# build products
+build/
+*.[oa]
+
+# Other source repository archive directories (protects when importing)
+.hg
+.svn
+CVS
+
+
+# automatic backup files
+*~.nib
+*.swp
+*~
+*(Autosaved).rtfd/
+Backup[ ]of[ ]*.pages/
+Backup[ ]of[ ]*.key/
+Backup[ ]of[ ]*.numbers/

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,25 @@
+/*******************************************************************************
+ * AppDelegate.h
+ *
+ * Title: Dynamic Table Demo
+ * Description: Demo App for Dynamic, Editable Table Cell Classes
+ * This header file contains the template for the
+ * application's delegated methods
+ * Author: Eric Crichlow
+ * Version: 1.0
+ * Copyright: (c) 2011 Infusions of Grandeur. All rights reserved.
+ ********************************************************************************
+ * 08/27/11 * EGC * File creation date
+ *******************************************************************************/
+
+#import <UIKit/UIKit.h>
+#import "DemoTableViewController.h"
+
+@class ViewController;
+
+@interface AppDelegate : UIResponder <UIApplicationDelegate>
+{
+}
+@property (nonatomic, retain) IBOutlet UIWindow *window;
+@property (nonatomic, retain) IBOutlet DemoTableViewController *demoTableViewController;
+@end
@@ -0,0 +1,40 @@
+/*******************************************************************************
+ * AppDelegate.m
+ *
+ * Title: Dynamic Table Demo
+ * Description: Demo App for Dynamic, Editable Table Cell Classes
+ * This header file contains the implementation for the
+ * application's delegated methods
+ * Author: Eric Crichlow
+ * Version: 1.0
+ * Copyright: (c) 2011 Infusions of Grandeur. All rights reserved.
+ ********************************************************************************
+ * 08/27/11 * EGC * File creation date
+ *******************************************************************************/
+
+#import "AppDelegate.h"
+#import "DemoTableViewController.h"
+
+@implementation AppDelegate
+
+@synthesize window = _window;
+@synthesize demoTableViewController;
+
+- (void)dealloc
+{
+ [_window release];
+ [demoTableViewController release];
+ [super dealloc];
+}
+
+- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
+{
+
+ self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
+ self.demoTableViewController = [[[DemoTableViewController alloc] initWithNibName:@"DemoTableViewController" bundle:nil] autorelease];
+ self.window.rootViewController = self.demoTableViewController;
+ [self.window makeKeyAndVisible];
+ return YES;
+}
+
+@end
@@ -0,0 +1,58 @@
+/*******************************************************************************
+ * DemoTableViewController.h
+ *
+ * Title: Dynamic Table Demo
+ * Description: Demo App for Dynamic, Editable Table Cell Classes
+ * This header file contains the template for the
+ * application's main (only) view
+ * Author: Eric Crichlow
+ * Version: 1.0
+ * Copyright: (c) 2011 Infusions of Grandeur. All rights reserved.
+ ********************************************************************************
+ * 08/27/11 * EGC * File creation date
+ *******************************************************************************/
+
+#import <UIKit/UIKit.h>
+#import "MockDataManager.h"
+#import "EditableTableDataRow.h"
+
+#define DEFAULT_ROW_ITEM_PADDING 36
+
+#define TABLE_COLUMN_YEAR 0
+#define TABLE_COLUMN_MAKE 1
+#define TABLE_COLUMN_MODEL 2
+#define TABLE_COLUMN_COLOR 3
+#define TABLE_COLUMN_MILEAGE 4
+#define TABLE_COLUMN_TITLED 5
+#define TABLE_COLUMN_IMAGE 6
+
+#define YEAR_COLUMN_RELATIVE_WIDTH 45
+#define MAKE_COLUMN_RELATIVE_WIDTH 100
+#define MODEL_COLUMN_RELATIVE_WIDTH 100
+#define COLOR_COLUMN_RELATIVE_WIDTH 80
+#define MILEAGE_COLUMN_RELATIVE_WIDTH 80
+#define TITLED_COLUMN_RELATIVE_WIDTH 30
+#define IMAGE_COLUMN_RELATIVE_WIDTH 40
+#define NUMBER_OF_DATA_FIELDS 7
+
+#define DEFAULT_POPOVER_WIDTH 320
+#define DEFAULT_POPUP_HEIGHT 21
+#define DEFAULT_COMBO_HEIGHT 24
+#define DEFAULT_TEXTFIELD_HEIGHT 24
+
+#define TABLE_HEADER_LABEL_PORTRAIT @" Year Make Model Color Mileage Titled? Image"
+#define TABLE_HEADER_LABEL_LANDSCAPE @" Year Make Model Color Mileage Titled? Image"
+
+
+@interface DemoTableViewController : UIViewController <UITableViewDelegate, UITableViewDataSource, EditableTableDataRowDelegate>
+{
+
+ UITableView *autoTableView;
+ UILabel *tableHeader;
+
+ MockDataManager *dataManager;
+}
+@property (nonatomic, retain) IBOutlet UITableView *autoTableView;
+@property (nonatomic, retain) IBOutlet UILabel *tableHeader;
+- (IBAction)addAuto:(id)sender;
+@end
@@ -0,0 +1,203 @@
+/*******************************************************************************
+ * DemoTableViewController.m
+ *
+ * Title: Dynamic Table Demo
+ * Description: Demo App for Dynamic, Editable Table Cell Classes
+ * This header file contains the template for the
+ * application's main (only) view
+ * Author: Eric Crichlow
+ * Version: 1.0
+ * Copyright: (c) 2011 Infusions of Grandeur. All rights reserved.
+ ********************************************************************************
+ * 08/27/11 * EGC * File creation date
+ *******************************************************************************/
+
+#import "DemoTableViewController.h"
+#import "AppDelegate.h"
+#import "EditableTableDataRow.h"
+#import "EditableTableDataRowItem.h"
+
+@implementation DemoTableViewController
+
+@synthesize autoTableView;
+@synthesize tableHeader;
+
+#pragma mark - View lifecycle
+
+- (void)viewDidLoad
+{
+
+ [super viewDidLoad];
+ dataManager = [[MockDataManager alloc] init];
+ tableHeader.text = TABLE_HEADER_LABEL_PORTRAIT;
+}
+
+- (void)viewDidUnload
+{
+ [autoTableView release];
+ [tableHeader release];
+ [dataManager release];
+ [super viewDidUnload];
+}
+
+- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
+{
+
+ // Every EditableTableRow item is going to need to re-adjust its item sizes
+ for (EditableTableDataRow *row in self.autoTableView.visibleCells)
+ {
+ [row updateSizes];
+ }
+ return YES;
+}
+
+- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
+{
+
+ if (fromInterfaceOrientation == UIInterfaceOrientationPortrait || fromInterfaceOrientation == UIInterfaceOrientationPortraitUpsideDown)
+ {
+ tableHeader.text = TABLE_HEADER_LABEL_LANDSCAPE;
+ }
+ else if (fromInterfaceOrientation == UIInterfaceOrientationLandscapeLeft || fromInterfaceOrientation == UIInterfaceOrientationLandscapeRight)
+ {
+ tableHeader.text = TABLE_HEADER_LABEL_PORTRAIT;
+ }
+ [self.autoTableView setNeedsLayout];
+}
+
+#pragma mark - Business Logic
+
+- (IBAction)addAuto:(id)sender
+{
+
+ NSMutableArray *autos = dataManager.autoCollection;
+ NSMutableDictionary *newAuto = [NSMutableDictionary dictionaryWithObjectsAndKeys:@"", @"year", @"", @"make", @"", @"model", @"", @"color", @"", @"mileage", [NSNumber numberWithBool:YES], @"titled", nil];
+
+ [autos addObject:newAuto];
+ [autoTableView reloadData];
+}
+
+- (IBAction)attachImageToAuto:(id)sender
+{
+ UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Unimplemented Feature" message:@"Still need to implement picture import feature" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
+ [alertView show];
+ [alertView release];
+}
+
+#pragma mark - EditableTableDataRowItem Delegate methods
+
+- (void)dataRow:(EditableTableDataRow *)dataRow didSetValue:(id)newValue forColumn:(int)column
+{
+
+ NSMutableDictionary *editedAuto = [dataManager.autoCollection objectAtIndex:dataRow.tag];
+
+ switch (column)
+ {
+ case TABLE_COLUMN_YEAR:
+ [editedAuto setValue:newValue forKey:@"year"];
+ break;
+ case TABLE_COLUMN_MAKE:
+ [editedAuto setValue:newValue forKey:@"make"];
+ [editedAuto setValue:@"" forKey:@"model"];
+ break;
+ case TABLE_COLUMN_MODEL:
+ [editedAuto setValue:newValue forKey:@"model"];
+ break;
+ case TABLE_COLUMN_COLOR:
+ [editedAuto setValue:newValue forKey:@"color"];
+ break;
+ case TABLE_COLUMN_MILEAGE:
+ [editedAuto setValue:newValue forKey:@"mileage"];
+ break;
+ case TABLE_COLUMN_TITLED:
+ [editedAuto setValue:newValue forKey:@"titled"];
+ break;
+ default:
+ break;
+ }
+ dataRow.editColumn = nil;
+ [self.autoTableView reloadData];
+}
+
+#pragma mark - Table view delegate
+- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
+{
+
+ if ([[[dataManager.autoCollection objectAtIndex:indexPath.row] valueForKey:@"year"] isEqualToString:@""])
+ {
+ EditableTableDataRow *dataCell = (EditableTableDataRow *)cell;
+ dataCell.editColumn = [NSNumber numberWithInt:TABLE_COLUMN_YEAR];
+ }
+}
+
+- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
+{
+}
+
+#pragma mark - Table view data source
+
+- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
+{
+ return 1;
+}
+
+- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
+{
+ return ([dataManager.autoCollection count]);
+}
+
+- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
+{
+
+ static NSString *customCellIdentifier = @"customCell";
+ EditableTableDataRow *cell = nil;
+
+ cell = (EditableTableDataRow *)[tableView dequeueReusableCellWithIdentifier:customCellIdentifier];
+ if (cell == nil)
+ {
+ cell = [[[EditableTableDataRow alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:customCellIdentifier itemPadding:DEFAULT_ROW_ITEM_PADDING scaleToFill:YES] autorelease];
+ }
+
+ EditableTableDataRowItem *yearRowItem = [[[EditableTableDataRowItem alloc] initWithRowItemControlType:ControlTypeTextField selections:nil selectionListKey:nil baseSize:CGSizeMake(YEAR_COLUMN_RELATIVE_WIDTH, DEFAULT_TEXTFIELD_HEIGHT) canResize:NO normalImage:nil selectedImage:nil controlLabel:[[dataManager.autoCollection objectAtIndex:indexPath.row] valueForKey:@"year"] buttonTarget:nil buttonAction:nil] autorelease];
+ EditableTableDataRowItem *makeRowItem = [[[EditableTableDataRowItem alloc] initWithRowItemControlType:ControlTypeCombo selections:dataManager.makerList selectionListKey:nil baseSize:CGSizeMake(MAKE_COLUMN_RELATIVE_WIDTH, DEFAULT_COMBO_HEIGHT) canResize:YES normalImage:[UIImage imageNamed:@"comboBox.png"] selectedImage:[UIImage imageNamed:@"comboBoxSelected.png"] controlLabel:[[dataManager.autoCollection objectAtIndex:indexPath.row] valueForKey:@"make"] buttonTarget:nil buttonAction:nil] autorelease];
+ EditableTableDataRowItem *modelRowItem = [[[EditableTableDataRowItem alloc] initWithRowItemControlType:ControlTypeCombo selections:[dataManager.modelList valueForKey:[[dataManager.autoCollection objectAtIndex:indexPath.row] valueForKey:@"make"]] selectionListKey:nil baseSize:CGSizeMake(MODEL_COLUMN_RELATIVE_WIDTH, DEFAULT_COMBO_HEIGHT) canResize:NO normalImage:[UIImage imageNamed:@"comboBox.png"] selectedImage:[UIImage imageNamed:@"comboBoxSelected.png"] controlLabel:[[dataManager.autoCollection objectAtIndex:indexPath.row] valueForKey:@"model"] buttonTarget:nil buttonAction:nil] autorelease];
+ EditableTableDataRowItem *colorRowItem = [[[EditableTableDataRowItem alloc] initWithRowItemControlType:ControlTypePopup selections:dataManager.colorList selectionListKey:nil baseSize:CGSizeMake(COLOR_COLUMN_RELATIVE_WIDTH, DEFAULT_POPUP_HEIGHT) canResize:YES normalImage:[UIImage imageNamed:@"popupButton.png"] selectedImage:[UIImage imageNamed:@"popupButtonSelected.png"] controlLabel:[[dataManager.autoCollection objectAtIndex:indexPath.row] valueForKey:@"color"] buttonTarget:nil buttonAction:nil] autorelease];
+ EditableTableDataRowItem *mileageRowItem = [[[EditableTableDataRowItem alloc] initWithRowItemControlType:ControlTypeTextField selections:nil selectionListKey:nil baseSize:CGSizeMake(MILEAGE_COLUMN_RELATIVE_WIDTH, DEFAULT_POPUP_HEIGHT) canResize:YES normalImage:nil selectedImage:nil controlLabel:[[dataManager.autoCollection objectAtIndex:indexPath.row] valueForKey:@"mileage"] buttonTarget:nil buttonAction:nil] autorelease];
+ EditableTableDataRowItem *titledRowItem = [[[EditableTableDataRowItem alloc] initWithRowItemControlType:ControlTypeToggleButton selections:nil selectionListKey:nil baseSize:CGSizeMake(TITLED_COLUMN_RELATIVE_WIDTH, DEFAULT_TEXTFIELD_HEIGHT) canResize:NO normalImage:[UIImage imageNamed:@"checkBox.png"] selectedImage:[UIImage imageNamed:@"checkBoxChecked.png"] controlLabel:nil buttonTarget:nil buttonAction:nil] autorelease];
+ EditableTableDataRowItem *imageRowItem = [[[EditableTableDataRowItem alloc] initWithRowItemControlType:ControlTypeButton selections:nil selectionListKey:nil baseSize:CGSizeMake(IMAGE_COLUMN_RELATIVE_WIDTH, 0) canResize:NO normalImage:[UIImage imageNamed:@"camera.png"] selectedImage:[UIImage imageNamed:@"cameraSelected.png"] controlLabel:nil buttonTarget:self buttonAction:@selector(attachImageToAuto:)] autorelease];
+ NSArray *dataRowItems = [NSArray arrayWithObjects:yearRowItem, makeRowItem, modelRowItem, colorRowItem, mileageRowItem, titledRowItem, imageRowItem, nil];
+ UITextField *yearField = (UITextField *)yearRowItem.control;
+ UITextField *mileageField = (UITextField *)mileageRowItem.control;
+ UIButton *titledField = (UIButton *)titledRowItem.control;
+ cell.delegate = self;
+ cell.tag = indexPath.row;
+
+ if ([[[dataManager.autoCollection objectAtIndex:indexPath.row] valueForKey:@"year"] isEqualToString:@""])
+ {
+ yearField.placeholder = @"Year";
+ }
+ else
+ {
+ yearField.text = [[dataManager.autoCollection objectAtIndex:indexPath.row] valueForKey:@"year"];
+ }
+ if ([[[dataManager.autoCollection objectAtIndex:indexPath.row] valueForKey:@"mileage"] isEqualToString:@""])
+ {
+ mileageField.placeholder = @"Mileage";
+ }
+ else
+ {
+ mileageField.text = [[dataManager.autoCollection objectAtIndex:indexPath.row] valueForKey:@"mileage"];
+ }
+ if ([[[dataManager.autoCollection objectAtIndex:indexPath.row] valueForKey:@"titled"] boolValue] == YES)
+ {
+ [titledField setImage:[UIImage imageNamed:@"checkBoxChecked.png"] forState:UIControlStateNormal];
+ }
+ else
+ {
+ [titledField setImage:[UIImage imageNamed:@"checkBox.png"] forState:UIControlStateNormal];
+ }
+ cell.rowItems = dataRowItems;
+ return cell;
+}
+
+@end
Oops, something went wrong.

0 comments on commit 4038497

Please sign in to comment.