Skip to content

Commit f015da3

Browse files
authored
feat(text-area): allow to fix the height of the component despite the number of entered lines (#1329)
1 parent b53932a commit f015da3

26 files changed

Lines changed: 375 additions & 34 deletions

File tree

app/src/main/java/com/orange/ouds/app/ui/components/textarea/TextAreaDemoScreen.kt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,11 @@ private fun TextAreaDemoBottomSheetContent(state: TextAreaDemoState) {
7373
onCheckedChange = { readOnly = it },
7474
enabled = readOnlySwitchEnabled
7575
)
76+
CustomizationSwitchItem(
77+
label = stringResource(R.string.app_components_textArea_autoResize_tech),
78+
checked = autoResize,
79+
onCheckedChange = { autoResize = it },
80+
)
7681
CustomizationSwitchItem(
7782
label = stringResource(R.string.app_components_common_error_tech),
7883
checked = error,
@@ -130,6 +135,7 @@ private fun TextAreaDemoContent(state: TextAreaDemoState) {
130135
loader = if (hasLoader) OudsTextInputLoader(null) else null,
131136
enabled = enabled,
132137
readOnly = readOnly,
138+
autoResize = autoResize,
133139
error = if (error) OudsError(errorMessage) else null,
134140
helperText = helperText,
135141
helperLink = if (helperLink.isNotEmpty()) OudsTextInputHelperLink(text = helperLink, onClick = { }) else null,
@@ -153,6 +159,7 @@ private fun Code.Builder.textAreaDemoCodeSnippet(state: TextAreaDemoState) {
153159
}
154160
if (!enabled) enabledArgument(false)
155161
if (readOnly) readOnlyArgument(true)
162+
if (!autoResize) typedArgument("autoResize", autoResize)
156163
if (error) errorArgument(errorMessage)
157164
if (helperText.isNotEmpty()) typedArgument("helperText", helperText)
158165
if (helperLink.isNotEmpty()) {

app/src/main/java/com/orange/ouds/app/ui/components/textarea/TextAreaDemoState.kt

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ fun rememberTextAreaDemoState(
3232
hasLoader: Boolean = false,
3333
enabled: Boolean = true,
3434
readOnly: Boolean = false,
35+
autoResize: Boolean = true,
3536
error: Boolean = false,
3637
errorMessage: String = stringResource(id = R.string.app_components_common_errorMessage_label),
3738
helperText: String = "",
@@ -45,6 +46,7 @@ fun rememberTextAreaDemoState(
4546
enabled,
4647
readOnly,
4748
hasLoader,
49+
autoResize,
4850
error,
4951
errorMessage,
5052
helperText,
@@ -60,6 +62,7 @@ fun rememberTextAreaDemoState(
6062
hasLoader,
6163
enabled,
6264
readOnly,
65+
autoResize,
6366
error,
6467
errorMessage,
6568
helperText,
@@ -76,6 +79,7 @@ class TextAreaDemoState(
7679
hasLoader: Boolean,
7780
enabled: Boolean,
7881
readOnly: Boolean,
82+
autoResize: Boolean,
7983
error: Boolean,
8084
errorMessage: String,
8185
helperText: String,
@@ -96,6 +100,7 @@ class TextAreaDemoState(
96100
hasLoader,
97101
enabled,
98102
readOnly,
103+
autoResize,
99104
error,
100105
errorMessage,
101106
helperText,
@@ -115,10 +120,11 @@ class TextAreaDemoState(
115120
list[5] as Boolean,
116121
list[6] as Boolean,
117122
list[7] as Boolean,
118-
list[8] as String,
123+
list[8] as Boolean,
119124
list[9] as String,
120125
list[10] as String,
121-
list[11] as Boolean
126+
list[11] as String,
127+
list[12] as Boolean
122128
)
123129
}
124130
)
@@ -132,6 +138,8 @@ class TextAreaDemoState(
132138

133139
var outlined: Boolean by mutableStateOf(outlined)
134140

141+
var autoResize: Boolean by mutableStateOf(autoResize)
142+
135143
var error: Boolean by mutableStateOf(error)
136144

137145
var errorMessage: String by mutableStateOf(errorMessage)

app/src/main/res/values/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,7 @@
315315
<!-- Components: text area -->
316316
<string name="app_components_textArea_tech" translatable="false">Text area</string>
317317
<string name="app_components_textArea_description_text">Text area is a UI element that allows to type, edit, or select longer blocks of textual data, such as comments, messages or descriptions; by expanding vertically and offering more space to input text.</string>
318+
<string name="app_components_textArea_autoResize_tech" translatable="false">Auto-resize</string>
318319

319320
<!-- Components: text input -->
320321
<string name="app_components_textInput_tech" translatable="false">Text input</string>

core-test/src/main/java/com/orange/ouds/core/test/OudsTextAreaTest.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,15 +57,15 @@ internal class OudsTextAreaTest {
5757
}
5858

5959
@RunWith(Parameterized::class)
60-
class MultiLineValue(parameter: Any) : OudsComponentSnapshotTest(
61-
OudsPreviewableComponent.TextArea.MultiLineValue,
60+
class AutoResize(parameter: Any) : OudsComponentSnapshotTest(
61+
OudsPreviewableComponent.TextArea.AutoResize,
6262
parameter,
6363
OudsComponentTestSuite.theme
6464
) {
6565
companion object {
6666
@JvmStatic
6767
@Parameterized.Parameters
68-
internal fun data() = OudsPreviewableComponent.TextArea.MultiLineValue.parameters
68+
internal fun data() = OudsPreviewableComponent.TextArea.AutoResize.parameters
6969
}
7070
}
7171

0 commit comments

Comments
 (0)