~repos /only-bible-app
git clone
https://pyrossh.dev/repos/only-bible-app.git
The only bible app you will ever need. No ads. No in-app purchases. No distractions.
file:
composeApp/src/commonMain/kotlin/dev/pyrossh/onlyBible/composables/VerseHeading.kt
package dev.pyrossh.onlyBible.composables
import androidx.compose.foundation.layout.paddingimport androidx.compose.foundation.text.ClickableTextimport androidx.compose.material3.MaterialThemeimport androidx.compose.runtime.Composableimport androidx.compose.ui.Modifierimport androidx.compose.ui.graphics.Colorimport androidx.compose.ui.text.SpanStyleimport androidx.compose.ui.text.TextStyleimport androidx.compose.ui.text.buildAnnotatedStringimport androidx.compose.ui.text.font.FontStyleimport androidx.compose.ui.text.font.FontWeightimport androidx.compose.ui.text.withStyleimport androidx.compose.ui.unit.dpimport androidx.compose.ui.unit.spimport dev.pyrossh.onlyBible.FontTypeimport dev.pyrossh.onlyBible.screens.ChapterScreenPropsimport dev.pyrossh.onlyBible.utils.SimpleParserimport dev.pyrossh.onlyBible.utils.TagNodeimport dev.pyrossh.onlyBible.utils.TextNodeimport utils.LocalNavController
@Composablefun VerseHeading( text: String, fontType: FontType, fontSizeDelta: Int,) { val navController = LocalNavController.current val nodes = SimpleParser(text).parse() val annotatedString = buildAnnotatedString { for (n in nodes) { if (n is TextNode) { append(n.value) } else if (n is TagNode && n.name == "br") { append("\n") } else if (n is TagNode && n.name == "red") { withStyle( style = SpanStyle( color = Color.Red, ) ) { append(n.child!!.value) } } else if (n is TagNode && n.name == "yellow") { withStyle( style = SpanStyle( background = Color.Yellow, ) ) { append(n.child!!.value) } } else if (n is TagNode && n.name == "a") { withStyle( style = SpanStyle( fontSize = (14 + fontSizeDelta).sp, fontStyle = FontStyle.Italic, color = Color(0xFF008AE6), ) ) { append(n.child!!.value) addStringAnnotation( tag = "URL", annotation = n.attributes["href"]!!, start = n.child!!.pos.start, end = n.child!!.pos.end, ) } } } } ClickableText( modifier = Modifier.padding(bottom = 12.dp), style = TextStyle( fontFamily = fontType.family(), fontSize = (16 + fontSizeDelta).sp, fontWeight = FontWeight.W700, color = MaterialTheme.colorScheme.onSurface, ), text = annotatedString, onClick = { // view.playSoundEffect(SoundEffectConstants.CLICK) annotatedString .getStringAnnotations("URL", it, it) .map { anno -> val parts = anno.item.split(":") navController.navigate( ChapterScreenProps( bookIndex = parts[0].toInt(), chapterIndex = parts[1].toInt(), verseIndex = parts[2].toInt(), ) ) }
} )}