Skip to content

Commit 8f57469

Browse files
committed
Fix default paywall vertical centering in scroll layout
1 parent 2cd9063 commit 8f57469

1 file changed

Lines changed: 45 additions & 40 deletions

File tree

  • ui/revenuecatui/src/main/kotlin/com/revenuecat/purchases/ui/revenuecatui/defaultpaywall

ui/revenuecatui/src/main/kotlin/com/revenuecat/purchases/ui/revenuecatui/defaultpaywall/DefaultPaywallView.kt

Lines changed: 45 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,13 @@ import androidx.compose.foundation.background
77
import androidx.compose.foundation.isSystemInDarkTheme
88
import androidx.compose.foundation.layout.Arrangement
99
import androidx.compose.foundation.layout.Box
10+
import androidx.compose.foundation.layout.BoxWithConstraints
1011
import androidx.compose.foundation.layout.Column
1112
import androidx.compose.foundation.layout.Spacer
1213
import androidx.compose.foundation.layout.fillMaxSize
1314
import androidx.compose.foundation.layout.fillMaxWidth
1415
import androidx.compose.foundation.layout.height
16+
import androidx.compose.foundation.layout.heightIn
1517
import androidx.compose.foundation.layout.padding
1618
import androidx.compose.foundation.layout.size
1719
import androidx.compose.foundation.layout.widthIn
@@ -119,58 +121,61 @@ internal fun DefaultPaywallView(
119121
),
120122
),
121123
) {
122-
Column(
124+
BoxWithConstraints(
123125
modifier = Modifier
124126
.fillMaxSize()
125127
.widthIn(max = 630.dp)
126128
.align(Alignment.TopCenter)
127-
.verticalScroll(rememberScrollState())
128129
.padding(16.dp),
129-
horizontalAlignment = Alignment.CenterHorizontally,
130130
) {
131-
// Title (only when showing warning)
132-
if (shouldShowWarning) {
133-
Text(
134-
text = stringResource(R.string.revenuecatui_paywalls_title),
135-
style = MaterialTheme.typography.titleMedium,
136-
fontWeight = FontWeight.Bold,
137-
textAlign = TextAlign.Center,
138-
modifier = Modifier.fillMaxWidth(),
139-
)
140-
}
141-
142-
Spacer(modifier = Modifier.weight(1f))
143-
144-
// Content area - either warning or app icon
145-
if (shouldShowWarning && warning != null) {
146-
DefaultPaywallWarning(warning = warning, warningColor = RevenueCatBrandRed)
147-
} else {
148-
AppIconSection(
149-
bitmap = appIconBitmap,
150-
appName = appName,
151-
shadowColor = mainColor,
152-
)
153-
}
154-
155-
Spacer(modifier = Modifier.weight(1f))
156-
157-
// Product list
158131
Column(
159-
verticalArrangement = Arrangement.spacedBy(8.dp),
132+
modifier = Modifier
133+
.fillMaxSize()
134+
.verticalScroll(rememberScrollState())
135+
.heightIn(min = maxHeight),
160136
horizontalAlignment = Alignment.CenterHorizontally,
137+
verticalArrangement = Arrangement.SpaceBetween,
161138
) {
162-
packages.forEach { pkg ->
163-
DefaultProductCell(
164-
pkg = pkg,
165-
accentColor = mainColor,
166-
selectedFontColor = foregroundOnAccentColor,
167-
isSelected = selectedPackage == pkg,
168-
onSelect = { selectedPackage = pkg },
139+
// Title (only when showing warning)
140+
if (shouldShowWarning) {
141+
Text(
142+
text = stringResource(R.string.revenuecatui_paywalls_title),
143+
style = MaterialTheme.typography.titleMedium,
144+
fontWeight = FontWeight.Bold,
145+
textAlign = TextAlign.Center,
146+
modifier = Modifier.fillMaxWidth(),
169147
)
148+
} else {
149+
Spacer(modifier = Modifier)
170150
}
171-
}
172151

173-
Spacer(modifier = Modifier.height(16.dp))
152+
// Content area - either warning or app icon
153+
if (shouldShowWarning && warning != null) {
154+
DefaultPaywallWarning(warning = warning, warningColor = RevenueCatBrandRed)
155+
} else {
156+
AppIconSection(
157+
bitmap = appIconBitmap,
158+
appName = appName,
159+
shadowColor = mainColor,
160+
)
161+
}
162+
163+
Column(
164+
verticalArrangement = Arrangement.spacedBy(8.dp),
165+
horizontalAlignment = Alignment.CenterHorizontally,
166+
) {
167+
packages.forEach { pkg ->
168+
DefaultProductCell(
169+
pkg = pkg,
170+
accentColor = mainColor,
171+
selectedFontColor = foregroundOnAccentColor,
172+
isSelected = selectedPackage == pkg,
173+
onSelect = { selectedPackage = pkg },
174+
)
175+
}
176+
Spacer(modifier = Modifier.height(16.dp))
177+
}
178+
}
174179
}
175180

176181
// Footer buttons

0 commit comments

Comments
 (0)