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>( val doublePressExit = setting<Boolean, Boolean>(
key = booleanPreferencesKey("double_press_exit"), default = false key = booleanPreferencesKey("double_press_exit"), default = false
) )
val showNavigationLabels = setting<Boolean, Boolean>(
key = booleanPreferencesKey("show_navigation_labels"), default = true
)
/* ------ Reader ----------------------------- */ /* ------ Reader ----------------------------- */
val fontFamily = setting<FontWithName, String>( val fontFamily = setting<FontWithName, String>(

View file

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

View file

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

View file

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

View file

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

View file

@ -25,10 +25,12 @@ fun NavigationRailItem(
modifier: Modifier = Modifier, modifier: Modifier = Modifier,
item: NavigatorItem, item: NavigatorItem,
isSelected: Boolean, isSelected: Boolean,
showLabel: Boolean,
onClick: () -> Unit onClick: () -> Unit
) { ) {
NavigationRailItem( NavigationRailItem(
label = { label = if (showLabel) {
{
Tooltip( Tooltip(
text = stringResource(id = item.tooltip), text = stringResource(id = item.tooltip),
padding = 48.dp padding = 48.dp
@ -38,7 +40,8 @@ fun NavigationRailItem(
maxLines = 1 maxLines = 1
) )
} }
}, }
} else null,
selected = isSelected, selected = isSelected,
onClick = { onClick() }, onClick = { onClick() },
icon = { 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.AppThemeOption
import ua.acclorite.book_story.ui.settings.appearance.theme_preferences.components.DarkThemeOption 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.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.appearance.theme_preferences.components.ThemeContrastOption
import ua.acclorite.book_story.ui.settings.components.SettingsSubcategory import ua.acclorite.book_story.ui.settings.components.SettingsSubcategory
@ -52,5 +53,9 @@ fun LazyListScope.ThemePreferencesSubcategory(
item { item {
AbsoluteDarkOption() 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="app_theme_option">Тема застосунка</string>
<string name="double_press_exit_option">Подвійне натискання для виходу</string> <string name="double_press_exit_option">Подвійне натискання для виходу</string>
<string name="double_press_exit_option_desc">Натисніть назад двічі, щоб вийти з застосунку</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 --> <!-- Reader -->
<string name="font_family_option">Сімейство шрифтів</string> <string name="font_family_option">Сімейство шрифтів</string>

View file

@ -186,6 +186,8 @@
<string name="app_theme_option">App theme</string> <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">Double back press to exit</string>
<string name="double_press_exit_option_desc">Press back twice to exit the app</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 --> <!-- Reader -->
<string name="font_family_option">Font family</string> <string name="font_family_option">Font family</string>