diff --git a/pillarbox-demo-tv/src/main/java/ch/srgssr/pillarbox/demo/tv/ui/integrationLayer/SearchView.kt b/pillarbox-demo-tv/src/main/java/ch/srgssr/pillarbox/demo/tv/ui/integrationLayer/SearchView.kt index 43155734b..46fd608cf 100644 --- a/pillarbox-demo-tv/src/main/java/ch/srgssr/pillarbox/demo/tv/ui/integrationLayer/SearchView.kt +++ b/pillarbox-demo-tv/src/main/java/ch/srgssr/pillarbox/demo/tv/ui/integrationLayer/SearchView.kt @@ -29,6 +29,7 @@ import androidx.compose.ui.focus.FocusRequester import androidx.compose.ui.focus.focusRequester import androidx.compose.ui.graphics.Brush import androidx.compose.ui.graphics.graphicsLayer +import androidx.compose.ui.graphics.vector.ImageVector import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.input.ImeAction @@ -188,32 +189,33 @@ private fun SearchInput( } @Composable -@OptIn(ExperimentalTvMaterial3Api::class) private fun NoResults( modifier: Modifier = Modifier ) { - Column( + StateMessage( modifier = modifier, - verticalArrangement = Arrangement.Center, - horizontalAlignment = Alignment.CenterHorizontally - ) { - Icon( - imageVector = Icons.Default.Block, - contentDescription = null, - modifier = Modifier.size(56.dp) - ) - - Text( - text = stringResource(R.string.no_results), - modifier = Modifier.padding(top = 8.dp) - ) - } + message = stringResource(R.string.no_results), + image = Icons.Default.Block + ) } @Composable -@OptIn(ExperimentalTvMaterial3Api::class) private fun NoContent( modifier: Modifier = Modifier +) { + StateMessage( + modifier = modifier, + message = stringResource(R.string.empty_search_query), + image = Icons.Default.Search + ) +} + +@Composable +@OptIn(ExperimentalTvMaterial3Api::class) +private fun StateMessage( + modifier: Modifier, + message: String, + image: ImageVector ) { Column( modifier = modifier, @@ -221,13 +223,13 @@ private fun NoContent( horizontalAlignment = Alignment.CenterHorizontally ) { Icon( - imageVector = Icons.Default.Search, + imageVector = image, contentDescription = null, modifier = Modifier.size(56.dp) ) Text( - text = stringResource(R.string.empty_search_query), + text = image, modifier = Modifier.padding(top = 8.dp) ) } diff --git a/pillarbox-demo/src/main/java/ch/srgssr/pillarbox/demo/ui/integrationLayer/SearchView.kt b/pillarbox-demo/src/main/java/ch/srgssr/pillarbox/demo/ui/integrationLayer/SearchView.kt index a0aa17ec5..4280d8139 100644 --- a/pillarbox-demo/src/main/java/ch/srgssr/pillarbox/demo/ui/integrationLayer/SearchView.kt +++ b/pillarbox-demo/src/main/java/ch/srgssr/pillarbox/demo/ui/integrationLayer/SearchView.kt @@ -53,6 +53,7 @@ import androidx.compose.ui.draw.rotate import androidx.compose.ui.focus.FocusRequester import androidx.compose.ui.focus.focusRequester import androidx.compose.ui.graphics.RectangleShape +import androidx.compose.ui.graphics.vector.ImageVector import androidx.compose.ui.res.stringResource import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.DpOffset @@ -280,39 +281,29 @@ private fun SearchInput( @Composable private fun NoContent(modifier: Modifier = Modifier) { - Column( - modifier = modifier, - verticalArrangement = Arrangement.Center, - horizontalAlignment = Alignment.CenterHorizontally - ) { - Icon( - imageVector = Icons.Default.Search, - contentDescription = null, - modifier = Modifier.size(56.dp) - ) - - Text( - text = stringResource(sharedR.string.empty_search_query), - modifier = Modifier.padding(top = MaterialTheme.paddings.small) - ) - } + StateMessage(modifier = modifier, message = stringResource(sharedR.string.empty_search_query), image = Icons.Default.Search) } @Composable private fun NoResult(modifier: Modifier = Modifier) { + StateMessage(modifier = modifier, message = stringResource(sharedR.string.no_results), image = Icons.Default.Block) +} + +@Composable +private fun StateMessage(modifier: Modifier, message: String, image: ImageVector) { Column( modifier = modifier, verticalArrangement = Arrangement.Center, horizontalAlignment = Alignment.CenterHorizontally ) { Icon( - imageVector = Icons.Default.Block, + imageVector = image, contentDescription = null, modifier = Modifier.size(56.dp) ) Text( - text = stringResource(sharedR.string.no_results), + text = message, modifier = Modifier.padding(top = MaterialTheme.paddings.small) ) }