implement delayed FAB text display in MainVocabularyScreen

This commit is contained in:
jonasgaudian
2026-02-15 17:39:39 +01:00
parent 2e0fe76fbf
commit 61a97a1119

View File

@@ -75,8 +75,6 @@ enum class VocabularyTab(
Statistics(title = "label_all_vocabulary", icon = AppIcons.BarChart, route = "statistics") Statistics(title = "label_all_vocabulary", icon = AppIcons.BarChart, route = "statistics")
} }
//Used to avoid the warning of unused variables in strings.xml
@Suppress("unused", "HardCodedStringLiteral", "UnusedVariable") @Suppress("unused", "HardCodedStringLiteral", "UnusedVariable")
@Composable @Composable
fun Dummy() { fun Dummy() {
@@ -297,7 +295,18 @@ fun MainVocabularyScreen(
VocabularyTab.entries.find { it.route == currentRoute } ?: VocabularyTab.Dashboard VocabularyTab.entries.find { it.route == currentRoute } ?: VocabularyTab.Dashboard
} }
val showFabText = selectedTab == VocabularyTab.Dashboard && !isScrolling val rawShowFabText = selectedTab == VocabularyTab.Dashboard && !isScrolling
var showFabText by remember { mutableStateOf(rawShowFabText) }
LaunchedEffect(rawShowFabText) {
if (rawShowFabText) {
// Only delay when showing (true), hide immediately
kotlinx.coroutines.delay(2000)
showFabText = true
} else {
showFabText = false
}
}
val repoEmpty = val repoEmpty =
vocabularyViewModel.vocabularyItems.collectAsState(initial = emptyList()).value.isEmpty() vocabularyViewModel.vocabularyItems.collectAsState(initial = emptyList()).value.isEmpty()