aboutsummaryrefslogtreecommitdiffstats
path: root/iBean/iBean
diff options
context:
space:
mode:
authorEddie Ehlin <eddiex@eddiex.se>2013-01-12 20:44:24 +0100
committerEddie Ehlin <eddiex@eddiex.se>2013-01-12 20:44:24 +0100
commitf1ca62e3237aceda58b60f29b3cceb7d6ec33d37 (patch)
tree3be3d276a9f1c97e791c65f908a0b2624d8280c2 /iBean/iBean
parent18837282529f46b471a48d811ea2d86564690758 (diff)
downloadiBean-f1ca62e3237aceda58b60f29b3cceb7d6ec33d37.tar.gz
iBean-f1ca62e3237aceda58b60f29b3cceb7d6ec33d37.zip
Added ExtractionViewController and also closed the Add-new-bean-collection-loop.
Diffstat (limited to 'iBean/iBean')
-rw-r--r--iBean/iBean/AddBeanViewController.h1
-rw-r--r--iBean/iBean/AddBeanViewController.m18
-rw-r--r--iBean/iBean/AppDelegate+Storage.m1
-rw-r--r--iBean/iBean/EditBeanViewController.m18
-rw-r--r--iBean/iBean/ExtractionViewController.h29
-rw-r--r--iBean/iBean/ExtractionViewController.m108
-rw-r--r--iBean/iBean/iPhoneStoryboard.storyboard26
7 files changed, 195 insertions, 6 deletions
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>