Repository navigation
Expand file tree
/
Copy pathHappyPreferencesViewController.m
More file actions
executable file
·186 lines (146 loc) · 4.92 KB
/
Copy pathHappyPreferencesViewController.m
File metadata and controls
executable file
·186 lines (146 loc) · 4.92 KB
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
//
// HappyPreferencesViewController.m
// iBeHappy
//
// Created by Jaroslaw Szymczyk on 12/21/12.
// Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//
#import "HappyPreferencesViewController.h"
@interface HappyPreferencesViewController ()
@end
@implementation HappyPreferencesViewController
@synthesize profile;
@synthesize bloodView;
//@synthesize selectVC;
@synthesize OpennessSlider;
@synthesize LanguageSlider;
@synthesize homeVC;
@synthesize remVC;
@synthesize scoreVC;
@synthesize challengeVC;
@synthesize incomeVC;
- (IBAction)Home:(id)sender
{
if (nil == homeVC) {
homeVC = [[HappyHomeViewController alloc] initWithNibName:@"HappyHomeViewController"
bundle:nil];
}
// viewDidLoad will be called
//[self presentModalViewController:homeVC animated:YES];
self.homeVC = nil;
}
- (IBAction)Score:(id)sender
{
if (nil == scoreVC) {
scoreVC = [[HappyScoreViewController alloc] initWithNibName:@"HappyScoreViewController"
bundle:nil];
}
// viewDidLoad will be called
//[self presentModalViewController:scoreVC animated:YES];
self.scoreVC = nil;
}
- (IBAction)Challenge:(id)sender
{
if (nil == challengeVC) {
challengeVC = [[HappyChallengeViewController alloc] initWithNibName:@"HappyChallengeViewController"
bundle:nil];
}
// viewDidLoad will be called
//[self presentModalViewController:challengeVC animated:YES];
self.challengeVC = nil;
}
- (IBAction)Reminders:(id)sender
{
if (nil == remVC) {
remVC = [[HappyRemindersViewController alloc] initWithNibName:@"HappyRemindersViewController"
bundle:nil];
}
// viewDidLoad will be called
//[self presentModalViewController:remVC animated:YES];
self.remVC = nil;
}
#pragma mark -
#pragma mark -prepare for segue
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([segue.identifier isEqualToString:@"ToBlood"])
{
bloodView = [segue destinationViewController];
bloodView.profile = self.profile;
bloodView.happyOptions = self.happyOptions;
}
else
{
incomeVC.profile = self.profile;
incomeVC.happyOptions = self.happyOptions;
[self.navigationController popViewControllerAnimated:YES];
}
}
- (IBAction)selectType:(id)sender
{
if (sender == OpennessSlider) {
profile.personality = (NSInteger)(roundf(OpennessSlider.value * 10));
}
else if (sender == LanguageSlider) {
profile.language = (NSInteger)(roundf(LanguageSlider.value * 10));
}
}
- (IBAction)doneAction:(id)sender {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Profile Complete?"
message:@"Save profile and proceed to your first challenge?"
delegate:self
cancelButtonTitle:@"Cancel"
otherButtonTitles: @"Continue",nil];
[alert show];
}
-(void)alertView:(UIAlertView*)alert didDismissWithButtonIndex:(NSInteger)buttonIndex;
{
NSLog(@">>> Entering %s <<<", __PRETTY_FUNCTION__);
NSString *title = [alert buttonTitleAtIndex:buttonIndex];
if ([title isEqualToString:@"Continue"])
{
[Utility archiveProfile:profile];
if (nil == challengeVC) {
challengeVC = [[HappyChallengeViewController alloc] initWithNibName:@"HappyChallengeViewController"
bundle:nil];
}
challengeVC.profile = profile;
// viewDidLoad will be called
//[self presentModalViewController:challengeVC animated:YES];
self.challengeVC = nil;
}
}
- (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.
OpennessSlider.value = (float)profile.personality/10.0f;
LanguageSlider.value = (float)profile.language/10.0f;
}
- (void)viewDidUnload
{
[self setOpennessSlider:nil];
[self setLanguageSlider:nil];
[self setDoneButton:nil];
[super viewDidUnload];
// Release any retained subviews of the main view.
}
-(void) viewWillDisappear:(BOOL)animated {
// profile.personality = OpennessSlider.value;
// profile.language = LanguageSlider.value;
// [Utility archiveProfile:profile]
[super viewWillDisappear:animated];
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
@end