add PollRecipientsField,
add buttons for add/delete options, format poll text fields, change poll option placeholder string rename primaryPollDescription string
This commit is contained in:
@@ -1,6 +1,8 @@
|
|||||||
package com.vitorpamplona.amethyst.ui.actions
|
package com.vitorpamplona.amethyst.ui.actions
|
||||||
|
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
|
import androidx.compose.foundation.BorderStroke
|
||||||
|
import androidx.compose.foundation.Image
|
||||||
import androidx.compose.foundation.layout.*
|
import androidx.compose.foundation.layout.*
|
||||||
import androidx.compose.foundation.lazy.LazyColumn
|
import androidx.compose.foundation.lazy.LazyColumn
|
||||||
import androidx.compose.foundation.lazy.itemsIndexed
|
import androidx.compose.foundation.lazy.itemsIndexed
|
||||||
@@ -14,6 +16,7 @@ import androidx.compose.ui.Alignment
|
|||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.graphics.Color
|
import androidx.compose.ui.graphics.Color
|
||||||
import androidx.compose.ui.platform.LocalContext
|
import androidx.compose.ui.platform.LocalContext
|
||||||
|
import androidx.compose.ui.res.painterResource
|
||||||
import androidx.compose.ui.res.stringResource
|
import androidx.compose.ui.res.stringResource
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import androidx.compose.ui.window.Dialog
|
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.service.model.TextNoteEvent
|
||||||
import com.vitorpamplona.amethyst.ui.components.PollOption
|
import com.vitorpamplona.amethyst.ui.components.PollOption
|
||||||
import com.vitorpamplona.amethyst.ui.components.PollPrimaryDescription
|
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.note.ReplyInformation
|
||||||
import com.vitorpamplona.amethyst.ui.screen.loggedIn.UserLine
|
import com.vitorpamplona.amethyst.ui.screen.loggedIn.UserLine
|
||||||
import kotlinx.coroutines.delay
|
import kotlinx.coroutines.delay
|
||||||
@@ -37,6 +41,8 @@ fun NewPollView(onClose: () -> Unit, baseReplyTo: Note? = null, quote: Note? = n
|
|||||||
|
|
||||||
val scrollState = rememberScrollState()
|
val scrollState = rememberScrollState()
|
||||||
|
|
||||||
|
var pollOptionList = listOf<String>()
|
||||||
|
|
||||||
LaunchedEffect(Unit) {
|
LaunchedEffect(Unit) {
|
||||||
pollViewModel.load(account, baseReplyTo, quote)
|
pollViewModel.load(account, baseReplyTo, quote)
|
||||||
delay(100)
|
delay(100)
|
||||||
@@ -106,10 +112,23 @@ fun NewPollView(onClose: () -> Unit, baseReplyTo: Note? = null, quote: Note? = n
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PollRecipientsField()
|
||||||
PollPrimaryDescription(pollViewModel = pollViewModel)
|
PollPrimaryDescription(pollViewModel = pollViewModel)
|
||||||
|
|
||||||
PollOption(pollViewModel, 0)
|
PollOption(pollViewModel, 0)
|
||||||
PollOption(pollViewModel, 1)
|
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)
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,14 +1,21 @@
|
|||||||
package com.vitorpamplona.amethyst.ui.components
|
package com.vitorpamplona.amethyst.ui.components
|
||||||
|
|
||||||
import androidx.compose.material.MaterialTheme
|
import androidx.compose.foundation.BorderStroke
|
||||||
import androidx.compose.material.OutlinedTextField
|
import androidx.compose.foundation.Image
|
||||||
import androidx.compose.material.Text
|
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.Composable
|
||||||
import androidx.compose.runtime.getValue
|
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.painterResource
|
||||||
import androidx.compose.ui.res.stringResource
|
import androidx.compose.ui.res.stringResource
|
||||||
|
import androidx.compose.ui.unit.dp
|
||||||
import com.vitorpamplona.amethyst.R
|
import com.vitorpamplona.amethyst.R
|
||||||
import com.vitorpamplona.amethyst.ui.actions.NewPollViewModel
|
import com.vitorpamplona.amethyst.ui.actions.NewPollViewModel
|
||||||
|
|
||||||
@@ -16,21 +23,39 @@ import com.vitorpamplona.amethyst.ui.actions.NewPollViewModel
|
|||||||
fun PollOption(pollViewModel: NewPollViewModel, optionIndex: Int) {
|
fun PollOption(pollViewModel: NewPollViewModel, optionIndex: Int) {
|
||||||
var text by rememberSaveable() { mutableStateOf("") }
|
var text by rememberSaveable() { mutableStateOf("") }
|
||||||
|
|
||||||
OutlinedTextField(
|
Row() {
|
||||||
value = text,
|
OutlinedTextField(
|
||||||
onValueChange = { text = it },
|
value = text,
|
||||||
label = {
|
onValueChange = { text = it },
|
||||||
Text(
|
label = {
|
||||||
text = stringResource(R.string.poll_option_index).format(optionIndex),
|
Text(
|
||||||
color = MaterialTheme.colors.onSurface.copy(alpha = 0.32f)
|
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 = {
|
Image(
|
||||||
Text(
|
painterResource(id = android.R.drawable.ic_delete),
|
||||||
text = stringResource(R.string.what_s_on_your_mind),
|
contentDescription = "Remove poll option button",
|
||||||
color = MaterialTheme.colors.onSurface.copy(alpha = 0.32f)
|
modifier = Modifier.size(18.dp)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|||||||
+10
-2
@@ -2,6 +2,7 @@ package com.vitorpamplona.amethyst.ui.components
|
|||||||
|
|
||||||
import androidx.compose.foundation.border
|
import androidx.compose.foundation.border
|
||||||
import androidx.compose.foundation.layout.fillMaxWidth
|
import androidx.compose.foundation.layout.fillMaxWidth
|
||||||
|
import androidx.compose.foundation.layout.padding
|
||||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||||
import androidx.compose.foundation.text.KeyboardOptions
|
import androidx.compose.foundation.text.KeyboardOptions
|
||||||
import androidx.compose.material.*
|
import androidx.compose.material.*
|
||||||
@@ -34,14 +35,21 @@ fun PollPrimaryDescription(pollViewModel: NewPollViewModel) {
|
|||||||
onValueChange = {
|
onValueChange = {
|
||||||
pollViewModel.updateMessage(it)
|
pollViewModel.updateMessage(it)
|
||||||
},
|
},
|
||||||
|
label = {
|
||||||
|
Text(
|
||||||
|
text = stringResource(R.string.poll_primary_description),
|
||||||
|
color = MaterialTheme.colors.onSurface.copy(alpha = 0.32f)
|
||||||
|
)
|
||||||
|
},
|
||||||
keyboardOptions = KeyboardOptions.Default.copy(
|
keyboardOptions = KeyboardOptions.Default.copy(
|
||||||
capitalization = KeyboardCapitalization.Sentences
|
capitalization = KeyboardCapitalization.Sentences
|
||||||
),
|
),
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
|
.padding(top = 8.dp)
|
||||||
.border(
|
.border(
|
||||||
width = 1.dp,
|
width = 1.dp,
|
||||||
color = MaterialTheme.colors.surface,
|
color = MaterialTheme.colors.onSurface.copy(alpha = 0.32f),
|
||||||
shape = RoundedCornerShape(8.dp)
|
shape = RoundedCornerShape(8.dp)
|
||||||
)
|
)
|
||||||
.focusRequester(focusRequester)
|
.focusRequester(focusRequester)
|
||||||
@@ -52,7 +60,7 @@ fun PollPrimaryDescription(pollViewModel: NewPollViewModel) {
|
|||||||
},
|
},
|
||||||
placeholder = {
|
placeholder = {
|
||||||
Text(
|
Text(
|
||||||
text = stringResource(R.string.primary_poll_description),
|
text = stringResource(R.string.poll_primary_description),
|
||||||
color = MaterialTheme.colors.onSurface.copy(alpha = 0.32f)
|
color = MaterialTheme.colors.onSurface.copy(alpha = 0.32f)
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -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)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -221,8 +221,9 @@
|
|||||||
|
|
||||||
<string name="private_conversation_notification">"<Unable to decrypt private message>\n\nYou were cited in a private/encrypted conversation between %1$s and %2$s."</string>
|
<string name="private_conversation_notification">"<Unable to decrypt private message>\n\nYou were cited in a private/encrypted conversation between %1$s and %2$s."</string>
|
||||||
<string name="post_poll">Post Poll</string>
|
<string name="post_poll">Post Poll</string>
|
||||||
<string name="primary_poll_description">Primary poll description…</string>
|
<string name="poll_primary_description">Primary poll description…</string>
|
||||||
<string name="poll_option_description">Poll option description</string>
|
<string name="poll_option_description">Poll option description</string>
|
||||||
<string name="poll_option_index">Option %s</string>
|
<string name="poll_option_index">Option %s</string>
|
||||||
|
<string name="poll_recipients">Poll recipients</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
Reference in New Issue
Block a user