Skip to content

Commit

Permalink
Paywalls: Markdown support (#1312)
Browse files Browse the repository at this point in the history
This uses https://github.com/commonmark/commonmark-java for parsing, and
the rendering implementation is derived from
https://github.com/ErikHellman/MarkdownComposer/blob/master/app/src/main/java/se/hellsoft/markdowncomposer/MarkdownComposer.kt
with a lot changes to be able to use `Markdown()` in the same way we use
`Text()`, therefore being able to replace our usages everywhere.

<img width="352" alt="Screenshot 2023-10-05 at 12 27 37"
src="https://github.com/RevenueCat/purchases-android/assets/685609/08b05cf2-9c63-46bf-9f9f-b86f0225c34a">
  • Loading branch information
NachoSoto authored and tonidero committed Oct 31, 2023
1 parent dfa58c4 commit 17da156
Show file tree
Hide file tree
Showing 12 changed files with 401 additions and 28 deletions.
4 changes: 4 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ viewmodelCompose = "2.4.0"
paparrazzi = "1.3.1"
coil = "2.4.0"
window = "1.1.0"
commonmark = "0.21.0"

[plugins]
android-application = { id = "com.android.application", version.ref = "agp" }
Expand Down Expand Up @@ -120,6 +121,9 @@ window-core = { module = "androidx.window:window-core", version.ref = "window" }
coil-compose = { module = "io.coil-kt:coil-compose", version.ref = "coil" }
coil-svg = { module = "io.coil-kt:coil-svg", version.ref = "coil" }

commonmark = { module = "org.commonmark:commonmark", version.ref = "commonmark" }
commonmark-strikethrough = { module = "org.commonmark:commonmark-ext-gfm-strikethrough", version.ref = "commonmark" }

navigation-compose = "androidx.navigation:navigation-compose:2.5.3"

[bundles]
Expand Down
2 changes: 2 additions & 0 deletions ui/revenuecatui/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ dependencies {
implementation libs.androidx.lifecycle.viewmodel.compose
implementation libs.coil.compose
implementation libs.coil.svg
implementation libs.commonmark
implementation libs.commonmark.strikethrough
debugImplementation libs.compose.ui.tooling
debugImplementation libs.androidx.test.compose.manifest

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.revenuecat.purchases.ui.revenuecatui.composables

import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.TextStyle
Expand Down Expand Up @@ -30,7 +29,7 @@ internal fun IntroEligibilityStateView(
textWithNoIntroOffer ?: textWithIntroOffer ?: ""
}

Text(
Markdown(
text,
color = color,
style = style,
Expand Down
Loading

0 comments on commit 17da156

Please sign in to comment.