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

Commit

Permalink
Merge pull request #53 from alikaragoz/dev
Browse files Browse the repository at this point in the history
Merge of changes made in dev branch.
  • Loading branch information
alikaragoz committed Jan 16, 2014
2 parents 5821fd2 + b732d8d commit 7b4bd08
Show file tree
Hide file tree
Showing 10 changed files with 853 additions and 544 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2013 Ali Karagoz (http://alikaragoz.net/)
Copyright (c) 2014 Ali Karagoz (http://alikaragoz.net/)

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion MCSwipe Demo/MCSwipe Demo/MCAppDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// MCSwipeTableViewCell
//
// Created by Ali Karagoz on 24/02/13.
// Copyright (c) 2013 Mad Castle. All rights reserved.
// Copyright (c) 2014 Ali Karagoz. All rights reserved.
//

#import <UIKit/UIKit.h>
Expand Down
2 changes: 1 addition & 1 deletion MCSwipe Demo/MCSwipe Demo/MCAppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// MCAppDelegate.m
// MCSwipeTableViewCell
// Created by Ali Karagoz on 24/02/13.
// Copyright (c) 2013 Mad Castle. All rights reserved.
// Copyright (c) 2014 Ali Karagoz. All rights reserved.
//

#import "MCAppDelegate.h"
Expand Down
2 changes: 1 addition & 1 deletion MCSwipe Demo/MCSwipe Demo/MCTableViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// MCSwipeTableViewCell
//
// Created by Ali Karagoz on 24/02/13.
// Copyright (c) 2013 Mad Castle. All rights reserved.
// Copyright (c) 2014 Ali Karagoz. All rights reserved.
//

@interface MCTableViewController : UITableViewController
Expand Down
249 changes: 143 additions & 106 deletions MCSwipe Demo/MCSwipe Demo/MCTableViewController.m

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion MCSwipe Demo/MCSwipe Demo/main.m
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// MCSwipe Demo
//
// Created by Ali Karagoz on 02/03/13.
// Copyright (c) 2013 Mad Castle. All rights reserved.
// Copyright (c) 2014 Ali Karagoz. All rights reserved.
//

#import <UIKit/UIKit.h>
Expand Down
4 changes: 2 additions & 2 deletions MCSwipeTableViewCell.podspec
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
Pod::Spec.new do |s|
s.name = 'MCSwipeTableViewCell'
s.version = '1.2.0'
s.version = '2.0.0'
s.author = { 'Ali Karagoz' => '[email protected]' }
s.homepage = 'https://github.com/alikaragoz/MCSwipeTableViewCell'
s.summary = 'Mailbox app style UITableViewCell.'
s.license = 'MIT'
s.source = { :git => 'https://github.com/alikaragoz/MCSwipeTableViewCell.git', :tag => '1.2.0' }
s.source = { :git => 'https://github.com/alikaragoz/MCSwipeTableViewCell.git', :tag => '2.0.0' }
s.source_files = 'MCSwipeTableViewCell'
s.platform = :ios
s.ios.deployment_target = '5.0'
Expand Down
238 changes: 168 additions & 70 deletions MCSwipeTableViewCell/MCSwipeTableViewCell.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,107 +3,205 @@
// MCSwipeTableViewCell
//
// Created by Ali Karagoz on 24/02/13.
// Copyright (c) 2013 Mad Castle. All rights reserved.
// Copyright (c) 2014 Ali Karagoz. All rights reserved.
//

#import <UIKit/UIKit.h>

@class MCSwipeTableViewCell;

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

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

/** 1st state triggered during a Left -> Right swipe. */
MCSwipeTableViewCellState1,

/** 2nd state triggered during a Left -> Right swipe. */
MCSwipeTableViewCellState2,

/** 1st state triggered during a Right -> Left swipe. */
MCSwipeTableViewCellState3,

/** 2nd state triggered during a Right -> Left swipe. */
MCSwipeTableViewCellState4
};

typedef NS_ENUM(NSUInteger, MCSwipeTableViewCellDirection) {
MCSwipeTableViewCellDirectionLeft = 0,
MCSwipeTableViewCellDirectionCenter,
MCSwipeTableViewCellDirectionRight
};

/** Describes the mode used during a swipe */
typedef NS_ENUM(NSUInteger, MCSwipeTableViewCellMode) {
/** Disabled swipe. */
MCSwipeTableViewCellModeNone = 0,

/** Upon swipe the cell if exited from the view. Useful for destructive actions. */
MCSwipeTableViewCellModeExit,

/** Upon swipe the cell if automatically swiped back to it's initial position. */
MCSwipeTableViewCellModeSwitch
};

@protocol MCSwipeTableViewCellDelegate <NSObject>
/**
* `MCSwipeCompletionBlock`
*
* @param cell Currently swiped `MCSwipeTableViewCell`.
* @param state `MCSwipeTableViewCellState` which has been triggered.
* @param mode `MCSwipeTableViewCellMode` used for for swiping.
*
* @return No return value.
*/
typedef void (^MCSwipeCompletionBlock)(MCSwipeTableViewCell *cell, MCSwipeTableViewCellState state, MCSwipeTableViewCellMode mode);

@optional
@protocol MCSwipeTableViewCellDelegate;

// When the user starts swiping the cell this method is called
- (void)swipeTableViewCellDidStartSwiping:(MCSwipeTableViewCell *)cell;
@interface MCSwipeTableViewCell : UITableViewCell

// When the user ends swiping the cell this method is called
- (void)swipeTableViewCellDidEndSwiping:(MCSwipeTableViewCell *)cell;
/** Delegate of `MCSwipeTableViewCell` */
@property (nonatomic, assign) id <MCSwipeTableViewCellDelegate> delegate;

// When the user is dragging, this method is called and return the dragged percentage from the border
- (void)swipeTableViewCell:(MCSwipeTableViewCell *)cell didSwipWithPercentage:(CGFloat)percentage;
/**
* Damping of the physical spring animation. Expressed in percent.
*
* @dicussion Only applied for version of iOS > 7.
*/
@property (nonatomic, assign, readwrite) CGFloat damping;

// When the user releases the cell, after swiping it, this method is called
- (void)swipeTableViewCell:(MCSwipeTableViewCell *)cell didEndSwipingSwipingWithState:(MCSwipeTableViewCellState)state mode:(MCSwipeTableViewCellMode)mode;
/**
* Velocity of the spring animation. Expressed in points per second (pts/s).
*
* @dicussion Only applied for version of iOS > 7.
*/
@property (nonatomic, assign, readwrite) CGFloat velocity;

@end
/** Duration of the animations. */
@property (nonatomic, assign, readwrite) NSTimeInterval animationDuration;

@interface MCSwipeTableViewCell : UITableViewCell

@property (nonatomic, assign) id <MCSwipeTableViewCellDelegate> delegate;
/** Color for background, when no state has been triggered. */
@property (nonatomic, strong, readwrite) UIColor *defaultColor;


/** 1st `UIColor` of the state triggered during a Left -> Right swipe. */
@property (nonatomic, strong, readwrite) UIColor *color1;

/** 2nd `UIColor` of the state triggered during a Left -> Right swipe. */
@property (nonatomic, strong, readwrite) UIColor *color2;

/** 1st `UIColor` of the state triggered during a Right -> Left swipe. */
@property (nonatomic, strong, readwrite) UIColor *color3;

/** 2nd `UIColor` of the state triggered during a Right -> Left swipe. */
@property (nonatomic, strong, readwrite) UIColor *color4;


/** 1st `UIView` of the state triggered during a Left -> Right swipe. */
@property (nonatomic, strong, readwrite) UIView *view1;

/** 2nd `UIView` of the state triggered during a Left -> Right swipe. */
@property (nonatomic, strong, readwrite) UIView *view2;

/** 1st `UIView` of the state triggered during a Right -> Left swipe. */
@property (nonatomic, strong, readwrite) UIView *view3;

/** 2nd `UIView` of the state triggered during a Right -> Left swipe. */
@property (nonatomic, strong, readwrite) UIView *view4;


/** 1st `MCSwipeCompletionBlock` of the state triggered during a Left -> Right swipe. */
@property (nonatomic, copy, readwrite) MCSwipeCompletionBlock completionBlock1;

/** 2nd `MCSwipeCompletionBlock` of the state triggered during a Left -> Right swipe. */
@property (nonatomic, copy, readwrite) MCSwipeCompletionBlock completionBlock2;

@property (nonatomic, copy) NSString *firstIconName;
@property (nonatomic, copy) NSString *secondIconName;
@property (nonatomic, copy) NSString *thirdIconName;
@property (nonatomic, copy) NSString *fourthIconName;
/** 1st `MCSwipeCompletionBlock` of the state triggered during a Right -> Left swipe. */
@property (nonatomic, copy, readwrite) MCSwipeCompletionBlock completionBlock3;

/** 2nd `MCSwipeCompletionBlock` of the state triggered during a Right -> Left swipe. */
@property (nonatomic, copy, readwrite) MCSwipeCompletionBlock completionBlock4;

@property (nonatomic, strong) UIColor *firstColor;
@property (nonatomic, strong) UIColor *secondColor;
@property (nonatomic, strong) UIColor *thirdColor;
@property (nonatomic, strong) UIColor *fourthColor;

// Percentage of when the first and second action are activated, respectively
@property (nonatomic, assign) CGFloat firstTrigger;
@property (nonatomic, assign) CGFloat secondTrigger;

// Color for background, when any state hasn't triggered yet
@property (nonatomic, strong) UIColor *defaultColor;

// This is the general mode for all states
// If a specific mode for a state isn't defined, this mode will be taken in action
@property (nonatomic, assign) MCSwipeTableViewCellMode mode;

// Individual mode for states
@property (nonatomic, assign) MCSwipeTableViewCellMode modeForState1;
@property (nonatomic, assign) MCSwipeTableViewCellMode modeForState2;
@property (nonatomic, assign) MCSwipeTableViewCellMode modeForState3;
@property (nonatomic, assign) MCSwipeTableViewCellMode modeForState4;

@property (nonatomic, assign) BOOL isDragging;
@property (nonatomic, assign) BOOL shouldDrag;
@property (nonatomic, assign) BOOL shouldAnimatesIcons;

- (id)initWithStyle:(UITableViewCellStyle)style
reuseIdentifier:(NSString *)reuseIdentifier
firstStateIconName:(NSString *)firstIconName
firstColor:(UIColor *)firstColor
secondStateIconName:(NSString *)secondIconName
secondColor:(UIColor *)secondColor
thirdIconName:(NSString *)thirdIconName
thirdColor:(UIColor *)thirdColor
fourthIconName:(NSString *)fourthIconName
fourthColor:(UIColor *)fourthColor;

- (void)setFirstStateIconName:(NSString *)firstIconName
firstColor:(UIColor *)firstColor
secondStateIconName:(NSString *)secondIconName
secondColor:(UIColor *)secondColor
thirdIconName:(NSString *)thirdIconName
thirdColor:(UIColor *)thirdColor
fourthIconName:(NSString *)fourthIconName
fourthColor:(UIColor *)fourthColor;


// Manually swipe to origin

/** Percentage value to trigger the 1st state of a swipe gesture. */
@property (nonatomic, assign, readwrite) CGFloat firstTrigger;

/** Percentage value to trigger the 2nd state of a swipe gesture. */
@property (nonatomic, assign, readwrite) CGFloat secondTrigger;


/** 1st `MCSwipeTableViewCellMode` of the state triggered during a Left -> Right swipe. */
@property (nonatomic, assign, readwrite) MCSwipeTableViewCellMode modeForState1;

/** 2nd `MCSwipeTableViewCellMode` of the state triggered during a Left -> Right swipe. */
@property (nonatomic, assign, readwrite) MCSwipeTableViewCellMode modeForState2;

/** 1st `MCSwipeTableViewCellMode` of the state triggered during a Right -> Left swipe. */
@property (nonatomic, assign, readwrite) MCSwipeTableViewCellMode modeForState3;

/** 2nd `MCSwipeTableViewCellMode` of the state triggered during a Right -> Left swipe. */
@property (nonatomic, assign, readwrite) MCSwipeTableViewCellMode modeForState4;


/** `BOOL` indicator to know if the cell is currently dragged. */
@property (nonatomic, assign, readonly) BOOL isDragging;

/** `BOOL` to enable/disable the draggability of a cell. */
@property (nonatomic, assign, readwrite) BOOL shouldDrag;

/** `BOOL` to enable/disable the animation of the view during the swipe. */
@property (nonatomic, assign, readwrite) BOOL shouldAnimateIcons;

/**
* Configures the properties of a cell.
*
* @param view `UIView` of the state triggered during a swipe.
* @param color `UIColor` of the state triggered during a swipe.
* @param mode `MCSwipeTableViewCellMode` used by the cell during a swipe.
* @param state `MCSwipeTableViewCellState` on which the properties are applied.
* @param completionBlock `MCSwipeCompletionBlock` of the state triggered during a swipe.
*/
- (void)setSwipeGestureWithView:(UIView *)view
color:(UIColor *)color
mode:(MCSwipeTableViewCellMode)mode
state:(MCSwipeTableViewCellState)state
completionBlock:(MCSwipeCompletionBlock)completionBlock;


/**
* Swiped back the cell to it's original position
*
* @param completion Callback block executed at the end of the animation.
*/
- (void)swipeToOriginWithCompletion:(void(^)(void))completion;

@end


@protocol MCSwipeTableViewCellDelegate <NSObject>

@optional

/**
* Called when the user starts swiping the cell.
*
* @param cell `MCSwipeTableViewCell` currently swiped.
*/
- (void)swipeTableViewCellDidStartSwiping:(MCSwipeTableViewCell *)cell;

/**
* Called when the user ends swiping the cell.
*
* @param cell `MCSwipeTableViewCell` currently swiped.
*/
- (void)swipeTableViewCellDidEndSwiping:(MCSwipeTableViewCell *)cell;

/**
* Called during a swipe.
*
* @param cell `MCSwipeTableViewCell` currently swiped.
* @param percentage Current percentage of the swipe movement. Percentage is calculated from the
* left of the table view.
*/
- (void)swipeTableViewCell:(MCSwipeTableViewCell *)cell didSwipeWithPercentage:(CGFloat)percentage;

@end
Loading

0 comments on commit 7b4bd08

Please sign in to comment.