Skip to content
This repository has been archived by the owner on Jul 12, 2019. It is now read-only.

Commit

Permalink
Allow multiple states when setting swipe gesture (#55).
Browse files Browse the repository at this point in the history
  • Loading branch information
alikaragoz committed Jan 22, 2014
1 parent 7b4bd08 commit a59c36c
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 37 deletions.
10 changes: 5 additions & 5 deletions MCSwipeTableViewCell/MCSwipeTableViewCell.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,22 @@
@class MCSwipeTableViewCell;

/** Describes the state that has been triggered by the user. */
typedef NS_ENUM(NSUInteger, MCSwipeTableViewCellState) {
typedef NS_OPTIONS(NSUInteger, MCSwipeTableViewCellState) {

/** No state has been triggered. */
MCSwipeTableViewCellStateNone = 0,

/** 1st state triggered during a Left -> Right swipe. */
MCSwipeTableViewCellState1,
MCSwipeTableViewCellState1 = (1 << 0),

/** 2nd state triggered during a Left -> Right swipe. */
MCSwipeTableViewCellState2,
MCSwipeTableViewCellState2 = (1 << 1),

/** 1st state triggered during a Right -> Left swipe. */
MCSwipeTableViewCellState3,
MCSwipeTableViewCellState3 = (1 << 2),

/** 2nd state triggered during a Right -> Left swipe. */
MCSwipeTableViewCellState4
MCSwipeTableViewCellState4 = (1 << 3)
};

/** Describes the mode used during a swipe */
Expand Down
57 changes: 25 additions & 32 deletions MCSwipeTableViewCell/MCSwipeTableViewCell.m
Original file line number Diff line number Diff line change
Expand Up @@ -222,40 +222,33 @@ - (void)setSwipeGestureWithView:(UIView *)view
NSParameterAssert(color);

// Depending on the state we assign the attributes
switch (state) {
case MCSwipeTableViewCellState1: {
_completionBlock1 = completionBlock;
_view1 = view;
_color1 = color;
_modeForState1 = mode;

} break;

case MCSwipeTableViewCellState2: {
_completionBlock2 = completionBlock;
_view2 = view;
_color2 = color;
_modeForState2 = mode;
} break;

case MCSwipeTableViewCellState3: {
_completionBlock3 = completionBlock;
_view3 = view;
_color3 = color;
_modeForState3 = mode;
} break;

case MCSwipeTableViewCellState4: {
_completionBlock4 = completionBlock;
_view4 = view;
_color4 = color;
_modeForState4 = mode;
} break;

default:
break;
if ((state & MCSwipeTableViewCellState1) == MCSwipeTableViewCellState1) {
_completionBlock1 = completionBlock;
_view1 = view;
_color1 = color;
_modeForState1 = mode;
}

if ((state & MCSwipeTableViewCellState2) == MCSwipeTableViewCellState2) {
_completionBlock2 = completionBlock;
_view2 = view;
_color2 = color;
_modeForState2 = mode;
}

if ((state & MCSwipeTableViewCellState3) == MCSwipeTableViewCellState3) {
_completionBlock3 = completionBlock;
_view3 = view;
_color3 = color;
_modeForState3 = mode;
}

if ((state & MCSwipeTableViewCellState4) == MCSwipeTableViewCellState4) {
_completionBlock4 = completionBlock;
_view4 = view;
_color4 = color;
_modeForState4 = mode;
}
}

#pragma mark - Handle Gestures
Expand Down

0 comments on commit a59c36c

Please sign in to comment.