Skip to content

Commit

Permalink
updated something
Browse files Browse the repository at this point in the history
  • Loading branch information
Tan Duy committed Jan 25, 2013
1 parent 7aa38fa commit a25112a
Show file tree
Hide file tree
Showing 13 changed files with 225 additions and 186 deletions.
6 changes: 6 additions & 0 deletions MiniEvalApp.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
8D07C1D016B21A1800690C0C /* MECustomTabBarController.m in Sources */ = {isa = PBXBuildFile; fileRef = 8D07C1CF16B21A1800690C0C /* MECustomTabBarController.m */; };
8D07C1D916B223B900690C0C /* MECustomTabBar.xib in Resources */ = {isa = PBXBuildFile; fileRef = 8D07C1D816B223B900690C0C /* MECustomTabBar.xib */; };
8D07C1F016B22F8A00690C0C /* MECustomTabBarView.m in Sources */ = {isa = PBXBuildFile; fileRef = 8D07C1EF16B22F8A00690C0C /* MECustomTabBarView.m */; };
8D07C1FC16B264EF00690C0C /* KTNavigationBar.m in Sources */ = {isa = PBXBuildFile; fileRef = 8D07C1F916B264EF00690C0C /* KTNavigationBar.m */; };
8D4C512116AD330C008F6922 /* MEStaffCustomViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 8D4C512016AD330C008F6922 /* MEStaffCustomViewCell.m */; };
8D4CC9BF16ACEE5300DCB309 /* MEViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 8D4CC9BE16ACEE5300DCB309 /* MEViewController.m */; };
8D4CC9CA16ACEF9E00DCB309 /* MEConstants.m in Sources */ = {isa = PBXBuildFile; fileRef = 8D4CC9C916ACEF9E00DCB309 /* MEConstants.m */; };
Expand Down Expand Up @@ -84,6 +85,8 @@
8D07C1D816B223B900690C0C /* MECustomTabBar.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = MECustomTabBar.xib; sourceTree = "<group>"; };
8D07C1EE16B22F8A00690C0C /* MECustomTabBarView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MECustomTabBarView.h; path = View/MECustomTabBarView.h; sourceTree = "<group>"; };
8D07C1EF16B22F8A00690C0C /* MECustomTabBarView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = MECustomTabBarView.m; path = View/MECustomTabBarView.m; sourceTree = "<group>"; };
8D07C1F816B264EF00690C0C /* KTNavigationBar.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KTNavigationBar.h; sourceTree = "<group>"; };
8D07C1F916B264EF00690C0C /* KTNavigationBar.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KTNavigationBar.m; sourceTree = "<group>"; };
8D4C511F16AD330C008F6922 /* MEStaffCustomViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MEStaffCustomViewCell.h; path = View/MEStaffCustomViewCell.h; sourceTree = "<group>"; };
8D4C512016AD330C008F6922 /* MEStaffCustomViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = MEStaffCustomViewCell.m; path = View/MEStaffCustomViewCell.m; sourceTree = "<group>"; };
8D4CC9BD16ACEE5300DCB309 /* MEViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MEViewController.h; path = Controller/MEViewController.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -373,6 +376,8 @@
8DB5C3B816ACE8C0008D5E02 /* Vendors */ = {
isa = PBXGroup;
children = (
8D07C1F816B264EF00690C0C /* KTNavigationBar.h */,
8D07C1F916B264EF00690C0C /* KTNavigationBar.m */,
8D994EB416B147520049E709 /* ZHCustomSegue.h */,
8D994EB516B147520049E709 /* ZHCustomSegue.m */,
8D9C2C5816AEA20B008D9101 /* SVPullToRefresh */,
Expand Down Expand Up @@ -531,6 +536,7 @@
8D994EB616B147520049E709 /* ZHCustomSegue.m in Sources */,
8D07C1D016B21A1800690C0C /* MECustomTabBarController.m in Sources */,
8D07C1F016B22F8A00690C0C /* MECustomTabBarView.m in Sources */,
8D07C1FC16B264EF00690C0C /* KTNavigationBar.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
Binary file not shown.
22 changes: 19 additions & 3 deletions MiniEvalApp/Controller/MECustomTabBarController.m
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,27 @@ - (void)hideExistingTabBar
}
}

#pragma mark ALTabBarDelegate

-(void)tabWasSelected:(NSInteger)index {
-(void)tabWasSelected:(NSInteger)index
{
UIViewController *viewController = [self.viewControllers objectAtIndex:index];

UIView * fromView = self.selectedViewController.view;
UIView * toView = viewController.view;

self.selectedIndex = index;
if (fromView != toView) {
NSUInteger fromIndex = [self.viewControllers indexOfObject:self.selectedViewController];

[UIView transitionFromView:fromView
toView:toView
duration:0.5
options: index > fromIndex ? UIViewAnimationOptionTransitionFlipFromLeft : UIViewAnimationOptionTransitionFlipFromRight
completion:^(BOOL finished) {
if (finished) {
self.selectedIndex = index;
}
}];
}
}

@end
2 changes: 1 addition & 1 deletion MiniEvalApp/Controller/MEInfoViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ - (void)viewDidLoad
NSURLRequest *request = [NSURLRequest requestWithURL:url];
[self.webView loadRequest:request];


self.webView.scalesPageToFit = YES;
}

- (void)didReceiveMemoryWarning
Expand Down
97 changes: 83 additions & 14 deletions MiniEvalApp/Controller/MEStaffDetailsTableViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@
#import <MessageUI/MFMailComposeViewController.h>
#import <MessageUI/MFMessageComposeViewController.h>

@interface MEStaffDetailsTableViewController () <MFMailComposeViewControllerDelegate, MFMessageComposeViewControllerDelegate, UINavigationControllerDelegate>
@interface MEStaffDetailsTableViewController () <MFMailComposeViewControllerDelegate, MFMessageComposeViewControllerDelegate>

@property (strong, nonatomic) NSMutableArray *items;
@property (nonatomic) BOOL fistLoadTableView;

@end

Expand Down Expand Up @@ -43,8 +44,80 @@ - (void)viewDidLoad
{
[super viewDidLoad];

self.title = self.person.name;
self.title = self.person.name;

[self saveVistedCount];

[self customizeBackButton];

[self customAddContactButton];

self.fistLoadTableView = YES;
[self initStaffDetailsCustomViewCells];
}


- (void) viewWillLayoutSubviews
{
if (self.fistLoadTableView == YES) {
// [self.tableView setHidden:YES];

UIColor *LightOrganColor = UIColorFromRGB(kLightOrganColor);

UIView *animationView = [[UIView alloc] initWithFrame:self.tableView.frame];
[animationView setBackgroundColor:[UIColor whiteColor]];


[self.view addSubview:animationView];

for (int i = 0; i < self.items.count; i++) {
MEStaffDetailsCustomViewCell *cell = (MEStaffDetailsCustomViewCell *)[self.tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:i inSection:0]];
UIView *rowView = [[UIView alloc] initWithFrame:cell.frame];

[rowView setBackgroundColor:LightOrganColor];

[rowView addSubview:cell.imageCell];
[rowView addSubview:cell.textCell];

[animationView addSubview:rowView];

rowView.alpha = 0;
}

[self checkSubviews:animationView atIndex:0];
}
}

- (void)checkSubviews:(UIView *)myView
atIndex:(int)idx
{
if (idx == [myView.subviews count]) {
self.fistLoadTableView = NO;
for (int i = 0; i < self.items.count; i++) {
MEStaffDetailsCustomViewCell *cell = (MEStaffDetailsCustomViewCell *)[self.tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:i inSection:0]];
// [cell addSubview:[[(UIView *)[myView.subviews objectAtIndex:i] subviews] objectAtIndex:0]];
// [cell addSubview:[[(UIView *)[myView.subviews objectAtIndex:i] subviews] objectAtIndex:1]];
}

//[myView removeFromSuperview];
// [self.tableView reloadData];
return;
}

UIView *mySubview = [myView.subviews objectAtIndex:idx];
[UIView animateWithDuration:0.3
delay:0
options: UIViewAnimationCurveLinear
animations:^{
mySubview.alpha = 1;
}
completion:^(BOOL finished){
[self checkSubviews:myView atIndex:idx + 1];
}];
}

- (void)saveVistedCount
{
// Use NSUserDefault to store the visit count for each person.
// When a user is selected, increase visit count

Expand Down Expand Up @@ -75,13 +148,6 @@ - (void)viewDidLoad

[defaults setObject:staffs forKey:STAFFS_KEY];
[defaults synchronize];


[self customizeBackButton];

[self customAddContactButton];

[self initStaffDetailsCustomViewCells];
}

- (void)initStaffDetailsCustomViewCells
Expand Down Expand Up @@ -114,19 +180,19 @@ - (void)initStaffDetailsCustomViewCells
if (self.person.like) {
imageCell = @"icon_like.png";
textCell = self.person.like;
[self.items addObject:[NSDictionary dictionaryWithObjectsAndKeys: imageCell, @"imageCell", textCell, @"textCell", nil]];
[self.items addObject:[NSDictionary dictionaryWithObjectsAndKeys: imageCell, @"imageCell", textCell, @"textCell",[NSNumber numberWithUnsignedInt:0], @"tag", nil]];
}

if (self.person.dislike) {
imageCell = @"icon_dislike.png";
textCell = self.person.dislike;
[self.items addObject:[[NSDictionary alloc] initWithObjectsAndKeys:imageCell, @"imageCell", textCell, @"textCell", nil]];
[self.items addObject:[[NSDictionary alloc] initWithObjectsAndKeys:imageCell, @"imageCell", textCell, @"textCell",[NSNumber numberWithUnsignedInt:0], @"tag", nil]];
}

if (self.person.visitedCount) {
imageCell = @"icon_star.png";
textCell = [NSString stringWithFormat:@"%d visitors", self.person.visitedCount];
[self.items addObject:[[NSDictionary alloc] initWithObjectsAndKeys:imageCell, @"imageCell", textCell, @"textCell", nil]];
[self.items addObject:[[NSDictionary alloc] initWithObjectsAndKeys:imageCell, @"imageCell", textCell, @"textCell",[NSNumber numberWithUnsignedInt:0], @"tag", nil]];
}
}

Expand Down Expand Up @@ -278,11 +344,10 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
return cell;
}



#define FONT_SIZE 11.0f
#define CELL_CONTENT_WIDTH 222.0f
#define CELL_CONTENT_MARGIN 10.0f
#define CELL_HEIGHT_FIRST_LOAD 70.0f

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath;
{
Expand All @@ -308,6 +373,10 @@ - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPa
if (height < size.height) {
height = size.height;
}

if (self.fistLoadTableView && height > CELL_HEIGHT_FIRST_LOAD) {
height = CELL_HEIGHT_FIRST_LOAD;
}

// return the height, with a bit of extra padding in
return height + (CELL_CONTENT_MARGIN * 2);
Expand Down
46 changes: 3 additions & 43 deletions MiniEvalApp/Controller/MEStaffTableViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#import "MEStaffCustomViewCell.h"
#import "SVPullToRefresh.h"

@interface MEStaffTableViewController () <UITableViewDelegate, UITableViewDataSource, UITabBarControllerDelegate>
@interface MEStaffTableViewController () <UITableViewDelegate, UITableViewDataSource>

@property (strong, nonatomic) NSMutableArray *results;
@property (strong, nonatomic) NSMutableArray *filteredArray;
Expand Down Expand Up @@ -118,51 +118,11 @@ - (void)viewDidLoad

[self reload:nil];

// UIImage *imgInfo = [UIImage imageNamed:@"icon_info.png"];
// UIImage *imgInfoHighlight = [UIImage imageNamed:@"icon_info_selected.png"];
//
// UIImage *imgContacts = [UIImage imageNamed:@"icon_contacts.png"];
// UIImage *imgContactsHighlight = [UIImage imageNamed:@"icon_contacts_selected.png"];
//
// UIImage *imgSettings = [UIImage imageNamed:@"middle_button.png"];
//
//
// UITabBar *tabBar = self.tabBarController.tabBar;
//
// UITabBarItem *firstTabItem = [tabBar.items objectAtIndex:0];
// UITabBarItem *secondTabItem = [tabBar.items objectAtIndex:1];
// UITabBarItem *thirdTabItem = [tabBar.items objectAtIndex:2];
//
// [thirdTabItem setFinishedSelectedImage:imgInfoHighlight withFinishedUnselectedImage:imgInfo];
// [firstTabItem setFinishedSelectedImage:imgContactsHighlight withFinishedUnselectedImage:imgContacts];
// [secondTabItem setFinishedSelectedImage:imgSettings withFinishedUnselectedImage:imgSettings];
UINavigationBar *bar = [self.navigationController navigationBar];
[bar setNeedsDisplay];

[self.tabBarController setDelegate:self];
}

- (BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController {

NSArray *tabViewControllers = tabBarController.viewControllers;
UIView * fromView = tabBarController.selectedViewController.view;
UIView * toView = viewController.view;

if (fromView == toView)
return false;

NSUInteger fromIndex = [tabViewControllers indexOfObject:tabBarController.selectedViewController];
NSUInteger toIndex = [tabViewControllers indexOfObject:viewController];

[UIView transitionFromView:fromView
toView:toView
duration:0.5
options: toIndex > fromIndex ? UIViewAnimationOptionTransitionFlipFromLeft : UIViewAnimationOptionTransitionFlipFromRight
completion:^(BOOL finished) {
if (finished) {
tabBarController.selectedIndex = toIndex;
}
}];
return true;
}

- (void)viewDidUnload {
_activityIndicatorView = nil;
Expand Down
6 changes: 4 additions & 2 deletions MiniEvalApp/MEAppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#import "MEAppDelegate.h"
#import "AFNetworkActivityIndicatorManager.h"


@implementation MEAppDelegate

- (BOOL)application:(UIApplication *)application
Expand All @@ -23,7 +24,7 @@ - (BOOL)application:(UIApplication *)application
UIColor *DarkOrganColor = UIColorFromRGB(kDarkOrganColor);
UIColor *MainColor = UIColorFromRGB(kMainColor);

// [[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:@"bk.png"] forBarMetrics:UIBarStyleDefault];
// [[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:@"bk.png"] forBarMetrics:UIBarStyleDefault];
[[UINavigationBar appearance] setTintColor:MainColor];

[[UINavigationBar appearance] setTitleTextAttributes:
Expand All @@ -43,11 +44,12 @@ - (BOOL)application:(UIApplication *)application

[[UIBarButtonItem appearance] setTintColor:DarkOrganColor];


// [[UIBarButtonItem appearance]
// setBackButtonBackgroundImage:[UIImage imageNamed:@"icon_back.png"]
// forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];

return YES;
}

@end
@end
2 changes: 1 addition & 1 deletion MiniEvalApp/MEConstants.m
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ @implementation MEConstants
NSString * const kAppAPIToken = @"";
NSString * const kAppJSONPath = @"https://ajax.googleapis.com/ajax/services/feed/load?v=1.0&q=http%3A%2F%2Fwww.digg.com%2Frss%2Findex.xml";
int const kLightOrganColor = 0xfff0db;
int const kDarkOrganColor = 0xcd853f;
int const kDarkOrganColor = 0xEA6D26;
int const kMainColor = 0xEB773F;
int const kLightBlueColor = 0x199CB1;
int const kDarkBlueColor = 0x199CB1;
Expand Down
Loading

0 comments on commit a25112a

Please sign in to comment.