Skip to content

Commit

Permalink
feature: add a couple of UI improvements (#1084)
Browse files Browse the repository at this point in the history
* fix: images not filling full card

On some larger thinner handsets like ZFlip the images in the collection or search results do not
fill the whole card height, leaving a small gap. Update to make the image fill the max height.

* feat: pressing done should perform search

When on the search screen, if the done button is pressed on the software keyboard it should perform
the search and close the keyboard.

* style: ktlint fixes
  • Loading branch information
Chesire authored Oct 8, 2023
1 parent f669721 commit 1983395
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.text.KeyboardActions
import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Add
Expand Down Expand Up @@ -53,6 +54,7 @@ import androidx.compose.ui.ExperimentalComposeUiApi
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.alpha
import androidx.compose.ui.graphics.vector.rememberVectorPainter
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.platform.LocalSoftwareKeyboardController
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.semantics.semantics
Expand Down Expand Up @@ -108,7 +110,12 @@ private fun Render(
.padding(paddingValues),
horizontalAlignment = Alignment.CenterHorizontally
) {
InputText(state.value.searchText, state.value.isSearchTextError, onInputTextChanged)
InputText(
state.value.searchText,
state.value.isSearchTextError,
onInputTextChanged,
onSearchPressed
)
SearchGroup(state.value.searchGroup, onSearchGroupSelected)
if (state.value.isSearching) {
CircularProgressIndicator()
Expand All @@ -131,14 +138,27 @@ private fun Render(
}

@Composable
private fun InputText(text: String, isError: Boolean, onInputTextChanged: (String) -> Unit) {
private fun InputText(
text: String,
isError: Boolean,
onInputTextChanged: (String) -> Unit,
onDonePressed: () -> Unit
) {
val keyboardController = LocalSoftwareKeyboardController.current

OutlinedTextField(
value = text,
onValueChange = onInputTextChanged,
keyboardOptions = KeyboardOptions.Default.copy(
keyboardType = KeyboardType.Text,
autoCorrect = false
),
keyboardActions = KeyboardActions(
onDone = {
onDonePressed()
keyboardController?.hide()
}
),
singleLine = true,
label = { Text(text = stringResource(id = StringResource.search_series_title)) },
isError = isError,
Expand Down Expand Up @@ -258,9 +278,10 @@ private fun ResultItem(model: ResultModel, onSeriesTrack: (ResultModel) -> Unit)
error = rememberVectorPainter(image = Icons.Default.BrokenImage),
contentDescription = null,
modifier = Modifier
.fillMaxWidth(0.25f)
.fillMaxHeight()
.aspectRatio(0.7f)
.align(Alignment.CenterVertically)
.align(Alignment.CenterVertically),
contentScale = ContentScale.FillBounds
)
Column(
modifier = Modifier
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.alpha
import androidx.compose.ui.graphics.vector.rememberVectorPainter
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.semantics.semantics
Expand Down Expand Up @@ -286,9 +287,10 @@ private fun SeriesItem(
error = rememberVectorPainter(image = Icons.Default.BrokenImage),
contentDescription = null,
modifier = Modifier
.fillMaxWidth(0.25f)
.fillMaxHeight()
.aspectRatio(0.7f)
.align(Alignment.CenterVertically)
.align(Alignment.CenterVertically),
contentScale = ContentScale.FillBounds
)
Column(
modifier = Modifier
Expand Down Expand Up @@ -363,6 +365,7 @@ private fun buildDateString(context: Context, startDate: String, endDate: String
startDate.isEmpty() && endDate.isEmpty() -> context.getString(
StringResource.series_list_unknown
)

startDate == endDate -> startDate
endDate.isEmpty() -> context.getString(
StringResource.series_list_date_range,
Expand Down

0 comments on commit 1983395

Please sign in to comment.