Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

forum ui updates

  • Loading branch information...
commit ec6e0d2aee2a9d45a926fda09bb33cdd7f6683ed 1 parent a738bb2
@satyamag authored
View
34 Classes/Forum.m
@@ -33,14 +33,14 @@ - (void)displayThreadContent:(NSString *)content{
}
-- (void)updateSubThreadTableView:(NSArray *)children {
+- (void)updateSubThreadTableView:(NSArray *)children andPreviousTable:(id)previousTable{
//update the subthreadtable view with this new table
if (children != nil) {
//prepare to push in new main thread table view
ForumSubThreadTable *newForumTable = [[ForumSubThreadTable alloc] init];
-
+ [newForumTable setPreviousTable:(ForumSubThreadTable*)previousTable];
//set the new tableview delegate as the forum class
[newForumTable setDelegate:self];
@@ -54,6 +54,14 @@ - (void)updateSubThreadTableView:(NSArray *)children {
}
+- (void)updateMainThreadTableView:(id)newForumTable {
+
+ ForumMainThreadTable *table = (ForumMainThreadTable*) newForumTable;
+ table.view.frame = CGRectMake(0, 0, self.mainThreadTable.frame.size.width, self.mainThreadTable.frame.size.height);
+ [self.mainThreadTable addSubview:table.view];
+}
+
+
- (void)updateMainThreadTableView:(NSArray *)tableDataSource andIndexPath:(NSIndexPath *)indexPath{
if (tableDataSource != nil) {
@@ -66,11 +74,13 @@ - (void)updateMainThreadTableView:(NSArray *)tableDataSource andIndexPath:(NSInd
newTable.tableDataSource = tableDataSource;
- [self.mainNC pushViewController:newTable animated:YES];
-
+// [self.mainNC pushViewController:newTable animated:YES];
+ newTable.view.frame = CGRectMake(0, 0, self.mainThreadTable.frame.size.width, self.mainThreadTable.frame.size.height);
+
+ [self.mainThreadTable addSubview:newTable.view];
+
[newTable.tableView selectRowAtIndexPath:indexPath animated:YES scrollPosition:UITableViewScrollPositionNone];
- [newTable release];
}
}
@@ -107,24 +117,26 @@ - (void)viewDidLoad {
[mainTable setDelegate:self];
//set up navigation controller for the main thread tableview
- mainNC = [[UINavigationController alloc] init];
+// mainNC = [[UINavigationController alloc] init];
- [mainNC pushViewController:mainTable animated:NO];
- mainNC.navigationBar.barStyle = UIBarStyleBlack;
+// [mainNC pushViewController:mainTable animated:NO];
+// mainNC.navigationBar.tintColor = kNavBarColor;
//set the navigation controller's view frame into the IBOutlet view frame
- mainNC.view.frame = CGRectMake(0, 0, self.mainThreadTable.frame.size.width, self.mainThreadTable.frame.size.height);
- [self.mainThreadTable addSubview:mainNC.view];
+// mainNC.view.frame = CGRectMake(0, 0, self.mainThreadTable.frame.size.width, self.mainThreadTable.frame.size.height);
+
+ mainTable.view.frame = CGRectMake(0, 0, self.mainThreadTable.frame.size.width, self.mainThreadTable.frame.size.height);
+ [self.mainThreadTable addSubview:mainTable.view];
contentDisplay.backgroundColor = [UIColor clearColor];
mainThreadTable.backgroundColor = [UIColor clearColor];
contentDisplay.backgroundColor = [UIColor colorWithPatternImage:bgImage_announcements];
self.view.backgroundColor = [UIColor colorWithPatternImage:bgImage_announcements];
self.subThreadTable.backgroundColor = [UIColor colorWithPatternImage:bgImage_subthread_table];
- self.title = @"Forum";
+// self.title = @"Forum";
NSLog(@"done loading forum!!!");
}
View
1  Classes/Forum.xib
@@ -81,7 +81,6 @@
<string key="NSFrame">{{350, 400}, {474, 349}}</string>
<reference key="NSSuperview" ref="766721923"/>
<reference key="NSWindow"/>
- <reference key="NSNextKeyView"/>
<object class="NSColor" key="IBUIBackgroundColor">
<int key="NSColorSpace">3</int>
<bytes key="NSWhite">MQA</bytes>
View
4 Classes/ForumMainThreadTable.h
@@ -18,7 +18,9 @@
- (void)displayThreadContent:(UIWebView *)content;
//sent new content to the Forum controller to update the content in the textfield
-- (void)updateSubThreadTableView:(NSArray *)children;
+- (void)updateMainThreadTableView:(id)newForumTable;
+
+- (void)updateSubThreadTableView:(NSArray *)children andPreviousTable:(id)previousTable;
//update the subthread table view with this newTable
-(void) clearSubThreadView;
View
210 Classes/ForumMainThreadTable.m
@@ -131,9 +131,10 @@ -(void)postNewThreadWithHeading:(NSString *)headingName title:(NSString *)titleN
- (void)viewDidLoad {
[super viewDidLoad];
-
- self.view.backgroundColor = [UIColor clearColor];
- self.tableView.backgroundColor = [UIColor clearColor];
+
+ UIImage *bgImage_forumMainTable = [UIImage imageNamed:@"modules_workbin_3rd_column.png"];
+ self.view.backgroundColor = [UIColor colorWithPatternImage:bgImage_forumMainTable];
+ self.tableView.backgroundColor = [UIColor colorWithPatternImage:bgImage_forumMainTable];
self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
if (currentLevel == 0) {
@@ -161,17 +162,176 @@ - (void)viewDidLoad {
if (currentLevel > 1) {
//add a "post" button in the navigation view controller
- self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:[self retain] action:@selector(postNewThread)];
-
- // change the back button and add an event handler
- self.navigationItem.leftBarButtonItem =
- [[UIBarButtonItem alloc] initWithTitle:@"Back"
- style:UIBarButtonItemStyleBordered
- target:self
- action:@selector(handleBack:)];
+// self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:[self retain] action:@selector(postNewThread)];
+//
+// // change the back button and add an event handler
+// self.navigationItem.leftBarButtonItem =
+// [[UIBarButtonItem alloc] initWithTitle:@"Back"
+// style:UIBarButtonItemStyleBordered
+// target:self
+// action:@selector(handleBack:)];
}
+
+ UISwipeGestureRecognizer *rightSwipeGesture = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(didSwipeRight:)];
+ rightSwipeGesture.direction = UISwipeGestureRecognizerDirectionRight;
+
+ UISwipeGestureRecognizer *leftSwipeGesture = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(didSwipeLeft:)];
+ leftSwipeGesture.direction = UISwipeGestureRecognizerDirectionLeft;
+
+ [self.tableView addGestureRecognizer:rightSwipeGesture];
+ [self.tableView addGestureRecognizer:leftSwipeGesture];
+}
+
+- (UIActivityIndicatorView *) createSpinner {
+
+ CGSize superviewFrameSize = [[self.view superview] frame].size;
+
+ UIActivityIndicatorView *spinner = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
+ spinner.frame = CGRectMake(superviewFrameSize.width/2, superviewFrameSize.height/2, spinner.frame.size.width, spinner.frame.size.height);
+ [spinner startAnimating];
+ [[self.view superview] addSubview:spinner];
+ self.view.userInteractionEnabled = NO;
+ return spinner;
}
+-(void)didSwipeRight:(UIGestureRecognizer *)gestureRecognizer {
+
+
+ if (currentLevel == 3) {
+ [self.delegate clearSubThreadView];
+ [self.delegate clearContentView];
+ }
+
+ [self.view removeFromSuperview];
+// [self.navigationController popViewControllerAnimated:YES];
+
+}
+
+-(void)didSwipeLeft:(UIGestureRecognizer *)gestureRecognizer {
+
+ CGPoint swipeLocation = [gestureRecognizer locationInView:self.tableView];
+ NSIndexPath *indexPath = [self.tableView indexPathForRowAtPoint:swipeLocation];
+
+
+
+
+
+ //activity spinner
+ UIActivityIndicatorView *spinner;
+ spinner = [self createSpinner];
+
+ NSLog(@"print data source");
+ //NSLog(@"%@",self.tableDataSource);
+ //NSLog(@"%@", indexPath.row);
+ NSLog(@"data at row indexpath %@",[self.tableDataSource objectAtIndex:indexPath.row]);
+ //NSLog(@"now test sub threads");
+ //NSLog(@"%@",[self getSubThreadsForMainThreads:@"2f74c3d3-e112-4dd0-8160-901cfab60558"]);
+
+ NSDictionary *dictionary = [self.tableDataSource objectAtIndex:indexPath.row];
+ NSArray *children; //for the next level tableDataSource
+
+ if (currentLevel == 0 || currentLevel == 1) {
+ //no need to display content, but update the main thread table view
+
+ //get the children of the present item
+ if (currentLevel == 0) {
+ children = [dictionary objectForKey:@"Headings"];
+
+ headingNames = [[NSMutableArray alloc] init];
+ headingIDs = [[NSMutableArray alloc] init];
+
+ //record heading names
+ for(int j=0; j<[children count];j++){
+
+ [headingNames addObject:[[children objectAtIndex:j] objectForKey:@"Title"]];
+ [headingIDs addObject:[[children objectAtIndex:j] objectForKey:@"ID"]];
+ }
+ NSLog(@"Names: %@ and IDs: %@", self.headingNames, self.headingIDs);
+ }
+ else if (currentLevel == 1) {
+ children = [self getMainThreadsForHeading:[dictionary objectForKey:@"ID"]];
+ }
+
+ //push a new table view to main thread table view window
+ if ([children count] != 0) {
+
+
+ //prepare to push in new main thread table view
+ ForumMainThreadTable *newForumTable = [[ForumMainThreadTable alloc] init];
+
+ //set the new tableview delegate as the forum class
+ [newForumTable setDelegate:self.delegate];
+
+ //increment the current level
+ newForumTable.currentLevel = self.currentLevel + 1;
+
+ //set the title
+ newForumTable.currentTitle = [dictionary objectForKey:@"Title"];
+
+ //set the headingNames
+ newForumTable.headingNames = self.headingNames;
+ newForumTable.headingIDs = self.headingIDs;
+ newForumTable.tableDataSource = children;
+
+ //push the new table view on the stack of the navigation controller
+ [[self delegate] updateMainThreadTableView:newForumTable];
+ //[self.navigationController pushViewController:newForumTable animated:YES];
+
+ //update the data source
+
+
+ //[newForumTable release];
+ }
+ else {
+
+ NSLog(@"No headings or main threads!");
+ }
+
+
+ }
+ else {
+
+ if (selectedCell) {
+ selectedCell.titleText.textColor = kWorkbinFontColor;
+ selectedCell.metaText.textColor = kWorkbinFontColor;
+ }
+ selectedCell = (ForumTableCell*)[self.tableView cellForRowAtIndexPath:indexPath];
+ selectedCell.titleText.textColor = kWorkbinFontCompColor;
+ selectedCell.metaText.textColor = kWorkbinFontCompColor;
+
+ //update the content display view
+ UIWebView *content = [[tableDataSource objectAtIndex:indexPath.row] objectForKey:@"PostBody"];
+ [[self delegate] displayThreadContent:content];
+
+ //update the subthread table view
+ if (currentLevel == 2) {
+ children = [self getSubThreadsForMainThreads:[dictionary objectForKey:@"ID"]];
+ }
+ else {
+ children = [dictionary objectForKey:@"Threads"];
+ }
+
+ if ([children count] != 0) {
+
+ //call delegate to update sub thread table
+ [[self delegate] clearSubThreadView];
+ [[self delegate] updateSubThreadTableView:children andPreviousTable:nil];
+
+ }
+ else {
+ NSLog(@"No more sub threads!");
+ [[self delegate] clearSubThreadView];
+ [[self delegate] updateSubThreadTableView:nil andPreviousTable:nil];
+ }
+
+ }
+
+ [spinner removeFromSuperview];
+ [spinner release];
+ self.view.userInteractionEnabled = YES;}
+
+
+
- (void) handleBack:(id)sender
{
// do your custom handler code here
@@ -230,7 +390,7 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
NSDictionary *info = [self.tableDataSource objectAtIndex:indexPath.row];
cell.titleText.text = [info objectForKey:@"Title"];
-
+ cell.selectionStyle = UITableViewCellSelectionStyleNone;
return cell;
}
@@ -276,23 +436,14 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
if ([indexPath row] == 0) {
- return 56.0;
+ return 50.0;
+ // return 56.0;
}
return 50.0;
}
-- (UIActivityIndicatorView *) createSpinner {
-
- CGSize superviewFrameSize = [[self.view superview] frame].size;
-
- UIActivityIndicatorView *spinner = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
- spinner.frame = CGRectMake(superviewFrameSize.width/2, superviewFrameSize.height/2, spinner.frame.size.width, spinner.frame.size.height);
- [spinner startAnimating];
- [[self.view superview] addSubview:spinner];
- self.view.userInteractionEnabled = NO;
- return spinner;
-}
+
@@ -353,19 +504,20 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath
newForumTable.currentLevel = self.currentLevel + 1;
//set the title
- newForumTable.currentTitle = [dictionary objectForKey:@"Title"];
+// newForumTable.currentTitle = [dictionary objectForKey:@"Title"];
//set the headingNames
newForumTable.headingNames = self.headingNames;
newForumTable.headingIDs = self.headingIDs;
//push the new table view on the stack of the navigation controller
- [self.navigationController pushViewController:newForumTable animated:YES];
+ [[self delegate] updateMainThreadTableView:newForumTable];
+// [self.navigationController pushViewController:newForumTable animated:YES];
//update the data source
newForumTable.tableDataSource = children;
- [newForumTable release];
+// [newForumTable release];
}
else {
@@ -400,13 +552,13 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath
//call delegate to update sub thread table
[[self delegate] clearSubThreadView];
- [[self delegate] updateSubThreadTableView:children];
+ [[self delegate] updateSubThreadTableView:children andPreviousTable:nil];
}
else {
NSLog(@"No more sub threads!");
[[self delegate] clearSubThreadView];
- [[self delegate] updateSubThreadTableView:nil];
+ [[self delegate] updateSubThreadTableView:nil andPreviousTable:nil];
}
}
View
5 Classes/ForumSubThreadTable.h
@@ -21,7 +21,7 @@
- (void)displayThreadContent:(UIWebView *)content;
//sent new content to the Forum controller to update the content in the textfield
-- (void)updateSubThreadTableView:(NSArray *)children;
+- (void)updateSubThreadTableView:(NSArray *)children andPreviousTable:(id)previousTable;
//update the subthread table view with this newTable
@end
@@ -33,13 +33,16 @@
NSMutableArray *cells;
ForumTableCell *selectedCell;
+ ForumSubThreadTable *previousTable;
id <ForumSubThreadTableDelegate> delegate;
}
@property (nonatomic, retain) NSArray *tableDataSource;
@property (nonatomic, retain) NSMutableArray *cells;
+@property (nonatomic, retain) ForumSubThreadTable *previousTable;
@property (nonatomic, retain) ForumTableCell *selectedCell;
@property (nonatomic, assign) id <ForumSubThreadTableDelegate> delegate;
+-(void) updateContentView;
@end
View
89 Classes/ForumSubThreadTable.m
@@ -11,7 +11,7 @@
@implementation ForumSubThreadTable
-@synthesize tableDataSource, cells, delegate, selectedCell;
+@synthesize tableDataSource, cells, delegate, selectedCell, previousTable;
#pragma mark -
#pragma mark help methods
@@ -73,7 +73,86 @@ - (void)viewDidLoad {
cells = [[NSMutableArray alloc] init];
self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
+
+ UISwipeGestureRecognizer *rightSwipeGesture = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(didSwipeRight:)];
+ rightSwipeGesture.direction = UISwipeGestureRecognizerDirectionRight;
+
+ UISwipeGestureRecognizer *leftSwipeGesture = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(didSwipeLeft:)];
+ leftSwipeGesture.direction = UISwipeGestureRecognizerDirectionLeft;
+
+ [self.tableView addGestureRecognizer:rightSwipeGesture];
+ [self.tableView addGestureRecognizer:leftSwipeGesture];
+
+}
+
+-(void) updateContentView {
+
+ if (selectedCell) {
+ selectedCell.titleText.textColor = kWorkbinFontColor;
+ selectedCell.metaText.textColor = kWorkbinFontColor;
+ }
+
+ UIWebView *content = [[tableDataSource objectAtIndex:0] objectForKey:@"PostBody"];
+ [[self delegate] displayThreadContent:content];
+}
+
+-(void)didSwipeRight:(UIGestureRecognizer *)gestureRecognizer {
+
+
+ int parentSubViewCount = [[self.view superview].subviews count];
+ if (gestureRecognizer.state == UIGestureRecognizerStateEnded) {
+ if (parentSubViewCount > 1) {
+ if (previousTable) {
+ [previousTable updateContentView];
+ }
+ [self.view removeFromSuperview];
+
+ }
+ }
+}
+
+-(void)didSwipeLeft:(UIGestureRecognizer *)gestureRecognizer {
+
+ CGPoint swipeLocation = [gestureRecognizer locationInView:self.tableView];
+ NSIndexPath *indexPath = [self.tableView indexPathForRowAtPoint:swipeLocation];
+
+
+ if (selectedCell) {
+ selectedCell.titleText.textColor = kWorkbinFontColor;
+ selectedCell.metaText.textColor = kWorkbinFontColor;
+ }
+ selectedCell = (ForumTableCell*)[self.tableView cellForRowAtIndexPath:indexPath];
+ selectedCell.titleText.textColor = kWorkbinFontCompColor;
+ selectedCell.metaText.textColor = kWorkbinFontCompColor;
+
+ UIWebView *content = [[tableDataSource objectAtIndex:indexPath.row] objectForKey:@"PostBody"];
+ [[self delegate] displayThreadContent:content];
+
+ NSArray *children = [[tableDataSource objectAtIndex:indexPath.row] objectForKey:@"Threads"];
+ if ([children count] != 0) {
+
+ if ([children count] == 1) {
+ //call delegate to update sub thread table
+ //[self.view removeFromSuperview];
+ [[self delegate] updateSubThreadTableView:children andPreviousTable:self];
+ }
+ else {
+ //[self.view removeFromSuperview];
+ [[self delegate] updateSubThreadTableView:[NSArray arrayWithObjects:[children objectAtIndex:0], nil]andPreviousTable:self];
+ NSMutableArray *mainThreadChildren = [[NSMutableArray alloc] init];
+ for (int i=1; i<[children count]; i++) {
+ [mainThreadChildren addObject:[children objectAtIndex:i]];
+ }
+ [[self delegate] updateMainThreadTableView:mainThreadChildren andIndexPath:indexPath];
+ [mainThreadChildren release];
+ }
+
+
+ }
+
+
+ //[self.delegate updateMainThreadTableView:self.tableDataSource andCells:self.cells andIndexPath:indexPath];
}
@@ -162,12 +241,12 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath
if ([children count] == 1) {
//call delegate to update sub thread table
- [self.view removeFromSuperview];
- [[self delegate] updateSubThreadTableView:children];
+ //[self.view removeFromSuperview];
+ [[self delegate] updateSubThreadTableView:children andPreviousTable:self];
}
else {
- [self.view removeFromSuperview];
- [[self delegate] updateSubThreadTableView:[NSArray arrayWithObjects:[children objectAtIndex:0], nil]];
+ //[self.view removeFromSuperview];
+ [[self delegate] updateSubThreadTableView:[NSArray arrayWithObjects:[children objectAtIndex:0], nil]andPreviousTable:self];
[[self delegate] updateMainThreadTableView:children andIndexPath:indexPath];
}
View
BIN  images/Icon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Please sign in to comment.
Something went wrong with that request. Please try again.