Skip to content

Commit

Permalink
fix contact link in relay information dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
jiftechnify committed Sep 25, 2023
1 parent 045699e commit b5a0d65
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,15 @@ fun RelayInformationDialog(
Section(stringResource(R.string.contact))

Box(modifier = Modifier.padding(start = 10.dp)) {
ClickableEmail(relayInfo.contact ?: "")
relayInfo.contact?.let {
if (it.startsWith("https:")) {
ClickableUrl(urlText = it, url = it)
} else if (it.startsWith("mailto:") || it.contains('@')) {
ClickableEmail(it)
} else {
SectionContent(it)
}
}
}

Section(stringResource(R.string.supports))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@ import androidx.compose.ui.text.AnnotatedString

@Composable
fun ClickableEmail(email: String) {
val stripped = email.replaceFirst("mailto:", "")
val context = LocalContext.current

ClickableText(
text = remember { AnnotatedString(email) },
onClick = { runCatching { context.sendMail(email) } },
text = remember { AnnotatedString(stripped) },
onClick = { runCatching { context.sendMail(stripped) } },
style = LocalTextStyle.current.copy(color = MaterialTheme.colors.primary)
)
}
Expand Down

0 comments on commit b5a0d65

Please sign in to comment.