Skip to content

Commit

Permalink
Sections for voting, consistent backgrounds for html, other consisten…
Browse files Browse the repository at this point in the history
…cy fixes.
  • Loading branch information
wangbus committed Oct 30, 2011
1 parent c44be0e commit 71aac80
Show file tree
Hide file tree
Showing 14 changed files with 202 additions and 72 deletions.
52 changes: 40 additions & 12 deletions LemonadeAlley/LemonadeAlley.xcodeproj/project.pbxproj
Expand Up @@ -565,6 +565,39 @@
/* End PBXFrameworksBuildPhase section */

/* Begin PBXGroup section */
A314C46E145CDE4200CFC860 /* About */ = {
isa = PBXGroup;
children = (
A35145D71453B0DB00A10826 /* AboutViewController.h */,
A35145D81453B0DB00A10826 /* AboutViewController.m */,
A3111B5F145432C7001019E7 /* PageViewController.h */,
A3111B60145432C7001019E7 /* PageViewController.m */,
);
name = About;
sourceTree = "<group>";
};
A314C470145CDE5400CFC860 /* News */ = {
isa = PBXGroup;
children = (
A3D1306A144BD0E50019A696 /* NewsViewController.h */,
A3D1306B144BD0E50019A696 /* NewsViewController.m */,
A3DB1230144B934C00DFC686 /* PostViewController.h */,
A3DB1231144B934C00DFC686 /* PostViewController.m */,
);
name = News;
sourceTree = "<group>";
};
A314C471145CDE7300CFC860 /* Voting */ = {
isa = PBXGroup;
children = (
A3B4484F145983620045FCC3 /* VotingViewController.h */,
A3B44850145983620045FCC3 /* VotingViewController.m */,
A3B01A59145A7BD9007D3CDD /* FacebookViewController.h */,
A3B01A5A145A7BD9007D3CDD /* FacebookViewController.m */,
);
name = Voting;
sourceTree = "<group>";
};
A342AA77144C4A1E0051DAC3 /* MBProgressHUD */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -668,18 +701,9 @@
A3DB1222144B934B00DFC686 /* AppDelegate.m */,
A3DB1224144B934B00DFC686 /* MainStoryboard_iPhone.storyboard */,
A3DB1227144B934C00DFC686 /* MainStoryboard_iPad.storyboard */,
A35145D71453B0DB00A10826 /* AboutViewController.h */,
A35145D81453B0DB00A10826 /* AboutViewController.m */,
A3D1306A144BD0E50019A696 /* NewsViewController.h */,
A3D1306B144BD0E50019A696 /* NewsViewController.m */,
A3111B5F145432C7001019E7 /* PageViewController.h */,
A3111B60145432C7001019E7 /* PageViewController.m */,
A3DB1230144B934C00DFC686 /* PostViewController.h */,
A3DB1231144B934C00DFC686 /* PostViewController.m */,
A3B4484F145983620045FCC3 /* VotingViewController.h */,
A3B44850145983620045FCC3 /* VotingViewController.m */,
A3B01A59145A7BD9007D3CDD /* FacebookViewController.h */,
A3B01A5A145A7BD9007D3CDD /* FacebookViewController.m */,
A314C46E145CDE4200CFC860 /* About */,
A314C470145CDE5400CFC860 /* News */,
A314C471145CDE7300CFC860 /* Voting */,
A3DB122A144B934C00DFC686 /* LemonadeAlley.xcdatamodeld */,
A3DB1219144B934B00DFC686 /* Supporting Files */,
);
Expand Down Expand Up @@ -1336,6 +1360,7 @@
ALWAYS_SEARCH_USER_PATHS = NO;
ARCHS = "$(ARCHS_STANDARD_32_BIT)";
CLANG_ENABLE_OBJC_ARC = YES;
CODE_SIGN_IDENTITY = "iPhone Developer: Jian Shi WANG (M7SG4N2CX7)";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = NO;
GCC_C_LANGUAGE_STANDARD = gnu99;
Expand All @@ -1351,6 +1376,7 @@
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 5.0;
PROVISIONING_PROFILE = "5215CD0E-7CB8-4556-8D0B-F78BC6A77B3D";
SDKROOT = iphoneos;
TARGETED_DEVICE_FAMILY = "1,2";
};
Expand All @@ -1362,6 +1388,7 @@
ALWAYS_SEARCH_USER_PATHS = NO;
ARCHS = "$(ARCHS_STANDARD_32_BIT)";
CLANG_ENABLE_OBJC_ARC = YES;
CODE_SIGN_IDENTITY = "iPhone Developer: Jian Shi WANG (M7SG4N2CX7)";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
Expand All @@ -1371,6 +1398,7 @@
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 5.0;
OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1";
PROVISIONING_PROFILE = "5215CD0E-7CB8-4556-8D0B-F78BC6A77B3D";
SDKROOT = iphoneos;
TARGETED_DEVICE_FAMILY = "1,2";
VALIDATE_PRODUCT = YES;
Expand Down
Binary file not shown.
25 changes: 22 additions & 3 deletions LemonadeAlley/LemonadeAlley/AboutViewController.m
@@ -1,3 +1,7 @@
#define FONT_SIZE 14.0f
#define CELL_CONTENT_WIDTH 320.0f
#define CELL_CONTENT_MARGIN 10.0f

#import "AboutViewController.h"
#import "PageViewController.h"

Expand All @@ -16,7 +20,6 @@ - (id)initWithStyle:(UITableViewStyle)style {
- (void)didReceiveMemoryWarning {
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];

// Release any cached data, images, etc that aren't in use.
}

Expand Down Expand Up @@ -99,11 +102,17 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
NSLog(@"Page: %@", page);
// Configure the cell...
cell.backgroundColor = [UIColor colorWithWhite:1.0 alpha:0.8];

cell.textLabel.backgroundColor = [UIColor clearColor];
cell.textLabel.font = [UIFont fontWithName:@"Helvetica-Bold" size:14.0];
// cell.textLabel.textColor = [UIColor whiteColor];
cell.textLabel.text = [page objectForKey:@"name"];
// cell.detailTextLabel.font = [UIFont fontWithName:@"Noteworthy-Light" size:14.0];
cell.detailTextLabel.text = [page objectForKey:@"url"];

cell.detailTextLabel.backgroundColor = [UIColor clearColor];
cell.detailTextLabel.text = [page objectForKey:@"details"];
cell.detailTextLabel.lineBreakMode = UILineBreakModeWordWrap;
cell.detailTextLabel.numberOfLines = 0;
return cell;
}

Expand All @@ -116,6 +125,16 @@ - (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInte
}
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
NSDictionary *page = [[wordpressPageAgent pages] objectAtIndex:[indexPath row]];
NSString *text = [page objectForKey:@"title"];
CGSize constraint = CGSizeMake(CELL_CONTENT_WIDTH - (CELL_CONTENT_MARGIN * 2), 20000.0f);
CGSize size = [text sizeWithFont:[UIFont systemFontOfSize:FONT_SIZE] constrainedToSize:constraint lineBreakMode:UILineBreakModeWordWrap];
CGFloat height = MAX(size.height, 44.0f);
return height + (CELL_CONTENT_MARGIN * 2);
}


/*
// Override to support conditional editing of the table view.
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
Expand Down Expand Up @@ -170,8 +189,8 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath
- (void) receiveDataNotification:(NSNotification *) notification {
if ([[notification name] isEqualToString:@"PagesUpdateNotification"]) {
NSLog (@"Successfully received the Data Update notification!");
[[self tableView] reloadData];
[HUD hide:YES];
[[self tableView] reloadData];
}
}

Expand Down
8 changes: 4 additions & 4 deletions LemonadeAlley/LemonadeAlley/AppDelegate.m
Expand Up @@ -20,9 +20,9 @@ - (void)customizeAppearance {
// forBarMetrics:UIBarMetricsDefault];
// [[UINavigationBar appearance] setBackgroundImage:gradientImage32
// forBarMetrics:UIBarMetricsLandscapePhone];
UIImage *navigationBackgroundImage44 = [[UIImage imageNamed:@"nav_bg_44"]
resizableImageWithCapInsets:UIEdgeInsetsMake(0, 0, 0, 0)];
[[UINavigationBar appearance] setBackgroundImage:navigationBackgroundImage44 forBarMetrics:UIBarMetricsDefault];
// UIImage *navigationBackgroundImage44 = [[UIImage imageNamed:@"nav_bg_44"]
// resizableImageWithCapInsets:UIEdgeInsetsMake(0, 0, 0, 0)];
// [[UINavigationBar appearance] setBackgroundImage:navigationBackgroundImage44 forBarMetrics:UIBarMetricsDefault];

// Customize the title text for *all* UINavigationBars
[[UINavigationBar appearance] setTitleTextAttributes:
Expand All @@ -33,7 +33,7 @@ - (void)customizeAppearance {
UITextAttributeTextShadowColor,
[NSValue valueWithUIOffset:UIOffsetMake(0, -1)],
UITextAttributeTextShadowOffset,
[UIFont fontWithName:@"MarkerFelt-Wide" size:18.0],
[UIFont fontWithName:@"Helvetica-Bold" size:18.0],
UITextAttributeFont,
nil]];

Expand Down
28 changes: 18 additions & 10 deletions LemonadeAlley/LemonadeAlley/FacebookViewController.m
Expand Up @@ -43,16 +43,24 @@ - (void)viewDidLoad {
[super viewDidLoad];
NSString *urlAddress = [self.contestantInfo objectForKey:@"facebook url"];

//Create a URL object.
NSURL *url = [NSURL URLWithString:urlAddress];

//URL Requst Object
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];

//Load the request in the UIWebView.
[webView loadRequest:requestObj];
[webView setOpaque:NO];
//pass the string to the webview
if ([urlAddress isEqualToString:@"-"]) {
[webView loadHTMLString:@"No Facebook page found." baseURL:nil];
[webView setOpaque:NO];
[webView setBackgroundColor:[UIColor colorWithWhite:1 alpha:0.3]];
self.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"lemon_200x200.png"]];
}
else {
//Create a URL object.
NSURL *url = [NSURL URLWithString:urlAddress];

//URL Requst Object
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];

//Load the request in the UIWebView.
[webView loadRequest:requestObj];
[webView setOpaque:NO];
//pass the string to the webview
}
}

- (void)viewDidUnload
Expand Down
38 changes: 35 additions & 3 deletions LemonadeAlley/LemonadeAlley/NewsViewController.m
@@ -1,3 +1,7 @@
#define FONT_SIZE 14.0f
#define CELL_CONTENT_WIDTH 320.0f
#define CELL_CONTENT_MARGIN 10.0f

#import "NewsViewController.h"
#import "WordpressPostAgent.h"
#import "PostViewController.h"
Expand Down Expand Up @@ -55,8 +59,7 @@ - (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
}

- (void)viewDidAppear:(BOOL)animated
{
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
}

Expand Down Expand Up @@ -105,10 +108,39 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N

// Configure the cell...
cell.textLabel.text = [post objectForKey:@"title"];
cell.detailTextLabel.text = [post objectForKey:@"modified"];

cell.textLabel.lineBreakMode = UILineBreakModeWordWrap;
cell.textLabel.numberOfLines = 0;
cell.textLabel.backgroundColor = [UIColor clearColor];
// cell.detailTextLabel.text =

NSString *modified = [post objectForKey:@"modified"];
NSDateFormatter *dateFormatterFromWordpress = [[NSDateFormatter alloc] init];
[dateFormatterFromWordpress setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
NSDate *date = [dateFormatterFromWordpress dateFromString:modified];

NSLocale *locale = [NSLocale currentLocale];
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
NSString *dateFormat = [NSDateFormatter dateFormatFromTemplate:@"E MMM d yyyy HH:mm" options:0 locale:locale];
[dateFormatter setDateFormat:dateFormat];
[dateFormatter setLocale:locale];

NSString *modifiedFormatted = [dateFormatter stringFromDate: date];
cell.detailTextLabel.text = [NSString stringWithFormat:@"Posted: %@", modifiedFormatted];

cell.detailTextLabel.backgroundColor = [UIColor clearColor];
return cell;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
NSDictionary *post = [[wordpressPostAgent posts] objectAtIndex:[indexPath row]];
NSString *text = [post objectForKey:@"title"];
CGSize constraint = CGSizeMake(CELL_CONTENT_WIDTH - (CELL_CONTENT_MARGIN * 2), 20000.0f);
CGSize size = [text sizeWithFont:[UIFont systemFontOfSize:FONT_SIZE] constrainedToSize:constraint lineBreakMode:UILineBreakModeWordWrap];
CGFloat height = MAX(size.height, 44.0f);
return height + (CELL_CONTENT_MARGIN * 2);
}

/*
// Override to support conditional editing of the table view.
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
Expand Down
6 changes: 5 additions & 1 deletion LemonadeAlley/LemonadeAlley/PageViewController.m
Expand Up @@ -36,6 +36,8 @@ - (void)loadView
- (void)viewDidLoad {
[super viewDidLoad];
NSString *url = [page objectForKey:@"url"];
self.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"lemon_200x200.png"]];
//make the background transparent
// Create the request.
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:url]
cachePolicy:NSURLRequestUseProtocolCachePolicy
Expand Down Expand Up @@ -93,7 +95,9 @@ - (void)connectionDidFinishLoading:(NSURLConnection *)connection {
NSDictionary *jsonPage = [response objectForKey:@"page"];
NSString *html = [jsonPage objectForKey:@"content"];
NSLog(@"HTML: %@", html);
[webView setBackgroundColor:[UIColor clearColor]];

[webView setOpaque:NO];
[webView setBackgroundColor:[UIColor colorWithWhite:1 alpha:0.3]];

//pass the string to the webview
[webView loadHTMLString:[html description] baseURL:nil];
Expand Down
1 change: 1 addition & 0 deletions LemonadeAlley/LemonadeAlley/VotingViewController.h
Expand Up @@ -15,5 +15,6 @@

@property (strong, nonatomic) ContestantsInfoAgent *contestantsInfoAgent;
@property (strong, nonatomic) MBProgressHUD *HUD;
@property (strong, nonatomic) NSMutableArray *arrayOfSections;

@end

0 comments on commit 71aac80

Please sign in to comment.