Reenabled option to change lists spacing

This commit is contained in:
Abdelilah El Aissaoui 2024-08-20 20:56:39 +02:00
parent 635dfbbaed
commit dfe9ebb4f0
No known key found for this signature in database
GPG Key ID: 7587FC860F594869
3 changed files with 20 additions and 21 deletions

View File

@ -164,12 +164,12 @@ class AppSettingsRepository @Inject constructor() {
var linesHeightType: LinesHeightType var linesHeightType: LinesHeightType
get() { 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 { return try {
LinesHeightType.fromInt(lineHeightTypeValue) LinesHeightType.fromInt(lineHeightTypeValue)
} catch (ex: Exception) { } catch (ex: Exception) {
ex.printStackTrace() ex.printStackTrace()
LinesHeightType.NORMAL LinesHeightType.SPACED
} }
} }
set(value) { set(value) {

View File

@ -12,7 +12,7 @@ import com.jetpackduba.gitnuro.ui.dropdowns.DropDownOption
private val defaultAppTheme: ColorsScheme = darkBlueTheme private val defaultAppTheme: ColorsScheme = darkBlueTheme
private var appTheme: ColorsScheme = defaultAppTheme private var appTheme: ColorsScheme = defaultAppTheme
internal val LocalLinesHeight = compositionLocalOf { normalLineHeight } internal val LocalLinesHeight = compositionLocalOf { spacedLineHeight }
class LinesHeight internal constructor( class LinesHeight internal constructor(
val fileHeight: Dp, val fileHeight: Dp,
@ -20,9 +20,9 @@ class LinesHeight internal constructor(
val sidePanelItemHeight: Dp, val sidePanelItemHeight: Dp,
) )
val normalLineHeight = LinesHeight( val spacedLineHeight = LinesHeight(
fileHeight = 40.dp, fileHeight = 38.dp,
logCommitHeight = 36.dp, logCommitHeight = 38.dp,
sidePanelItemHeight = 36.dp sidePanelItemHeight = 36.dp
) )
@ -33,7 +33,7 @@ val compactLineHeight = LinesHeight(
) )
enum class LinesHeightType(val value: Int) { enum class LinesHeightType(val value: Int) {
NORMAL(0), SPACED(0),
COMPACT(1); COMPACT(1);
companion object { companion object {
@ -44,9 +44,9 @@ enum class LinesHeightType(val value: Int) {
@Composable @Composable
fun AppTheme( fun AppTheme(
selectedTheme: Theme = Theme.DARK, selectedTheme: Theme = Theme.DARK,
linesHeightType: LinesHeightType = LinesHeightType.NORMAL, linesHeightType: LinesHeightType = LinesHeightType.COMPACT,
customTheme: ColorsScheme?, customTheme: ColorsScheme?,
content: @Composable() () -> Unit content: @Composable () -> Unit
) { ) {
val theme = when (selectedTheme) { val theme = when (selectedTheme) {
Theme.LIGHT -> lightTheme Theme.LIGHT -> lightTheme
@ -56,7 +56,7 @@ fun AppTheme(
} }
val lineHeight = when (linesHeightType) { val lineHeight = when (linesHeightType) {
LinesHeightType.NORMAL -> normalLineHeight LinesHeightType.SPACED -> spacedLineHeight
LinesHeightType.COMPACT -> compactLineHeight LinesHeightType.COMPACT -> compactLineHeight
} }

View File

@ -428,7 +428,7 @@ private fun Layout(settingsViewModel: SettingsViewModel) {
} }
val linesHeightTypesList = listOf( val linesHeightTypesList = listOf(
DropDownOption(LinesHeightType.NORMAL, "Normal"), DropDownOption(LinesHeightType.SPACED, "Spaced"),
DropDownOption(LinesHeightType.COMPACT, "Compact"), DropDownOption(LinesHeightType.COMPACT, "Compact"),
) )
@ -469,16 +469,15 @@ private fun Appearance(settingsViewModel: SettingsViewModel) {
) )
} }
// TODO Uncomment this once UI/UX has been implemented properly SettingDropDown(
// SettingDropDown( title = "Lists spacing (Beta)",
// title = "Lists spacing (Beta)", subtitle = "Spacing around lists items",
// subtitle = "Spacing around lists items", dropDownOptions = linesHeightTypesList,
// dropDownOptions = linesHeightTypesList, currentOption = linesHeightTypesList.first { it.value == currentLinesHeightType },
// currentOption = linesHeightTypesList.first { it.value == currentLinesHeightType }, onOptionSelected = { dropDown ->
// onOptionSelected = { dropDown -> settingsViewModel.linesHeightType = dropDown.value
// settingsViewModel.linesHeightType = dropDown.value }
// } )
// )
val density = LocalDensity.current.density val density = LocalDensity.current.density
var options by remember { var options by remember {