From 88432d4ab6e03024339b9e6b1bbffb2d951761c8 Mon Sep 17 00:00:00 2001 From: Vitor Pamplona Date: Mon, 20 Feb 2023 16:39:02 -0500 Subject: [PATCH] Notification Note background is now clickable. --- .../amethyst/ui/note/BoostSetCompose.kt | 22 +++++++++++++++++++ .../amethyst/ui/note/LikeSetCompose.kt | 22 +++++++++++++++++++ .../amethyst/ui/note/ZapSetCompose.kt | 22 +++++++++++++++++++ 3 files changed, 66 insertions(+) diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/note/BoostSetCompose.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/note/BoostSetCompose.kt index 60a009fa1..65a852e87 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/note/BoostSetCompose.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/note/BoostSetCompose.kt @@ -1,6 +1,8 @@ package com.vitorpamplona.amethyst.ui.note +import androidx.compose.foundation.ExperimentalFoundationApi import androidx.compose.foundation.background +import androidx.compose.foundation.combinedClickable import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row @@ -26,9 +28,11 @@ import androidx.navigation.NavController import com.google.accompanist.flowlayout.FlowRow import com.vitorpamplona.amethyst.NotificationCache import com.vitorpamplona.amethyst.R +import com.vitorpamplona.amethyst.service.model.ChannelMessageEvent import com.vitorpamplona.amethyst.ui.screen.BoostSetCard import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel +@OptIn(ExperimentalFoundationApi::class) @Composable fun BoostSetCompose(boostSetCard: BoostSetCard, isInnerNote: Boolean = false, routeForLastRead: String, accountViewModel: AccountViewModel, navController: NavController) { val noteState by boostSetCard.note.live().metadata.observeAsState() @@ -39,6 +43,9 @@ fun BoostSetCompose(boostSetCard: BoostSetCard, isInnerNote: Boolean = false, ro val context = LocalContext.current.applicationContext + val noteEvent = note?.event + var popupExpanded by remember { mutableStateOf(false) } + if (note?.event == null) { BlankNote(Modifier, isInnerNote) } else { @@ -55,6 +62,19 @@ fun BoostSetCompose(boostSetCard: BoostSetCard, isInnerNote: Boolean = false, ro Column( modifier = Modifier.background( if (isNew) MaterialTheme.colors.primary.copy(0.12f) else MaterialTheme.colors.background + ).combinedClickable( + onClick = { + if (noteEvent !is ChannelMessageEvent) { + navController.navigate("Note/${note.idHex}"){ + launchSingleTop = true + } + } else { + note.channel?.let { + navController.navigate("Channel/${it.idHex}") + } + } + }, + onLongClick = { popupExpanded = true } ) ) { Row(modifier = Modifier @@ -91,6 +111,8 @@ fun BoostSetCompose(boostSetCard: BoostSetCard, isInnerNote: Boolean = false, ro } NoteCompose(note, null, Modifier.padding(top = 5.dp), true, accountViewModel, navController) + + NoteDropDownMenu(note, popupExpanded, { popupExpanded = false }, accountViewModel) } } } diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/note/LikeSetCompose.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/note/LikeSetCompose.kt index ef852ea33..4c2e45063 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/note/LikeSetCompose.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/note/LikeSetCompose.kt @@ -1,6 +1,8 @@ package com.vitorpamplona.amethyst.ui.note +import androidx.compose.foundation.ExperimentalFoundationApi import androidx.compose.foundation.background +import androidx.compose.foundation.combinedClickable import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row @@ -26,9 +28,11 @@ import androidx.navigation.NavController import com.google.accompanist.flowlayout.FlowRow import com.vitorpamplona.amethyst.NotificationCache import com.vitorpamplona.amethyst.R +import com.vitorpamplona.amethyst.service.model.ChannelMessageEvent import com.vitorpamplona.amethyst.ui.screen.LikeSetCard import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel +@OptIn(ExperimentalFoundationApi::class) @Composable fun LikeSetCompose(likeSetCard: LikeSetCard, modifier: Modifier = Modifier, isInnerNote: Boolean = false, routeForLastRead: String, accountViewModel: AccountViewModel, navController: NavController) { val noteState by likeSetCard.note.live().metadata.observeAsState() @@ -39,6 +43,9 @@ fun LikeSetCompose(likeSetCard: LikeSetCard, modifier: Modifier = Modifier, isIn val context = LocalContext.current.applicationContext + val noteEvent = note?.event + var popupExpanded by remember { mutableStateOf(false) } + if (note == null) { BlankNote(Modifier, isInnerNote) } else { @@ -55,6 +62,19 @@ fun LikeSetCompose(likeSetCard: LikeSetCard, modifier: Modifier = Modifier, isIn Column( modifier = Modifier.background( if (isNew) MaterialTheme.colors.primary.copy(0.12f) else MaterialTheme.colors.background + ).combinedClickable( + onClick = { + if (noteEvent !is ChannelMessageEvent) { + navController.navigate("Note/${note.idHex}"){ + launchSingleTop = true + } + } else { + note.channel?.let { + navController.navigate("Channel/${it.idHex}") + } + } + }, + onLongClick = { popupExpanded = true } ) ) { Row(modifier = Modifier @@ -91,6 +111,8 @@ fun LikeSetCompose(likeSetCard: LikeSetCard, modifier: Modifier = Modifier, isIn } NoteCompose(note, null, Modifier.padding(top = 5.dp), true, accountViewModel, navController) + + NoteDropDownMenu(note, popupExpanded, { popupExpanded = false }, accountViewModel) } } } diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/note/ZapSetCompose.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/note/ZapSetCompose.kt index 9376dc8e5..7109ff4a3 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/note/ZapSetCompose.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/note/ZapSetCompose.kt @@ -1,6 +1,8 @@ package com.vitorpamplona.amethyst.ui.note +import androidx.compose.foundation.ExperimentalFoundationApi import androidx.compose.foundation.background +import androidx.compose.foundation.combinedClickable import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row @@ -25,10 +27,12 @@ import androidx.compose.ui.unit.dp import androidx.navigation.NavController import com.google.accompanist.flowlayout.FlowRow import com.vitorpamplona.amethyst.NotificationCache +import com.vitorpamplona.amethyst.service.model.ChannelMessageEvent import com.vitorpamplona.amethyst.ui.screen.ZapSetCard import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel import com.vitorpamplona.amethyst.ui.theme.BitcoinOrange +@OptIn(ExperimentalFoundationApi::class) @Composable fun ZapSetCompose(zapSetCard: ZapSetCard, modifier: Modifier = Modifier, isInnerNote: Boolean = false, routeForLastRead: String, accountViewModel: AccountViewModel, navController: NavController) { val noteState by zapSetCard.note.live().metadata.observeAsState() @@ -39,6 +43,9 @@ fun ZapSetCompose(zapSetCard: ZapSetCard, modifier: Modifier = Modifier, isInner val context = LocalContext.current.applicationContext + val noteEvent = note?.event + var popupExpanded by remember { mutableStateOf(false) } + if (note == null) { BlankNote(Modifier, isInnerNote) } else { @@ -55,6 +62,19 @@ fun ZapSetCompose(zapSetCard: ZapSetCard, modifier: Modifier = Modifier, isInner Column( modifier = Modifier.background( if (isNew) MaterialTheme.colors.primary.copy(0.12f) else MaterialTheme.colors.background + ).combinedClickable( + onClick = { + if (noteEvent !is ChannelMessageEvent) { + navController.navigate("Note/${note.idHex}"){ + launchSingleTop = true + } + } else { + note.channel?.let { + navController.navigate("Channel/${it.idHex}") + } + } + }, + onLongClick = { popupExpanded = true } ) ) { Row(modifier = Modifier @@ -91,6 +111,8 @@ fun ZapSetCompose(zapSetCard: ZapSetCard, modifier: Modifier = Modifier, isInner } NoteCompose(note, null, Modifier.padding(top = 5.dp), true, accountViewModel, navController) + + NoteDropDownMenu(note, popupExpanded, { popupExpanded = false }, accountViewModel) } } }