Dialog annimation
This commit is contained in:
		
							parent
							
								
									f3b11e30c5
								
							
						
					
					
						commit
						9591b4239c
					
				
					 5 changed files with 31 additions and 16 deletions
				
			
		| 
						 | 
				
			
			@ -31,15 +31,15 @@ fun ErrorCard(
 | 
			
		|||
    Card(elevation = 8.dp, modifier = modifier) {
 | 
			
		||||
        Column(
 | 
			
		||||
            modifier = Modifier
 | 
			
		||||
                .width(200.dp)
 | 
			
		||||
                .padding(16.dp)
 | 
			
		||||
                .width(250.dp)
 | 
			
		||||
                .padding(32.dp)
 | 
			
		||||
        ) {
 | 
			
		||||
            Icon(
 | 
			
		||||
                modifier = Modifier
 | 
			
		||||
                    .width(72.dp)
 | 
			
		||||
                    .height(72.dp)
 | 
			
		||||
                    .width(64.dp)
 | 
			
		||||
                    .height(64.dp)
 | 
			
		||||
                    .align(Alignment.CenterHorizontally)
 | 
			
		||||
                    .padding(16.dp),
 | 
			
		||||
                    .padding(bottom = 16.dp),
 | 
			
		||||
                tint = MaterialTheme.colors.error,
 | 
			
		||||
                imageVector = Icons.Sharp.ErrorOutline,
 | 
			
		||||
                contentDescription = "error"
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -26,13 +26,13 @@ fun LoadingCard(
 | 
			
		|||
    Card(elevation = 8.dp, modifier = modifier) {
 | 
			
		||||
        Column(
 | 
			
		||||
            modifier = Modifier
 | 
			
		||||
                .width(200.dp)
 | 
			
		||||
                .padding(16.dp)
 | 
			
		||||
                .width(250.dp)
 | 
			
		||||
                .padding(32.dp)
 | 
			
		||||
        ) {
 | 
			
		||||
            CircularProgressIndicator(
 | 
			
		||||
                modifier = Modifier
 | 
			
		||||
                    .align(Alignment.CenterHorizontally)
 | 
			
		||||
                    .padding(16.dp)
 | 
			
		||||
                    .padding(bottom = 16.dp)
 | 
			
		||||
            )
 | 
			
		||||
            if (message?.isNotEmpty() == true) {
 | 
			
		||||
                val typography = MaterialTheme.typography
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,6 +1,10 @@
 | 
			
		|||
package com.pixelized.biblib.ui.composable.screen
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
import androidx.compose.animation.AnimatedVisibility
 | 
			
		||||
import androidx.compose.animation.ExperimentalAnimationApi
 | 
			
		||||
import androidx.compose.animation.expandVertically
 | 
			
		||||
import androidx.compose.animation.shrinkVertically
 | 
			
		||||
import androidx.compose.foundation.Image
 | 
			
		||||
import androidx.compose.foundation.clickable
 | 
			
		||||
import androidx.compose.foundation.layout.*
 | 
			
		||||
| 
						 | 
				
			
			@ -145,6 +149,7 @@ private fun LoginScreenContentComposable(
 | 
			
		|||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@OptIn(ExperimentalAnimationApi::class)
 | 
			
		||||
@Composable
 | 
			
		||||
private fun LoginScreenDialogComposable(
 | 
			
		||||
    authentication: IAuthentication
 | 
			
		||||
| 
						 | 
				
			
			@ -158,18 +163,26 @@ private fun LoginScreenDialogComposable(
 | 
			
		|||
        },
 | 
			
		||||
        visible = (state.value is IAuthentication.State.Initial).not()
 | 
			
		||||
    ) {
 | 
			
		||||
        when (val currentState = state.value) {
 | 
			
		||||
            is IAuthentication.State.Error -> ErrorCard(
 | 
			
		||||
                modifier = Modifier.align(Alignment.Center),
 | 
			
		||||
        AnimatedVisibility(
 | 
			
		||||
            modifier = Modifier.align(Alignment.Center),
 | 
			
		||||
            visible = state.value is IAuthentication.State.Error,
 | 
			
		||||
            enter = expandVertically(Alignment.CenterVertically),
 | 
			
		||||
            exit = shrinkVertically(Alignment.CenterVertically),
 | 
			
		||||
        ) {
 | 
			
		||||
            ErrorCard(
 | 
			
		||||
                message = stringResource(id = R.string.error_generic),
 | 
			
		||||
                exception = currentState.exception
 | 
			
		||||
                exception = (state.value as? IAuthentication.State.Error)?.exception
 | 
			
		||||
            )
 | 
			
		||||
            is IAuthentication.State.Connect,
 | 
			
		||||
            is IAuthentication.State.Loading -> LoadingCard(
 | 
			
		||||
                modifier = Modifier.align(Alignment.Center),
 | 
			
		||||
        }
 | 
			
		||||
        AnimatedVisibility(
 | 
			
		||||
            modifier = Modifier.align(Alignment.Center),
 | 
			
		||||
            visible = state.value is IAuthentication.State.Loading || state.value is IAuthentication.State.Connect,
 | 
			
		||||
            enter = expandVertically(Alignment.CenterVertically),
 | 
			
		||||
            exit = shrinkVertically(Alignment.CenterVertically),
 | 
			
		||||
        ) {
 | 
			
		||||
            LoadingCard(
 | 
			
		||||
                message = stringResource(id = R.string.loading)
 | 
			
		||||
            )
 | 
			
		||||
            else -> Box {}
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue