hyperlinkStyle
HyperlinkStyle method is meant to be style text as an Skapa Hyperlink component in those cases the raw component is not enough by itself
Return
Parameters
color
HyperlinkColor different set of colors for the text
active
indicates if the link has been clicked
Samples
import androidx.compose.foundation.clickable
import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.text.BasicText
import androidx.compose.material3.LocalTextStyle
import androidx.compose.runtime.*
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.ui.Modifier
import androidx.compose.ui.text.buildAnnotatedString
import androidx.compose.ui.text.withStyle
import androidx.compose.ui.tooling.preview.Preview
import net.ikea.skapa.foundation.*
import net.ikea.skapa.ui.components.Checkbox
import net.ikea.skapa.ui.components.Hyperlink
import net.ikea.skapa.ui.components.HyperlinkColor
import net.ikea.skapa.ui.components.hyperlinkStyle
fun main() {
//sampleStart
var active by rememberSaveable { mutableStateOf(false) }
val annotatedText = buildAnnotatedString {
append("I have read the ")
// We attach this *URL* annotation to the following content
// until `pop()` is called
pushStringAnnotation(
tag = "link",
annotation = "terms and conditions"
)
withStyle(
hyperlinkStyle(active = active, color = HyperlinkColor.Grey)
) {
append("terms and conditions")
}
pop()
}
var checked by remember { mutableStateOf(false) }
SkapaTheme2(isSystemInDarkTheme()) {
Row(horizontalArrangement = Arrangement.spacedBy(SkapaSpacing.space100)) {
Checkbox(
checked = checked,
onCheckedChange = { checked = !checked }
)
BasicText(
text = annotatedText,
style = LocalTextStyle.current,
modifier = Modifier.clickable {
active = true
}
)
}
}
//sampleEnd
}