Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 2 additions & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,8 @@ dependencies {
//noinspection GradleDependency
implementation("androidx.browser:browser:1.8.0")

implementation("io.github.zly2006:markdown-parser-android:0.0.1-alpha.3")
implementation("io.github.zly2006:markdown-renderer-android:0.0.1-alpha.3")
implementation("io.github.zly2006:markdown-parser-android:0.0.1-alpha.4")
implementation("io.github.zly2006:markdown-renderer-android:0.0.1-alpha.4")

implementation("io.coil-kt.coil3:coil-compose:$coil")
implementation("io.coil-kt.coil3:coil-network-ktor3-android:$coil")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ import com.github.zly2006.zhihu.data.AccountData
import com.github.zly2006.zhihu.navigation.LocalNavigator
import com.github.zly2006.zhihu.navigation.Video
import com.github.zly2006.zhihu.navigation.resolveContent
import com.github.zly2006.zhihu.theme.ThemeManager
import com.github.zly2006.zhihu.ui.PREFERENCE_NAME
import com.github.zly2006.zhihu.ui.components.OpenImageDislog
import com.github.zly2006.zhihu.ui.subscreens.PREF_FONT_SIZE
Expand Down Expand Up @@ -220,8 +221,9 @@ fun RenderMarkdown(
val preferences = remember { context.getSharedPreferences(PREFERENCE_NAME, Context.MODE_PRIVATE) }
val fontSize = preferences.getInt(PREF_FONT_SIZE, 100)
val lineHeight = preferences.getInt(PREF_LINE_HEIGHT, 160)
val theme = MarkdownTheme.auto().copy(
bodyStyle = MarkdownTheme.auto().bodyStyle.copy(
val defaultTheme = MarkdownTheme.auto(ThemeManager.isDarkTheme())
val theme = defaultTheme.copy(
bodyStyle = defaultTheme.bodyStyle.copy(
fontSize = 16.sp * fontSize / 100,
lineHeight = 16.sp * fontSize / 100 * lineHeight / 100,
),
Expand All @@ -237,25 +239,21 @@ fun RenderMarkdown(
resolveContent(url)?.let { navigator.onNavigate(it) }
?: luoTianYiUrlLauncher(context, url.toUri())
},
header = header,
footer = footer,
theme = theme,
)
}

if (selectable) {
SelectionContainer(modifier = modifier) {
Column {
header?.invoke()
markdownBody()
footer?.invoke()
}
markdownBody()
}
} else {
Column(
modifier = modifier,
) {
header?.invoke()
markdownBody()
footer?.invoke()
}
}
}
Loading