From f1025d779266ffe399d3c8431d6b21932b947df5 Mon Sep 17 00:00:00 2001 From: Aryan Ghassemi Date: Sun, 26 Jan 2014 15:27:57 -0800 Subject: [PATCH] - Some cleanup - Structured menu for a better presentation of slide menu features --- SlideMenu/Helper Classes/MenuViewController.h | 2 +- SlideMenu/Helper Classes/MenuViewController.m | 208 ++++++++++-------- ...NavigationContorllerAnimatorScaleAndFade.h | 1 + .../en.lproj/MainStoryboard_iPhone.storyboard | 5 +- 4 files changed, 122 insertions(+), 94 deletions(-) diff --git a/SlideMenu/Helper Classes/MenuViewController.h b/SlideMenu/Helper Classes/MenuViewController.h index 412e0b8..0d2e7aa 100755 --- a/SlideMenu/Helper Classes/MenuViewController.h +++ b/SlideMenu/Helper Classes/MenuViewController.h @@ -9,7 +9,7 @@ #import #import "SlideNavigationController.h" -@interface MenuViewController : UIViewController +@interface MenuViewController : UIViewController @property (nonatomic, strong) NSString *cellIdentifier; diff --git a/SlideMenu/Helper Classes/MenuViewController.m b/SlideMenu/Helper Classes/MenuViewController.m index e7d9589..646ea43 100755 --- a/SlideMenu/Helper Classes/MenuViewController.m +++ b/SlideMenu/Helper Classes/MenuViewController.m @@ -18,56 +18,74 @@ #pragma mark - UITableView Delegate & Datasrouce - +- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView +{ + return 2; +} + - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { - return 10; + return (section == 0) ? 4 : 6; +} + +- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section +{ + return (section == 0) ? @"Navigation" : @"Menu Animation"; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:self.cellIdentifier]; - switch (indexPath.row) + if (indexPath.section == 0) { - case 0: - cell.textLabel.text = @"Home"; - break; - - case 1: - cell.textLabel.text = @"Profile"; - break; - - case 2: - cell.textLabel.text = @"Friends"; - break; - - case 3: - cell.textLabel.text = @"Sign Out"; - break; - - case 4: - cell.textLabel.text = @"No Animation"; - break; - - case 5: - cell.textLabel.text = @"Slide Animation"; - break; - - case 6: - cell.textLabel.text = @"Fade Animation"; - break; - - case 7: - cell.textLabel.text = @"Slide And Fade Animation"; - break; - - case 8: - cell.textLabel.text = @"Scale Animation"; - break; - - case 9: - cell.textLabel.text = @"Scale And Fade Animation"; - break; + switch (indexPath.row) + { + case 0: + cell.textLabel.text = @"Home"; + break; + + case 1: + cell.textLabel.text = @"Profile"; + break; + + case 2: + cell.textLabel.text = @"Friends"; + break; + + case 3: + cell.textLabel.text = @"Sign Out"; + break; + } + } + else + { + switch (indexPath.row) + { + case 0: + cell.textLabel.text = @"No Animation"; + break; + + case 1: + cell.textLabel.text = @"Slide Animation"; + break; + + case 2: + cell.textLabel.text = @"Fade Animation"; + break; + + case 3: + cell.textLabel.text = @"Slide And Fade Animation"; + break; + + case 4: + cell.textLabel.text = @"Scale Animation"; + break; + + case 5: + cell.textLabel.text = @"Scale And Fade Animation"; + break; + } } return cell; @@ -78,62 +96,70 @@ UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:@"MainStoryboard_iPhone" bundle: nil]; - UIViewController *vc ; - id revealAnimator; - - switch (indexPath.row) + if (indexPath.section == 0) { - case 0: - vc = [mainStoryboard instantiateViewControllerWithIdentifier: @"HomeViewController"]; - break; - - case 1: - vc = [mainStoryboard instantiateViewControllerWithIdentifier: @"ProfileViewController"]; - break; - - case 2: - vc = [mainStoryboard instantiateViewControllerWithIdentifier: @"FriendsViewController"]; - break; - - case 3: - [[SlideNavigationController sharedInstance] popToRootViewControllerAnimated:YES]; - return; - break; - - case 4: - revealAnimator = nil; - break; - - case 5: - revealAnimator = [[SlideNavigationContorllerAnimatorSlide alloc] init]; - break; - - case 6: - revealAnimator = [[SlideNavigationContorllerAnimatorFade alloc] init]; - break; - - case 7: - revealAnimator = [[SlideNavigationContorllerAnimatorSlideAndFade alloc] init]; - break; - - case 8: - revealAnimator = [[SlideNavigationContorllerAnimatorScale alloc] init]; - break; - - case 9: - revealAnimator = [[SlideNavigationContorllerAnimatorScaleAndFade alloc] init]; - break; - - default: - return; - } - - if (vc) + UIViewController *vc ; + + switch (indexPath.row) + { + case 0: + vc = [mainStoryboard instantiateViewControllerWithIdentifier: @"HomeViewController"]; + break; + + case 1: + vc = [mainStoryboard instantiateViewControllerWithIdentifier: @"ProfileViewController"]; + break; + + case 2: + vc = [mainStoryboard instantiateViewControllerWithIdentifier: @"FriendsViewController"]; + break; + + case 3: + [[SlideNavigationController sharedInstance] popToRootViewControllerAnimated:YES]; + return; + break; + } + [[SlideNavigationController sharedInstance] switchToViewController:vc withCompletion:nil]; + } else + { + id revealAnimator; + + switch (indexPath.row) + { + case 0: + revealAnimator = nil; + break; + + case 1: + revealAnimator = [[SlideNavigationContorllerAnimatorSlide alloc] init]; + break; + + case 2: + revealAnimator = [[SlideNavigationContorllerAnimatorFade alloc] init]; + break; + + case 3: + revealAnimator = [[SlideNavigationContorllerAnimatorSlideAndFade alloc] initWithMaximumFadeAlpha:.7 fadeColor:[UIColor purpleColor] andSlideMovement:100]; + break; + + case 4: + revealAnimator = [[SlideNavigationContorllerAnimatorScale alloc] init]; + break; + + case 5: + revealAnimator = [[SlideNavigationContorllerAnimatorScaleAndFade alloc] initWithMaximumFadeAlpha:.6 fadeColor:[UIColor blueColor] andMinimumScale:.7]; + break; + + default: + return; + } + [[SlideNavigationController sharedInstance] closeMenuWithCompletion:^{ [SlideNavigationController sharedInstance].menuRevealAnimator = revealAnimator; }]; + } } @end diff --git a/SlideMenu/Source/Animations/SlideNavigationContorllerAnimatorScaleAndFade.h b/SlideMenu/Source/Animations/SlideNavigationContorllerAnimatorScaleAndFade.h index 389c224..398e645 100644 --- a/SlideMenu/Source/Animations/SlideNavigationContorllerAnimatorScaleAndFade.h +++ b/SlideMenu/Source/Animations/SlideNavigationContorllerAnimatorScaleAndFade.h @@ -11,5 +11,6 @@ @interface SlideNavigationContorllerAnimatorScaleAndFade : NSObject +- (id)initWithMaximumFadeAlpha:(CGFloat)maximumFadeAlpha fadeColor:(UIColor *)fadeColor andMinimumScale:(CGFloat)minimumScale; @end diff --git a/SlideMenu/en.lproj/MainStoryboard_iPhone.storyboard b/SlideMenu/en.lproj/MainStoryboard_iPhone.storyboard index 4f07817..2ac4a4c 100755 --- a/SlideMenu/en.lproj/MainStoryboard_iPhone.storyboard +++ b/SlideMenu/en.lproj/MainStoryboard_iPhone.storyboard @@ -14,9 +14,10 @@ - - + + +