mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2026-08-12 09:13:23 +00:00
fix: prevent share dialog from being dismissed by control auto-hide
The share dialog in zoomable/fullscreen media view was auto-hiding before users could select an option. This was caused by: 1. A 2-second timer in ZoomableContentDialog that hides all controls (including the share dialog) via AnimatedVisibility 2. A LaunchedEffect in RenderTopButtons that explicitly closed the share dialog whenever video controls auto-hid 3. Tap-to-toggle on the background also hiding controls while dialog was open Fix: Hoist the share popup state and guard the auto-hide timer, tap-to-toggle, and video control hide from dismissing when the share dialog is open. https://claude.ai/code/session_01YLujgxRDuujKCS3vgHc6Gq
This commit is contained in:
-5
@@ -25,7 +25,6 @@ import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.runtime.MutableState
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
@@ -129,10 +128,6 @@ fun RenderTopButtons(
|
||||
accountViewModel.saveMediaToGallery(mediaData.videoUri, mediaData.mimeType, context)
|
||||
}
|
||||
|
||||
LaunchedEffect(controllerVisible.value) {
|
||||
if (!controllerVisible.value) shareDialogVisible.value = false
|
||||
}
|
||||
|
||||
Row(modifier) {
|
||||
if (onZoomClick != null) {
|
||||
FullScreenButton(
|
||||
|
||||
+16
-8
@@ -95,7 +95,6 @@ import kotlinx.collections.immutable.toImmutableList
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
import net.engawapg.lib.zoomable.rememberZoomState
|
||||
import net.engawapg.lib.zoomable.zoomable
|
||||
|
||||
@@ -143,6 +142,7 @@ private fun DialogContent(
|
||||
) {
|
||||
val pagerState: PagerState = rememberPagerState { allImages.size }
|
||||
val controllerVisible = remember { mutableStateOf(true) }
|
||||
val sharePopupExpanded = remember { mutableStateOf(false) }
|
||||
|
||||
LaunchedEffect(key1 = pagerState, key2 = imageUrl) {
|
||||
launch {
|
||||
@@ -151,20 +151,30 @@ private fun DialogContent(
|
||||
pagerState.scrollToPage(page)
|
||||
}
|
||||
}
|
||||
launch(Dispatchers.IO) {
|
||||
launch {
|
||||
delay(2000)
|
||||
withContext(Dispatchers.Main) {
|
||||
if (!sharePopupExpanded.value) {
|
||||
controllerVisible.value = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Re-trigger auto-hide after the share dialog is dismissed
|
||||
LaunchedEffect(sharePopupExpanded.value) {
|
||||
if (!sharePopupExpanded.value && controllerVisible.value) {
|
||||
delay(2000)
|
||||
controllerVisible.value = false
|
||||
}
|
||||
}
|
||||
|
||||
Box(
|
||||
Modifier
|
||||
.fillMaxSize()
|
||||
.clickable(
|
||||
onClick = {
|
||||
controllerVisible.value = !controllerVisible.value
|
||||
if (!sharePopupExpanded.value) {
|
||||
controllerVisible.value = !controllerVisible.value
|
||||
}
|
||||
},
|
||||
),
|
||||
Alignment.TopCenter,
|
||||
@@ -227,10 +237,8 @@ private fun DialogContent(
|
||||
|
||||
allImages.getOrNull(pagerState.currentPage)?.let { myContent ->
|
||||
if (myContent is MediaUrlImage || myContent is MediaLocalImage) {
|
||||
val popupExpanded = remember { mutableStateOf(false) }
|
||||
|
||||
OutlinedButton(
|
||||
onClick = { popupExpanded.value = true },
|
||||
onClick = { sharePopupExpanded.value = true },
|
||||
contentPadding = PaddingValues(horizontal = Size5dp),
|
||||
colors = ButtonDefaults.outlinedButtonColors().copy(containerColor = MaterialTheme.colorScheme.background),
|
||||
) {
|
||||
@@ -240,7 +248,7 @@ private fun DialogContent(
|
||||
contentDescription = stringRes(R.string.quick_action_share),
|
||||
)
|
||||
|
||||
ShareMediaAction(accountViewModel = accountViewModel, popupExpanded = popupExpanded, myContent, onDismiss = { popupExpanded.value = false })
|
||||
ShareMediaAction(accountViewModel = accountViewModel, popupExpanded = sharePopupExpanded, myContent, onDismiss = { sharePopupExpanded.value = false })
|
||||
}
|
||||
|
||||
if (myContent !is MediaUrlContent || !isLiveStreaming(myContent.url)) {
|
||||
|
||||
Reference in New Issue
Block a user