feat: add 'current exact position' button for station A
Removed the automatic posA=stationPos override. Added a button '当前精确位置' below the grid input that fills in the exact station position from settings (lat/lon + grid). Users can now freely edit the position fields and use the button when they want the exact position.
This commit is contained in:
1 parent
571145838d
commit
81ae8772d2
2 files changed
+16
-13
No files matched your search
@@ -129,6 +129,7 @@ fun MutualScreen(
|
||||
onStationBLon = viewModel::onStationBLon,
|
||||
onStationBGrid = viewModel::onStationBGrid,
|
||||
onStationBMinElev = viewModel::onStationBMinElev,
|
||||
onUseCurrentPosition = viewModel::onUseCurrentPosition,
|
||||
onHoursAhead = viewModel::onHoursAhead,
|
||||
onClearError = viewModel::clearError
|
||||
)
|
||||
@@ -150,6 +151,7 @@ private fun MutualContent(
|
||||
onStationBLon: (String) -> Unit,
|
||||
onStationBGrid: (String) -> Unit,
|
||||
onStationBMinElev: (Double) -> Unit,
|
||||
onUseCurrentPosition: () -> Unit,
|
||||
onHoursAhead: (Int) -> Unit,
|
||||
onClearError: () -> Unit
|
||||
) {
|
||||
@@ -224,6 +226,12 @@ private fun MutualContent(
|
||||
singleLine = true,
|
||||
modifier = Modifier.fillMaxWidth()
|
||||
)
|
||||
OutlinedButton(
|
||||
onClick = onUseCurrentPosition,
|
||||
modifier = Modifier.align(Alignment.End)
|
||||
) {
|
||||
Text("当前精确位置", style = MaterialTheme.typography.bodySmall)
|
||||
}
|
||||
Text(
|
||||
text = "最小仰角:${state.stationAMinElev.toInt()}°",
|
||||
style = MaterialTheme.typography.bodySmall
|
||||
|
||||
+8
-13
@@ -139,6 +139,14 @@ class MutualViewModel(
|
||||
}
|
||||
fun onStationAMinElev(value: Double) = _uiState.update { it.copy(stationAMinElev = value) }
|
||||
fun onStationBMinElev(value: Double) = _uiState.update { it.copy(stationBMinElev = value) }
|
||||
fun onUseCurrentPosition() {
|
||||
val pos = settingsRepo.stationPosition.value
|
||||
_uiState.update { it.copy(
|
||||
stationALat = "%.4f".format(pos.latitude),
|
||||
stationALon = "%.4f".format(pos.longitude),
|
||||
stationAGrid = latLonToGrid(pos.latitude, pos.longitude)
|
||||
) }
|
||||
}
|
||||
fun onHoursAhead(value: Int) = _uiState.update { it.copy(hoursAhead = value) }
|
||||
fun onSelectPass(index: Int) = _uiState.update { it.copy(selectedPassIndex = index) }
|
||||
|
||||
@@ -154,19 +162,6 @@ class MutualViewModel(
|
||||
return
|
||||
}
|
||||
|
||||
// When station A's grid matches the pre-filled grid (user hasn't changed it),
|
||||
// use the exact station position from settings so the pass times and elevation
|
||||
// curves are consistent with the main Passes page.
|
||||
val stationPos = settingsRepo.stationPosition.value
|
||||
val prefillGrid = latLonToGrid(stationPos.latitude, stationPos.longitude)
|
||||
if (state.stationAGrid.trim().uppercase() == prefillGrid) {
|
||||
posA = stationPos
|
||||
}
|
||||
// Same for station B: if its grid matches the user's station, use exact position.
|
||||
if (state.stationBGrid.trim().uppercase() == prefillGrid) {
|
||||
posB = stationPos
|
||||
}
|
||||
|
||||
val satellites = satelliteRepo.satellites.value
|
||||
if (satellites.isEmpty()) {
|
||||
_uiState.update { it.copy(errorMessage = "没有卫星数据,请先在卫星列表中选择卫星") }
|
||||
|
||||
Reference in new issue
Block a user