Improving reply screen to clarify which users will be notified.
This commit is contained in:
@@ -26,6 +26,7 @@ import androidx.compose.material.icons.outlined.Bolt
|
|||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.LaunchedEffect
|
import androidx.compose.runtime.LaunchedEffect
|
||||||
import androidx.compose.runtime.getValue
|
import androidx.compose.runtime.getValue
|
||||||
|
import androidx.compose.runtime.livedata.observeAsState
|
||||||
import androidx.compose.runtime.mutableStateOf
|
import androidx.compose.runtime.mutableStateOf
|
||||||
import androidx.compose.runtime.remember
|
import androidx.compose.runtime.remember
|
||||||
import androidx.compose.runtime.rememberCoroutineScope
|
import androidx.compose.runtime.rememberCoroutineScope
|
||||||
@@ -47,6 +48,7 @@ import androidx.compose.ui.res.stringResource
|
|||||||
import androidx.compose.ui.text.font.FontWeight
|
import androidx.compose.ui.text.font.FontWeight
|
||||||
import androidx.compose.ui.text.input.KeyboardCapitalization
|
import androidx.compose.ui.text.input.KeyboardCapitalization
|
||||||
import androidx.compose.ui.text.input.TextFieldValue
|
import androidx.compose.ui.text.input.TextFieldValue
|
||||||
|
import androidx.compose.ui.text.style.TextAlign
|
||||||
import androidx.compose.ui.text.style.TextDirection
|
import androidx.compose.ui.text.style.TextDirection
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import androidx.compose.ui.unit.sp
|
import androidx.compose.ui.unit.sp
|
||||||
@@ -58,9 +60,8 @@ import coil.compose.AsyncImage
|
|||||||
import com.vitorpamplona.amethyst.R
|
import com.vitorpamplona.amethyst.R
|
||||||
import com.vitorpamplona.amethyst.model.Account
|
import com.vitorpamplona.amethyst.model.Account
|
||||||
import com.vitorpamplona.amethyst.model.Note
|
import com.vitorpamplona.amethyst.model.Note
|
||||||
import com.vitorpamplona.amethyst.service.model.TextNoteEvent
|
import com.vitorpamplona.amethyst.model.User
|
||||||
import com.vitorpamplona.amethyst.ui.components.*
|
import com.vitorpamplona.amethyst.ui.components.*
|
||||||
import com.vitorpamplona.amethyst.ui.note.ReplyInformation
|
|
||||||
import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel
|
import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel
|
||||||
import com.vitorpamplona.amethyst.ui.screen.loggedIn.TextSpinner
|
import com.vitorpamplona.amethyst.ui.screen.loggedIn.TextSpinner
|
||||||
import com.vitorpamplona.amethyst.ui.screen.loggedIn.UserLine
|
import com.vitorpamplona.amethyst.ui.screen.loggedIn.UserLine
|
||||||
@@ -145,10 +146,8 @@ fun NewPostView(onClose: () -> Unit, baseReplyTo: Note? = null, quote: Note? = n
|
|||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
.verticalScroll(scroolState)
|
.verticalScroll(scroolState)
|
||||||
) {
|
) {
|
||||||
if (postViewModel.replyTos != null && baseReplyTo?.event is TextNoteEvent) {
|
Notifying(postViewModel.mentions) {
|
||||||
ReplyInformation(postViewModel.replyTos, postViewModel.mentions, account, "✖ ") {
|
postViewModel.removeFromReplyList(it)
|
||||||
postViewModel.removeFromReplyList(it)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
OutlinedTextField(
|
OutlinedTextField(
|
||||||
@@ -345,6 +344,47 @@ fun NewPostView(onClose: () -> Unit, baseReplyTo: Note? = null, quote: Note? = n
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@OptIn(ExperimentalLayoutApi::class)
|
||||||
|
@Composable
|
||||||
|
fun Notifying(baseMentions: List<User>?, onClick: (User) -> Unit) {
|
||||||
|
val mentions = baseMentions?.toSet()
|
||||||
|
|
||||||
|
FlowRow(verticalAlignment = Alignment.CenterVertically, modifier = Modifier.padding(horizontal = 10.dp)) {
|
||||||
|
if (!mentions.isNullOrEmpty()) {
|
||||||
|
Text(
|
||||||
|
stringResource(R.string.reply_notify),
|
||||||
|
fontWeight = FontWeight.Bold,
|
||||||
|
color = MaterialTheme.colors.onSurface.copy(alpha = 0.32f)
|
||||||
|
)
|
||||||
|
|
||||||
|
mentions.forEachIndexed { idx, user ->
|
||||||
|
val innerUserState by user.live().metadata.observeAsState()
|
||||||
|
val innerUser = innerUserState?.user
|
||||||
|
|
||||||
|
innerUser?.let { myUser ->
|
||||||
|
Spacer(modifier = Modifier.width(5.dp))
|
||||||
|
|
||||||
|
Button(
|
||||||
|
shape = RoundedCornerShape(20.dp),
|
||||||
|
colors = ButtonDefaults.buttonColors(
|
||||||
|
backgroundColor = MaterialTheme.colors.primary.copy(alpha = 0.32f)
|
||||||
|
),
|
||||||
|
onClick = {
|
||||||
|
onClick(myUser)
|
||||||
|
}
|
||||||
|
) {
|
||||||
|
Text(
|
||||||
|
"✖ ${myUser.toBestDisplayName()}",
|
||||||
|
color = Color.White,
|
||||||
|
textAlign = TextAlign.Center
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
private fun AddPollButton(
|
private fun AddPollButton(
|
||||||
isPollActive: Boolean,
|
isPollActive: Boolean,
|
||||||
|
|||||||
@@ -198,8 +198,8 @@ open class NewPostViewModel : ViewModel() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
open fun removeFromReplyList(it: User) {
|
open fun removeFromReplyList(userToRemove: User) {
|
||||||
mentions = mentions?.minus(it)
|
mentions = mentions?.filter { it != userToRemove }
|
||||||
}
|
}
|
||||||
|
|
||||||
open fun updateMessage(it: TextFieldValue) {
|
open fun updateMessage(it: TextFieldValue) {
|
||||||
|
|||||||
@@ -394,4 +394,6 @@
|
|||||||
<string name="app_notification_zaps_channel_message">%1$s sats</string>
|
<string name="app_notification_zaps_channel_message">%1$s sats</string>
|
||||||
<string name="app_notification_zaps_channel_message_from">From %1$s</string>
|
<string name="app_notification_zaps_channel_message_from">From %1$s</string>
|
||||||
<string name="app_notification_zaps_channel_message_for">for %1$s</string>
|
<string name="app_notification_zaps_channel_message_for">for %1$s</string>
|
||||||
|
|
||||||
|
<string name="reply_notify">Notify: </string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
Reference in New Issue
Block a user