feat: option to hide navigation labels
* Added an option to hide navigation bar labels under icons
This commit is contained in:
parent
67befe9a8c
commit
bd7dbecce2
10 changed files with 83 additions and 26 deletions
|
|
@ -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>(
|
||||||
|
|
|
||||||
|
|
@ -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()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -26,20 +26,23 @@ 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(
|
{
|
||||||
text = stringResource(id = item.tooltip),
|
Tooltip(
|
||||||
padding = 64.dp
|
text = stringResource(id = item.tooltip),
|
||||||
) {
|
padding = 64.dp
|
||||||
StyledText(
|
) {
|
||||||
text = stringResource(id = item.title),
|
StyledText(
|
||||||
maxLines = 1
|
text = stringResource(id = item.title),
|
||||||
)
|
maxLines = 1
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
} else null,
|
||||||
selected = isSelected,
|
selected = isSelected,
|
||||||
onClick = { onClick() },
|
onClick = { onClick() },
|
||||||
icon = {
|
icon = {
|
||||||
|
|
|
||||||
|
|
@ -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)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -25,20 +25,23 @@ 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(
|
{
|
||||||
text = stringResource(id = item.tooltip),
|
Tooltip(
|
||||||
padding = 48.dp
|
text = stringResource(id = item.tooltip),
|
||||||
) {
|
padding = 48.dp
|
||||||
StyledText(
|
) {
|
||||||
text = stringResource(id = item.title),
|
StyledText(
|
||||||
maxLines = 1
|
text = stringResource(id = item.title),
|
||||||
)
|
maxLines = 1
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
} else null,
|
||||||
selected = isSelected,
|
selected = isSelected,
|
||||||
onClick = { onClick() },
|
onClick = { onClick() },
|
||||||
icon = {
|
icon = {
|
||||||
|
|
|
||||||
|
|
@ -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()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -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)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
@ -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>
|
||||||
|
|
|
||||||
|
|
@ -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>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue