From 8ed55c1c7891d76ae15c155c0469253ca8fb3f34 Mon Sep 17 00:00:00 2001 From: Eddie Ehlin Date: Sat, 19 Jan 2013 00:07:02 +0100 Subject: Added custom UITableViewCell for displaying bean information + extraction view controller (stub). --- iBean/iBean.xcodeproj/project.pbxproj | 20 ++++ .../UserInterfaceState.xcuserstate | Bin 34539 -> 36309 bytes .../xcdebugger/Breakpoints.xcbkptlist | 15 --- iBean/iBean/BeanCell.h | 20 ++++ iBean/iBean/BeanCell.m | 36 ++++++ .../iBean/BeanCollectionExtractionViewController.h | 26 +++++ .../iBean/BeanCollectionExtractionViewController.m | 96 ++++++++++++++++ iBean/iBean/BeanCollectionListViewController.m | 7 +- iBean/iBean/iPhoneStoryboard.storyboard | 122 +++++++++++++++++++++ 9 files changed, 324 insertions(+), 18 deletions(-) create mode 100644 iBean/iBean/BeanCell.h create mode 100644 iBean/iBean/BeanCell.m create mode 100644 iBean/iBean/BeanCollectionExtractionViewController.h create mode 100644 iBean/iBean/BeanCollectionExtractionViewController.m (limited to 'iBean') diff --git a/iBean/iBean.xcodeproj/project.pbxproj b/iBean/iBean.xcodeproj/project.pbxproj index 5775776..f809461 100644 --- a/iBean/iBean.xcodeproj/project.pbxproj +++ b/iBean/iBean.xcodeproj/project.pbxproj @@ -33,6 +33,8 @@ 020C569916A49C5900D8224C /* Configuration.m in Sources */ = {isa = PBXBuildFile; fileRef = 020C569816A49C5900D8224C /* Configuration.m */; }; 020C569C16A49C8300D8224C /* Configuration+Interface.m in Sources */ = {isa = PBXBuildFile; fileRef = 020C569B16A49C8300D8224C /* Configuration+Interface.m */; }; 024F676D16A4A61D004A1201 /* InstantExtractionViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 024F676C16A4A61D004A1201 /* InstantExtractionViewController.m */; }; + 02E557AE16A9C1E40080FBBA /* BeanCollectionExtractionViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 02E557AD16A9C1E40080FBBA /* BeanCollectionExtractionViewController.m */; }; + 02E557B116A9CFB50080FBBA /* BeanCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 02E557B016A9CFB50080FBBA /* BeanCell.m */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ @@ -80,6 +82,10 @@ 020C569B16A49C8300D8224C /* Configuration+Interface.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "Configuration+Interface.m"; sourceTree = ""; }; 024F676B16A4A61D004A1201 /* InstantExtractionViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InstantExtractionViewController.h; sourceTree = ""; }; 024F676C16A4A61D004A1201 /* InstantExtractionViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = InstantExtractionViewController.m; sourceTree = ""; }; + 02E557AC16A9C1E40080FBBA /* BeanCollectionExtractionViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BeanCollectionExtractionViewController.h; sourceTree = ""; }; + 02E557AD16A9C1E40080FBBA /* BeanCollectionExtractionViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BeanCollectionExtractionViewController.m; sourceTree = ""; }; + 02E557AF16A9CFB50080FBBA /* BeanCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BeanCell.h; sourceTree = ""; }; + 02E557B016A9CFB50080FBBA /* BeanCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BeanCell.m; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -176,6 +182,7 @@ 020C55D31695C2C800D8224C /* iBean */ = { isa = PBXGroup; children = ( + 02E557AA16A9C1B90080FBBA /* BeanCollectionExtraction */, 020C56081698F58900D8224C /* BeanCollectionList */, 020C56091698F59F00D8224C /* Step 1 - BeanCollectionInfo */, 020C56071698F4DC00D8224C /* Step 2 - BeanCollectionBeanList */, @@ -259,6 +266,17 @@ name = "Step 4 - Extraction"; sourceTree = ""; }; + 02E557AA16A9C1B90080FBBA /* BeanCollectionExtraction */ = { + isa = PBXGroup; + children = ( + 02E557AF16A9CFB50080FBBA /* BeanCell.h */, + 02E557B016A9CFB50080FBBA /* BeanCell.m */, + 02E557AC16A9C1E40080FBBA /* BeanCollectionExtractionViewController.h */, + 02E557AD16A9C1E40080FBBA /* BeanCollectionExtractionViewController.m */, + ); + name = BeanCollectionExtraction; + sourceTree = ""; + }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ @@ -342,6 +360,8 @@ 020C569916A49C5900D8224C /* Configuration.m in Sources */, 020C569C16A49C8300D8224C /* Configuration+Interface.m in Sources */, 024F676D16A4A61D004A1201 /* InstantExtractionViewController.m in Sources */, + 02E557AE16A9C1E40080FBBA /* BeanCollectionExtractionViewController.m in Sources */, + 02E557B116A9CFB50080FBBA /* BeanCell.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/iBean/iBean.xcodeproj/project.xcworkspace/xcuserdata/eddiex.xcuserdatad/UserInterfaceState.xcuserstate b/iBean/iBean.xcodeproj/project.xcworkspace/xcuserdata/eddiex.xcuserdatad/UserInterfaceState.xcuserstate index b35e28b..d93e807 100644 Binary files a/iBean/iBean.xcodeproj/project.xcworkspace/xcuserdata/eddiex.xcuserdatad/UserInterfaceState.xcuserstate and b/iBean/iBean.xcodeproj/project.xcworkspace/xcuserdata/eddiex.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/iBean/iBean.xcodeproj/xcuserdata/eddiex.xcuserdatad/xcdebugger/Breakpoints.xcbkptlist b/iBean/iBean.xcodeproj/xcuserdata/eddiex.xcuserdatad/xcdebugger/Breakpoints.xcbkptlist index 443de6d..05301bc 100644 --- a/iBean/iBean.xcodeproj/xcuserdata/eddiex.xcuserdatad/xcdebugger/Breakpoints.xcbkptlist +++ b/iBean/iBean.xcodeproj/xcuserdata/eddiex.xcuserdatad/xcdebugger/Breakpoints.xcbkptlist @@ -2,19 +2,4 @@ - - - - diff --git a/iBean/iBean/BeanCell.h b/iBean/iBean/BeanCell.h new file mode 100644 index 0000000..f244eab --- /dev/null +++ b/iBean/iBean/BeanCell.h @@ -0,0 +1,20 @@ +// +// BeanCell.h +// iBean +// +// Created by Eddie Ehlin on 2013-01-18. +// Copyright (c) 2013 Eddie Ehlin. All rights reserved. +// + +#import + +@interface BeanCell : UITableViewCell +@property (weak, nonatomic) IBOutlet UIImageView *beanImageLeft; +@property (weak, nonatomic) IBOutlet UILabel *beanNameLabel; +@property (weak, nonatomic) IBOutlet UILabel *beanGrindSettingLabel; +@property (weak, nonatomic) IBOutlet UIImageView *beanImageRight; +@property (weak, nonatomic) IBOutlet UILabel *beanAmountLabel; + + +- (void) initWithNameGrindSettingAndAmount: (NSString*) name: (NSNumber*)grindSetting: (NSNumber*) amount; +@end diff --git a/iBean/iBean/BeanCell.m b/iBean/iBean/BeanCell.m new file mode 100644 index 0000000..cc5f663 --- /dev/null +++ b/iBean/iBean/BeanCell.m @@ -0,0 +1,36 @@ +// +// BeanCell.m +// iBean +// +// Created by Eddie Ehlin on 2013-01-18. +// Copyright (c) 2013 Eddie Ehlin. All rights reserved. +// + +#import "BeanCell.h" + +@implementation BeanCell + +- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier +{ + self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]; + if (self) { + // Initialization code + } + return self; +} + +- (void)setSelected:(BOOL)selected animated:(BOOL)animated +{ + [super setSelected:selected animated:animated]; + + // Configure the view for the selected state +} + +- (void) initWithNameGrindSettingAndAmount: (NSString*) name: (NSNumber*)grindSetting: (NSNumber*) amount +{ + self.beanNameLabel.text = name; + self.beanGrindSettingLabel.text = [NSString stringWithFormat:@"%@", grindSetting]; + self.beanAmountLabel.text = [NSString stringWithFormat:@"%1.1f g", [amount doubleValue]]; +} + +@end diff --git a/iBean/iBean/BeanCollectionExtractionViewController.h b/iBean/iBean/BeanCollectionExtractionViewController.h new file mode 100644 index 0000000..4f7a608 --- /dev/null +++ b/iBean/iBean/BeanCollectionExtractionViewController.h @@ -0,0 +1,26 @@ +// +// BeanCollectionExtractionViewController.h +// iBean +// +// Created by Eddie Ehlin on 2013-01-18. +// Copyright (c) 2013 Eddie Ehlin. All rights reserved. +// + +#import +@class BeanCollection; + +@interface BeanCollectionExtractionViewController : UIViewController + +@property (nonatomic, strong) BeanCollection *beanCollection; + +/* Utility methods */ +- (void) initViewController; +- (void) initWithBeanCollection:(BeanCollection*) bc; + +/* UI Outlets */ +@property (weak, nonatomic) IBOutlet UITableView *beanTableView; + +/* UI Actions */ + + +@end diff --git a/iBean/iBean/BeanCollectionExtractionViewController.m b/iBean/iBean/BeanCollectionExtractionViewController.m new file mode 100644 index 0000000..e89324c --- /dev/null +++ b/iBean/iBean/BeanCollectionExtractionViewController.m @@ -0,0 +1,96 @@ +// +// BeanCollectionExtractionViewController.m +// iBean +// +// Created by Eddie Ehlin on 2013-01-18. +// Copyright (c) 2013 Eddie Ehlin. All rights reserved. +// + +#import "BeanCollectionExtractionViewController.h" +#import "BeanCollection+Interface.h" +#import "BeanCell.h" +#import "Bean+Interface.h" + +@interface BeanCollectionExtractionViewController () + +@end + +@implementation BeanCollectionExtractionViewController + +- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil +{ + self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; + if (self) { + // Custom initialization + } + return self; +} + +- (void)viewDidLoad +{ + [super viewDidLoad]; + // Do any additional setup after loading the view. +} + +- (void)viewWillAppear:(BOOL)animated +{ + [super viewWillAppear:animated]; + [self initViewController]; +} + +- (void)didReceiveMemoryWarning +{ + [super didReceiveMemoryWarning]; + // Dispose of any resources that can be recreated. +} + +/***************************************************** + Utility methods + *****************************************************/ +#pragma mark - Utility methods +- (void) initViewController +{ + NSLog(@"BeanCollectionExtraction - initViewController"); + self.navigationItem.title = self.beanCollection.name; +} + +- (void) initWithBeanCollection:(BeanCollection *)bc +{ + self.beanCollection = bc; + +} + +/***************************************************** + UI Actions + *****************************************************/ +#pragma mark - UI action methods + +/***************************************************** + Delegates + *****************************************************/ +#pragma mark - UITableViewDelegate & datasource + +- (NSInteger) numberOfSectionsInTableView:(UITableView *)tableView +{ + return 1; +} + +- (NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section +{ + return self.beanCollection.beans.count; +} + +- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath +{ + static NSString *CellIdentifier = @"BeanCell"; + BeanCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath]; + + //Configure the cell and set its title + Bean *currentBean = [self.beanCollection.beans objectAtIndex:indexPath.row]; + + [cell initWithNameGrindSettingAndAmount:currentBean.name :currentBean.grindSetting :currentBean.amount]; + + return cell; +} + +@end diff --git a/iBean/iBean/BeanCollectionListViewController.m b/iBean/iBean/BeanCollectionListViewController.m index 5bb9b44..6c0f46c 100644 --- a/iBean/iBean/BeanCollectionListViewController.m +++ b/iBean/iBean/BeanCollectionListViewController.m @@ -8,6 +8,7 @@ #import "BeanCollectionListViewController.h" #import "BeanCollectionInfoViewController.h" +#import "BeanCollectionExtractionViewController.h" #import "BeanCollection.h" #import "AppDelegate+Storage.h" @@ -56,12 +57,12 @@ self.beanCollection = [(AppDelegate*) [[UIApplication sharedApplication] delegate] createBeanCollection]; [infoViewController initWithModeAndBeanCollection:NO :self.beanCollection]; } - else if ([segue.identifier isEqualToString:@"ViewBeanCollectionInfoSegue"]) + else if ([segue.identifier isEqualToString:@"BeanCollectionListBeanCollectionExtractionSegue"]) { //Tell the view controller that we'll be handling/viewing an existing bean collection - BeanCollectionInfoViewController *infoViewController = segue.destinationViewController; + BeanCollectionExtractionViewController *extractionViewController = segue.destinationViewController; self.beanCollection = [self.beanCollections objectAtIndex:[self.tableView indexPathForSelectedRow].row]; - [infoViewController initWithModeAndBeanCollection:YES :self.beanCollection]; + [extractionViewController initWithBeanCollection: self.beanCollection]; } } diff --git a/iBean/iBean/iPhoneStoryboard.storyboard b/iBean/iBean/iPhoneStoryboard.storyboard index 358e404..f496545 100644 --- a/iBean/iBean/iPhoneStoryboard.storyboard +++ b/iBean/iBean/iPhoneStoryboard.storyboard @@ -28,6 +28,9 @@ + + + @@ -630,6 +633,109 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -647,6 +753,16 @@ + + + + + + + + + + @@ -656,6 +772,12 @@ + + + + + + -- cgit v1.2.3