Center empty text

This commit is contained in:
LooKeR 2022-03-01 16:54:11 +05:30
parent 5a5e59d410
commit 5f4dffd483

View File

@ -1,15 +1,18 @@
package com.looker.droidify.ui.compose package com.looker.droidify.ui.compose
import androidx.compose.foundation.ExperimentalFoundationApi import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement.Absolute.spacedBy import androidx.compose.foundation.layout.Arrangement.Absolute.spacedBy
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.LazyItemScope import androidx.compose.foundation.lazy.LazyItemScope
import androidx.compose.foundation.lazy.LazyRow import androidx.compose.foundation.lazy.LazyRow
import androidx.compose.foundation.lazy.items import androidx.compose.foundation.lazy.items
import androidx.compose.material3.MaterialTheme import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Surface
import androidx.compose.material3.Text import androidx.compose.material3.Text
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.stringResource import androidx.compose.ui.res.stringResource
@ -77,8 +80,13 @@ fun <T> VerticalItemList(
itemKey: ((T) -> Any)? = null, itemKey: ((T) -> Any)? = null,
itemContent: @Composable LazyItemScope.(T) -> Unit itemContent: @Composable LazyItemScope.(T) -> Unit
) { ) {
Surface(modifier = modifier, color = backgroundColor) { Box(
if (list != null) { modifier = modifier
.fillMaxSize()
.background(backgroundColor),
contentAlignment = Alignment.Center
) {
if (!list.isNullOrEmpty()) {
LazyColumn(verticalArrangement = spacedBy(4.dp)) { LazyColumn(verticalArrangement = spacedBy(4.dp)) {
items(items = list, key = itemKey, itemContent = itemContent) items(items = list, key = itemKey, itemContent = itemContent)
} }