check for load images option
This commit is contained in:
+17
@@ -15,6 +15,7 @@ import androidx.compose.runtime.Composable
|
|||||||
import androidx.compose.runtime.MutableState
|
import androidx.compose.runtime.MutableState
|
||||||
import androidx.compose.runtime.derivedStateOf
|
import androidx.compose.runtime.derivedStateOf
|
||||||
import androidx.compose.runtime.getValue
|
import androidx.compose.runtime.getValue
|
||||||
|
import androidx.compose.runtime.livedata.observeAsState
|
||||||
import androidx.compose.runtime.mutableStateOf
|
import androidx.compose.runtime.mutableStateOf
|
||||||
import androidx.compose.runtime.remember
|
import androidx.compose.runtime.remember
|
||||||
import androidx.compose.runtime.setValue
|
import androidx.compose.runtime.setValue
|
||||||
@@ -24,6 +25,7 @@ import androidx.compose.ui.graphics.Color
|
|||||||
import androidx.compose.ui.res.stringResource
|
import androidx.compose.ui.res.stringResource
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import com.vitorpamplona.amethyst.R
|
import com.vitorpamplona.amethyst.R
|
||||||
|
import com.vitorpamplona.amethyst.service.connectivitystatus.ConnectivityStatus
|
||||||
import com.vitorpamplona.amethyst.ui.actions.ImmutableListOfLists
|
import com.vitorpamplona.amethyst.ui.actions.ImmutableListOfLists
|
||||||
import com.vitorpamplona.amethyst.ui.note.getGradient
|
import com.vitorpamplona.amethyst.ui.note.getGradient
|
||||||
import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel
|
import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel
|
||||||
@@ -42,6 +44,20 @@ fun ExpandableRichTextViewer(
|
|||||||
accountViewModel: AccountViewModel,
|
accountViewModel: AccountViewModel,
|
||||||
nav: (String) -> Unit
|
nav: (String) -> Unit
|
||||||
) {
|
) {
|
||||||
|
val accountState by accountViewModel.accountLiveData.observeAsState()
|
||||||
|
val settings = accountState?.account?.settings
|
||||||
|
val isMobile = ConnectivityStatus.isOnMobileData.value
|
||||||
|
|
||||||
|
val showImage = remember {
|
||||||
|
mutableStateOf(
|
||||||
|
when (settings?.automaticallyShowImages) {
|
||||||
|
true -> !isMobile
|
||||||
|
false -> false
|
||||||
|
else -> true
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
var showFullText by remember { mutableStateOf(false) }
|
var showFullText by remember { mutableStateOf(false) }
|
||||||
|
|
||||||
val whereToCut = remember(content) {
|
val whereToCut = remember(content) {
|
||||||
@@ -70,6 +86,7 @@ fun ExpandableRichTextViewer(
|
|||||||
tags,
|
tags,
|
||||||
backgroundColor,
|
backgroundColor,
|
||||||
accountViewModel,
|
accountViewModel,
|
||||||
|
showImage,
|
||||||
nav
|
nav
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -108,13 +108,14 @@ fun RichTextViewer(
|
|||||||
tags: ImmutableListOfLists<String>,
|
tags: ImmutableListOfLists<String>,
|
||||||
backgroundColor: MutableState<Color>,
|
backgroundColor: MutableState<Color>,
|
||||||
accountViewModel: AccountViewModel,
|
accountViewModel: AccountViewModel,
|
||||||
|
showImage: MutableState<Boolean>,
|
||||||
nav: (String) -> Unit
|
nav: (String) -> Unit
|
||||||
) {
|
) {
|
||||||
Column(modifier = modifier) {
|
Column(modifier = modifier) {
|
||||||
if (remember(content) { isMarkdown(content) }) {
|
if (remember(content) { isMarkdown(content) }) {
|
||||||
RenderContentAsMarkdown(content, tags, nav)
|
RenderContentAsMarkdown(content, tags, nav)
|
||||||
} else {
|
} else {
|
||||||
RenderRegular(content, tags, canPreview, backgroundColor, accountViewModel, nav)
|
RenderRegular(content, tags, canPreview, backgroundColor, accountViewModel, showImage, nav)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -127,6 +128,7 @@ private fun RenderRegular(
|
|||||||
canPreview: Boolean,
|
canPreview: Boolean,
|
||||||
backgroundColor: MutableState<Color>,
|
backgroundColor: MutableState<Color>,
|
||||||
accountViewModel: AccountViewModel,
|
accountViewModel: AccountViewModel,
|
||||||
|
showImage: MutableState<Boolean>,
|
||||||
nav: (String) -> Unit
|
nav: (String) -> Unit
|
||||||
) {
|
) {
|
||||||
val state by remember(content) {
|
val state by remember(content) {
|
||||||
@@ -156,6 +158,7 @@ private fun RenderRegular(
|
|||||||
backgroundColor,
|
backgroundColor,
|
||||||
textStyle,
|
textStyle,
|
||||||
accountViewModel,
|
accountViewModel,
|
||||||
|
showImage,
|
||||||
nav
|
nav
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -235,10 +238,11 @@ private fun RenderWordWithPreview(
|
|||||||
backgroundColor: MutableState<Color>,
|
backgroundColor: MutableState<Color>,
|
||||||
style: TextStyle,
|
style: TextStyle,
|
||||||
accountViewModel: AccountViewModel,
|
accountViewModel: AccountViewModel,
|
||||||
|
showImage: MutableState<Boolean>,
|
||||||
nav: (String) -> Unit
|
nav: (String) -> Unit
|
||||||
) {
|
) {
|
||||||
when (word) {
|
when (word) {
|
||||||
is ImageSegment -> ZoomableContentView(word.segmentText, state)
|
is ImageSegment -> ZoomableContentView(word.segmentText, state, showImage)
|
||||||
is LinkSegment -> UrlPreview(word.segmentText, word.segmentText)
|
is LinkSegment -> UrlPreview(word.segmentText, word.segmentText)
|
||||||
is EmojiSegment -> RenderCustomEmoji(word.segmentText, state)
|
is EmojiSegment -> RenderCustomEmoji(word.segmentText, state)
|
||||||
is InvoiceSegment -> MayBeInvoicePreview(word.segmentText)
|
is InvoiceSegment -> MayBeInvoicePreview(word.segmentText)
|
||||||
@@ -256,9 +260,9 @@ private fun RenderWordWithPreview(
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
private fun ZoomableContentView(word: String, state: RichTextViewerState) {
|
private fun ZoomableContentView(word: String, state: RichTextViewerState, showImage: MutableState<Boolean>) {
|
||||||
state.imagesForPager[word]?.let {
|
state.imagesForPager[word]?.let {
|
||||||
ZoomableContentView(it, state.imageList)
|
ZoomableContentView(it, state.imageList, showImage)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -253,6 +253,9 @@ private fun RenderVideoPlayer(
|
|||||||
.defaultMinSize(minHeight = 70.dp)
|
.defaultMinSize(minHeight = 70.dp)
|
||||||
.align(Alignment.Center)
|
.align(Alignment.Center)
|
||||||
.onVisibilityChanges { visible ->
|
.onVisibilityChanges { visible ->
|
||||||
|
if (!showVideo.value) {
|
||||||
|
playerData.exoPlayer.stop()
|
||||||
|
}
|
||||||
if (!showVideo.value && visible && !playerData.exoPlayer.isPlaying) {
|
if (!showVideo.value && visible && !playerData.exoPlayer.isPlaying) {
|
||||||
playerData.exoPlayer.pause()
|
playerData.exoPlayer.pause()
|
||||||
} else if (visible && !playerData.exoPlayer.isPlaying) {
|
} else if (visible && !playerData.exoPlayer.isPlaying) {
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import android.os.Build
|
|||||||
import android.util.Log
|
import android.util.Log
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
import androidx.compose.foundation.ExperimentalFoundationApi
|
import androidx.compose.foundation.ExperimentalFoundationApi
|
||||||
import androidx.compose.foundation.background
|
|
||||||
import androidx.compose.foundation.clickable
|
import androidx.compose.foundation.clickable
|
||||||
import androidx.compose.foundation.combinedClickable
|
import androidx.compose.foundation.combinedClickable
|
||||||
import androidx.compose.foundation.layout.Arrangement
|
import androidx.compose.foundation.layout.Arrangement
|
||||||
@@ -72,7 +71,6 @@ import coil.imageLoader
|
|||||||
import com.vitorpamplona.amethyst.R
|
import com.vitorpamplona.amethyst.R
|
||||||
import com.vitorpamplona.amethyst.model.toHexKey
|
import com.vitorpamplona.amethyst.model.toHexKey
|
||||||
import com.vitorpamplona.amethyst.service.BlurHashRequester
|
import com.vitorpamplona.amethyst.service.BlurHashRequester
|
||||||
import com.vitorpamplona.amethyst.service.connectivitystatus.ConnectivityStatus
|
|
||||||
import com.vitorpamplona.amethyst.ui.actions.CloseButton
|
import com.vitorpamplona.amethyst.ui.actions.CloseButton
|
||||||
import com.vitorpamplona.amethyst.ui.actions.LoadingAnimation
|
import com.vitorpamplona.amethyst.ui.actions.LoadingAnimation
|
||||||
import com.vitorpamplona.amethyst.ui.actions.SaveToGallery
|
import com.vitorpamplona.amethyst.ui.actions.SaveToGallery
|
||||||
@@ -170,7 +168,7 @@ fun figureOutMimeType(fullUrl: String): ZoomableContent {
|
|||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
@OptIn(ExperimentalFoundationApi::class)
|
@OptIn(ExperimentalFoundationApi::class)
|
||||||
fun ZoomableContentView(content: ZoomableContent, images: ImmutableList<ZoomableContent> = listOf(content).toImmutableList()) {
|
fun ZoomableContentView(content: ZoomableContent, images: ImmutableList<ZoomableContent> = listOf(content).toImmutableList(), showImage: MutableState<Boolean>) {
|
||||||
val clipboardManager = LocalClipboardManager.current
|
val clipboardManager = LocalClipboardManager.current
|
||||||
|
|
||||||
// store the dialog open or close state
|
// store the dialog open or close state
|
||||||
@@ -178,12 +176,6 @@ fun ZoomableContentView(content: ZoomableContent, images: ImmutableList<Zoomable
|
|||||||
mutableStateOf(false)
|
mutableStateOf(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
val isOnMobileData by ConnectivityStatus.isOnMobileData
|
|
||||||
|
|
||||||
val showImage = remember {
|
|
||||||
mutableStateOf(!isOnMobileData)
|
|
||||||
}
|
|
||||||
|
|
||||||
var mainImageModifier = MaterialTheme.colors.imageModifier
|
var mainImageModifier = MaterialTheme.colors.imageModifier
|
||||||
|
|
||||||
if (content is ZoomableUrlContent) {
|
if (content is ZoomableUrlContent) {
|
||||||
@@ -205,7 +197,7 @@ fun ZoomableContentView(content: ZoomableContent, images: ImmutableList<Zoomable
|
|||||||
when (content) {
|
when (content) {
|
||||||
is ZoomableUrlImage -> UrlImageView(content, mainImageModifier, showImage)
|
is ZoomableUrlImage -> UrlImageView(content, mainImageModifier, showImage)
|
||||||
is ZoomableUrlVideo -> VideoView(content.url, content.description, showVideo = showImage) { dialogOpen = true }
|
is ZoomableUrlVideo -> VideoView(content.url, content.description, showVideo = showImage) { dialogOpen = true }
|
||||||
is ZoomableLocalImage -> LocalImageView(content, mainImageModifier)
|
is ZoomableLocalImage -> LocalImageView(content, mainImageModifier, showImage)
|
||||||
is ZoomableLocalVideo ->
|
is ZoomableLocalVideo ->
|
||||||
content.localFile?.let {
|
content.localFile?.let {
|
||||||
VideoView(it.toUri().toString(), content.description, showVideo = showImage) { dialogOpen = true }
|
VideoView(it.toUri().toString(), content.description, showVideo = showImage) { dialogOpen = true }
|
||||||
@@ -220,7 +212,8 @@ fun ZoomableContentView(content: ZoomableContent, images: ImmutableList<Zoomable
|
|||||||
@Composable
|
@Composable
|
||||||
private fun LocalImageView(
|
private fun LocalImageView(
|
||||||
content: ZoomableLocalImage,
|
content: ZoomableLocalImage,
|
||||||
mainImageModifier: Modifier
|
mainImageModifier: Modifier,
|
||||||
|
showImage: MutableState<Boolean>
|
||||||
) {
|
) {
|
||||||
if (content.localFile != null && content.localFile.exists()) {
|
if (content.localFile != null && content.localFile.exists()) {
|
||||||
BoxWithConstraints(contentAlignment = Alignment.Center) {
|
BoxWithConstraints(contentAlignment = Alignment.Center) {
|
||||||
@@ -245,17 +238,19 @@ private fun LocalImageView(
|
|||||||
mutableStateOf<AsyncImagePainter.State?>(null)
|
mutableStateOf<AsyncImagePainter.State?>(null)
|
||||||
}
|
}
|
||||||
|
|
||||||
AsyncImage(
|
if (showImage.value) {
|
||||||
model = content.localFile,
|
AsyncImage(
|
||||||
contentDescription = content.description,
|
model = content.localFile,
|
||||||
contentScale = contentScale,
|
contentDescription = content.description,
|
||||||
modifier = myModifier,
|
contentScale = contentScale,
|
||||||
onState = {
|
modifier = myModifier,
|
||||||
painterState.value = it
|
onState = {
|
||||||
}
|
painterState.value = it
|
||||||
)
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
AddedImageFeatures(painterState, content, contentScale, myModifier, verifierModifier)
|
AddedImageFeatures(painterState, content, contentScale, myModifier, verifierModifier, showImage)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
BlankNote()
|
BlankNote()
|
||||||
@@ -313,8 +308,18 @@ private fun AddedImageFeatures(
|
|||||||
content: ZoomableLocalImage,
|
content: ZoomableLocalImage,
|
||||||
contentScale: ContentScale,
|
contentScale: ContentScale,
|
||||||
myModifier: Modifier,
|
myModifier: Modifier,
|
||||||
verifiedModifier: Modifier
|
verifiedModifier: Modifier,
|
||||||
|
showImage: MutableState<Boolean>
|
||||||
) {
|
) {
|
||||||
|
if (!showImage.value) {
|
||||||
|
return Column(horizontalAlignment = Alignment.CenterHorizontally) {
|
||||||
|
ClickableUrl(urlText = "${content.uri} ", url = content.uri)
|
||||||
|
Button(onClick = { showImage.value = true }) {
|
||||||
|
Text("Load image")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
when (painter.value) {
|
when (painter.value) {
|
||||||
null, is AsyncImagePainter.State.Loading -> {
|
null, is AsyncImagePainter.State.Loading -> {
|
||||||
if (content.blurhash != null) {
|
if (content.blurhash != null) {
|
||||||
@@ -537,11 +542,11 @@ fun ZoomableImageDialog(imageUrl: ZoomableContent, allImages: ImmutableList<Zoom
|
|||||||
pagerState = pagerState,
|
pagerState = pagerState,
|
||||||
itemsCount = allImages.size,
|
itemsCount = allImages.size,
|
||||||
itemContent = { index ->
|
itemContent = { index ->
|
||||||
RenderImageOrVideo(allImages[index])
|
RenderImageOrVideo(allImages[index], remember { mutableStateOf(true) })
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
RenderImageOrVideo(imageUrl)
|
RenderImageOrVideo(imageUrl, remember { mutableStateOf(true) })
|
||||||
}
|
}
|
||||||
|
|
||||||
Row(
|
Row(
|
||||||
@@ -566,13 +571,10 @@ fun ZoomableImageDialog(imageUrl: ZoomableContent, allImages: ImmutableList<Zoom
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun RenderImageOrVideo(content: ZoomableContent) {
|
fun RenderImageOrVideo(content: ZoomableContent, showImage: MutableState<Boolean>) {
|
||||||
val mainModifier = Modifier
|
val mainModifier = Modifier
|
||||||
.fillMaxSize()
|
.fillMaxSize()
|
||||||
.zoomable(rememberZoomState())
|
.zoomable(rememberZoomState())
|
||||||
val showImage = remember {
|
|
||||||
mutableStateOf(true)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (content is ZoomableUrlImage) {
|
if (content is ZoomableUrlImage) {
|
||||||
UrlImageView(content = content, mainImageModifier = mainModifier, showImage)
|
UrlImageView(content = content, mainImageModifier = mainModifier, showImage)
|
||||||
@@ -581,7 +583,7 @@ fun RenderImageOrVideo(content: ZoomableContent) {
|
|||||||
VideoView(content.url, content.description, showVideo = showImage)
|
VideoView(content.url, content.description, showVideo = showImage)
|
||||||
}
|
}
|
||||||
} else if (content is ZoomableLocalImage) {
|
} else if (content is ZoomableLocalImage) {
|
||||||
LocalImageView(content = content, mainImageModifier = mainModifier)
|
LocalImageView(content = content, mainImageModifier = mainModifier, showImage)
|
||||||
} else if (content is ZoomableLocalVideo) {
|
} else if (content is ZoomableLocalVideo) {
|
||||||
Row(verticalAlignment = Alignment.CenterVertically, modifier = Modifier.fillMaxSize(1f)) {
|
Row(verticalAlignment = Alignment.CenterVertically, modifier = Modifier.fillMaxSize(1f)) {
|
||||||
content.localFile?.let {
|
content.localFile?.let {
|
||||||
|
|||||||
@@ -52,6 +52,7 @@ import com.vitorpamplona.amethyst.model.User
|
|||||||
import com.vitorpamplona.amethyst.service.OnlineChecker
|
import com.vitorpamplona.amethyst.service.OnlineChecker
|
||||||
import com.vitorpamplona.amethyst.service.model.ChannelCreateEvent
|
import com.vitorpamplona.amethyst.service.model.ChannelCreateEvent
|
||||||
import com.vitorpamplona.amethyst.service.model.CommunityDefinitionEvent
|
import com.vitorpamplona.amethyst.service.model.CommunityDefinitionEvent
|
||||||
|
import com.vitorpamplona.amethyst.service.connectivitystatus.ConnectivityStatus
|
||||||
import com.vitorpamplona.amethyst.service.model.LiveActivitiesEvent
|
import com.vitorpamplona.amethyst.service.model.LiveActivitiesEvent
|
||||||
import com.vitorpamplona.amethyst.service.model.LiveActivitiesEvent.Companion.STATUS_ENDED
|
import com.vitorpamplona.amethyst.service.model.LiveActivitiesEvent.Companion.STATUS_ENDED
|
||||||
import com.vitorpamplona.amethyst.service.model.LiveActivitiesEvent.Companion.STATUS_LIVE
|
import com.vitorpamplona.amethyst.service.model.LiveActivitiesEvent.Companion.STATUS_LIVE
|
||||||
@@ -93,6 +94,20 @@ fun ChannelCardCompose(
|
|||||||
it.note.event == null
|
it.note.event == null
|
||||||
}.distinctUntilChanged().observeAsState(baseNote.event == null)
|
}.distinctUntilChanged().observeAsState(baseNote.event == null)
|
||||||
|
|
||||||
|
val accountState by accountViewModel.accountLiveData.observeAsState()
|
||||||
|
val settings = accountState?.account?.settings
|
||||||
|
val isMobile = ConnectivityStatus.isOnMobileData.value
|
||||||
|
|
||||||
|
val showImage = remember {
|
||||||
|
mutableStateOf(
|
||||||
|
when (settings?.automaticallyShowImages) {
|
||||||
|
true -> !isMobile
|
||||||
|
false -> false
|
||||||
|
else -> true
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
Crossfade(targetState = isBlank) {
|
Crossfade(targetState = isBlank) {
|
||||||
if (it) {
|
if (it) {
|
||||||
LongPressToQuickAction(baseNote = baseNote, accountViewModel = accountViewModel) { showPopup ->
|
LongPressToQuickAction(baseNote = baseNote, accountViewModel = accountViewModel) { showPopup ->
|
||||||
@@ -113,6 +128,7 @@ fun ChannelCardCompose(
|
|||||||
modifier,
|
modifier,
|
||||||
parentBackgroundColor,
|
parentBackgroundColor,
|
||||||
accountViewModel,
|
accountViewModel,
|
||||||
|
showImage,
|
||||||
nav
|
nav
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -126,6 +142,7 @@ fun CheckHiddenChannelCardCompose(
|
|||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
parentBackgroundColor: MutableState<Color>? = null,
|
parentBackgroundColor: MutableState<Color>? = null,
|
||||||
accountViewModel: AccountViewModel,
|
accountViewModel: AccountViewModel,
|
||||||
|
showImage: MutableState<Boolean>,
|
||||||
nav: (String) -> Unit
|
nav: (String) -> Unit
|
||||||
) {
|
) {
|
||||||
val isHidden by accountViewModel.accountLiveData.map {
|
val isHidden by accountViewModel.accountLiveData.map {
|
||||||
@@ -140,6 +157,7 @@ fun CheckHiddenChannelCardCompose(
|
|||||||
modifier,
|
modifier,
|
||||||
parentBackgroundColor,
|
parentBackgroundColor,
|
||||||
accountViewModel,
|
accountViewModel,
|
||||||
|
showImage,
|
||||||
nav
|
nav
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -153,6 +171,7 @@ fun LoadedChannelCardCompose(
|
|||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
parentBackgroundColor: MutableState<Color>? = null,
|
parentBackgroundColor: MutableState<Color>? = null,
|
||||||
accountViewModel: AccountViewModel,
|
accountViewModel: AccountViewModel,
|
||||||
|
showImage: MutableState<Boolean>,
|
||||||
nav: (String) -> Unit
|
nav: (String) -> Unit
|
||||||
) {
|
) {
|
||||||
var state by remember {
|
var state by remember {
|
||||||
@@ -184,6 +203,7 @@ fun LoadedChannelCardCompose(
|
|||||||
modifier,
|
modifier,
|
||||||
parentBackgroundColor,
|
parentBackgroundColor,
|
||||||
accountViewModel,
|
accountViewModel,
|
||||||
|
showImage,
|
||||||
nav
|
nav
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -197,6 +217,7 @@ fun RenderChannelCardReportState(
|
|||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
parentBackgroundColor: MutableState<Color>? = null,
|
parentBackgroundColor: MutableState<Color>? = null,
|
||||||
accountViewModel: AccountViewModel,
|
accountViewModel: AccountViewModel,
|
||||||
|
showImage: MutableState<Boolean>,
|
||||||
nav: (String) -> Unit
|
nav: (String) -> Unit
|
||||||
) {
|
) {
|
||||||
var showReportedNote by remember { mutableStateOf(false) }
|
var showReportedNote by remember { mutableStateOf(false) }
|
||||||
@@ -218,6 +239,7 @@ fun RenderChannelCardReportState(
|
|||||||
modifier,
|
modifier,
|
||||||
parentBackgroundColor,
|
parentBackgroundColor,
|
||||||
accountViewModel,
|
accountViewModel,
|
||||||
|
showImage,
|
||||||
nav
|
nav
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -231,6 +253,7 @@ fun NormalChannelCard(
|
|||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
parentBackgroundColor: MutableState<Color>? = null,
|
parentBackgroundColor: MutableState<Color>? = null,
|
||||||
accountViewModel: AccountViewModel,
|
accountViewModel: AccountViewModel,
|
||||||
|
showImage: MutableState<Boolean>,
|
||||||
nav: (String) -> Unit
|
nav: (String) -> Unit
|
||||||
) {
|
) {
|
||||||
LongPressToQuickAction(baseNote = baseNote, accountViewModel = accountViewModel) { showPopup ->
|
LongPressToQuickAction(baseNote = baseNote, accountViewModel = accountViewModel) { showPopup ->
|
||||||
@@ -240,6 +263,7 @@ fun NormalChannelCard(
|
|||||||
modifier,
|
modifier,
|
||||||
parentBackgroundColor,
|
parentBackgroundColor,
|
||||||
accountViewModel,
|
accountViewModel,
|
||||||
|
showImage,
|
||||||
showPopup,
|
showPopup,
|
||||||
nav
|
nav
|
||||||
)
|
)
|
||||||
@@ -253,6 +277,7 @@ private fun CheckNewAndRenderChannelCard(
|
|||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
parentBackgroundColor: MutableState<Color>? = null,
|
parentBackgroundColor: MutableState<Color>? = null,
|
||||||
accountViewModel: AccountViewModel,
|
accountViewModel: AccountViewModel,
|
||||||
|
showImage: MutableState<Boolean>,
|
||||||
showPopup: () -> Unit,
|
showPopup: () -> Unit,
|
||||||
nav: (String) -> Unit
|
nav: (String) -> Unit
|
||||||
) {
|
) {
|
||||||
@@ -310,6 +335,7 @@ private fun CheckNewAndRenderChannelCard(
|
|||||||
InnerChannelCardWithReactions(
|
InnerChannelCardWithReactions(
|
||||||
baseNote = baseNote,
|
baseNote = baseNote,
|
||||||
accountViewModel = accountViewModel,
|
accountViewModel = accountViewModel,
|
||||||
|
showImage,
|
||||||
nav = nav
|
nav = nav
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -319,6 +345,7 @@ private fun CheckNewAndRenderChannelCard(
|
|||||||
fun InnerChannelCardWithReactions(
|
fun InnerChannelCardWithReactions(
|
||||||
baseNote: Note,
|
baseNote: Note,
|
||||||
accountViewModel: AccountViewModel,
|
accountViewModel: AccountViewModel,
|
||||||
|
showImage: MutableState<Boolean>,
|
||||||
nav: (String) -> Unit
|
nav: (String) -> Unit
|
||||||
) {
|
) {
|
||||||
Column(StdPadding) {
|
Column(StdPadding) {
|
||||||
@@ -339,11 +366,12 @@ fun InnerChannelCardWithReactions(
|
|||||||
private fun RenderNoteRow(
|
private fun RenderNoteRow(
|
||||||
baseNote: Note,
|
baseNote: Note,
|
||||||
accountViewModel: AccountViewModel,
|
accountViewModel: AccountViewModel,
|
||||||
|
showImage: MutableState<Boolean>,
|
||||||
nav: (String) -> Unit
|
nav: (String) -> Unit
|
||||||
) {
|
) {
|
||||||
when (remember { baseNote.event }) {
|
when (remember { baseNote.event }) {
|
||||||
is LiveActivitiesEvent -> {
|
is LiveActivitiesEvent -> {
|
||||||
RenderLiveActivityThumb(baseNote, accountViewModel, nav)
|
RenderLiveActivityThumb(baseNote, accountViewModel, showImage, nav)
|
||||||
}
|
}
|
||||||
is CommunityDefinitionEvent -> {
|
is CommunityDefinitionEvent -> {
|
||||||
RenderCommunitiesThumb(baseNote, accountViewModel, nav)
|
RenderCommunitiesThumb(baseNote, accountViewModel, nav)
|
||||||
@@ -355,7 +383,7 @@ private fun RenderNoteRow(
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun RenderLiveActivityThumb(baseNote: Note, accountViewModel: AccountViewModel, nav: (String) -> Unit) {
|
fun RenderLiveActivityThumb(baseNote: Note, accountViewModel: AccountViewModel, showImage: MutableState<Boolean>, nav: (String) -> Unit) {
|
||||||
val noteEvent = baseNote.event as? LiveActivitiesEvent ?: return
|
val noteEvent = baseNote.event as? LiveActivitiesEvent ?: return
|
||||||
|
|
||||||
val eventUpdates by baseNote.live().metadata.observeAsState()
|
val eventUpdates by baseNote.live().metadata.observeAsState()
|
||||||
@@ -492,6 +520,7 @@ fun RenderLiveActivityThumb(baseNote: Note, accountViewModel: AccountViewModel,
|
|||||||
Modifier.padding(start = 0.dp, end = 0.dp, top = 5.dp, bottom = 5.dp)
|
Modifier.padding(start = 0.dp, end = 0.dp, top = 5.dp, bottom = 5.dp)
|
||||||
},
|
},
|
||||||
accountViewModel = accountViewModel,
|
accountViewModel = accountViewModel,
|
||||||
|
showImage = showImage,
|
||||||
nav = nav
|
nav = nav
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -86,6 +86,7 @@ import com.vitorpamplona.amethyst.model.User
|
|||||||
import com.vitorpamplona.amethyst.model.UserMetadata
|
import com.vitorpamplona.amethyst.model.UserMetadata
|
||||||
import com.vitorpamplona.amethyst.service.OnlineChecker
|
import com.vitorpamplona.amethyst.service.OnlineChecker
|
||||||
import com.vitorpamplona.amethyst.service.model.ATag
|
import com.vitorpamplona.amethyst.service.model.ATag
|
||||||
|
import com.vitorpamplona.amethyst.service.connectivitystatus.ConnectivityStatus
|
||||||
import com.vitorpamplona.amethyst.service.model.AppDefinitionEvent
|
import com.vitorpamplona.amethyst.service.model.AppDefinitionEvent
|
||||||
import com.vitorpamplona.amethyst.service.model.AudioTrackEvent
|
import com.vitorpamplona.amethyst.service.model.AudioTrackEvent
|
||||||
import com.vitorpamplona.amethyst.service.model.BadgeAwardEvent
|
import com.vitorpamplona.amethyst.service.model.BadgeAwardEvent
|
||||||
@@ -210,6 +211,20 @@ fun NoteCompose(
|
|||||||
it.note.event == null
|
it.note.event == null
|
||||||
}.distinctUntilChanged().observeAsState(baseNote.event == null)
|
}.distinctUntilChanged().observeAsState(baseNote.event == null)
|
||||||
|
|
||||||
|
val accountState by accountViewModel.accountLiveData.observeAsState()
|
||||||
|
val settings = accountState?.account?.settings
|
||||||
|
val isMobile = ConnectivityStatus.isOnMobileData.value
|
||||||
|
|
||||||
|
val showImage = remember {
|
||||||
|
mutableStateOf(
|
||||||
|
when (settings?.automaticallyShowImages) {
|
||||||
|
true -> !isMobile
|
||||||
|
false -> false
|
||||||
|
else -> true
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
Crossfade(targetState = isBlank) {
|
Crossfade(targetState = isBlank) {
|
||||||
if (it) {
|
if (it) {
|
||||||
LongPressToQuickAction(baseNote = baseNote, accountViewModel = accountViewModel) { showPopup ->
|
LongPressToQuickAction(baseNote = baseNote, accountViewModel = accountViewModel) { showPopup ->
|
||||||
@@ -235,6 +250,7 @@ fun NoteCompose(
|
|||||||
addMarginTop,
|
addMarginTop,
|
||||||
parentBackgroundColor,
|
parentBackgroundColor,
|
||||||
accountViewModel,
|
accountViewModel,
|
||||||
|
showImage,
|
||||||
nav
|
nav
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -253,6 +269,7 @@ fun CheckHiddenNoteCompose(
|
|||||||
addMarginTop: Boolean = true,
|
addMarginTop: Boolean = true,
|
||||||
parentBackgroundColor: MutableState<Color>? = null,
|
parentBackgroundColor: MutableState<Color>? = null,
|
||||||
accountViewModel: AccountViewModel,
|
accountViewModel: AccountViewModel,
|
||||||
|
showImage: MutableState<Boolean>,
|
||||||
nav: (String) -> Unit
|
nav: (String) -> Unit
|
||||||
) {
|
) {
|
||||||
val isHidden by accountViewModel.accountLiveData.map {
|
val isHidden by accountViewModel.accountLiveData.map {
|
||||||
@@ -272,6 +289,7 @@ fun CheckHiddenNoteCompose(
|
|||||||
addMarginTop,
|
addMarginTop,
|
||||||
parentBackgroundColor,
|
parentBackgroundColor,
|
||||||
accountViewModel,
|
accountViewModel,
|
||||||
|
showImage,
|
||||||
nav
|
nav
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -297,6 +315,7 @@ fun LoadedNoteCompose(
|
|||||||
addMarginTop: Boolean = true,
|
addMarginTop: Boolean = true,
|
||||||
parentBackgroundColor: MutableState<Color>? = null,
|
parentBackgroundColor: MutableState<Color>? = null,
|
||||||
accountViewModel: AccountViewModel,
|
accountViewModel: AccountViewModel,
|
||||||
|
showImage: MutableState<Boolean>,
|
||||||
nav: (String) -> Unit
|
nav: (String) -> Unit
|
||||||
) {
|
) {
|
||||||
var state by remember {
|
var state by remember {
|
||||||
@@ -333,6 +352,7 @@ fun LoadedNoteCompose(
|
|||||||
addMarginTop,
|
addMarginTop,
|
||||||
parentBackgroundColor,
|
parentBackgroundColor,
|
||||||
accountViewModel,
|
accountViewModel,
|
||||||
|
showImage,
|
||||||
nav
|
nav
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -351,6 +371,7 @@ fun RenderReportState(
|
|||||||
addMarginTop: Boolean = true,
|
addMarginTop: Boolean = true,
|
||||||
parentBackgroundColor: MutableState<Color>? = null,
|
parentBackgroundColor: MutableState<Color>? = null,
|
||||||
accountViewModel: AccountViewModel,
|
accountViewModel: AccountViewModel,
|
||||||
|
showImage: MutableState<Boolean>,
|
||||||
nav: (String) -> Unit
|
nav: (String) -> Unit
|
||||||
) {
|
) {
|
||||||
var showReportedNote by remember { mutableStateOf(false) }
|
var showReportedNote by remember { mutableStateOf(false) }
|
||||||
@@ -380,6 +401,7 @@ fun RenderReportState(
|
|||||||
canPreview,
|
canPreview,
|
||||||
parentBackgroundColor,
|
parentBackgroundColor,
|
||||||
accountViewModel,
|
accountViewModel,
|
||||||
|
showImage,
|
||||||
nav
|
nav
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -415,6 +437,7 @@ fun NormalNote(
|
|||||||
canPreview: Boolean = true,
|
canPreview: Boolean = true,
|
||||||
parentBackgroundColor: MutableState<Color>? = null,
|
parentBackgroundColor: MutableState<Color>? = null,
|
||||||
accountViewModel: AccountViewModel,
|
accountViewModel: AccountViewModel,
|
||||||
|
showImage: MutableState<Boolean>,
|
||||||
nav: (String) -> Unit
|
nav: (String) -> Unit
|
||||||
) {
|
) {
|
||||||
when (baseNote.event) {
|
when (baseNote.event) {
|
||||||
@@ -423,6 +446,7 @@ fun NormalNote(
|
|||||||
showVideo = !makeItShort,
|
showVideo = !makeItShort,
|
||||||
showBottomDiviser = true,
|
showBottomDiviser = true,
|
||||||
accountViewModel = accountViewModel,
|
accountViewModel = accountViewModel,
|
||||||
|
showImage = showImage,
|
||||||
nav = nav
|
nav = nav
|
||||||
)
|
)
|
||||||
is CommunityDefinitionEvent -> CommunityHeader(
|
is CommunityDefinitionEvent -> CommunityHeader(
|
||||||
@@ -448,6 +472,7 @@ fun NormalNote(
|
|||||||
canPreview,
|
canPreview,
|
||||||
parentBackgroundColor,
|
parentBackgroundColor,
|
||||||
accountViewModel,
|
accountViewModel,
|
||||||
|
showImage,
|
||||||
showPopup,
|
showPopup,
|
||||||
nav
|
nav
|
||||||
)
|
)
|
||||||
@@ -745,6 +770,7 @@ private fun CheckNewAndRenderNote(
|
|||||||
canPreview: Boolean = true,
|
canPreview: Boolean = true,
|
||||||
parentBackgroundColor: MutableState<Color>? = null,
|
parentBackgroundColor: MutableState<Color>? = null,
|
||||||
accountViewModel: AccountViewModel,
|
accountViewModel: AccountViewModel,
|
||||||
|
showImage: MutableState<Boolean>,
|
||||||
showPopup: () -> Unit,
|
showPopup: () -> Unit,
|
||||||
nav: (String) -> Unit
|
nav: (String) -> Unit
|
||||||
) {
|
) {
|
||||||
@@ -809,6 +835,7 @@ private fun CheckNewAndRenderNote(
|
|||||||
makeItShort = makeItShort,
|
makeItShort = makeItShort,
|
||||||
canPreview = canPreview,
|
canPreview = canPreview,
|
||||||
accountViewModel = accountViewModel,
|
accountViewModel = accountViewModel,
|
||||||
|
showImage = showImage,
|
||||||
nav = nav
|
nav = nav
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -859,6 +886,7 @@ fun InnerNoteWithReactions(
|
|||||||
makeItShort: Boolean,
|
makeItShort: Boolean,
|
||||||
canPreview: Boolean,
|
canPreview: Boolean,
|
||||||
accountViewModel: AccountViewModel,
|
accountViewModel: AccountViewModel,
|
||||||
|
showImage: MutableState<Boolean>,
|
||||||
nav: (String) -> Unit
|
nav: (String) -> Unit
|
||||||
) {
|
) {
|
||||||
val notBoostedNorQuote = !isBoostedNote && !isQuotedNote
|
val notBoostedNorQuote = !isBoostedNote && !isQuotedNote
|
||||||
@@ -897,6 +925,7 @@ fun InnerNoteWithReactions(
|
|||||||
showSecondRow = showSecondRow,
|
showSecondRow = showSecondRow,
|
||||||
backgroundColor = backgroundColor,
|
backgroundColor = backgroundColor,
|
||||||
accountViewModel = accountViewModel,
|
accountViewModel = accountViewModel,
|
||||||
|
showImage = showImage,
|
||||||
nav = nav
|
nav = nav
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -942,6 +971,7 @@ private fun NoteBody(
|
|||||||
showSecondRow: Boolean,
|
showSecondRow: Boolean,
|
||||||
backgroundColor: MutableState<Color>,
|
backgroundColor: MutableState<Color>,
|
||||||
accountViewModel: AccountViewModel,
|
accountViewModel: AccountViewModel,
|
||||||
|
showImage: MutableState<Boolean>,
|
||||||
nav: (String) -> Unit
|
nav: (String) -> Unit
|
||||||
) {
|
) {
|
||||||
FirstUserInfoRow(
|
FirstUserInfoRow(
|
||||||
@@ -967,6 +997,7 @@ private fun NoteBody(
|
|||||||
unPackReply,
|
unPackReply,
|
||||||
backgroundColor,
|
backgroundColor,
|
||||||
accountViewModel,
|
accountViewModel,
|
||||||
|
showImage,
|
||||||
nav
|
nav
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -977,6 +1008,7 @@ private fun NoteBody(
|
|||||||
makeItShort,
|
makeItShort,
|
||||||
canPreview,
|
canPreview,
|
||||||
accountViewModel,
|
accountViewModel,
|
||||||
|
showImage,
|
||||||
nav
|
nav
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -988,11 +1020,12 @@ private fun RenderNoteRow(
|
|||||||
makeItShort: Boolean,
|
makeItShort: Boolean,
|
||||||
canPreview: Boolean,
|
canPreview: Boolean,
|
||||||
accountViewModel: AccountViewModel,
|
accountViewModel: AccountViewModel,
|
||||||
|
showImage: MutableState<Boolean>,
|
||||||
nav: (String) -> Unit
|
nav: (String) -> Unit
|
||||||
) {
|
) {
|
||||||
when (baseNote.event) {
|
when (baseNote.event) {
|
||||||
is AppDefinitionEvent -> {
|
is AppDefinitionEvent -> {
|
||||||
RenderAppDefinition(baseNote, accountViewModel, nav)
|
RenderAppDefinition(baseNote, accountViewModel, showImage, nav)
|
||||||
}
|
}
|
||||||
|
|
||||||
is ReactionEvent -> {
|
is ReactionEvent -> {
|
||||||
@@ -1236,6 +1269,7 @@ fun RenderPoll(
|
|||||||
fun RenderAppDefinition(
|
fun RenderAppDefinition(
|
||||||
note: Note,
|
note: Note,
|
||||||
accountViewModel: AccountViewModel,
|
accountViewModel: AccountViewModel,
|
||||||
|
showImage: MutableState<Boolean>,
|
||||||
nav: (String) -> Unit
|
nav: (String) -> Unit
|
||||||
) {
|
) {
|
||||||
val noteEvent = note.event as? AppDefinitionEvent ?: return
|
val noteEvent = note.event as? AppDefinitionEvent ?: return
|
||||||
@@ -2065,6 +2099,7 @@ private fun ReplyRow(
|
|||||||
unPackReply: Boolean,
|
unPackReply: Boolean,
|
||||||
backgroundColor: MutableState<Color>,
|
backgroundColor: MutableState<Color>,
|
||||||
accountViewModel: AccountViewModel,
|
accountViewModel: AccountViewModel,
|
||||||
|
showImage: MutableState<Boolean>,
|
||||||
nav: (String) -> Unit
|
nav: (String) -> Unit
|
||||||
) {
|
) {
|
||||||
val noteEvent = note.event
|
val noteEvent = note.event
|
||||||
@@ -2100,6 +2135,7 @@ private fun ReplyRow(
|
|||||||
showBottomDiviser = false,
|
showBottomDiviser = false,
|
||||||
modifier = remember { Modifier.padding(vertical = 5.dp) },
|
modifier = remember { Modifier.padding(vertical = 5.dp) },
|
||||||
accountViewModel = accountViewModel,
|
accountViewModel = accountViewModel,
|
||||||
|
showImage = showImage,
|
||||||
nav = nav
|
nav = nav
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -55,6 +55,7 @@ import androidx.compose.ui.unit.sp
|
|||||||
import coil.compose.AsyncImage
|
import coil.compose.AsyncImage
|
||||||
import com.vitorpamplona.amethyst.R
|
import com.vitorpamplona.amethyst.R
|
||||||
import com.vitorpamplona.amethyst.model.Note
|
import com.vitorpamplona.amethyst.model.Note
|
||||||
|
import com.vitorpamplona.amethyst.service.connectivitystatus.ConnectivityStatus
|
||||||
import com.vitorpamplona.amethyst.service.model.AppDefinitionEvent
|
import com.vitorpamplona.amethyst.service.model.AppDefinitionEvent
|
||||||
import com.vitorpamplona.amethyst.service.model.AudioTrackEvent
|
import com.vitorpamplona.amethyst.service.model.AudioTrackEvent
|
||||||
import com.vitorpamplona.amethyst.service.model.BadgeDefinitionEvent
|
import com.vitorpamplona.amethyst.service.model.BadgeDefinitionEvent
|
||||||
@@ -244,6 +245,19 @@ fun NoteMaster(
|
|||||||
val accountState by accountViewModel.accountLiveData.observeAsState()
|
val accountState by accountViewModel.accountLiveData.observeAsState()
|
||||||
val account = accountState?.account ?: return
|
val account = accountState?.account ?: return
|
||||||
|
|
||||||
|
val settings = accountState?.account?.settings
|
||||||
|
val isMobile = ConnectivityStatus.isOnMobileData.value
|
||||||
|
|
||||||
|
val showImage = remember {
|
||||||
|
mutableStateOf(
|
||||||
|
when (settings?.automaticallyShowImages) {
|
||||||
|
true -> !isMobile
|
||||||
|
false -> false
|
||||||
|
else -> true
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
var showHiddenNote by remember { mutableStateOf(false) }
|
var showHiddenNote by remember { mutableStateOf(false) }
|
||||||
|
|
||||||
val context = LocalContext.current
|
val context = LocalContext.current
|
||||||
@@ -398,7 +412,7 @@ fun NoteMaster(
|
|||||||
) {
|
) {
|
||||||
Column() {
|
Column() {
|
||||||
if ((noteEvent is ChannelCreateEvent || noteEvent is ChannelMetadataEvent) && note.channelHex() != null) {
|
if ((noteEvent is ChannelCreateEvent || noteEvent is ChannelMetadataEvent) && note.channelHex() != null) {
|
||||||
ChannelHeader(channelHex = note.channelHex()!!, showVideo = true, showBottomDiviser = false, accountViewModel = accountViewModel, nav = nav)
|
ChannelHeader(channelHex = note.channelHex()!!, showVideo = true, showBottomDiviser = false, accountViewModel = accountViewModel, showImage = showImage, nav = nav)
|
||||||
} else if (noteEvent is FileHeaderEvent) {
|
} else if (noteEvent is FileHeaderEvent) {
|
||||||
FileHeaderDisplay(baseNote, accountViewModel)
|
FileHeaderDisplay(baseNote, accountViewModel)
|
||||||
} else if (noteEvent is FileStorageHeaderEvent) {
|
} else if (noteEvent is FileStorageHeaderEvent) {
|
||||||
@@ -431,7 +445,7 @@ fun NoteMaster(
|
|||||||
nav
|
nav
|
||||||
)
|
)
|
||||||
} else if (noteEvent is AppDefinitionEvent) {
|
} else if (noteEvent is AppDefinitionEvent) {
|
||||||
RenderAppDefinition(baseNote, accountViewModel, nav)
|
RenderAppDefinition(baseNote, accountViewModel, showImage, nav)
|
||||||
} else if (noteEvent is HighlightEvent) {
|
} else if (noteEvent is HighlightEvent) {
|
||||||
DisplayHighlight(
|
DisplayHighlight(
|
||||||
noteEvent.quote(),
|
noteEvent.quote(),
|
||||||
|
|||||||
@@ -87,6 +87,7 @@ import com.vitorpamplona.amethyst.model.Note
|
|||||||
import com.vitorpamplona.amethyst.model.PublicChatChannel
|
import com.vitorpamplona.amethyst.model.PublicChatChannel
|
||||||
import com.vitorpamplona.amethyst.model.User
|
import com.vitorpamplona.amethyst.model.User
|
||||||
import com.vitorpamplona.amethyst.service.NostrChannelDataSource
|
import com.vitorpamplona.amethyst.service.NostrChannelDataSource
|
||||||
|
import com.vitorpamplona.amethyst.service.connectivitystatus.ConnectivityStatus
|
||||||
import com.vitorpamplona.amethyst.service.model.LiveActivitiesEvent.Companion.STATUS_LIVE
|
import com.vitorpamplona.amethyst.service.model.LiveActivitiesEvent.Companion.STATUS_LIVE
|
||||||
import com.vitorpamplona.amethyst.service.model.Participant
|
import com.vitorpamplona.amethyst.service.model.Participant
|
||||||
import com.vitorpamplona.amethyst.ui.actions.ImmutableListOfLists
|
import com.vitorpamplona.amethyst.ui.actions.ImmutableListOfLists
|
||||||
@@ -199,6 +200,20 @@ fun ChannelScreen(
|
|||||||
|
|
||||||
val lifeCycleOwner = LocalLifecycleOwner.current
|
val lifeCycleOwner = LocalLifecycleOwner.current
|
||||||
|
|
||||||
|
val accountState by accountViewModel.accountLiveData.observeAsState()
|
||||||
|
val settings = accountState?.account?.settings
|
||||||
|
val isMobile = ConnectivityStatus.isOnMobileData.value
|
||||||
|
|
||||||
|
val showImage = remember {
|
||||||
|
mutableStateOf(
|
||||||
|
when (settings?.automaticallyShowImages) {
|
||||||
|
true -> !isMobile
|
||||||
|
false -> false
|
||||||
|
else -> true
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
LaunchedEffect(Unit) {
|
LaunchedEffect(Unit) {
|
||||||
NostrChannelDataSource.start()
|
NostrChannelDataSource.start()
|
||||||
feedViewModel.invalidateData()
|
feedViewModel.invalidateData()
|
||||||
@@ -239,6 +254,7 @@ fun ChannelScreen(
|
|||||||
showVideo = true,
|
showVideo = true,
|
||||||
showBottomDiviser = true,
|
showBottomDiviser = true,
|
||||||
accountViewModel = accountViewModel,
|
accountViewModel = accountViewModel,
|
||||||
|
showImage = showImage,
|
||||||
nav = nav
|
nav = nav
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -518,6 +534,7 @@ fun ChannelHeader(
|
|||||||
showBottomDiviser: Boolean,
|
showBottomDiviser: Boolean,
|
||||||
modifier: Modifier = StdPadding,
|
modifier: Modifier = StdPadding,
|
||||||
accountViewModel: AccountViewModel,
|
accountViewModel: AccountViewModel,
|
||||||
|
showImage: MutableState<Boolean>,
|
||||||
nav: (String) -> Unit
|
nav: (String) -> Unit
|
||||||
) {
|
) {
|
||||||
val channelHex by remember {
|
val channelHex by remember {
|
||||||
@@ -531,6 +548,7 @@ fun ChannelHeader(
|
|||||||
showVideo = showVideo,
|
showVideo = showVideo,
|
||||||
showBottomDiviser = showBottomDiviser,
|
showBottomDiviser = showBottomDiviser,
|
||||||
accountViewModel = accountViewModel,
|
accountViewModel = accountViewModel,
|
||||||
|
showImage = showImage,
|
||||||
nav = nav
|
nav = nav
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -544,6 +562,7 @@ fun ChannelHeader(
|
|||||||
showFlag: Boolean = true,
|
showFlag: Boolean = true,
|
||||||
modifier: Modifier = StdPadding,
|
modifier: Modifier = StdPadding,
|
||||||
accountViewModel: AccountViewModel,
|
accountViewModel: AccountViewModel,
|
||||||
|
showImage: MutableState<Boolean>,
|
||||||
nav: (String) -> Unit
|
nav: (String) -> Unit
|
||||||
) {
|
) {
|
||||||
var baseChannel by remember { mutableStateOf(LocalCache.channels[channelHex]) }
|
var baseChannel by remember { mutableStateOf(LocalCache.channels[channelHex]) }
|
||||||
@@ -564,6 +583,7 @@ fun ChannelHeader(
|
|||||||
showFlag,
|
showFlag,
|
||||||
modifier,
|
modifier,
|
||||||
accountViewModel,
|
accountViewModel,
|
||||||
|
showImage,
|
||||||
nav
|
nav
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -577,6 +597,7 @@ fun ChannelHeader(
|
|||||||
showFlag: Boolean = true,
|
showFlag: Boolean = true,
|
||||||
modifier: Modifier = StdPadding,
|
modifier: Modifier = StdPadding,
|
||||||
accountViewModel: AccountViewModel,
|
accountViewModel: AccountViewModel,
|
||||||
|
showImage: MutableState<Boolean>,
|
||||||
nav: (String) -> Unit
|
nav: (String) -> Unit
|
||||||
) {
|
) {
|
||||||
Column(Modifier.fillMaxWidth()) {
|
Column(Modifier.fillMaxWidth()) {
|
||||||
|
|||||||
@@ -57,6 +57,7 @@ import com.vitorpamplona.amethyst.model.LocalCache
|
|||||||
import com.vitorpamplona.amethyst.model.Note
|
import com.vitorpamplona.amethyst.model.Note
|
||||||
import com.vitorpamplona.amethyst.model.User
|
import com.vitorpamplona.amethyst.model.User
|
||||||
import com.vitorpamplona.amethyst.service.NostrUserProfileDataSource
|
import com.vitorpamplona.amethyst.service.NostrUserProfileDataSource
|
||||||
|
import com.vitorpamplona.amethyst.service.connectivitystatus.ConnectivityStatus
|
||||||
import com.vitorpamplona.amethyst.service.model.AppDefinitionEvent
|
import com.vitorpamplona.amethyst.service.model.AppDefinitionEvent
|
||||||
import com.vitorpamplona.amethyst.service.model.BadgeDefinitionEvent
|
import com.vitorpamplona.amethyst.service.model.BadgeDefinitionEvent
|
||||||
import com.vitorpamplona.amethyst.service.model.BadgeProfilesEvent
|
import com.vitorpamplona.amethyst.service.model.BadgeProfilesEvent
|
||||||
@@ -598,6 +599,20 @@ private fun ProfileHeader(
|
|||||||
var popupExpanded by remember { mutableStateOf(false) }
|
var popupExpanded by remember { mutableStateOf(false) }
|
||||||
var zoomImageDialogOpen by remember { mutableStateOf(false) }
|
var zoomImageDialogOpen by remember { mutableStateOf(false) }
|
||||||
|
|
||||||
|
val accountState by accountViewModel.accountLiveData.observeAsState()
|
||||||
|
val settings = accountState?.account?.settings
|
||||||
|
val isMobile = ConnectivityStatus.isOnMobileData.value
|
||||||
|
|
||||||
|
val showImage = remember {
|
||||||
|
mutableStateOf(
|
||||||
|
when (settings?.automaticallyShowImages) {
|
||||||
|
true -> !isMobile
|
||||||
|
false -> false
|
||||||
|
else -> true
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
Box {
|
Box {
|
||||||
DrawBanner(baseUser)
|
DrawBanner(baseUser)
|
||||||
|
|
||||||
@@ -1260,7 +1275,7 @@ private fun WatchAndRenderBadgeImage(
|
|||||||
|
|
||||||
@OptIn(ExperimentalFoundationApi::class)
|
@OptIn(ExperimentalFoundationApi::class)
|
||||||
@Composable
|
@Composable
|
||||||
public fun DrawBanner(baseUser: User) {
|
fun DrawBanner(baseUser: User) {
|
||||||
val userState by baseUser.live().metadata.observeAsState()
|
val userState by baseUser.live().metadata.observeAsState()
|
||||||
val banner = remember(userState) { userState?.user?.info?.banner }
|
val banner = remember(userState) { userState?.user?.info?.banner }
|
||||||
|
|
||||||
|
|||||||
@@ -62,6 +62,7 @@ import com.google.accompanist.permissions.rememberPermissionState
|
|||||||
import com.vitorpamplona.amethyst.R
|
import com.vitorpamplona.amethyst.R
|
||||||
import com.vitorpamplona.amethyst.model.Note
|
import com.vitorpamplona.amethyst.model.Note
|
||||||
import com.vitorpamplona.amethyst.service.NostrVideoDataSource
|
import com.vitorpamplona.amethyst.service.NostrVideoDataSource
|
||||||
|
import com.vitorpamplona.amethyst.service.connectivitystatus.ConnectivityStatus
|
||||||
import com.vitorpamplona.amethyst.service.model.FileHeaderEvent
|
import com.vitorpamplona.amethyst.service.model.FileHeaderEvent
|
||||||
import com.vitorpamplona.amethyst.service.model.FileStorageHeaderEvent
|
import com.vitorpamplona.amethyst.service.model.FileStorageHeaderEvent
|
||||||
import com.vitorpamplona.amethyst.ui.actions.GallerySelect
|
import com.vitorpamplona.amethyst.ui.actions.GallerySelect
|
||||||
@@ -192,7 +193,19 @@ fun RenderPage(
|
|||||||
nav: (String) -> Unit
|
nav: (String) -> Unit
|
||||||
) {
|
) {
|
||||||
val feedState by videoFeedView.feedContent.collectAsState()
|
val feedState by videoFeedView.feedContent.collectAsState()
|
||||||
|
val accountState by accountViewModel.accountLiveData.observeAsState()
|
||||||
|
val settings = accountState?.account?.settings
|
||||||
|
val isMobile = ConnectivityStatus.isOnMobileData.value
|
||||||
|
|
||||||
|
val showImage = remember {
|
||||||
|
mutableStateOf(
|
||||||
|
when (settings?.automaticallyShowImages) {
|
||||||
|
true -> !isMobile
|
||||||
|
false -> false
|
||||||
|
else -> true
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
Box() {
|
Box() {
|
||||||
Column {
|
Column {
|
||||||
Crossfade(
|
Crossfade(
|
||||||
@@ -213,6 +226,7 @@ fun RenderPage(
|
|||||||
state.feed,
|
state.feed,
|
||||||
pagerState,
|
pagerState,
|
||||||
accountViewModel,
|
accountViewModel,
|
||||||
|
showImage,
|
||||||
nav
|
nav
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -232,6 +246,7 @@ fun SlidingCarousel(
|
|||||||
feed: MutableState<ImmutableList<Note>>,
|
feed: MutableState<ImmutableList<Note>>,
|
||||||
pagerState: PagerState,
|
pagerState: PagerState,
|
||||||
accountViewModel: AccountViewModel,
|
accountViewModel: AccountViewModel,
|
||||||
|
showImage: MutableState<Boolean>,
|
||||||
nav: (String) -> Unit
|
nav: (String) -> Unit
|
||||||
) {
|
) {
|
||||||
VerticalPager(
|
VerticalPager(
|
||||||
@@ -244,7 +259,7 @@ fun SlidingCarousel(
|
|||||||
}
|
}
|
||||||
) { index ->
|
) { index ->
|
||||||
feed.value.getOrNull(index)?.let { note ->
|
feed.value.getOrNull(index)?.let { note ->
|
||||||
RenderVideoOrPictureNote(note, accountViewModel, nav)
|
RenderVideoOrPictureNote(note, accountViewModel, showImage, nav)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -253,6 +268,7 @@ fun SlidingCarousel(
|
|||||||
private fun RenderVideoOrPictureNote(
|
private fun RenderVideoOrPictureNote(
|
||||||
note: Note,
|
note: Note,
|
||||||
accountViewModel: AccountViewModel,
|
accountViewModel: AccountViewModel,
|
||||||
|
showImage: MutableState<Boolean>,
|
||||||
nav: (String) -> Unit
|
nav: (String) -> Unit
|
||||||
) {
|
) {
|
||||||
Column(remember { Modifier.fillMaxSize(1f) }) {
|
Column(remember { Modifier.fillMaxSize(1f) }) {
|
||||||
|
|||||||
Reference in New Issue
Block a user