diff options
-rw-r--r-- | iBean/iBean.xcodeproj/project.pbxproj | 32 | ||||
-rw-r--r-- | iBean/iBean.xcodeproj/project.xcworkspace/xcuserdata/eddiex.xcuserdatad/UserInterfaceState.xcuserstate | bin | 34150 -> 33585 bytes | |||
-rw-r--r-- | iBean/iBean/AddBeanViewController.h | 1 | ||||
-rw-r--r-- | iBean/iBean/AddBeanViewController.m | 18 | ||||
-rw-r--r-- | iBean/iBean/AppDelegate+Storage.m | 1 | ||||
-rw-r--r-- | iBean/iBean/EditBeanViewController.m | 18 | ||||
-rw-r--r-- | iBean/iBean/ExtractionViewController.h | 29 | ||||
-rw-r--r-- | iBean/iBean/ExtractionViewController.m | 108 | ||||
-rw-r--r-- | iBean/iBean/iPhoneStoryboard.storyboard | 26 |
9 files changed, 218 insertions, 15 deletions
diff --git a/iBean/iBean.xcodeproj/project.pbxproj b/iBean/iBean.xcodeproj/project.pbxproj index e3df510..68cbbd0 100644 --- a/iBean/iBean.xcodeproj/project.pbxproj +++ b/iBean/iBean.xcodeproj/project.pbxproj @@ -31,6 +31,7 @@ 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 */; }; 020C568F16A1CE0E00D8224C /* EditBeanViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 020C568E16A1CE0E00D8224C /* EditBeanViewController.m */; }; + 020C569316A1E55600D8224C /* ExtractionViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 020C569216A1E55600D8224C /* ExtractionViewController.m */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ @@ -74,6 +75,8 @@ 020C5682169F5FBB00D8224C /* BeanCollection+Interface.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "BeanCollection+Interface.m"; sourceTree = "<group>"; }; 020C568D16A1CE0E00D8224C /* EditBeanViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EditBeanViewController.h; sourceTree = "<group>"; }; 020C568E16A1CE0E00D8224C /* EditBeanViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = EditBeanViewController.m; sourceTree = "<group>"; }; + 020C569116A1E55600D8224C /* ExtractionViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ExtractionViewController.h; sourceTree = "<group>"; }; + 020C569216A1E55600D8224C /* ExtractionViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ExtractionViewController.m; sourceTree = "<group>"; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -172,9 +175,10 @@ isa = PBXGroup; children = ( 020C56081698F58900D8224C /* BeanCollectionList */, - 020C56091698F59F00D8224C /* BeanCollectionInfo */, - 020C56071698F4DC00D8224C /* BeanCollectionBeanList */, - 020C566E169E1ACB00D8224C /* Bean */, + 020C56091698F59F00D8224C /* Step 1 - BeanCollectionInfo */, + 020C56071698F4DC00D8224C /* Step 2 - BeanCollectionBeanList */, + 020C566E169E1ACB00D8224C /* Step 3 - Bean */, + 020C569016A1E50200D8224C /* Step 4 - Extraction */, 020C55DF169792F800D8224C /* Data */, ); name = iBean; @@ -192,13 +196,13 @@ name = Data; sourceTree = "<group>"; }; - 020C56071698F4DC00D8224C /* BeanCollectionBeanList */ = { + 020C56071698F4DC00D8224C /* Step 2 - BeanCollectionBeanList */ = { isa = PBXGroup; children = ( 020C56041698A85000D8224C /* BeanCollectionBeanListViewController.h */, 020C56051698A85000D8224C /* BeanCollectionBeanListViewController.m */, ); - name = BeanCollectionBeanList; + name = "Step 2 - BeanCollectionBeanList"; sourceTree = "<group>"; }; 020C56081698F58900D8224C /* BeanCollectionList */ = { @@ -210,16 +214,16 @@ name = BeanCollectionList; sourceTree = "<group>"; }; - 020C56091698F59F00D8224C /* BeanCollectionInfo */ = { + 020C56091698F59F00D8224C /* Step 1 - BeanCollectionInfo */ = { isa = PBXGroup; children = ( 020C560116989D4500D8224C /* BeanCollectionInfoViewController.h */, 020C560216989D4500D8224C /* BeanCollectionInfoViewController.m */, ); - name = BeanCollectionInfo; + name = "Step 1 - BeanCollectionInfo"; sourceTree = "<group>"; }; - 020C566E169E1ACB00D8224C /* Bean */ = { + 020C566E169E1ACB00D8224C /* Step 3 - Bean */ = { isa = PBXGroup; children = ( 020C5670169E1B0100D8224C /* AddBeanViewController.h */, @@ -227,7 +231,7 @@ 020C568D16A1CE0E00D8224C /* EditBeanViewController.h */, 020C568E16A1CE0E00D8224C /* EditBeanViewController.m */, ); - name = Bean; + name = "Step 3 - Bean"; sourceTree = "<group>"; }; 020C5684169F603700D8224C /* Interface */ = { @@ -241,6 +245,15 @@ name = Interface; sourceTree = "<group>"; }; + 020C569016A1E50200D8224C /* Step 4 - Extraction */ = { + isa = PBXGroup; + children = ( + 020C569116A1E55600D8224C /* ExtractionViewController.h */, + 020C569216A1E55600D8224C /* ExtractionViewController.m */, + ); + name = "Step 4 - Extraction"; + sourceTree = "<group>"; + }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ @@ -322,6 +335,7 @@ 020C5680169F5E9A00D8224C /* Bean+Interface.m in Sources */, 020C5683169F5FBB00D8224C /* BeanCollection+Interface.m in Sources */, 020C568F16A1CE0E00D8224C /* EditBeanViewController.m in Sources */, + 020C569316A1E55600D8224C /* ExtractionViewController.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 9d36b94..e41083a 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 index 0778f36..e246b6e 100644 --- a/iBean/iBean/AddBeanViewController.h +++ b/iBean/iBean/AddBeanViewController.h @@ -24,6 +24,7 @@ @property (weak, nonatomic) IBOutlet UIStepper *amountStepper; @property (weak, nonatomic) IBOutlet UILabel *grinderSettingLabel; @property (weak, nonatomic) IBOutlet UIStepper *grinderSettingStepper; +@property (weak, nonatomic) IBOutlet UINavigationBar *addBeanNavigationBar; /* UI Actions */ - (IBAction) amountStepperChanged:(id)sender; diff --git a/iBean/iBean/AddBeanViewController.m b/iBean/iBean/AddBeanViewController.m index f2faa54..be5cc8e 100644 --- a/iBean/iBean/AddBeanViewController.m +++ b/iBean/iBean/AddBeanViewController.m @@ -112,7 +112,23 @@ /***************************************************** Delegate *****************************************************/ -#pragma mark - UITextField delagate related methods +#pragma mark - UITextFieldDelegate methods +- (void) textFieldDidBeginEditing:(UITextField *)textField +{ + if (textField == self.beanNameTextField) + { + [[[self.addBeanNavigationBar.items objectAtIndex:0] rightBarButtonItem] setEnabled:NO]; + } +} + +- (void) textFieldDidEndEditing:(UITextField *)textField +{ + if (textField == self.beanNameTextField) + { + [[[self.addBeanNavigationBar.items objectAtIndex:0] rightBarButtonItem] setEnabled:YES]; + } +} + //Purpose: When "return" is pressed the keyboard will go away and "change" event will be triggered. - (BOOL)textFieldShouldReturn:(UITextField *)textField { diff --git a/iBean/iBean/AppDelegate+Storage.m b/iBean/iBean/AppDelegate+Storage.m index 4f8fc0d..013ce10 100644 --- a/iBean/iBean/AppDelegate+Storage.m +++ b/iBean/iBean/AppDelegate+Storage.m @@ -107,6 +107,7 @@ if (bc != nil) { bc.created = [NSDate date]; + bc.extractionTime = [NSNumber numberWithDouble:25.0f]; } } diff --git a/iBean/iBean/EditBeanViewController.m b/iBean/iBean/EditBeanViewController.m index 5f1a84c..59b3d8d 100644 --- a/iBean/iBean/EditBeanViewController.m +++ b/iBean/iBean/EditBeanViewController.m @@ -120,7 +120,23 @@ /***************************************************** Delegate *****************************************************/ -#pragma mark - UITextField delagate related methods +#pragma mark - UITextFieldDelegate methods +- (void) textFieldDidBeginEditing:(UITextField *)textField +{ + if (textField == self.beanNameTextField) + { + [self.navigationItem.rightBarButtonItem setEnabled:NO]; + } +} + +- (void) textFieldDidEndEditing:(UITextField *)textField +{ + if (textField == self.beanNameTextField) + { + [self.navigationItem.rightBarButtonItem setEnabled:YES]; + } +} + //Purpose: When "return" is pressed the keyboard will go away and "change" event will be triggered. - (BOOL)textFieldShouldReturn:(UITextField *)textField { diff --git a/iBean/iBean/ExtractionViewController.h b/iBean/iBean/ExtractionViewController.h new file mode 100644 index 0000000..3844440 --- /dev/null +++ b/iBean/iBean/ExtractionViewController.h @@ -0,0 +1,29 @@ +// +// ExtractionViewController.h +// iBean +// +// Created by Eddie Ehlin on 2013-01-12. +// Copyright (c) 2013 Eddie Ehlin. All rights reserved. +// + +#import <UIKit/UIKit.h> +@class BeanCollection; + +@interface ExtractionViewController : UIViewController + +@property (nonatomic, strong) BeanCollection *beanCollection; +@property (nonatomic, assign) BOOL editMode; + +/* Utility methods */ +- (void) initViewController; +- (void) initWithModeAndBeanCollection:(BOOL)editMode: (BeanCollection*) bc; +- (BOOL) commitBeanCollection; + +/* UI Outlets */ +@property (weak, nonatomic) IBOutlet UIStepper *extractionSettingStepper; +@property (weak, nonatomic) IBOutlet UILabel *extractionSettingLabel; + +/* UI Actions */ +- (IBAction) extractionSettingStepperChanged:(id)sender; + +@end diff --git a/iBean/iBean/ExtractionViewController.m b/iBean/iBean/ExtractionViewController.m new file mode 100644 index 0000000..a96b895 --- /dev/null +++ b/iBean/iBean/ExtractionViewController.m @@ -0,0 +1,108 @@ +// +// ExtractionViewController.m +// iBean +// +// Created by Eddie Ehlin on 2013-01-12. +// Copyright (c) 2013 Eddie Ehlin. All rights reserved. +// + +#import "ExtractionViewController.h" +#import "BeanCollection+Interface.h" +#import "AppDelegate+Storage.h" + +@interface ExtractionViewController () + +@end + +@implementation ExtractionViewController + +- (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. +} + +- (BOOL)shouldPerformSegueWithIdentifier:(NSString *)identifier sender:(id)sender +{ + //Check if we should perform the segue back to bean collection list. + if ([identifier isEqualToString:@"CommitBeanCollectionSegue"]) + { + return [self commitBeanCollection]; + } + + return YES; +} + +/***************************************************** + Utility methods + *****************************************************/ +- (void) initViewController +{ + NSLog(@"ExtractionViewController - initViewController"); + + + //No need to check self.editMode here, since bean collection + //receives a default value of 25.0 for extraction time. + if (self.beanCollection != nil) + { + self.extractionSettingLabel.text = [NSString stringWithFormat:@"%1.1f", [self.beanCollection.extractionTime doubleValue]]; + self.extractionSettingStepper.value = [self.beanCollection.extractionTime doubleValue]; + } +} + +- (void) initWithModeAndBeanCollection:(BOOL)editMode: (BeanCollection*) bc +{ + NSLog(@"ExtractionViewController - initWithModeAndBeanCollection"); + self.editMode = editMode; + self.beanCollection = bc; +} + +- (BOOL) commitBeanCollection +{ + NSError *commitError = nil; + commitError = [(AppDelegate*) [[UIApplication sharedApplication] delegate] save]; + + if (commitError != nil) + { +#warning TODO - Display error messsag! + return NO; + } + + //Bean collection successfully saved, lets go back to list of bean collections. + return YES; +} + +/***************************************************** + UI Actions + *****************************************************/ +- (void) extractionSettingStepperChanged:(id)sender +{ + self.extractionSettingLabel.text = [NSString stringWithFormat:@"%1.1f", self.extractionSettingStepper.value]; + if (self.beanCollection != nil) + { + self.beanCollection.extractionTime = [NSNumber numberWithDouble:self.extractionSettingStepper.value]; + } +} + +@end diff --git a/iBean/iBean/iPhoneStoryboard.storyboard b/iBean/iBean/iPhoneStoryboard.storyboard index 1c18432..94023a4 100644 --- a/iBean/iBean/iPhoneStoryboard.storyboard +++ b/iBean/iBean/iPhoneStoryboard.storyboard @@ -440,10 +440,10 @@ </objects> <point key="canvasLocation" x="3314" y="744"/> </scene> - <!--View Controller - Extraction (3/3)--> + <!--Extraction View Controller - Extraction (3/3)--> <scene sceneID="HiW-Hk-DPa"> <objects> - <viewController id="49F-vz-WhB" sceneMemberID="viewController"> + <viewController id="49F-vz-WhB" customClass="ExtractionViewController" sceneMemberID="viewController"> <view key="view" contentMode="scaleToFill" id="GTi-kB-GK2"> <rect key="frame" x="0.0" y="64" width="320" height="504"/> <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/> @@ -453,7 +453,11 @@ <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="lvU-0d-qF1"/> + <stepper opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" maximumValue="100" stepValue="0.5" translatesAutoresizingMaskIntoConstraints="NO" id="lvU-0d-qF1"> + <connections> + <action selector="extractionSettingStepperChanged:" destination="49F-vz-WhB" eventType="valueChanged" id="Tht-18-lS4"/> + </connections> + </stepper> <label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" text="25" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="i9j-PQ-aof"> <constraints> <constraint firstAttribute="height" constant="53" id="DUG-g4-TU9"/> @@ -477,10 +481,14 @@ <navigationItem key="navigationItem" title="Extraction (3/3)" id="rnS-KT-Ugg"> <barButtonItem key="rightBarButtonItem" systemItem="done" id="a0e-Mo-oEY"> <connections> - <segue destination="C1o-is-nML" kind="modal" identifier="CommitNewBeanCollectionSegue" id="CyX-df-8ge"/> + <segue destination="C1o-is-nML" kind="modal" identifier="CommitBeanCollectionSegue" id="CyX-df-8ge"/> </connections> </barButtonItem> </navigationItem> + <connections> + <outlet property="extractionSettingLabel" destination="i9j-PQ-aof" id="2p3-yA-2fc"/> + <outlet property="extractionSettingStepper" destination="lvU-0d-qF1" id="4he-Lz-Asc"/> + </connections> </viewController> <placeholder placeholderIdentifier="IBFirstResponder" id="xVN-NA-gLQ" userLabel="First Responder" sceneMemberID="firstResponder"/> </objects> @@ -592,6 +600,7 @@ </view> <navigationItem key="navigationItem" id="oBX-Cx-tP7"/> <connections> + <outlet property="addBeanNavigationBar" destination="dAe-1J-Z5P" id="Tfv-Wi-b6m"/> <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"/> @@ -631,6 +640,7 @@ <relationship kind="action" name="cancelBean:"/> <relationship kind="action" name="commitBean:"/> <relationship kind="action" name="grinderSettingStepperChanged:"/> + <relationship kind="outlet" name="addBeanNavigationBar" candidateClass="UINavigationBar"/> <relationship kind="outlet" name="amountLabel" candidateClass="UILabel"/> <relationship kind="outlet" name="amountStepper" candidateClass="UIStepper"/> <relationship kind="outlet" name="beanNameTextField" candidateClass="UITextField"/> @@ -680,6 +690,14 @@ <relationship kind="outlet" name="grinderSettingStepper" candidateClass="UIStepper"/> </relationships> </class> + <class className="ExtractionViewController" superclassName="UIViewController"> + <source key="sourceIdentifier" type="project" relativePath="./Classes/ExtractionViewController.h"/> + <relationships> + <relationship kind="action" name="extractionSettingStepperChanged:"/> + <relationship kind="outlet" name="extractionSettingLabel" candidateClass="UILabel"/> + <relationship kind="outlet" name="extractionSettingStepper" candidateClass="UIStepper"/> + </relationships> + </class> <class className="InstaBeanViewController" superclassName="UIViewController"> <source key="sourceIdentifier" type="project" relativePath="./Classes/InstaBeanViewController.h"/> <relationships> |