Register Route in AppNavigation

Modify ReplyViaVoiceReaction to Navigate
This commit is contained in:
davotoula
2025-12-18 12:59:11 +01:00
parent 13e07eb2e8
commit 8eee85a05e
2 changed files with 25 additions and 4 deletions
@@ -85,6 +85,7 @@ import com.vitorpamplona.amethyst.ui.screen.loggedIn.hashtag.HashtagPostScreen
import com.vitorpamplona.amethyst.ui.screen.loggedIn.hashtag.HashtagScreen import com.vitorpamplona.amethyst.ui.screen.loggedIn.hashtag.HashtagScreen
import com.vitorpamplona.amethyst.ui.screen.loggedIn.home.HomeScreen import com.vitorpamplona.amethyst.ui.screen.loggedIn.home.HomeScreen
import com.vitorpamplona.amethyst.ui.screen.loggedIn.home.ShortNotePostScreen import com.vitorpamplona.amethyst.ui.screen.loggedIn.home.ShortNotePostScreen
import com.vitorpamplona.amethyst.ui.screen.loggedIn.home.VoiceReplyScreen
import com.vitorpamplona.amethyst.ui.screen.loggedIn.lists.display.lists.PeopleListScreen import com.vitorpamplona.amethyst.ui.screen.loggedIn.lists.display.lists.PeopleListScreen
import com.vitorpamplona.amethyst.ui.screen.loggedIn.lists.display.packs.FollowPackScreen import com.vitorpamplona.amethyst.ui.screen.loggedIn.lists.display.packs.FollowPackScreen
import com.vitorpamplona.amethyst.ui.screen.loggedIn.lists.list.ListOfPeopleListsScreen import com.vitorpamplona.amethyst.ui.screen.loggedIn.lists.list.ListOfPeopleListsScreen
@@ -289,6 +290,18 @@ fun AppNavigation(
nav = nav, nav = nav,
) )
} }
composableFromBottomArgs<Route.VoiceReply> {
VoiceReplyScreen(
replyToNoteId = it.replyToNoteId,
recordingFilePath = it.recordingFilePath,
mimeType = it.mimeType,
duration = it.duration,
amplitudesJson = it.amplitudes,
accountViewModel = accountViewModel,
nav = nav,
)
}
} }
} }
@@ -169,6 +169,7 @@ import kotlinx.collections.immutable.toImmutableSet
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.delay import kotlinx.coroutines.delay
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
import kotlinx.serialization.json.Json
import kotlin.math.roundToInt import kotlin.math.roundToInt
import kotlin.uuid.ExperimentalUuidApi import kotlin.uuid.ExperimentalUuidApi
import kotlin.uuid.Uuid import kotlin.uuid.Uuid
@@ -585,7 +586,7 @@ private fun ReplyReactionWithDialog(
nav: INav, nav: INav,
) { ) {
if (baseNote.event is BaseVoiceEvent) { if (baseNote.event is BaseVoiceEvent) {
ReplyViaVoiceReaction(baseNote, grayTint, accountViewModel) ReplyViaVoiceReaction(baseNote, grayTint, accountViewModel, nav)
} else { } else {
ReplyReaction(baseNote, grayTint, accountViewModel) { ReplyReaction(baseNote, grayTint, accountViewModel) {
nav.nav { routeReplyTo(baseNote, accountViewModel.account) } nav.nav { routeReplyTo(baseNote, accountViewModel.account) }
@@ -599,15 +600,22 @@ fun ReplyViaVoiceReaction(
baseNote: Note, baseNote: Note,
grayTint: Color, grayTint: Color,
accountViewModel: AccountViewModel, accountViewModel: AccountViewModel,
nav: INav,
showCounter: Boolean = true, showCounter: Boolean = true,
iconSizeModifier: Modifier = Size19Modifier, iconSizeModifier: Modifier = Size19Modifier,
) { ) {
val context = LocalContext.current
RecordAudioBox( RecordAudioBox(
modifier = iconSizeModifier, modifier = iconSizeModifier,
onRecordTaken = { audio -> onRecordTaken = { audio ->
accountViewModel.sendVoiceReply(baseNote, audio, context) nav.nav {
Route.VoiceReply(
replyToNoteId = baseNote.idHex,
recordingFilePath = audio.file.absolutePath,
mimeType = audio.mimeType,
duration = audio.duration,
amplitudes = Json.encodeToString(audio.amplitudes),
)
}
}, },
) { _, _ -> ) { _, _ ->
VoiceReplyIcon(iconSizeModifier, grayTint) VoiceReplyIcon(iconSizeModifier, grayTint)