mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2025-10-03 21:52:31 +02:00
add PollVoteValueRange component,
add PollOption, PollVoteValueRange component previews, rename poll_recipients string
This commit is contained in:
@@ -29,6 +29,7 @@ import com.vitorpamplona.amethyst.service.model.TextNoteEvent
|
||||
import com.vitorpamplona.amethyst.ui.components.PollOption
|
||||
import com.vitorpamplona.amethyst.ui.components.PollPrimaryDescription
|
||||
import com.vitorpamplona.amethyst.ui.components.PollRecipientsField
|
||||
import com.vitorpamplona.amethyst.ui.components.PollVoteValueRange
|
||||
import com.vitorpamplona.amethyst.ui.note.ReplyInformation
|
||||
import com.vitorpamplona.amethyst.ui.screen.loggedIn.UserLine
|
||||
import kotlinx.coroutines.delay
|
||||
@@ -114,8 +115,8 @@ fun NewPollView(onClose: () -> Unit, baseReplyTo: Note? = null, quote: Note? = n
|
||||
|
||||
PollRecipientsField()
|
||||
PollPrimaryDescription(pollViewModel = pollViewModel)
|
||||
PollOption(pollViewModel, 0)
|
||||
PollOption(pollViewModel, 1)
|
||||
PollOption(0)
|
||||
PollOption(1)
|
||||
Button(
|
||||
onClick = { /*TODO*/ },
|
||||
border = BorderStroke(1.dp, MaterialTheme.colors.onSurface.copy(alpha = 0.32f)),
|
||||
@@ -129,6 +130,8 @@ fun NewPollView(onClose: () -> Unit, baseReplyTo: Note? = null, quote: Note? = n
|
||||
modifier = Modifier.size(18.dp)
|
||||
)
|
||||
}
|
||||
Text(stringResource(R.string.poll_heading_optional))
|
||||
PollVoteValueRange()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -182,3 +185,9 @@ fun PollButton(modifier: Modifier = Modifier, onPost: () -> Unit = {}, isActive:
|
||||
Text(text = stringResource(R.string.post_poll), color = Color.White)
|
||||
}
|
||||
}
|
||||
|
||||
/*@Preview
|
||||
@Composable
|
||||
fun NewPollViewPreview() {
|
||||
NewPollView(onClose = {}, account = Account(loggedIn = Persona()))
|
||||
}*/
|
||||
|
@@ -15,12 +15,12 @@ import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.compose.ui.unit.dp
|
||||
import com.vitorpamplona.amethyst.R
|
||||
import com.vitorpamplona.amethyst.ui.actions.NewPollViewModel
|
||||
|
||||
@Composable
|
||||
fun PollOption(pollViewModel: NewPollViewModel, optionIndex: Int) {
|
||||
fun PollOption(optionIndex: Int) {
|
||||
var text by rememberSaveable() { mutableStateOf("") }
|
||||
|
||||
Row() {
|
||||
@@ -59,3 +59,9 @@ fun PollOption(pollViewModel: NewPollViewModel, optionIndex: Int) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Preview
|
||||
@Composable
|
||||
fun PollOptionPreview() {
|
||||
PollOption(0)
|
||||
}
|
||||
|
@@ -20,13 +20,13 @@ fun PollRecipientsField() {
|
||||
onValueChange = { text = it },
|
||||
label = {
|
||||
Text(
|
||||
text = stringResource(R.string.poll_recipients),
|
||||
text = stringResource(R.string.poll_zap_recipients),
|
||||
color = MaterialTheme.colors.onSurface.copy(alpha = 0.32f)
|
||||
)
|
||||
},
|
||||
placeholder = {
|
||||
Text(
|
||||
text = stringResource(R.string.poll_recipients),
|
||||
text = stringResource(R.string.poll_zap_recipients),
|
||||
color = MaterialTheme.colors.onSurface.copy(alpha = 0.32f)
|
||||
)
|
||||
}
|
||||
|
@@ -0,0 +1,75 @@
|
||||
package com.vitorpamplona.amethyst.ui.components
|
||||
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.width
|
||||
import androidx.compose.foundation.text.KeyboardOptions
|
||||
import androidx.compose.material.MaterialTheme
|
||||
import androidx.compose.material.OutlinedTextField
|
||||
import androidx.compose.material.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.saveable.rememberSaveable
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.text.input.KeyboardType
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.compose.ui.unit.dp
|
||||
import com.vitorpamplona.amethyst.R
|
||||
|
||||
@Composable
|
||||
fun PollVoteValueRange() {
|
||||
var minText by rememberSaveable { mutableStateOf("") }
|
||||
var maxText by rememberSaveable { mutableStateOf("") }
|
||||
|
||||
Row(
|
||||
Modifier.fillMaxWidth(),
|
||||
horizontalArrangement = Arrangement.Center
|
||||
) {
|
||||
OutlinedTextField(
|
||||
value = minText,
|
||||
onValueChange = { minText = it },
|
||||
keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Number),
|
||||
modifier = Modifier.width(150.dp),
|
||||
label = {
|
||||
Text(
|
||||
text = stringResource(R.string.poll_vote_value_min),
|
||||
color = MaterialTheme.colors.onSurface.copy(alpha = 0.32f)
|
||||
)
|
||||
},
|
||||
placeholder = {
|
||||
Text(
|
||||
text = stringResource(R.string.poll_vote_value_min),
|
||||
color = MaterialTheme.colors.onSurface.copy(alpha = 0.32f)
|
||||
)
|
||||
}
|
||||
)
|
||||
OutlinedTextField(
|
||||
value = maxText,
|
||||
onValueChange = { maxText = it },
|
||||
keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Number),
|
||||
modifier = Modifier.width(150.dp),
|
||||
label = {
|
||||
Text(
|
||||
text = stringResource(R.string.poll_vote_value_max),
|
||||
color = MaterialTheme.colors.onSurface.copy(alpha = 0.32f)
|
||||
)
|
||||
},
|
||||
placeholder = {
|
||||
Text(
|
||||
text = stringResource(R.string.poll_vote_value_max),
|
||||
color = MaterialTheme.colors.onSurface.copy(alpha = 0.32f)
|
||||
)
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Preview
|
||||
@Composable
|
||||
fun PollVoteValueRangePreview() {
|
||||
PollVoteValueRange()
|
||||
}
|
@@ -224,6 +224,9 @@
|
||||
<string name="poll_primary_description">Primary poll description…</string>
|
||||
<string name="poll_option_description">Poll option description</string>
|
||||
<string name="poll_option_index">Option %s</string>
|
||||
<string name="poll_recipients">Poll recipients</string>
|
||||
<string name="poll_zap_recipients">Zap recipients</string>
|
||||
<string name="poll_heading_optional">Optional:</string>
|
||||
<string name="poll_vote_value_min">Vote minimum</string>
|
||||
<string name="poll_vote_value_max">Vote maximum</string>
|
||||
|
||||
</resources>
|
||||
|
Reference in New Issue
Block a user