Use a LazyColumn, in case we get more results in the future.
This commit is contained in:
parent
18f32e51b4
commit
6b1809ed3b
1 changed files with 60 additions and 56 deletions
|
|
@ -19,7 +19,6 @@
|
||||||
package io.element.android.features.login.impl.screens.searchaccountprovider
|
package io.element.android.features.login.impl.screens.searchaccountprovider
|
||||||
|
|
||||||
import androidx.compose.foundation.layout.Box
|
import androidx.compose.foundation.layout.Box
|
||||||
import androidx.compose.foundation.layout.Column
|
|
||||||
import androidx.compose.foundation.layout.ExperimentalLayoutApi
|
import androidx.compose.foundation.layout.ExperimentalLayoutApi
|
||||||
import androidx.compose.foundation.layout.Spacer
|
import androidx.compose.foundation.layout.Spacer
|
||||||
import androidx.compose.foundation.layout.consumeWindowInsets
|
import androidx.compose.foundation.layout.consumeWindowInsets
|
||||||
|
|
@ -28,9 +27,10 @@ import androidx.compose.foundation.layout.fillMaxWidth
|
||||||
import androidx.compose.foundation.layout.height
|
import androidx.compose.foundation.layout.height
|
||||||
import androidx.compose.foundation.layout.imePadding
|
import androidx.compose.foundation.layout.imePadding
|
||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
import androidx.compose.foundation.rememberScrollState
|
import androidx.compose.foundation.lazy.LazyColumn
|
||||||
|
import androidx.compose.foundation.lazy.items
|
||||||
|
import androidx.compose.foundation.lazy.rememberLazyListState
|
||||||
import androidx.compose.foundation.text.KeyboardOptions
|
import androidx.compose.foundation.text.KeyboardOptions
|
||||||
import androidx.compose.foundation.verticalScroll
|
|
||||||
import androidx.compose.material.icons.Icons
|
import androidx.compose.material.icons.Icons
|
||||||
import androidx.compose.material.icons.filled.Close
|
import androidx.compose.material.icons.filled.Close
|
||||||
import androidx.compose.material.icons.filled.Search
|
import androidx.compose.material.icons.filled.Search
|
||||||
|
|
@ -98,17 +98,16 @@ fun SearchAccountProviderView(
|
||||||
.padding(padding)
|
.padding(padding)
|
||||||
.consumeWindowInsets(padding)
|
.consumeWindowInsets(padding)
|
||||||
) {
|
) {
|
||||||
Column(
|
LazyColumn(modifier = Modifier.fillMaxWidth(), state = rememberLazyListState()) {
|
||||||
modifier = Modifier
|
item {
|
||||||
.verticalScroll(state = rememberScrollState())
|
|
||||||
) {
|
|
||||||
IconTitleSubtitleMolecule(
|
IconTitleSubtitleMolecule(
|
||||||
modifier = Modifier.padding(top = 16.dp, bottom = 40.dp, start = 16.dp, end = 16.dp),
|
modifier = Modifier.padding(top = 16.dp, bottom = 40.dp, start = 16.dp, end = 16.dp),
|
||||||
iconImageVector = Icons.Filled.Search,
|
iconImageVector = Icons.Filled.Search,
|
||||||
title = stringResource(id = R.string.screen_account_provider_form_title),
|
title = stringResource(id = R.string.screen_account_provider_form_title),
|
||||||
subTitle = stringResource(id = R.string.screen_account_provider_form_subtitle),
|
subTitle = stringResource(id = R.string.screen_account_provider_form_subtitle),
|
||||||
)
|
)
|
||||||
|
}
|
||||||
|
item {
|
||||||
// TextInput
|
// TextInput
|
||||||
var userInputState by textFieldState(stateValue = state.userInput)
|
var userInputState by textFieldState(stateValue = state.userInput)
|
||||||
|
|
||||||
|
|
@ -145,12 +144,14 @@ fun SearchAccountProviderView(
|
||||||
Text(text = stringResource(id = R.string.screen_account_provider_form_notice), color = MaterialTheme.colorScheme.secondary)
|
Text(text = stringResource(id = R.string.screen_account_provider_form_notice), color = MaterialTheme.colorScheme.secondary)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
}
|
||||||
|
|
||||||
when (state.userInputResult) {
|
when (state.userInputResult) {
|
||||||
is Async.Failure -> {
|
is Async.Failure -> {
|
||||||
// Ignore errors (let the user type more chars)
|
// Ignore errors (let the user type more chars)
|
||||||
}
|
}
|
||||||
is Async.Loading -> {
|
is Async.Loading -> {
|
||||||
|
item {
|
||||||
Box(
|
Box(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.fillMaxSize()
|
.fillMaxSize()
|
||||||
|
|
@ -160,8 +161,9 @@ fun SearchAccountProviderView(
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
is Async.Success -> {
|
is Async.Success -> {
|
||||||
state.userInputResult.state.forEach { homeserverData ->
|
items(state.userInputResult.state) { homeserverData ->
|
||||||
val item = homeserverData.toAccountProvider()
|
val item = homeserverData.toAccountProvider()
|
||||||
AccountProviderView(
|
AccountProviderView(
|
||||||
item = item,
|
item = item,
|
||||||
|
|
@ -173,8 +175,10 @@ fun SearchAccountProviderView(
|
||||||
}
|
}
|
||||||
Async.Uninitialized -> Unit
|
Async.Uninitialized -> Unit
|
||||||
}
|
}
|
||||||
|
item {
|
||||||
Spacer(Modifier.height(32.dp))
|
Spacer(Modifier.height(32.dp))
|
||||||
}
|
}
|
||||||
|
}
|
||||||
ChangeServerView(
|
ChangeServerView(
|
||||||
state = state.changeServerState,
|
state = state.changeServerState,
|
||||||
onLearnMoreClicked = onLearnMoreClicked,
|
onLearnMoreClicked = onLearnMoreClicked,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue