improvement: Show 'Empty' in place of an empty title text

This commit is contained in:
Artem Chepurnoy 2024-04-10 11:54:25 +03:00
parent 3fc4ec3f03
commit b8cd84a7f4
No known key found for this signature in database
GPG Key ID: FAC37D0CF674043E
4 changed files with 73 additions and 22 deletions

View File

@ -302,11 +302,23 @@ fun VaultListItemText(
content = {
FlatItemTextContent(
title = {
Text(
text = item.title,
overflow = TextOverflow.Ellipsis,
maxLines = 1,
)
val title = item.title
.takeUnless { it.isEmpty() }
if (title != null) {
Text(
text = title,
overflow = TextOverflow.Ellipsis,
maxLines = 1,
)
} else {
Text(
text = stringResource(Res.strings.empty_value),
color = LocalContentColor.current
.combineAlpha(DisabledEmphasisAlpha),
overflow = TextOverflow.Ellipsis,
maxLines = 1,
)
}
},
text = item.text
?.takeIf { it.isNotEmpty() }

View File

@ -47,6 +47,7 @@ import com.artemchep.keyguard.feature.home.vault.component.rememberSecretAccentC
import com.artemchep.keyguard.feature.home.vault.component.surfaceColorAtElevationSemi
import com.artemchep.keyguard.feature.home.vault.model.VaultItemIcon
import com.artemchep.keyguard.feature.navigation.NavigationIcon
import com.artemchep.keyguard.res.Res
import com.artemchep.keyguard.ui.Avatar
import com.artemchep.keyguard.ui.DefaultFab
import com.artemchep.keyguard.ui.DisabledEmphasisAlpha
@ -63,6 +64,7 @@ import com.artemchep.keyguard.ui.shimmer.shimmer
import com.artemchep.keyguard.ui.skeleton.SkeletonText
import com.artemchep.keyguard.ui.theme.combineAlpha
import com.artemchep.keyguard.ui.toolbar.LargeToolbar
import dev.icerock.moko.resources.compose.stringResource
@Composable
fun VaultViewScreen(
@ -312,12 +314,23 @@ private fun VaultViewTitle(
}
is VaultViewState.Content.Cipher -> {
val name = state.content.data.name
Text(
text = name,
maxLines = 2,
overflow = TextOverflow.Ellipsis,
)
val title = state.content.data.name
.takeUnless { it.isEmpty() }
if (title != null) {
Text(
text = title,
maxLines = 2,
overflow = TextOverflow.Ellipsis,
)
} else {
Text(
text = stringResource(Res.strings.empty_value),
color = LocalContentColor.current
.combineAlpha(DisabledEmphasisAlpha),
maxLines = 1,
overflow = TextOverflow.Ellipsis,
)
}
}
is VaultViewState.Content.NotFound -> {

View File

@ -29,6 +29,7 @@ import androidx.compose.material3.DropdownMenu
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon
import androidx.compose.material3.LocalAbsoluteTonalElevation
import androidx.compose.material3.LocalContentColor
import androidx.compose.material3.LocalTextStyle
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
@ -82,6 +83,7 @@ import com.artemchep.keyguard.ui.CollectedEffect
import com.artemchep.keyguard.ui.Compose
import com.artemchep.keyguard.ui.DefaultFab
import com.artemchep.keyguard.ui.DefaultSelection
import com.artemchep.keyguard.ui.DisabledEmphasisAlpha
import com.artemchep.keyguard.ui.DropdownMenuItemFlat
import com.artemchep.keyguard.ui.DropdownMinWidth
import com.artemchep.keyguard.ui.DropdownScopeImpl
@ -101,6 +103,7 @@ import com.artemchep.keyguard.ui.icons.KeyguardNote
import com.artemchep.keyguard.ui.icons.KeyguardView
import com.artemchep.keyguard.ui.pulltosearch.PullToSearch
import com.artemchep.keyguard.ui.skeleton.SkeletonItem
import com.artemchep.keyguard.ui.theme.combineAlpha
import com.artemchep.keyguard.ui.theme.selectedContainer
import com.artemchep.keyguard.ui.toolbar.CustomToolbar
import com.artemchep.keyguard.ui.toolbar.content.CustomSearchbarContent
@ -512,11 +515,23 @@ fun VaultSendItemText(
content = {
FlatItemTextContent(
title = {
Text(
text = item.title,
overflow = TextOverflow.Ellipsis,
maxLines = 1,
)
val title = item.title
.takeUnless { it.isEmpty() }
if (title != null) {
Text(
text = title,
overflow = TextOverflow.Ellipsis,
maxLines = 1,
)
} else {
Text(
text = stringResource(Res.strings.empty_value),
color = LocalContentColor.current
.combineAlpha(DisabledEmphasisAlpha),
overflow = TextOverflow.Ellipsis,
maxLines = 1,
)
}
},
text = item.text
?.takeIf { it.isNotEmpty() }

View File

@ -311,12 +311,23 @@ private fun VaultViewTitle(
}
is SendViewState.Content.Cipher -> {
val name = state.content.data.name
Text(
text = name,
maxLines = 2,
overflow = TextOverflow.Ellipsis,
)
val title = state.content.data.name
.takeUnless { it.isEmpty() }
if (title != null) {
Text(
text = title,
maxLines = 2,
overflow = TextOverflow.Ellipsis,
)
} else {
Text(
text = stringResource(Res.strings.empty_value),
color = LocalContentColor.current
.combineAlpha(DisabledEmphasisAlpha),
maxLines = 1,
overflow = TextOverflow.Ellipsis,
)
}
}
is SendViewState.Content.NotFound -> {