Giter Club home page Giter Club logo

compactcreditinput's Introduction

CompactCreditInput

A compact credit card input field that combines the number date and cvv into a single field

Build Status
Release

gif_demo static_amex static_visa

Features

  • Automatic card number formatting
  • Realtime date validation
  • Card type logo based on typed number
  • Lifecycle automatic disposal support
  • Keyboard events handling
  • Auto-fill compatible
  • Copy & Paste support

Installation

Add JitPack to your repositories

repositories { 
    maven { url "https://jitpack.io" } 
}  

And then add the dependency to your dependencies

dependencies { 
    implementation "com.github.10bis:compactCreditInput:$latest_version" 
}  

Usage

Add the view to your layout file

<com.tenbis.support.views.CompactCreditInput  
    android:id="@+id/compact_credit_card_input"  
    android:layout_width="match_parent"  
    android:layout_height="wrap_content" />

You can further customize the field in your layout file by changing

  • card_background
  • label_text
  • label_text_color
  • label_text_font
  • text_font
  • text_color
  • hint_color
  • card_number_hint
  • card_date_hint
  • card_cvv_hint

Or in your code

  • cardBackground
  • labelText
  • labelTextColor
  • labelTextFont
  • textFont
  • textColor
  • hintColor
  • cardNumberHint
  • cardDateHint
  • cardCvvHint

Events

The library notifies when a change occur using the OnCreditCardStateChanged interface

  • Once all fields have valid inputs

     onCreditCardValid(creditCard: CreditCard)
    
  • Once a valid card number is entered

     onCreditCardNumberValid(creditCardNumber: String)
    
  • Once a valid expiration date is entered

     onCreditCardExpirationDateValid(month: Int, year: Int)
    
  • Once a valid cvv is entered

     onCreditCardCvvValid(cvv: String)
    
  • Once the card type is found

     onCreditCardTypeFound(cardType: CardType)
    
  • Once one of the fields is invalid

     onInvalidCardTyped()
    

You can subscribe to events by calling

compactCreditCardInput.addOnCreditCardStateChangedListener(OnCreditCardStateChanged)

You can unsubscribe from events by calling

compactCreditCardInput.removeOnCreditCardStateChangedListener(OnCreditCardStateChanged)

Cleaning up

The library can clean it self automatically when it has an attached Lifecycle You can attach your lifecycle by calling

compactCreditCardInput.attachLifecycle(Lifecycle)

If you don't want to attach the lifecycle just call

compactCreditCardInput.onDestroy()

When your'e done with the field

Contributing

Please read CONTRIBUTING for details on our code of conduct, and the process for submitting pull requests to us.

Versioning

We use SemVer for versioning. For the versions available, see the tags on this repository.

Authors

See also the list of contributors who participated in this project.

License

This project is licensed under the GNU General Public License v3.0 - see the LICENSE.md file for details

compactcreditinput's People

Contributors

gilgoldzweig avatar

Watchers

 avatar  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.