Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix visual bug for empty folders #365

Merged
merged 1 commit into from
Sep 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions app/src/main/java/com/capyreader/app/ui/articles/ArticleLayout.kt
Original file line number Diff line number Diff line change
@@ -39,7 +39,6 @@ import androidx.compose.ui.platform.LocalFocusManager
import androidx.compose.ui.platform.LocalSoftwareKeyboardController
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.paging.PagingData
import androidx.paging.compose.collectAsLazyPagingItems
import com.capyreader.app.R
@@ -66,7 +65,6 @@ import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.emptyFlow
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext

@OptIn(
ExperimentalMaterial3AdaptiveApi::class,
@@ -78,6 +76,7 @@ fun ArticleLayout(
folders: List<Folder>,
feeds: List<Feed>,
allFeeds: List<Feed>,
allFolders: List<Folder>,
articles: Flow<PagingData<Article>>,
article: Article?,
search: ArticleSearch,
@@ -262,26 +261,26 @@ fun ArticleLayout(
}),
topBar = {
FeedListTopBar(
onRequestJumpToTop = {
scrollToTop()
},
onNavigateToDrawer = {
coroutineScope.launch {
drawerState.open()
}
},
onRequestJumpToTop = {
onRequestSnackbar = { showSnackbar(it) },
onRemoveFeed = onRemoveFeed,
onSearchQueryChange = {
scrollToTop()
},
onRemoveFeed = onRemoveFeed,
scrollBehavior = scrollBehavior,
filter = filter,
feeds = allFeeds,
folders = folders,
currentFeed = currentFeed,
onMarkAllRead = onMarkAllRead,
onRequestSnackbar = { showSnackbar(it) },
search = search,
onSearchQueryChange = {
scrollToTop()
}
filter = filter,
currentFeed = currentFeed,
feeds = allFeeds,
allFolders = allFolders
)
},
snackbarHost = {
@@ -436,6 +435,7 @@ fun ArticleLayoutPreview() {
filter = ArticleFilter.default(),
folders = folders,
feeds = feeds,
allFolders = emptyList(),
allFeeds = emptyList(),
articles = emptyFlow(),
search = ArticleSearch(),
Original file line number Diff line number Diff line change
@@ -17,6 +17,7 @@ fun ArticleScreen(
) {
val feeds by viewModel.feeds.collectAsStateWithLifecycle(initialValue = emptyList())
val allFeeds by viewModel.allFeeds.collectAsStateWithLifecycle(initialValue = emptyList())
val allFolders by viewModel.allFolders.collectAsStateWithLifecycle(initialValue = emptyList())
val folders by viewModel.folders.collectAsStateWithLifecycle(initialValue = emptyList())
val statusCount by viewModel.statusCount.collectAsStateWithLifecycle(initialValue = 0)
val filter by viewModel.filter.collectAsStateWithLifecycle()
@@ -26,6 +27,7 @@ fun ArticleScreen(
filter = filter,
folders = folders,
feeds = feeds,
allFolders = allFolders,
allFeeds = allFeeds,
articles = viewModel.articles,
article = viewModel.article,
Original file line number Diff line number Diff line change
@@ -66,6 +66,8 @@ class ArticleScreenViewModel(

val allFeeds = account.allFeeds

val allFolders = account.folders

val feeds = account.feeds.combine(_counts) { feeds, latestCounts ->
feeds.map { copyFeedCounts(it, latestCounts) }
.withPositiveCount(filterStatus)
Original file line number Diff line number Diff line change
@@ -4,7 +4,6 @@ import androidx.compose.foundation.clickable
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
@@ -16,16 +15,16 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.tooling.preview.Preview
import com.capyreader.app.ui.navigationTitle
import com.jocmp.capy.ArticleFilter
import com.jocmp.capy.Feed
import com.jocmp.capy.Folder
import com.capyreader.app.ui.navigationTitle

@Composable
fun FilterAppBarTitle(
filter: ArticleFilter,
allFeeds: List<Feed>,
folders: List<Folder>,
allFolders: List<Folder>,
onRequestJumpToTop: () -> Unit
) {
val text = when (filter) {
@@ -35,7 +34,7 @@ fun FilterAppBarTitle(
}

is ArticleFilter.Folders -> {
folders.find { it.title == filter.folderTitle }?.title
allFolders.find { it.title == filter.folderTitle }?.title
}
}.orEmpty()

@@ -68,7 +67,7 @@ fun FilterAppBarTitlePreview() {
FilterAppBarTitle(
filter = ArticleFilter.default(),
allFeeds = emptyList(),
folders = emptyList(),
allFolders = emptyList(),
onRequestJumpToTop = {}
)
})
Original file line number Diff line number Diff line change
@@ -39,7 +39,6 @@ import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.launch
import org.koin.compose.koinInject

@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun ArticleView(
article: Article,
Original file line number Diff line number Diff line change
@@ -50,7 +50,7 @@ fun FeedListTopBar(
filter: ArticleFilter,
currentFeed: Feed?,
feeds: List<Feed>,
folders: List<Folder>,
allFolders: List<Folder>,
) {
val editSuccessMessage = stringResource(R.string.feed_action_edit_success)
val unsubscribeMessage = stringResource(R.string.feed_action_unsubscribe_success)
@@ -113,7 +113,7 @@ fun FeedListTopBar(
FilterAppBarTitle(
filter = filter,
allFeeds = feeds,
folders = folders,
allFolders = allFolders,
onRequestJumpToTop = onRequestJumpToTop
)
}
@@ -179,13 +179,13 @@ private fun FeedListTopBarPreview() {
onNavigateToDrawer = { },
onRequestSnackbar = {},
onRemoveFeed = { _, _, _ -> },
onSearchQueryChange = {},
scrollBehavior = scrollBehavior,
onMarkAllRead = {},
search = ArticleSearch(),
filter = ArticleFilter.default(),
currentFeed = null,
feeds = listOf(),
folders = listOf(),
search = ArticleSearch(),
onSearchQueryChange = {}
allFolders = emptyList()
)
}