Skip to content

Commit 603a89e

Browse files
committed
add kdocs and move keyboard to molecules
1 parent 1743054 commit 603a89e

File tree

3 files changed

+71
-41
lines changed

3 files changed

+71
-41
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
package br.com.mob1st.core.design.molecules.keyboard
2+
3+
import androidx.compose.runtime.Immutable
4+
5+
/**
6+
* A key that can be clicked in the [Keyboard] component.
7+
*/
8+
sealed interface Key
9+
10+
/**
11+
* A numeric key that can be clicked in the [Keyboard] component.
12+
* It can be any number between 0 and 9.
13+
* The constructor is private to avoid creating instances with invalid numbers.
14+
* Use the [NumericKey.Instances] object to get the available instances.
15+
*/
16+
@Immutable
17+
@JvmInline
18+
value class NumericKey private constructor(
19+
val number: Int,
20+
) : Key {
21+
init {
22+
require(number in 0..9) { "Number must be between 0 and 9. Current is $number" }
23+
}
24+
25+
/**
26+
* The available instances of the [NumericKey].
27+
*/
28+
companion object Instances {
29+
val Zero = NumericKey(0)
30+
val One = NumericKey(1)
31+
val Two = NumericKey(2)
32+
val Three = NumericKey(3)
33+
val Four = NumericKey(4)
34+
val Five = NumericKey(5)
35+
val Six = NumericKey(6)
36+
val Seven = NumericKey(7)
37+
val Eight = NumericKey(8)
38+
val Nine = NumericKey(9)
39+
}
40+
}
41+
42+
/**
43+
* Keys that, differently from the [NumericKey], have a specific behavior when clicked.
44+
*/
45+
sealed interface FunctionKey : Key {
46+
/**
47+
* When clicked, it indicates the amount type should be undone and the original value should be restored.
48+
*/
49+
data object Undo : FunctionKey
50+
51+
/**
52+
* Removes the last character from the amount.
53+
*/
54+
data object Delete : FunctionKey
55+
56+
/**
57+
* Submits the information on screen and dismisses the keyboard.
58+
*/
59+
data object Done : FunctionKey
60+
61+
/**
62+
* Allows the user to select a date.
63+
*/
64+
data object Calendar : FunctionKey
65+
66+
/**
67+
* Allows the user to set cents for the amount.
68+
*/
69+
data object Decimal : FunctionKey
70+
}

Diff for: core/design/src/main/kotlin/br/com/mob1st/core/design/organisms/keyboard/Keyboard.kt renamed to core/design/src/main/kotlin/br/com/mob1st/core/design/molecules/keyboard/Keyboard.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package br.com.mob1st.core.design.organisms.keyboard
1+
package br.com.mob1st.core.design.molecules.keyboard
22

33
import android.icu.text.DecimalFormatSymbols
44
import androidx.annotation.FloatRange

Diff for: core/design/src/main/kotlin/br/com/mob1st/core/design/organisms/keyboard/Key.kt

-40
This file was deleted.

0 commit comments

Comments
 (0)