mirror of
https://github.com/Novaloop-AG/element-x-android.git
synced 2026-11-03 16:10:00 +00:00
Address review
This commit is contained in:
+2
-2
@@ -259,7 +259,7 @@ private fun MaxSelectionsStepper(
|
|||||||
) {
|
) {
|
||||||
Icon(
|
Icon(
|
||||||
imageVector = CompoundIcons.Minus(),
|
imageVector = CompoundIcons.Minus(),
|
||||||
contentDescription = null,
|
contentDescription = stringResource(id = CommonStrings.a11y_create_poll_votes_allowed_decrease),
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.clickable(enabled = current > 1) { onDecrement() }
|
.clickable(enabled = current > 1) { onDecrement() }
|
||||||
.size(32.dp)
|
.size(32.dp)
|
||||||
@@ -277,7 +277,7 @@ private fun MaxSelectionsStepper(
|
|||||||
)
|
)
|
||||||
Icon(
|
Icon(
|
||||||
imageVector = CompoundIcons.Plus(),
|
imageVector = CompoundIcons.Plus(),
|
||||||
contentDescription = null,
|
contentDescription = stringResource(id = CommonStrings.a11y_create_poll_votes_allowed_increase),
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.clickable(enabled = current < max) { onIncrement() }
|
.clickable(enabled = current < max) { onIncrement() }
|
||||||
.size(32.dp)
|
.size(32.dp)
|
||||||
|
|||||||
+1
-9
@@ -46,8 +46,6 @@ data class PollFormState(
|
|||||||
* Create a copy of the [PollFormState] with a new blank answer added.
|
* Create a copy of the [PollFormState] with a new blank answer added.
|
||||||
*
|
*
|
||||||
* If the maximum number of answers has already been reached an answer is not added.
|
* If the maximum number of answers has already been reached an answer is not added.
|
||||||
*
|
|
||||||
* Also clamps [maxSelections] to the new answer count to keep state consistent.
|
|
||||||
*/
|
*/
|
||||||
fun withNewAnswer(): PollFormState {
|
fun withNewAnswer(): PollFormState {
|
||||||
if (!canAddAnswer) {
|
if (!canAddAnswer) {
|
||||||
@@ -55,8 +53,7 @@ data class PollFormState(
|
|||||||
}
|
}
|
||||||
|
|
||||||
val newAnswers = (answers + "").toImmutableList()
|
val newAnswers = (answers + "").toImmutableList()
|
||||||
val clampedMaxSelections = maxSelections.coerceIn(1, newAnswers.size)
|
return copy(answers = newAnswers)
|
||||||
return copy(answers = newAnswers, maxSelections = clampedMaxSelections)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -103,11 +100,6 @@ data class PollFormState(
|
|||||||
*/
|
*/
|
||||||
val canDeleteAnswer get() = answers.size > MIN_ANSWERS
|
val canDeleteAnswer get() = answers.size > MIN_ANSWERS
|
||||||
|
|
||||||
/**
|
|
||||||
* The effective max selections, clamped to the number of answers.
|
|
||||||
*/
|
|
||||||
val effectiveMaxSelections get() = maxSelections.coerceIn(1, answers.size)
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether the form is currently valid.
|
* Whether the form is currently valid.
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user