blob: ab77ed712cc246b2b7f95822609d34d5feeace8b (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
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
|