From a688c1566fe6a4eccc4ad5c5aaf5fadd79efef18 Mon Sep 17 00:00:00 2001 From: Eddie Ehlin Date: Mon, 31 Dec 2012 00:08:03 +0100 Subject: Moved XCode project iBean to iBean.old --- iBean.old/iBean/InstaBeanViewController.m | 108 ++++++++++++++++++++++++++++++ 1 file changed, 108 insertions(+) create mode 100644 iBean.old/iBean/InstaBeanViewController.m (limited to 'iBean.old/iBean/InstaBeanViewController.m') 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 -- cgit v1.2.3