-
Notifications
You must be signed in to change notification settings - Fork 348
Expand file tree
/
Copy pathHomeViewController.m
More file actions
executable file
·115 lines (90 loc) · 2.96 KB
/
HomeViewController.m
File metadata and controls
executable file
·115 lines (90 loc) · 2.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
//
// HomeViewController.m
// SlideMenu
//
// Created by Aryan Gh on 4/24/13.
// Copyright (c) 2013 Aryan Ghassemi. All rights reserved.
//
#import "HomeViewController.h"
#import "LeftMenuViewController.h"
@implementation HomeViewController
- (void)viewDidLoad
{
[super viewDidLoad];
self.scrollView.contentSize = CGSizeMake(self.view.frame.size.width, 503);
self.portraitSlideOffsetSegment.selectedSegmentIndex = [self indexFromPixels:[SlideNavigationController sharedInstance].portraitSlideOffset];
self.landscapeSlideOffsetSegment.selectedSegmentIndex = [self indexFromPixels:[SlideNavigationController sharedInstance].landscapeSlideOffset];
self.panGestureSwitch.on = [SlideNavigationController sharedInstance].enableSwipeGesture;
self.shadowSwitch.on = [SlideNavigationController sharedInstance].enableShadow;
self.limitPanGestureSwitch.on = ([SlideNavigationController sharedInstance].panGestureSideOffset == 0) ? NO : YES;
self.slideOutAnimationSwitch.on = ((LeftMenuViewController *)[SlideNavigationController sharedInstance].leftMenu).slideOutAnimationEnabled;
}
#pragma mark - SlideNavigationController Methods -
- (BOOL)slideNavigationControllerShouldDisplayLeftMenu
{
return YES;
}
- (BOOL)slideNavigationControllerShouldDisplayRightMenu
{
return YES;
}
#pragma mark - IBActions -
- (IBAction)bounceMenu:(id)sender
{
static MenuSide menu = MenuSideLeft;
[[SlideNavigationController sharedInstance] bounceMenu:menu withCompletion:nil];
menu = (menu == MenuSideLeft) ? MenuSideRight : MenuSideLeft;
}
- (IBAction)slideOutAnimationSwitchChanged:(UISwitch *)sender
{
((LeftMenuViewController *)[SlideNavigationController sharedInstance].leftMenu).slideOutAnimationEnabled = sender.isOn;
}
- (IBAction)limitPanGestureSwitchChanged:(UISwitch *)sender
{
[SlideNavigationController sharedInstance].panGestureSideOffset = (sender.isOn) ? 50 : 0;
}
- (IBAction)changeAnimationSelected:(id)sender
{
[[SlideNavigationController sharedInstance] openMenu:MenuSideRight withCompletion:nil];
}
- (IBAction)shadowSwitchSelected:(UISwitch *)sender
{
[SlideNavigationController sharedInstance].enableShadow = sender.isOn;
}
- (IBAction)enablePanGestureSelected:(UISwitch *)sender
{
[SlideNavigationController sharedInstance].enableSwipeGesture = sender.isOn;
}
- (IBAction)portraitSlideOffsetChanged:(UISegmentedControl *)sender
{
[SlideNavigationController sharedInstance].portraitSlideOffset = [self pixelsFromIndex:sender.selectedSegmentIndex];
}
- (IBAction)landscapeSlideOffsetChanged:(UISegmentedControl *)sender
{
[SlideNavigationController sharedInstance].landscapeSlideOffset = [self pixelsFromIndex:sender.selectedSegmentIndex];
}
#pragma mark - Helpers -
- (NSInteger)indexFromPixels:(NSInteger)pixels
{
if (pixels == 60)
return 0;
else if (pixels == 120)
return 1;
else
return 2;
}
- (NSInteger)pixelsFromIndex:(NSInteger)index
{
switch (index)
{
case 0:
return 60;
case 1:
return 120;
case 2:
return 200;
default:
return 0;
}
}
@end