Skip to content

Commit a9e71d1

Browse files
committed
Update README.md
1 parent 5f58789 commit a9e71d1

File tree

2 files changed

+41
-71
lines changed

2 files changed

+41
-71
lines changed

CHANGELOG.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# Change Log
22

3-
## Version 4.0.0 *(XX/XX/2023)*
3+
## Version 4.0.0 *(03/11/2023)*
44

5-
- Revamped Number Keyboard to Compose #37
5+
- Revamped Number Keyboard to Compose #37 (thanks @delacrixmorgan!)
66

77
## Version 3.1.0 *(13/12/2022)*
88

README.md

Lines changed: 39 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Number Keyboard [![](https://jitpack.io/v/davidmigloz/number-keyboard.svg)](https://jitpack.io/#davidmigloz/number-keyboard)
22

3-
Android library that provides a number keyboard view.
3+
Android library that provides a number keyboard composable.
44

55
![screenshot](img/screenshot.jpg)
66

@@ -33,73 +33,43 @@ dependencies {
3333

3434
#### Step 3
3535

36-
Use `NumberKeyboard` view in your layout:
37-
38-
```xml
39-
<com.davidmiguel.numberkeyboard.NumberKeyboard
40-
xmlns:android="http://schemas.android.com/apk/res/android"
41-
xmlns:keyboard="http://schemas.android.com/apk/res-auto"
42-
...
43-
keyboard:numberkeyboard_keyboardType="integer"
44-
... />
45-
```
46-
47-
#### Attributes
48-
49-
- `keyboard:numberkeyboard_keyboardType="[integer|decimal|fingerprint|custom]"` (required): defines the type of keyboard.
50-
- `integer`: numbers and backspace keys.
51-
- `decimal`: numbers, comma and backspace keys.
52-
- `fingerprint`: numbers, fingerprint and backspace keys.
53-
- `custom`: numbers and defined auxiliary keys.
54-
- `keyboard:numberkeyboard_keyWidth="[dimension]"` (default: `match_parent`): key width (`wrap_content` not allowed).
55-
- `keyboard:numberkeyboard_keyHeight="[dimension]"` (default: `match_parent`): key height (`wrap_content` not allowed).
56-
- `keyboard:numberkeyboard_keyPadding="[dimension]"` (default: `16dp`): key padding.
57-
- `keyboard:numberkeyboard_numberKeyBackground="[reference]"` (default: circle): number keys background drawable.
58-
- `keyboard:numberkeyboard_numberKeyTextColor="[reference]"` (default: dark blue): number keys text color.
59-
- `keyboard:numberkeyboard_numberKeyTypeface="[reference]"` (default: dark blue): number keys text color.
60-
- `keyboard:numberkeyboard_numberKeyTypeface="[reference]"` (default: none): number keys text typeface.
61-
- `keyboard:numberkeyboard_numberKeyTextSize="[dimension]"` (default: none): number keys text size (if it is not set, the text auto scales to fit the key).
62-
- `keyboard:numberkeyboard_leftAuxBtnBackground="[reference]"` (default: none): if `keyboardType="custom"`, left auxiliary button background.
63-
- `keyboard:numberkeyboard_rightAuxBtnIcon="[reference]"` (default: none): if `keyboardType="custom"`, icon shown in right auxiliary button.
64-
- `keyboard:numberkeyboard_rightAuxBtnBackground="[reference]"` (default: none): if `keyboardType="custom"`, right auxiliary button background.
65-
66-
#### Methods
67-
68-
- `hideLeftAuxButton()`: hides left auxiliary button.
69-
- `showLeftAuxButton()`: shows left auxiliary button.
70-
- `hideRightAuxButton()`: hides right auxiliary button.
71-
- `showRightAuxButton()`: shows right auxiliary button.
72-
- `setKeyWidth()`: sets key width in px.
73-
- `setKeyHeight()`: sets key height in px.
74-
- `setKeyPadding()`: sets key padding in px.
75-
- `setNumberKeyBackground()`: sets number keys background.
76-
- `setNumberKeyTextColor()`: sets number keys text color.
77-
- `setNumberKeyTypeface()`: sets number keys text typeface.
78-
- `setNumberKeyTextSize()`: sets number keys text size in pixels.
79-
- `setLeftAuxButtonIcon()`: sets left auxiliary button icon.
80-
- `setRightAuxButtonIcon()`: sets right auxiliary button icon.
81-
- `setLeftAuxButtonBackground()`: sets left auxiliary button background.
82-
- `setRightAuxButtonBackground()`: sets right auxiliary button background.
83-
84-
#### Callback
85-
86-
To listen to keyboard events, you have to use `NumberKeyboardListener`:
87-
88-
- `onNumberClicked()`: invoked when a number key is clicked.
89-
- `onLeftAuxButtonClicked()`: invoked when the left auxiliary button is clicked.
90-
- `onRightAuxButtonClicked()`: invoked when the right auxiliary button is clicked.
91-
92-
```java
93-
numberKeyboard.setListener(new NumberKeyboardListener() {
94-
@Override
95-
public void onNumberClicked(int number) {...}
96-
97-
@Override
98-
public void onLeftAuxButtonClicked() {...}
99-
100-
@Override
101-
public void onRightAuxButtonClicked() {...}
102-
});
36+
Use `NumberKeyboard` composable in your layout:
37+
38+
```kotlin
39+
NumberKeyboard(
40+
maxAllowedAmount = 999.00,
41+
maxAllowedDecimals = 0,
42+
roundUpToMax = false,
43+
button = { number, clickedListener ->
44+
NumberKeyboardButton(
45+
modifier = buttonModifier,
46+
textStyle = buttonTextStyle,
47+
number = number,
48+
listener = clickedListener
49+
)
50+
},
51+
leftAuxButton = { _ ->
52+
NumberKeyboardAuxButton(
53+
modifier = buttonModifier,
54+
textStyle = buttonTextStyle,
55+
imageVector = Icons.Rounded.Fingerprint,
56+
clicked = { Toast.makeText(context, "Triggered", Toast.LENGTH_SHORT).show() }
57+
)
58+
},
59+
rightAuxButton = { clickedListener ->
60+
NumberKeyboardAuxButton(
61+
modifier = buttonModifier,
62+
textStyle = buttonTextStyle,
63+
imageVector = Icons.Rounded.Backspace,
64+
clicked = { clickedListener.onRightAuxButtonClicked() }
65+
)
66+
},
67+
listener = object : NumberKeyboardListener {
68+
override fun onUpdated(data: NumberKeyboardData) {
69+
text = data.int.toString()
70+
}
71+
}
72+
)
10373
```
10474

10575
Take a look at the [sample app](https://github.com/davidmigloz/number-keyboard/tree/master/sample) to see the library working.
@@ -111,7 +81,7 @@ Pull request are very appreciated.
11181

11282
## License
11383

114-
Copyright (c) 2023 David Miguel Lozano
84+
Copyright (c) 2023 David Miguel Lozano / Morgan Koh
11585

11686
Licensed under the Apache License, Version 2.0 (the "License");
11787
you may not use this file except in compliance with the License.

0 commit comments

Comments
 (0)