A Swift library for swipeable table cells

Overview

BWSwipeRevealCell

Example

Using the library

**Note: Use version 1.0.1 for Swift 2.3 support and version 2.0.0 or higher for Swift 3 support **

There are two main classes available - BWSwipeCell and BWSwipeRevealCell

BWSwipeCell - Only contains the pan gesture handling, and is useful mainly for heavy customization through subclassing if all you need is a leg up on swipe interactions

BWSwipeRevealCell - Is an out of the box solution that lets you set images and colors for 1 action on the left and right of the table cell. BWSwipeRevealCell is a subclass of BWSwipeCell.

BWSwipeRevealCell Example

After setting BWSwipeRevealCell as your table cell's type in the storyboard and setting a delegate. Use this code in your controller:

    
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath) as! BWSwipeRevealCell
        
        swipeCell.bgViewLeftImage = UIImage(named:"Done")!.withRenderingMode(.alwaysTemplate)
        swipeCell.bgViewLeftColor = UIColor.green
        
        swipeCell.bgViewRightImage = UIImage(named:"Delete")!.withRenderingMode(.alwaysTemplate)
        swipeCell.bgViewRightColor = UIColor.red
        
        swipeCell.type = .springRelease
        
        swipeCell.delegate = self // Or whatever your delegate might be
        return cell
    }

Customizing through the interface

BWSwipeCell Properties

var type:BWSwipeCellType

Can be .springRelease, .swipeThrough or .slidingDoor. Defaults to .springRelease

var revealDirection: BWSwipeCellRevealDirection

Can be .both, .left or .right. Defaults to .both

(readonly) var state: BWSwipeCellState

Can be .normal, .pastThresholdLeft or .pastThresholdRight

var threshold: CGFloat

The point at which pan elasticity starts, and state changes. Defaults to the height of the UITableViewCell (i.e. when it form a perfect square)

(readonly) var progress:CGFloat

A number between 0 and 1 to indicate progress toward reaching threshold in the current swiping direction. Useful for changing UI gradually as the user swipes.

var shouldExceedThreshold: Bool

Control whether or not the cell pans past the threshold point

var panElasticityFactor: CGFloat

Control how much elasticity there is past threshold, if it can be exceeded. Default is 0.7 and 1.0 would mean no elastic resistance

var animationDuration: Double

Animation duration. Defaults to 0.2

weak var delegate: BWSwipeCellDelegate?

Set the delegate on the cell

@objc public protocol BWSwipeCellDelegate: NSObjectProtocol {
    optional func swipeCellDidStartSwiping(cell: BWSwipeCell)
    optional func swipeCellDidSwipe(cell: BWSwipeCell)
    optional func swipeCellWillRelease(cell: BWSwipeCell)
    optional func swipeCellDidCompleteRelease(cell: BWSwipeCell)
    optional func swipeCellDidChangeState(cell: BWSwipeCell)
}

BWSwipeRevealCell Properties

var bgViewInactiveColor: UIColor

var bgViewLeftColor: UIColor

var bgViewRightColor: UIColor

Colors for inactive, and activated states for left and right

var bgViewLeftImage: UIImage?

var bgViewRightImage: UIImage?

Images for the left and right actions

weak var delegate: BWSwipeRevealCellDelegate?

@objc public protocol BWSwipeRevealCellDelegate:BWSwipeCellDelegate {
    optional func swipeCellActivatedAction(cell: BWSwipeCell, isActionLeft: Bool)
}

Set the delegate on the cell

Roadmap

Some brief ideas on ways to improve this library

v 1.x.0 (Swift 2.x version)

  • Complete
v 2.x.0 (Swift 3.x version)
  • Fix bugs
v 3.0.0
v x.0.0 (a.k.a. Ideas. PRs welcome.)
  • Customizable interaction per side (i.e. left .SwipeThrough, right .SlidingDoor)
  • Possible subclass for allowing .SlidingDoor to convert to .SwipeThrough past a threshold point (see Mail.app)
Comments
  • Add Carthage support

    Add Carthage support

    • Share scheme to enable Carthage builds.
    • Remove extra files from build target to fix command-line build errors.

    TODO:

    • tag latest release (Carthage only picks up tagged releases)
    opened by ewerx 4
  • Swift 3.0 support

    Swift 3.0 support

    Make sure that the code is Swift 3.0 ready and adjust the APIs in accordance with rules outlined in the WWDC 2016 Swift API Guidelines

    https://developer.apple.com/videos/play/wwdc2016/403/

    enhancement 
    opened by bitwit 4
  • Expose BWSwipeCell for subclassing

    Expose BWSwipeCell for subclassing

    This framework is pretty useful, but BWSwipeRevealCell doesn't do quite what I'd like. I think it would be useful if you allowed BWSwipeCell to be subclassed in addition to BWSwipeRevealCell.

    feature request 
    opened by emuye 4
  • Help with CustomCell + BWSwipeRevealCell

    Help with CustomCell + BWSwipeRevealCell

    I created a CustomCell that I subclassed from BWSwipeRevealCell. And in the ViewController's cellForRowAtIndexPath I have these lines added:

    let swipeCell:BWSwipeRevealCell = cell as! BWSwipeRevealCell swipeCell.bgViewRightImage = UIImage(named:"delete_icon")!.imageWithRenderingMode(.AlwaysTemplate) swipeCell.bgViewRightColor = UIColor.redColor() swipeCell.type = .SlidingDoor swipeCell.delegate = self return swipeCell

    I see the Right View but it is not triggering any action. The swipeCellActivatedAction method is never called. It would be helpful if you can provide any solutions/workarounds.

    question 
    opened by AnnieNinaJoyceV 3
  • Preparations for V1.0.0 release

    Preparations for V1.0.0 release

    Related to #4

    • Fixes to example project and print calls in all delegate callbacks
    • Update to the way some properties are used to take advantage of lazy and private(set) keywords
    • Small fix to new threshold delegate callback so that it only fires the moment threshold is passed and state changes
    opened by bitwit 2
  • Support for updating constraint offset rather then animating contentView.frame

    Support for updating constraint offset rather then animating contentView.frame

    I've been able to use this library to achieve the following: example

    However this meant having to override any function that references contentView.frame.

    It would be great to be able to have support for updating the offset using a closure rather than animating the content view frame...

    opened by markst 2
  • make initWithStyle public

    make initWithStyle public

    As I've mention you should consider make method override init(style: UITableViewCellStyle, reuseIdentifier: String?) { public

    The reason people need it that is subclassing your cell to make custom UI. I simply cannot see this method from framework.

    enhancement 
    opened by tereks 1
  • (WIP): Refactor for maximizing customization capabilities and cleaner design

    (WIP): Refactor for maximizing customization capabilities and cleaner design

    (Currently incomplete, but...)

    • ~~Swift 3.0 syntax [Closes #8]~~ To be rebase on 2.0.0
    • Swipe logic extracted to a generic swipe handler
    • Support for UICollectionViewCell [Closes #9]
    • Configuration encapsulated in a struct, including settings for all interaction behaviour, including release animations [Related to #7]
    opened by bitwit 0
Releases(3.0.0)
Owner
Kyle Newsome
Kyle Newsome
A cells of UITableView can be rearranged by drag and drop.

TableViewDragger This is a demo that uses a TableViewDragger. Appetize's Demo Requirements Swift 4.2 iOS 8.0 or later How to Install TableViewDragger

Kyohei Ito 515 Dec 28, 2022
Dynamically hide / show cells of static UITableViewController

Dynamically hide / show cells of static UITableViewController, Swift Port of StaticDataTableViewController. Installation CocoaPods pod 'StaticTableVie

muyexi 26 Sep 16, 2022
MultiplyTypeCellExample - An example of the implementation of different types of cells in a tableview

MultiplyTypeCellExample An example of the implementation of different types of c

Marina Demchenko 0 Feb 13, 2022
Simple static table views for iOS in Swift.

Simple static table views for iOS in Swift. Static's goal is to separate model data from presentation. Rows and Sections are your “view models” for yo

Venmo 1.3k Nov 19, 2022
TableViews - Emoji Table View For iOS With Swift

TableViews Hello! This is EmojiTableView. Let me introduce you my first app when

null 0 Jan 2, 2022
Use Yelp API to fetch restuarants around a location and show them in a table view

Yelp Use Yelp API to fetch restuarants around a location and show them in a table view - Infinite scrolling, Prefetching, Image Caching. Design Patter

null 0 Nov 1, 2021
Using UI Table View

News-App Table View와 Table view controller Table View : Table의 크기를 지정할 수 있다. Table View Controller: 전체의 뷰가 하나의 테이블 Table View Table view 구성요소 결정하기 어떤

Jiwon 0 Dec 9, 2021
Typed, yet Flexible Table View Controller

ConfigurableTableViewController Simple view controller that provides a way to configure a table view with multiple types of cells while keeping type s

Arek Holko 270 Oct 15, 2022
Type-safe declarative table views.

TableKit TableKit is a super lightweight yet powerful generic library that allows you to build complex table views in a declarative type-safe manner.

Max Sokolov 694 Dec 13, 2022
Generic table view controller with external data processing

FlexibleTableViewController Swift library of generic table view controller with external data processing of functionality, like determine cell's reuse

Dmytro Pylypenko 9 May 20, 2018
A UITableView extension that enables cell insertion from the bottom of a table view.

ReverseExtension UITableView extension that enabled to insert cell from bottom of tableView. Concept It is difficult to fill a tableview content from

Taiki Suzuki 1.7k Dec 15, 2022
This framework allows you to build Table views using UIKit with syntax similar to SwiftUI

This framework allows you to build Table views using UIKit with syntax similar to SwiftUI

Fun 60 Dec 17, 2022
Swift package for easily rendering text tables. Inspired by the Python tabulate library.

TextTable Easily print textual tables in Swift. Inspired by the Python tabulate library. Upcoming Changes See details on an upcoming change.

Cristian Filipov 102 Jan 5, 2023
VTMagic is a page container library for iOS.

VTMagic VTMagic is a page container library for iOS, you can custom every page controller by different identifier if you need. It's so easy to use!(中文

Victor Tian 1.8k Dec 28, 2022
Objective-C library for drag-n-drop of UITableViewCells in a navigation hierarchy of view controllers.

ios-dragable-table-cells Support for drag-n-drop of UITableViewCells in a navigation hierarchy of view controllers. You drag cells by tapping and hold

Anders Borum 49 Aug 23, 2022
A simple way to create a UITableView for settings in Swift.

QuickTableViewController A simple way to create a table view for settings, including: Table view cells with UISwitch Table view cells with center alig

Cheng-Yao Lin 525 Dec 20, 2022
A pixel perfect replacement for UITableView section index, written in Swift

MYTableViewIndex MYTableViewIndex is a re-implementation of UITableView section index. This control is usually seen in apps displaying contacts, track

Yury 520 Oct 27, 2022
A no-nonsense way to write cleaner UITableViewDelegate and UITableViewDataSource in Swift.

CascadingTableDelegate A no-nonsense way to write cleaner UITableViewDelegate and UITableViewDataSource. Why is this library made? In common iOS devel

Ricardo Pramana Suranta 920 Dec 14, 2022