Skip to content

Commit 84f859b

Browse files
committed
Finished writing comments on iOS
1 parent 669ca7a commit 84f859b

File tree

11 files changed

+210
-188
lines changed

11 files changed

+210
-188
lines changed

iHW-iOS/iHW/iHW.xcodeproj/project.xcworkspace/xcshareddata/iHW.xccheckout

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,36 +5,36 @@
55
<key>IDESourceControlProjectFavoriteDictionaryKey</key>
66
<false/>
77
<key>IDESourceControlProjectIdentifier</key>
8-
<string>C9333D26-C4DF-4098-A141-0A6A85A667C3</string>
8+
<string>67CE4F47-5D7D-4996-96A5-204162BC8583</string>
99
<key>IDESourceControlProjectName</key>
1010
<string>iHW</string>
1111
<key>IDESourceControlProjectOriginsDictionary</key>
1212
<dict>
13-
<key>8FC1D82D-C544-4141-AB44-490AF58A7947</key>
14-
<string>https://github.com/jburns20/hw-schedule.git</string>
13+
<key>40308155-690F-4ED3-82DD-718708C4D6EB</key>
14+
<string>https://github.com/HWComputerScience/iHW-iOS.git</string>
1515
</dict>
1616
<key>IDESourceControlProjectPath</key>
1717
<string>iHW-iOS/iHW/iHW.xcodeproj/project.xcworkspace</string>
1818
<key>IDESourceControlProjectRelativeInstallPathDictionary</key>
1919
<dict>
20-
<key>8FC1D82D-C544-4141-AB44-490AF58A7947</key>
20+
<key>40308155-690F-4ED3-82DD-718708C4D6EB</key>
2121
<string>../../../..</string>
2222
</dict>
2323
<key>IDESourceControlProjectURL</key>
24-
<string>https://github.com/jburns20/hw-schedule.git</string>
24+
<string>https://github.com/HWComputerScience/iHW-iOS.git</string>
2525
<key>IDESourceControlProjectVersion</key>
2626
<integer>110</integer>
2727
<key>IDESourceControlProjectWCCIdentifier</key>
28-
<string>8FC1D82D-C544-4141-AB44-490AF58A7947</string>
28+
<string>40308155-690F-4ED3-82DD-718708C4D6EB</string>
2929
<key>IDESourceControlProjectWCConfigurations</key>
3030
<array>
3131
<dict>
3232
<key>IDESourceControlRepositoryExtensionIdentifierKey</key>
3333
<string>public.vcs.git</string>
3434
<key>IDESourceControlWCCIdentifierKey</key>
35-
<string>8FC1D82D-C544-4141-AB44-490AF58A7947</string>
35+
<string>40308155-690F-4ED3-82DD-718708C4D6EB</string>
3636
<key>IDESourceControlWCCName</key>
37-
<string>hw-schedule</string>
37+
<string>iHW-iOS</string>
3838
</dict>
3939
</array>
4040
</dict>

iHW-iOS/iHW/iHW/IHWChangeYearViewController.m

Lines changed: 25 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,6 @@
1111
#import "IHWAppDelegate.h"
1212
#import "IHWScheduleViewController.h"
1313

14-
@interface IHWChangeYearViewController ()
15-
16-
@end
17-
1814
@implementation IHWChangeYearViewController
1915

2016
- (id)initWithStyle:(UITableViewStyle)style
@@ -25,7 +21,6 @@ - (id)initWithStyle:(UITableViewStyle)style
2521
self.tableView.delegate = self;
2622
self.tableView.dataSource = self;
2723
self.navigationItem.title = @"Change Year";
28-
//self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(done)];
2924
self.selectedCampus = [IHWCurriculum currentCampus];
3025
}
3126
return self;
@@ -50,9 +45,11 @@ - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger
5045
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
5146
{
5247
if (indexPath.section == 0) {
48+
//Create the "change year" cell
5349
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"changeYear"];
5450
if (cell==nil) cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"changeYear"];
5551
if (self.stepper == nil) {
52+
//Create a stepper
5653
self.stepper = [[UIStepper alloc] init];
5754
self.stepper.minimumValue = 1;
5855
self.stepper.maximumValue = INT16_MAX;
@@ -61,42 +58,56 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
6158
self.stepper.tintColor = [UIColor colorWithRed:0.6 green:0 blue:0 alpha:1];
6259
[self.stepper addTarget:self action:@selector(yearChanged) forControlEvents:UIControlEventValueChanged];
6360
}
61+
//Add the stepper to the right side of the cell
6462
cell.accessoryView = self.stepper;
6563
cell.textLabel.text = [self formatYear:[IHWCurriculum currentYear]];
6664
return cell;
6765
} else {
66+
//Create the "change campus" cells
6867
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"changeCampus"];
6968
if (cell==nil) cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"changeCampus"];
7069
cell.tintColor = [UIColor colorWithRed:0.6 green:0 blue:0 alpha:1];
7170
if (indexPath.row == 0) {
7271
cell.textLabel.text = @"Middle School";
73-
if (self.selectedCampus == CAMPUS_MIDDLE) cell.accessoryType = UITableViewCellAccessoryCheckmark;
72+
if (self.selectedCampus == CAMPUS_MIDDLE) {
73+
//Add a checkmark if necessary
74+
cell.accessoryType = UITableViewCellAccessoryCheckmark;
75+
}
7476
} else {
7577
cell.textLabel.text = @"Upper School";
76-
if (self.selectedCampus == CAMPUS_UPPER) cell.accessoryType = UITableViewCellAccessoryCheckmark;
78+
if (self.selectedCampus == CAMPUS_UPPER) {
79+
//Add a checkmark if necessary
80+
cell.accessoryType = UITableViewCellAccessoryCheckmark;
81+
}
7782
}
7883
return cell;
7984
}
8085
}
8186

8287
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
88+
//Adjust the spacing before and between cells
8389
if (section == 0) return 44;
8490
else return 24;
8591
}
8692

8793
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
88-
UITableViewHeaderFooterView *view = [[UITableViewHeaderFooterView alloc] initWithReuseIdentifier:@"changeScheduleHeader"];
94+
UITableViewHeaderFooterView *view = [tableView dequeueReusableHeaderFooterViewWithIdentifier:@"changeScheduleHeader"];
95+
if (view == nil) {
96+
view = [[UITableViewHeaderFooterView alloc] initWithReuseIdentifier:@"changeScheduleHeader"];
97+
}
8998
if (section == 0) view.textLabel.text = @"Year";
9099
else view.textLabel.text = @"Campus";
91100
return view;
92101
}
102+
93103
- (NSIndexPath *)tableView:(UITableView *)tableView willSelectRowAtIndexPath:(NSIndexPath *)indexPath {
94104
if (indexPath.section == 0) return nil;
95105
else return indexPath;
96106
}
97107

98108
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
99109
if (indexPath.section == 1) {
110+
//Handle changing campus
100111
if (indexPath.row == 0) self.selectedCampus = CAMPUS_MIDDLE;
101112
else self.selectedCampus = CAMPUS_UPPER;
102113
[self campusChanged];
@@ -107,10 +118,12 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath
107118

108119
- (void)yearChanged {
109120
int year = self.stepper.value;
121+
//Update year cell text
110122
[self.tableView cellForRowAtIndexPath:[NSIndexPath indexPathForItem:0 inSection:0]].textLabel.text = [self formatYear:year];
111123
}
112124

113125
- (void)campusChanged {
126+
//Update checkmarks
114127
if (self.selectedCampus == CAMPUS_MIDDLE) {
115128
[self.tableView cellForRowAtIndexPath:[NSIndexPath indexPathForItem:0 inSection:1]].accessoryType = UITableViewCellAccessoryCheckmark;
116129
[self.tableView cellForRowAtIndexPath:[NSIndexPath indexPathForItem:1 inSection:1]].accessoryType = UITableViewCellAccessoryNone;
@@ -124,65 +137,17 @@ - (NSString *)formatYear:(int)year {
124137
return [NSString stringWithFormat:@"%d-%02d", year, (year+1)%100];
125138
}
126139

127-
-(void) viewWillDisappear:(BOOL)animated {
140+
- (void)viewWillDisappear:(BOOL)animated {
128141
if ([self.navigationController.viewControllers indexOfObject:self]==NSNotFound) {
142+
//Save updated campus and year
129143
int year = self.stepper.value;
130144
[IHWCurriculum setCurrentYear:year];
131145
[IHWCurriculum setCurrentCampus:self.selectedCampus];
146+
//Create a new schedule view controller
147+
//(this is not shown immediately -- instead, it appears behind the preferences view controller when the preferences view controller is dismissed)
132148
[((IHWAppDelegate *)[[UIApplication sharedApplication] delegate]).navController setViewControllers:@[[[IHWScheduleViewController alloc] initWithNibName:@"IHWScheduleViewController" bundle:nil]] animated:NO];
133-
//[self.navigationController.presentingViewController dismissViewControllerAnimated:YES completion:nil];
134149
}
135150
[super viewWillDisappear:animated];
136151
}
137152

138-
139-
/*
140-
// Override to support conditional editing of the table view.
141-
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
142-
{
143-
// Return NO if you do not want the specified item to be editable.
144-
return YES;
145-
}
146-
*/
147-
148-
/*
149-
// Override to support editing the table view.
150-
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
151-
{
152-
if (editingStyle == UITableViewCellEditingStyleDelete) {
153-
// Delete the row from the data source
154-
[tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];
155-
} else if (editingStyle == UITableViewCellEditingStyleInsert) {
156-
// Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
157-
}
158-
}
159-
*/
160-
161-
/*
162-
// Override to support rearranging the table view.
163-
- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath
164-
{
165-
}
166-
*/
167-
168-
/*
169-
// Override to support conditional rearranging of the table view.
170-
- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath
171-
{
172-
// Return NO if you do not want the item to be re-orderable.
173-
return YES;
174-
}
175-
*/
176-
177-
/*
178-
#pragma mark - Navigation
179-
180-
// In a storyboard-based application, you will often want to do a little preparation before navigation
181-
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
182-
{
183-
// Get the new view controller using [segue destinationViewController].
184-
// Pass the selected object to the new view controller.
185-
}
186-
*/
187-
188153
@end

iHW-iOS/iHW/iHW/IHWDayViewController.m

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,10 @@ - (void)viewDidLoad
8181
self.periodsTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
8282
}
8383

84+
//Preload all of the tableview cells
8485
[self loadTableViewCells];
8586

86-
//Set up holiday title
87+
//Set up holiday title, keeping track of the header height
8788
if ([self.day isKindOfClass:[IHWHoliday class]] && ![((IHWHoliday*)self.day).name isEqualToString:@""]) {
8889
UIFont *font = [UIFont systemFontOfSize:30];
8990
CGSize textSize = [((IHWHoliday*)self.day).name sizeWithFont:font constrainedToSize:CGSizeMake(self.periodsTableView.bounds.size.width-4, self.periodsTableView.bounds.size.height)];
@@ -104,7 +105,7 @@ - (void)viewDidLoad
104105
self.headerHeight += textSize.height+4;
105106
}
106107

107-
//Set up day caption
108+
//Set up day caption, keeping track of the header height
108109
if (self.day.caption != nil && ![self.day.caption isEqualToString:@""]) {
109110
UIFont *font = [UIFont systemFontOfSize:17];
110111
CGSize textSize = [self.day.caption sizeWithFont:font constrainedToSize:CGSizeMake(self.periodsTableView.bounds.size.width-4, self.periodsTableView.bounds.size.height)];
@@ -164,6 +165,7 @@ - (void)viewDidAppear:(BOOL)animated {
164165
}
165166

166167
- (void)keyboardWillShow:(NSNotification *)notification {
168+
//Do some fancy math to set the contentinsets of the tableview so that the keyboard doesn't overlap anything
167169
NSDictionary *userInfo = [notification userInfo];
168170
NSValue *aValue = [userInfo objectForKey:UIKeyboardFrameEndUserInfoKey];
169171
CGRect keyboardRect = [self.view convertRect:[aValue CGRectValue] fromView:nil];
@@ -177,26 +179,26 @@ - (void)keyboardWillShow:(NSNotification *)notification {
177179
}
178180

179181
- (void)keyboardWillHide:(NSNotification *)notification {
182+
//Reset the contentinsets back to what they were originally
180183
[UIView animateWithDuration:0.25 animations:^{
181184
self.periodsTableView.contentInset = self.originalInsets;
182185
self.periodsTableView.scrollIndicatorInsets = self.originalInsets;
183186
}];
184187
}
185188

186189
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
187-
/*if ([self.day isKindOfClass:[IHWHoliday class]] && ![((IHWHoliday*)self.day).name isEqualToString:@""]) return 64;
188-
return 0;*/
189190
return self.headerHeight;
190191
}
191192

192193
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
194+
//Build the header view
193195
UIView *headerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.periodsTableView.bounds.size.width, self.headerHeight)];
194196
if (self.dayNameLabel != nil) {
195197
[headerView addSubview:self.dayNameLabel];
196198
}
197199
if (self.dayCaptionLabel != nil) {
198200
[headerView addSubview:self.dayCaptionLabel];
199-
201+
//If the caption has a link, add a tap gesture recognizer to respond to it
200202
if (self.day.captionLink != nil && ![self.day.captionLink isEqualToString:@""]) {
201203
[headerView addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(captionTapped)]];
202204
CALayer *imageLayer = [CALayer layer];
@@ -210,6 +212,7 @@ - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger
210212
}
211213

212214
- (void)captionTapped {
215+
//Open the caption link in the browser
213216
if (self.day.captionLink != nil && ![self.day.captionLink isEqualToString:@""]) {
214217
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:self.day.captionLink]];
215218
}
@@ -220,12 +223,12 @@ - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger
220223
}
221224

222225
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
223-
if (indexPath.row >= self.cells.count) return 72;
224-
int result = [((IHWPeriodCellView *)[((UITableViewCell *)[self.cells objectAtIndex:indexPath.row]).contentView.subviews objectAtIndex:0]) neededHeight];
225-
if (result != 0) {
226-
//NSLog(@"Returned %d", result);
227-
return result;
226+
if (indexPath.row >= self.cells.count) {
227+
return 72; //For blank lines that show on overflow
228228
}
229+
//Ask the cell itself what height it needs
230+
int result = [((IHWPeriodCellView *)[((UITableViewCell *)[self.cells objectAtIndex:indexPath.row]).contentView.subviews objectAtIndex:0]) neededHeight];
231+
if (result != 0) return result;
229232
else return 72;
230233
}
231234

@@ -245,15 +248,16 @@ - (UITableViewCell *)createNewCellForIndex:(int)index {
245248

246249
cell.frame = CGRectMake(0, 0, self.view.bounds.size.width, [view neededHeight]);
247250
view.dayViewController = self;
251+
//Autoscroll to next period
248252
if ([view createCountdownViewIfNeeded]) self.scrollToIndex = index;
249253
[cell.contentView addSubview:view];
250254
return cell;
251255
}
252256

253257
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
254-
//first try to reuse a cell
258+
//first try to reuse a cell (each one has a unique identifier)
255259
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:[NSString stringWithFormat:@"period%@.%d", self.date.description, (int)indexPath.row]];
256-
//then try to find the cell is in the array
260+
//then try to find the cell in the array
257261
if (cell==nil && indexPath.row < self.cells.count && [self.cells objectAtIndex:indexPath.row] != [NSNull null]) {
258262
cell = [self.cells objectAtIndex:indexPath.row];
259263
}
@@ -265,7 +269,7 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
265269
return cell;
266270
}
267271

268-
//disable selecting cells (disable turning blue)
272+
//disable selecting cells (disable turning blue on tap)
269273
- (NSIndexPath *)tableView:(UITableView *)tableView willSelectRowAtIndexPath:(NSIndexPath *)indexPath {
270274
return nil;
271275
}

iHW-iOS/iHW/iHW/IHWLoadingView.m

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,19 @@ - (id)initWithText:(NSString *)message
1515
{
1616
self = [super initWithFrame:[UIScreen mainScreen].bounds];
1717
if (self) {
18-
self.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.25];
18+
//Add this view directly to the screen, ignoring any on-screen viewcontrollers
1919
[[[[UIApplication sharedApplication] delegate] window] addSubview:self];
20+
21+
//Necessary configuration stuff
22+
self.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.25];
2023
self.alpha = 0;
2124
self.popupView = [[UIView alloc] initWithFrame:CGRectMake(self.bounds.size.width/2-180/2, self.bounds.size.height/2-100/2, 180, 100)];
2225
[self addSubview:self.popupView];
2326
self.popupView.layer.cornerRadius = 10;
2427
self.popupView.layer.masksToBounds = YES;
2528
self.popupView.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.5];
2629

30+
//Configuration for textlabel
2731
self.textLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 10, 160, 30)];
2832
self.textLabel.textAlignment = NSTextAlignmentCenter;
2933
self.textLabel.opaque = NO;
@@ -40,6 +44,7 @@ - (id)initWithText:(NSString *)message
4044
[self.popupView addSubview:progressView];
4145
[progressView startAnimating];
4246

47+
//Fade in
4348
[UIView animateWithDuration:0.1 animations:^{
4449
self.alpha = 1;
4550
}];
@@ -48,6 +53,7 @@ - (id)initWithText:(NSString *)message
4853
}
4954

5055
- (void)dismiss {
56+
//Fade out
5157
[UIView animateWithDuration:0.1 animations:^{
5258
self.alpha = 0;
5359
} completion:^(BOOL finished) {

0 commit comments

Comments
 (0)