diff options
author | Eddie Ehlin <eddiex@eddiex.se> | 2013-01-10 22:55:05 +0100 |
---|---|---|
committer | Eddie Ehlin <eddiex@eddiex.se> | 2013-01-10 22:55:05 +0100 |
commit | 0a4f78102a90f44c555320205cf54be826cb0795 (patch) | |
tree | bec3059137b8c4447c523646586b0abdbce8b00c | |
parent | cf036b3c0509ca28505b73c4028c2b90371bf027 (diff) | |
download | iBean-0a4f78102a90f44c555320205cf54be826cb0795.tar.gz iBean-0a4f78102a90f44c555320205cf54be826cb0795.zip |
Add bean functionality is now in order (for state add new) and left to do is being able to edit a bean thats been added (in state new).
-rw-r--r-- | iBean/iBean.xcodeproj/project.pbxproj | 58 | ||||
-rw-r--r-- | iBean/iBean.xcodeproj/project.xcworkspace/xcuserdata/eddiex.xcuserdatad/UserInterfaceState.xcuserstate | bin | 30580 -> 32116 bytes | |||
-rw-r--r-- | iBean/iBean/AddBeanViewController.h | 34 | ||||
-rw-r--r-- | iBean/iBean/AddBeanViewController.m | 112 | ||||
-rw-r--r-- | iBean/iBean/AppDelegate+Storage.h | 5 | ||||
-rw-r--r-- | iBean/iBean/AppDelegate+Storage.m | 19 | ||||
-rw-r--r-- | iBean/iBean/Bean+Interface.h | 15 | ||||
-rw-r--r-- | iBean/iBean/Bean+Interface.m | 13 | ||||
-rw-r--r-- | iBean/iBean/Bean.h | 2 | ||||
-rw-r--r-- | iBean/iBean/Bean.m | 2 | ||||
-rw-r--r-- | iBean/iBean/BeanCollection+Interface.h | 16 | ||||
-rw-r--r-- | iBean/iBean/BeanCollection+Interface.m | 55 | ||||
-rw-r--r-- | iBean/iBean/BeanCollection.h | 15 | ||||
-rw-r--r-- | iBean/iBean/BeanCollection.m | 2 | ||||
-rw-r--r-- | iBean/iBean/BeanCollectionBeanListViewController.h | 4 | ||||
-rw-r--r-- | iBean/iBean/BeanCollectionBeanListViewController.m | 73 | ||||
-rw-r--r-- | iBean/iBean/iBean.xcdatamodeld/iBean.xcdatamodel/contents | 2 | ||||
-rw-r--r-- | iBean/iBean/iPhoneStoryboard.storyboard | 196 |
18 files changed, 567 insertions, 56 deletions
diff --git a/iBean/iBean.xcodeproj/project.pbxproj b/iBean/iBean.xcodeproj/project.pbxproj index d67b623..c17a052 100644 --- a/iBean/iBean.xcodeproj/project.pbxproj +++ b/iBean/iBean.xcodeproj/project.pbxproj @@ -23,10 +23,13 @@ 020C55C716910EAD00D8224C /* InstaBeanConfiguration.m in Sources */ = {isa = PBXBuildFile; fileRef = 020C55C616910EAD00D8224C /* InstaBeanConfiguration.m */; }; 020C55CA1691100000D8224C /* AppDelegate+Storage.m in Sources */ = {isa = PBXBuildFile; fileRef = 020C55C91691100000D8224C /* AppDelegate+Storage.m */; }; 020C55FA16983E9900D8224C /* BeanCollectionListViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 020C55F916983E9900D8224C /* BeanCollectionListViewController.m */; }; - 020C55FD16983F7400D8224C /* Bean.m in Sources */ = {isa = PBXBuildFile; fileRef = 020C55FC16983F7400D8224C /* Bean.m */; }; - 020C560016983F7400D8224C /* BeanCollection.m in Sources */ = {isa = PBXBuildFile; fileRef = 020C55FF16983F7400D8224C /* BeanCollection.m */; }; 020C560316989D4500D8224C /* BeanCollectionInfoViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 020C560216989D4500D8224C /* BeanCollectionInfoViewController.m */; }; 020C56061698A85000D8224C /* BeanCollectionBeanListViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 020C56051698A85000D8224C /* BeanCollectionBeanListViewController.m */; }; + 020C5672169E1B0100D8224C /* AddBeanViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 020C5671169E1B0100D8224C /* AddBeanViewController.m */; }; + 020C567A169F597300D8224C /* Bean.m in Sources */ = {isa = PBXBuildFile; fileRef = 020C5679169F597300D8224C /* Bean.m */; }; + 020C567D169F597300D8224C /* BeanCollection.m in Sources */ = {isa = PBXBuildFile; fileRef = 020C567C169F597300D8224C /* BeanCollection.m */; }; + 020C5680169F5E9A00D8224C /* Bean+Interface.m in Sources */ = {isa = PBXBuildFile; fileRef = 020C567F169F5E9900D8224C /* Bean+Interface.m */; }; + 020C5683169F5FBB00D8224C /* BeanCollection+Interface.m in Sources */ = {isa = PBXBuildFile; fileRef = 020C5682169F5FBB00D8224C /* BeanCollection+Interface.m */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ @@ -54,14 +57,20 @@ 020C55C91691100000D8224C /* AppDelegate+Storage.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "AppDelegate+Storage.m"; sourceTree = "<group>"; }; 020C55F816983E9900D8224C /* BeanCollectionListViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BeanCollectionListViewController.h; sourceTree = "<group>"; }; 020C55F916983E9900D8224C /* BeanCollectionListViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BeanCollectionListViewController.m; sourceTree = "<group>"; }; - 020C55FB16983F7400D8224C /* Bean.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Bean.h; sourceTree = "<group>"; }; - 020C55FC16983F7400D8224C /* Bean.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Bean.m; sourceTree = "<group>"; }; - 020C55FE16983F7400D8224C /* BeanCollection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BeanCollection.h; sourceTree = "<group>"; }; - 020C55FF16983F7400D8224C /* BeanCollection.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BeanCollection.m; sourceTree = "<group>"; }; 020C560116989D4500D8224C /* BeanCollectionInfoViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BeanCollectionInfoViewController.h; sourceTree = "<group>"; }; 020C560216989D4500D8224C /* BeanCollectionInfoViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BeanCollectionInfoViewController.m; sourceTree = "<group>"; }; 020C56041698A85000D8224C /* BeanCollectionBeanListViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BeanCollectionBeanListViewController.h; sourceTree = "<group>"; }; 020C56051698A85000D8224C /* BeanCollectionBeanListViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BeanCollectionBeanListViewController.m; sourceTree = "<group>"; }; + 020C5670169E1B0100D8224C /* AddBeanViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AddBeanViewController.h; sourceTree = "<group>"; }; + 020C5671169E1B0100D8224C /* AddBeanViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AddBeanViewController.m; sourceTree = "<group>"; }; + 020C5678169F597300D8224C /* Bean.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Bean.h; sourceTree = "<group>"; }; + 020C5679169F597300D8224C /* Bean.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Bean.m; sourceTree = "<group>"; }; + 020C567B169F597300D8224C /* BeanCollection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BeanCollection.h; sourceTree = "<group>"; }; + 020C567C169F597300D8224C /* BeanCollection.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BeanCollection.m; sourceTree = "<group>"; }; + 020C567E169F5E9900D8224C /* Bean+Interface.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "Bean+Interface.h"; sourceTree = "<group>"; }; + 020C567F169F5E9900D8224C /* Bean+Interface.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "Bean+Interface.m"; sourceTree = "<group>"; }; + 020C5681169F5FBA00D8224C /* BeanCollection+Interface.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "BeanCollection+Interface.h"; sourceTree = "<group>"; }; + 020C5682169F5FBB00D8224C /* BeanCollection+Interface.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "BeanCollection+Interface.m"; sourceTree = "<group>"; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -162,6 +171,7 @@ 020C56081698F58900D8224C /* BeanCollectionList */, 020C56091698F59F00D8224C /* BeanCollectionInfo */, 020C56071698F4DC00D8224C /* BeanCollectionBeanList */, + 020C566E169E1ACB00D8224C /* Bean */, 020C55DF169792F800D8224C /* Data */, ); name = iBean; @@ -170,10 +180,11 @@ 020C55DF169792F800D8224C /* Data */ = { isa = PBXGroup; children = ( - 020C55FE16983F7400D8224C /* BeanCollection.h */, - 020C55FF16983F7400D8224C /* BeanCollection.m */, - 020C55FB16983F7400D8224C /* Bean.h */, - 020C55FC16983F7400D8224C /* Bean.m */, + 020C5684169F603700D8224C /* Interface */, + 020C567B169F597300D8224C /* BeanCollection.h */, + 020C567C169F597300D8224C /* BeanCollection.m */, + 020C5678169F597300D8224C /* Bean.h */, + 020C5679169F597300D8224C /* Bean.m */, ); name = Data; sourceTree = "<group>"; @@ -205,6 +216,26 @@ name = BeanCollectionInfo; sourceTree = "<group>"; }; + 020C566E169E1ACB00D8224C /* Bean */ = { + isa = PBXGroup; + children = ( + 020C5670169E1B0100D8224C /* AddBeanViewController.h */, + 020C5671169E1B0100D8224C /* AddBeanViewController.m */, + ); + name = Bean; + sourceTree = "<group>"; + }; + 020C5684169F603700D8224C /* Interface */ = { + isa = PBXGroup; + children = ( + 020C567E169F5E9900D8224C /* Bean+Interface.h */, + 020C567F169F5E9900D8224C /* Bean+Interface.m */, + 020C5681169F5FBA00D8224C /* BeanCollection+Interface.h */, + 020C5682169F5FBB00D8224C /* BeanCollection+Interface.m */, + ); + name = Interface; + sourceTree = "<group>"; + }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ @@ -278,10 +309,13 @@ 020C55C716910EAD00D8224C /* InstaBeanConfiguration.m in Sources */, 020C55CA1691100000D8224C /* AppDelegate+Storage.m in Sources */, 020C55FA16983E9900D8224C /* BeanCollectionListViewController.m in Sources */, - 020C55FD16983F7400D8224C /* Bean.m in Sources */, - 020C560016983F7400D8224C /* BeanCollection.m in Sources */, 020C560316989D4500D8224C /* BeanCollectionInfoViewController.m in Sources */, 020C56061698A85000D8224C /* BeanCollectionBeanListViewController.m in Sources */, + 020C5672169E1B0100D8224C /* AddBeanViewController.m in Sources */, + 020C567A169F597300D8224C /* Bean.m in Sources */, + 020C567D169F597300D8224C /* BeanCollection.m in Sources */, + 020C5680169F5E9A00D8224C /* Bean+Interface.m in Sources */, + 020C5683169F5FBB00D8224C /* BeanCollection+Interface.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 Binary files differindex b147436..c78c824 100644 --- a/iBean/iBean.xcodeproj/project.xcworkspace/xcuserdata/eddiex.xcuserdatad/UserInterfaceState.xcuserstate +++ b/iBean/iBean.xcodeproj/project.xcworkspace/xcuserdata/eddiex.xcuserdatad/UserInterfaceState.xcuserstate diff --git a/iBean/iBean/AddBeanViewController.h b/iBean/iBean/AddBeanViewController.h new file mode 100644 index 0000000..155e18b --- /dev/null +++ b/iBean/iBean/AddBeanViewController.h @@ -0,0 +1,34 @@ +// +// AddBeanViewController.h +// iBean +// +// Created by Eddie Ehlin on 2013-01-09. +// Copyright (c) 2013 Eddie Ehlin. All rights reserved. +// + +#import <UIKit/UIKit.h> +@class BeanCollection; + +@interface AddBeanViewController : UIViewController + +@property (nonatomic, strong) BeanCollection *beanCollection; +@property (nonatomic, assign) BOOL editMode; + +/* Utility methods */ +- (void) initViewController; +- (void) initWithModeAndBeanCollection:(BOOL)editMode: (BeanCollection*) bc; + +/* UI Outlets */ +@property (weak, nonatomic) IBOutlet UITextField *beanNameTextField; +@property (weak, nonatomic) IBOutlet UILabel *amountLabel; +@property (weak, nonatomic) IBOutlet UIStepper *amountStepper; +@property (weak, nonatomic) IBOutlet UILabel *grinderSettingLabel; +@property (weak, nonatomic) IBOutlet UIStepper *grinderSettingStepper; + +/* UI Actions */ +- (IBAction) amountStepperChanged:(id)sender; +- (IBAction) grinderSettingStepperChanged:(id)sender; +- (IBAction) cancelBean:(id)sender; +- (IBAction) commitBean:(id)sender; + +@end diff --git a/iBean/iBean/AddBeanViewController.m b/iBean/iBean/AddBeanViewController.m new file mode 100644 index 0000000..bebea6f --- /dev/null +++ b/iBean/iBean/AddBeanViewController.m @@ -0,0 +1,112 @@ +// +// AddBeanViewController.m +// iBean +// +// Created by Eddie Ehlin on 2013-01-09. +// Copyright (c) 2013 Eddie Ehlin. All rights reserved. +// + +#import "AppDelegate+Storage.h" +#import "AddBeanViewController.h" +#import "Bean+Interface.h" +#import "BeanCollection+Interface.h" + +@interface AddBeanViewController () + +@end + +@implementation AddBeanViewController + +- (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 + *****************************************************/ +- (void) initViewController +{ + NSLog(@"AddBeanViewController - initViewController"); + + if (self.editMode == YES) + { + //TODO: Update UI to refelect edit mode. + + //+ set UI controls with values from beanCollection. + NSLog(@"AddBeanViewController - in edit state"); + } + else + { + NSLog(@"AddBeanViewController - in add new state"); + } +} + +- (void) initWithModeAndBeanCollection:(BOOL)editMode: (BeanCollection*) bc +{ + NSLog(@"AddBeanViewController - initWithModeAndBeanCollection"); + self.editMode = editMode; + self.beanCollection = bc; +} + +/***************************************************** + UI Actions + *****************************************************/ +#pragma mark - IBActions +- (void) amountStepperChanged:(id)sender +{ + self.amountLabel.text = [NSString stringWithFormat:@"%1.1f", self.amountStepper.value]; +} + +- (void) grinderSettingStepperChanged:(id)sender +{ + self.grinderSettingLabel.text = [NSString stringWithFormat:@"%1.1f", self.grinderSettingStepper.value]; +} + +- (void) cancelBean:(id)sender +{ + [self dismissViewControllerAnimated:YES completion:nil]; +} + +- (void) commitBean:(id)sender +{ + Bean *b = [(AppDelegate*) [[UIApplication sharedApplication] delegate] createBean]; + if (b != nil && self.beanCollection != nil) + { + b.amount = [NSNumber numberWithDouble:self.amountStepper.value]; + b.name = self.beanNameTextField.text; + b.grindSetting = [NSNumber numberWithDouble:self.grinderSettingStepper.value]; + [self.beanCollection addBeansObject:b]; +#warning TODO - If we are in edit mode (for the bean collection) should we commit the managed context? + + //Go back to the bean list. + [self dismissViewControllerAnimated:YES completion:nil]; + } + else + { +#warning TODO - Messagebox telling user that error occured. + } +} +@end diff --git a/iBean/iBean/AppDelegate+Storage.h b/iBean/iBean/AppDelegate+Storage.h index effcd92..e56b8bf 100644 --- a/iBean/iBean/AppDelegate+Storage.h +++ b/iBean/iBean/AppDelegate+Storage.h @@ -9,6 +9,7 @@ #import "AppDelegate.h" @class InstaBeanConfiguration; @class BeanCollection; +@class Bean; /* Main purpose of this category is to have all storage (core data) related @@ -30,8 +31,6 @@ #pragma mark - iBean related storage methods - (NSArray*) getBeanCollections; - (BeanCollection*) createBeanCollection; +- (Bean*) createBean; - - -//warning TODO: Create methods for fetching managedContext (if needed?) as well methods for saving/deleting/fetching core data objects. @end diff --git a/iBean/iBean/AppDelegate+Storage.m b/iBean/iBean/AppDelegate+Storage.m index 9acaeb2..4f8fc0d 100644 --- a/iBean/iBean/AppDelegate+Storage.m +++ b/iBean/iBean/AppDelegate+Storage.m @@ -80,7 +80,7 @@ { NSFetchRequest *fetchRequest = [NSFetchRequest fetchRequestWithEntityName:@"BeanCollection"]; //For now we sort them on name. - fetchRequest.sortDescriptors = [NSArray arrayWithObject: [NSSortDescriptor sortDescriptorWithKey:@"name" ascending:NO]]; + fetchRequest.sortDescriptors = [NSArray arrayWithObject: [NSSortDescriptor sortDescriptorWithKey:@"name" ascending:YES]]; NSError *fetchRequestError = nil; fetchRequestResult = [self.managedObjectContext executeFetchRequest:fetchRequest error:&fetchRequestError]; @@ -113,6 +113,23 @@ return bc; } +- (Bean*) createBean +{ + Bean *b = nil; + + if (self.managedObjectContext != nil) + { + b = [NSEntityDescription insertNewObjectForEntityForName:@"Bean" inManagedObjectContext:self.managedObjectContext]; + + //Set default values + if (b != nil) + { + //TODO: Set default values here... + } + } + return b; +} + @end diff --git a/iBean/iBean/Bean+Interface.h b/iBean/iBean/Bean+Interface.h new file mode 100644 index 0000000..3b4874c --- /dev/null +++ b/iBean/iBean/Bean+Interface.h @@ -0,0 +1,15 @@ +// +// Bean+Interface.h +// iBean +// +// Created by Eddie Ehlin on 2013-01-10. +// Copyright (c) 2013 Eddie Ehlin. All rights reserved. +// + +#import "Bean.h" + +@interface Bean (Interface) + + + +@end diff --git a/iBean/iBean/Bean+Interface.m b/iBean/iBean/Bean+Interface.m new file mode 100644 index 0000000..baf7430 --- /dev/null +++ b/iBean/iBean/Bean+Interface.m @@ -0,0 +1,13 @@ +// +// Bean+Interface.m +// iBean +// +// Created by Eddie Ehlin on 2013-01-10. +// Copyright (c) 2013 Eddie Ehlin. All rights reserved. +// + +#import "Bean+Interface.h" + +@implementation Bean (Interface) + +@end diff --git a/iBean/iBean/Bean.h b/iBean/iBean/Bean.h index 80094b3..eb74a10 100644 --- a/iBean/iBean/Bean.h +++ b/iBean/iBean/Bean.h @@ -2,7 +2,7 @@ // Bean.h // iBean // -// Created by Eddie Ehlin on 2013-01-05. +// Created by Eddie Ehlin on 2013-01-10. // Copyright (c) 2013 Eddie Ehlin. All rights reserved. // diff --git a/iBean/iBean/Bean.m b/iBean/iBean/Bean.m index fbb21b3..6c6a6b4 100644 --- a/iBean/iBean/Bean.m +++ b/iBean/iBean/Bean.m @@ -2,7 +2,7 @@ // Bean.m // iBean // -// Created by Eddie Ehlin on 2013-01-05. +// Created by Eddie Ehlin on 2013-01-10. // Copyright (c) 2013 Eddie Ehlin. All rights reserved. // diff --git a/iBean/iBean/BeanCollection+Interface.h b/iBean/iBean/BeanCollection+Interface.h new file mode 100644 index 0000000..6df1040 --- /dev/null +++ b/iBean/iBean/BeanCollection+Interface.h @@ -0,0 +1,16 @@ +// +// BeanCollection+Interface.h +// iBean +// +// Created by Eddie Ehlin on 2013-01-10. +// Copyright (c) 2013 Eddie Ehlin. All rights reserved. +// + +#import "BeanCollection.h" + +@interface BeanCollection (Interface) + +- (void) addBeansObject: (Bean *)b; +- (void) removeObjectFromBeansAtIndex:(NSUInteger)beanIndex; +- (void)replaceBeansAtIndexes:(NSIndexSet *)beanIndexes withBeans:(NSArray *)beans; +@end diff --git a/iBean/iBean/BeanCollection+Interface.m b/iBean/iBean/BeanCollection+Interface.m new file mode 100644 index 0000000..e01e25e --- /dev/null +++ b/iBean/iBean/BeanCollection+Interface.m @@ -0,0 +1,55 @@ +// +// BeanCollection+Interface.m +// iBean +// +// Created by Eddie Ehlin on 2013-01-10. +// Copyright (c) 2013 Eddie Ehlin. All rights reserved. +// + +#import "BeanCollection+Interface.h" + +@implementation BeanCollection (Interface) + +- (void) addBeansObject:(Bean *)b +{ + NSMutableOrderedSet *tmpSet = [self mutableOrderedSetValueForKey:@"beans"]; + [tmpSet addObject:b]; +} + +- (void) removeObjectFromBeansAtIndex:(NSUInteger)beanIndex +{ + /* + NSIndexSet* indexes = [NSIndexSet indexSetWithIndex:idx]; + [self willChange:NSKeyValueChangeRemoval valuesAtIndexes:indexes forKey:@"beans"]; + NSMutableOrderedSet *tmpOrderedSet = [NSMutableOrderedSet orderedSetWithOrderedSet:[self mutableOrderedSetValueForKey:@"beans"]]; + [tmpOrderedSet removeObjectAtIndex:idx]; + [self setPrimitiveValue:tmpOrderedSet forKey:@"beans"]; + [self didChange:NSKeyValueChangeRemoval valuesAtIndexes:indexes forKey:@"beans"]; + */ + + NSMutableOrderedSet *tmpSet = [self mutableOrderedSetValueForKey:@"beans"]; + if (beanIndex >= 0 && beanIndex < tmpSet.count) + [tmpSet removeObjectAtIndex:beanIndex]; + else + NSLog(@"BeanCollection+Interface - removeBeansObjectAtIndex: Index out of range!"); +} + +- (void)replaceBeansAtIndexes:(NSIndexSet *)beanIndexes withBeans:(NSArray *)beans { + /* + [self willChange:NSKeyValueChangeReplacement valuesAtIndexes:indexes forKey:@"beans"]; + NSMutableOrderedSet *tmpOrderedSet = [NSMutableOrderedSet orderedSetWithOrderedSet:[self mutableOrderedSetValueForKey:@"beans"]]; + [tmpOrderedSet replaceObjectsAtIndexes:indexes withObjects:values]; + [self setPrimitiveValue:tmpOrderedSet forKey:@"beans"]; + [self didChange:NSKeyValueChangeReplacement valuesAtIndexes:indexes forKey:@"beans"]; + */ + + if (beans.count > 0) + { + NSMutableOrderedSet *tmpSet = [self mutableOrderedSetValueForKey:@"beans"]; + [tmpSet replaceObjectsAtIndexes:beanIndexes withObjects:beans]; + } + +} + + +@end diff --git a/iBean/iBean/BeanCollection.h b/iBean/iBean/BeanCollection.h index 801fa4c..08f03da 100644 --- a/iBean/iBean/BeanCollection.h +++ b/iBean/iBean/BeanCollection.h @@ -2,7 +2,7 @@ // BeanCollection.h // iBean // -// Created by Eddie Ehlin on 2013-01-05. +// Created by Eddie Ehlin on 2013-01-10. // Copyright (c) 2013 Eddie Ehlin. All rights reserved. // @@ -19,14 +19,19 @@ @property (nonatomic, retain) NSDate * modified; @property (nonatomic, retain) NSString * name; @property (nonatomic, retain) NSString * note; -@property (nonatomic, retain) NSSet *beans; +@property (nonatomic, retain) NSOrderedSet *beans; @end @interface BeanCollection (CoreDataGeneratedAccessors) +- (void)insertObject:(Bean *)value inBeansAtIndex:(NSUInteger)idx; +- (void)removeObjectFromBeansAtIndex:(NSUInteger)idx; +- (void)insertBeans:(NSArray *)value atIndexes:(NSIndexSet *)indexes; +- (void)removeBeansAtIndexes:(NSIndexSet *)indexes; +- (void)replaceObjectInBeansAtIndex:(NSUInteger)idx withObject:(Bean *)value; +- (void)replaceBeansAtIndexes:(NSIndexSet *)indexes withBeans:(NSArray *)values; - (void)addBeansObject:(Bean *)value; - (void)removeBeansObject:(Bean *)value; -- (void)addBeans:(NSSet *)values; -- (void)removeBeans:(NSSet *)values; - +- (void)addBeans:(NSOrderedSet *)values; +- (void)removeBeans:(NSOrderedSet *)values; @end diff --git a/iBean/iBean/BeanCollection.m b/iBean/iBean/BeanCollection.m index 39107ba..21ac2ab 100644 --- a/iBean/iBean/BeanCollection.m +++ b/iBean/iBean/BeanCollection.m @@ -2,7 +2,7 @@ // BeanCollection.m // iBean // -// Created by Eddie Ehlin on 2013-01-05. +// Created by Eddie Ehlin on 2013-01-10. // Copyright (c) 2013 Eddie Ehlin. All rights reserved. // diff --git a/iBean/iBean/BeanCollectionBeanListViewController.h b/iBean/iBean/BeanCollectionBeanListViewController.h index 5865904..ec6e47d 100644 --- a/iBean/iBean/BeanCollectionBeanListViewController.h +++ b/iBean/iBean/BeanCollectionBeanListViewController.h @@ -13,6 +13,7 @@ @property (nonatomic, strong) BeanCollection *beanCollection; @property (nonatomic, assign) BOOL editMode; +@property (nonatomic, strong) UIBarButtonItem *beanListEditDoneButton; /* Utility methods */ - (void) initViewController; @@ -20,8 +21,11 @@ /* UI Outlets */ @property (weak, nonatomic) IBOutlet UITableView *beanListTableView; +@property (strong, nonatomic) IBOutlet UIBarButtonItem *beanListEditButton; +@property (weak, nonatomic) IBOutlet UIToolbar *beanListBottomToolbar; /* UI Actions */ +- (IBAction) toggleEditMode:(id)sender; @end diff --git a/iBean/iBean/BeanCollectionBeanListViewController.m b/iBean/iBean/BeanCollectionBeanListViewController.m index 4564776..08b1eed 100644 --- a/iBean/iBean/BeanCollectionBeanListViewController.m +++ b/iBean/iBean/BeanCollectionBeanListViewController.m @@ -7,7 +7,9 @@ // #import "BeanCollectionBeanListViewController.h" +#import "AddBeanViewController.h" #import "BeanCollection.h" +#import "Bean.h" @interface BeanCollectionBeanListViewController () @@ -45,6 +47,23 @@ // Dispose of any resources that can be recreated. } +- (void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender +{ + //AddBeanSegue + if ([segue.identifier isEqualToString:@"AddBeanSegue"]) + { + //Pass on the edit/add state and bean collection + AddBeanViewController *beanViewController = segue.destinationViewController; + [beanViewController initWithModeAndBeanCollection:self.editMode :self.beanCollection]; + + //TODO: Check what last grinder setting was (last bean) and pre set it + } + else if ([segue.identifier isEqualToString:@"EditBeanSegue"]) + { + //TODO + } +} + /***************************************************** Utility methods *****************************************************/ @@ -52,8 +71,11 @@ { NSLog(@"BeanCollectionBeanListViewController - initViewController"); + //Allocate edit's "Done" button + self.beanListEditDoneButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(toggleEditMode:)]; + //Load beans into the table view. - //[self.beanListTableView reloadData]; + [self.beanListTableView reloadData]; if (self.editMode == YES) { @@ -80,6 +102,20 @@ UI Actions *****************************************************/ #pragma mark - IBActions +- (void) toggleEditMode:(id)sender +{ + NSMutableArray *bottomToolbarItems = [NSMutableArray arrayWithArray:self.beanListBottomToolbar.items]; + if (self.beanListTableView.editing) + { + [bottomToolbarItems replaceObjectAtIndex:0 withObject:self.beanListEditButton]; + } + else + { + [bottomToolbarItems replaceObjectAtIndex:0 withObject:self.beanListEditDoneButton]; + } + [self.beanListTableView setEditing:!self.beanListTableView.editing animated:YES]; + [self.beanListBottomToolbar setItems:bottomToolbarItems animated:YES]; +} /***************************************************** UITableView related delegate / datasource methods @@ -102,9 +138,9 @@ UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath]; //Configure the cell and set its title + Bean *currentBean = [self.beanCollection.beans objectAtIndex:indexPath.row]; #warning TODO: This may fuck things up since the beanCollection.beans set is NOT ordered? - BeanCollection *currentCollection = [[self.beanCollection.beans allObjects] objectAtIndex:indexPath.row]; - cell.textLabel.text = currentCollection.name; + cell.textLabel.text = currentBean.name; return cell; } @@ -121,7 +157,12 @@ { if (editingStyle == UITableViewCellEditingStyleDelete) { // Delete the row from the data source -#warning TODO - Implement this (look at CollectionList....) + if (self.beanCollection != nil) + { +#warning TODO - Do we need to remove it via delegate, and then reload the structure or just remove it? + [self.beanCollection removeObjectFromBeansAtIndex: indexPath.row]; + } +#warning TODO - Double check that correct bean is removed! [tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade]; } else if (editingStyle == UITableViewCellEditingStyleInsert) { @@ -129,5 +170,29 @@ } } + // Override to support conditional rearranging of the table view. + - (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath + { + // Return NO if you do not want the item to be re-orderable. + return YES; + } + + // Override to support rearranging the table view. +//http://developer.apple.com/library/ios/#documentation/userexperience/conceptual/tableview_iphone/ManageReorderRow/ManageReorderRow.html + - (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath + { + if (self.beanCollection != nil && fromIndexPath.row != toIndexPath.row) + { + NSLog(@"From: %d, To: %d", fromIndexPath.row, toIndexPath.row); + if (toIndexPath.row < (self.beanCollection.beans.count - 1)) + { + NSMutableIndexSet *beanIndexes = [NSMutableIndexSet indexSetWithIndex:fromIndexPath.row]; + [beanIndexes addIndex:toIndexPath.row]; + NSArray *beans = [NSArray arrayWithObjects:[self.beanCollection.beans objectAtIndex:fromIndexPath.row], [self.beanCollection.beans objectAtIndex:toIndexPath.row], nil]; + [self.beanCollection replaceBeansAtIndexes:beanIndexes withBeans:beans]; + } + } +#warning TODO - Make sure to test to "view/edit" bean after moving it, so that it is correct item! :-) + } @end diff --git a/iBean/iBean/iBean.xcdatamodeld/iBean.xcdatamodel/contents b/iBean/iBean/iBean.xcdatamodeld/iBean.xcdatamodel/contents index 4677f93..f7f7901 100644 --- a/iBean/iBean/iBean.xcdatamodeld/iBean.xcdatamodel/contents +++ b/iBean/iBean/iBean.xcdatamodeld/iBean.xcdatamodel/contents @@ -13,7 +13,7 @@ <attribute name="modified" optional="YES" attributeType="Date" syncable="YES"/> <attribute name="name" optional="YES" attributeType="String" syncable="YES"/> <attribute name="note" optional="YES" attributeType="String" syncable="YES"/> - <relationship name="beans" optional="YES" toMany="YES" deletionRule="Cascade" destinationEntity="Bean" inverseName="beanCollection" inverseEntity="Bean" syncable="YES"/> + <relationship name="beans" optional="YES" toMany="YES" deletionRule="Cascade" ordered="YES" destinationEntity="Bean" inverseName="beanCollection" inverseEntity="Bean" syncable="YES"/> </entity> <entity name="InstaBeanConfiguration" representedClassName="InstaBeanConfiguration" syncable="YES"> <attribute name="extractionTime" optional="YES" attributeType="Double" defaultValueString="0.0" syncable="YES"/> diff --git a/iBean/iBean/iPhoneStoryboard.storyboard b/iBean/iBean/iPhoneStoryboard.storyboard index 5fc65b8..9fbf609 100644 --- a/iBean/iBean/iPhoneStoryboard.storyboard +++ b/iBean/iBean/iPhoneStoryboard.storyboard @@ -236,7 +236,7 @@ </constraints> </view> <navigationItem key="navigationItem" title="Information (1/3)" id="znt-MK-XJf"> - <barButtonItem key="leftBarButtonItem" title="Cancel" id="x9O-iQ-Nw6"> + <barButtonItem key="leftBarButtonItem" systemItem="cancel" id="x9O-iQ-Nw6"> <connections> <segue destination="C1o-is-nML" kind="modal" id="roV-hD-UY6"/> </connections> @@ -269,11 +269,11 @@ <tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" rowHeight="44" sectionHeaderHeight="22" sectionFooterHeight="22" translatesAutoresizingMaskIntoConstraints="NO" id="bW3-E7-UoQ"> <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/> <prototypes> - <tableViewCell contentMode="scaleToFill" selectionStyle="blue" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" reuseIdentifier="BeanCell" textLabel="87B-hs-oLz" style="IBUITableViewCellStyleDefault" id="4VM-0O-fxA"> + <tableViewCell contentMode="scaleToFill" selectionStyle="blue" accessoryType="disclosureIndicator" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" reuseIdentifier="BeanCell" textLabel="87B-hs-oLz" style="IBUITableViewCellStyleDefault" id="4VM-0O-fxA"> <rect key="frame" x="0.0" y="22" width="320" height="44"/> <autoresizingMask key="autoresizingMask"/> <view key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center"> - <rect key="frame" x="0.0" y="0.0" width="320" height="43"/> + <rect key="frame" x="0.0" y="0.0" width="300" height="43"/> <autoresizingMask key="autoresizingMask"/> <subviews> <label opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="left" text="Bean title" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="87B-hs-oLz"> @@ -284,6 +284,9 @@ </subviews> <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/> </view> + <connections> + <segue destination="4CQ-Gd-pSW" kind="push" identifier="EditBeanSegue" id="Fx1-fy-gzR"/> + </connections> </tableViewCell> </prototypes> <connections> @@ -293,11 +296,15 @@ </tableView> <toolbar opaque="NO" clearsContextBeforeDrawing="NO" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="6cY-dj-XP0"> <items> - <barButtonItem title="Edit" id="tKF-jM-0Uj"/> + <barButtonItem title="Edit" id="tKF-jM-0Uj"> + <connections> + <action selector="toggleEditMode:" destination="utP-dF-IAb" id="AjM-pe-V7f"/> + </connections> + </barButtonItem> <barButtonItem style="plain" systemItem="flexibleSpace" id="jlc-7u-JYn"/> <barButtonItem systemItem="add" id="Uv7-P6-bFk"> <connections> - <segue destination="YXO-0S-PzZ" kind="push" identifier="AddBeanSegue" id="h8P-86-6Pm"/> + <segue destination="YXO-0S-PzZ" kind="modal" identifier="AddBeanSegue" id="h8P-86-6Pm"/> </connections> </barButtonItem> </items> @@ -322,12 +329,91 @@ </barButtonItem> </navigationItem> <connections> + <outlet property="beanListBottomToolbar" destination="6cY-dj-XP0" id="Ccm-25-INv"/> + <outlet property="beanListEditButton" destination="tKF-jM-0Uj" id="pAL-HD-4GE"/> <outlet property="beanListTableView" destination="bW3-E7-UoQ" id="ZGo-IU-3Im"/> </connections> </viewController> <placeholder placeholderIdentifier="IBFirstResponder" id="BhV-Dk-tNN" userLabel="First Responder" sceneMemberID="firstResponder"/> </objects> - <point key="canvasLocation" x="2730" y="403"/> + <point key="canvasLocation" x="2777" y="403"/> + </scene> + <!--View Controller - Edit bean--> + <scene sceneID="Uz1-1o-7sM"> + <objects> + <viewController id="4CQ-Gd-pSW" sceneMemberID="viewController"> + <view key="view" contentMode="scaleToFill" id="3Yp-lm-I9K"> + <rect key="frame" x="0.0" y="64" width="320" height="504"/> + <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/> + <subviews> + <label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" text="Name:" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Tbo-8t-W22"> + <fontDescription key="fontDescription" type="system" pointSize="17"/> + <color key="textColor" cocoaTouchSystemColor="darkTextColor"/> + <nil key="highlightedColor"/> + </label> + <textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" placeholder="Enter descriptive name for the bean" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="GEQ-Pg-YlJ"> + <constraints> + <constraint firstAttribute="width" constant="281" id="Y2Z-eE-IrG"/> + </constraints> + <fontDescription key="fontDescription" type="system" pointSize="14"/> + <textInputTraits key="textInputTraits"/> + </textField> + <label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" text="Amount (g):" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="qb5-I0-339"> + <constraints> + <constraint firstAttribute="width" constant="96" id="LD9-FM-Nhn"/> + </constraints> + <fontDescription key="fontDescription" name="Helvetica" family="Helvetica" pointSize="17"/> + <color key="textColor" cocoaTouchSystemColor="darkTextColor"/> + <nil key="highlightedColor"/> + </label> + <stepper opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" maximumValue="500" stepValue="0.5" translatesAutoresizingMaskIntoConstraints="NO" id="blJ-S2-uV9"/> + <label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" text="Grinder setting:" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="bUi-2X-Nne"> + <fontDescription key="fontDescription" type="system" pointSize="17"/> + <color key="textColor" cocoaTouchSystemColor="darkTextColor"/> + <nil key="highlightedColor"/> + </label> + <stepper opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" maximumValue="1000" translatesAutoresizingMaskIntoConstraints="NO" id="bIT-x3-0cE"/> + <label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" text="###" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="o6F-sa-dYn"> + <constraints> + <constraint firstAttribute="width" constant="42" id="d7l-M7-k5y"/> + </constraints> + <fontDescription key="fontDescription" type="system" pointSize="17"/> + <color key="textColor" cocoaTouchSystemColor="darkTextColor"/> + <nil key="highlightedColor"/> + </label> + <label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" text="###" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="nPM-k1-zYG"> + <fontDescription key="fontDescription" type="system" pointSize="17"/> + <color key="textColor" cocoaTouchSystemColor="darkTextColor"/> + <nil key="highlightedColor"/> + </label> + </subviews> + <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/> + <constraints> + <constraint firstItem="o6F-sa-dYn" firstAttribute="leading" secondItem="3Yp-lm-I9K" secondAttribute="leading" constant="144" id="0v6-kO-Mri"/> + <constraint firstItem="blJ-S2-uV9" firstAttribute="top" secondItem="3Yp-lm-I9K" secondAttribute="top" constant="119" id="37C-JE-2LQ"/> + <constraint firstItem="bUi-2X-Nne" firstAttribute="leading" secondItem="Tbo-8t-W22" secondAttribute="leading" type="default" id="BTS-CE-WSI"/> + <constraint firstAttribute="trailing" secondItem="blJ-S2-uV9" secondAttribute="trailing" constant="20" symbolic="YES" type="default" id="Kql-Pp-MaV"/> + <constraint firstItem="GEQ-Pg-YlJ" firstAttribute="top" secondItem="Tbo-8t-W22" secondAttribute="bottom" constant="8" symbolic="YES" type="default" id="L52-kL-FXZ"/> + <constraint firstAttribute="trailing" secondItem="bIT-x3-0cE" secondAttribute="trailing" constant="25" id="MFr-eH-Gd5"/> + <constraint firstItem="qb5-I0-339" firstAttribute="leading" secondItem="3Yp-lm-I9K" secondAttribute="leading" constant="20" symbolic="YES" type="default" id="VXd-tb-OoD"/> + <constraint firstItem="bUi-2X-Nne" firstAttribute="leading" secondItem="3Yp-lm-I9K" secondAttribute="leading" constant="14" id="WFp-1i-ucU"/> + <constraint firstItem="nPM-k1-zYG" firstAttribute="centerY" secondItem="bIT-x3-0cE" secondAttribute="centerY" type="default" id="b9z-GH-iLZ"/> + <constraint firstItem="Tbo-8t-W22" firstAttribute="top" secondItem="3Yp-lm-I9K" secondAttribute="top" constant="20" symbolic="YES" type="default" id="dbh-vK-IP0"/> + <constraint firstItem="nPM-k1-zYG" firstAttribute="baseline" secondItem="bUi-2X-Nne" secondAttribute="baseline" type="default" id="fc6-DV-eht"/> + <constraint firstItem="o6F-sa-dYn" firstAttribute="baseline" secondItem="qb5-I0-339" secondAttribute="baseline" type="default" id="gTY-0N-LM6"/> + <constraint firstItem="nPM-k1-zYG" firstAttribute="leading" secondItem="3Yp-lm-I9K" secondAttribute="leading" constant="145" id="mwi-L1-YFq"/> + <constraint firstItem="o6F-sa-dYn" firstAttribute="centerY" secondItem="blJ-S2-uV9" secondAttribute="centerY" type="default" id="sQk-uG-tQj"/> + <constraint firstItem="GEQ-Pg-YlJ" firstAttribute="leading" secondItem="3Yp-lm-I9K" secondAttribute="leading" constant="13" id="tPV-Xw-rMr"/> + <constraint firstItem="bIT-x3-0cE" firstAttribute="top" secondItem="3Yp-lm-I9K" secondAttribute="top" constant="216" id="wFC-kX-wJz"/> + </constraints> + </view> + <navigationItem key="navigationItem" title="Edit bean" id="A3D-NS-DOt"> + <barButtonItem key="rightBarButtonItem" systemItem="done" id="Dcw-BA-AX2"/> + </navigationItem> + </viewController> + <placeholder placeholderIdentifier="IBFirstResponder" id="WEn-wW-jac" userLabel="First Responder" sceneMemberID="firstResponder"/> + </objects> + <point key="canvasLocation" x="3314" y="744"/> </scene> <!--View Controller - Extraction (3/3)--> <scene sceneID="HiW-Hk-DPa"> @@ -373,14 +459,14 @@ </viewController> <placeholder placeholderIdentifier="IBFirstResponder" id="xVN-NA-gLQ" userLabel="First Responder" sceneMemberID="firstResponder"/> </objects> - <point key="canvasLocation" x="3298" y="403"/> + <point key="canvasLocation" x="4498" y="403"/> </scene> - <!--View Controller - Bean--> + <!--Add Bean View Controller--> <scene sceneID="w0g-Bq-kR5"> <objects> - <viewController id="YXO-0S-PzZ" sceneMemberID="viewController"> + <viewController id="YXO-0S-PzZ" customClass="AddBeanViewController" sceneMemberID="viewController"> <view key="view" contentMode="scaleToFill" id="ghC-6L-tQj"> - <rect key="frame" x="0.0" y="64" width="320" height="504"/> + <rect key="frame" x="0.0" y="20" width="320" height="548"/> <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/> <subviews> <label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" text="Name:" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="9Ya-ar-5en"> @@ -389,6 +475,9 @@ <nil key="highlightedColor"/> </label> <textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" placeholder="Enter descriptive name for the bean" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="Agc-Md-Eqn"> + <constraints> + <constraint firstAttribute="width" constant="281" id="WQ1-oe-YTn"/> + </constraints> <fontDescription key="fontDescription" type="system" pointSize="14"/> <textInputTraits key="textInputTraits"/> </textField> @@ -400,8 +489,12 @@ <color key="textColor" cocoaTouchSystemColor="darkTextColor"/> <nil key="highlightedColor"/> </label> - <stepper opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" maximumValue="100" translatesAutoresizingMaskIntoConstraints="NO" id="pNd-jx-t84"/> - <label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" text="###" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Kyc-kO-LC1"> + <stepper opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" maximumValue="500" stepValue="0.5" translatesAutoresizingMaskIntoConstraints="NO" id="pNd-jx-t84"> + <connections> + <action selector="amountStepperChanged:" destination="YXO-0S-PzZ" eventType="valueChanged" id="vOW-sZ-Ybg"/> + </connections> + </stepper> + <label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" text="0.0" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Kyc-kO-LC1"> <constraints> <constraint firstAttribute="width" constant="42" id="B4f-Sc-iuA"/> </constraints> @@ -414,41 +507,73 @@ <color key="textColor" cocoaTouchSystemColor="darkTextColor"/> <nil key="highlightedColor"/> </label> - <stepper opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" maximumValue="100" translatesAutoresizingMaskIntoConstraints="NO" id="jC3-9l-BMe"/> - <label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" text="###" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="hHL-o2-clY"> + <stepper opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" maximumValue="1000" translatesAutoresizingMaskIntoConstraints="NO" id="jC3-9l-BMe"> + <connections> + <action selector="grinderSettingStepperChanged:" destination="YXO-0S-PzZ" eventType="valueChanged" id="f0Q-WO-wvI"/> + </connections> + </stepper> + <label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" text="0.0" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="hHL-o2-clY"> + <constraints> + <constraint firstAttribute="width" constant="29" id="7IX-JY-Sim"/> + </constraints> <fontDescription key="fontDescription" type="system" pointSize="17"/> <color key="textColor" cocoaTouchSystemColor="darkTextColor"/> <nil key="highlightedColor"/> </label> + <navigationBar contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="dAe-1J-Z5P"> + <constraints> + <constraint firstAttribute="width" constant="320" id="nsS-2k-wy5"/> + </constraints> + <items> + <navigationItem title="Bean" id="xZU-h1-dhg"> + <barButtonItem key="leftBarButtonItem" systemItem="cancel" id="1v4-Op-ecW"> + <connections> + <action selector="cancelBean:" destination="YXO-0S-PzZ" id="H6V-8C-zaU"/> + </connections> + </barButtonItem> + <barButtonItem key="rightBarButtonItem" systemItem="done" id="qZu-Oo-8Af"> + <connections> + <action selector="commitBean:" destination="YXO-0S-PzZ" id="qPq-wH-NHg"/> + </connections> + </barButtonItem> + </navigationItem> + </items> + </navigationBar> </subviews> <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/> <constraints> <constraint firstItem="hHL-o2-clY" firstAttribute="centerY" secondItem="jC3-9l-BMe" secondAttribute="centerY" type="default" id="1sM-7a-reS"/> + <constraint firstItem="Agc-Md-Eqn" firstAttribute="centerX" secondItem="hHL-o2-clY" secondAttribute="centerX" type="default" id="2Lt-hI-wPV"/> + <constraint firstItem="Kyc-kO-LC1" firstAttribute="centerX" secondItem="ghC-6L-tQj" secondAttribute="centerX" type="default" id="2uH-Fc-EHc"/> <constraint firstItem="hHL-o2-clY" firstAttribute="baseline" secondItem="xEq-oC-MEA" secondAttribute="baseline" type="default" id="43h-a4-Meu"/> - <constraint firstItem="9Ya-ar-5en" firstAttribute="top" secondItem="ghC-6L-tQj" secondAttribute="top" constant="20" symbolic="YES" type="default" id="5FW-23-E1L"/> <constraint firstItem="Agc-Md-Eqn" firstAttribute="top" secondItem="9Ya-ar-5en" secondAttribute="bottom" constant="8" symbolic="YES" type="default" id="5h5-LQ-Qba"/> - <constraint firstAttribute="trailing" secondItem="jC3-9l-BMe" secondAttribute="trailing" constant="20" symbolic="YES" type="default" id="5xb-gL-fz8"/> - <constraint firstAttribute="trailing" secondItem="Agc-Md-Eqn" secondAttribute="trailing" constant="20" symbolic="YES" type="default" id="6Yu-WN-8Wg"/> - <constraint firstItem="xEq-oC-MEA" firstAttribute="leading" secondItem="ghC-6L-tQj" secondAttribute="leading" constant="20" symbolic="YES" type="default" id="M1u-yJ-5p4"/> - <constraint firstItem="Agc-Md-Eqn" firstAttribute="leading" secondItem="ghC-6L-tQj" secondAttribute="leading" constant="20" symbolic="YES" type="default" id="Tsk-6D-L9R"/> - <constraint firstItem="hHL-o2-clY" firstAttribute="leading" secondItem="xEq-oC-MEA" secondAttribute="trailing" constant="8" symbolic="YES" type="default" id="Vs4-pL-o1v"/> - <constraint firstItem="9Ya-ar-5en" firstAttribute="leading" secondItem="ghC-6L-tQj" secondAttribute="leading" constant="20" symbolic="YES" type="default" id="bCm-4d-Wta"/> + <constraint firstItem="9Ya-ar-5en" firstAttribute="top" secondItem="ghC-6L-tQj" secondAttribute="top" constant="56" id="LTC-5k-f7U"/> + <constraint firstAttribute="trailing" secondItem="Agc-Md-Eqn" secondAttribute="trailing" constant="20" symbolic="YES" type="default" id="O1O-Eb-6id"/> + <constraint firstItem="Agc-Md-Eqn" firstAttribute="leading" secondItem="9Ya-ar-5en" secondAttribute="leading" type="default" id="Vzr-9t-8rK"/> + <constraint firstAttribute="trailing" secondItem="jC3-9l-BMe" secondAttribute="trailing" constant="20" symbolic="YES" type="default" id="Wbf-lD-OSk"/> + <constraint firstItem="xEq-oC-MEA" firstAttribute="leading" secondItem="Agc-Md-Eqn" secondAttribute="leading" type="default" id="aFF-rC-Dgh"/> <constraint firstItem="Kyc-kO-LC1" firstAttribute="baseline" secondItem="K5g-ln-AQ0" secondAttribute="baseline" type="default" id="bZr-bn-25o"/> + <constraint firstItem="dAe-1J-Z5P" firstAttribute="top" secondItem="ghC-6L-tQj" secondAttribute="top" type="default" id="bbT-z9-Mlf"/> <constraint firstItem="K5g-ln-AQ0" firstAttribute="leading" secondItem="ghC-6L-tQj" secondAttribute="leading" constant="20" symbolic="YES" type="default" id="blM-BY-AMC"/> - <constraint firstItem="Kyc-kO-LC1" firstAttribute="centerX" secondItem="Agc-Md-Eqn" secondAttribute="centerX" type="default" id="k17-W5-gMi"/> + <constraint firstItem="dAe-1J-Z5P" firstAttribute="centerX" secondItem="Agc-Md-Eqn" secondAttribute="centerX" type="default" id="dY6-6N-zm6"/> <constraint firstAttribute="trailing" secondItem="pNd-jx-t84" secondAttribute="trailing" constant="20" symbolic="YES" type="default" id="mTh-qS-7lC"/> <constraint firstItem="Kyc-kO-LC1" firstAttribute="centerY" secondItem="pNd-jx-t84" secondAttribute="centerY" type="default" id="q7g-KI-mpp"/> <constraint firstAttribute="bottom" secondItem="jC3-9l-BMe" secondAttribute="bottom" constant="185" id="wga-Xo-SQg"/> <constraint firstItem="pNd-jx-t84" firstAttribute="top" secondItem="ghC-6L-tQj" secondAttribute="top" constant="138" id="zhn-ni-dd4"/> </constraints> </view> - <navigationItem key="navigationItem" title="Bean" id="D7u-lI-2Vv"> - <barButtonItem key="rightBarButtonItem" systemItem="done" id="qZu-Oo-8Af"/> - </navigationItem> + <navigationItem key="navigationItem" id="oBX-Cx-tP7"/> + <connections> + <outlet property="amountLabel" destination="Kyc-kO-LC1" id="WFz-Jx-q0Z"/> + <outlet property="amountStepper" destination="pNd-jx-t84" id="Gc7-pS-pd3"/> + <outlet property="beanNameTextField" destination="Agc-Md-Eqn" id="sAv-gC-aCk"/> + <outlet property="grinderSettingLabel" destination="hHL-o2-clY" id="x7w-p1-WzF"/> + <outlet property="grinderSettingStepper" destination="jC3-9l-BMe" id="GIc-Fa-E4E"/> + </connections> </viewController> <placeholder placeholderIdentifier="IBFirstResponder" id="myk-um-Owg" userLabel="First Responder" sceneMemberID="firstResponder"/> </objects> - <point key="canvasLocation" x="2730" y="-291"/> + <point key="canvasLocation" x="3314" y="31"/> </scene> <!--Navigation Controller--> <scene sceneID="kQ1-YP-ELW"> @@ -471,9 +596,26 @@ </scene> </scenes> <classes> + <class className="AddBeanViewController" superclassName="UIViewController"> + <source key="sourceIdentifier" type="project" relativePath="./Classes/AddBeanViewController.h"/> + <relationships> + <relationship kind="action" name="amountStepperChanged:"/> + <relationship kind="action" name="cancelBean:"/> + <relationship kind="action" name="commitBean:"/> + <relationship kind="action" name="grinderSettingStepperChanged:"/> + <relationship kind="outlet" name="amountLabel" candidateClass="UILabel"/> + <relationship kind="outlet" name="amountStepper" candidateClass="UIStepper"/> + <relationship kind="outlet" name="beanNameTextField" candidateClass="UITextField"/> + <relationship kind="outlet" name="grinderSettingLabel" candidateClass="UILabel"/> + <relationship kind="outlet" name="grinderSettingStepper" candidateClass="UIStepper"/> + </relationships> + </class> <class className="BeanCollectionBeanListViewController" superclassName="UIViewController"> <source key="sourceIdentifier" type="project" relativePath="./Classes/BeanCollectionBeanListViewController.h"/> <relationships> + <relationship kind="action" name="toggleEditMode:"/> + <relationship kind="outlet" name="beanListBottomToolbar" candidateClass="UIToolbar"/> + <relationship kind="outlet" name="beanListEditButton" candidateClass="UIBarButtonItem"/> <relationship kind="outlet" name="beanListTableView" candidateClass="UITableView"/> </relationships> </class> @@ -518,6 +660,6 @@ <simulatedScreenMetrics key="destination" type="retina4"/> </simulatedMetricsContainer> <inferredMetricsTieBreakers> - <segue reference="roV-hD-UY6"/> + <segue reference="CyX-df-8ge"/> </inferredMetricsTieBreakers> </document>
\ No newline at end of file |