Adds a Pin icon to the post instead of making a separate section in user profiles
This commit is contained in:
@@ -33,6 +33,7 @@ import androidx.compose.foundation.layout.fillMaxWidth
|
|||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
import androidx.compose.foundation.layout.size
|
import androidx.compose.foundation.layout.size
|
||||||
import androidx.compose.material.icons.Icons
|
import androidx.compose.material.icons.Icons
|
||||||
|
import androidx.compose.material.icons.filled.PushPin
|
||||||
import androidx.compose.material.icons.outlined.Timer
|
import androidx.compose.material.icons.outlined.Timer
|
||||||
import androidx.compose.material3.Icon
|
import androidx.compose.material3.Icon
|
||||||
import androidx.compose.material3.MaterialTheme
|
import androidx.compose.material3.MaterialTheme
|
||||||
@@ -273,6 +274,7 @@ fun NoteCompose(
|
|||||||
unPackReply: ReplyRenderType = ReplyRenderType.FULL,
|
unPackReply: ReplyRenderType = ReplyRenderType.FULL,
|
||||||
makeItShort: Boolean = false,
|
makeItShort: Boolean = false,
|
||||||
isHiddenFeed: Boolean = false,
|
isHiddenFeed: Boolean = false,
|
||||||
|
isPinned: Boolean = false,
|
||||||
quotesLeft: Int,
|
quotesLeft: Int,
|
||||||
parentBackgroundColor: MutableState<Color>? = null,
|
parentBackgroundColor: MutableState<Color>? = null,
|
||||||
accountViewModel: AccountViewModel,
|
accountViewModel: AccountViewModel,
|
||||||
@@ -302,6 +304,7 @@ fun NoteCompose(
|
|||||||
unPackReply = unPackReply,
|
unPackReply = unPackReply,
|
||||||
makeItShort = makeItShort,
|
makeItShort = makeItShort,
|
||||||
canPreview = canPreview,
|
canPreview = canPreview,
|
||||||
|
isPinned = isPinned,
|
||||||
quotesLeft = quotesLeft,
|
quotesLeft = quotesLeft,
|
||||||
parentBackgroundColor = parentBackgroundColor,
|
parentBackgroundColor = parentBackgroundColor,
|
||||||
accountViewModel = accountViewModel,
|
accountViewModel = accountViewModel,
|
||||||
@@ -322,6 +325,7 @@ fun AcceptableNote(
|
|||||||
unPackReply: ReplyRenderType = ReplyRenderType.FULL,
|
unPackReply: ReplyRenderType = ReplyRenderType.FULL,
|
||||||
makeItShort: Boolean = false,
|
makeItShort: Boolean = false,
|
||||||
canPreview: Boolean = true,
|
canPreview: Boolean = true,
|
||||||
|
isPinned: Boolean = false,
|
||||||
quotesLeft: Int,
|
quotesLeft: Int,
|
||||||
parentBackgroundColor: MutableState<Color>? = null,
|
parentBackgroundColor: MutableState<Color>? = null,
|
||||||
accountViewModel: AccountViewModel,
|
accountViewModel: AccountViewModel,
|
||||||
@@ -377,6 +381,7 @@ fun AcceptableNote(
|
|||||||
makeItShort = makeItShort,
|
makeItShort = makeItShort,
|
||||||
canPreview = canPreview,
|
canPreview = canPreview,
|
||||||
quotesLeft = quotesLeft,
|
quotesLeft = quotesLeft,
|
||||||
|
isPinned = isPinned,
|
||||||
parentBackgroundColor = parentBackgroundColor,
|
parentBackgroundColor = parentBackgroundColor,
|
||||||
accountViewModel = accountViewModel,
|
accountViewModel = accountViewModel,
|
||||||
showPopup = showPopup,
|
showPopup = showPopup,
|
||||||
@@ -433,6 +438,7 @@ fun AcceptableNote(
|
|||||||
unPackReply = unPackReply,
|
unPackReply = unPackReply,
|
||||||
makeItShort = makeItShort,
|
makeItShort = makeItShort,
|
||||||
canPreview = canPreview,
|
canPreview = canPreview,
|
||||||
|
isPinned = isPinned,
|
||||||
quotesLeft = quotesLeft,
|
quotesLeft = quotesLeft,
|
||||||
parentBackgroundColor = parentBackgroundColor,
|
parentBackgroundColor = parentBackgroundColor,
|
||||||
accountViewModel = accountViewModel,
|
accountViewModel = accountViewModel,
|
||||||
@@ -494,6 +500,7 @@ private fun CheckNewAndRenderNote(
|
|||||||
unPackReply: ReplyRenderType = ReplyRenderType.FULL,
|
unPackReply: ReplyRenderType = ReplyRenderType.FULL,
|
||||||
makeItShort: Boolean = false,
|
makeItShort: Boolean = false,
|
||||||
canPreview: Boolean = true,
|
canPreview: Boolean = true,
|
||||||
|
isPinned: Boolean = false,
|
||||||
quotesLeft: Int,
|
quotesLeft: Int,
|
||||||
parentBackgroundColor: MutableState<Color>? = null,
|
parentBackgroundColor: MutableState<Color>? = null,
|
||||||
accountViewModel: AccountViewModel,
|
accountViewModel: AccountViewModel,
|
||||||
@@ -525,6 +532,7 @@ private fun CheckNewAndRenderNote(
|
|||||||
unPackReply = unPackReply,
|
unPackReply = unPackReply,
|
||||||
makeItShort = makeItShort,
|
makeItShort = makeItShort,
|
||||||
canPreview = canPreview,
|
canPreview = canPreview,
|
||||||
|
isPinned = isPinned,
|
||||||
quotesLeft = quotesLeft,
|
quotesLeft = quotesLeft,
|
||||||
accountViewModel = accountViewModel,
|
accountViewModel = accountViewModel,
|
||||||
nav = nav,
|
nav = nav,
|
||||||
@@ -582,6 +590,7 @@ fun InnerNoteWithReactions(
|
|||||||
unPackReply: ReplyRenderType,
|
unPackReply: ReplyRenderType,
|
||||||
makeItShort: Boolean,
|
makeItShort: Boolean,
|
||||||
canPreview: Boolean,
|
canPreview: Boolean,
|
||||||
|
isPinned: Boolean,
|
||||||
quotesLeft: Int,
|
quotesLeft: Int,
|
||||||
accountViewModel: AccountViewModel,
|
accountViewModel: AccountViewModel,
|
||||||
nav: INav,
|
nav: INav,
|
||||||
@@ -624,6 +633,7 @@ fun InnerNoteWithReactions(
|
|||||||
makeItShort = makeItShort,
|
makeItShort = makeItShort,
|
||||||
canPreview = canPreview,
|
canPreview = canPreview,
|
||||||
showSecondRow = showSecondRow,
|
showSecondRow = showSecondRow,
|
||||||
|
isPinned = isPinned,
|
||||||
quotesLeft = quotesLeft,
|
quotesLeft = quotesLeft,
|
||||||
backgroundColor = backgroundColor,
|
backgroundColor = backgroundColor,
|
||||||
editState = editState,
|
editState = editState,
|
||||||
@@ -707,6 +717,7 @@ fun NoteBody(
|
|||||||
makeItShort: Boolean = false,
|
makeItShort: Boolean = false,
|
||||||
canPreview: Boolean = true,
|
canPreview: Boolean = true,
|
||||||
showSecondRow: Boolean,
|
showSecondRow: Boolean,
|
||||||
|
isPinned: Boolean = false,
|
||||||
quotesLeft: Int,
|
quotesLeft: Int,
|
||||||
backgroundColor: MutableState<Color>,
|
backgroundColor: MutableState<Color>,
|
||||||
editState: State<GenericLoadable<EditState>>,
|
editState: State<GenericLoadable<EditState>>,
|
||||||
@@ -717,6 +728,7 @@ fun NoteBody(
|
|||||||
FirstUserInfoRow(
|
FirstUserInfoRow(
|
||||||
baseNote = baseNote,
|
baseNote = baseNote,
|
||||||
showAuthorPicture = showAuthorPicture,
|
showAuthorPicture = showAuthorPicture,
|
||||||
|
isPinned = isPinned,
|
||||||
editState = editState,
|
editState = editState,
|
||||||
accountViewModel = accountViewModel,
|
accountViewModel = accountViewModel,
|
||||||
nav = nav,
|
nav = nav,
|
||||||
@@ -1438,6 +1450,7 @@ fun DisplayDraftChat() {
|
|||||||
fun FirstUserInfoRow(
|
fun FirstUserInfoRow(
|
||||||
baseNote: Note,
|
baseNote: Note,
|
||||||
showAuthorPicture: Boolean,
|
showAuthorPicture: Boolean,
|
||||||
|
isPinned: Boolean,
|
||||||
editState: State<GenericLoadable<EditState>>,
|
editState: State<GenericLoadable<EditState>>,
|
||||||
accountViewModel: AccountViewModel,
|
accountViewModel: AccountViewModel,
|
||||||
nav: INav,
|
nav: INav,
|
||||||
@@ -1492,6 +1505,10 @@ fun FirstUserInfoRow(
|
|||||||
DisplayDraft()
|
DisplayDraft()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isPinned) {
|
||||||
|
PinnedMark()
|
||||||
|
}
|
||||||
|
|
||||||
Expiration(baseNote)
|
Expiration(baseNote)
|
||||||
|
|
||||||
TimeAgo(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
|
@Composable
|
||||||
fun Expiration(note: Note) {
|
fun Expiration(note: Note) {
|
||||||
val event = note.event
|
val event = note.event
|
||||||
|
|||||||
+1
-38
@@ -23,30 +23,18 @@ package com.vitorpamplona.amethyst.ui.screen.loggedIn.profile.newthreads
|
|||||||
import androidx.compose.foundation.ExperimentalFoundationApi
|
import androidx.compose.foundation.ExperimentalFoundationApi
|
||||||
import androidx.compose.foundation.layout.Column
|
import androidx.compose.foundation.layout.Column
|
||||||
import androidx.compose.foundation.layout.Row
|
import androidx.compose.foundation.layout.Row
|
||||||
import androidx.compose.foundation.layout.Spacer
|
|
||||||
import androidx.compose.foundation.layout.fillMaxHeight
|
import androidx.compose.foundation.layout.fillMaxHeight
|
||||||
import androidx.compose.foundation.layout.fillMaxWidth
|
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.LazyColumn
|
||||||
import androidx.compose.foundation.lazy.LazyListState
|
import androidx.compose.foundation.lazy.LazyListState
|
||||||
import androidx.compose.foundation.lazy.items
|
import androidx.compose.foundation.lazy.items
|
||||||
import androidx.compose.foundation.lazy.itemsIndexed
|
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.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.Composable
|
||||||
import androidx.compose.runtime.LaunchedEffect
|
import androidx.compose.runtime.LaunchedEffect
|
||||||
import androidx.compose.runtime.getValue
|
import androidx.compose.runtime.getValue
|
||||||
import androidx.compose.ui.Alignment
|
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.unit.dp
|
|
||||||
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||||
import com.vitorpamplona.amethyst.R
|
|
||||||
import com.vitorpamplona.amethyst.commons.ui.feeds.FeedState
|
import com.vitorpamplona.amethyst.commons.ui.feeds.FeedState
|
||||||
import com.vitorpamplona.amethyst.ui.feeds.FeedEmpty
|
import com.vitorpamplona.amethyst.ui.feeds.FeedEmpty
|
||||||
import com.vitorpamplona.amethyst.ui.feeds.FeedError
|
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.AccountViewModel
|
||||||
import com.vitorpamplona.amethyst.ui.screen.loggedIn.profile.newthreads.dal.UserProfileNewThreadsFeedViewModel
|
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.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.DividerThickness
|
||||||
import com.vitorpamplona.amethyst.ui.theme.FeedPadding
|
import com.vitorpamplona.amethyst.ui.theme.FeedPadding
|
||||||
|
|
||||||
@@ -157,13 +144,13 @@ private fun FeedLoadedWithPinnedNotes(
|
|||||||
contentType = { it.event?.kind ?: -1 },
|
contentType = { it.event?.kind ?: -1 },
|
||||||
) { item ->
|
) { item ->
|
||||||
Column(Modifier.fillMaxWidth().animateItem()) {
|
Column(Modifier.fillMaxWidth().animateItem()) {
|
||||||
PinnedNoteLabel()
|
|
||||||
NoteCompose(
|
NoteCompose(
|
||||||
item,
|
item,
|
||||||
modifier = Modifier.fillMaxWidth(),
|
modifier = Modifier.fillMaxWidth(),
|
||||||
routeForLastRead = null,
|
routeForLastRead = null,
|
||||||
isBoostedNote = false,
|
isBoostedNote = false,
|
||||||
isHiddenFeed = pinnedItems.showHidden,
|
isHiddenFeed = pinnedItems.showHidden,
|
||||||
|
isPinned = true,
|
||||||
quotesLeft = 3,
|
quotesLeft = 3,
|
||||||
accountViewModel = accountViewModel,
|
accountViewModel = accountViewModel,
|
||||||
nav = nav,
|
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),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user