From ffb2a199632a2d4625523084524fc17d7cab7aac Mon Sep 17 00:00:00 2001 From: Vitor Pamplona Date: Mon, 19 Jun 2023 20:43:48 -0400 Subject: [PATCH] Adds Zaps and Reactions to the Zap Activity author --- .../ui/screen/loggedIn/ChannelScreen.kt | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/ChannelScreen.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/ChannelScreen.kt index 4256c239d..cb8add738 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/ChannelScreen.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/ChannelScreen.kt @@ -80,6 +80,9 @@ import com.vitorpamplona.amethyst.ui.components.RobohashAsyncImageProxy import com.vitorpamplona.amethyst.ui.components.VideoView import com.vitorpamplona.amethyst.ui.navigation.Route import com.vitorpamplona.amethyst.ui.note.ChatroomMessageCompose +import com.vitorpamplona.amethyst.ui.note.LikeIcon +import com.vitorpamplona.amethyst.ui.note.LikeReaction +import com.vitorpamplona.amethyst.ui.note.ZapReaction import com.vitorpamplona.amethyst.ui.screen.NostrChannelFeedViewModel import com.vitorpamplona.amethyst.ui.screen.RefreshingChatroomFeedView import com.vitorpamplona.amethyst.ui.theme.ButtonBorder @@ -449,6 +452,9 @@ fun ChannelHeader(baseChannel: Channel, accountViewModel: AccountViewModel, nav: if (channel is PublicChatChannel) { ChannelActionOptions(channel, accountViewModel, nav) } + if (channel is LiveActivitiesChannel) { + LiveChannelActionOptions(channel, accountViewModel, nav) + } } } } @@ -509,6 +515,36 @@ private fun ChannelActionOptions( } } +@Composable +private fun LiveChannelActionOptions( + channel: LiveActivitiesChannel, + accountViewModel: AccountViewModel, + nav: (String) -> Unit +) { + val isMe by remember(accountViewModel) { + derivedStateOf { + channel.creator == accountViewModel.account.userProfile() + } + } + + val accountState by accountViewModel.accountLiveData.observeAsState() + val isFollowing by remember(accountState) { + derivedStateOf { + accountState?.account?.followingChannels?.contains(channel.idHex) ?: false + } + } + + if (isMe) { + //EditButton(accountViewModel, channel) + } else { + LocalCache.addressables[channel.idHex]?.let { + LikeReaction(it, MaterialTheme.colors.onSurface, accountViewModel) + Spacer(modifier = Modifier.width(5.dp)) + ZapReaction(baseNote = it, grayTint = MaterialTheme.colors.onSurface, accountViewModel = accountViewModel) + } + } +} + @Composable private fun NoteCopyButton( note: Channel