Improves the rendering of Channels and Communities when quoted
This commit is contained in:
@@ -54,6 +54,7 @@ import androidx.lifecycle.distinctUntilChanged
|
|||||||
import androidx.lifecycle.map
|
import androidx.lifecycle.map
|
||||||
import com.vitorpamplona.amethyst.R
|
import com.vitorpamplona.amethyst.R
|
||||||
import com.vitorpamplona.amethyst.commons.compose.produceCachedStateAsync
|
import com.vitorpamplona.amethyst.commons.compose.produceCachedStateAsync
|
||||||
|
import com.vitorpamplona.amethyst.model.AddressableNote
|
||||||
import com.vitorpamplona.amethyst.model.Channel
|
import com.vitorpamplona.amethyst.model.Channel
|
||||||
import com.vitorpamplona.amethyst.model.FeatureSetType
|
import com.vitorpamplona.amethyst.model.FeatureSetType
|
||||||
import com.vitorpamplona.amethyst.model.Note
|
import com.vitorpamplona.amethyst.model.Note
|
||||||
@@ -75,6 +76,7 @@ import com.vitorpamplona.amethyst.ui.note.elements.MoreOptionsButton
|
|||||||
import com.vitorpamplona.amethyst.ui.note.elements.Reward
|
import com.vitorpamplona.amethyst.ui.note.elements.Reward
|
||||||
import com.vitorpamplona.amethyst.ui.note.elements.ShowForkInformation
|
import com.vitorpamplona.amethyst.ui.note.elements.ShowForkInformation
|
||||||
import com.vitorpamplona.amethyst.ui.note.elements.TimeAgo
|
import com.vitorpamplona.amethyst.ui.note.elements.TimeAgo
|
||||||
|
import com.vitorpamplona.amethyst.ui.note.types.BadgeDisplay
|
||||||
import com.vitorpamplona.amethyst.ui.note.types.DisplayPeopleList
|
import com.vitorpamplona.amethyst.ui.note.types.DisplayPeopleList
|
||||||
import com.vitorpamplona.amethyst.ui.note.types.DisplayRelaySet
|
import com.vitorpamplona.amethyst.ui.note.types.DisplayRelaySet
|
||||||
import com.vitorpamplona.amethyst.ui.note.types.EditState
|
import com.vitorpamplona.amethyst.ui.note.types.EditState
|
||||||
@@ -87,6 +89,7 @@ import com.vitorpamplona.amethyst.ui.note.types.RenderBadgeAward
|
|||||||
import com.vitorpamplona.amethyst.ui.note.types.RenderChannelMessage
|
import com.vitorpamplona.amethyst.ui.note.types.RenderChannelMessage
|
||||||
import com.vitorpamplona.amethyst.ui.note.types.RenderChatMessage
|
import com.vitorpamplona.amethyst.ui.note.types.RenderChatMessage
|
||||||
import com.vitorpamplona.amethyst.ui.note.types.RenderClassifieds
|
import com.vitorpamplona.amethyst.ui.note.types.RenderClassifieds
|
||||||
|
import com.vitorpamplona.amethyst.ui.note.types.RenderCommunity
|
||||||
import com.vitorpamplona.amethyst.ui.note.types.RenderEmojiPack
|
import com.vitorpamplona.amethyst.ui.note.types.RenderEmojiPack
|
||||||
import com.vitorpamplona.amethyst.ui.note.types.RenderFhirResource
|
import com.vitorpamplona.amethyst.ui.note.types.RenderFhirResource
|
||||||
import com.vitorpamplona.amethyst.ui.note.types.RenderGitIssueEvent
|
import com.vitorpamplona.amethyst.ui.note.types.RenderGitIssueEvent
|
||||||
@@ -107,7 +110,7 @@ import com.vitorpamplona.amethyst.ui.note.types.RenderTextModificationEvent
|
|||||||
import com.vitorpamplona.amethyst.ui.note.types.RenderWikiContent
|
import com.vitorpamplona.amethyst.ui.note.types.RenderWikiContent
|
||||||
import com.vitorpamplona.amethyst.ui.note.types.VideoDisplay
|
import com.vitorpamplona.amethyst.ui.note.types.VideoDisplay
|
||||||
import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel
|
import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel
|
||||||
import com.vitorpamplona.amethyst.ui.screen.loggedIn.ChannelHeader
|
import com.vitorpamplona.amethyst.ui.screen.loggedIn.RenderChannelHeader
|
||||||
import com.vitorpamplona.amethyst.ui.theme.DoubleHorzSpacer
|
import com.vitorpamplona.amethyst.ui.theme.DoubleHorzSpacer
|
||||||
import com.vitorpamplona.amethyst.ui.theme.DoubleVertSpacer
|
import com.vitorpamplona.amethyst.ui.theme.DoubleVertSpacer
|
||||||
import com.vitorpamplona.amethyst.ui.theme.Font12SP
|
import com.vitorpamplona.amethyst.ui.theme.Font12SP
|
||||||
@@ -136,6 +139,7 @@ import com.vitorpamplona.quartz.events.AppDefinitionEvent
|
|||||||
import com.vitorpamplona.quartz.events.AudioHeaderEvent
|
import com.vitorpamplona.quartz.events.AudioHeaderEvent
|
||||||
import com.vitorpamplona.quartz.events.AudioTrackEvent
|
import com.vitorpamplona.quartz.events.AudioTrackEvent
|
||||||
import com.vitorpamplona.quartz.events.BadgeAwardEvent
|
import com.vitorpamplona.quartz.events.BadgeAwardEvent
|
||||||
|
import com.vitorpamplona.quartz.events.BadgeDefinitionEvent
|
||||||
import com.vitorpamplona.quartz.events.BaseTextNoteEvent
|
import com.vitorpamplona.quartz.events.BaseTextNoteEvent
|
||||||
import com.vitorpamplona.quartz.events.ChannelCreateEvent
|
import com.vitorpamplona.quartz.events.ChannelCreateEvent
|
||||||
import com.vitorpamplona.quartz.events.ChannelMessageEvent
|
import com.vitorpamplona.quartz.events.ChannelMessageEvent
|
||||||
@@ -238,13 +242,22 @@ fun AcceptableNote(
|
|||||||
is ChannelCreateEvent,
|
is ChannelCreateEvent,
|
||||||
is ChannelMetadataEvent,
|
is ChannelMetadataEvent,
|
||||||
->
|
->
|
||||||
ChannelHeader(
|
RenderChannelHeader(
|
||||||
channelNote = baseNote,
|
channelNote = baseNote,
|
||||||
showVideo = !makeItShort,
|
showVideo = !makeItShort,
|
||||||
sendToChannel = true,
|
sendToChannel = true,
|
||||||
accountViewModel = accountViewModel,
|
accountViewModel = accountViewModel,
|
||||||
nav = nav,
|
nav = nav,
|
||||||
)
|
)
|
||||||
|
is CommunityDefinitionEvent ->
|
||||||
|
(baseNote as? AddressableNote)?.let {
|
||||||
|
RenderCommunity(
|
||||||
|
baseNote = it,
|
||||||
|
accountViewModel = accountViewModel,
|
||||||
|
nav = nav,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
is BadgeDefinitionEvent -> BadgeDisplay(baseNote = baseNote)
|
||||||
else ->
|
else ->
|
||||||
LongPressToQuickAction(baseNote = baseNote, accountViewModel = accountViewModel) {
|
LongPressToQuickAction(baseNote = baseNote, accountViewModel = accountViewModel) {
|
||||||
showPopup,
|
showPopup,
|
||||||
@@ -271,13 +284,22 @@ fun AcceptableNote(
|
|||||||
is ChannelCreateEvent,
|
is ChannelCreateEvent,
|
||||||
is ChannelMetadataEvent,
|
is ChannelMetadataEvent,
|
||||||
->
|
->
|
||||||
ChannelHeader(
|
RenderChannelHeader(
|
||||||
channelNote = baseNote,
|
channelNote = baseNote,
|
||||||
showVideo = !makeItShort,
|
showVideo = !makeItShort,
|
||||||
sendToChannel = true,
|
sendToChannel = true,
|
||||||
accountViewModel = accountViewModel,
|
accountViewModel = accountViewModel,
|
||||||
nav = nav,
|
nav = nav,
|
||||||
)
|
)
|
||||||
|
is CommunityDefinitionEvent ->
|
||||||
|
(baseNote as? AddressableNote)?.let {
|
||||||
|
RenderCommunity(
|
||||||
|
baseNote = it,
|
||||||
|
accountViewModel = accountViewModel,
|
||||||
|
nav = nav,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
is BadgeDefinitionEvent -> BadgeDisplay(baseNote = baseNote)
|
||||||
is FileHeaderEvent -> FileHeaderDisplay(baseNote, false, accountViewModel)
|
is FileHeaderEvent -> FileHeaderDisplay(baseNote, false, accountViewModel)
|
||||||
is FileStorageHeaderEvent -> FileStorageHeaderDisplay(baseNote, false, accountViewModel)
|
is FileStorageHeaderEvent -> FileStorageHeaderDisplay(baseNote, false, accountViewModel)
|
||||||
else ->
|
else ->
|
||||||
|
|||||||
@@ -25,12 +25,9 @@ import androidx.compose.foundation.layout.Arrangement
|
|||||||
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.Spacer
|
||||||
import androidx.compose.foundation.layout.fillMaxWidth
|
|
||||||
import androidx.compose.foundation.layout.height
|
import androidx.compose.foundation.layout.height
|
||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
import androidx.compose.foundation.layout.width
|
import androidx.compose.foundation.layout.width
|
||||||
import androidx.compose.foundation.rememberScrollState
|
|
||||||
import androidx.compose.foundation.verticalScroll
|
|
||||||
import androidx.compose.material3.MaterialTheme
|
import androidx.compose.material3.MaterialTheme
|
||||||
import androidx.compose.material3.Text
|
import androidx.compose.material3.Text
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
@@ -50,6 +47,7 @@ import androidx.lifecycle.distinctUntilChanged
|
|||||||
import androidx.lifecycle.map
|
import androidx.lifecycle.map
|
||||||
import com.vitorpamplona.amethyst.R
|
import com.vitorpamplona.amethyst.R
|
||||||
import com.vitorpamplona.amethyst.model.AddressableNote
|
import com.vitorpamplona.amethyst.model.AddressableNote
|
||||||
|
import com.vitorpamplona.amethyst.model.Note
|
||||||
import com.vitorpamplona.amethyst.model.User
|
import com.vitorpamplona.amethyst.model.User
|
||||||
import com.vitorpamplona.amethyst.ui.components.RobohashFallbackAsyncImage
|
import com.vitorpamplona.amethyst.ui.components.RobohashFallbackAsyncImage
|
||||||
import com.vitorpamplona.amethyst.ui.components.TranslatableRichTextViewer
|
import com.vitorpamplona.amethyst.ui.components.TranslatableRichTextViewer
|
||||||
@@ -74,7 +72,7 @@ import com.vitorpamplona.amethyst.ui.theme.Size25dp
|
|||||||
import com.vitorpamplona.amethyst.ui.theme.Size35dp
|
import com.vitorpamplona.amethyst.ui.theme.Size35dp
|
||||||
import com.vitorpamplona.amethyst.ui.theme.Size5dp
|
import com.vitorpamplona.amethyst.ui.theme.Size5dp
|
||||||
import com.vitorpamplona.amethyst.ui.theme.StdHorzSpacer
|
import com.vitorpamplona.amethyst.ui.theme.StdHorzSpacer
|
||||||
import com.vitorpamplona.amethyst.ui.theme.StdPadding
|
import com.vitorpamplona.amethyst.ui.theme.innerPostModifier
|
||||||
import com.vitorpamplona.quartz.events.CommunityDefinitionEvent
|
import com.vitorpamplona.quartz.events.CommunityDefinitionEvent
|
||||||
import com.vitorpamplona.quartz.events.EmptyTagList
|
import com.vitorpamplona.quartz.events.EmptyTagList
|
||||||
import com.vitorpamplona.quartz.events.Participant
|
import com.vitorpamplona.quartz.events.Participant
|
||||||
@@ -84,43 +82,22 @@ import kotlinx.collections.immutable.toImmutableList
|
|||||||
import java.util.Locale
|
import java.util.Locale
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun CommunityHeader(
|
fun RenderCommunity(
|
||||||
baseNote: AddressableNote,
|
baseNote: Note,
|
||||||
sendToCommunity: Boolean,
|
|
||||||
modifier: Modifier = StdPadding,
|
|
||||||
accountViewModel: AccountViewModel,
|
accountViewModel: AccountViewModel,
|
||||||
nav: (String) -> Unit,
|
nav: (String) -> Unit,
|
||||||
) {
|
) {
|
||||||
val expanded = remember { mutableStateOf(false) }
|
if (baseNote is AddressableNote) {
|
||||||
|
Row(
|
||||||
Column(Modifier.fillMaxWidth()) {
|
MaterialTheme.colorScheme.innerPostModifier.clickable {
|
||||||
Column(
|
routeFor(baseNote, accountViewModel.userProfile())?.let { nav(it) }
|
||||||
verticalArrangement = Arrangement.Center,
|
}.padding(Size10dp),
|
||||||
modifier =
|
|
||||||
Modifier.clickable {
|
|
||||||
if (sendToCommunity) {
|
|
||||||
routeFor(baseNote, accountViewModel.userProfile())?.let { nav(it) }
|
|
||||||
} else {
|
|
||||||
expanded.value = !expanded.value
|
|
||||||
}
|
|
||||||
},
|
|
||||||
) {
|
) {
|
||||||
ShortCommunityHeader(
|
ShortCommunityHeader(
|
||||||
baseNote = baseNote,
|
baseNote = baseNote,
|
||||||
accountViewModel = accountViewModel,
|
accountViewModel = accountViewModel,
|
||||||
nav = nav,
|
nav = nav,
|
||||||
)
|
)
|
||||||
|
|
||||||
if (expanded.value) {
|
|
||||||
Column(Modifier.verticalScroll(rememberScrollState())) {
|
|
||||||
LongCommunityHeader(
|
|
||||||
baseNote = baseNote,
|
|
||||||
lineModifier = modifier,
|
|
||||||
accountViewModel = accountViewModel,
|
|
||||||
nav = nav,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -58,9 +58,8 @@ fun RenderPostApproval(
|
|||||||
noteEvent.communities().forEach { tag ->
|
noteEvent.communities().forEach { tag ->
|
||||||
LoadAddressableNote(tag, accountViewModel) { baseNote ->
|
LoadAddressableNote(tag, accountViewModel) { baseNote ->
|
||||||
baseNote?.let {
|
baseNote?.let {
|
||||||
CommunityHeader(
|
RenderCommunity(
|
||||||
baseNote = it,
|
baseNote = it,
|
||||||
sendToCommunity = true,
|
|
||||||
accountViewModel = accountViewModel,
|
accountViewModel = accountViewModel,
|
||||||
nav = nav,
|
nav = nav,
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -147,6 +147,7 @@ import com.vitorpamplona.amethyst.ui.theme.EditFieldModifier
|
|||||||
import com.vitorpamplona.amethyst.ui.theme.EditFieldTrailingIconModifier
|
import com.vitorpamplona.amethyst.ui.theme.EditFieldTrailingIconModifier
|
||||||
import com.vitorpamplona.amethyst.ui.theme.HeaderPictureModifier
|
import com.vitorpamplona.amethyst.ui.theme.HeaderPictureModifier
|
||||||
import com.vitorpamplona.amethyst.ui.theme.RowColSpacing
|
import com.vitorpamplona.amethyst.ui.theme.RowColSpacing
|
||||||
|
import com.vitorpamplona.amethyst.ui.theme.Size10dp
|
||||||
import com.vitorpamplona.amethyst.ui.theme.Size25dp
|
import com.vitorpamplona.amethyst.ui.theme.Size25dp
|
||||||
import com.vitorpamplona.amethyst.ui.theme.Size34dp
|
import com.vitorpamplona.amethyst.ui.theme.Size34dp
|
||||||
import com.vitorpamplona.amethyst.ui.theme.Size35dp
|
import com.vitorpamplona.amethyst.ui.theme.Size35dp
|
||||||
@@ -154,6 +155,7 @@ import com.vitorpamplona.amethyst.ui.theme.SmallBorder
|
|||||||
import com.vitorpamplona.amethyst.ui.theme.StdHorzSpacer
|
import com.vitorpamplona.amethyst.ui.theme.StdHorzSpacer
|
||||||
import com.vitorpamplona.amethyst.ui.theme.StdPadding
|
import com.vitorpamplona.amethyst.ui.theme.StdPadding
|
||||||
import com.vitorpamplona.amethyst.ui.theme.ZeroPadding
|
import com.vitorpamplona.amethyst.ui.theme.ZeroPadding
|
||||||
|
import com.vitorpamplona.amethyst.ui.theme.innerPostModifier
|
||||||
import com.vitorpamplona.amethyst.ui.theme.liveStreamTag
|
import com.vitorpamplona.amethyst.ui.theme.liveStreamTag
|
||||||
import com.vitorpamplona.amethyst.ui.theme.placeholderText
|
import com.vitorpamplona.amethyst.ui.theme.placeholderText
|
||||||
import com.vitorpamplona.quartz.events.EmptyTagList
|
import com.vitorpamplona.quartz.events.EmptyTagList
|
||||||
@@ -587,6 +589,25 @@ fun MyTextField(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun RenderChannelHeader(
|
||||||
|
channelNote: Note,
|
||||||
|
showVideo: Boolean,
|
||||||
|
sendToChannel: Boolean,
|
||||||
|
modifier: Modifier = StdPadding,
|
||||||
|
accountViewModel: AccountViewModel,
|
||||||
|
nav: (String) -> Unit,
|
||||||
|
) {
|
||||||
|
ChannelHeader(
|
||||||
|
channelNote = channelNote,
|
||||||
|
showVideo = showVideo,
|
||||||
|
sendToChannel = sendToChannel,
|
||||||
|
modifier = MaterialTheme.colorScheme.innerPostModifier.padding(Size10dp),
|
||||||
|
accountViewModel = accountViewModel,
|
||||||
|
nav = nav,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun ChannelHeader(
|
fun ChannelHeader(
|
||||||
channelNote: Note,
|
channelNote: Note,
|
||||||
|
|||||||
Reference in New Issue
Block a user