Skip to content

Commit

Permalink
[Paywalls] Add spacing between paragraphs and make text go full width…
Browse files Browse the repository at this point in the history
… so text align applies (#1824)

### Motivation

Fix spacing and text align consistency between Android, iOS, and web
preview

### Description

- Adds vertical spacing inbetween each paragraph type elment that
matches the line height
- Make text in `Markdown` component full width so text align applies for
single line configurations
  • Loading branch information
joshdholtz authored Aug 26, 2024
1 parent dd81d76 commit f60813b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion fastlane/.purchases-android-snapshots-commit
Original file line number Diff line number Diff line change
@@ -1 +1 @@
86ca6a1231c3e7dcbc34924f8cea83322029adb9
02ef696e3beddcdbc6791eb3c9a9140ec4e58c8f
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),
) {
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

0 comments on commit f60813b

Please sign in to comment.