Fix weird behavior on summary header when skill card colapse.
This commit is contained in:
		
							parent
							
								
									4058c072a4
								
							
						
					
					
						commit
						8b22ea4276
					
				
					 4 changed files with 58 additions and 32 deletions
				
			
		| 
						 | 
				
			
			@ -88,12 +88,8 @@ fun SummaryScreen(
 | 
			
		|||
                        extendProficiencies = extendProficiencies,
 | 
			
		||||
                        extendPassives = extendPassives,
 | 
			
		||||
                        extendSpells = extendSpells,
 | 
			
		||||
                        onClass = {
 | 
			
		||||
                            screen.navigateToCharacterSheet(name = it.label)
 | 
			
		||||
                        },
 | 
			
		||||
                        onDice = {
 | 
			
		||||
                            statisticsViewModel.showDetail(dice = it)
 | 
			
		||||
                        },
 | 
			
		||||
                        onClass = { screen.navigateToCharacterSheet(name = it.label) },
 | 
			
		||||
                        onDice = { statisticsViewModel.showDetail(dice = it) },
 | 
			
		||||
                        onAttribute = { extendAttribute.value = it },
 | 
			
		||||
                        onCharacteristic = { extendCharacteristic.value = it },
 | 
			
		||||
                        onSavingThrows = { extendSavingThrows.value = it },
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -40,6 +40,11 @@ fun rememberAttributesSummary(): AttributesSummaryUio {
 | 
			
		|||
            ),
 | 
			
		||||
            initiative = SummaryRowUio(
 | 
			
		||||
                label = R.string.character_sheet_title_initiative,
 | 
			
		||||
                c1 = mutableStateOf(label(label = "+0")),
 | 
			
		||||
                c2 = mutableStateOf(label(label = "-1")),
 | 
			
		||||
                c3 = mutableStateOf(label(label = "+3")),
 | 
			
		||||
                c4 = mutableStateOf(label(label = "+2")),
 | 
			
		||||
                c5 = mutableStateOf(label(label = "+3")),
 | 
			
		||||
            ),
 | 
			
		||||
            speed = SummaryRowUio(
 | 
			
		||||
                label = R.string.character_sheet_title_speed,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -21,6 +21,7 @@ fun rememberClassHeaderSummary(): ClassHeaderSummaryUio {
 | 
			
		|||
            dice1 = mutableStateOf(
 | 
			
		||||
                ClassHeaderSummaryUio.Dice(
 | 
			
		||||
                    result = "20",
 | 
			
		||||
                    isCriticalSuccess = true,
 | 
			
		||||
                )
 | 
			
		||||
            ),
 | 
			
		||||
            clazz2 = mutableStateOf(
 | 
			
		||||
| 
						 | 
				
			
			@ -30,7 +31,9 @@ fun rememberClassHeaderSummary(): ClassHeaderSummaryUio {
 | 
			
		|||
                )
 | 
			
		||||
            ),
 | 
			
		||||
            dice2 = mutableStateOf(
 | 
			
		||||
                ClassHeaderSummaryUio.Dice()
 | 
			
		||||
                ClassHeaderSummaryUio.Dice(
 | 
			
		||||
                    result = "16",
 | 
			
		||||
                ),
 | 
			
		||||
            ),
 | 
			
		||||
            clazz3 = mutableStateOf(
 | 
			
		||||
                ClassHeaderSummaryUio.Header(
 | 
			
		||||
| 
						 | 
				
			
			@ -39,7 +42,9 @@ fun rememberClassHeaderSummary(): ClassHeaderSummaryUio {
 | 
			
		|||
                )
 | 
			
		||||
            ),
 | 
			
		||||
            dice3 = mutableStateOf(
 | 
			
		||||
                ClassHeaderSummaryUio.Dice()
 | 
			
		||||
                ClassHeaderSummaryUio.Dice(
 | 
			
		||||
                    result = "18",
 | 
			
		||||
                ),
 | 
			
		||||
            ),
 | 
			
		||||
            clazz4 = mutableStateOf(
 | 
			
		||||
                ClassHeaderSummaryUio.Header(
 | 
			
		||||
| 
						 | 
				
			
			@ -48,7 +53,10 @@ fun rememberClassHeaderSummary(): ClassHeaderSummaryUio {
 | 
			
		|||
                )
 | 
			
		||||
            ),
 | 
			
		||||
            dice4 = mutableStateOf(
 | 
			
		||||
                ClassHeaderSummaryUio.Dice()
 | 
			
		||||
                ClassHeaderSummaryUio.Dice(
 | 
			
		||||
                    result = "1",
 | 
			
		||||
                    isCriticalFailure = true,
 | 
			
		||||
                ),
 | 
			
		||||
            ),
 | 
			
		||||
            clazz5 = mutableStateOf(
 | 
			
		||||
                ClassHeaderSummaryUio.Header(
 | 
			
		||||
| 
						 | 
				
			
			@ -57,7 +65,9 @@ fun rememberClassHeaderSummary(): ClassHeaderSummaryUio {
 | 
			
		|||
                )
 | 
			
		||||
            ),
 | 
			
		||||
            dice5 = mutableStateOf(
 | 
			
		||||
                ClassHeaderSummaryUio.Dice()
 | 
			
		||||
                ClassHeaderSummaryUio.Dice(
 | 
			
		||||
                    result = "24",
 | 
			
		||||
                ),
 | 
			
		||||
            ),
 | 
			
		||||
        )
 | 
			
		||||
    }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -8,10 +8,12 @@ import androidx.compose.animation.slideInVertically
 | 
			
		|||
import androidx.compose.foundation.ScrollState
 | 
			
		||||
import androidx.compose.foundation.background
 | 
			
		||||
import androidx.compose.foundation.layout.Arrangement
 | 
			
		||||
import androidx.compose.foundation.layout.Box
 | 
			
		||||
import androidx.compose.foundation.layout.Column
 | 
			
		||||
import androidx.compose.foundation.layout.Spacer
 | 
			
		||||
import androidx.compose.foundation.layout.fillMaxSize
 | 
			
		||||
import androidx.compose.foundation.layout.fillMaxWidth
 | 
			
		||||
import androidx.compose.foundation.layout.offset
 | 
			
		||||
import androidx.compose.foundation.layout.height
 | 
			
		||||
import androidx.compose.foundation.layout.padding
 | 
			
		||||
import androidx.compose.foundation.rememberScrollState
 | 
			
		||||
import androidx.compose.foundation.verticalScroll
 | 
			
		||||
| 
						 | 
				
			
			@ -20,16 +22,17 @@ import androidx.compose.material3.Surface
 | 
			
		|||
import androidx.compose.runtime.Composable
 | 
			
		||||
import androidx.compose.runtime.Stable
 | 
			
		||||
import androidx.compose.runtime.State
 | 
			
		||||
import androidx.compose.runtime.derivedStateOf
 | 
			
		||||
import androidx.compose.runtime.mutableStateOf
 | 
			
		||||
import androidx.compose.runtime.remember
 | 
			
		||||
import androidx.compose.ui.Modifier
 | 
			
		||||
import androidx.compose.ui.graphics.Brush
 | 
			
		||||
import androidx.compose.ui.layout.onSizeChanged
 | 
			
		||||
import androidx.compose.ui.platform.LocalDensity
 | 
			
		||||
import androidx.compose.ui.tooling.preview.Preview
 | 
			
		||||
import androidx.compose.ui.unit.Density
 | 
			
		||||
import androidx.compose.ui.unit.IntOffset
 | 
			
		||||
import androidx.compose.ui.unit.IntSize
 | 
			
		||||
import androidx.compose.ui.unit.dp
 | 
			
		||||
import androidx.compose.ui.zIndex
 | 
			
		||||
import com.pixelized.rplexicon.ui.screens.summary.composable.AttributesSummary
 | 
			
		||||
import com.pixelized.rplexicon.ui.screens.summary.composable.AttributesSummaryUio
 | 
			
		||||
import com.pixelized.rplexicon.ui.screens.summary.composable.CharacteristicsSummary
 | 
			
		||||
| 
						 | 
				
			
			@ -85,32 +88,28 @@ fun StatisticSummary(
 | 
			
		|||
    onPassives: (Boolean) -> Unit,
 | 
			
		||||
    onSpells: (Boolean) -> Unit,
 | 
			
		||||
) {
 | 
			
		||||
    Column(
 | 
			
		||||
    val density = LocalDensity.current
 | 
			
		||||
    
 | 
			
		||||
    val headerSize = remember {
 | 
			
		||||
        mutableStateOf(IntSize.Zero)
 | 
			
		||||
    }
 | 
			
		||||
    val headerHeight = remember {
 | 
			
		||||
        derivedStateOf { with(density) { headerSize.value.height.toDp() - 24.dp } }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    Box(
 | 
			
		||||
        modifier = Modifier
 | 
			
		||||
            .verticalScroll(state = scrollState)
 | 
			
		||||
            .padding(horizontal = 16.dp)
 | 
			
		||||
            .then(other = modifier),
 | 
			
		||||
    ) {
 | 
			
		||||
        AnimatedVisibility(
 | 
			
		||||
            modifier = Modifier
 | 
			
		||||
                .zIndex(zIndex = 1f)
 | 
			
		||||
                .fillMaxWidth()
 | 
			
		||||
                .offset { IntOffset(x = 0, y = scrollState.value) }
 | 
			
		||||
                .background(brush = rememberHeaderBackgroundGradient())
 | 
			
		||||
                .padding(bottom = 16.dp, end = 3.dp),
 | 
			
		||||
            visible = summary.headerVisibility.value,
 | 
			
		||||
            enter = fadeIn(),
 | 
			
		||||
        ) {
 | 
			
		||||
            ClassHeaderSummary(
 | 
			
		||||
                header = summary.header,
 | 
			
		||||
                onClass = onClass,
 | 
			
		||||
                onDice = onDice,
 | 
			
		||||
            )
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        Column(
 | 
			
		||||
            modifier = Modifier.verticalScroll(state = scrollState),
 | 
			
		||||
            verticalArrangement = Arrangement.spacedBy(space = 16.dp),
 | 
			
		||||
        ) {
 | 
			
		||||
            Spacer(
 | 
			
		||||
                modifier = Modifier.height(height = headerHeight.value),
 | 
			
		||||
            )
 | 
			
		||||
 | 
			
		||||
            AnimatedVisibility(
 | 
			
		||||
                visible = summary.statsVisibility.value,
 | 
			
		||||
                enter = enterTransition(),
 | 
			
		||||
| 
						 | 
				
			
			@ -178,6 +177,22 @@ fun StatisticSummary(
 | 
			
		|||
                )
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        AnimatedVisibility(
 | 
			
		||||
            modifier = Modifier
 | 
			
		||||
                .fillMaxWidth()
 | 
			
		||||
                .onSizeChanged { headerSize.value = it }
 | 
			
		||||
                .background(brush = rememberHeaderBackgroundGradient())
 | 
			
		||||
                .padding(bottom = 16.dp, end = 3.dp),
 | 
			
		||||
            visible = summary.headerVisibility.value,
 | 
			
		||||
            enter = fadeIn(),
 | 
			
		||||
        ) {
 | 
			
		||||
            ClassHeaderSummary(
 | 
			
		||||
                header = summary.header,
 | 
			
		||||
                onClass = onClass,
 | 
			
		||||
                onDice = onDice,
 | 
			
		||||
            )
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue