Skip to content

Commit

Permalink
1
Browse files Browse the repository at this point in the history
  • Loading branch information
xfqwdsj committed Jan 25, 2024
1 parent 78c869b commit 78cf8ea
Showing 1 changed file with 12 additions and 26 deletions.
38 changes: 12 additions & 26 deletions composeApp/src/commonMain/kotlin/ui/pages/root/SignIn.kt
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ fun SignIn(component: SignInComponent) {
},
additionalContent = {
if (state is SignInComponent.ComponentState.SignIn) {
state.MoreMethods(modifier = Modifier.fillMaxWidth(), scrollState = rememberScrollState())
state.MoreMethods(modifier = Modifier.fillMaxWidth())
}
},
)
Expand Down Expand Up @@ -313,38 +313,22 @@ fun SignInLayout(

val additionalContentBackgroundY = additionalContentY + (height - additionalContentY) * animationSecondStage

// == Scrollbars ==
val mainScrollbarHeight = (safeHeight - mainBottomSpace).roundToInt().coerceAtLeast(0)
// == Scrollbar ==
val scrollbarHeight = (safeHeight - mainBottomSpace).roundToInt().coerceAtLeast(0)

val mainScrollbarPlaceable = subcompose("mainScrollBar") {
val scrollbarPlaceable = subcompose("scrollBar") {
VerticalScrollbar(scrollState = scrollState)
}.firstOrNull()?.measure(
Constraints(maxWidth = mainWidth, minHeight = mainScrollbarHeight, maxHeight = mainScrollbarHeight)
)

val mainScrollbarX = mainScrollbarPlaceable?.let { mainWidth - mainScrollbarPlaceable.width }
val mainScrollbarY = contentPaddingTop.roundToInt()

val additionalContentScrollbarHeight = additionalContentActualHeight.roundToInt().coerceAtLeast(0)

val additionalContentScrollbarPlaceable = subcompose("additionalContentScrollBar") {
VerticalScrollbar(scrollState = scrollState)
}.firstOrNull()?.measure(
Constraints(
maxWidth = additionalContentActualWidth.roundToInt().coerceAtLeast(0),
minHeight = additionalContentScrollbarHeight,
maxHeight = additionalContentScrollbarHeight
)
)
}.firstOrNull()
?.measure(Constraints(maxWidth = mainWidth, minHeight = scrollbarHeight, maxHeight = scrollbarHeight))

val additionalContentScrollbarX = additionalContentScrollbarPlaceable?.let { additionalContentActualWidth - additionalContentScrollbarPlaceable.width }
val scrollbarX = scrollbarPlaceable?.let { mainWidth - scrollbarPlaceable.width }
val scrollbarY = contentPaddingTop.roundToInt()

layout(width, height) {
mainPlaceable.placeRelative(0, 0)
mainScrollbarX?.let { mainScrollbarPlaceable.placeRelative(mainScrollbarX, mainScrollbarY) }
scrollbarX?.let { scrollbarPlaceable.placeRelative(scrollbarX, scrollbarY) }
additionalContentBackgroundPlaceable.placeRelative(0, additionalContentBackgroundY.roundToInt())
additionalContentPlaceable.placeRelative(additionalContentX.roundToInt(), additionalContentY.roundToInt())
additionalContentScrollbarX?.let { additionalContentScrollbarPlaceable.placeRelative(additionalContentScrollbarX.roundToInt(), additionalContentY.roundToInt()) }
}
}

Expand Down Expand Up @@ -507,7 +491,9 @@ fun SignInMainLayout(
}

@Composable
fun SignInComponent.ComponentState.SignIn.MoreMethods(modifier: Modifier = Modifier, scrollState: ScrollState) {
fun SignInComponent.ComponentState.SignIn.MoreMethods(modifier: Modifier = Modifier) {
val scrollState = rememberScrollState()

SubcomposeLayout { constraints ->
val buttons = subcompose("buttons") {
Column(modifier = modifier.verticalScroll(state = scrollState)) {
Expand Down

0 comments on commit 78cf8ea

Please sign in to comment.