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] Add spacing between paragraphs and make text go full width so text align applies #1824

Merged
merged 2 commits into from
Aug 26, 2024
Merged
Changes from 1 commit
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,8 +3,10 @@
package com.revenuecat.purchases.ui.revenuecatui.composables

import androidx.compose.foundation.gestures.detectTapGestures
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
Expand All @@ -16,6 +18,7 @@ import androidx.compose.ui.draw.drawBehind
import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.input.pointer.pointerInput
import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.platform.LocalUriHandler
import androidx.compose.ui.text.AnnotatedString
import androidx.compose.ui.text.SpanStyle
Expand Down Expand Up @@ -69,7 +72,12 @@ internal fun Markdown(
) {
val root = parser.parse(text) as Document

Column {
val density = LocalDensity.current
val paragraphPadding = with(density) { style.lineHeight.toDp() }

Column(
verticalArrangement = Arrangement.spacedBy(paragraphPadding),
Comment on lines +76 to +79
Copy link
Member

Choose a reason for hiding this comment

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

Inventive! 🧠

) {
MDDocument(root, color, style, fontWeight, textAlign, allowLinks, modifier)
}
}
Expand Down Expand Up @@ -375,6 +383,7 @@ private fun MarkdownText(
fontWeight = fontWeight,
textAlign = textAlign,
modifier = modifier
.fillMaxWidth()
.conditional(allowLinks) {
pointerInput(Unit) {
detectTapGestures { offset ->
Expand Down