• This repository has been archived on 13/Jun/2024
  • Stars
    star
    110
  • Rank 316,770 (Top 7 %)
  • Language
    Objective-C
  • License
    MIT License
  • Created about 9 years ago
  • Updated about 7 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

YMSwipeTableViewCell is a lightweight library that enables table view cell swiping.

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 increasing in proportion to the swipe content offset:

##Features

  • Users have complete control over the views exposed during a left or right swipe.

  • Configurable cell swipe effect:

    • Unmasking

- Trailing

* 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

  • Implement a new cell class using the UITableViewCell class category. In this new cell class, make sure to import the class category:
#import "UITableViewCell+Swipe.h"
  • Create the desired swipe views. In this demo app, a two-button view (YMTwoButtonSwipeView) is created for the right swipe view and a single-button view (YMOneButtonSwipeView) is created for the left swipe view.

  • Initialize the left and right views:

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.
[self addLeftView:self.leftSwipeView];
[self addRightView:self.rightSwipeView];
  • Set the swipe effect (the default value is YATableSwipeEffectUnmask):
[cell setSwipeEffect:YATableSwipeEffectUnmask];
  • Set the allowMultiple flag to enable multiple cells to be swiped at once if desired (default is NO):
self.allowMultiple = YES;
  • Set the swipeContainerViewBackgroundColor to change the default swipe container view background color (default color is grayColor).
self.swipeContainerViewBackgroundColor = [UIColor grayColor];
  • Set the right and left swipe snap threshold values (the default value is 0, so right or left snaps will always occur when a swipe is initiated):
self.rightSwipeSnapThreshold = self.bounds.size.width * 0.3;
self.leftSwipeSnapThreshold = self.bounds.size.width * 0.1;
  • Set the swipeBlock to notify the subviews and/or the view controller that a swipe is occurring:
[self setSwipeBlock:^(UITableViewCell *cell, CGPoint translation){
    if (translation.x < 0) {
        [rightView didSwipeWithTranslation:translation];
    }
    else {
        [leftView didSwipeWithTranslation:translation];
    }
}];
  • Set the modeChangedBlock to notify the subviews and/or view controller that a swipe mode has changed:
[self setModeChangedBlock:^(UITableViewCell *cell, YATableSwipeMode mode){
    [leftView didChangeMode:mode];
    [rightView didChangeMode:mode];
    
    if (weakSelf.delegate) {
        [weakSelf.delegate swipeableTableViewCell:weakSelf didCompleteSwipe:mode];
    }
}];
  • Optionally set the modeWillChangeBlock to notify the subviews and/or view controller that a swipe mode will change.

  • In your view controller's cellForRowAtIndexPath delegate, instantiate the table view cell.

- (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;
}

Installation

###Option 1 Clone repo and manually add source to project.

###Option 2 Carthage:

github "yammer/YMSwipeTableViewCell"

###Option 3 CocoaPods:

pod 'YMSwipeTableViewCell', '~> 2.1.1'

##Contributing

Use Github issues to track bugs and feature requests.

##Contact

Alda Luong

Sumit Kumar

##License

YMSwipeTableViewCell is available under the MIT license. See the LICENSE file for more info.

More Repositories

1

circuitbox

Circuit breaker built with large Ruby apps in mind.
Ruby
702
star
2

circuit-breaker-js

Hystrix-like circuit breaker for JavaScript.
JavaScript
265
star
3

tenacity

Dropwizard + Hystrix Module.
Java
203
star
4

model_attribute

ModelAttribute gem - attributes for non-ActiveRecord models
Ruby
126
star
5

breakerbox

Frontend for Tenacity + Archaius
Java
63
star
6

yam

The official Yammer Ruby gem..
Ruby
45
star
7

dropwizard-auth-ldap

Dropwizard Authentication Module for LDAP using JNDI.
Java
36
star
8

sched.do

Ruby
30
star
9

yam-python

A python wrapper around the Yammer API.
Python
29
star
10

telemetry

A dapper-like substance in Java.
Java
18
star
11

schedulizer

An app to manage schedules
JavaScript
15
star
12

dropwizard-testing-integration

Utilities for writing dropwizard integration tests.
Java
15
star
13

EspressoApplicationSample-

EspressoApplicationSample
Java
14
star
14

dotnet-yammersdk

dotnet-yammersdk - build windows universal apps using the yammer fabric
C#
10
star
15

ios-oauth-demo

A sample application to demonstrate how the Yammer OAuth API works.
Objective-C
9
star
16

ios-yammer-sdk

Yammer iOS SDK
Objective-C
8
star
17

backbone-component

A thin layer on top of Backbone's view class to add nested child views.
JavaScript
7
star
18

windows-phone-oauth-sdk-demo

SDK tools and a demo for Windows Phone users to consume the Yammer API via Oauth.
C#
7
star
19

JS_SDK_Sample

6
star
20

yammer-collections

Collections utilities which build on top of Guava and the standard collections library.
Java
6
star
21

docker-registry-cache

Shell
5
star
22

backups

Backups as a Service
Java
4
star
23

mcrouter-build-docker

An Ubuntu 12.04 package builder for mcrouter
Makefile
4
star
24

powershell_example

A Powershell example of using the Yammer Oauth 2 to retrieve a token
PowerShell
3
star
25

azure-table

Azure Table backed Guava Table implementation.
Java
3
star
26

yamoverflow

YamOverflow.
Ruby
3
star