Skip to content

Commit

Permalink
-My Events (events the user has registered for) now appear under My UP
Browse files Browse the repository at this point in the history
  • Loading branch information
MilesCrabbe committed Jun 6, 2014
1 parent 6b55a57 commit d4fec34
Show file tree
Hide file tree
Showing 7 changed files with 117 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -218,15 +218,16 @@
children = (
1BB198C7193FA4530017A1D6 /* UIColor+UPColors.h */,
1BB198C8193FA4530017A1D6 /* UIColor+UPColors.m */,
1BEC1BF8193914BE009DADEF /* UPDataRetrieval.m */,
);
name = Utils;
sourceTree = "<group>";
};
1B0A69081938D474005C821D /* Views */ = {
isa = PBXGroup;
children = (
1B0A690A1938D487005C821D /* Table Cells */,
1B0A69091938D47E005C821D /* Basic Views */,
1B0A690A1938D487005C821D /* Table Cells */,
);
name = Views;
sourceTree = "<group>";
Expand Down Expand Up @@ -470,7 +471,6 @@
1BEC1BFD1939183C009DADEF /* NSObject+ObjectMap.h */,
1BEC1BFE1939183C009DADEF /* NSObject+ObjectMap.m */,
1BEC1BF7193914BE009DADEF /* UPDataRetrieval.h */,
1BEC1BF8193914BE009DADEF /* UPDataRetrieval.m */,
1B38F299193F6FD2005158D1 /* UPWebserviceConstants.h */,
);
name = "Web Calls";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,19 @@
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxX="YES" heightSizable="YES" flexibleMaxY="YES"/>
</imageView>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="First Name:" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="m6W-c1-tHF">
<rect key="frame" x="115.000000532683" y="8" width="185" height="21"/>
<rect key="frame" x="115.00000082594502" y="8" width="185" height="21"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" widthSizable="YES" flexibleMinY="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="15"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Last Name:" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="cDu-45-d4P">
<rect key="frame" x="115.000000532683" y="37" width="185" height="21"/>
<rect key="frame" x="115.00000082594502" y="37" width="185" height="21"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" widthSizable="YES" flexibleMinY="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="15"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="CWID:" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="pOV-nf-aF9">
<rect key="frame" x="115.000000532683" y="66" width="185" height="21"/>
<rect key="frame" x="115.00000082594502" y="66" width="185" height="21"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" widthSizable="YES" flexibleMinY="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="15"/>
<nil key="highlightedColor"/>
Expand All @@ -42,7 +42,7 @@
<nil key="highlightedColor"/>
</label>
<view contentMode="scaleToFill" id="hTe-Yy-YFL">
<rect key="frame" x="10" y="123" width="360" height="1"/>
<rect key="frame" x="0.0" y="123" width="360" height="1"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES" flexibleMaxY="YES"/>
<color key="backgroundColor" white="0.66666666666666663" alpha="1" colorSpace="calibratedWhite"/>
</view>
Expand Down
89 changes: 83 additions & 6 deletions UniversityPrograms/UniversityPrograms/MyUPViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,16 @@
#import "UPDataRetrieval.h"
#import "NSObject+ObjectMap.h"
#import "UIColor+UPColors.h"
#import "UpcomingEventsTableViewCell.h"
#import "SpecificEventViewController.h"
@import QuartzCore;
@interface MyUPViewController ()
@property (weak, nonatomic) IBOutlet UITableView *myUPTableView;
@property NSArray *priorCommentArray;
@property NSArray *unsortedEventArray;
@property NSMutableArray *sortedEventArray;
@property (strong, nonatomic) IBOutlet UITableViewCell *yourEvents;


@property (strong, nonatomic) IBOutlet UITableViewCell *commentTitleCell;
@property UIRefreshControl *refreshControl;
Expand All @@ -38,6 +44,9 @@ - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
self.tabBarItem.image= [UIImage imageNamed:@"Cog.png"];
self.tabBarItem.selectedImage = [UIImage imageNamed:@"Cog_filled.png"];
self.priorCommentArray=[[NSArray alloc] init];
self.unsortedEventArray=[[NSArray alloc] init];
self.sortedEventArray=[[NSMutableArray alloc] init];

return self;
}

Expand All @@ -51,16 +60,45 @@ - (void)viewDidLoad
//self.navigationItem.rightBarButtonItem=[[UIBarButtonItem alloc]initWithTitle:@"Add Comment" style:UIBarButtonItemStyleDone target:self action:@selector(didSelectComment)];

self.refreshControl = [[UIRefreshControl alloc] initWithFrame:CGRectMake(0, -60, self.myUPTableView.frame.size.width, 60)];
[self.refreshControl addTarget:self action:@selector(loadFeedback) forControlEvents:UIControlEventValueChanged];
[self.refreshControl addTarget:self action:@selector(loadData) forControlEvents:UIControlEventValueChanged];
[self.myUPTableView addSubview:self.refreshControl];



// Do any additional setup after loading the view from its nib.
}
-(void)viewDidAppear:(BOOL)animated{
[self loadData];
}
-(void)loadData{
[self loadFeedback];
[self loadEvents];

[self.refreshControl endRefreshing];
}
-(void)loadEvents{
[UPDataRetrieval getEvents:[[NSUserDefaults standardUserDefaults] valueForKey:@"cwid"] completetionHandler:^(NSURLResponse *response, NSData *data, NSError *e) {
self.sortedEventArray=[[NSMutableArray alloc] init];
self.unsortedEventArray=[NSObject arrayOfType:[Event class] FromJSONData:data];
//NSLog(@"%@",[[NSString alloc]initWithData:data encoding:NSUTF8StringEncoding]);
NSArray *sortedArray = [self.unsortedEventArray sortedArrayUsingComparator:^NSComparisonResult(Event *event1, Event *event2) {
return [event1.startDate compare: event2.startDate];
}];
for (int index =0; index<sortedArray.count; ++index) {
Event *e=[sortedArray objectAtIndex:index];
if(e.isRegistered==true){
[self.sortedEventArray addObject:e];
}
}
dispatch_async(dispatch_get_main_queue(), ^{
[self.myUPTableView reloadData];

});

}];

}


- (void)didReceiveMemoryWarning
{
Expand All @@ -85,9 +123,8 @@ -(void)loadFeedback{
[UPDataRetrieval retrieveComments:[[NSUserDefaults standardUserDefaults] valueForKey:@"cwid"] completetionHandler:^(NSURLResponse *response, NSData *data, NSError *e) {
self.priorCommentArray=[NSObject arrayOfType:[Comment class] FromJSONData:data];
dispatch_async(dispatch_get_main_queue(), ^{

[self.myUPTableView reloadData];
[self.refreshControl endRefreshing];

});
}];

Expand All @@ -108,7 +145,7 @@ - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger
{

// Return the number of rows in the section.
return self.priorCommentArray.count+2;
return self.priorCommentArray.count+self.sortedEventArray.count+3;
}


Expand All @@ -126,7 +163,30 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
return cell;
}
else if(indexPath.row==1){
tableView.rowHeight=125;
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"yourEvents"];
if(!cell){
cell=self.yourEvents;
}
cell.backgroundColor=[UIColor whiteColor];
return cell;

}
else if(indexPath.row<self.sortedEventArray.count+2){
UpcomingEventsTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"upcomingCell"];
if(!cell){
cell=[[UpcomingEventsTableViewCell alloc] init];
}
Event *e = [self.sortedEventArray objectAtIndex:indexPath.row-2];
[cell buildWithEvent:e];


return cell;

}


else if(indexPath.row==self.sortedEventArray.count+2){

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"commentTitle"];

if(!cell){
Expand All @@ -140,12 +200,13 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N

PriorFeedbackTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"PriorCell"];

Comment *c=[self.priorCommentArray objectAtIndex:indexPath.row-2];
Comment *c=[self.priorCommentArray objectAtIndex:indexPath.row-self.sortedEventArray.count-3];
if(!cell){
cell = [[PriorFeedbackTableViewCell alloc] init];
}
[cell buildWithComment:c];
cell.backgroundColor=[UIColor whiteColor];

return cell;
}

Expand All @@ -156,12 +217,23 @@ - (CGFloat)tableView:(UITableView *)tableview heightForRowAtIndexPath:(NSIndexPa
CGFloat retVal =0.0f;
if(indexPath.row==0){
retVal=125.0f;

}
else if(indexPath.row==1){
retVal=44.0f;

}
else if(indexPath.row<self.sortedEventArray.count+2){

retVal=180.0f;
}
else if (indexPath.row==self.sortedEventArray.count+2){
retVal=44.0f;

}
else{
retVal=125.0f;

}
return retVal;

Expand All @@ -170,6 +242,11 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath
if(indexPath.row==0){
[self didSelectUser];
}
else if (indexPath.row>1 && indexPath.row<self.sortedEventArray.count+2){
SpecificEventViewController *tappedEvent = [[SpecificEventViewController alloc] initWithEvent:self.sortedEventArray[indexPath.row-2]];
[self.navigationController pushViewController:tappedEvent animated:YES];
[self.myUPTableView reloadData];
}
else{
[self.myUPTableView reloadData];
}
Expand Down
27 changes: 24 additions & 3 deletions UniversityPrograms/UniversityPrograms/MyUPViewController.xib
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<outlet property="commentTitleCell" destination="aAT-6Y-4WM" id="lgw-e1-QIe"/>
<outlet property="myUPTableView" destination="Te0-zl-hhH" id="b9o-5z-GNM"/>
<outlet property="view" destination="i5M-Pr-FkT" id="sfx-zR-JGt"/>
<outlet property="yourEvents" destination="VHT-xw-cZP" id="Hmo-Tc-JKj"/>
</connections>
</placeholder>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
Expand All @@ -32,18 +33,38 @@
<simulatedTabBarMetrics key="simulatedBottomBarMetrics" barStyle="black" translucent="NO"/>
<simulatedScreenMetrics key="simulatedDestinationMetrics"/>
</view>
<tableViewCell contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" reuseIdentifier="commentTitle" rowHeight="44" id="aAT-6Y-4WM">
<tableViewCell userInteractionEnabled="NO" contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" reuseIdentifier="commentTitle" id="aAT-6Y-4WM">
<rect key="frame" x="0.0" y="0.0" width="320" height="44"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="aAT-6Y-4WM" id="WZ6-wU-a5g">
<rect key="frame" x="0.0" y="0.0" width="320" height="43"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Your Comments" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="oBx-En-RaU">
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="My Comments" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="oBx-En-RaU">
<rect key="frame" x="0.0" y="0.0" width="320" height="44"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<color key="backgroundColor" red="0.0" green="0.47843137250000001" blue="1" alpha="1" colorSpace="calibratedRGB"/>
<fontDescription key="fontDescription" type="system" pointSize="20"/>
<color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<nil key="highlightedColor"/>
</label>
</subviews>
</tableViewCellContentView>
<color key="backgroundColor" red="0.0" green="0.47843137250000001" blue="1" alpha="1" colorSpace="calibratedRGB"/>
</tableViewCell>
<tableViewCell userInteractionEnabled="NO" contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" reuseIdentifier="yourEvent" id="VHT-xw-cZP">
<rect key="frame" x="0.0" y="0.0" width="320" height="44"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="VHT-xw-cZP" id="Frp-hs-dFY">
<rect key="frame" x="0.0" y="0.0" width="320" height="43"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="My Events" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="l8C-Wt-s0d">
<rect key="frame" x="0.0" y="0.0" width="320" height="44"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" red="0.0" green="0.47843137250000001" blue="1" alpha="1" colorSpace="calibratedRGB"/>
<fontDescription key="fontDescription" type="system" pointSize="20"/>
<color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<nil key="highlightedColor"/>
</label>
</subviews>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<tableViewCell contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" reuseIdentifier="PriorCell" rowHeight="125" id="KGk-i7-Jjw" customClass="PriorFeedbackTableViewCell">
<tableViewCell userInteractionEnabled="NO" contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" reuseIdentifier="PriorCell" rowHeight="125" id="KGk-i7-Jjw" customClass="PriorFeedbackTableViewCell">
<rect key="frame" x="0.0" y="0.0" width="320" height="120"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="KGk-i7-Jjw" id="H2p-sc-9uM">
Expand Down Expand Up @@ -35,7 +35,7 @@
<nil key="highlightedColor"/>
</label>
<view contentMode="scaleToFill" id="tUr-Ii-bib">
<rect key="frame" x="10" y="118" width="310" height="1"/>
<rect key="frame" x="0.0" y="118" width="320" height="1"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
<color key="backgroundColor" white="0.66666666666666663" alpha="1" colorSpace="calibratedWhite"/>
</view>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
</view>
<view contentMode="scaleToFill" id="Jqq-2f-E1x" userLabel="Body View">
<rect key="frame" x="0.0" y="199.00000494718552" width="320" height="399.99999505281448"/>
<rect key="frame" x="0.0" y="199" width="320" height="400"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES" heightSizable="YES"/>
<subviews>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Titley" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="iDq-hK-aBJ">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<tableViewCell contentMode="scaleToFill" selectionStyle="default" indentationLevel="10" indentationWidth="10" shouldIndentWhileEditing="NO" reuseIdentifier="upcomingCell" rowHeight="70" id="KGk-i7-Jjw" customClass="UpcomingEventsTableViewCell">
<tableViewCell contentMode="scaleToFill" selectionStyle="default" indentationLevel="10" indentationWidth="10" shouldIndentWhileEditing="NO" reuseIdentifier="upcomingCell" rowHeight="180" id="KGk-i7-Jjw" customClass="UpcomingEventsTableViewCell">
<rect key="frame" x="0.0" y="0.0" width="320" height="180"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="KGk-i7-Jjw" id="H2p-sc-9uM">
Expand Down

0 comments on commit d4fec34

Please sign in to comment.