CreditCardHelper 🖊️ A Jetpack-Compose library providing useful credit card utilities such as card type recognition and TextField ViewTransformations

Overview

CreditCardHelper 🖊️

A Jetpack-Compose library providing useful credit card utilities such as card type recognition and TextField ViewTransformations!

What's included? 📜

  • 🗂️ Automatic card type recognition that supports the following cards:

    • Visa
    • Mastercard
    • Maestro
    • American Express
    • Dinners Club
    • JCB
    • Discover
  • 🤩 Simple VisualTransformation subclasses for the following use-cases:

    • Card expiration date
    • Card number (with custom separators)

Adding the library to your project

Add the following to your root build.gradle file:

allprojects {
	repositories {
		maven { url 'https://jitpack.io' }
	}
}

Next, add the dependency below to your module's build.gradle file:

dependencies {
  implementation 'com.github.SteliosPapamichail:CreditCardHelper:v1.0.0'
}

Usage 📓

Masks 🎭

You can use the ExpirationDateMask or CardNumberMask VisualTransformations, by simply passing the respective composable to the visualTransfomration field of your TextField. For example:

@Composable
fun Expiration() {
    var expiration by remember { mutableStateOf("") }
    OutlinedTextField(
        value = expiration,
        visualTransformation = ExpirationDateMask(),
        onValueChange = {
            if (it.length <= 4) expiration = it
        }, label = { Text("Expiration") }
    )
}

The above code will produce something like the following:

Expiration date example image

The CardNumberMask transform will use the " " blank separator by default. If you would like to use a custom one, you can simply pass it as a parameter to the composable like so:

@Composable
fun CardNumber() {
    var number by remember { mutableStateOf("") }
    OutlinedTextField(
        value = number,
        visualTransformation = CardNumberMask("-"),
        onValueChange = {
            if (it.length <= 16) number = it
        }, label = { Text("Card number") }
    )
}

This will produce the following:

Card number example image

Card Types 🤖

You can use the provided getCardTypeFromNumber(number: String) function which accepts a string containing the input card number, and returning one of the recognized types or UKNOWN if no match was found. You can use it for building out Topup/Payment forms, card-selection or card-creation forms, and much more. Here's an example from the sample project:

Card recognition example image

You might also like...
Kindling - A standalone collection of utilities to help Ignition users. Features various tools to help work with Ignition's custom data export formats Little utilities for more pleasant immutable data in Kotlin
Little utilities for more pleasant immutable data in Kotlin

What can KopyKat do? Mutable copy Nested mutation Nested collections Mapping copyMap copy for sealed hierarchies copy from supertypes copy for type al

A set of helper classes for using dagger 1 with Android components such as Applications, Activities, Fragments, BroadcastReceivers, and Services.

##fb-android-dagger A set of helper classes for using dagger with Android components such as Applications, Activities, Fragments, BroadcastReceivers,

A simple Android utils library to write any type of data into cache files and read them later.

CacheUtilsLibrary This is a simple Android utils library to write any type of data into cache files and then read them later, using Gson to serialize

A dual screen capable home screen launcher for Android phones with dual displays, such as the LG V60, G8X & Velvet.

Duality-Launcher A dual screen capable home screen launcher for Android phones with dual displays, such as the LG V60, G8X & Velvet

Utility library that utilizes KSP to generate Room type converter classes.

Roomie Roomie is an annotation processing library that utilizes KSP to geaRoomie is an annotation processing library that utilizes KSP to generate TypeConverter classes for Room. TypeConverter classes most often involve same boiler-plate code and Roomie makes it really easy to quickly create them with a single annotation.nerate TypeConverter classes for Room. TypeConverter classes most often invol

Type safe intent building for services and activities

#IntentBuilder Type safe intent building for services and activities. IntentBuilder is a type safe way of creating intents and populating them with ex

Validator - Notify type based validation for input fields.
Validator - Notify type based validation for input fields.

Validator - Notify type based validation for input fields.

Some useful tools
Some useful tools

JustWeTools - Some useful tools JustWe 现在有哪些模块? View自定义控件 PaintView画图工具(包含重构压感新版) CodeView代码编辑 ExplorerView文件管理器 ReadView小说阅读器 MarkDownView支持MarkDown语

Releases(v1.0.0)
Owner
Stelios Papamichail
Android developer @Threenitas & Computer Science undergrad at the University Of Crete
Stelios Papamichail
Various useful utilities for Android apps development

Android Commons Various useful utilities for Android apps development. API documentation provided as Javadoc. Usage Add dependency to your build.gradl

Alex Vasilkov 112 Nov 14, 2022
Android library that regroup bunch of dateTime utilities

DateTimeUtils This library is a package of functions that let you manipulate objects and or java date string. it combine the most common functions use

Thunder413 98 Nov 16, 2022
Android Utilities Library build in kotlin Provide user 100 of pre defined method to create advanced native android app.

Android Utilities Library build in kotlin Provide user 100 of pre defined method to create advanced native android app.

Shahid Iqbal 4 Nov 29, 2022
General purpose utilities and hash functions for Android and Java (aka java-common)

Essentials Essentials are a collection of general-purpose classes we found useful in many occasions. Beats standard Java API performance, e.g. LongHas

Markus Junginger 1.4k Dec 29, 2022
General purpose utilities and hash functions for Android and Java (aka java-common)

Essentials Essentials are a collection of general-purpose classes we found useful in many occasions. Beats standard Java API performance, e.g. LongHas

Markus Junginger 1.4k Dec 29, 2022
Collection of source codes, utilities, templates and snippets for Android development.

Android Templates and Utilities [DEPRECATED] Android Templates and Utilities are deprecated. I started with this project in 2012. Android ecosystem ha

Petr Nohejl 1.1k Nov 30, 2022
FractalUtils - A collection of utility functions and classes, with an emphasis on game related utilities

A collection of utility functions and classes written in Kotlin. There is some emphasis on utilities useful for games (Geometry, Random, Time, Updating, etc).

null 2 Nov 11, 2022
A Kotlin-based testing/scraping/parsing library providing the ability to analyze and extract data from HTML

A Kotlin-based testing/scraping/parsing library providing the ability to analyze and extract data from HTML (server & client-side rendered). It places particular emphasis on ease of use and a high level of readability by providing an intuitive DSL. It aims to be a testing lib, but can also be used to scrape websites in a convenient fashion.

null 603 Jan 1, 2023
Utilities I wish Android had but doesn't

wishlist Library of helpers and utilities that I wish were included in the Android SDK but aren't. If you think something in this library is already h

Kevin Sawicki 386 Nov 21, 2022
A Telegram bot utilities that help to reduce the code amount

Flume Party A Telegram bot utilities that help to reduce code amount. Real project examples Pull Party Bot: 19% of code has been reduced. Resistance B

pool party 1 Jun 8, 2022