delete pollOption values on cancel(),
move recipients field to optional section, make recipients, options textFields fillMaxWidth
This commit is contained in:
@@ -109,7 +109,6 @@ fun NewPollView(onClose: () -> Unit, baseReplyTo: Note? = null, quote: Note? = n
|
|||||||
}
|
}
|
||||||
|
|
||||||
Text(stringResource(R.string.poll_heading_required))
|
Text(stringResource(R.string.poll_heading_required))
|
||||||
PollRecipientsField()
|
|
||||||
PollPrimaryDescription(pollViewModel = pollViewModel)
|
PollPrimaryDescription(pollViewModel = pollViewModel)
|
||||||
pollViewModel.pollOptions.forEachIndexed { index, element ->
|
pollViewModel.pollOptions.forEachIndexed { index, element ->
|
||||||
PollOption(pollViewModel, index)
|
PollOption(pollViewModel, index)
|
||||||
@@ -128,6 +127,7 @@ fun NewPollView(onClose: () -> Unit, baseReplyTo: Note? = null, quote: Note? = n
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
Text(stringResource(R.string.poll_heading_optional))
|
Text(stringResource(R.string.poll_heading_optional))
|
||||||
|
PollRecipientsField()
|
||||||
PollVoteValueRange()
|
PollVoteValueRange()
|
||||||
PollConsensusThreshold()
|
PollConsensusThreshold()
|
||||||
PollClosing()
|
PollClosing()
|
||||||
|
|||||||
@@ -35,6 +35,9 @@ class NewPollViewModel : NewPostViewModel() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun cancel() {
|
override fun cancel() {
|
||||||
|
// delete existing pollOptions
|
||||||
|
pollOptions = mutableStateListOf("", "")
|
||||||
|
|
||||||
super.cancel()
|
super.cancel()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,10 +2,7 @@ package com.vitorpamplona.amethyst.ui.components
|
|||||||
|
|
||||||
import androidx.compose.foundation.BorderStroke
|
import androidx.compose.foundation.BorderStroke
|
||||||
import androidx.compose.foundation.Image
|
import androidx.compose.foundation.Image
|
||||||
import androidx.compose.foundation.layout.Row
|
import androidx.compose.foundation.layout.*
|
||||||
import androidx.compose.foundation.layout.imePadding
|
|
||||||
import androidx.compose.foundation.layout.padding
|
|
||||||
import androidx.compose.foundation.layout.size
|
|
||||||
import androidx.compose.material.*
|
import androidx.compose.material.*
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
@@ -18,8 +15,10 @@ import com.vitorpamplona.amethyst.ui.actions.NewPollViewModel
|
|||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun PollOption(pollViewModel: NewPollViewModel, optionIndex: Int) {
|
fun PollOption(pollViewModel: NewPollViewModel, optionIndex: Int) {
|
||||||
Row() {
|
Row {
|
||||||
OutlinedTextField(
|
OutlinedTextField(
|
||||||
|
modifier = Modifier
|
||||||
|
.weight(1F),
|
||||||
value = pollViewModel.pollOptions[optionIndex],
|
value = pollViewModel.pollOptions[optionIndex],
|
||||||
onValueChange = { pollViewModel.pollOptions[optionIndex] = it },
|
onValueChange = { pollViewModel.pollOptions[optionIndex] = it },
|
||||||
label = {
|
label = {
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.vitorpamplona.amethyst.ui.components
|
package com.vitorpamplona.amethyst.ui.components
|
||||||
|
|
||||||
|
import androidx.compose.foundation.layout.fillMaxWidth
|
||||||
import androidx.compose.material.MaterialTheme
|
import androidx.compose.material.MaterialTheme
|
||||||
import androidx.compose.material.OutlinedTextField
|
import androidx.compose.material.OutlinedTextField
|
||||||
import androidx.compose.material.Text
|
import androidx.compose.material.Text
|
||||||
@@ -8,6 +9,7 @@ import androidx.compose.runtime.getValue
|
|||||||
import androidx.compose.runtime.mutableStateOf
|
import androidx.compose.runtime.mutableStateOf
|
||||||
import androidx.compose.runtime.saveable.rememberSaveable
|
import androidx.compose.runtime.saveable.rememberSaveable
|
||||||
import androidx.compose.runtime.setValue
|
import androidx.compose.runtime.setValue
|
||||||
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.res.stringResource
|
import androidx.compose.ui.res.stringResource
|
||||||
import com.vitorpamplona.amethyst.R
|
import com.vitorpamplona.amethyst.R
|
||||||
|
|
||||||
@@ -16,6 +18,8 @@ fun PollRecipientsField() {
|
|||||||
var text by rememberSaveable() { mutableStateOf("") }
|
var text by rememberSaveable() { mutableStateOf("") }
|
||||||
|
|
||||||
OutlinedTextField(
|
OutlinedTextField(
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxWidth(),
|
||||||
value = text,
|
value = text,
|
||||||
onValueChange = { text = it },
|
onValueChange = { text = it },
|
||||||
label = {
|
label = {
|
||||||
|
|||||||
Reference in New Issue
Block a user