-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTRPushBackController.h
130 lines (109 loc) · 4.24 KB
/
TRPushBackController.h
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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
//
// TRPushBackController.h
// TRPushBackControllerExample
//
// Created by Tom Redman on 2014-04-13.
// Copyright (c) 2014 Tom Redman. All rights reserved.
//
#import <UIKit/UIKit.h>
extern NSString * const kNotificationWillPushBack;
extern NSString * const kNotificationDidPushBack;
extern NSString * const kNotificationWillPullForward;
extern NSString * const kNotificationDidPullForward;
typedef void(^Completion)();
typedef NS_ENUM(NSInteger, TRPushBackSliderDirection) {
TRPushBackSliderDirectionLeft = 0,
TRPushBackSliderDirectionRight
};
@interface TRPushBackController : UIViewController
@property (nonatomic) CGFloat pushBackDistance;
@property (nonatomic) BOOL isPushedBack;
@property (nonatomic, strong) UIViewController *rootViewController;
@property (nonatomic, strong) UIViewController *leftViewController;
@property (nonatomic, strong) UIViewController *rightViewController;
@property (nonatomic, weak) IBOutlet UIButton *pushBackButton;
- (IBAction)pushBackButtonTapped:(id)sender;
/**-----------------------------------------------------------------------------
* @name Convenience initializer
* -----------------------------------------------------------------------------
*/
/** Returns a new `TRPushBackController` instance, using the default xib file.
*
* @return A new `TRPushBackController` instance.
*/
+ (instancetype)controller;
/**-----------------------------------------------------------------------------
* @name Pushing and pulling
* -----------------------------------------------------------------------------
*/
/** Performs the push back or pull forward animation as required.
*/
- (void)togglePush;
/** Performs the push back animation.
*
* The method fires the `kNotificationWillPushBack` and
* `kNotificationDidPushBack` notifications.
*/
- (void)pushBack;
- (void)pushBackWithCompletion:(Completion)completion;
/** Performs the pull forward animation
*
* The method fires the `kNotificationWillPullForward` and
* `kNotificationDidPullForward` notifications.
*/
- (void)pullForward;
- (void)pullForwardWithCompletion:(Completion)completion;
/**-----------------------------------------------------------------------------
* @name Adding root, left and right view controllers
* -----------------------------------------------------------------------------
*/
/** Adds the root view controller as a child view controller of
* TRPushBackController.
*
* This method will add the viewController provider as a childViewController
* of the TRPushBackController instance.
*
* This is your app's main view controller and fills the entire
* TRPushBackController (e.g., UINavigationController or UITableViewController)
*
* If set, prefersStatusBarHidden and preferredStatusBarStyle will return this
* view controllers respective values.
*
* @param viewController The UIViewController to add as the root of the
* TRPushBackController
*/
- (void)setRootViewController:(UIViewController *)viewController;
/** Adds the left view controller as a child view controller of
* TRPushBackController.
*
* This method will add the viewController provider as a childViewController
* of the TRPushBackController instance. It will be offset by 50pt and will
* move relatively to it's final position as the TRPushBackController is dragged
* or toggled by `revealViewControllerInDirection:`
*
* @param viewController The UIViewController to add to the left side of the
* TRPushBackController
*
* @see slide:
*/
- (void)setLeftViewController:(UIViewController *)viewController;
/** Adds the right view controller as a child view controller of
* TRPushBackController.
*
* This method will add the viewController provider as a childViewController
* of the TRPushBackController instance. It will be offset by 50pt and will
* move relatively to it's final position as the TRPushBackController is dragged
* or toggled by `revealViewControllerInDirection:`
*
* @param viewController The UIViewController to add to the right side of the
* TRPushBackController
*
* @see slide:
*/
- (void)setRightViewController:(UIViewController *)viewController;
/** Slides the TRPushBackController to the side inidicated
*
* @param direction The direction of the UIViewController to reveal
*/
- (void)slide:(TRPushBackSliderDirection)direction;
@end