feat: option to hide navigation labels

* Added an option to hide navigation bar labels under icons
This commit is contained in:
Acclorite 2025-10-19 19:55:55 +03:00
parent 67befe9a8c
commit bd7dbecce2
No known key found for this signature in database
GPG key ID: 6E54C611F6EE8593
10 changed files with 83 additions and 26 deletions

View file

@ -106,6 +106,9 @@ class SettingsManager @Inject constructor(
val doublePressExit = setting<Boolean, Boolean>(
key = booleanPreferencesKey("double_press_exit"), default = false
)
val showNavigationLabels = setting<Boolean, Boolean>(
key = booleanPreferencesKey("show_navigation_labels"), default = true
)
/* ------ Reader ----------------------------- */
val fontFamily = setting<FontWithName, String>(

View file

@ -151,8 +151,18 @@ class MainActivity : AppCompatActivity() {
Transitions.FadeTransitionIn
.togetherWith(Transitions.FadeTransitionOut)
},
navigationBar = { NavigationBar(tabs = tabs) },
navigationRail = { NavigationRail(tabs = tabs) }
navigationBar = {
NavigationBar(
tabs = tabs,
showLabels = settings.showNavigationLabels.value
)
},
navigationRail = {
NavigationRail(
tabs = tabs,
showLabels = settings.showNavigationLabels.value
)
}
) { tab ->
tab.Content()
}

View file

@ -16,7 +16,7 @@ import ua.acclorite.book_story.presentation.navigator.NavigatorItem
import ua.acclorite.book_story.ui.navigator.LocalNavigator
@Composable
fun NavigationBar(tabs: List<NavigatorItem>) {
fun NavigationBar(tabs: List<NavigatorItem>, showLabels: Boolean) {
val navigator = LocalNavigator.current
val lastItem = navigator.lastItem.collectAsStateWithLifecycle()
@ -31,7 +31,8 @@ fun NavigationBar(tabs: List<NavigatorItem>) {
tabs.forEach { tab ->
NavigationBarItem(
item = tab,
isSelected = currentTab.value::class == tab.screen::class
isSelected = currentTab.value::class == tab.screen::class,
showLabel = showLabels
) {
navigator.push(tab.screen)
}

View file

@ -26,20 +26,23 @@ fun RowScope.NavigationBarItem(
modifier: Modifier = Modifier,
item: NavigatorItem,
isSelected: Boolean,
showLabel: Boolean,
onClick: () -> Unit
) {
NavigationBarItem(
label = {
Tooltip(
text = stringResource(id = item.tooltip),
padding = 64.dp
) {
StyledText(
text = stringResource(id = item.title),
maxLines = 1
)
label = if (showLabel) {
{
Tooltip(
text = stringResource(id = item.tooltip),
padding = 64.dp
) {
StyledText(
text = stringResource(id = item.title),
maxLines = 1
)
}
}
},
} else null,
selected = isSelected,
onClick = { onClick() },
icon = {

View file

@ -32,7 +32,7 @@ import ua.acclorite.book_story.presentation.navigator.NavigatorItem
import ua.acclorite.book_story.ui.navigator.LocalNavigator
@Composable
fun NavigationRail(tabs: List<NavigatorItem>) {
fun NavigationRail(tabs: List<NavigatorItem>, showLabels: Boolean) {
val navigator = LocalNavigator.current
val layoutDirection = LocalLayoutDirection.current
val lastItem = navigator.lastItem.collectAsStateWithLifecycle()
@ -69,7 +69,8 @@ fun NavigationRail(tabs: List<NavigatorItem>) {
tabs.forEach { tab ->
NavigationRailItem(
item = tab,
isSelected = currentTab.value::class == tab.screen::class
isSelected = currentTab.value::class == tab.screen::class,
showLabel = showLabels
) {
navigator.push(tab.screen)
}

View file

@ -25,20 +25,23 @@ fun NavigationRailItem(
modifier: Modifier = Modifier,
item: NavigatorItem,
isSelected: Boolean,
showLabel: Boolean,
onClick: () -> Unit
) {
NavigationRailItem(
label = {
Tooltip(
text = stringResource(id = item.tooltip),
padding = 48.dp
) {
StyledText(
text = stringResource(id = item.title),
maxLines = 1
)
label = if (showLabel) {
{
Tooltip(
text = stringResource(id = item.tooltip),
padding = 48.dp
) {
StyledText(
text = stringResource(id = item.title),
maxLines = 1
)
}
}
},
} else null,
selected = isSelected,
onClick = { onClick() },
icon = {

View file

@ -18,6 +18,7 @@ import ua.acclorite.book_story.ui.settings.appearance.theme_preferences.componen
import ua.acclorite.book_story.ui.settings.appearance.theme_preferences.components.AppThemeOption
import ua.acclorite.book_story.ui.settings.appearance.theme_preferences.components.DarkThemeOption
import ua.acclorite.book_story.ui.settings.appearance.theme_preferences.components.PureDarkOption
import ua.acclorite.book_story.ui.settings.appearance.theme_preferences.components.ShowNavigationLabelsOption
import ua.acclorite.book_story.ui.settings.appearance.theme_preferences.components.ThemeContrastOption
import ua.acclorite.book_story.ui.settings.components.SettingsSubcategory
@ -52,5 +53,9 @@ fun LazyListScope.ThemePreferencesSubcategory(
item {
AbsoluteDarkOption()
}
item {
ShowNavigationLabelsOption()
}
}
}

View file

@ -0,0 +1,27 @@
/*
* Book's Story free and open-source Material You eBook reader.
* Copyright (C) 2024-2025 Acclorite
* SPDX-License-Identifier: GPL-3.0-only
*/
package ua.acclorite.book_story.ui.settings.appearance.theme_preferences.components
import androidx.compose.runtime.Composable
import androidx.compose.ui.res.stringResource
import ua.acclorite.book_story.R
import ua.acclorite.book_story.ui.common.components.settings.SwitchWithTitle
import ua.acclorite.book_story.ui.common.helpers.LocalSettings
@Composable
fun ShowNavigationLabelsOption() {
val settings = LocalSettings.current
SwitchWithTitle(
selected = settings.showNavigationLabels.value,
title = stringResource(id = R.string.show_navigation_labels_option),
description = stringResource(id = R.string.show_navigation_labels_option_desc),
onClick = {
settings.showNavigationLabels.update(!settings.showNavigationLabels.lastValue)
}
)
}

View file

@ -164,6 +164,8 @@
<string name="app_theme_option">Тема застосунка</string>
<string name="double_press_exit_option">Подвійне натискання для виходу</string>
<string name="double_press_exit_option_desc">Натисніть назад двічі, щоб вийти з застосунку</string>
<string name="show_navigation_labels_option">Показувати заголовки навігації</string>
<string name="show_navigation_labels_option_desc">Показувати заголовки навігаційної панелі під іконками</string>
<!-- Reader -->
<string name="font_family_option">Сімейство шрифтів</string>

View file

@ -186,6 +186,8 @@
<string name="app_theme_option">App theme</string>
<string name="double_press_exit_option">Double back press to exit</string>
<string name="double_press_exit_option_desc">Press back twice to exit the app</string>
<string name="show_navigation_labels_option">Show navigation labels</string>
<string name="show_navigation_labels_option_desc">Show navigation bar labels under icons</string>
<!-- Reader -->
<string name="font_family_option">Font family</string>