diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/navigation/AppNavigation.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/navigation/AppNavigation.kt index bcc6cc9f9..24a294e32 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/navigation/AppNavigation.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/navigation/AppNavigation.kt @@ -176,8 +176,9 @@ fun AppNavigation( composableFromBottomArgs { NewPublicMessageScreen( to = it.toKey(), - accountViewModel, - nav, + reply = it.replyId?.let { hex -> accountViewModel.getNoteIfExists(hex) }, + accountViewModel = accountViewModel, + nav = nav, ) } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/navigation/routes/RouteMaker.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/navigation/routes/RouteMaker.kt index a51df6440..292541708 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/navigation/routes/RouteMaker.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/navigation/routes/RouteMaker.kt @@ -201,7 +201,11 @@ fun routeReplyTo( ): Route? { val noteEvent = note.event return when (noteEvent) { - is PublicMessageEvent -> Route.NewPublicMessage(noteEvent.groupKeySet() - account.userProfile().pubkeyHex) + is PublicMessageEvent -> + Route.NewPublicMessage( + users = noteEvent.groupKeySet() - account.userProfile().pubkeyHex, + parentId = noteEvent.id, + ) is TextNoteEvent -> Route.NewPost(baseReplyTo = note.idHex) is PrivateDmEvent -> routeToMessage( diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/navigation/routes/Routes.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/navigation/routes/Routes.kt index b01823b12..5364b57b7 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/navigation/routes/Routes.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/navigation/routes/Routes.kt @@ -140,9 +140,11 @@ sealed class Route { @Serializable data class NewPublicMessage( val to: String, + val replyId: HexKey? = null, ) : Route() { - constructor(users: Set) : this( + constructor(users: Set, parentId: HexKey) : this( to = users.joinToString(","), + replyId = parentId, ) fun toKey(): Set = to.split(",").toSet() diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/notifications/publicMessages/NewPublicMessageScreen.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/notifications/publicMessages/NewPublicMessageScreen.kt index 8c126e857..29fa178c2 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/notifications/publicMessages/NewPublicMessageScreen.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/notifications/publicMessages/NewPublicMessageScreen.kt @@ -56,6 +56,7 @@ import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.unit.dp import androidx.lifecycle.viewmodel.compose.viewModel import com.vitorpamplona.amethyst.R +import com.vitorpamplona.amethyst.model.Note import com.vitorpamplona.amethyst.ui.actions.UrlUserTagTransformation import com.vitorpamplona.amethyst.ui.actions.mediaServers.ServerType import com.vitorpamplona.amethyst.ui.actions.uploads.SelectFromGallery @@ -64,6 +65,7 @@ import com.vitorpamplona.amethyst.ui.components.ThinPaddingTextField import com.vitorpamplona.amethyst.ui.navigation.navs.INav import com.vitorpamplona.amethyst.ui.navigation.navs.Nav import com.vitorpamplona.amethyst.ui.navigation.topbars.PostingTopBar +import com.vitorpamplona.amethyst.ui.note.NoteCompose import com.vitorpamplona.amethyst.ui.note.creators.contentWarning.ContentSensitivityExplainer import com.vitorpamplona.amethyst.ui.note.creators.contentWarning.MarkAsSensitiveButton import com.vitorpamplona.amethyst.ui.note.creators.emojiSuggestions.ShowEmojiSuggestionList @@ -89,6 +91,7 @@ import com.vitorpamplona.amethyst.ui.theme.DividerThickness import com.vitorpamplona.amethyst.ui.theme.Font14SP import com.vitorpamplona.amethyst.ui.theme.Size10dp import com.vitorpamplona.amethyst.ui.theme.Size5dp +import com.vitorpamplona.amethyst.ui.theme.imageModifier import com.vitorpamplona.amethyst.ui.theme.placeholderText import com.vitorpamplona.quartz.nip01Core.core.HexKey import kotlinx.coroutines.Dispatchers @@ -101,6 +104,7 @@ import kotlinx.coroutines.withContext @Composable fun NewPublicMessageScreen( to: Set? = null, + reply: Note? = null, accountViewModel: AccountViewModel, nav: Nav, ) { @@ -112,6 +116,9 @@ fun NewPublicMessageScreen( to?.let { postViewModel.load(it) } + reply?.let { + postViewModel.reply(it) + } } } @@ -171,7 +178,24 @@ fun PublicMessageScreenContent( Modifier.fillMaxWidth().verticalScroll(scrollState), verticalArrangement = spacedBy(Size10dp), ) { - SendDirectMessageTo(postViewModel, accountViewModel) + val replyTo = postViewModel.replyingTo + + if (replyTo == null) { + SendDirectMessageTo(postViewModel, accountViewModel) + } else { + Row { + NoteCompose( + baseNote = replyTo, + modifier = MaterialTheme.colorScheme.imageModifier, + isQuotedNote = true, + unPackReply = false, + makeItShort = true, + quotesLeft = 1, + accountViewModel = accountViewModel, + nav = nav, + ) + } + } MessageFieldRow(postViewModel, accountViewModel, postViewModel.toUsers.text.isNotBlank()) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/notifications/publicMessages/NewPublicMessageViewModel.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/notifications/publicMessages/NewPublicMessageViewModel.kt index 948affe69..9b0a7c945 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/notifications/publicMessages/NewPublicMessageViewModel.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/notifications/publicMessages/NewPublicMessageViewModel.kt @@ -133,6 +133,8 @@ class NewPublicMessageViewModel : } } + var replyingTo: Note? by mutableStateOf(null) + val iMetaAttachments = IMetaAttachments() var nip95attachments by mutableStateOf>>(emptyList()) @@ -203,6 +205,10 @@ class NewPublicMessageViewModel : ) } + fun reply(post: Note) { + this.replyingTo = post + } + fun quote(quote: Note) { message = TextFieldValue(message.text + "\nnostr:${quote.toNEvent()}") urlPreviews.update(message) @@ -332,7 +338,7 @@ class NewPublicMessageViewModel : } } - private suspend fun createTemplate(): EventTemplate? { + private suspend fun createTemplate(): EventTemplate? { val toUsersTagger = NewMessageTagger(this@NewPublicMessageViewModel.toUsers.text, null, null, accountViewModel) toUsersTagger.run() diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/theme/Shape.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/theme/Shape.kt index 272519c0c..ecae26927 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/theme/Shape.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/theme/Shape.kt @@ -120,6 +120,7 @@ val HalfStartPadding = Modifier.padding(start = 5.dp) val StdStartPadding = Modifier.padding(start = 10.dp) val StdTopPadding = Modifier.padding(top = 10.dp) val HalfTopPadding = Modifier.padding(top = 5.dp) +val HalfHalfTopPadding = Modifier.padding(top = 3.dp) val HalfHalfVertPadding = Modifier.padding(vertical = 3.dp) val HalfHalfHorzModifier = Modifier.padding(horizontal = 3.dp)