Skip to content

Commit

Permalink
Merge pull request #1 from wangbus/master
Browse files Browse the repository at this point in the history
Updated
  • Loading branch information
wangbus committed Oct 27, 2011
2 parents 1ed90de + 75a5553 commit 14e336a
Show file tree
Hide file tree
Showing 49 changed files with 4,643 additions and 133 deletions.
156 changes: 141 additions & 15 deletions LemonadeAlley/LemonadeAlley.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Binary file not shown.
18 changes: 18 additions & 0 deletions LemonadeAlley/LemonadeAlley/AboutViewController.h
@@ -0,0 +1,18 @@
//
// PagesViewController.h
// LemonadeAlley
//
// Created by James Wang on 10/22/11.
// Copyright (c) 2011 __MyCompanyName__. All rights reserved.
//

#import <UIKit/UIKit.h>
#import "WordpressPageAgent.h"
#import "MBProgressHUD.h"

@interface AboutViewController : UITableViewController

@property (strong, nonatomic) WordpressPageAgent *wordpressPageAgent;
@property (strong, nonatomic) MBProgressHUD *HUD;

@end
199 changes: 199 additions & 0 deletions LemonadeAlley/LemonadeAlley/AboutViewController.m
@@ -0,0 +1,199 @@
#import "AboutViewController.h"
#import "PageViewController.h"

@implementation AboutViewController
@synthesize wordpressPageAgent;
@synthesize HUD;

- (id)initWithStyle:(UITableViewStyle)style {
self = [super initWithStyle:style];
if (self) {
// Custom initialization
}
return self;
}

- (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.
}

#pragma mark - View lifecycle

- (void)viewDidLoad {
[super viewDidLoad];
self.tableView.backgroundView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"lemon_200x200.png"]];
wordpressPageAgent = [[WordpressPageAgent alloc] init];
self.parentViewController.title = @"About";
// Uncomment the following line to preserve selection between presentations.
// self.clearsSelectionOnViewWillAppear = NO;

// Uncomment the following line to display an Edit button in the navigation bar for this view controller.
// self.navigationItem.rightBarButtonItem = self.editButtonItem;
}

- (void)viewDidUnload
{
[super viewDidUnload];
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}

- (void)viewWillAppear:(BOOL)animated {
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(receiveDataNotification:)
name:@"PagesUpdateNotification"
object:nil];
[super viewWillAppear:animated];
}

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

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

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

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

#pragma mark - Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return [[wordpressPageAgent pages] count];
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
}
NSUInteger row = [indexPath row];
NSDictionary *page = [[wordpressPageAgent pages] objectAtIndex:row];

NSLog(@"Page: %@", page);
// Configure the cell...
cell.backgroundColor = [UIColor colorWithWhite:1.0 alpha:0.8];
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"];
return cell;
}

- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
if (section == 0) {
return @"Information";
}
else {
return @"";
}
}

/*
// Override to support conditional editing of the table view.
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
{
// Return NO if you do not want the specified item to be editable.
return YES;
}
*/

/*
// Override to support editing the table view.
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
if (editingStyle == UITableViewCellEditingStyleDelete) {
// Delete the row from the data source
[tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
}
else if (editingStyle == UITableViewCellEditingStyleInsert) {
// Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
}
}
*/

/*
// Override to support rearranging the table view.
- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath
{
}
*/

/*
// Override to support conditional rearranging of the table view.
- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath
{
// Return NO if you do not want the item to be re-orderable.
return YES;
}
*/

#pragma mark - Table view delegate

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
// Navigation logic may go here. Create and push another view controller.
/*
DetailViewController *detailViewController = [[DetailViewController alloc] initWithNibName:@"Nib name" bundle:nil];
// ...
// Pass the selected object to the new view controller.
[self.navigationController pushViewController:detailViewController animated:YES];
*/
}

- (void) receiveDataNotification:(NSNotification *) notification {
if ([[notification name] isEqualToString:@"PagesUpdateNotification"]) {
NSLog (@"Successfully received the Data Update notification!");
[[self tableView] reloadData];
[HUD hide:YES];
}
}

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
NSLog(@"Segue identifier: %@", segue.identifier);

if ([[segue identifier] isEqualToString:@"showPage"]) {
NSLog(@"ShowDetails from prepareforsegue");
NSInteger row = [[self.tableView indexPathForSelectedRow] row];
NSDictionary *page = [wordpressPageAgent.pages objectAtIndex:row];

// [segue destinationViewController] is read-only, so in order to
// write to that view controller you'll have to locally instantiate
// it here:
PageViewController *detailViewController = [segue destinationViewController];
detailViewController.page = page;

// You now have a solid reference to the upcoming / destination view
// controller. Example use: Allocate and initialize some property of
// the destination view controller before you reach it and inject a
// reference to the current view controller into the upcoming one:
// upcomingViewController.someProperty = [[SomePropertyClass alloc] initWithString:@"Whatever!"];
// upcomingViewController. = [segue sourceViewController];

// Or, equivalent, but more straightforward:
//upcomingViewController.initialViewController = self;
}
}


@end
4 changes: 3 additions & 1 deletion LemonadeAlley/LemonadeAlley/AppDelegate.h
Expand Up @@ -7,14 +7,16 @@
//

#import <UIKit/UIKit.h>
#import "FBConnect.h"

@interface AppDelegate : UIResponder <UIApplicationDelegate>
@interface AppDelegate : UIResponder <UIApplicationDelegate, FBSessionDelegate>

@property (strong, nonatomic) UIWindow *window;

@property (readonly, strong, nonatomic) NSManagedObjectContext *managedObjectContext;
@property (readonly, strong, nonatomic) NSManagedObjectModel *managedObjectModel;
@property (readonly, strong, nonatomic) NSPersistentStoreCoordinator *persistentStoreCoordinator;
@property (nonatomic, retain) Facebook *facebook;

- (void)saveContext;
- (NSURL *)applicationDocumentsDirectory;
Expand Down
72 changes: 48 additions & 24 deletions LemonadeAlley/LemonadeAlley/AppDelegate.m
@@ -1,11 +1,3 @@
//
// AppDelegate.m
// LemonadeAlley
//
// Created by Jian Shi Wang on 10/16/11.
// Copyright (c) 2011 __MyCompanyName__. All rights reserved.
//

#import "AppDelegate.h"

@implementation AppDelegate
Expand All @@ -14,23 +6,43 @@ @implementation AppDelegate
@synthesize managedObjectContext = __managedObjectContext;
@synthesize managedObjectModel = __managedObjectModel;
@synthesize persistentStoreCoordinator = __persistentStoreCoordinator;
@synthesize facebook;

- (void)customizeAppearance {
// Create resizable images
// UIImage *gradientImage44 = [[UIImage imageNamed:@"surf_gradient_textured_44"]
// resizableImageWithCapInsets:UIEdgeInsetsMake(0, 0, 0, 0)];
// UIImage *gradientImage32 = [[UIImage imageNamed:@"surf_gradient_textured_32"]
// resizableImageWithCapInsets:UIEdgeInsetsMake(0, 0, 0, 0)];
//
// // Set the background image for *all* UINavigationBars
// [[UINavigationBar appearance] setBackgroundImage:gradientImage44
// 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];

// Customize the title text for *all* UINavigationBars
[[UINavigationBar appearance] setTitleTextAttributes:
[NSDictionary dictionaryWithObjectsAndKeys:
[UIColor colorWithRed:255.0/255.0 green:255.0/255.0 blue:255.0/255.0 alpha:1.0],
UITextAttributeTextColor,
[UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:0.8],
UITextAttributeTextShadowColor,
[NSValue valueWithUIOffset:UIOffsetMake(0, -1)],
UITextAttributeTextShadowOffset,
[UIFont fontWithName:@"MarkerFelt-Wide" size:18.0],
UITextAttributeFont,
nil]];

[[UITableView appearance] setSeparatorStyle:UITableViewCellSeparatorStyleNone];
}

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
// if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) {
// UISplitViewController *splitViewController = (UISplitViewController *)self.window.rootViewController;
// UINavigationController *navigationController = [splitViewController.viewControllers lastObject];
// splitViewController.delegate = (id)navigationController.topViewController;
//
// UINavigationController *masterNavigationController = [splitViewController.viewControllers objectAtIndex:0];
// Tab *controller = (MasterViewController *)masterNavigationController.topViewController;
// controller.managedObjectContext = self.managedObjectContext;
// } else {
// UINavigationController *navigationController = (UINavigationController *)self.window.rootViewController;
// MasterViewController *controller = (MasterViewController *)navigationController.topViewController;
// controller.managedObjectContext = self.managedObjectContext;
// }
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[self customizeAppearance];
facebook = [[Facebook alloc] initWithAppId:@"YOUR_APP_ID" andDelegate:self];
return YES;
}

Expand Down Expand Up @@ -183,4 +195,16 @@ - (NSURL *)applicationDocumentsDirectory
return [[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask] lastObject];
}

- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url
sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {
return [facebook handleOpenURL:url];
}

- (void)fbDidLogin {
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults setObject:[facebook accessToken] forKey:@"FBAccessTokenKey"];
[defaults setObject:[facebook expirationDate] forKey:@"FBExpirationDateKey"];
[defaults synchronize];

}
@end
22 changes: 22 additions & 0 deletions LemonadeAlley/LemonadeAlley/FBConnect/FBConnect.h
@@ -0,0 +1,22 @@
/*
* Copyright 2010 Facebook
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/


#include "Facebook.h"
#include "FBDialog.h"
#include "FBLoginDialog.h"
#include "FBRequest.h"
#include "SBJSON.h"
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 14e336a

Please sign in to comment.