aboutsummaryrefslogtreecommitdiffstats
path: root/iBean
diff options
context:
space:
mode:
authorEddie Ehlin <eddiex@eddiex.se>2012-12-29 19:14:18 +0100
committerEddie Ehlin <eddiex@eddiex.se>2012-12-29 19:14:18 +0100
commit5a21cbfb85b34f498a758c66f663b45b822dc262 (patch)
tree725f793c938ac0d0148062deaf7061ce031bdf67 /iBean
parentee4cbc12735a86d2a69f25f6678a2cb3df0de7e2 (diff)
downloadiBean-5a21cbfb85b34f498a758c66f663b45b822dc262.tar.gz
iBean-5a21cbfb85b34f498a758c66f663b45b822dc262.zip
InstaBean functionality implemented, except for CoreData.
Diffstat (limited to 'iBean')
-rw-r--r--iBean/iBean.xcodeproj/project.xcworkspace/xcuserdata/eddiex.xcuserdatad/UserInterfaceState.xcuserstatebin18900 -> 20760 bytes
-rw-r--r--iBean/iBean.xcodeproj/xcuserdata/eddiex.xcuserdatad/xcdebugger/Breakpoints.xcbkptlist20
-rw-r--r--iBean/iBean/InstaBeanViewController.h19
-rw-r--r--iBean/iBean/InstaBeanViewController.m85
-rw-r--r--iBean/iBean/en.lproj/MainStoryboard_iPhone.storyboard20
5 files changed, 104 insertions, 40 deletions
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 a6b65d0..c1a02c2 100644
--- a/iBean/iBean.xcodeproj/project.xcworkspace/xcuserdata/eddiex.xcuserdatad/UserInterfaceState.xcuserstate
+++ b/iBean/iBean.xcodeproj/project.xcworkspace/xcuserdata/eddiex.xcuserdatad/UserInterfaceState.xcuserstate
Binary files differ
diff --git a/iBean/iBean.xcodeproj/xcuserdata/eddiex.xcuserdatad/xcdebugger/Breakpoints.xcbkptlist b/iBean/iBean.xcodeproj/xcuserdata/eddiex.xcuserdatad/xcdebugger/Breakpoints.xcbkptlist
new file mode 100644
index 0000000..34b12d6
--- /dev/null
+++ b/iBean/iBean.xcodeproj/xcuserdata/eddiex.xcuserdatad/xcdebugger/Breakpoints.xcbkptlist
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Bucket
+ type = "1"
+ version = "1.0">
+ <FileBreakpoints>
+ <FileBreakpoint
+ shouldBeEnabled = "No"
+ ignoreCount = "0"
+ continueAfterRunningActions = "No"
+ filePath = "iBean/InstaBeanViewController.m"
+ timestampString = "378477821.220756"
+ startingColumnNumber = "9223372036854775807"
+ endingColumnNumber = "9223372036854775807"
+ startingLineNumber = "30"
+ endingLineNumber = "30"
+ landmarkName = "-viewDidLoad"
+ landmarkType = "5">
+ </FileBreakpoint>
+ </FileBreakpoints>
+</Bucket>
diff --git a/iBean/iBean/InstaBeanViewController.h b/iBean/iBean/InstaBeanViewController.h
index 7dbb6de..65ae31b 100644
--- a/iBean/iBean/InstaBeanViewController.h
+++ b/iBean/iBean/InstaBeanViewController.h
@@ -9,10 +9,23 @@
#import <UIKit/UIKit.h>
@interface InstaBeanViewController : UIViewController
-@property (weak, nonatomic) IBOutlet UILabel *extractionTimerLabel;
+@property (weak, nonatomic) IBOutlet UILabel *extractionProgressLabel;
+@property (weak, nonatomic) IBOutlet UIStepper *extractionSettingStepper;
+@property (weak, nonatomic) IBOutlet UILabel *extractionSettingLabel;
@property (weak, nonatomic) IBOutlet UIButton *extractionButton;
-@property (weak, nonatomic) IBOutlet UIStepper *extractionSetupStepper;
-@property (weak, nonatomic) IBOutlet UILabel *extractionTimerSettingLabel;
+
+@property (nonatomic) double extractionProgress;
@property (nonatomic) BOOL extractionInProgress;
+@property (weak, nonatomic) NSTimer* timer;
+
+//Utility methods
+- (void) updateExtractionSettingLabel;
+- (void) initInstaBean;
+- (void) updateExtractionProgressLabel;
+- (void) haltExtractionTimer;
+
+//Event/signal based methods
+- (IBAction)setExtractionTimer:(id)sender;
+- (IBAction)startExtraction:(id)sender;
@end
diff --git a/iBean/iBean/InstaBeanViewController.m b/iBean/iBean/InstaBeanViewController.m
index e528122..dd67379 100644
--- a/iBean/iBean/InstaBeanViewController.m
+++ b/iBean/iBean/InstaBeanViewController.m
@@ -14,22 +14,12 @@
@implementation InstaBeanViewController
-/*
-- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
-{
- self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
- if (self) {
- // Custom initialization
- }
- return self;
-}
- */
-
- (void)viewDidLoad
{
[super viewDidLoad];
NSLog(@"InstaBean viewDidLoad");
- // Do any additional setup after loading the view.
+ [self initInstaBean];
+
}
- (void)didReceiveMemoryWarning
@@ -39,33 +29,74 @@
}
-//Insta bean methods
-- (IBAction)setTimerInterval:(id)sender {
- NSString *timerSetting = [NSString stringWithFormat:@"%1.0f", [self.extractionSetupStepper value]];
- NSLog(@"%@", timerSetting);
- [self.extractionTimerSettingLabel setText:timerSetting];
+//-------------------------------------------------------------------
+// UTILITY METHODS
+//-------------------------------------------------------------------
+- (void) updateExtractionSettingLabel {
+ NSString *timerSetting = [NSString stringWithFormat:@"%1.0f", [self.extractionSettingStepper value]];
+ self.extractionSettingLabel.text = timerSetting;
+}
+
+- (void) updateExtractionProgressLabel {
+ self.extractionProgress += 0.1f;
+ self.extractionProgressLabel.text = [NSString stringWithFormat:@"%1.1f", self.extractionProgress];
+
+ if (self.extractionProgress >= self.extractionSettingStepper.value)
+ {
+ NSLog(@"Timer reached its limit!");
+ [self haltExtractionTimer];
+ }
+}
+
+- (void) haltExtractionTimer
+{
+ if (self.timer != nil)
+ {
+ [self.timer invalidate];
+ self.timer = nil;
+ [self.extractionButton setTitle:@"Start extraction" forState:UIControlStateNormal];
+ self.extractionInProgress = NO;
+ [self.extractionSettingStepper setEnabled:YES];
+ }
+}
+
+//-------------------------------------------------------------------
+// ACTION METHODS
+//-------------------------------------------------------------------
+
+- (void) initInstaBean
+{
+ NSLog(@"Loading & setting stepper!");
+ //TODO: Read from storage..
+ [self.extractionSettingStepper setValue:25.0f];
+ [self updateExtractionSettingLabel];
+}
+
+- (IBAction)setExtractionTimer:(id)sender {
+ [self updateExtractionSettingLabel];
}
- (IBAction)startExtraction:(id)sender {
+
if (self.extractionInProgress == NO)
{
- //Update button text to "Stop extraction"
self.extractionInProgress = YES;
+ self.extractionProgress = 0.0f;
+ self.extractionProgressLabel.text = @"0.0";
[self.extractionButton setTitle:@"Stop extraction" forState:UIControlStateNormal];
- [self.extractionButton setTintColor:[UIColor redColor]];
+ [self.extractionSettingStepper setEnabled:NO];
+
+ if (self.timer == nil)
+ {
+ self.timer = [NSTimer scheduledTimerWithTimeInterval:0.1f target:self selector:@selector(updateExtractionProgressLabel) userInfo:nil repeats:YES];
+ }
//TODO: Set red background image.
- //TODO: Start timer.
+
}
else
{
- [self.extractionButton setTitle:@"Start extraction" forState:UIControlStateNormal];
- self.extractionInProgress = NO;
- [self.extractionButton setTintColor:[UIColor greenColor]];
//TODO: Set green background image.
- //TODO: Halt timer
+ [self haltExtractionTimer];
}
-
}
-
-
@end
diff --git a/iBean/iBean/en.lproj/MainStoryboard_iPhone.storyboard b/iBean/iBean/en.lproj/MainStoryboard_iPhone.storyboard
index 0e1a2c4..a65aaa4 100644
--- a/iBean/iBean/en.lproj/MainStoryboard_iPhone.storyboard
+++ b/iBean/iBean/en.lproj/MainStoryboard_iPhone.storyboard
@@ -68,12 +68,12 @@
<color key="titleColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
</state>
<connections>
- <action selector="startExtraction:" destination="3" eventType="touchUpInside" id="XmK-mp-8Vw"/>
+ <action selector="startExtraction:" destination="3" eventType="touchUpInside" id="kjW-U4-gbu"/>
</connections>
</button>
<stepper opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" value="25" minimumValue="1" maximumValue="60" translatesAutoresizingMaskIntoConstraints="NO" id="507-KX-F4S">
<connections>
- <action selector="setTimerInterval:" destination="3" eventType="valueChanged" id="Bnl-Rg-Rc5"/>
+ <action selector="setExtractionTimer:" destination="3" eventType="valueChanged" id="zsr-5X-Pbz"/>
</connections>
</stepper>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" text="Label" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Fpj-yQ-Jhw">
@@ -97,10 +97,10 @@
</view>
<tabBarItem key="tabBarItem" title="Insta bean" image="second" id="6"/>
<connections>
- <outlet property="extractionButton" destination="ghy-eB-Fc0" id="XCY-hn-3mK"/>
- <outlet property="extractionSetupStepper" destination="507-KX-F4S" id="nnb-jU-llM"/>
- <outlet property="extractionTimerLabel" destination="CiC-m9-5rR" id="8qh-Y6-1s1"/>
- <outlet property="extractionTimerSettingLabel" destination="Fpj-yQ-Jhw" id="am4-jQ-vy1"/>
+ <outlet property="extractionButton" destination="ghy-eB-Fc0" id="SPP-wT-uF3"/>
+ <outlet property="extractionProgressLabel" destination="CiC-m9-5rR" id="8Ca-UB-cZV"/>
+ <outlet property="extractionSettingLabel" destination="Fpj-yQ-Jhw" id="hhI-wZ-9Lc"/>
+ <outlet property="extractionSettingStepper" destination="507-KX-F4S" id="6Pt-3K-8eE"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="12" sceneMemberID="firstResponder"/>
@@ -138,12 +138,12 @@
<class className="InstaBeanViewController" superclassName="UIViewController">
<source key="sourceIdentifier" type="project" relativePath="./Classes/InstaBeanViewController.h"/>
<relationships>
- <relationship kind="action" name="setTimerInterval:"/>
+ <relationship kind="action" name="setExtractionTimer:"/>
<relationship kind="action" name="startExtraction:"/>
<relationship kind="outlet" name="extractionButton" candidateClass="UIButton"/>
- <relationship kind="outlet" name="extractionSetupStepper" candidateClass="UIStepper"/>
- <relationship kind="outlet" name="extractionTimerLabel" candidateClass="UILabel"/>
- <relationship kind="outlet" name="extractionTimerSettingLabel" candidateClass="UILabel"/>
+ <relationship kind="outlet" name="extractionProgressLabel" candidateClass="UILabel"/>
+ <relationship kind="outlet" name="extractionSettingLabel" candidateClass="UILabel"/>
+ <relationship kind="outlet" name="extractionSettingStepper" candidateClass="UIStepper"/>
</relationships>
</class>
<class className="NSLayoutConstraint" superclassName="NSObject">