Skip to content

Commit 02034e3

Browse files
committed
Exposed constrainedSize property and shrinkSide methods in IISideController.
Allows to manually trigger the resizing of the side controller when the ledge side of a IIViewDeckController is triggered. You can change the constrainedSize (-1: use ledge value from viewdeckcontroller) or just trigger the resize using the method calls. Changing the property will automatically shrink.
1 parent 003a2ce commit 02034e3

File tree

4 files changed

+52
-18
lines changed

4 files changed

+52
-18
lines changed

VERSION

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2.2.3
1+
2.2.4

ViewDeck.podspec

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = 'ViewDeck'
3-
s.version = '2.2.3'
3+
s.version = '2.2.4'
44
s.platform = :ios
55
s.summary = 'An implementation of the sliding functionality found in the ' \
66
'Path 2.0 or Facebook iOS apps.'
@@ -19,7 +19,7 @@ Pod::Spec.new do |s|
1919
}
2020
s.author = { 'Tom Adriaenssen' => 'http://codedump.blergh.be/' }
2121
s.source = { :git => 'https://github.com/Inferis/ViewDeck.git',
22-
:tag => '2.2.3'}
22+
:tag => '2.2.4'}
2323
s.source_files = 'ViewDeck/*.{h,m}'
2424
s.frameworks = 'QuartzCore'
2525
end

ViewDeck/IISideController.h

+13-1
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,20 @@
1010

1111
@interface IISideController : IIWrapController
1212

13-
@property (nonatomic, assign) BOOL animatedShrink; // if the shrink action should participate in any ongoing animation. Defaults to NO.
13+
@property (nonatomic, assign) CGFloat constrainedSize;
1414

1515
- (id)initWithViewController:(UIViewController*)controller constrained:(CGFloat)constrainedSize;
1616

17+
- (void)shrinkSide;
18+
- (void)shrinkSideAnimated:(BOOL)animated;
19+
1720
@end
21+
22+
23+
// category on UIViewController to provide access to the sideController in the
24+
// contained viewcontrollers, a la UINavigationController.
25+
@interface UIViewController (IISideController)
26+
27+
@property(nonatomic,readonly,retain) IISideController *sideController;
28+
29+
@end

ViewDeck/IISideController.m

+36-14
Original file line numberDiff line numberDiff line change
@@ -19,22 +19,18 @@ @interface IISideController ()
1919

2020
@end
2121

22-
@implementation IISideController {
23-
CGFloat _constrainedSize;
24-
}
22+
@implementation IISideController
2523

2624
- (id)initWithViewController:(UIViewController*)controller constrained:(CGFloat)constrainedSize {
2725
if ((self = [super initWithViewController:controller])) {
2826
_constrainedSize = constrainedSize;
29-
_animatedShrink = NO;
3027
}
3128
return self;
3229
}
3330

3431
- (id)initWithViewController:(UIViewController*)controller {
3532
if ((self = [super initWithViewController:controller])) {
3633
_constrainedSize = -1;
37-
_animatedShrink = NO;
3834
}
3935
return self;
4036
}
@@ -46,26 +42,40 @@ - (void)viewDidLoad {
4642

4743
- (void)viewWillAppear:(BOOL)animated {
4844
[super viewWillAppear:animated];
49-
[CATransaction begin];
50-
if (!self.animatedShrink) {
51-
[CATransaction setValue:(id)kCFBooleanTrue forKey:kCATransactionDisableActions];
52-
}
45+
5346
self.view.backgroundColor = self.wrappedController.view.backgroundColor;
54-
[CATransaction commit];
55-
[self shrinkSide];
47+
[self shrinkSideAnimated:animated];
5648
}
5749

5850
- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
5951
[super willAnimateRotationToInterfaceOrientation:toInterfaceOrientation duration:duration];
60-
[self shrinkSide];
52+
[self shrinkSideAnimated:YES];
53+
}
54+
55+
- (void)setConstrainedSize:(CGFloat)constrainedSize {
56+
[self setConstrainedSize:constrainedSize animated:YES];
57+
}
58+
59+
- (void)setConstrainedSize:(CGFloat)constrainedSize animated:(BOOL)animated {
60+
_constrainedSize = constrainedSize;
61+
[self shrinkSideAnimated:animated];
6162
}
6263

6364
- (void)shrinkSide {
65+
[self shrinkSideAnimated:YES];
66+
}
67+
68+
- (void)shrinkSideAnimated:(BOOL)animated {
6469
if (self.viewDeckController) {
6570
// we don't want this animated
6671
[CATransaction begin];
67-
if (!self.animatedShrink) {
68-
[CATransaction setValue:(id)kCFBooleanTrue forKey:kCATransactionDisableActions];
72+
if (animated) {
73+
[UIView beginAnimations:@"shrinkSide" context:nil];
74+
[UIView setAnimationDuration:0.3];
75+
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
76+
}
77+
else {
78+
[CATransaction disableActions];
6979
}
7080

7181
if (self.viewDeckController.leftController == self) {
@@ -85,8 +95,20 @@ - (void)shrinkSide {
8595
self.wrappedController.view.frame = II_CGRectOffsetTopAndShrink(self.view.bounds, offset);
8696
}
8797

98+
if (animated) {
99+
[UIView commitAnimations];
100+
}
88101
[CATransaction commit];
89102
}
90103
}
91104

92105
@end
106+
107+
108+
@implementation UIViewController (IISideController)
109+
110+
- (IISideController*)sideController {
111+
return (IISideController*)self.wrapController;
112+
}
113+
114+
@end

0 commit comments

Comments
 (0)