This repository has been archived by the owner on Jun 13, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 20
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
0 parents
commit 8b96660
Showing
41 changed files
with
3,045 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,15 @@ | ||
# references: | ||
# * http://www.objc.io/issue-6/travis-ci.html | ||
# * https://github.com/supermarin/xcpretty#usage | ||
|
||
language: objective-c | ||
# cache: cocoapods | ||
# podfile: Example/Podfile | ||
# before_install: | ||
# - gem install cocoapods # Since Travis is not always on latest version | ||
# - pod install --project-directory=Example | ||
install: | ||
- gem install xcpretty --no-rdoc --no-ri --no-document --quiet | ||
script: | ||
- set -o pipefail && xcodebuild test -workspace Example/${POD_NAME}.xcworkspace -scheme ${POD_NAME}-Example -sdk iphonesimulator ONLY_ACTIVE_ARCH=NO | xcpretty -c | ||
- pod lib lint --quick |
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,19 @@ | ||
Copyright (c) 2015 Microsoft | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. |
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,145 @@ | ||
YMSwipeTableViewCell | ||
=============== | ||
|
||
YMSwipeTableViewCell is a lightweight library that enables table view cell swiping (seen in most mail applications). It is implemented as a UITableViewCell class category and can detect left or right horizontal swipes. Upon a left or right swipe, a swipe view is exposed. This library is meant to be flexible, so that any views can be exposed during a swipe and a myriad of actions can be taken during the swipe (e.g., swipe view animations, or cell snap back or destruction at the completion of a swipe). The example app shows the right view as two buttons and the left view as a single button with a checkmark's alpha animating in proportion to the swipe content offset: | ||
|
||
<p align="center"><img src="https://github.com/aluong-yammer/YMSwipeTableViewCell/tree/master/github-assets/YMSwipeTableViewCellSample.gif"/></p> | ||
|
||
###Features | ||
* Users have complete control over the views exposed during a left or right swipe. | ||
* Configurable cell swipe animation: | ||
Unmasking | ||
<p align="center"><img src="https://github.com/aluong-yammer/YMSwipeTableViewCell/tree/master/github-assets/YMSwipeTableViewCellUnmasking.gif”/></p> | ||
Trailing | ||
<p align="center"><img src="https://github.com/aluong-yammer/YMSwipeTableViewCell/tree/master/github-assets/YMSwipeTableViewCellTrailing.gif"/></p> | ||
* Block callback for cell swiping or cell mode change so that actions can be taken at any time during the swipe. | ||
* Configurable values for the snap-to-right or snap-to-left views threshold. | ||
* The ability to configure multiple cell swipe. | ||
* Low overhead and memory profile for the following reasons: | ||
- Swipe views are not added to the view until a swipe actually begins. | ||
- A cell snapshot, and not the actual cell content view, is used during the swipe animation. | ||
|
||
###Usage | ||
|
||
1. Implement a new cell class using the UITableViewCell class category. In this new cell class, make sure to import the class category: | ||
|
||
```objc | ||
#import "UITableViewCell+Swipe.h" | ||
``` | ||
|
||
2. Initialize the left and right views: | ||
|
||
```objc | ||
YMTwoButtonSwipeView *rightView = [[YMTwoButtonSwipeView alloc] initWithFrame:CGRectMake(0, 0, kRightSwipeViewWidth, YMTableViewCellHeight)]; | ||
YMOneButtonSwipeView *leftView = [[YMOneButtonSwipeView alloc] init]; | ||
|
||
self.rightSwipeView = rightView; | ||
self.leftSwipeView = leftView; | ||
``` | ||
Set the left or right views by calling addLeftView or addRightView. If no left view is added, then the left to right swipe is disabled. If no right view is added, then the right to left swipe is disabled. | ||
```objc | ||
[self addLeftView:self.leftSwipeView]; | ||
[self addRightView:self.rightSwipeView]; | ||
``` | ||
|
||
3. Set the swipe effect: | ||
|
||
```objc | ||
[cell setSwipeEffect:YATableSwipeEffectDefault]; | ||
``` | ||
4. Set the allowMultiple flag to enable multiple cells to be swiped at once if desired: | ||
```objc | ||
self.allowMultiple = YES; | ||
``` | ||
|
||
5. Set the swipeContainerViewBackgroundColor to change the default swipe container view background color. | ||
|
||
```objc | ||
self.swipeContainerViewBackgroundColor = [UIColor grayColor]; | ||
``` | ||
|
||
6. Set the right and left swipe snap threshold values: | ||
|
||
```objc | ||
self.rightSwipeSnapThreshold = self.bounds.size.width * 0.3; | ||
self.leftSwipeSnapThreshold = self.bounds.size.width * 0.1; | ||
``` | ||
|
||
7. Set the swipeBlock to notify the subviews and/or the view controller that a swipe is occurring: | ||
|
||
```objc | ||
[self setSwipeBlock:^(UITableViewCell *cell, CGPoint translation){ | ||
if (translation.x < 0) { | ||
[rightView didSwipeWithTranslation:translation]; | ||
} | ||
else { | ||
[leftView didSwipeWithTranslation:translation]; | ||
} | ||
}]; | ||
``` | ||
8. Set the modeChangedBlock to notify the subviews and/or view controller that a swipe mode has changed: | ||
```objc | ||
[self setModeChangedBlock:^(UITableViewCell *cell, YATableSwipeMode mode){ | ||
[leftView didChangeMode:mode]; | ||
[rightView didChangeMode:mode]; | ||
if (weakSelf.delegate) { | ||
[weakSelf.delegate swipeableTableViewCell:weakSelf didCompleteSwipe:mode]; | ||
} | ||
}]; | ||
``` | ||
|
||
9. Optionally set the modeWillChangeBlock to notify the subviews and/or view controller that a swipe mode will change. | ||
|
||
10. In your view controller's cellForRowAtIndexPath delegate, instantiate a table view cell. | ||
```objc | ||
- (UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ | ||
YMTableViewCell *cell = (YMTableViewCell*)[tableView dequeueReusableCellWithIdentifier:NSStringFromClass([YMTableViewCell class]) forIndexPath:indexPath]; | ||
cell.delegate = self; | ||
if (indexPath.row % 2 == 0) { | ||
[cell setSwipeEffect:YATableSwipeEffectDefault]; | ||
cell.textLabel.text = kYMSwipeTableViewCell0Title; | ||
cell.detailTextLabel.text = kYMSwipeTableViewCellDetailTitleSwipeLeftRight; | ||
cell.backgroundColor = [self unmaskingCellColor]; | ||
} else { | ||
[cell setSwipeEffect:YATableSwipeEffectTrail]; | ||
cell.textLabel.text = kYMSwipeTableViewCell1Title; | ||
cell.detailTextLabel.text = kYMSwipeTableViewCellDetailTitleSwipeLeftRight; | ||
cell.backgroundColor = [self trailingCellColor]; | ||
} | ||
|
||
return cell; | ||
} | ||
``` | ||
|
||
##Usage | ||
In your Podfile: | ||
<pre>pod 'YMTableViewCell', '~> 1.0.0'</pre> | ||
|
||
Or just clone this repo and manually add source to project | ||
|
||
|
||
##Contributing | ||
Use [Github issues](https://github.com/cewendel/SWTableViewCell/issues) to track bugs and feature requests. | ||
|
||
##Contact | ||
|
||
Alda Luong | ||
- https://github.com/aluong-yammer/ | ||
Sumit Kumar | ||
- https://github.com//appdios/ | ||
|
||
## License | ||
|
||
YMSwipeTableViewCell is available under the MIT license. See the LICENSE file for more info. | ||
|
||
|
||
|
||
|
||
|
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,14 @@ | ||
Pod::Spec.new do |s| | ||
s.name = 'YMSwipeTableViewCell' | ||
s.version = '1.0.0' | ||
s.summary = 'YMSwipeTableViewCell is a lightweight library that enables table view cell swiping.' | ||
s.description = 'YMSwipeTableViewCell is a lightweight library that enables table view cell swiping (seen in most mail applications). It is implemented as a UITableViewCell class category and can detect left or right horizontal swipes. Upon a left or right swipe, a swipe view is exposed. This library is meant to be flexible, so that any views can be exposed during a swipe and a myriad of actions can be taken during the swipe (e.g., swipe view animations, or cell snap back or destruction at the completion of a swipe).' | ||
s.homepage = 'https://github.com/aluong-yammer/YMSwipeTableViewCell.git' | ||
s.screenshots = 'https://github.com/aluong-yammer/YMSwipeTableViewCell/tree/master/github-assets/YMSwipeTableViewCellSample.gif' | ||
s.license = 'MIT' | ||
s.author = { 'Alda Luong' => 'alluong@microsoft.com', 'Sumit Kumar' => 'sumkuma@microsoft.com' } | ||
s.source = { :git => 'https://github.com/aluong-yammer/YMSwipeTableViewCell.git', :tag => '1.0.0' } | ||
s.platform = :ios, '7.0' | ||
s.requires_arc = true | ||
s.source_files = 'https://github.com/aluong-yammer/YMSwipeTableViewCell/tree/master/YMSwipeTableViewCell/PodFiles/*' | ||
end |
Oops, something went wrong.