ProductPromotion
Logo

Kotlin

made by https://0x3d.site

GitHub - itmaginationdemos/OTPComposable: OTPComposable is an Android library dedicated to making OTP (One Time Password) components a breeze to implement in Android apps.
OTPComposable is an Android library dedicated to making OTP (One Time Password) components a breeze to implement in Android apps. - itmaginationdemos/OTPComposable
Visit Site

GitHub - itmaginationdemos/OTPComposable: OTPComposable is an Android library dedicated to making OTP (One Time Password) components a breeze to implement in Android apps.

GitHub - itmaginationdemos/OTPComposable: OTPComposable is an Android library dedicated to making OTP (One Time Password) components a breeze to implement in Android apps.

OTPComposable

This is a small library/view for anyone who is not in the mode to create yet another OTP screen from scratch.

Integration

Follow these steps:

Step 1. Add the Jitpack repository in your root build.gradle at the end of repositories:

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

Step 2. Add the dependency with the current version

dependencies {
    implementation 'com.github.itmaginationdemos:OTPComposable:x.x.x'
}

Using it

We made sure to make it as simple as possible.
Bellow examples will include example which use every available property.
Properties will be explained in the next section.

Otp View with unknown Pin/Password

In cases where you will check if the Pin is correct only after the user entered it or in cases where mobile client will never know the value of a correct pin you should use this Composable.
This one is a bit more complex for you as you will have to handle the State changes (LCE). We did try to help out as much as we could without hurting the customization options.

 val (pinValue, onPinValueChange) = remember { mutableStateOf("") }

OtpView(
  pin = pinValue,
  onPinChange = onPinValueChange, 
  onFullPin: (String) -> Unit,
  content: ContentCustomization,
  error: ErrorCustomization,
  loading: LoadingCustomization,
  scaffoldState: ScaffoldState,
  lce: LCE = LCE.Content,
)

Otp View with preexisting Pin

This one is easy. You just pass us the pin you expect from user and a success lambda and you are golden. Rest of the logic comes for free.

 val (pinValue, onPinValueChange) = remember { mutableStateOf("") }

ExistingOtpView(
  pin: String, 
  onPinChange: (String) -> Unit,
  expectedPin: String,
  onSuccess: () -> Unit,
  content: ContentCustomization,
  error: ErrorCustomization,
  scaffoldState: ScaffoldState
)

Properties

Basics

Pin - current pin entered by user
onPinChange - action you want to take when user adds or removes a character (usually just save it)
expectedPin (ExistingOtpView) - in case you know the pin in advance just put it here and all state changes are handled
onSuccess (ExistingOtpView) - lambda to call when we determined the pin is correct
onFullPin (OtpView) - lambda which is called when all digits are entered
scaffoldState - needed for calling a Snackbar
lce (OtpView) - lce, or Loading, Content, Error. More details in next chapter, but basically these are the three possible state of this Composable

ErrorCustomization

ErrorCustomization(
  val modifier: Modifier = Modifier,
  val snackMsg: String = "",
  val message: String = "Code is incorrect",
)

modifier - standard stuff
snackMsg - if empty no Snackbar will be shown. In other case this will be the message in it
message - message displayed bellow the inputs when wrong pin is entered. If empty still ocupies space

ContentCustomization

ContentCustomization(
  val modifier: Modifier = Modifier,
  val color: Color = Color.Black,
  val digitCount: Int = 6,
  val type: DigitViewType = DigitViewType.Rounded(50),
  val digitSize: TextUnit = 24.sp,
  val containerSize: Dp = digitSize.value.dp * 2.2f,
)

modifier - standard stuff
color - text color
digitCount - number of places for pin, important for logic
digitSize - font size of digit
containerSize - size of the cell for one digit, default is 2.2 times the digit font size type - see bellow

DigitViewType {
  object Underline : DigitViewType
  data class Rounded(@IntRange(from = 0, to = 50) val percentage: Int): DigitViewType
}

Underline - digit cell will have no borders just a line bellow the digit itself
Rounded - digit cell with borders ranging from 0 to 50. 0 means it will be a square cell while a 50 will mean it will be a circle one. And all other numbers in between are basically rounded corners.

LoadingCustomization

LoadingCustomization(
  val modifier: Modifier = Modifier,
  val loadingMessage: String = "Loading...",
  val showMessage: Boolean = true,
  val showProgress: Boolean = true,
)

modifier - standard stuff
loadingMessage - displayed message
showMessage - if false no text will be shown
showProgress - if false no loading indicator will be shown

More Resources
to explore the angular.

mail [email protected] to add your project or resources here 🔥.

Related Articles
to learn about angular.

FAQ's
to learn more about Angular JS.

mail [email protected] to add more queries here 🔍.

More Sites
to check out once you're finished browsing here.

0x3d
https://www.0x3d.site/
0x3d is designed for aggregating information.
NodeJS
https://nodejs.0x3d.site/
NodeJS Online Directory
Cross Platform
https://cross-platform.0x3d.site/
Cross Platform Online Directory
Open Source
https://open-source.0x3d.site/
Open Source Online Directory
Analytics
https://analytics.0x3d.site/
Analytics Online Directory
JavaScript
https://javascript.0x3d.site/
JavaScript Online Directory
GoLang
https://golang.0x3d.site/
GoLang Online Directory
Python
https://python.0x3d.site/
Python Online Directory
Swift
https://swift.0x3d.site/
Swift Online Directory
Rust
https://rust.0x3d.site/
Rust Online Directory
Scala
https://scala.0x3d.site/
Scala Online Directory
Ruby
https://ruby.0x3d.site/
Ruby Online Directory
Clojure
https://clojure.0x3d.site/
Clojure Online Directory
Elixir
https://elixir.0x3d.site/
Elixir Online Directory
Elm
https://elm.0x3d.site/
Elm Online Directory
Lua
https://lua.0x3d.site/
Lua Online Directory
C Programming
https://c-programming.0x3d.site/
C Programming Online Directory
C++ Programming
https://cpp-programming.0x3d.site/
C++ Programming Online Directory
R Programming
https://r-programming.0x3d.site/
R Programming Online Directory
Perl
https://perl.0x3d.site/
Perl Online Directory
Java
https://java.0x3d.site/
Java Online Directory
Kotlin
https://kotlin.0x3d.site/
Kotlin Online Directory
PHP
https://php.0x3d.site/
PHP Online Directory
React JS
https://react.0x3d.site/
React JS Online Directory
Angular
https://angular.0x3d.site/
Angular JS Online Directory