aboutsummaryrefslogtreecommitdiffstats
path: root/iBean.old/iBean/InstaBeanViewController.m
diff options
context:
space:
mode:
authorEddie Ehlin <eddiex@eddiex.se>2012-12-31 00:08:03 +0100
committerEddie Ehlin <eddiex@eddiex.se>2012-12-31 00:08:03 +0100
commita688c1566fe6a4eccc4ad5c5aaf5fadd79efef18 (patch)
treea0671a5773dec119ca5b13c97e6354320111e8e1 /iBean.old/iBean/InstaBeanViewController.m
parentf732bdde2a17539ae8a955eb948365c9d392c43a (diff)
downloadiBean-a688c1566fe6a4eccc4ad5c5aaf5fadd79efef18.tar.gz
iBean-a688c1566fe6a4eccc4ad5c5aaf5fadd79efef18.zip
Moved XCode project iBean to iBean.old
Diffstat (limited to 'iBean.old/iBean/InstaBeanViewController.m')
-rw-r--r--iBean.old/iBean/InstaBeanViewController.m108
1 files changed, 108 insertions, 0 deletions
diff --git a/iBean.old/iBean/InstaBeanViewController.m b/iBean.old/iBean/InstaBeanViewController.m
new file mode 100644
index 0000000..ab77ed7
--- /dev/null
+++ b/iBean.old/iBean/InstaBeanViewController.m
@@ -0,0 +1,108 @@
+//
+// InstaBeanViewController.m
+// iBean
+//
+// Created by Eddie Ehlin on 2012-12-28.
+// Copyright (c) 2012 Eddie Ehlin. All rights reserved.
+//
+
+#import "InstaBeanViewController.h"
+
+@interface InstaBeanViewController ()
+
+@end
+
+@implementation InstaBeanViewController
+
+- (void)viewDidLoad
+{
+ [super viewDidLoad];
+
+ //Add any view related setup?
+}
+
+- (void)viewWillAppear:(BOOL)animated
+{
+ NSLog(@"InstaBean viewWillAppear");
+ //[super viewWillAppear:<#animated#>];
+ [self initInstaBean];
+}
+
+- (void)didReceiveMemoryWarning
+{
+ [super didReceiveMemoryWarning];
+ // Dispose of any resources that can be recreated.
+}
+
+
+//-------------------------------------------------------------------
+// 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)
+ {
+ self.extractionInProgress = YES;
+ self.extractionProgress = 0.0f;
+ self.extractionProgressLabel.text = @"0.0";
+ [self.extractionButton setTitle:@"Stop extraction" forState:UIControlStateNormal];
+ [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.
+
+ }
+ else
+ {
+ //TODO: Set green background image.
+ [self haltExtractionTimer];
+ }
+}
+@end