add check for whitespace in display name (#360)

This commit is contained in:
IanRDavies
2022-02-23 12:40:50 +00:00
committed by GitHub
parent 470b18786e
commit e071e4cdbf

View File

@@ -59,6 +59,10 @@ fun WelcomeView(chatModel: ChatModel, routeHome: () -> Unit) {
}
}
fun isValidDisplayName(name: String) : Boolean {
return (name.firstOrNull { it.isWhitespace() }) == null
}
@DelicateCoroutinesApi
@Composable
fun CreateProfilePanel(chatModel: ChatModel, routeHome: () -> Unit) {
@@ -100,6 +104,13 @@ fun CreateProfilePanel(chatModel: ChatModel, routeHome: () -> Unit) {
),
singleLine = true
)
if(!isValidDisplayName(displayName)) {
Text(
"Display name cannot contain whitespace.",
style = MaterialTheme.typography.body1,
color = MaterialTheme.colors.error
)
}
Spacer(Modifier.height(10.dp))
Text(
"Full Name (Optional)",