forked from angelaz/Ubiquity
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTutorialViewController.m
353 lines (268 loc) · 10.1 KB
/
TutorialViewController.m
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
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
//
// TutorialViewController.m
// Ubiquity
//
// Created by Catherine Morrison on 8/19/13.
// Copyright (c) 2013 Team Ubi. All rights reserved.
//
#import "TutorialViewController.h"
#import "ArrowView.h"
#import "AppDelegate.h"
#import "NewMessageView.h"
@interface TutorialViewController ()
{
CGFloat SCREEN_WIDTH;
CGFloat SCREEN_HEIGHT;
CGFloat BUTTON_WIDTH;
CGFloat BUTTON_HEIGHT;
int bubbleCount;
ArrowView *welcomeBubble;
ArrowView *introBubble;
ArrowView *selfBubble;
ArrowView *friendsBubble;
ArrowView *publicBubble;
ArrowView *listBubble;
ArrowView *searchBarBubble;
ArrowView *newMessageBubble;
ArrowView *thankYouBubble;
NewMessageView *nmv;
UIView *cover;
}
@end
@implementation TutorialViewController
- (id)init
{
self = [super init];
if (self) {
}
return self;
}
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
NSLog(@"tutorial view initialized");
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
NSLog(@"tutorial view loaded");
// Do any additional setup after loading the view.
_bubbleTapRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(nextBubble:)];
[self.view addGestureRecognizer:_bubbleTapRecognizer];
bubbleCount = 0;
// self.delegate = self;
SCREEN_WIDTH = self.view.frame.size.width;
SCREEN_HEIGHT = self.view.frame.size.height;
BUTTON_WIDTH = 240;
BUTTON_HEIGHT = 38;
self.view.opaque = NO;
self.view.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.5f];
[self firstBubble];
}
- (void) firstBubble {
welcomeBubble = [[ArrowView alloc] initWithFrame:CGRectMake(SCREEN_WIDTH/2 - BUTTON_WIDTH/2, SCREEN_HEIGHT-300, BUTTON_WIDTH, BUTTON_HEIGHT*2.3)];
[welcomeBubble setPointY:0.0];
[welcomeBubble setPointHeight:0.0];
[welcomeBubble setPointWidth:0.0];
welcomeBubble.label.text = @"Welcome to TerraFlare! Tap to get started.";
[self.view addSubview:welcomeBubble];
}
- (void) loadIntroBubble {
welcomeBubble.label.text = @"TerraFlares are notes you can leave your friends or yourself at chosen locations.";
}
- (void) loadLongTapInstructions {
welcomeBubble.label.text = @"To choose a location, hold your finger on the map until the location bead shifts.";
}
-(void) nextBubble: (id) sender
{
bubbleCount++;
switch (bubbleCount)
{
case 1:
[self loadIntroBubble];
break;
case 2:
[self loadLongTapInstructions];
break;
case 3:
[self loadSearchBarBubble];
break;
case 4:
[self loadNewMessageBubble];
break;
case 5:
[self openNewMessageView];
break;
case 6:
[self loadMessageViewTut1];
break;
case 7:
[self loadMessageViewTut2];
break;
case 8:
[self loadMessageViewTut3];
break;
case 9:
[self loadMessageViewTut4];
break;
case 10:
[self loadBarBubble];
break;
case 11:
[self loadSelfBubble];
break;
case 12:
[self loadFriendsBubble];
break;
case 13:
[self loadPublicBubble];
break;
case 14:
[self loadListBubble];
break;
case 15:
[self loadThankYouBubble];
break;
case 16:
[self didFinishTutorial];
break;
}
}
- (void)loadSearchBarBubble {
welcomeBubble.frame = CGRectMake(SCREEN_WIDTH/8, SCREEN_HEIGHT/7, BUTTON_WIDTH, BUTTON_HEIGHT*2.3);
[welcomeBubble setPointY:10.0];
[welcomeBubble setPointHeight:20.0];
[welcomeBubble setPointWidth:10.0];
[welcomeBubble setNeedsDisplay];
welcomeBubble.label.text = @"Or, you can look for an address using the search bar.";
welcomeBubble.label.numberOfLines = 3;
}
- (void)loadNewMessageBubble {
welcomeBubble.frame = CGRectMake(SCREEN_WIDTH*29/30 - BUTTON_WIDTH, SCREEN_HEIGHT/11, BUTTON_WIDTH, BUTTON_HEIGHT*2.3);
[welcomeBubble setPointY:210.0];
[welcomeBubble setPointHeight:20.0];
[welcomeBubble setPointWidth:10.0];
[welcomeBubble setNeedsDisplay];
welcomeBubble.label.text = @"When you've picked the location you want, click here to set off a Terraflare!";
welcomeBubble.label.numberOfLines = 3;
}
- (void) openNewMessageView {
nmv = [[NewMessageView alloc] initWithFrame: self.view.bounds];
[self.view addSubview:nmv];
[welcomeBubble.layer setZPosition:1.0];
cover = [[UIView alloc] initWithFrame: self.view.bounds];
cover.backgroundColor = [[UIColor alloc] initWithWhite: 0.0 alpha: 0.5];
[self.view addSubview:cover];
welcomeBubble.frame = CGRectMake(SCREEN_WIDTH/2 - BUTTON_WIDTH/2, SCREEN_HEIGHT/2 - BUTTON_HEIGHT*2.3, BUTTON_WIDTH, BUTTON_HEIGHT*2.3);
[welcomeBubble setPointY:0.0];
[welcomeBubble setPointHeight:0.0];
[welcomeBubble setPointWidth:0.0];
[welcomeBubble setNeedsDisplay];
welcomeBubble.label.text = @"This is what you'll see when you want to leave a new TerraFlare.";
welcomeBubble.label.numberOfLines = 3;
}
- (void) loadMessageViewTut1 {
[welcomeBubble setPointY:60.0];
[welcomeBubble setPointHeight:20.0];
[welcomeBubble setPointWidth:10.0];
[welcomeBubble setNeedsDisplay];
welcomeBubble.label.text = @"Start typing here to leave a note!";
}
- (void) loadMessageViewTut2 {
welcomeBubble.frame = CGRectMake(SCREEN_WIDTH/2 - BUTTON_WIDTH/2, SCREEN_HEIGHT*2/3+10, BUTTON_WIDTH, BUTTON_HEIGHT*2);
[welcomeBubble setPointY:0.0];
[welcomeBubble setPointHeight:0.0];
[welcomeBubble setPointWidth:0.0];
[welcomeBubble setNeedsDisplay];
welcomeBubble.label.text = @"You can also attach a song or a picture to your TerraFlare";
welcomeBubble.label.numberOfLines = 2;
}
- (void) loadMessageViewTut3 {
welcomeBubble.frame = CGRectMake(SCREEN_WIDTH/2 - BUTTON_WIDTH/2, SCREEN_HEIGHT/5, BUTTON_WIDTH, BUTTON_HEIGHT*2.3);
[welcomeBubble setPointY:60.0];
[welcomeBubble setPointHeight:20.0];
[welcomeBubble setPointWidth:10.0];
[welcomeBubble setNeedsDisplay];
welcomeBubble.label.text = @"And finally, you can change who you want to see your TerraFlare!";
welcomeBubble.label.numberOfLines = 3;
}
- (void) loadMessageViewTut4 {
[nmv removeFromSuperview];
[cover removeFromSuperview];
welcomeBubble.frame = CGRectMake(SCREEN_WIDTH/2 - BUTTON_WIDTH/2, SCREEN_HEIGHT/2 - BUTTON_HEIGHT*2.3, BUTTON_WIDTH, BUTTON_HEIGHT*2.3);
[welcomeBubble setPointY:0.0];
[welcomeBubble setPointHeight:0.0];
[welcomeBubble setPointWidth:0.0];
welcomeBubble.label.text = @"Set lots of TerraFlares for friends to find! When you're in an area with TerraFlares around, they'll appear on the map!";
welcomeBubble.label.numberOfLines = 6;
[welcomeBubble setNeedsDisplay];
}
- (void)loadBarBubble {
welcomeBubble.frame = CGRectMake(SCREEN_WIDTH/4, SCREEN_HEIGHT/11, BUTTON_WIDTH, BUTTON_HEIGHT*2.3);
[welcomeBubble setPointY:20.0];
[welcomeBubble setPointHeight:20.0];
[welcomeBubble setPointWidth:10.0];
[welcomeBubble setNeedsDisplay];
welcomeBubble.label.text = @"This bar controls what kinds of TerraFlares you want to see on the map.";
welcomeBubble.label.numberOfLines = 5;
}
- (void)loadSelfBubble {
welcomeBubble.frame = CGRectMake(SCREEN_WIDTH/4, SCREEN_HEIGHT/11, BUTTON_WIDTH, BUTTON_HEIGHT*2.3);
[welcomeBubble setPointY:20.0];
[welcomeBubble setPointHeight:20.0];
[welcomeBubble setPointWidth:10.0];
[welcomeBubble setNeedsDisplay];
welcomeBubble.label.text = @"This option shows everything you left yourself.";
welcomeBubble.label.numberOfLines = 5;
}
- (void)loadFriendsBubble {
welcomeBubble.frame = CGRectMake(SCREEN_WIDTH/4, SCREEN_HEIGHT/11, BUTTON_WIDTH, BUTTON_HEIGHT*2);
[welcomeBubble setPointY:70.0];
[welcomeBubble setPointHeight:20.0];
[welcomeBubble setPointWidth:10.0];
[welcomeBubble setNeedsDisplay];
welcomeBubble.label.text = @"To see TerraFlares your friends left you, click here";
welcomeBubble.label.numberOfLines = 2;
}
- (void)loadPublicBubble {
welcomeBubble.frame = CGRectMake(SCREEN_WIDTH/4, SCREEN_HEIGHT/11, BUTTON_WIDTH, BUTTON_HEIGHT*2.3);
[welcomeBubble setPointY:120.0];
[welcomeBubble setPointHeight:20.0];
[welcomeBubble setPointWidth:10.0];
[welcomeBubble setNeedsDisplay];
welcomeBubble.label.text = @"Or if you're a social butterfly, you can choose to see public notes, from everyone around you!";
welcomeBubble.label.numberOfLines = 3;
}
- (void)loadListBubble {
welcomeBubble.frame= CGRectMake(SCREEN_WIDTH/20, SCREEN_HEIGHT/11, BUTTON_WIDTH, BUTTON_HEIGHT*2);
[welcomeBubble setPointY:20.0];
[welcomeBubble setPointHeight:20.0];
[welcomeBubble setPointWidth:10.0];
[welcomeBubble setNeedsDisplay];
welcomeBubble.label.text = @"Or, you can view all the TerraFlares in the area at once here";
welcomeBubble.label.numberOfLines = 3;
}
- (void)loadThankYouBubble {
welcomeBubble.frame = CGRectMake(SCREEN_WIDTH/2 - BUTTON_WIDTH/2, SCREEN_HEIGHT-300, BUTTON_WIDTH, BUTTON_HEIGHT*2.3);
[welcomeBubble setPointY:0.0];
[welcomeBubble setPointHeight:0.0];
[welcomeBubble setPointWidth:0.0];
[welcomeBubble setNeedsDisplay];
welcomeBubble.label.text = @"Thanks for using TerraFlare! Tap to end the tutorial.";
welcomeBubble.label.numberOfLines = 5;
}
- (void) didFinishTutorial {
AppDelegate *delegate = [[UIApplication sharedApplication] delegate];
delegate.firstLaunch = NO;
[self dismissViewControllerAnimated:YES completion:nil];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end