forked from grp/tweaks
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
82 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
include theos/makefiles/common.mk | ||
|
||
TWEAK_NAME = SplitResizer | ||
SplitResizer_FILES = Tweak.xm | ||
SplitResizer_FRAMEWORKS = UIKit | ||
|
||
include $(THEOS_MAKE_PATH)/tweak.mk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{ Filter = { Bundles = ( "com.apple.UIKit" ); }; } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
|
||
#import <UIKit/UIKit.h> | ||
|
||
@interface UISplitViewController (Private) | ||
|
||
- (UIViewController *)masterViewController; | ||
- (UIViewController *)detailViewController; | ||
- (CGRect)_detailViewFrame; | ||
- (CGRect)_masterViewFrame; | ||
|
||
- (void)viewWillLayoutSubviews; | ||
|
||
@end | ||
|
||
@interface UINavigationController (Private) | ||
|
||
- (void)_layoutTopViewController; | ||
|
||
@end | ||
|
||
#define kHandleWidth 16.0f | ||
|
||
%hook UISplitViewController | ||
|
||
- (void)setGutterWidth:(CGFloat)width { | ||
%log; | ||
%orig(kHandleWidth); | ||
} | ||
|
||
%new(v@:@) | ||
- (void)panFromRecognizer:(UIPanGestureRecognizer *)recognizer { | ||
%log; | ||
|
||
if ([recognizer state] == UIGestureRecognizerStateBegan || [recognizer state] == UIGestureRecognizerStateChanged) { | ||
CGPoint location = [recognizer locationInView:self.view]; | ||
CGFloat offset = location.x - (kHandleWidth / 2); | ||
|
||
NSLog(@"Resizing view to offset: %f", offset); | ||
[self setMasterColumnWidth:offset]; | ||
if ([[self masterViewController] isKindOfClass:[UINavigationController class]]) | ||
[(UINavigationController *) [self masterViewController] _layoutTopViewController]; | ||
if ([[self detailViewController] isKindOfClass:[UINavigationController class]]) | ||
[(UINavigationController *) [self detailViewController] _layoutTopViewController]; | ||
[recognizer.view setFrame:CGRectMake(offset, 0, kHandleWidth, [self.view bounds].size.height)]; | ||
} | ||
} | ||
|
||
- (void)_commonInit { | ||
%orig; | ||
|
||
[self setGutterWidth:kHandleWidth]; | ||
|
||
UIView *dragView = [[UIView alloc] initWithFrame:CGRectMake([self masterColumnWidth], 0, kHandleWidth, [self.view bounds].size.height)]; | ||
[dragView setAutoresizingMask:UIViewAutoresizingFlexibleHeight]; | ||
[self.view addSubview:dragView]; | ||
[dragView release]; | ||
|
||
UIPanGestureRecognizer *panRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(panFromRecognizer:)]; | ||
[dragView addGestureRecognizer:panRecognizer]; | ||
[panRecognizer release]; | ||
} | ||
|
||
%end | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
Package: com.chpwn.splitresizer | ||
Name: SplitResizer | ||
Depends: mobilesubstrate | ||
Version: 0.0.1 | ||
Architecture: iphoneos-arm | ||
Description: An awesome MobileSubstrate tweak! | ||
Maintainer: Grant Paul | ||
Author: Grant Paul | ||
Section: Tweaks |