• Stars
    star
    215
  • Rank 178,022 (Top 4 %)
  • Language
    Objective-C
  • License
    MIT License
  • Created almost 11 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

AMBubbleTableView

AMBubbleTableViewController

Build Status

Simple implementation of a UITableView styled as chat bubbles. It's strongly based on Jesse Squires' MessagesTableViewController, since I needed to deeply customize the view, I decided to spawn a new library.

Please note

This library is no longer maintained. I strongly suggest to use Jesse's library, linked above. Want to adopt this library? Contact me in the issue section.

Screenshot

AMBubbleTableViewController

Setup with CocoaPods

  • Add pod 'AMBubbleTableViewController' to your Podfile
  • Run pod install
  • Run open App.xcworkspace
  • Import AMBubbleTableViewController.h in your AppDelegate
  • Subclass AMBubbleTableViewController from your controller
  • Provide a AMBubbleTableDataSource and AMBubbleTableDelegate

Setup without CocoaPods

  • Clone this repo
  • Add the AMBubbleTableViewController folder to your project
  • Import AMBubbleTableViewController.h in your AppDelegate
  • Subclass AMBubbleTableViewController from your controller
  • Provide a AMBubbleTableDataSource and AMBubbleTableDelegate

AMBubbleTableDataSource

You need to provide an object that implements the AMBubbleTableDataSource with all the data that you want to display. The required calls are:

- (NSInteger)numberOfRows;
- (AMBubbleCellType)cellTypeForRowAtIndexPath:(NSIndexPath *)indexPath;
- (NSString *)textForRowAtIndexPath:(NSIndexPath *)indexPath;
- (NSDate *)timestampForRowAtIndexPath:(NSIndexPath *)indexPath;

You can also optionally specify an avatar image, a username and its color:

- (UIImage*)avatarForRowAtIndexPath:(NSIndexPath *)indexPath;
- (NSString*)usernameForRowAtIndexPath:(NSIndexPath *)indexPath;
- (UIColor*)usernameColorForRowAtIndexPath:(NSIndexPath *)indexPath;

AMBubbleTableDelegate

Implement the delegate to receive the user's text:

- (void)didSendText:(NSString*)text;
- (void)swipedCellAtIndexPath:(NSIndexPath *)indexPath withFrame:(CGRect)frame andDirection:(UISwipeGestureRecognizerDirection)direction;
- (void)longPressedCellAtIndexPath:(NSIndexPath *)indexPath withFrame:(CGRect)frame;

Main styles

You can change the style of the AMBubbleTableViewController like this:

// After initialization
[self setTableStyle:AMBubbleTableStyleFlat];    // AMBubbleTableStyleDefault, AMBubbleTableStyleSquare, AMBubbleTableStyleFlat

Custom accessory view

AMBubbleTableViewController uses a second accessory view (it's separate from the standard accessory view) to display the avatar and the timestamp. You can customize this view by passing your accessory class in the options dictionary. Your class just needs to be a UIView's subclass and implement AMBubbleAccessory protocol:

- (id)setOptions:(NSDictionary*)options;
- (void)setupView:(NSDictionary*)params;

Where params is a dictionary containing the UIImage @"avatar" and the NSString @"date".

Options Dictionary

The AMBubbleTableViewController configuration can be handled by passing an NSDictionary to it. The default values can be found in AMBubbleGlobals.m. Here's a brief description of the possible options:

AMOptionsTableStyle             // @(AMBubbleTableCellStyle), Sets the table style. Defaults to AMBubbleTableCellDefault.
AMOptionsTimestampEachMessage   // @(BOOL), Enables the timestamp for each message. Defaults to @YES.
AMOptionsTimestampShortFont     // UIFont, Sets the short timestamp font. 
AMOptionsTimestampFont          // UIFont, Sets the full timestamp font.
AMOptionsAvatarSize             // @(float), The avatar size. Defaults to @50.
AMOptionsAccessoryClass         // NSString, The accessory view for each cell. Defaults to @"AMBubbleAccessoryView".
AMOptionsAccessorySize          // @(float), The accssory view size (used to compute the minimum cell height). Defaults to @50.
AMOptionsAccessoryMargin        // @(float), The accessory view margin. Defaults to @5.
AMOptionsTimestampHeight        // @(float), The height of the timestamp row. Defaults to @40.

Styling Options

You can also specify other styling options. AMBubbleTableViewController includes three styles, the default values of the following options differs from style to style. Check AMBubbleGlobals.m for more info.

AMOptionsImageIncoming          // UIImage, the left bubble stretchable image
AMOptionsImageOutgoing          // UIImage, the right bubble stretchable image
AMOptionsImageBar               // UIImage, the text bar background, resizable with cap insets
AMOptionsImageInput             // UIImage, the text view mask, resizable with cap insets
AMOptionsImageButton            // UIImage, the button image, resizable with cap insets
AMOptionsImageButtonHighlight   // UIImage, the highlighted button image, resizable with cap insets
AMOptionsTextFieldBackground    // UIColor, the textView color
AMOptionsTextFieldFont          // UIFont, the textView font
AMOptionsTextFieldFontColor     // UIColor, the textView font color
AMOptionsBubbleTableBackground  // UIColor, the tableView color
AMOptionsAccessoryPosition      // @(AMBubbleAccessoryPosition), defines wether the accessory should stay up or down
AMOptionsButtonOffset           // @(float), the vertical offset of the send button
AMOptionsBubbleTextColor        // UIColor, the main bubble's text color
AMOptionsBubbleTextFont         // UIFont, the main bubble's text font
AMOptionsUsernameFont           // UIFont, the username's text font
AMOptionsButtonFont             // UIFont, the button's text font
AMOptionsBubbleSwipeEnabled     // @(BOOL), enables the swipe detection on a cell
AMOptionsBubblePressEnabled     // @(BOOL), enables the long press detection on a cell
AMOptionsBubbleDetectionType    // @(int), the text detection type, refer to UIDataDetectorTypes. Defaults to UIDataDetectorTypeNone

Changelog

0.5

TODO

  • Add further customizations

MIT License

Copyright (c) 2013 Andrea Mazzini. All rights reserved.

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.

More Repositories

1

AMScrollingNavbar

Scrollable UINavigationBar that follows the scrolling of a UIScrollView
Swift
6,053
star
2

BubbleTransition

A custom modal transition that presents and dismiss a controller with an expanding bubble effect.
Swift
3,314
star
3

AMPopTip

An animated popover that pops out a given frame, great for subtle UI tips and onboarding.
Swift
3,140
star
4

AMWaveTransition

Custom transition between viewcontrollers holding tableviews
Objective-C
2,376
star
5

SubtleVolume

Replace the system volume popup with a more subtle indicator.
Swift
1,200
star
6

AMTagListView

UIScrollView subclass that allows to add a list of highly customizable tags.
Objective-C
759
star
7

UITextField-Shake

UITextField category that adds shake animation
Objective-C
738
star
8

GearRefreshControl

A custom animation for the UIRefreshControl
Swift
618
star
9

UIView-Shake

UIView category that adds shake animation
Objective-C
492
star
10

UIView-draggable

UIView category that adds dragging capabilities
Objective-C
435
star
11

ViralSwitch

A UISwitch that infects its superview with its tint color.
Objective-C
333
star
12

SlideOutNavigation

SlideOut Navigation Controller for iOS.
Objective-C
210
star
13

AMDraggableBlurView

Draggable blurred view.
Objective-C
66
star
14

one-icon-a-day

My 2015's challenge: design an icon a day.
28
star
15

UIView-Notify

UIView category for simple user notifications
Objective-C
12
star
16

AMTextField

A UITextField subclass with some nifty animations
Objective-C
7
star
17

Gitorade

Simple iOS app for educational purposes
Objective-C
3
star
18

iOS2016

Sample project shown in class ¯\_(ツ)_/¯
Swift
2
star
19

chatberry

A node.js+Express.js+socket.io chat
JavaScript
2
star
20

andreamazz.github.io

Syntax Error
HTML
1
star
21

zsh-peepcodelike

A Peepcode-like ZSH theme with dark background
1
star
22

whoisandrea.me

Code for the personal page http://whoisandrea.me/
CSS
1
star
23

AFHTTPRequestOperationManager-multipart

Adds multipart support for PUT and PATCH methods to the AFHTTPRequestOperationManager
Objective-C
1
star
24

pickdate-rails

Pickdate.js for Rails
Ruby
1
star
25

onealbum

One Album A Day. A simple rails blog
Ruby
1
star