• Stars
    star
    38
  • Rank 706,870 (Top 14 %)
  • Language
    Swift
  • License
    Other
  • Created over 4 years ago
  • Updated over 4 years ago

Reviews

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

Repository Details

Easy to use iOS library with components for input of Credit Card data.

AnimatedCardInput

GitHub license CocoaPods Swift 5.0

This library allows you to drop into your project two easily customisable, animated components that will make input of Credit Card information for users much better experience.

Example

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

Requirements

AnimatedCardInput is written in Swift 5.0 and supports iOS 11.0+.

Installation

AnimatedCardInput is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'AnimatedCardInput'

Usage

Both components available in this Pod can be used either individually or in pair on one screen.

Card View

cardViewBothsides To use Card View on our screen we simply initialise the view and place it in our hierarchy. This will create default credit card view, with 16-digit card number separated into blocks of 4 and CVV number limited to 3 digits.

/// cardNumberDigitsLimit: Indicates maximum length of card number. Defaults to 16.
/// cardNumberChunkLengths: Indicates format of card number,
///                         e.g. [4, 3] means that number of length 7 will be split
///                         into two parts of length 4 and 3 respectively (XXXX XXX).
/// CVVNumberDigitsLimit: Indicates maximum length of CVV number.
let cardView = CardView(
    cardNumberDigitsLimit: 16,
    cardNumberChunkLengths: [4, 4, 4, 4],
    CVVNumberDigitsLimit: 3
)
view.addSubview(cardView)
NSLayoutConstraint.activate([...])

We can customise our card view in almost every way. Starting with the design, both fonts and color can be adjusted. Here's a list of all available properties that can be changed.

  • isSecureInput - Enables masking of CVV number (defaults to false).
  • validatesDateInput - Enables validation on Validity Date Field (defaults to true).
  • frontSideCardColor - Background color of the card's front side (defaults to #373737).
  • frontSideTextColor - Text color of the card's front side (defaults to #FFFFFF).
  • backSideCardColor - Background color of the card's back side (defaults to #373737).
  • CVVBackgroundColor - Background color of the card's CVV Field (defaults to #FFFFFF).
  • backSideTextColor - Text color of the card's back side (defaults to #000000).
  • selectionIndicatorColor - Border color of a selected field indicator (defaults to #ff8000).
  • numberInputFont - Font of the Card Number Field (defaults to System SemiBold 24).
  • nameLabelFont - Font of the Cardholder Name Label (defaults to System Light 14. Recommended font size is 0.6 of Card Number size).
  • nameInputFont - Font of the Cardholder Name Field (defaults to System Regular 14. Recommended font size is 0.6 of Card Number size).
  • validityLabelFont - Font of the Validity Date Label (defaults to System Light 14. Recommended font size is 0.6 of Card Number size).
  • validityInputFont - Font of the Validity Date Field (defaults to System Regular 14. Recommended font size is 0.6 of Card Number size).
  • CVVInputFont - Font of the CVV Number Field (defaults to System SemiBold 20. Recommended font size is 0.85 of Card Number size).
  • cardNumberSeparator - Character used as the Card Number Separator (defaults to " ").
  • cardNumberEmptyCharacter - Character used as the Card Number Empty Character (defaults to "X").
  • validityDateSeparator - Character used as the Validity Date Separator (defaults to "/").
  • validityDateCustomPlaceHolder - Text used as the Validity Date Placeholder (defaults to "MM/YY").
  • CVVNumberEmptyCharacter - Character used as CVV Number Empty Character (defaults to "X").
  • cardholderNameTitle - Custom string to use for title label of Cardholder Name input.
  • cardholderNamePlaceholder - Custom string to use for placeholder of Cardholder Name input.
  • validityDateTitle - Custom string to use for title label of Validity Date input.

Card Inputs View

CardInputsViewCardholderName To use Card Inputs View on our screen we simply initialise the view and place it in our hierarchy. This will create default default scroll view with four text fields and card number limited to 16 digits.

let cardInputsView = CardInputsView(cardNumberDigitLimit: 16)
view.addSubview(cardInputsView)
NSLayoutConstraint.activate([...])

Input views can be customised all at once with following properties.

  • isSecureInput - Enables masking ov CVV number (defaults to false).
  • validatesDateInput - Enables validation on Validity Date Field (defaults to true).
  • inputTintColor - Color of tint for text fields (defaults to #000000).
  • inputborderColor - Color of border for text fields (defaults to #808080).
  • titleColor - Color of text in title label (defaults to #000000).
  • titleFont - Font of text in title label (defaults to System Light 12).
  • inputColor - Color of text in text field (defaults to #000000).
  • inputFont - Font of text in text field (defaults to System Regular 24).
  • cardNumberTitle - Custom string to use for title label of Card Number input.
  • cardholderNameTitle - Custom string to use for title label of Cardholder Name input.
  • validityDateTitle - Custom string to use for title label of Validity Date input.
  • cvvNumberTitle - Custom string to use for title label of CVV Code input.

Connecting both components

If we want users to input data either directly onto card or by selecting textfields we need to pair both components with creditCardDataDelegate property.

cardView.creditCardDataDelegate = inputsView
cardInputsView.creditCardDataDelegate = cardView

From now on both inputs will update to the same data and step in the filling flow.

Adding new Card Providers

If default card brands provided with this library are not enough for your needs, you can add your own Card Provider with custom name, icon and recognition pattern that will be used in regex ("^\(pattern)\\d*"), eg. a fake _Cardinio_ provider that have card numbers starting with 92or95`:

let newCardProvider = CardProvider(name: "Cardinio", image: #imageLiteral(resourceName: "cardinio_icon"), pattern: "9[2,5]")
CardProvider.addCardProviders(newCardProvider)

Roadmap

  • Labels localisation.
  • Adding new, custom credit card providers with icons.
  • Validation errors displayed on the inputs.
  • Even more...

About

This project is made with ❤️ by Netguru and maintained by Kamil Szczepański.

License

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

More Repositories

1

ResponseDetective

Sherlock Holmes of the networking layer. 🕵️‍♂️
Swift
1,956
star
2

sticky-parallax-header

A simple React Native library, enabling the creation of fully customized header for your iOS and Android apps.
TypeScript
1,811
star
3

CarLensCollectionViewLayout

An easy-to-use Collection View Layout for card-like animation.
Swift
548
star
4

Kissme

Kissme: Kotlin Secure Storage Multiplatform
Kotlin
411
star
5

videochatguru-android

Open source library to create fast and beautiful video chats over WebRTC
Kotlin
309
star
6

BlueSwift

Swift framework for easy connection with Bluetooth peripherals.
Swift
169
star
7

ngrvalidator

Validation has never been as easy as now!
Objective-C
165
star
8

compose-multiplatform-charts

Charts library for Kotlin multiplatform applications
Kotlin
136
star
9

CarLens-iOS

CarLens - Recognize and Collect Cars
Swift
130
star
10

ar-localizer-view-android

Kotlin
33
star
11

CarLens-Android

CarLens - Recognize and Collect Cars
Kotlin
24
star
12

mobile-security-checklist

Netguru mobile security checklist
Python
23
star
13

rnd-retail-multiplatform-public

Kotlin
22
star
14

baby-monitor-client-android

Internal Baby Monitor android project
Kotlin
20
star
15

heroes-api

TypeScript
18
star
16

baby-monitor-client-ios

Swift
17
star
17

netguru

netguru gem - collection of solutions we use to develop and deploy our projects.
Ruby
16
star
18

awesome-list

Ruby
15
star
19

xcconfigs

Collection of common Xcode configuration files. 🛠️
14
star
20

CreateML-Research

The easy ways to start your journey with CreateML.
Swift
14
star
21

mobile-security-review

Security review guidelines for mobile projects
13
star
22

react-native-ar-localizer

Java
12
star
23

nodejs-recruitment-task

Repository for Node.js department's recruitment process.
JavaScript
11
star
24

productivity

Productivity tips for Netguru
Dockerfile
10
star
25

ng-ios-network-module

iOS Networking Module
Swift
9
star
26

commentable-rs

Rust
9
star
27

highway

Build system on top of Fastlane.
Ruby
9
star
28

coolcal-android

Kotlin
9
star
29

flutter-recruitment-task

Dart
8
star
30

design-process

CSS
7
star
31

opoca

Library for speeding up building machine learning proof of concepts.
Python
7
star
32

atstats-android

atStats native android app
Kotlin
5
star
33

graphql-starter-pack

Graphql training by Netguru.
Ruby
4
star
34

kivy-games

Python
4
star
35

SimpleRegEx

Wrapper for RegEx, made so the RegEx code will be understable
Python
4
star
36

smarthome

Kotlin
4
star
37

netguru-grdb

Swift
4
star
38

react-native-modal-dropdown

JavaScript
4
star
39

sections-decorator-android

Kotlin
4
star
40

bitrise-step-slack

A next-gen Slack webhook step for Bitrise
Ruby
3
star
41

frontend-recruitment-task

3
star
42

picguard-swift

Image analysis framework for Swift
Swift
3
star
43

hubguru-ios-public

Swift
3
star
44

ios-framework-template

Swift
3
star
45

qa-selenium-java-framework

Java
2
star
46

ar-localizer-view-iOS

Swift
2
star
47

capistrano-docker

Ruby
2
star
48

ngrcrop-ios

ngrcrop-ios: UI component for editing selected photos.
Objective-C
2
star
49

rack_password

Small rack middleware to block your site from unwanted vistors.
Ruby
2
star
50

awesome-frontend-architecture

Collection of awesome frontend architecture resources
2
star
51

iOS-Good-Practices

Swift
2
star
52

inicjatywyotwarte-be

A website that tries to collect all important and relevant initiatives that could help in the times of COVID-19. https://www.inicjatywyotwarte.pl
Ruby
2
star
53

terraform-module-hcloud

Hetzner Cloud module for terraform
HCL
2
star
54

inicjatywyotwarte-fe

A website that tries to collect all important and relevant initiatives that could help in the times of COVID-19.
JavaScript
2
star
55

sync-aws-extend-switch-roles

Sync AWS Extend Switch Roles
1
star
56

ios-bitrise-client-public

Swift
1
star
57

bitrise-step-ng-jira-step

Shell
1
star
58

codestories-react-native-hooks

JavaScript
1
star
59

devise-2fa

Devise with 2FA support based on Twilio
Ruby
1
star
60

twilio-2fa-bot

Simple Twilio messages scrapper for shared phone numbers
JavaScript
1
star
61

danger-flutter-coverage

Ruby
1
star
62

meetguru

JavaScript
1
star
63

django-modular-user

Python
1
star
64

bitrise-step-danger-android

Shell
1
star
65

dc-docker-task

This repo stores docker recruitment tasks for devops-college
Dockerfile
1
star