diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/NoteCompose.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/NoteCompose.kt index 92763735b..e208cde2b 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/NoteCompose.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/NoteCompose.kt @@ -33,6 +33,7 @@ import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size import androidx.compose.material.icons.Icons +import androidx.compose.material.icons.filled.PushPin import androidx.compose.material.icons.outlined.Timer import androidx.compose.material3.Icon import androidx.compose.material3.MaterialTheme @@ -273,6 +274,7 @@ fun NoteCompose( unPackReply: ReplyRenderType = ReplyRenderType.FULL, makeItShort: Boolean = false, isHiddenFeed: Boolean = false, + isPinned: Boolean = false, quotesLeft: Int, parentBackgroundColor: MutableState? = null, accountViewModel: AccountViewModel, @@ -302,6 +304,7 @@ fun NoteCompose( unPackReply = unPackReply, makeItShort = makeItShort, canPreview = canPreview, + isPinned = isPinned, quotesLeft = quotesLeft, parentBackgroundColor = parentBackgroundColor, accountViewModel = accountViewModel, @@ -322,6 +325,7 @@ fun AcceptableNote( unPackReply: ReplyRenderType = ReplyRenderType.FULL, makeItShort: Boolean = false, canPreview: Boolean = true, + isPinned: Boolean = false, quotesLeft: Int, parentBackgroundColor: MutableState? = null, accountViewModel: AccountViewModel, @@ -377,6 +381,7 @@ fun AcceptableNote( makeItShort = makeItShort, canPreview = canPreview, quotesLeft = quotesLeft, + isPinned = isPinned, parentBackgroundColor = parentBackgroundColor, accountViewModel = accountViewModel, showPopup = showPopup, @@ -433,6 +438,7 @@ fun AcceptableNote( unPackReply = unPackReply, makeItShort = makeItShort, canPreview = canPreview, + isPinned = isPinned, quotesLeft = quotesLeft, parentBackgroundColor = parentBackgroundColor, accountViewModel = accountViewModel, @@ -494,6 +500,7 @@ private fun CheckNewAndRenderNote( unPackReply: ReplyRenderType = ReplyRenderType.FULL, makeItShort: Boolean = false, canPreview: Boolean = true, + isPinned: Boolean = false, quotesLeft: Int, parentBackgroundColor: MutableState? = null, accountViewModel: AccountViewModel, @@ -525,6 +532,7 @@ private fun CheckNewAndRenderNote( unPackReply = unPackReply, makeItShort = makeItShort, canPreview = canPreview, + isPinned = isPinned, quotesLeft = quotesLeft, accountViewModel = accountViewModel, nav = nav, @@ -582,6 +590,7 @@ fun InnerNoteWithReactions( unPackReply: ReplyRenderType, makeItShort: Boolean, canPreview: Boolean, + isPinned: Boolean, quotesLeft: Int, accountViewModel: AccountViewModel, nav: INav, @@ -624,6 +633,7 @@ fun InnerNoteWithReactions( makeItShort = makeItShort, canPreview = canPreview, showSecondRow = showSecondRow, + isPinned = isPinned, quotesLeft = quotesLeft, backgroundColor = backgroundColor, editState = editState, @@ -707,6 +717,7 @@ fun NoteBody( makeItShort: Boolean = false, canPreview: Boolean = true, showSecondRow: Boolean, + isPinned: Boolean = false, quotesLeft: Int, backgroundColor: MutableState, editState: State>, @@ -717,6 +728,7 @@ fun NoteBody( FirstUserInfoRow( baseNote = baseNote, showAuthorPicture = showAuthorPicture, + isPinned = isPinned, editState = editState, accountViewModel = accountViewModel, nav = nav, @@ -1438,6 +1450,7 @@ fun DisplayDraftChat() { fun FirstUserInfoRow( baseNote: Note, showAuthorPicture: Boolean, + isPinned: Boolean, editState: State>, accountViewModel: AccountViewModel, nav: INav, @@ -1492,6 +1505,10 @@ fun FirstUserInfoRow( DisplayDraft() } + if (isPinned) { + PinnedMark() + } + Expiration(baseNote) TimeAgo(baseNote) @@ -1504,6 +1521,16 @@ fun FirstUserInfoRow( } } +@Composable +fun PinnedMark() { + Icon( + imageVector = Icons.Default.PushPin, + contentDescription = stringRes(R.string.pinned_notes), + modifier = Modifier.padding(start = 5.dp).size(16.dp), + tint = MaterialTheme.colorScheme.placeholderText, + ) +} + @Composable fun Expiration(note: Note) { val event = note.event diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/newthreads/TabNotesNewThreads.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/newthreads/TabNotesNewThreads.kt index 85d03e3ac..9b256d96f 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/newthreads/TabNotesNewThreads.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/newthreads/TabNotesNewThreads.kt @@ -23,30 +23,18 @@ package com.vitorpamplona.amethyst.ui.screen.loggedIn.profile.newthreads import androidx.compose.foundation.ExperimentalFoundationApi import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row -import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.fillMaxHeight import androidx.compose.foundation.layout.fillMaxWidth -import androidx.compose.foundation.layout.padding -import androidx.compose.foundation.layout.size -import androidx.compose.foundation.layout.width import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.LazyListState import androidx.compose.foundation.lazy.items import androidx.compose.foundation.lazy.itemsIndexed -import androidx.compose.material.icons.Icons -import androidx.compose.material.icons.filled.PushPin import androidx.compose.material3.HorizontalDivider -import androidx.compose.material3.Icon -import androidx.compose.material3.MaterialTheme -import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.getValue -import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier -import androidx.compose.ui.unit.dp import androidx.lifecycle.compose.collectAsStateWithLifecycle -import com.vitorpamplona.amethyst.R import com.vitorpamplona.amethyst.commons.ui.feeds.FeedState import com.vitorpamplona.amethyst.ui.feeds.FeedEmpty import com.vitorpamplona.amethyst.ui.feeds.FeedError @@ -58,7 +46,6 @@ import com.vitorpamplona.amethyst.ui.note.NoteCompose import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel import com.vitorpamplona.amethyst.ui.screen.loggedIn.profile.newthreads.dal.UserProfileNewThreadsFeedViewModel import com.vitorpamplona.amethyst.ui.screen.loggedIn.profile.pinnedNotes.dal.UserProfilePinnedNotesFeedViewModel -import com.vitorpamplona.amethyst.ui.stringRes import com.vitorpamplona.amethyst.ui.theme.DividerThickness import com.vitorpamplona.amethyst.ui.theme.FeedPadding @@ -157,13 +144,13 @@ private fun FeedLoadedWithPinnedNotes( contentType = { it.event?.kind ?: -1 }, ) { item -> Column(Modifier.fillMaxWidth().animateItem()) { - PinnedNoteLabel() NoteCompose( item, modifier = Modifier.fillMaxWidth(), routeForLastRead = null, isBoostedNote = false, isHiddenFeed = pinnedItems.showHidden, + isPinned = true, quotesLeft = 3, accountViewModel = accountViewModel, nav = nav, @@ -196,27 +183,3 @@ private fun FeedLoadedWithPinnedNotes( } } } - -@Composable -private fun PinnedNoteLabel() { - Row( - modifier = - Modifier - .fillMaxWidth() - .padding(start = 16.dp, top = 8.dp, end = 16.dp, bottom = 0.dp), - verticalAlignment = Alignment.CenterVertically, - ) { - Icon( - imageVector = Icons.Default.PushPin, - contentDescription = stringRes(R.string.pinned_notes), - modifier = Modifier.size(14.dp), - tint = MaterialTheme.colorScheme.onSurface.copy(alpha = 0.6f), - ) - Spacer(Modifier.width(4.dp)) - Text( - text = stringRes(R.string.pinned_notes), - style = MaterialTheme.typography.labelSmall, - color = MaterialTheme.colorScheme.onSurface.copy(alpha = 0.6f), - ) - } -}