|
1 | 1 | # VerifyCodeEditText |
2 | | -Verify Code Edit Text |
| 2 | + |
| 3 | +*** |
| 4 | +[](https://jitpack.io/#jakode2020/VerifyCodeEditText) |
| 5 | +[](https://kotlinlang.org) |
| 6 | +[](https://android-arsenal.com/api?level=17) |
| 7 | +[](http://t.me/jakode2020) |
| 8 | +[](http://www.instagram.com/jakode2020?r=nametag) |
| 9 | + |
| 10 | +The use of verify code edit text is to get a one-time code from the user, |
| 11 | +There is no default edit text in Android to get a one-time use code.<br> |
| 12 | +That's why I decided to build a library so that both xml and kotlin could create such input :) |
| 13 | + |
| 14 | +[1] |
| 15 | + |
| 16 | +### Gradle Setup |
| 17 | +*** |
| 18 | +```gradle |
| 19 | +repositories { |
| 20 | + maven { url 'https://jitpack.io' } |
| 21 | +} |
| 22 | +
|
| 23 | +dependencies { |
| 24 | + implementation 'com.github.jakode2020:VerifyCodeEditText:1.1' |
| 25 | +} |
| 26 | +``` |
| 27 | + |
| 28 | +## Usage |
| 29 | +*** |
| 30 | +### XML |
| 31 | + |
| 32 | +``` |
| 33 | + <com.jakode.verifycodeedittext.VerifyCodeEditText |
| 34 | + android:layout_width="wrap_content" |
| 35 | + android:layout_height="wrap_content" |
| 36 | + android:layoutDirection="ltr" (RTL language need this fiels) |
| 37 | + android:paddingBottom="12dp" |
| 38 | + app:BottomErrorIcon="@drawable/bottom_error_icon" |
| 39 | + app:BottomIconHeight="2dp" |
| 40 | + app:BottomIconWidth="40dp" |
| 41 | + app:BottomSelectedIcon="@drawable/bottom_selected_icon" |
| 42 | + app:BottomUnSelectedIcon="@drawable/bottom_unselected_icon" |
| 43 | + app:ItemSpaceSize="28dp" |
| 44 | + app:TextColor="@color/black" |
| 45 | + app:TextFont="@font/baloo" |
| 46 | + app:TextSize="16sp" |
| 47 | + app:ViewCount="Four"/> |
| 48 | +``` |
| 49 | +complete listener |
| 50 | +``` |
| 51 | + verifyCodeEditText.setCompleteListener { complete -> |
| 52 | + // some code |
| 53 | + } |
| 54 | +``` |
| 55 | +change bottom drawable state |
| 56 | +``` |
| 57 | + // all bottom drawble show erro state |
| 58 | + verifyCodeEditText.setCodeItemErrorLineDrawable() |
| 59 | + |
| 60 | + // reset drawble to normal state |
| 61 | + verifyCodeEditText.resetCodeItemLineDrawable() |
| 62 | +``` |
| 63 | + |
| 64 | +[2] |
| 65 | + |
| 66 | +set / get text |
| 67 | +``` |
| 68 | + verifyCodeEditText.text = "99999" // set |
| 69 | + println(verifyCodeEditText.text) // get |
| 70 | +``` |
| 71 | + |
| 72 | +### Kotlin Builder |
| 73 | +``` |
| 74 | + val verifyCodeEditText = VerifyCodeEditText.Builder { |
| 75 | + text { |
| 76 | + size = 20F |
| 77 | + color = Color.parseColor("#000000") |
| 78 | + } |
| 79 | + bottomIcon { |
| 80 | + iconHeight = 5 |
| 81 | + iconWidth = 60 |
| 82 | + selectedIcon = ContextCompat.getDrawable(this@MainActivity, R.drawable.bottom_selected_icon) |
| 83 | + unSelectedIcon = ContextCompat.getDrawable(this@MainActivity, R.drawable.bottom_unselected_icon) |
| 84 | + errorIcon = ContextCompat.getDrawable(this@MainActivity, R.drawable.bottom_error_icon) |
| 85 | + } |
| 86 | + verifyCell { |
| 87 | + count = VerifyCodeEditText.Builder.ViewCount.Five |
| 88 | + spaceSize = 48 |
| 89 | + } |
| 90 | + }.build(context = this) |
| 91 | + findViewById<ConstraintLayout>(R.id.layout).addView(verifyCodeEditText) |
| 92 | +``` |
| 93 | + |
| 94 | +### License |
| 95 | +*** |
| 96 | +``` |
| 97 | +Copyright Jakode2020 |
| 98 | +
|
| 99 | +Licensed under the Apache License, Version 2.0 (the "License"); |
| 100 | +you may not use this file except in compliance with the License. |
| 101 | +You may obtain a copy of the License at |
| 102 | +
|
| 103 | +http://www.apache.org/licenses/LICENSE-2.0 |
| 104 | +
|
| 105 | +Unless required by applicable law or agreed to in writing, software |
| 106 | +distributed under the License is distributed on an "AS IS" BASIS, |
| 107 | +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 108 | +See the License for the specific language governing permissions and |
| 109 | +limitations under the License. |
| 110 | +``` |
| 111 | + |
| 112 | +[1]: ./art/Screenshot.png |
| 113 | +[2]: ./art/ScreenshotError.png |
0 commit comments