1
Fork 0
mirror of https://github.com/Steffo99/twom.git synced 2024-11-21 23:54:26 +00:00

Display an X in case of error when inputting the homeserver

This commit is contained in:
Steffo 2023-11-18 05:21:37 +01:00
parent 9de4425287
commit b1e4051b60
Signed by: steffo
GPG key ID: 2A24051445686895
2 changed files with 5 additions and 3 deletions

View file

@ -32,7 +32,7 @@ import kotlinx.coroutines.launch
import org.matrix.android.sdk.api.auth.data.HomeServerConnectionConfig import org.matrix.android.sdk.api.auth.data.HomeServerConnectionConfig
@Composable @Composable
fun LoginFragment() { fun HomeserverFragment() {
TwoMMatrixProvider { TwoMMatrixProvider {
TwoMTheme { TwoMTheme {
HomeserverContents() HomeserverContents()
@ -98,8 +98,7 @@ fun HomeserverContents() {
)) ))
} }
catch(e: Throwable) { catch(e: Throwable) {
Log.e("LoginFragment", "Failed to get flows for homeserver", e) homeserverFieldState = HomeserverFieldState.Error
homeserverFieldState = HomeserverFieldState.Done
homeserverFlowValid = false homeserverFlowValid = false
return@ValidateFlows return@ValidateFlows
} }

View file

@ -3,6 +3,7 @@ package eu.steffo.twom.ui.input
import androidx.compose.material.icons.Icons import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Build import androidx.compose.material.icons.filled.Build
import androidx.compose.material.icons.filled.Check import androidx.compose.material.icons.filled.Check
import androidx.compose.material.icons.filled.Close
import androidx.compose.material.icons.filled.Create import androidx.compose.material.icons.filled.Create
import androidx.compose.material.icons.filled.Send import androidx.compose.material.icons.filled.Send
import androidx.compose.material3.Icon import androidx.compose.material3.Icon
@ -19,6 +20,7 @@ enum class HomeserverFieldState {
Empty, Empty,
Waiting, Waiting,
Validating, Validating,
Error,
Done, Done,
} }
@ -51,6 +53,7 @@ fun HomeserverField(
HomeserverFieldState.Empty -> Icons.Default.Build HomeserverFieldState.Empty -> Icons.Default.Build
HomeserverFieldState.Waiting -> Icons.Default.Create HomeserverFieldState.Waiting -> Icons.Default.Create
HomeserverFieldState.Validating -> Icons.Default.Send HomeserverFieldState.Validating -> Icons.Default.Send
HomeserverFieldState.Error -> Icons.Default.Close
HomeserverFieldState.Done -> Icons.Default.Check HomeserverFieldState.Done -> Icons.Default.Check
}, },
LocalContext.current.getString(R.string.homeserver_trailingicon_validating_description) LocalContext.current.getString(R.string.homeserver_trailingicon_validating_description)