Giter Site home page Giter Site logo

annanikiforova / kncontactspicker Goto Github PK

View Code? Open in Web Editor NEW

This project forked from dragosrobertn/kncontactspicker

1.0 1.0 0.0 2.93 MB

A modern, highly customisable contact picker with search and multi-selection options.

License: MIT License

Swift 98.57% Ruby 1.43%

kncontactspicker's Introduction

KNContactsPicker

CocoaPods codebeat badge contributions

A modern, highly customisable contact picker with multi-selection options that closely resembles the behaviour of the ContactsUI's CNContactPickerViewController.

Preview

Single Deselect Mode Single Reselect Mode Multiple Select Mode
Single Deselect Single Reselect Multi Select

Installation

CocoaPods

Add this to your podfile for the latest version

pod 'KNContactsPicker'

Or specify desired version

pod 'KNContactsPicker', '~> 0.1'

Manual Installation

Download and include the KNContactsPicker folder and files in your codebase.

Requirements

  • iOS 12+
  • Swift 5

Features

KNContactsPicker is a modern, customisable and easy to use Contacts Picker similar to the stock CNContactPickerViewController. It does improve in a couple of area for a better UX.

  • Three contact selection modes:
    • Single Deselect (Deselects all other contacts after first contact is selected)
    • Single Reselect (Selects another contact on tap)
    • Multi Select
  • Contact images or initials
  • Search contacts and ability to select while searching
  • Clear selection button
  • Contact section indexes to quickly navigate through the contact list
  • Returns CNContact objects
  • Highly customisable settings for strings and options
  • Two conditional methods to enable or deselect certain contacts
  • Support iOS 13
    • Dark Mode
    • Icons (SF Symbols)
    • Pull to Dismiss

Coming soon:

  • Extra contact info under name
  • Contact sort order
  • Contact display order
  • More modular contact property approach

Make sure your app (the host app) has provided a Privacy - Contacts Usage Description in your Info.plist. It's also recommended that you check that contact authorisation is granted.

How to use

Implement the Delegate Methods

// This is in your application
extension ViewController: KNContactPickingDelegate {
    func contactPicker(didFailPicking error: Error) {
        print(error)
    }
    func contactPicker(didCancel error: Error) {
         print(error)
    }
    func contactPicker(didSelect contact: CNContact) {
        self.contacts.append(contact)
        self.contactsTableView.reloadData()
    }
    
    func contactPicker(didSelect contacts: [CNContact]) {
        self.contacts.append(contentsOf: contacts)
        self.contactsTableView.reloadData()
    }
}

Customise the Settings

var settings = KNPickerSettings()
settings.pickerTitle = "Pick"

settings.conditionToDisplayContact = { contact in
  return contact.organizationName == "Apple"
}
settings.conditionToDisableContact = { contact in
    return self.contacts.contains(contact)
}

Initialise and Present the KNContactsPicker

let controller = KNContactsPicker(delegate: self, settings: settings)
        
self.navigationController?.present(controller, animated: true, completion: nil)

Recommended

You can use KNContactsPicker with KNContacts framework.

kncontactspicker's People

Contributors

dragosrobertn avatar annanikiforova avatar

Stargazers

Rakhim Abdullayev avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.