From 9efe2e8347f7a87c408e587b28ce17a70f5e2741 Mon Sep 17 00:00:00 2001 From: Troy Rijkaard Date: Mon, 2 Oct 2023 22:29:34 +0100 Subject: [PATCH 1/3] 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. --- .../com/chesire/nekome/app/search/host/ui/HostScreen.kt | 6 ++++-- .../nekome/app/series/collection/ui/CollectionScreen.kt | 8 ++++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/features/search/src/main/java/com/chesire/nekome/app/search/host/ui/HostScreen.kt b/features/search/src/main/java/com/chesire/nekome/app/search/host/ui/HostScreen.kt index b4d88a8ac..2ea68904f 100644 --- a/features/search/src/main/java/com/chesire/nekome/app/search/host/ui/HostScreen.kt +++ b/features/search/src/main/java/com/chesire/nekome/app/search/host/ui/HostScreen.kt @@ -53,6 +53,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 @@ -258,9 +259,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 diff --git a/features/series/src/main/java/com/chesire/nekome/app/series/collection/ui/CollectionScreen.kt b/features/series/src/main/java/com/chesire/nekome/app/series/collection/ui/CollectionScreen.kt index de9ed8c2b..1787b2e99 100644 --- a/features/series/src/main/java/com/chesire/nekome/app/series/collection/ui/CollectionScreen.kt +++ b/features/series/src/main/java/com/chesire/nekome/app/series/collection/ui/CollectionScreen.kt @@ -3,6 +3,7 @@ package com.chesire.nekome.app.series.collection.ui import android.content.Context +import androidx.compose.foundation.background import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column @@ -51,7 +52,9 @@ import androidx.compose.runtime.remember import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.draw.alpha +import androidx.compose.ui.graphics.Color 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 @@ -286,9 +289,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 From 95eeb26ae18b2c04fd50c9228e1a3e706724730f Mon Sep 17 00:00:00 2001 From: Troy Rijkaard Date: Mon, 2 Oct 2023 22:33:25 +0100 Subject: [PATCH 2/3] 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. --- .../nekome/app/search/host/ui/HostScreen.kt | 23 +++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/features/search/src/main/java/com/chesire/nekome/app/search/host/ui/HostScreen.kt b/features/search/src/main/java/com/chesire/nekome/app/search/host/ui/HostScreen.kt index 2ea68904f..5e375755f 100644 --- a/features/search/src/main/java/com/chesire/nekome/app/search/host/ui/HostScreen.kt +++ b/features/search/src/main/java/com/chesire/nekome/app/search/host/ui/HostScreen.kt @@ -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 @@ -109,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() @@ -132,7 +138,14 @@ 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, @@ -140,6 +153,12 @@ private fun InputText(text: String, isError: Boolean, onInputTextChanged: (Strin keyboardType = KeyboardType.Text, autoCorrect = false ), + keyboardActions = KeyboardActions( + onDone = { + onDonePressed() + keyboardController?.hide() + } + ), singleLine = true, label = { Text(text = stringResource(id = StringResource.search_series_title)) }, isError = isError, From 775a61e9a71a36f963030cf59015c4d3c23d6a35 Mon Sep 17 00:00:00 2001 From: Troy Rijkaard Date: Sun, 8 Oct 2023 11:51:17 +0100 Subject: [PATCH 3/3] style: ktlint fixes --- .../nekome/app/series/collection/ui/CollectionScreen.kt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/features/series/src/main/java/com/chesire/nekome/app/series/collection/ui/CollectionScreen.kt b/features/series/src/main/java/com/chesire/nekome/app/series/collection/ui/CollectionScreen.kt index 1787b2e99..ba6c77e10 100644 --- a/features/series/src/main/java/com/chesire/nekome/app/series/collection/ui/CollectionScreen.kt +++ b/features/series/src/main/java/com/chesire/nekome/app/series/collection/ui/CollectionScreen.kt @@ -3,7 +3,6 @@ package com.chesire.nekome.app.series.collection.ui import android.content.Context -import androidx.compose.foundation.background import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column @@ -52,7 +51,6 @@ import androidx.compose.runtime.remember import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.draw.alpha -import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.vector.rememberVectorPainter import androidx.compose.ui.layout.ContentScale import androidx.compose.ui.platform.LocalContext @@ -367,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,