Skip to content

Commit

Permalink
Added block handler for state transition
Browse files Browse the repository at this point in the history
  • Loading branch information
KieranLafferty committed Jun 25, 2013
1 parent af91bcb commit c4cf52e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
6 changes: 5 additions & 1 deletion Classes/KLNoteViewController.h
Expand Up @@ -7,6 +7,7 @@
//

#import <UIKit/UIKit.h>

@class KLNoteViewController;
@class KLControllerCard;
@protocol KLNoteViewControllerDataSource;
Expand All @@ -26,6 +27,8 @@ enum {
};
typedef UInt32 KLControllerCardPanGestureScope;

typedef void (^transitionStateBlock)(UIViewController* viewController, KLControllerCardState fromState, KLControllerCardState);

@protocol KLControllerCardDelegate <NSObject>
@optional
//Called on any time a state change has occured - even if a state has changed to itself - (i.e. from KLControllerCardStateDefault to KLControllerCardStateDefault)
Expand Down Expand Up @@ -57,6 +60,7 @@ typedef UInt32 KLControllerCardPanGestureScope;
@property (nonatomic, strong) UITapGestureRecognizer* tapGesture;
-(id) initWithNoteViewController: (KLNoteViewController*) noteViewController
andViewController:(UIViewController*) viewController;

-(void) toggleStateAnimated:(BOOL) animated;
-(void) setState:(KLControllerCardState) state animated:(BOOL) animated;
-(void) setYCoordinate:(CGFloat)yValue;
Expand All @@ -65,7 +69,7 @@ typedef UInt32 KLControllerCardPanGestureScope;

//KLNoteViewController manages the cards interfacing between the various cards
@interface KLNoteViewController : UIViewController <KLControllerCardDelegate>

@property (nonatomic, copy) transitionStateBlock stateTransitionBlock;
@property (nonatomic, weak) id<KLNoteViewControllerDataSource> dataSource;
@property (nonatomic, weak) id<KLNoteViewControllerDelegate> delegate;

Expand Down
4 changes: 3 additions & 1 deletion Classes/KLNoteViewController.m
Expand Up @@ -233,7 +233,6 @@ -(void) removeControllerCardFromSuperView {
}
}


- (NSArray*) controllerCardsAboveCard:(KLControllerCard*) card {
NSInteger index = [self indexForControllerCard:card];

Expand Down Expand Up @@ -316,6 +315,9 @@ -(void) controllerCard:(KLControllerCard*)controllerCard didChangeToDisplayState

}
-(void) noteViewController: (KLNoteViewController*) noteViewController didUpdateControllerCard:(KLControllerCard*)controllerCard toDisplayState:(KLControllerCardState) toState fromDisplayState:(KLControllerCardState) fromState {
if (self.stateTransitionBlock) {
self.stateTransitionBlock(controllerCard.viewController, fromState, toState);
}
if ([self.delegate respondsToSelector:@selector(noteViewController:didUpdateControllerCard:toDisplayState:fromDisplayState:)])
{
[self.delegate noteViewController:self
Expand Down
Binary file not shown.

0 comments on commit c4cf52e

Please sign in to comment.