|
3 | 3 | package com.revenuecat.purchases.ui.revenuecatui.components
|
4 | 4 |
|
5 | 5 | import android.content.res.Configuration
|
| 6 | +import androidx.compose.foundation.layout.Box |
6 | 7 | import androidx.compose.foundation.layout.Column
|
| 8 | +import androidx.compose.foundation.layout.Spacer |
7 | 9 | import androidx.compose.foundation.layout.fillMaxSize
|
8 | 10 | import androidx.compose.foundation.layout.fillMaxWidth
|
| 11 | +import androidx.compose.foundation.layout.height |
9 | 12 | import androidx.compose.foundation.rememberScrollState
|
10 | 13 | import androidx.compose.foundation.verticalScroll
|
11 | 14 | import androidx.compose.runtime.Composable
|
| 15 | +import androidx.compose.runtime.getValue |
| 16 | +import androidx.compose.runtime.mutableIntStateOf |
| 17 | +import androidx.compose.runtime.remember |
| 18 | +import androidx.compose.runtime.setValue |
| 19 | +import androidx.compose.ui.Alignment |
12 | 20 | import androidx.compose.ui.Modifier
|
13 | 21 | import androidx.compose.ui.graphics.Color
|
14 | 22 | import androidx.compose.ui.graphics.toArgb
|
| 23 | +import androidx.compose.ui.layout.onSizeChanged |
15 | 24 | import androidx.compose.ui.platform.LocalConfiguration
|
| 25 | +import androidx.compose.ui.platform.LocalDensity |
16 | 26 | import androidx.compose.ui.tooling.preview.Preview
|
17 | 27 | import com.revenuecat.purchases.Offering
|
18 | 28 | import com.revenuecat.purchases.paywalls.components.StackComponent
|
@@ -64,23 +74,29 @@ internal fun LoadedPaywallComponents(
|
64 | 74 | val footerComponentStyle = state.stickyFooter
|
65 | 75 | val background = rememberBackgroundStyle(state.background)
|
66 | 76 |
|
67 |
| - Column(modifier = modifier.background(background)) { |
68 |
| - ComponentView( |
69 |
| - style = style, |
70 |
| - state = state, |
71 |
| - onClick = clickHandler, |
72 |
| - modifier = Modifier |
73 |
| - .fillMaxWidth() |
74 |
| - .weight(1f) |
75 |
| - .verticalScroll(rememberScrollState()), |
76 |
| - ) |
| 77 | + Box(modifier = modifier.background(background)) { |
| 78 | + var footerHeight by remember { mutableIntStateOf(0) } |
| 79 | + Column(modifier = Modifier.verticalScroll(rememberScrollState())) { |
| 80 | + ComponentView( |
| 81 | + style = style, |
| 82 | + state = state, |
| 83 | + onClick = clickHandler, |
| 84 | + modifier = Modifier |
| 85 | + .fillMaxWidth(), |
| 86 | + ) |
| 87 | + val footerHeightDp = with(LocalDensity.current) { footerHeight.toDp() } |
| 88 | + Spacer(modifier = Modifier.height(footerHeightDp)) |
| 89 | + } |
| 90 | + |
77 | 91 | footerComponentStyle?.let {
|
78 | 92 | ComponentView(
|
79 | 93 | style = it,
|
80 | 94 | state = state,
|
81 | 95 | onClick = clickHandler,
|
82 | 96 | modifier = Modifier
|
83 |
| - .fillMaxWidth(), |
| 97 | + .fillMaxWidth() |
| 98 | + .align(Alignment.BottomCenter) |
| 99 | + .onSizeChanged { size -> footerHeight = size.height }, |
84 | 100 | )
|
85 | 101 | }
|
86 | 102 | }
|
|
0 commit comments