Modern Apps git

← Modern-Apps.git

astronomy: settings dialog -> full settings page

Commit
f5eb89f58ef8c03ce8ddd1ed7b52d9ea813e2981
Author
vayun-mathur <[email protected]>
When
2026-08-16 04:26 UTC (3 months ago)
Parents
5eba04c

Diff

astronomy/src/main/java/com/vayunmathur/astronomy/Navigation.kt
diff --git a/astronomy/src/main/java/com/vayunmathur/astronomy/Navigation.kt b/astronomy/src/main/java/com/vayunmathur/astronomy/Navigation.ktindex eddc7f130c..7fdc86e26b 100644--- a/astronomy/src/main/java/com/vayunmathur/astronomy/Navigation.kt+++ b/astronomy/src/main/java/com/vayunmathur/astronomy/Navigation.kt@@ -21,7 +21,7 @@ fun Navigation(viewModel: AstronomyViewModel) {         entry<Route.SkyMap>(metadata = ListPage()) { SkyMapPage(backStack, viewModel) }         entry<Route.ObjectDetail>(metadata = DialogPage()) { route -> ObjectDetailPage(backStack, viewModel, route.id) }         entry<Route.Search>(metadata = ListPage()) { SearchPage(backStack, viewModel) }-        entry<Route.Settings>(metadata = DialogPage()) { SettingsPage(backStack, viewModel) }+        entry<Route.Settings>(metadata = ListPage()) { SettingsPage(backStack, viewModel) }         entry<Route.HistoryDatePicker>(metadata = DialogPage()) { route ->             DatePickerDialog(backStack, "AstroHistoryDatePicker", route.initialDate)         }
astronomy/src/main/java/com/vayunmathur/astronomy/ui/SettingsPage.kt
diff --git a/astronomy/src/main/java/com/vayunmathur/astronomy/ui/SettingsPage.kt b/astronomy/src/main/java/com/vayunmathur/astronomy/ui/SettingsPage.ktindex a480e7d037..2d37887f3f 100644--- a/astronomy/src/main/java/com/vayunmathur/astronomy/ui/SettingsPage.kt+++ b/astronomy/src/main/java/com/vayunmathur/astronomy/ui/SettingsPage.kt@@ -4,7 +4,6 @@ import androidx.compose.foundation.layout.* import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.verticalScroll import androidx.compose.runtime.*-import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.unit.dp import com.vayunmathur.astronomy.R@@ -61,62 +60,64 @@ fun SettingsScreen(backStack: NavBackStack<Route>, state: SettingsUiState, actio     var latText by remember(state.latDeg) { mutableStateOf(state.latDeg?.toString() ?: "") }     var lonText by remember(state.lonDeg) { mutableStateOf(state.lonDeg?.toString() ?: "") } -    Box(Modifier.fillMaxSize()) {-        Column(Modifier.fillMaxSize().statusBarsPadding().padding(top = 56.dp).verticalScroll(rememberScrollState()).padding(16.dp), verticalArrangement = Arrangement.spacedBy(16.dp)) {-            Text(stringResource(R.string.display), style = MaterialTheme.typography.titleMedium)-            Row(Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.SpaceBetween, verticalAlignment = androidx.compose.ui.Alignment.CenterVertically) {-                Text(stringResource(R.string.constellations))-                var expanded by remember { mutableStateOf(false) }-                Box {-                    TextButton(onClick = { expanded = true }) {-                        Text(-                            when (state.constellationMode) {-                                ConstellationMode.OFF -> stringResource(R.string.off)-                                ConstellationMode.LINES -> stringResource(R.string.lines_only)-                                ConstellationMode.LINES_AND_ART -> stringResource(R.string.lines_art)-                            }-                        )-                    }-                    DropdownMenu(expanded = expanded, onDismissRequest = { expanded = false }) {-                        DropdownMenuItem(text = { Text(stringResource(R.string.off)) }, onClick = { actions.setShowConstellations(ConstellationMode.OFF); expanded = false })-                        DropdownMenuItem(text = { Text(stringResource(R.string.lines_only)) }, onClick = { actions.setShowConstellations(ConstellationMode.LINES); expanded = false })-                        DropdownMenuItem(text = { Text(stringResource(R.string.lines_art)) }, onClick = { actions.setShowConstellations(ConstellationMode.LINES_AND_ART); expanded = false })-                    }-                }+    val offLabel = stringResource(R.string.off)+    val linesLabel = stringResource(R.string.lines_only)+    val linesArtLabel = stringResource(R.string.lines_art)++    AppScaffold(title = stringResource(R.string.settings), onNavigateBack = { backStack.pop() }) { padding ->+        Column(Modifier.fillMaxSize().padding(padding).verticalScroll(rememberScrollState())) {+            SettingsSection(title = stringResource(R.string.display)) {+                SettingsSelectRow(+                    title = stringResource(R.string.constellations),+                    selected = state.constellationMode,+                    options = listOf(ConstellationMode.OFF, ConstellationMode.LINES, ConstellationMode.LINES_AND_ART),+                    label = {+                        when (it) {+                            ConstellationMode.OFF -> offLabel+                            ConstellationMode.LINES -> linesLabel+                            ConstellationMode.LINES_AND_ART -> linesArtLabel+                        }+                    },+                    onSelect = { actions.setShowConstellations(it) },+                )+                SettingsSwitchRow(title = stringResource(R.string.coordinate_grid_whole_sphere), checked = state.showGrid, onCheckedChange = { actions.setShowGrid(it) })+                SettingsSwitchRow(title = stringResource(R.string.show_deep_sky), checked = state.showDeepSky, onCheckedChange = { actions.setShowDeepSky(it) })+                SettingsSwitchRow(title = stringResource(R.string.planets_sun_moon), checked = state.showPlanets, onCheckedChange = { actions.setShowPlanets(it) })+                SettingsSwitchRow(title = stringResource(R.string.show_below_horizon_all_sky), checked = state.showBelowHorizon, onCheckedChange = { actions.setShowBelowHorizon(it) })+                SettingsSwitchRow(title = stringResource(R.string.night_mode), checked = state.nightMode, onCheckedChange = { actions.setNightMode(it) })             }-            Row(Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.SpaceBetween) { Text(stringResource(R.string.coordinate_grid_whole_sphere)); Switch(checked = state.showGrid, onCheckedChange = { actions.setShowGrid(it) }) }-            Row(Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.SpaceBetween) { Text(stringResource(R.string.show_deep_sky)); Switch(checked = state.showDeepSky, onCheckedChange = { actions.setShowDeepSky(it) }) }-            Row(Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.SpaceBetween) { Text(stringResource(R.string.planets_sun_moon)); Switch(checked = state.showPlanets, onCheckedChange = { actions.setShowPlanets(it) }) }-            Row(Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.SpaceBetween) { Text(stringResource(R.string.show_below_horizon_all_sky)); Switch(checked = state.showBelowHorizon, onCheckedChange = { actions.setShowBelowHorizon(it) }) }-            Row(Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.SpaceBetween) { Text(stringResource(R.string.night_mode)); Switch(checked = state.nightMode, onCheckedChange = { actions.setNightMode(it) }) } -            HorizontalDivider()+            SettingsDivider() -            Text(stringResource(R.string.magnitude_limit, state.magLimit.format(1)), style = MaterialTheme.typography.bodyMedium)-            Slider(value = state.magLimit, onValueChange = { actions.setMagLimit(it) }, valueRange = 1f..7f)+            Column(Modifier.padding(horizontal = 16.dp, vertical = 8.dp), verticalArrangement = Arrangement.spacedBy(8.dp)) {+                Text(stringResource(R.string.magnitude_limit, state.magLimit.format(1)), style = MaterialTheme.typography.bodyMedium)+                Slider(value = state.magLimit, onValueChange = { actions.setMagLimit(it) }, valueRange = 1f..7f) -            Text(stringResource(R.string.fov, state.fovDeg.toInt()), style = MaterialTheme.typography.bodyMedium)-            Slider(value = state.fovDeg, onValueChange = { actions.setFov(it) }, valueRange = 10f..120f)+                Text(stringResource(R.string.fov, state.fovDeg.toInt()), style = MaterialTheme.typography.bodyMedium)+                Slider(value = state.fovDeg, onValueChange = { actions.setFov(it) }, valueRange = 10f..120f)+            } -            HorizontalDivider()-            Text(stringResource(R.string.location), style = MaterialTheme.typography.titleMedium)-            OutlinedTextField(value = latText, onValueChange = { latText = it }, label = { Text(stringResource(R.string.latitude_deg)) }, modifier = Modifier.fillMaxWidth())-            OutlinedTextField(value = lonText, onValueChange = { lonText = it }, label = { Text(stringResource(R.string.longitude_deg)) }, modifier = Modifier.fillMaxWidth())-            Button(onClick = {-                val lat = latText.toDoubleOrNull(); val lon = lonText.toDoubleOrNull()-                if (lat != null && lon != null) actions.setManualLocation(lat, lon)-            }) { Text(stringResource(R.string.save_location)) }-            Button(onClick = { actions.refreshLocation() }) { Text(stringResource(R.string.use_current_location)) }+            SettingsDivider() -            HorizontalDivider()-            Text(stringResource(R.string.notes_true_north_correction_via_geomagne), style = MaterialTheme.typography.labelSmall)-            Text(stringResource(R.string.catalog_stars_constellations_dso, state.starCount, state.constellationCount, state.deepSkyCount), style = MaterialTheme.typography.labelSmall)-        }+            SettingsSection(title = stringResource(R.string.location)) {+                Column(Modifier.padding(horizontal = 16.dp, vertical = 8.dp), verticalArrangement = Arrangement.spacedBy(8.dp)) {+                    OutlinedTextField(value = latText, onValueChange = { latText = it }, label = { Text(stringResource(R.string.latitude_deg)) }, modifier = Modifier.fillMaxWidth())+                    OutlinedTextField(value = lonText, onValueChange = { lonText = it }, label = { Text(stringResource(R.string.longitude_deg)) }, modifier = Modifier.fillMaxWidth())+                    Button(onClick = {+                        val lat = latText.toDoubleOrNull(); val lon = lonText.toDoubleOrNull()+                        if (lat != null && lon != null) actions.setManualLocation(lat, lon)+                    }) { Text(stringResource(R.string.save_location)) }+                    Button(onClick = { actions.refreshLocation() }) { Text(stringResource(R.string.use_current_location)) }+                }+            }++            SettingsDivider() -        TopAppBarOverlay(-            modifier = Modifier.align(Alignment.TopCenter),-            onNavigateBack = { backStack.pop() },-        )+            Column(Modifier.padding(horizontal = 16.dp, vertical = 8.dp), verticalArrangement = Arrangement.spacedBy(8.dp)) {+                Text(stringResource(R.string.notes_true_north_correction_via_geomagne), style = MaterialTheme.typography.labelSmall)+                Text(stringResource(R.string.catalog_stars_constellations_dso, state.starCount, state.constellationCount, state.deepSkyCount), style = MaterialTheme.typography.labelSmall)+            }+        }     } } 
astronomy/src/main/res/values/strings.xml
diff --git a/astronomy/src/main/res/values/strings.xml b/astronomy/src/main/res/values/strings.xmlindex af8a4c0a8f..b9842c4b40 100644--- a/astronomy/src/main/res/values/strings.xml+++ b/astronomy/src/main/res/values/strings.xml@@ -47,6 +47,8 @@     <string name="search_stars_planets_messier">Search stars, planets, Messier</string>      <!-- SettingsPage -->+    <!-- SettingsPage: TopAppBar title -->+    <string name="settings">Settings</string>     <!-- SettingsPage: slider label showing current magnitude limit. %1$s = numeric limit e.g. 4.5 -->     <string name="magnitude_limit">Magnitude limit: <xliff:g id="limit" example="4.5">%1$s</xliff:g></string>     <!-- SettingsPage: text field label for manual longitude input in degrees -->