diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/actions/NewPollView.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/actions/NewPollView.kt index 1db3668ea..7f142094a 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/actions/NewPollView.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/actions/NewPollView.kt @@ -1,6 +1,8 @@ package com.vitorpamplona.amethyst.ui.actions import android.widget.Toast +import androidx.compose.foundation.BorderStroke +import androidx.compose.foundation.Image import androidx.compose.foundation.layout.* import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.itemsIndexed @@ -14,6 +16,7 @@ import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color import androidx.compose.ui.platform.LocalContext +import androidx.compose.ui.res.painterResource import androidx.compose.ui.res.stringResource import androidx.compose.ui.unit.dp import androidx.compose.ui.window.Dialog @@ -25,6 +28,7 @@ import com.vitorpamplona.amethyst.model.Note 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.note.ReplyInformation import com.vitorpamplona.amethyst.ui.screen.loggedIn.UserLine import kotlinx.coroutines.delay @@ -37,6 +41,8 @@ fun NewPollView(onClose: () -> Unit, baseReplyTo: Note? = null, quote: Note? = n val scrollState = rememberScrollState() + var pollOptionList = listOf() + LaunchedEffect(Unit) { pollViewModel.load(account, baseReplyTo, quote) delay(100) @@ -106,10 +112,23 @@ fun NewPollView(onClose: () -> Unit, baseReplyTo: Note? = null, quote: Note? = n } } + PollRecipientsField() PollPrimaryDescription(pollViewModel = pollViewModel) - PollOption(pollViewModel, 0) PollOption(pollViewModel, 1) + Button( + onClick = { /*TODO*/ }, + border = BorderStroke(1.dp, MaterialTheme.colors.onSurface.copy(alpha = 0.32f)), + colors = ButtonDefaults.outlinedButtonColors( + contentColor = MaterialTheme.colors.onSurface.copy(alpha = 0.32f) + ) + ) { + Image( + painterResource(id = android.R.drawable.ic_input_add), + contentDescription = "Add poll option button", + modifier = Modifier.size(18.dp) + ) + } } } diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/components/PollOption.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/components/PollOption.kt index ca335ecbb..888c23cdf 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/components/PollOption.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/components/PollOption.kt @@ -1,14 +1,21 @@ package com.vitorpamplona.amethyst.ui.components -import androidx.compose.material.MaterialTheme -import androidx.compose.material.OutlinedTextField -import androidx.compose.material.Text +import androidx.compose.foundation.BorderStroke +import androidx.compose.foundation.Image +import androidx.compose.foundation.layout.Row +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.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.painterResource import androidx.compose.ui.res.stringResource +import androidx.compose.ui.unit.dp import com.vitorpamplona.amethyst.R import com.vitorpamplona.amethyst.ui.actions.NewPollViewModel @@ -16,21 +23,39 @@ import com.vitorpamplona.amethyst.ui.actions.NewPollViewModel fun PollOption(pollViewModel: NewPollViewModel, optionIndex: Int) { var text by rememberSaveable() { mutableStateOf("") } - OutlinedTextField( - value = text, - onValueChange = { text = it }, - label = { - Text( - text = stringResource(R.string.poll_option_index).format(optionIndex), - color = MaterialTheme.colors.onSurface.copy(alpha = 0.32f) + Row() { + OutlinedTextField( + value = text, + onValueChange = { text = it }, + label = { + Text( + text = stringResource(R.string.poll_option_index).format(optionIndex), + color = MaterialTheme.colors.onSurface.copy(alpha = 0.32f) + ) + }, + placeholder = { + Text( + text = stringResource(R.string.poll_option_description), + color = MaterialTheme.colors.onSurface.copy(alpha = 0.32f) + ) + } + + ) + Button( + modifier = Modifier + .padding(start = 6.dp, top = 2.dp) + .imePadding(), + onClick = { /*TODO*/ }, + border = BorderStroke(1.dp, MaterialTheme.colors.onSurface.copy(alpha = 0.32f)), + colors = ButtonDefaults.outlinedButtonColors( + contentColor = MaterialTheme.colors.onSurface.copy(alpha = 0.32f) ) - }, - placeholder = { - Text( - text = stringResource(R.string.what_s_on_your_mind), - color = MaterialTheme.colors.onSurface.copy(alpha = 0.32f) + ) { + Image( + painterResource(id = android.R.drawable.ic_delete), + contentDescription = "Remove poll option button", + modifier = Modifier.size(18.dp) ) } - - ) + } } diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/components/PollPrimaryDescription.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/components/PollPrimaryDescription.kt index 8870b42ec..6f65c8266 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/components/PollPrimaryDescription.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/components/PollPrimaryDescription.kt @@ -2,6 +2,7 @@ package com.vitorpamplona.amethyst.ui.components import androidx.compose.foundation.border import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.padding import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.foundation.text.KeyboardOptions import androidx.compose.material.* @@ -34,14 +35,21 @@ fun PollPrimaryDescription(pollViewModel: NewPollViewModel) { onValueChange = { pollViewModel.updateMessage(it) }, + label = { + Text( + text = stringResource(R.string.poll_primary_description), + color = MaterialTheme.colors.onSurface.copy(alpha = 0.32f) + ) + }, keyboardOptions = KeyboardOptions.Default.copy( capitalization = KeyboardCapitalization.Sentences ), modifier = Modifier .fillMaxWidth() + .padding(top = 8.dp) .border( width = 1.dp, - color = MaterialTheme.colors.surface, + color = MaterialTheme.colors.onSurface.copy(alpha = 0.32f), shape = RoundedCornerShape(8.dp) ) .focusRequester(focusRequester) @@ -52,7 +60,7 @@ fun PollPrimaryDescription(pollViewModel: NewPollViewModel) { }, placeholder = { Text( - text = stringResource(R.string.primary_poll_description), + text = stringResource(R.string.poll_primary_description), color = MaterialTheme.colors.onSurface.copy(alpha = 0.32f) ) }, diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/components/PollRecipientsField.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/components/PollRecipientsField.kt new file mode 100644 index 000000000..0eb3b00c0 --- /dev/null +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/components/PollRecipientsField.kt @@ -0,0 +1,35 @@ +package com.vitorpamplona.amethyst.ui.components + +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.res.stringResource +import com.vitorpamplona.amethyst.R + +@Composable +fun PollRecipientsField() { + var text by rememberSaveable() { mutableStateOf("") } + + OutlinedTextField( + value = text, + onValueChange = { text = it }, + label = { + Text( + text = stringResource(R.string.poll_recipients), + color = MaterialTheme.colors.onSurface.copy(alpha = 0.32f) + ) + }, + placeholder = { + Text( + text = stringResource(R.string.poll_recipients), + color = MaterialTheme.colors.onSurface.copy(alpha = 0.32f) + ) + } + + ) +} diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index db4332bdc..17ed0b534 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -221,8 +221,9 @@ "<Unable to decrypt private message>\n\nYou were cited in a private/encrypted conversation between %1$s and %2$s." Post Poll - Primary poll description… + Primary poll description… Poll option description Option %s + Poll recipients