From dfe9ebb4f0cc2afc0bcc7b63270ccec885202575 Mon Sep 17 00:00:00 2001 From: Abdelilah El Aissaoui Date: Tue, 20 Aug 2024 20:56:39 +0200 Subject: [PATCH] Reenabled option to change lists spacing --- .../repositories/AppSettingsRepository.kt | 4 ++-- .../com/jetpackduba/gitnuro/theme/Theme.kt | 16 +++++++------- .../ui/dialogs/settings/SettingsDialog.kt | 21 +++++++++---------- 3 files changed, 20 insertions(+), 21 deletions(-) diff --git a/src/main/kotlin/com/jetpackduba/gitnuro/repositories/AppSettingsRepository.kt b/src/main/kotlin/com/jetpackduba/gitnuro/repositories/AppSettingsRepository.kt index 13ac172..01f6792 100644 --- a/src/main/kotlin/com/jetpackduba/gitnuro/repositories/AppSettingsRepository.kt +++ b/src/main/kotlin/com/jetpackduba/gitnuro/repositories/AppSettingsRepository.kt @@ -164,12 +164,12 @@ class AppSettingsRepository @Inject constructor() { var linesHeightType: LinesHeightType get() { - val lineHeightTypeValue = preferences.getInt(PREF_LINE_HEIGHT_TYPE, LinesHeightType.NORMAL.value) + val lineHeightTypeValue = preferences.getInt(PREF_LINE_HEIGHT_TYPE, LinesHeightType.SPACED.value) return try { LinesHeightType.fromInt(lineHeightTypeValue) } catch (ex: Exception) { ex.printStackTrace() - LinesHeightType.NORMAL + LinesHeightType.SPACED } } set(value) { diff --git a/src/main/kotlin/com/jetpackduba/gitnuro/theme/Theme.kt b/src/main/kotlin/com/jetpackduba/gitnuro/theme/Theme.kt index 6e78e1c..ada9e72 100644 --- a/src/main/kotlin/com/jetpackduba/gitnuro/theme/Theme.kt +++ b/src/main/kotlin/com/jetpackduba/gitnuro/theme/Theme.kt @@ -12,7 +12,7 @@ import com.jetpackduba.gitnuro.ui.dropdowns.DropDownOption private val defaultAppTheme: ColorsScheme = darkBlueTheme private var appTheme: ColorsScheme = defaultAppTheme -internal val LocalLinesHeight = compositionLocalOf { normalLineHeight } +internal val LocalLinesHeight = compositionLocalOf { spacedLineHeight } class LinesHeight internal constructor( val fileHeight: Dp, @@ -20,9 +20,9 @@ class LinesHeight internal constructor( val sidePanelItemHeight: Dp, ) -val normalLineHeight = LinesHeight( - fileHeight = 40.dp, - logCommitHeight = 36.dp, +val spacedLineHeight = LinesHeight( + fileHeight = 38.dp, + logCommitHeight = 38.dp, sidePanelItemHeight = 36.dp ) @@ -33,7 +33,7 @@ val compactLineHeight = LinesHeight( ) enum class LinesHeightType(val value: Int) { - NORMAL(0), + SPACED(0), COMPACT(1); companion object { @@ -44,9 +44,9 @@ enum class LinesHeightType(val value: Int) { @Composable fun AppTheme( selectedTheme: Theme = Theme.DARK, - linesHeightType: LinesHeightType = LinesHeightType.NORMAL, + linesHeightType: LinesHeightType = LinesHeightType.COMPACT, customTheme: ColorsScheme?, - content: @Composable() () -> Unit + content: @Composable () -> Unit ) { val theme = when (selectedTheme) { Theme.LIGHT -> lightTheme @@ -56,7 +56,7 @@ fun AppTheme( } val lineHeight = when (linesHeightType) { - LinesHeightType.NORMAL -> normalLineHeight + LinesHeightType.SPACED -> spacedLineHeight LinesHeightType.COMPACT -> compactLineHeight } diff --git a/src/main/kotlin/com/jetpackduba/gitnuro/ui/dialogs/settings/SettingsDialog.kt b/src/main/kotlin/com/jetpackduba/gitnuro/ui/dialogs/settings/SettingsDialog.kt index 929cf44..ee58f5e 100644 --- a/src/main/kotlin/com/jetpackduba/gitnuro/ui/dialogs/settings/SettingsDialog.kt +++ b/src/main/kotlin/com/jetpackduba/gitnuro/ui/dialogs/settings/SettingsDialog.kt @@ -428,7 +428,7 @@ private fun Layout(settingsViewModel: SettingsViewModel) { } val linesHeightTypesList = listOf( - DropDownOption(LinesHeightType.NORMAL, "Normal"), + DropDownOption(LinesHeightType.SPACED, "Spaced"), DropDownOption(LinesHeightType.COMPACT, "Compact"), ) @@ -469,16 +469,15 @@ private fun Appearance(settingsViewModel: SettingsViewModel) { ) } - // TODO Uncomment this once UI/UX has been implemented properly -// SettingDropDown( -// title = "Lists spacing (Beta)", -// subtitle = "Spacing around lists items", -// dropDownOptions = linesHeightTypesList, -// currentOption = linesHeightTypesList.first { it.value == currentLinesHeightType }, -// onOptionSelected = { dropDown -> -// settingsViewModel.linesHeightType = dropDown.value -// } -// ) + SettingDropDown( + title = "Lists spacing (Beta)", + subtitle = "Spacing around lists items", + dropDownOptions = linesHeightTypesList, + currentOption = linesHeightTypesList.first { it.value == currentLinesHeightType }, + onOptionSelected = { dropDown -> + settingsViewModel.linesHeightType = dropDown.value + } + ) val density = LocalDensity.current.density var options by remember {