Skip to content

Commit

Permalink
Remove some duplicate code
Browse files Browse the repository at this point in the history
  • Loading branch information
StaehliJ committed Nov 29, 2023
1 parent ffec0bb commit 8ce4f97
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -188,46 +189,47 @@ 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,
verticalArrangement = Arrangement.Center,
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)
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
)
}
Expand Down

0 comments on commit 8ce4f97

Please sign in to comment.