diff --git a/core/ui/src/main/kotlin/ru/tech/imageresizershrinker/core/ui/widget/enhanced/EnhancedAlertDialog.kt b/core/ui/src/main/kotlin/ru/tech/imageresizershrinker/core/ui/widget/enhanced/EnhancedAlertDialog.kt index 51a65f305..bdde12047 100644 --- a/core/ui/src/main/kotlin/ru/tech/imageresizershrinker/core/ui/widget/enhanced/EnhancedAlertDialog.kt +++ b/core/ui/src/main/kotlin/ru/tech/imageresizershrinker/core/ui/widget/enhanced/EnhancedAlertDialog.kt @@ -17,7 +17,6 @@ package ru.tech.imageresizershrinker.core.ui.widget.enhanced -import android.view.Window import androidx.activity.compose.PredictiveBackHandler import androidx.compose.animation.AnimatedVisibility import androidx.compose.animation.core.Spring @@ -49,9 +48,6 @@ import androidx.compose.runtime.Composable import androidx.compose.runtime.CompositionLocalProvider import androidx.compose.runtime.DisposableEffect import androidx.compose.runtime.LaunchedEffect -import androidx.compose.runtime.ProvidableCompositionLocal -import androidx.compose.runtime.SideEffect -import androidx.compose.runtime.compositionLocalWithComputedDefaultOf import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableFloatStateOf import androidx.compose.runtime.mutableStateOf @@ -64,13 +60,11 @@ import androidx.compose.ui.draw.scale import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.Shape import androidx.compose.ui.input.pointer.pointerInput -import androidx.compose.ui.platform.LocalView import androidx.compose.ui.semantics.paneTitle import androidx.compose.ui.semantics.semantics import androidx.compose.ui.text.TextStyle import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.dp -import androidx.compose.ui.window.DialogWindowProvider import com.t8rin.modalsheet.FullscreenPopup import kotlinx.coroutines.delay import ru.tech.imageresizershrinker.core.settings.presentation.provider.LocalSettingsState @@ -170,15 +164,6 @@ fun BasicEnhancedAlertDialog( if (visibleAnimated) { FullscreenPopup { - val dialogWindow = LocalDialogWindow.current - - SideEffect { - dialogWindow.let { window -> - window?.setDimAmount(0f) - window?.setWindowAnimations(-1) - } - } - Box( modifier = Modifier.fillMaxSize(), contentAlignment = Alignment.Center @@ -255,11 +240,6 @@ fun BasicEnhancedAlertDialog( } } -private val LocalDialogWindow: ProvidableCompositionLocal = - compositionLocalWithComputedDefaultOf { - (LocalView.currentValue.parent as? DialogWindowProvider)?.window - } - @Composable private fun EnhancedAlertDialogContent( buttons: @Composable () -> Unit, diff --git a/feature/single-edit/src/main/java/ru/tech/imageresizershrinker/feature/single_edit/presentation/components/FullscreenEditOption.kt b/feature/single-edit/src/main/java/ru/tech/imageresizershrinker/feature/single_edit/presentation/components/FullscreenEditOption.kt index 3d32fe003..c59d6abc3 100644 --- a/feature/single-edit/src/main/java/ru/tech/imageresizershrinker/feature/single_edit/presentation/components/FullscreenEditOption.kt +++ b/feature/single-edit/src/main/java/ru/tech/imageresizershrinker/feature/single_edit/presentation/components/FullscreenEditOption.kt @@ -21,6 +21,9 @@ import androidx.activity.compose.BackHandler import androidx.activity.compose.PredictiveBackHandler import androidx.compose.animation.AnimatedVisibility import androidx.compose.animation.core.animateFloatAsState +import androidx.compose.animation.core.tween +import androidx.compose.animation.fadeIn +import androidx.compose.animation.fadeOut import androidx.compose.foundation.background import androidx.compose.foundation.gestures.detectTapGestures import androidx.compose.foundation.layout.Arrangement @@ -53,6 +56,7 @@ import androidx.compose.material3.SheetValue import androidx.compose.material3.Surface import androidx.compose.material3.rememberBottomSheetScaffoldState import androidx.compose.runtime.Composable +import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableFloatStateOf import androidx.compose.runtime.mutableStateOf @@ -100,9 +104,22 @@ fun FullscreenEditOption( ) { val scope = rememberCoroutineScope() + var predictiveBackProgress by remember { + mutableFloatStateOf(0f) + } + + LaunchedEffect(predictiveBackProgress, visible) { + if (!visible && predictiveBackProgress != 0f) { + delay(600) + predictiveBackProgress = 0f + } + } + AnimatedVisibility( visible = visible, - modifier = Modifier.fillMaxSize() + modifier = Modifier.fillMaxSize(), + enter = fadeIn(tween(600)), + exit = fadeOut(tween(600)) ) { var showExitDialog by remember(visible) { mutableStateOf(false) } val internalOnDismiss = { @@ -112,9 +129,7 @@ fun FullscreenEditOption( val direction = LocalLayoutDirection.current val focus = LocalFocusManager.current - var predictiveBackProgress by remember { - mutableFloatStateOf(0f) - } + val animatedPredictiveBackProgress by animateFloatAsState(predictiveBackProgress) val scale = (1f - animatedPredictiveBackProgress * 1.5f).coerceAtLeast(0.75f) @@ -316,11 +331,9 @@ fun FullscreenEditOption( predictiveBackProgress = event.progress } internalOnDismiss() - } catch (_: Exception) { + } catch (e: Exception) { + predictiveBackProgress = 0f } - - delay(400) - predictiveBackProgress = 0f } } else { BackHandler(onBack = internalOnDismiss)