Fix Overlay clickable.
This commit is contained in:
		
							parent
							
								
									59d84963a9
								
							
						
					
					
						commit
						f3b11e30c5
					
				
					 3 changed files with 12 additions and 7 deletions
				
			
		| 
						 | 
				
			
			@ -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(
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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
 | 
			
		||||
            )
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue