update AppFabMenu to support optional titles and expand FABs in MainVocabularyScreen and VocabularyMenu
This commit is contained in:
@@ -12,7 +12,7 @@ sealed class WidgetType(val id: String, @param:StringRes val titleRes: Int) {
|
||||
data object StartButtons : WidgetType("start_buttons", R.string.label_start_exercise)
|
||||
data object AllVocabulary : WidgetType("all_vocabulary", R.string.label_all_vocabulary)
|
||||
data object DueToday : WidgetType("due_today", R.string.title_widget_due_today)
|
||||
data object CategoryProgress : WidgetType("category_progress", R.string.title_widget_category_progress)
|
||||
data object CategoryProgress : WidgetType("category_progress", R.string.label_categories)
|
||||
data object WeeklyActivityChart : WidgetType("weekly_activity_chart", R.string.text_widget_title_weekly_activity)
|
||||
data object Levels : WidgetType("category_stats", R.string.levels)
|
||||
|
||||
|
||||
@@ -54,7 +54,8 @@ data class FabMenuItem(
|
||||
@Composable
|
||||
fun AppFabMenu(
|
||||
items: List<FabMenuItem>,
|
||||
modifier: Modifier = Modifier
|
||||
modifier: Modifier = Modifier,
|
||||
title: String? = null
|
||||
) {
|
||||
var isMenuExpanded by remember { mutableStateOf(false) }
|
||||
|
||||
@@ -67,6 +68,10 @@ fun AppFabMenu(
|
||||
label = "fabRotation"
|
||||
)
|
||||
|
||||
// Only rotate the FAB itself if there's no title, otherwise rotate just the icon
|
||||
val fabRotationAngle = if (title == null) rotationAngle else 0f
|
||||
val iconRotationAngle = if (title != null) rotationAngle else 0f
|
||||
|
||||
Column(
|
||||
modifier = modifier,
|
||||
horizontalAlignment = Alignment.End,
|
||||
@@ -97,16 +102,29 @@ fun AppFabMenu(
|
||||
|
||||
FloatingActionButton(
|
||||
onClick = { isMenuExpanded = !isMenuExpanded },
|
||||
modifier = Modifier.rotate(rotationAngle),
|
||||
modifier = Modifier.rotate(fabRotationAngle),
|
||||
shape = RoundedCornerShape(16.dp),
|
||||
containerColor = MaterialTheme.colorScheme.primary,
|
||||
contentColor = MaterialTheme.colorScheme.onPrimary,
|
||||
elevation = FloatingActionButtonDefaults.elevation(defaultElevation = ComponentDefaults.DefaultElevation)
|
||||
) {
|
||||
Icon(
|
||||
imageVector = AppIcons.Add,
|
||||
contentDescription = stringResource(R.string.cd_toggle_menu)
|
||||
)
|
||||
Row(
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
horizontalArrangement = Arrangement.spacedBy(8.dp),
|
||||
modifier = Modifier.padding(horizontal = 16.dp)
|
||||
) {
|
||||
Icon(
|
||||
imageVector = AppIcons.Add,
|
||||
contentDescription = stringResource(R.string.cd_toggle_menu),
|
||||
modifier = Modifier.rotate(iconRotationAngle)
|
||||
)
|
||||
if (title != null) {
|
||||
Text(
|
||||
text = title,
|
||||
style = MaterialTheme.typography.labelLarge
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ fun VocabularyMenu(
|
||||
)
|
||||
)
|
||||
|
||||
AppFabMenu(items = menuItems, modifier = modifier)
|
||||
AppFabMenu(items = menuItems, modifier = modifier, title = stringResource(R.string.label_add_vocabulary))
|
||||
|
||||
if (showAddVocabularyDialog) {
|
||||
AddVocabularyDialog(
|
||||
|
||||
@@ -382,7 +382,7 @@ fun MainVocabularyScreen(
|
||||
var menuHeightPx by remember { mutableIntStateOf(0) }
|
||||
val density = LocalDensity.current
|
||||
val menuHeightDp = (menuHeightPx / density.density).dp
|
||||
val animatedBottomPadding by animateDpAsState(targetValue = 16.dp + 8.dp + menuHeightDp, label = "fabBottomPadding")
|
||||
val animatedBottomPadding by animateDpAsState(targetValue = 16.dp + 8.dp + menuHeightDp, label = "FBottomPadding")
|
||||
|
||||
Column(
|
||||
modifier = Modifier
|
||||
@@ -402,10 +402,20 @@ fun MainVocabularyScreen(
|
||||
.align(Alignment.BottomEnd)
|
||||
.padding(end = 16.dp, bottom = animatedBottomPadding)
|
||||
) {
|
||||
Icon(
|
||||
imageVector = AppIcons.Quiz,
|
||||
contentDescription = stringResource(R.string.cd_start_exercise)
|
||||
)
|
||||
Row(
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
horizontalArrangement = Arrangement.spacedBy(8.dp),
|
||||
modifier = Modifier.padding(horizontal = 16.dp)
|
||||
) {
|
||||
Icon(
|
||||
imageVector = AppIcons.Quiz,
|
||||
contentDescription = null
|
||||
)
|
||||
Text(
|
||||
text = stringResource(R.string.label_start_exercise),
|
||||
style = MaterialTheme.typography.labelLarge
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,7 +33,6 @@
|
||||
<string name="title_single">Einzeln</string>
|
||||
<string name="title_widget_streak">Streak</string>
|
||||
<string name="label_all_vocabulary">Alle Vokabeln</string>
|
||||
<string name="title_widget_category_progress">Kategoriefortschritt</string>
|
||||
<string name="title_widget_due_today">Heute fällig</string>
|
||||
<string name="title_show_success_message">Erfolgsmeldung anzeigen</string>
|
||||
<string name="label_add_category">Kategorie hinzufügen</string>
|
||||
|
||||
@@ -33,7 +33,6 @@
|
||||
<string name="title_single">Único</string>
|
||||
<string name="title_widget_streak">Sequência</string>
|
||||
<string name="label_all_vocabulary">Todo o Vocabulário</string>
|
||||
<string name="title_widget_category_progress">Progresso da Categoria</string>
|
||||
<string name="title_widget_due_today">Para Hoje</string>
|
||||
<string name="title_show_success_message">Mostrar Mensagem de Sucesso</string>
|
||||
<string name="label_add_category">Adicionar Categoria</string>
|
||||
|
||||
@@ -986,7 +986,6 @@
|
||||
<string name="title_show_success_message">Show Success Message</string>
|
||||
<string name="title_single">Single</string>
|
||||
<string name="title_title_preview_title">Preview Title</string>
|
||||
<string name="title_widget_category_progress">Category Progress</string>
|
||||
<string name="title_widget_due_today">Due Today</string>
|
||||
<string name="title_widget_streak">Streak</string>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user