Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Paywalls V2] Extend paywall content below sticky footer #2125

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,25 @@
package com.revenuecat.purchases.ui.revenuecatui.components

import android.content.res.Configuration
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableIntStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.toArgb
import androidx.compose.ui.layout.onSizeChanged
import androidx.compose.ui.platform.LocalConfiguration
import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.tooling.preview.Preview
import com.revenuecat.purchases.Offering
import com.revenuecat.purchases.paywalls.components.StackComponent
Expand Down Expand Up @@ -64,23 +73,32 @@ internal fun LoadedPaywallComponents(
val footerComponentStyle = state.stickyFooter
val background = rememberBackgroundStyle(state.background)

Column(modifier = modifier.background(background)) {
Box(
modifier = modifier
.background(background),
) {
var footerHeight by remember { mutableIntStateOf(0) }
Copy link
Contributor Author

@tonidero tonidero Feb 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought about using SubcomposeLayout for this instead but I was running into issues applying the padding and making it look right and this seemed easier for this use case. wdyt?

val footerHeightDp = with(LocalDensity.current) { footerHeight.toDp() }

ComponentView(
style = style,
state = state,
onClick = clickHandler,
modifier = Modifier
.fillMaxWidth()
.weight(1f)
.verticalScroll(rememberScrollState()),
.fillMaxSize()
.verticalScroll(rememberScrollState())
.padding(bottom = footerHeightDp),
)

footerComponentStyle?.let {
ComponentView(
style = it,
state = state,
onClick = clickHandler,
modifier = Modifier
.fillMaxWidth(),
.fillMaxWidth()
.align(Alignment.BottomCenter)
.onSizeChanged { size -> footerHeight = size.height },
)
}
}
Expand Down