@@ -32,6 +32,7 @@ import androidx.compose.ui.res.stringResource
32
32
import androidx.compose.ui.semantics.disabled
33
33
import androidx.compose.ui.semantics.semantics
34
34
import androidx.compose.ui.text.TextStyle
35
+ import androidx.compose.ui.text.input.TextFieldValue
35
36
import androidx.compose.ui.text.input.VisualTransformation
36
37
import androidx.compose.ui.text.style.TextAlign
37
38
import androidx.compose.ui.text.style.TextOverflow
@@ -127,6 +128,88 @@ object VitaminTextInputs {
127
128
)
128
129
}
129
130
131
+ /* *
132
+ * Outlined text input to get an input value from the user.
133
+ * @param value The value of your text input
134
+ * @param label The label to be displayed inside the text input container and pushed at the top
135
+ * of text input when the component takes the focus
136
+ * @param onValueChange The callback to be called when the user type a new character
137
+ * @param modifier The `Modifier` to be applied to the component
138
+ * @param helperText The optional helper text to be displayed at the start bottom outside the text input container
139
+ * @param counter The optional counter to be displayed the the end bottom outside the text input container
140
+ * @param singleLine True if the text input doesn't extend their height, otherwise, false
141
+ * @param maxLines The number of maximum lines the text input can have if the `singleLine` is set to `true`
142
+ * @param readOnly True if you don't want open the keyboard when the user click on the text field
143
+ * @param enabled True if you can type in the text input, otherwise false
144
+ * @param transformation Transforms the visual representation of the input value
145
+ * @param keyboardOptions When the text input emit an IME action, the corresponding callback is called
146
+ * @param keyboardActions Software keyboard options that contains such as KeyboardType and ImeAction
147
+ * @param interactionSource Representing the stream of interaction for the text input
148
+ * @param colors The color to notify your user if they are in normal, error or success state
149
+ * @param textStyle The typography of the text inside the text input
150
+ * @param icon The optional trailing icon to be displayed at the end of the text input container
151
+ */
152
+ @Composable
153
+ fun Outlined (
154
+ value : TextFieldValue ,
155
+ label : String ,
156
+ onValueChange : (TextFieldValue ) -> Unit ,
157
+ modifier : Modifier = Modifier ,
158
+ helperText : String? = null,
159
+ counter : Pair <Int , Int >? = null,
160
+ singleLine : Boolean = false,
161
+ maxLines : Int = Int .MAX_VALUE ,
162
+ readOnly : Boolean = false,
163
+ enabled : Boolean = true,
164
+ transformation : VisualTransformation = TextInputsTransformations .none,
165
+ keyboardOptions : KeyboardOptions = KeyboardOptions .Default ,
166
+ keyboardActions : KeyboardActions = KeyboardActions .Default ,
167
+ interactionSource : MutableInteractionSource = remember { MutableInteractionSource () },
168
+ colors : TextInputStateColors = TextInputsState .normal(),
169
+ textStyle : TextStyle = VitaminTheme .typography.text2,
170
+ icon : @Composable (() -> Unit )? = null,
171
+ ) {
172
+ VitaminTextInputLayoutImpl (
173
+ helperText = helperText,
174
+ counter = counter,
175
+ colors = colors,
176
+ enabled = enabled,
177
+ textInput = {
178
+ OutlinedTextField (
179
+ value = value,
180
+ onValueChange = onValueChange,
181
+ label = { Text (text = label) },
182
+ colors = colors.outlinedTextFieldColors(),
183
+ textStyle = textStyle,
184
+ visualTransformation = transformation,
185
+ interactionSource = interactionSource,
186
+ keyboardOptions = keyboardOptions,
187
+ keyboardActions = keyboardActions,
188
+ singleLine = singleLine,
189
+ maxLines = maxLines,
190
+ modifier = Modifier .fillMaxWidth().vtmnSemantics(helperText, counter),
191
+ enabled = enabled,
192
+ readOnly = readOnly,
193
+ isError = colors.state == State .ERROR ,
194
+ trailingIcon = {
195
+ if (icon != null && colors.state != State .SUCCESS ) {
196
+ icon()
197
+ } else if (
198
+ colors.imageVector != null &&
199
+ (colors.state == State .SUCCESS || colors.state == State .ERROR )
200
+ ) {
201
+ Icon (
202
+ imageVector = colors.imageVector,
203
+ contentDescription = null ,
204
+ )
205
+ }
206
+ },
207
+ )
208
+ },
209
+ modifier = modifier,
210
+ )
211
+ }
212
+
130
213
/* *
131
214
* Outlined dropdown to get the input from a dropdown menu.
132
215
* @param value The value of your text input
@@ -268,6 +351,88 @@ object VitaminTextInputs {
268
351
)
269
352
}
270
353
354
+ /* *
355
+ * Filled text input to get an input value from the user.
356
+ * @param value The value of your text input
357
+ * @param label The label to be displayed inside the text input container and pushed at the top
358
+ * of text input when the component takes the focus
359
+ * @param onValueChange The callback to be called when the user type a new character
360
+ * @param modifier The `Modifier` to be applied to the component
361
+ * @param helperText The optional helper text to be displayed at the start bottom outside the text input container
362
+ * @param counter The optional counter to be displayed the the end bottom outside the text input container
363
+ * @param maxLines The number of maximum lines the text input can have if the `singleLine` is set to `true`
364
+ * @param singleLine True if the text input doesn't extend their height, otherwise, false
365
+ * @param readOnly True if you don't want open the keyboard when the user click on the text field
366
+ * @param enabled True if you can type in the text input, otherwise false
367
+ * @param transformation Transforms the visual representation of the input value
368
+ * @param keyboardOptions When the text input emit an IME action, the corresponding callback is called
369
+ * @param keyboardActions Software keyboard options that contains such as KeyboardType and ImeAction
370
+ * @param interactionSource Representing the stream of interaction for the text input
371
+ * @param colors The color to notify your user if they are in normal, error or success state
372
+ * @param textStyle The typography of the text inside the text input
373
+ * @param icon The optional trailing icon to be displayed at the end of the text input container
374
+ */
375
+ @Composable
376
+ fun Filled (
377
+ value : TextFieldValue ,
378
+ label : String ,
379
+ onValueChange : (TextFieldValue ) -> Unit ,
380
+ modifier : Modifier = Modifier ,
381
+ helperText : String? = null,
382
+ counter : Pair <Int , Int >? = null,
383
+ maxLines : Int = Int .MAX_VALUE ,
384
+ singleLine : Boolean = false,
385
+ readOnly : Boolean = false,
386
+ enabled : Boolean = true,
387
+ transformation : VisualTransformation = TextInputsTransformations .none,
388
+ keyboardOptions : KeyboardOptions = KeyboardOptions .Default ,
389
+ keyboardActions : KeyboardActions = KeyboardActions .Default ,
390
+ interactionSource : MutableInteractionSource = remember { MutableInteractionSource () },
391
+ colors : TextInputStateColors = TextInputsState .normal(),
392
+ textStyle : TextStyle = VitaminTheme .typography.text2,
393
+ icon : @Composable (() -> Unit )? = null,
394
+ ) {
395
+ VitaminTextInputLayoutImpl (
396
+ helperText = helperText,
397
+ counter = counter,
398
+ colors = colors,
399
+ enabled = enabled,
400
+ textInput = {
401
+ TextField (
402
+ value = value,
403
+ onValueChange = onValueChange,
404
+ label = { Text (text = label) },
405
+ colors = colors.textFieldColors(),
406
+ textStyle = textStyle,
407
+ visualTransformation = transformation,
408
+ interactionSource = interactionSource,
409
+ keyboardOptions = keyboardOptions,
410
+ keyboardActions = keyboardActions,
411
+ singleLine = singleLine,
412
+ maxLines = maxLines,
413
+ modifier = Modifier .fillMaxWidth().vtmnSemantics(helperText, counter),
414
+ enabled = enabled,
415
+ isError = colors.state == State .ERROR ,
416
+ readOnly = readOnly,
417
+ trailingIcon = {
418
+ if (icon != null && colors.state != State .SUCCESS ) {
419
+ icon()
420
+ } else if (
421
+ colors.imageVector != null &&
422
+ (colors.state == State .SUCCESS || colors.state == State .ERROR )
423
+ ) {
424
+ Icon (
425
+ imageVector = colors.imageVector,
426
+ contentDescription = null ,
427
+ )
428
+ }
429
+ },
430
+ )
431
+ },
432
+ modifier = modifier,
433
+ )
434
+ }
435
+
271
436
/* *
272
437
* Filled dropdown to get the input from a dropdown menu.
273
438
* @param value The value of your text input
0 commit comments