in Jetsurvey/app/src/main/java/com/example/compose/jetsurvey/signinsignup/WelcomeScreen.kt [62:104]
fun WelcomeScreen(onEvent: (WelcomeEvent) -> Unit) {
var brandingBottom by remember { mutableStateOf(0f) }
var showBranding by remember { mutableStateOf(true) }
var heightWithBranding by remember { mutableStateOf(0) }
val currentOffsetHolder = remember { mutableStateOf(0f) }
currentOffsetHolder.value = if (showBranding) 0f else -brandingBottom
val currentOffsetHolderDp =
with(LocalDensity.current) { currentOffsetHolder.value.toDp() }
val heightDp = with(LocalDensity.current) { heightWithBranding.toDp() }
Surface(modifier = Modifier.supportWideScreen()) {
val offset by animateDpAsState(targetValue = currentOffsetHolderDp)
Column(
modifier = Modifier
.fillMaxWidth()
.brandingPreferredHeight(showBranding, heightDp)
.offset(y = offset)
.onSizeChanged {
if (showBranding) {
heightWithBranding = it.height
}
}
) {
Branding(
modifier = Modifier
.fillMaxWidth()
.weight(1f)
.onGloballyPositioned {
if (brandingBottom == 0f) {
brandingBottom = it.boundsInParent().bottom
}
}
)
SignInCreateAccount(
onEvent = onEvent,
onFocusChange = { focused -> showBranding = !focused },
modifier = Modifier
.fillMaxWidth()
.padding(horizontal = 20.dp)
)
}
}
}