mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2025-06-05 17:49:16 +02:00
Hide's the Video Full Screen dialog buttons together with video controls.
This commit is contained in:
parent
9f5a71020d
commit
b8b41f840a
@ -154,24 +154,26 @@ fun VideoView(
|
|||||||
authorName: String? = null,
|
authorName: String? = null,
|
||||||
nostrUriCallback: String? = null,
|
nostrUriCallback: String? = null,
|
||||||
onDialog: ((Boolean) -> Unit)? = null,
|
onDialog: ((Boolean) -> Unit)? = null,
|
||||||
|
onControllerVisibilityChanged: ((Boolean) -> Unit)? = null,
|
||||||
accountViewModel: AccountViewModel,
|
accountViewModel: AccountViewModel,
|
||||||
alwaysShowVideo: Boolean = false
|
alwaysShowVideo: Boolean = false
|
||||||
) {
|
) {
|
||||||
val defaultToStart by remember(videoUri) { mutableStateOf(DefaultMutedSetting.value) }
|
val defaultToStart by remember(videoUri) { mutableStateOf(DefaultMutedSetting.value) }
|
||||||
|
|
||||||
VideoViewInner(
|
VideoViewInner(
|
||||||
videoUri,
|
videoUri = videoUri,
|
||||||
defaultToStart,
|
defaultToStart = defaultToStart,
|
||||||
title,
|
title = title,
|
||||||
thumb,
|
thumb = thumb,
|
||||||
roundedCorner,
|
roundedCorner = roundedCorner,
|
||||||
waveform,
|
waveform = waveform,
|
||||||
artworkUri,
|
artworkUri = artworkUri,
|
||||||
authorName,
|
authorName = authorName,
|
||||||
nostrUriCallback,
|
nostrUriCallback = nostrUriCallback,
|
||||||
alwaysShowVideo,
|
alwaysShowVideo = alwaysShowVideo,
|
||||||
accountViewModel,
|
accountViewModel = accountViewModel,
|
||||||
onDialog
|
onControllerVisibilityChanged = onControllerVisibilityChanged,
|
||||||
|
onDialog = onDialog
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -189,6 +191,7 @@ fun VideoViewInner(
|
|||||||
nostrUriCallback: String? = null,
|
nostrUriCallback: String? = null,
|
||||||
alwaysShowVideo: Boolean = false,
|
alwaysShowVideo: Boolean = false,
|
||||||
accountViewModel: AccountViewModel,
|
accountViewModel: AccountViewModel,
|
||||||
|
onControllerVisibilityChanged: ((Boolean) -> Unit)? = null,
|
||||||
onDialog: ((Boolean) -> Unit)? = null
|
onDialog: ((Boolean) -> Unit)? = null
|
||||||
) {
|
) {
|
||||||
val automaticallyStartPlayback = remember {
|
val automaticallyStartPlayback = remember {
|
||||||
@ -247,6 +250,7 @@ fun VideoViewInner(
|
|||||||
keepPlaying = keepPlaying,
|
keepPlaying = keepPlaying,
|
||||||
automaticallyStartPlayback = automaticallyStartPlayback,
|
automaticallyStartPlayback = automaticallyStartPlayback,
|
||||||
activeOnScreen = activeOnScreen,
|
activeOnScreen = activeOnScreen,
|
||||||
|
onControllerVisibilityChanged = onControllerVisibilityChanged,
|
||||||
onDialog = onDialog
|
onDialog = onDialog
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -514,6 +518,7 @@ private fun RenderVideoPlayer(
|
|||||||
keepPlaying: MutableState<Boolean>,
|
keepPlaying: MutableState<Boolean>,
|
||||||
automaticallyStartPlayback: MutableState<Boolean>,
|
automaticallyStartPlayback: MutableState<Boolean>,
|
||||||
activeOnScreen: MutableState<Boolean>,
|
activeOnScreen: MutableState<Boolean>,
|
||||||
|
onControllerVisibilityChanged: ((Boolean) -> Unit)? = null,
|
||||||
onDialog: ((Boolean) -> Unit)?
|
onDialog: ((Boolean) -> Unit)?
|
||||||
) {
|
) {
|
||||||
ControlWhenPlayerIsActive(controller, keepPlaying, automaticallyStartPlayback, activeOnScreen)
|
ControlWhenPlayerIsActive(controller, keepPlaying, automaticallyStartPlayback, activeOnScreen)
|
||||||
@ -558,8 +563,11 @@ private fun RenderVideoPlayer(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
setControllerVisibilityListener(
|
setControllerVisibilityListener(
|
||||||
PlayerView.ControllerVisibilityListener {
|
PlayerView.ControllerVisibilityListener { visible ->
|
||||||
controllerVisible.value = it == View.VISIBLE
|
controllerVisible.value = visible == View.VISIBLE
|
||||||
|
onControllerVisibilityChanged?.let { callback ->
|
||||||
|
callback(visible == View.VISIBLE)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,9 @@ import android.content.ContextWrapper
|
|||||||
import android.os.Build
|
import android.os.Build
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import android.view.Window
|
import android.view.Window
|
||||||
|
import androidx.compose.animation.AnimatedVisibility
|
||||||
|
import androidx.compose.animation.fadeIn
|
||||||
|
import androidx.compose.animation.fadeOut
|
||||||
import androidx.compose.foundation.ExperimentalFoundationApi
|
import androidx.compose.foundation.ExperimentalFoundationApi
|
||||||
import androidx.compose.foundation.clickable
|
import androidx.compose.foundation.clickable
|
||||||
import androidx.compose.foundation.combinedClickable
|
import androidx.compose.foundation.combinedClickable
|
||||||
@ -636,48 +639,87 @@ fun ZoomableImageDialog(
|
|||||||
) {
|
) {
|
||||||
Surface(modifier = Modifier.fillMaxSize(), color = MaterialTheme.colorScheme.background) {
|
Surface(modifier = Modifier.fillMaxSize(), color = MaterialTheme.colorScheme.background) {
|
||||||
Box(modifier = Modifier.fillMaxSize(), contentAlignment = Alignment.TopCenter) {
|
Box(modifier = Modifier.fillMaxSize(), contentAlignment = Alignment.TopCenter) {
|
||||||
val pagerState: PagerState = rememberPagerState() { allImages.size }
|
DialogContent(allImages, imageUrl, onDismiss, accountViewModel)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
LaunchedEffect(key1 = pagerState, key2 = imageUrl) {
|
@Composable
|
||||||
val page = allImages.indexOf(imageUrl)
|
@OptIn(ExperimentalFoundationApi::class)
|
||||||
if (page > -1) {
|
private fun DialogContent(
|
||||||
pagerState.scrollToPage(page)
|
allImages: ImmutableList<ZoomableContent>,
|
||||||
}
|
imageUrl: ZoomableContent,
|
||||||
}
|
onDismiss: () -> Unit,
|
||||||
|
accountViewModel: AccountViewModel
|
||||||
if (allImages.size > 1) {
|
) {
|
||||||
SlidingCarousel(
|
val pagerState: PagerState = rememberPagerState() { allImages.size }
|
||||||
pagerState = pagerState
|
val controllerVisible = remember { mutableStateOf(false) }
|
||||||
) { index ->
|
val holdOn = remember { mutableStateOf<Boolean>(true) }
|
||||||
RenderImageOrVideo(allImages[index], false, accountViewModel)
|
|
||||||
}
|
LaunchedEffect(key1 = pagerState, key2 = imageUrl) {
|
||||||
} else {
|
launch {
|
||||||
RenderImageOrVideo(imageUrl, false, accountViewModel)
|
val page = allImages.indexOf(imageUrl)
|
||||||
}
|
if (page > -1) {
|
||||||
|
pagerState.scrollToPage(page)
|
||||||
Row(
|
}
|
||||||
modifier = Modifier
|
}
|
||||||
.padding(10.dp)
|
launch(Dispatchers.Default) {
|
||||||
.fillMaxWidth(),
|
delay(2000)
|
||||||
horizontalArrangement = Arrangement.SpaceBetween,
|
holdOn.value = false
|
||||||
verticalAlignment = Alignment.CenterVertically
|
}
|
||||||
) {
|
}
|
||||||
CloseButton(onPress = onDismiss)
|
|
||||||
|
if (allImages.size > 1) {
|
||||||
val myContent = allImages[pagerState.currentPage]
|
SlidingCarousel(
|
||||||
if (myContent is ZoomableUrlContent) {
|
pagerState = pagerState
|
||||||
Row() {
|
) { index ->
|
||||||
CopyToClipboard(content = myContent)
|
RenderImageOrVideo(
|
||||||
Spacer(modifier = StdHorzSpacer)
|
content = allImages[index],
|
||||||
SaveToGallery(url = myContent.url)
|
roundedCorner = false,
|
||||||
}
|
onControllerVisibilityChanged = {
|
||||||
} else if (myContent is ZoomableLocalImage && myContent.localFile != null) {
|
controllerVisible.value = it
|
||||||
SaveToGallery(
|
},
|
||||||
localFile = myContent.localFile,
|
accountViewModel = accountViewModel
|
||||||
mimeType = myContent.mimeType
|
)
|
||||||
)
|
}
|
||||||
}
|
} else {
|
||||||
|
RenderImageOrVideo(
|
||||||
|
content = imageUrl,
|
||||||
|
roundedCorner = false,
|
||||||
|
onControllerVisibilityChanged = {
|
||||||
|
controllerVisible.value = it
|
||||||
|
},
|
||||||
|
accountViewModel = accountViewModel
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
AnimatedVisibility(
|
||||||
|
visible = holdOn.value || controllerVisible.value,
|
||||||
|
enter = fadeIn(),
|
||||||
|
exit = fadeOut()
|
||||||
|
) {
|
||||||
|
Row(
|
||||||
|
modifier = Modifier
|
||||||
|
.padding(10.dp)
|
||||||
|
.fillMaxWidth(),
|
||||||
|
horizontalArrangement = Arrangement.SpaceBetween,
|
||||||
|
verticalAlignment = Alignment.CenterVertically
|
||||||
|
) {
|
||||||
|
CloseButton(onPress = onDismiss)
|
||||||
|
|
||||||
|
val myContent = allImages[pagerState.currentPage]
|
||||||
|
if (myContent is ZoomableUrlContent) {
|
||||||
|
Row() {
|
||||||
|
CopyToClipboard(content = myContent)
|
||||||
|
Spacer(modifier = StdHorzSpacer)
|
||||||
|
SaveToGallery(url = myContent.url)
|
||||||
}
|
}
|
||||||
|
} else if (myContent is ZoomableLocalImage && myContent.localFile != null) {
|
||||||
|
SaveToGallery(
|
||||||
|
localFile = myContent.localFile,
|
||||||
|
mimeType = myContent.mimeType
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -751,7 +793,12 @@ private fun ShareImageAction(
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
private fun RenderImageOrVideo(content: ZoomableContent, roundedCorner: Boolean, accountViewModel: AccountViewModel) {
|
private fun RenderImageOrVideo(
|
||||||
|
content: ZoomableContent,
|
||||||
|
roundedCorner: Boolean,
|
||||||
|
onControllerVisibilityChanged: ((Boolean) -> Unit)? = null,
|
||||||
|
accountViewModel: AccountViewModel
|
||||||
|
) {
|
||||||
val mainModifier = Modifier
|
val mainModifier = Modifier
|
||||||
.fillMaxSize()
|
.fillMaxSize()
|
||||||
.zoomable(rememberZoomState())
|
.zoomable(rememberZoomState())
|
||||||
@ -766,6 +813,7 @@ private fun RenderImageOrVideo(content: ZoomableContent, roundedCorner: Boolean,
|
|||||||
artworkUri = content.artworkUri,
|
artworkUri = content.artworkUri,
|
||||||
authorName = content.authorName,
|
authorName = content.authorName,
|
||||||
roundedCorner = roundedCorner,
|
roundedCorner = roundedCorner,
|
||||||
|
onControllerVisibilityChanged = onControllerVisibilityChanged,
|
||||||
accountViewModel = accountViewModel,
|
accountViewModel = accountViewModel,
|
||||||
alwaysShowVideo = true
|
alwaysShowVideo = true
|
||||||
)
|
)
|
||||||
@ -781,6 +829,7 @@ private fun RenderImageOrVideo(content: ZoomableContent, roundedCorner: Boolean,
|
|||||||
artworkUri = content.artworkUri,
|
artworkUri = content.artworkUri,
|
||||||
authorName = content.authorName,
|
authorName = content.authorName,
|
||||||
roundedCorner = roundedCorner,
|
roundedCorner = roundedCorner,
|
||||||
|
onControllerVisibilityChanged = onControllerVisibilityChanged,
|
||||||
accountViewModel = accountViewModel,
|
accountViewModel = accountViewModel,
|
||||||
alwaysShowVideo = true
|
alwaysShowVideo = true
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user