Skip to content

Commit b04e701

Browse files
committed
Make settings dialog occupy only as much width as necessary
1 parent 71c45a6 commit b04e701

1 file changed

Lines changed: 37 additions & 36 deletions

File tree

app/src/main/java/ru/spbu/depnav/ui/dialog/SettingsDialog.kt

Lines changed: 37 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,16 @@ package ru.spbu.depnav.ui.dialog
2121
import androidx.annotation.StringRes
2222
import androidx.compose.foundation.layout.Arrangement
2323
import androidx.compose.foundation.layout.Column
24+
import androidx.compose.foundation.layout.IntrinsicSize
2425
import androidx.compose.foundation.layout.Row
2526
import androidx.compose.foundation.layout.fillMaxWidth
2627
import androidx.compose.foundation.layout.height
2728
import androidx.compose.foundation.layout.padding
28-
import androidx.compose.foundation.lazy.LazyColumn
29+
import androidx.compose.foundation.layout.width
30+
import androidx.compose.foundation.rememberScrollState
2931
import androidx.compose.foundation.selection.selectable
3032
import androidx.compose.foundation.selection.selectableGroup
33+
import androidx.compose.foundation.verticalScroll
3134
import androidx.compose.material3.AlertDialog
3235
import androidx.compose.material3.MaterialTheme
3336
import androidx.compose.material3.RadioButton
@@ -63,47 +66,45 @@ fun SettingsDialog(prefs: PreferencesManager, onDismiss: () -> Unit) {
6366
},
6467
title = { Text(stringResource(R.string.settings)) },
6568
text = {
66-
LazyColumn(
67-
modifier = Modifier.padding(
68-
horizontal = HORIZONTAL_PADDING,
69-
vertical = HORIZONTAL_PADDING / 2
70-
),
69+
Column(
70+
modifier = Modifier
71+
.verticalScroll(rememberScrollState())
72+
.padding(
73+
horizontal = HORIZONTAL_PADDING,
74+
vertical = HORIZONTAL_PADDING / 2
75+
),
7176
verticalArrangement = Arrangement.spacedBy(DEFAULT_PADDING)
7277
) {
73-
item { GroupTitle(stringResource(R.string.theme)) }
78+
GroupTitle(stringResource(R.string.theme))
7479

75-
item {
76-
val themeMode by prefs.themeModeFlow.collectAsStateWithLifecycle()
77-
78-
RadioOption(
79-
options = listOf(
80-
R.string.light_theme,
81-
R.string.dark_theme,
82-
R.string.system_theme
83-
).map { id -> StringWithId(stringResource(id), id) },
84-
selected = themeMode.titleId.let { id ->
85-
StringWithId(stringResource(id), id)
86-
},
87-
onSelected = { (_, id) ->
88-
val selectedMode = ThemeMode.fromTitleId(id)
89-
checkNotNull(selectedMode) { "Unknown theme mode selected (id $id)" }
90-
prefs.updateThemeMode(selectedMode)
91-
}
92-
)
93-
}
80+
val themeMode by prefs.themeModeFlow.collectAsStateWithLifecycle()
81+
RadioOption(
82+
options = listOf(
83+
R.string.light_theme,
84+
R.string.dark_theme,
85+
R.string.system_theme
86+
).map { id -> StringWithId(stringResource(id), id) },
87+
selected = themeMode.titleId.let { id ->
88+
StringWithId(stringResource(id), id)
89+
},
90+
onSelected = { (_, id) ->
91+
val selectedMode = ThemeMode.fromTitleId(id)
92+
checkNotNull(selectedMode) { "Unknown theme mode selected (id $id)" }
93+
prefs.updateThemeMode(selectedMode)
94+
}
95+
)
9496

95-
item { GroupTitle(stringResource(R.string.map)) }
97+
GroupTitle(stringResource(R.string.map))
9698

97-
item {
98-
val enableRotation by prefs.enableRotationFlow.collectAsStateWithLifecycle()
99-
SwitchOption(
100-
title = stringResource(R.string.rotation_gesture),
101-
checked = enableRotation,
102-
onChecked = prefs::updateEnableRotation
103-
)
104-
}
99+
val enableRotation by prefs.enableRotationFlow.collectAsStateWithLifecycle()
100+
SwitchOption(
101+
title = stringResource(R.string.rotation_gesture),
102+
checked = enableRotation,
103+
onChecked = prefs::updateEnableRotation
104+
)
105105
}
106-
}
106+
},
107+
modifier = Modifier.width(IntrinsicSize.Max)
107108
)
108109
}
109110

0 commit comments

Comments
 (0)