Fix Overlay clickable.

This commit is contained in:
Thomas Andres Gomez 2021-05-08 21:23:33 +02:00
parent 59d84963a9
commit f3b11e30c5
3 changed files with 12 additions and 7 deletions

2
.idea/misc.xml generated
View file

@ -119,6 +119,8 @@
<entry key="../../../../../layout/compose-model-1620499743476.xml" value="0.5818181818181818" />
<entry key="../../../../../layout/compose-model-1620500516060.xml" value="0.5818181818181818" />
<entry key="../../../../../layout/compose-model-1620500563383.xml" value="0.5818181818181818" />
<entry key="../../../../../layout/compose-model-1620500952241.xml" value="0.5818181818181818" />
<entry key="../../../../../layout/compose-model-1620501296868.xml" value="0.1" />
<entry key="app/src/main/res/drawable-v24/ic_launcher_foreground.xml" value="0.2898148148148148" />
<entry key="app/src/main/res/drawable/ic_baseline_local_library_24.xml" value="0.25462962962962965" />
<entry key="app/src/main/res/drawable/ic_google.xml" value="0.2962962962962963" />

View file

@ -1,8 +1,8 @@
package com.pixelized.biblib.ui.composable.items.dialog
import androidx.compose.animation.Crossfade
import androidx.compose.animation.core.tween
import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.BoxScope
import androidx.compose.foundation.layout.fillMaxHeight
@ -14,16 +14,16 @@ import androidx.compose.ui.graphics.Color
@Composable
fun CrossFadeOverlay(
modifier: Modifier = Modifier,
visible: Boolean,
content: @Composable BoxScope.() -> Unit
) {
Crossfade(targetState = visible) {
Crossfade(targetState = visible, animationSpec = tween(500)) {
if (it) {
Box(
modifier = Modifier
modifier = modifier
.fillMaxWidth()
.fillMaxHeight()
.clickable { }
) {
// Transparent background.
Box(

View file

@ -151,13 +151,16 @@ private fun LoginScreenDialogComposable(
) {
val state = authentication.state.observeAsState()
CrossFadeOverlay(
modifier = Modifier.clickable {
if (state.value is IAuthentication.State.Error) {
authentication.clearState()
}
},
visible = (state.value is IAuthentication.State.Initial).not()
) {
when (val currentState = state.value) {
is IAuthentication.State.Error -> ErrorCard(
modifier = Modifier
.align(Alignment.Center)
.clickable { authentication.clearState() },
modifier = Modifier.align(Alignment.Center),
message = stringResource(id = R.string.error_generic),
exception = currentState.exception
)