@@ -38,19 +38,15 @@ import com.spendesk.grapes.compose.theme.GrapesTheme
38
38
* @since 04/07/2022
39
39
*/
40
40
41
- private const val DefaultWindowLength = 4
42
- private const val DefaultMaxLength = 12
43
- private val ForbiddenCharRegex = " \\ D" .toRegex()
44
-
45
41
@Composable
46
42
fun WindowEditText (
47
43
text : String ,
48
44
onTextChange : (String ) -> Unit ,
49
45
modifier : Modifier = Modifier ,
50
- windowLength : Int = DefaultWindowLength ,
51
- maxLength : Int = DefaultMaxLength ,
52
- cursorColor : Color = GrapesTheme .colors.mainWhite ,
53
- textStyle : TextStyle = GrapesTheme .typography.bodyM.copy(letterSpacing = 3.sp, color = GrapesTheme .colors.mainWhite, fontSize = 18.sp, fontFeatureSettings = "tnum" ),
46
+ windowLength : Int = WindowEditTextDefaults . DefaultWindowLength ,
47
+ maxLength : Int = WindowEditTextDefaults . DefaultMaxLength ,
48
+ cursorColor : Color = Color . White ,
49
+ textStyle : TextStyle = WindowEditTextDefaults .defaultTextStyle( ),
54
50
hintChar : Char = '0',
55
51
separatorChar : Char = '-',
56
52
) {
@@ -70,10 +66,10 @@ fun WindowEditText(
70
66
text = text,
71
67
onTextChange = onTextChange,
72
68
modifier = modifier
73
- .padding(16 .dp )
69
+ .padding(GrapesTheme .dimensions.spacing3 )
74
70
.fillMaxWidth()
75
71
.background(GrapesTheme .colors.primaryDark, RoundedCornerShape (12 .dp))
76
- .padding(vertical = 16 .dp ),
72
+ .padding(vertical = GrapesTheme .dimensions.spacing3 ),
77
73
windowLength = windowLength,
78
74
maxLength = maxLength,
79
75
cursorColor = cursorColor,
@@ -88,10 +84,10 @@ internal fun WindowEditTextBase(
88
84
text : String ,
89
85
onTextChange : (String ) -> Unit ,
90
86
modifier : Modifier = Modifier ,
91
- windowLength : Int = DefaultWindowLength ,
92
- maxLength : Int = DefaultMaxLength ,
93
- cursorColor : Color = GrapesTheme .colors.mainWhite ,
94
- textStyle : TextStyle = GrapesTheme .typography.bodyM.copy(letterSpacing = 3.sp, color = GrapesTheme .colors.mainWhite, fontSize = 18.sp, fontFeatureSettings = "tnum" ),
87
+ windowLength : Int = WindowEditTextDefaults . DefaultWindowLength ,
88
+ maxLength : Int = WindowEditTextDefaults . DefaultMaxLength ,
89
+ cursorColor : Color = Color . White ,
90
+ textStyle : TextStyle = WindowEditTextDefaults .defaultTextStyle( ),
95
91
hint : AnnotatedString = AnnotatedString ("0"),
96
92
separator : AnnotatedString = AnnotatedString ("-"),
97
93
) {
@@ -117,7 +113,7 @@ internal fun WindowEditTextBase(
117
113
}
118
114
119
115
private fun sanitizeWindowedEditTextContent (text : String , maxLength : Int ): String {
120
- return text.replace(ForbiddenCharRegex , " " ).run {
116
+ return text.replace(WindowEditTextDefaults . ForbiddenCharRegex , " " ).run {
121
117
if (this .length > maxLength) {
122
118
this .substring(0 until maxLength)
123
119
} else {
0 commit comments