An iOS UICollectionViewLayout subclass to show a list of contacts with configurable expandable items.

Overview

MEVHorizontalContacts

An iOS UICollectionViewLayout subclass to show a list of contacts with configurable expandable items.

CI Status Version License Platform Language

Features

  • Customizable contacts cells
  • Customizable contact items cells
  • Different sizes and responsive design
  • Multiple delegate methods

Demo App

Run the demo app and play with it! Demo App

Demo Project

To run the example project, clone the repo, and run pod install from the Example directory first.

Getting Started

Requirements

Requires iOS SDK version > 7.0

Requires ARC

Installation with CocoaPods

CocoaPods is a 3rd-party dependency manager for Swift and Objective-C projects. For more information, refer to the CocoaPods Getting Started Guide. Otherwise, you can install CocoaPods with the following command:

$ gem install cocoapods

Podfile

To integrate MEVHorizontalContacts into your Xcode project using CocoaPods, specify it in your Podfile:

source 'https://github.com/CocoaPods/Specs.git'
pod 'MEVHorizontalContacts'

Then, run the following command:

$ pod install

Installation Manually

To integrate MEVHorizontalContacts into your Xcode project manually, just include the filest from /Pod/Classes/ folder in your App’s Xcode project.

Then, import the following file your classes:

#import "MEVHorizontalContacts.h"

Quick Guide

Usage

1. Import class
#import "MEVHorizontalContacts.h"
2. Add Datasource and Delegate protocols.
@interface ViewController () <MEVHorizontalContactsDataSource, MEVHorizontalContactsDelegate>
@property (nonatomic, strong) MEVHorizontalContacts *horizontalContacts;
@end
3. Create, initialize and add MEVHorizontalContacts view.
_horizontalContacts = [MEVHorizontalContacts new];
_horizontalContacts.backgroundColor = [UIColor whiteColor];
_horizontalContacts.dataSource = self;
_horizontalContacts.delegate = self;
[self addSubview:_horizontalContacts];
[self addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|[horizontalContacts]|" options:NSLayoutFormatAlignAllCenterX metrics:nil views:@{@"horizontalContacts" : _horizontalContacts}]];
[self addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|[horizontalContacts]|" options:NSLayoutFormatAlignAllCenterY metrics:nil views:@{@"horizontalContacts" : _horizontalContacts}]];
4. Implement Datasource Methods
#pragma mark - MEVHorizontalContactsDataSource Methods

- (NSInteger)numberOfContacts;
- (NSInteger)numberOfItemsAtContactIndex:(NSInteger)index;
- (MEVHorizontalContactsCell *)contactAtIndex:(NSInteger)index;
- (MEVHorizontalContactsCell *)item:(NSInteger)item atContactIndex:(NSInteger)index;
- (UIEdgeInsets)horizontalContactsInsets;
- (NSInteger)horizontalContactsSpacing;
5. Implement Delegate Methods
#pragma mark - MEVHorizontalContactsDelegate Methods

- (void)contactSelectedAtIndex:(NSInteger)index;
- (void)item:(NSInteger)item selectedAtContactIndex:(NSInteger)index;

Example

Customization 1

- (MEVHorizontalContactsCell *)contactAtIndex:(NSInteger)index {
    MEVHorizontalContactsCell *cell = [_horizontalContacts dequeueReusableContactCellForIndex:index];
    [cell.imageView setImage:[UIImage imageNamed:[self getImageNameAtIndex:index]]];
    [cell.imageView.layer setBorderColor:[UIColor colorWithRed:34/255.0f green:167/255.0f blue:240/255.0f alpha:1].CGColor];
    [cell.imageView.layer setBorderWidth:1.0f];
    [cell.label setText:[self getUserNameAtIndex:index]];
    [cell.label setFont:[UIFont boldSystemFontOfSize:12.0f]];
    return cell;
}

- (MEVHorizontalContactsCell *)item:(NSInteger)item atContactIndex:(NSInteger)index {

    UIImage *image;
    NSString *labelText;
    switch (item) {
        case 0:
            labelText = @"Call";
            image = [UIImage imageNamed:@"actionCall"];
            break;
        case 1:
            labelText = @"Email";
            image = [UIImage imageNamed:@"actionEmail"];
            break;
        case 2:
            labelText = @"Message";
            image = [UIImage imageNamed:@"actionMessage"];
            break;
        default:
            labelText = @"Call";
            image = [UIImage imageNamed:@"actionCall"];
            break;
    }
    
    MEVHorizontalContactsCell *cell = [_horizontalContacts dequeueReusableItemCellForIndex:index];
    [cell.imageView setImage:image];
    [cell.imageView setTintColor:[UIColor colorWithRed:34/255.0f green:167/255.0f blue:240/255.0f alpha:1]];
    [cell.imageView.layer setBorderColor:[UIColor colorWithRed:34/255.0f green:167/255.0f blue:240/255.0f alpha:1].CGColor];
    [cell.imageView.layer setBorderWidth:1.0f];
    [cell.label setText:labelText];
    [cell.label setFont:[UIFont boldSystemFontOfSize:10.0f]];

    return cell;
}
Customization 2

- (MEVHorizontalContactsCell *)contactAtIndex:(NSInteger)index {
    MEVHorizontalContactsCell *cell = [_horizontalContacts dequeueReusableContactCellForIndex:index];
    [cell.imageView setImage:[UIImage imageNamed:[self getImageNameAtIndex:index]]];
    [cell.label setText:[self getUserNameAtIndex:index]];
    return cell;
}

- (MEVHorizontalContactsCell *)item:(NSInteger)item atContactIndex:(NSInteger)index {
    
    UIImage *image;
    NSString *labelText;
    switch (item) {
        case 0:
            labelText = @"Call";
            image = [UIImage imageNamed:@"actionCall"];
            break;
        case 1:
            labelText = @"Email";
            image = [UIImage imageNamed:@"actionEmail"];
            break;
        case 2:
            labelText = @"Message";
            image = [UIImage imageNamed:@"actionMessage"];
            break;
        default:
            labelText = @"Call";
            image = [UIImage imageNamed:@"actionCall"];
            break;
    }
    
    MEVHorizontalContactsCell *cell = [_horizontalContacts dequeueReusableItemCellForIndex:index];
    [cell.imageView setImage:image];
    [cell.imageView setBackgroundColor:[UIColor colorWithRed:34/255.0f green:167/255.0f blue:240/255.0f alpha:1]];
    [cell.imageView setTintColor:[UIColor whiteColor]];
    [cell.label setText:labelText];
    [cell.label setTextColor:[UIColor colorWithRed:34/255.0f green:167/255.0f blue:240/255.0f alpha:1]];
    return cell;
}

Roadmap

  • CocoaPods support
  • Carthage support
  • Tests

Change Log

See Changelog.md

Author

Apps using this library

License

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

Icons made by Gregor Cresnar is licensed by Creative Commons BY 3.0

You might also like...
Show the weather effects onto view written in Swift4.2
Show the weather effects onto view written in Swift4.2

URWeatherView What is this for? Showing some kinds of the weather effect, written in Swift4.2. This code style is the Protocol Oriented Programming. T

ToastSwiftUI-master - A simple way to show a toast or a popup in SwiftUI

ToastSwiftUI-master - A simple way to show a toast or a popup in SwiftUI

Simple and highly customizable iOS tag list view, in Swift.
Simple and highly customizable iOS tag list view, in Swift.

TagListView Simple and highly customizable iOS tag list view, in Swift. Supports Storyboard, Auto Layout, and @IBDesignable. Usage The most convenient

Reel Search is a Swift UI controller that allows you to choose options from a list
Reel Search is a Swift UI controller that allows you to choose options from a list

REEL SEARCH Reel Search is a Swift UI controller that allows you to choose options from a list We specialize in the designing and coding of custom UI

A controller that uses a UIStackView and view controller composition to display content in a list
A controller that uses a UIStackView and view controller composition to display content in a list

StackViewController Overview StackViewController is a Swift framework that simplifies the process of building forms and other static content using UIS

Advanced List View for SwiftUI with pagination & different states

AdvancedList This package provides a wrapper view around the SwiftUI List view which adds pagination (through my ListPagination package) and an empty,

List tree data souce to display hierachical data structures in lists-like way. It's UI agnostic, just like view-model and doesn't depend on UI framework
List tree data souce to display hierachical data structures in lists-like way. It's UI agnostic, just like view-model and doesn't depend on UI framework

SwiftListTreeDataSource List tree data souce to display hierachical data structures in lists-like way. It's UI agnostic, just like view-model, so can

Elimination-backoff stack is an unbounded lock-free LIFO linked list, that eliminates concurrent pairs of pushes and pops with exchanges.

Elimination-backoff stack is an unbounded lock-free LIFO linked list, that eliminates concurrent pairs of pushes and pops with exchanges. It uses compare-and-set (CAS) atomic operation to provide concurrent access with obstruction freedom. In order to support even greater concurrency, in case a push/pop fails, it tries to pair it with another pop/push to eliminate the operation through exchange of values.

UIStackView replica for iOS 7.x and iOS 8.x
UIStackView replica for iOS 7.x and iOS 8.x

TZStackView A wonderful layout component called the UIStackView was introduced with iOS 9. With this component it is really easy to layout components

Comments
  • Clear Background Color not working properly.

    Clear Background Color not working properly.

    When doing _horizontalContacts.backgroundColor = [UIColor clearColor]; , the background becomes black instead with a horizontal contacts copy visible in the background as well.

    How to fix this @manuelescrig ?

    opened by hyd00 2
  • An opportunity

    An opportunity

    Hello, I need help finishing an app. If you can help me, Id love to tell you the idea. Its a great idea and very unique. I'm 60% done with the app and its one of a kind. If your interested in hearing the app, please email me back. I emailed you because of the project examples you have on github. Thank you and hope to hear back from you.

    invalid 
    opened by Ahmedshubber 1
  • Can you make possible to expand item through programming

    Can you make possible to expand item through programming

    I am very happy to work with this library ... but I really need this option be available, so we can select and expand any contact at any time programmatically

    Thank you

    opened by albarq 0
Owner
Manuel Escrig
A Renaissance Man. Software Engineer
Manuel Escrig
Fetch the star wars api from all the planets and list and show details using Swift UI and Combine

Star Wars Planets Fetch the star wars planet data by using stat war api, list and show details using SwiftUI and Combine frameworks ?? Swift UI Framew

null 1 Aug 10, 2022
Full configurable spreadsheet view user interfaces for iOS applications. With this framework, you can easily create complex layouts like schedule, gantt chart or timetable as if you are using Excel.

kishikawakatsumi/SpreadsheetView has moved! It is being actively maintained at bannzai/SpreadsheetView. This fork was created when the project was mov

Kishikawa Katsumi 34 Sep 26, 2022
Declarative, configurable & highly reusable UI development as making Lego bricks.

LeeGo is a lightweight Swift framework that helps you decouple & modularise your UI component into small pieces of LEGO style's bricks, to make UI dev

WANG Shengjia 969 Dec 29, 2022
A highly configurable and out-of-the-box-pretty UI library

We absolutely love beautiful interfaces! As an organization named Unicorn, we are obligated to be unique and majestic.

Clayton (McIlrath) Unicorn 225 Feb 11, 2022
A UITextView subclass that adds support for multiline placeholder written in Swift.

KMPlaceholderTextView A UITextView subclass that adds support for multiline placeholder written in Swift. Usage You can set the value of the placehold

Zhouqi Mo 794 Jan 7, 2023
UIViewController subclass to beautifully present news articles and blog posts.

LMArticleViewController This framework allows you to create Apple News-inspired UIViewControllers with ease. It is heavily inspired by MRArticleViewCo

Luca Mozzarelli 7 Feb 3, 2022
A UIControl subclass that makes it easy to create empty states.

AZEmptyState Making empty state simple. Screenshots Installation Cocoa Pods: pod 'AZEmptyState' Manual: Simply drag and drop the Sources folder to you

Antonio Zaitoun 88 Oct 2, 2022
IHTypeWriterLabel - A simple, UILabel subclass which poulates itself as if being typed

IHTypeWriterLabel A simple, UILabel subclass which poulates itself as if being typed. HighLights Written purely in SWIFT. Very simple and lightweight.

Md Ibrahim Hassan 24 May 7, 2019
Show progress in your app's Dock icon

DockProgress Show progress in your app's Dock icon This package is used in production by the Gifski app. You might also like some of my other apps. Re

Sindre Sorhus 958 Jan 2, 2023
☠️ An elegant way to show users that something is happening and also prepare them to which contents they are awaiting

Features • Guides • Installation • Usage • Miscellaneous • Contributing ?? README is available in other languages: ???? . ???? . ???? . ???? . ???? To

Juanpe Catalán 11.7k Jan 6, 2023