Show folder/feed filter name in TopAppBar

This commit is contained in:
Shinokuni 2024-03-04 22:42:54 +01:00
parent 6664903532
commit 5c16ea09de
2 changed files with 26 additions and 11 deletions

View File

@ -255,7 +255,10 @@ data class TimelineState(
val foldersAndFeeds: Map<Folder?, List<Feed>> = emptyMap(),
val itemState: Flow<PagingData<ItemWithFeed>> = emptyFlow(),
val dialog: DialogState? = null
)
) {
val showSubtitle = filters.subFilter != SubFilter.ALL
}
sealed interface DialogState {
object ConfirmDialog : DialogState

View File

@ -4,6 +4,7 @@ import android.util.Log
import androidx.activity.compose.BackHandler
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.lazy.LazyColumn
@ -168,19 +169,30 @@ object TimelineTab : Tab {
topBar = {
TopAppBar(
title = {
Text(
text = when (state.filters.subFilter) {
SubFilter.FEED -> state.filterFeedName
SubFilter.FOLDER -> state.filterFolderName
else -> when (state.filters.mainFilter) {
Column {
Text(
text = when (state.filters.mainFilter) {
MainFilter.STARS -> stringResource(R.string.favorites)
MainFilter.ALL -> stringResource(R.string.articles)
MainFilter.NEW -> stringResource(R.string.new_articles)
}
},
maxLines = 1,
overflow = TextOverflow.Ellipsis
)
},
maxLines = 1,
overflow = TextOverflow.Ellipsis
)
if (state.showSubtitle) {
Text(
text = when (state.filters.subFilter) {
SubFilter.FEED -> state.filterFeedName
SubFilter.FOLDER -> state.filterFolderName
else -> ""
},
style = MaterialTheme.typography.labelLarge,
maxLines = 1,
overflow = TextOverflow.Ellipsis
)
}
}
},
navigationIcon = {
IconButton(