A custom view to enter otp of different sizes used usually in cases of authentication.
A custom view to enter otp of different sizes used usually in cases of authentication.
Compose OtpView/PinView
A custom control to enter a code usually in cases of authentication.
Compose PinView/OtpView is an independent project with ongoing development and support made possible thanks to your donations.
Integrating the project is simple. All you need to do is follow the below steps
Step 1. Add the JitPack repository to your build file. Add it in your root build.gradle at the end of repositories:
allprojects {
repositories {
...
maven { url "https://jitpack.io" }
}
}Step 2. Add the dependency for Compose
dependencies {
implementation 'com.github.mukeshsolanki.android-otpview-pinview:otpview-compose:3.1.0'
}for View system
dependencies {
implementation 'com.github.mukeshsolanki.android-otpview-pinview:otpview:3.1.0'
}Okay seems like you integrated the library in your project but how do you use it? Well its really easy.
OtpView composable where you need to display the view like.var otpValue by remember { mutableStateOf("") }
OtpView(
otpText = otpValue,
onOtpTextChange = {
otpValue = it
Log.d("Actual Value", otpValue)
},
type = OTP_VIEW_TYPE_BORDER,
password = true,
containerSize = 48.dp,
passwordChar = "•",
keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Number),
charColor = Color.White
)Next in your code assign otp_view to a variable like
val otpView = findViewById(R.id.otp_view)implement OnOtpCompletionListener
otpView.setOtpCompletionListener {
Log.d("Actual Value", it)
}That's pretty much it and your all wrapped up.
Maintained by Mukesh Solanki
…No open issues yet, or sync has not completed.