forked from androidx/androidx
-
Notifications
You must be signed in to change notification settings - Fork 79
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add minLines to the BasicTextiField.destkop #469
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -95,11 +95,12 @@ import androidx.compose.ui.text.input.VisualTransformation | |
* [KeyboardOptions.imeAction]. | ||
* @param singleLine when set to true, this text field becomes a single horizontally scrolling | ||
* text field instead of wrapping onto multiple lines. The keyboard will be informed to not show | ||
* the return key as the [ImeAction]. Note that [maxLines] parameter will be ignored as the | ||
* maxLines attribute will be automatically set to 1. | ||
* @param maxLines the maximum height in terms of maximum number of visible lines. Should be | ||
* equal or greater than 1. Note that this parameter will be ignored and instead maxLines will be | ||
* set to 1 if [singleLine] is set to true. | ||
* the return key as the [ImeAction]. [maxLines] and [minLines] are ignored as both are | ||
* automatically set to 1. | ||
* @param maxLines the maximum height in terms of maximum number of visible lines. It is required | ||
* that 1 <= [minLines] <= [maxLines]. This parameter is ignored when [singleLine] is true. | ||
* @param minLines the minimum height in terms of minimum number of visible lines. It is required | ||
* that 1 <= [minLines] <= [maxLines]. This parameter is ignored when [singleLine] is true. | ||
* @param visualTransformation The visual transformation filter for changing the visual | ||
* representation of the input. By default no visual transformation is applied. | ||
* @param onTextLayout Callback that is executed when a new text layout is calculated. A | ||
|
@@ -133,7 +134,8 @@ fun BasicTextField( | |
keyboardOptions: KeyboardOptions = KeyboardOptions.Default, | ||
keyboardActions: KeyboardActions = KeyboardActions.Default, | ||
singleLine: Boolean = false, | ||
maxLines: Int = Int.MAX_VALUE, | ||
maxLines: Int = if (singleLine) 1 else Int.MAX_VALUE, | ||
minLines: Int = 1, | ||
visualTransformation: VisualTransformation = VisualTransformation.None, | ||
onTextLayout: (TextLayoutResult) -> Unit = {}, | ||
interactionSource: MutableInteractionSource = remember { MutableInteractionSource() }, | ||
|
@@ -182,6 +184,7 @@ fun BasicTextField( | |
imeOptions = keyboardOptions.toImeOptions(singleLine = singleLine), | ||
keyboardActions = keyboardActions, | ||
softWrap = !singleLine, | ||
minLines = if (singleLine) 1 else minLines, | ||
maxLines = if (singleLine) 1 else maxLines, | ||
decorationBox = decorationBox, | ||
enabled = enabled, | ||
|
@@ -243,11 +246,12 @@ fun BasicTextField( | |
* [KeyboardOptions.imeAction]. | ||
* @param singleLine when set to true, this text field becomes a single horizontally scrolling | ||
* text field instead of wrapping onto multiple lines. The keyboard will be informed to not show | ||
* the return key as the [ImeAction]. Note that [maxLines] parameter will be ignored as the | ||
* maxLines attribute will be automatically set to 1. | ||
* @param maxLines the maximum height in terms of maximum number of visible lines. Should be | ||
* equal or greater than 1. Note that this parameter will be ignored and instead maxLines will be | ||
* set to 1 if [singleLine] is set to true. | ||
* the return key as the [ImeAction]. [maxLines] and [minLines] are ignored as both are | ||
* automatically set to 1. | ||
* @param maxLines the maximum height in terms of maximum number of visible lines. It is required | ||
* that 1 <= [minLines] <= [maxLines]. This parameter is ignored when [singleLine] is true. | ||
* @param minLines the minimum height in terms of minimum number of visible lines. It is required | ||
* that 1 <= [minLines] <= [maxLines]. This parameter is ignored when [singleLine] is true. | ||
* @param visualTransformation The visual transformation filter for changing the visual | ||
* representation of the input. By default no visual transformation is applied. | ||
* @param onTextLayout Callback that is executed when a new text layout is calculated. A | ||
|
@@ -281,7 +285,8 @@ fun BasicTextField( | |
keyboardOptions: KeyboardOptions = KeyboardOptions.Default, | ||
keyboardActions: KeyboardActions = KeyboardActions.Default, | ||
singleLine: Boolean = false, | ||
maxLines: Int = Int.MAX_VALUE, | ||
maxLines: Int = if (singleLine) 1 else Int.MAX_VALUE, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Likewise. |
||
minLines: Int = 1, | ||
visualTransformation: VisualTransformation = VisualTransformation.None, | ||
onTextLayout: (TextLayoutResult) -> Unit = {}, | ||
interactionSource: MutableInteractionSource = remember { MutableInteractionSource() }, | ||
|
@@ -306,6 +311,7 @@ fun BasicTextField( | |
imeOptions = keyboardOptions.toImeOptions(singleLine = singleLine), | ||
keyboardActions = keyboardActions, | ||
softWrap = !singleLine, | ||
minLines = if (singleLine) 1 else minLines, | ||
maxLines = if (singleLine) 1 else maxLines, | ||
decorationBox = decorationBox, | ||
enabled = enabled, | ||
|
@@ -314,4 +320,3 @@ fun BasicTextField( | |
) | ||
} | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can just be
maxLines: Int = Int.MAX_VALUE
because ifsingleLine
it's ignored below anyway.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better to keep the same code as in the original text field, to simplify future copy-pastes