mirror of
https://github.com/atsunatsu/Look4Sat.git
synced 2026-10-04 19:47:22 +00:00
Added minor tweaks to import components and strings
This commit is contained in:
1 parent
f6564c3c71
commit
13a79af27e
10 files changed
+67
-146
No files matched your search
@@ -212,8 +212,8 @@ fun CardButton(onClick: () -> Unit, text: String, modifier: Modifier = Modifier)
|
||||
containerColor = MaterialTheme.colorScheme.surfaceVariant,
|
||||
contentColor = MaterialTheme.colorScheme.onSurfaceVariant
|
||||
), shape = MaterialTheme.shapes.small, modifier = modifier,
|
||||
contentPadding = PaddingValues(horizontal = 12.dp)
|
||||
) { Text(text = text, fontSize = 16.sp) }
|
||||
contentPadding = PaddingValues(horizontal = 8.dp, vertical = 8.dp)
|
||||
) { Text(text = text, fontSize = 16.sp, textAlign = TextAlign.Center) }
|
||||
}
|
||||
|
||||
@Composable
|
||||
@@ -280,7 +280,7 @@ fun SharedDialog(
|
||||
) {
|
||||
Text(
|
||||
text = title,
|
||||
fontSize = 18.sp,
|
||||
fontSize = 16.sp,
|
||||
fontWeight = FontWeight.Medium,
|
||||
color = MaterialTheme.colorScheme.primary,
|
||||
modifier = Modifier.padding(start = padding, top = padding, end = padding)
|
||||
@@ -330,40 +330,6 @@ fun InfoDialog(title: String, text: String, onDismiss: () -> Unit) {
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun InfoDialog(
|
||||
title: String,
|
||||
onDismiss: () -> Unit,
|
||||
content: @Composable () -> Unit
|
||||
) {
|
||||
val padding = LocalSpacing.current.large
|
||||
|
||||
Dialog(onDismissRequest = onDismiss) {
|
||||
ElevatedCard {
|
||||
Column(
|
||||
horizontalAlignment = Alignment.CenterHorizontally,
|
||||
verticalArrangement = Arrangement.spacedBy(padding)
|
||||
) {
|
||||
Text(
|
||||
text = title,
|
||||
fontSize = 18.sp,
|
||||
fontWeight = FontWeight.Medium,
|
||||
color = MaterialTheme.colorScheme.primary,
|
||||
modifier = Modifier.padding(start = padding, top = padding, end = padding)
|
||||
)
|
||||
content()
|
||||
Row(modifier = Modifier.padding(start = padding, bottom = padding, end = padding)) {
|
||||
Spacer(modifier = Modifier.weight(1f))
|
||||
CardButton(
|
||||
onClick = onDismiss,
|
||||
text = stringResource(id = R.string.btn_cancel)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun hasEnoughHeight(): Boolean {
|
||||
return currentWindowAdaptiveInfo().windowSizeClass.isHeightAtLeastBreakpoint(480)
|
||||
|
||||
@@ -27,12 +27,13 @@ import androidx.compose.ui.tooling.preview.Preview
|
||||
import com.rtbishop.look4sat.R
|
||||
import com.rtbishop.look4sat.presentation.MainTheme
|
||||
import com.rtbishop.look4sat.presentation.common.SharedDialog
|
||||
import com.rtbishop.look4sat.presentation.common.InfoDialog
|
||||
import com.rtbishop.look4sat.presentation.common.CardButton
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.material3.Switch
|
||||
import androidx.compose.ui.unit.dp
|
||||
@@ -53,10 +54,16 @@ fun PositionDialog(lat: Double, lon: Double, dismiss: () -> Unit, save: (Double,
|
||||
val titleText = stringResource(id = R.string.prefs_station_title)
|
||||
val onAccept = { saveValues(latValue.value, lonValue.value, save).also { dismiss() } }
|
||||
SharedDialog(title = titleText, onCancel = dismiss, onAccept = onAccept) {
|
||||
Text(text = stringResource(id = R.string.prefs_station_lat_text))
|
||||
OutlinedTextField(value = latValue.value, onValueChange = { latValue.value = it })
|
||||
Text(text = stringResource(id = R.string.prefs_station_lon_text))
|
||||
OutlinedTextField(value = lonValue.value, onValueChange = { lonValue.value = it })
|
||||
OutlinedTextField(
|
||||
value = latValue.value,
|
||||
onValueChange = { latValue.value = it },
|
||||
label = { Text(text = stringResource(id = R.string.prefs_station_lat_text)) }
|
||||
)
|
||||
OutlinedTextField(
|
||||
value = lonValue.value,
|
||||
onValueChange = { lonValue.value = it },
|
||||
label = { Text(text = stringResource(id = R.string.prefs_station_lon_text)) }
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,55 +86,11 @@ fun LocatorDialog(qthLocator: String, dismiss: () -> Unit, save: (String) -> Uni
|
||||
val locator = rememberSaveable { mutableStateOf(qthLocator) }
|
||||
val onAccept = { save(locator.value).also { dismiss() } }
|
||||
SharedDialog(title = stringResource(R.string.prefs_locator_title), onCancel = dismiss, onAccept = onAccept) {
|
||||
Text(text = stringResource(id = R.string.prefs_locator_text))
|
||||
OutlinedTextField(value = locator.value, onValueChange = { locator.value = it })
|
||||
}
|
||||
}
|
||||
|
||||
@Preview(showBackground = true)
|
||||
@Composable
|
||||
private fun ImportDialogPreview() = MainTheme {
|
||||
ImportDialog(
|
||||
onImportTle = {},
|
||||
onImportTransceivers = {},
|
||||
onDismiss = {}
|
||||
)
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun ImportDialog(
|
||||
onImportTle: () -> Unit,
|
||||
onImportTransceivers: () -> Unit,
|
||||
onDismiss: () -> Unit
|
||||
) {
|
||||
val padding = LocalSpacing.current.large
|
||||
InfoDialog(
|
||||
title = stringResource(R.string.prefs_data_import),
|
||||
onDismiss = onDismiss
|
||||
) {
|
||||
Row(
|
||||
horizontalArrangement = Arrangement.spacedBy(12.dp),
|
||||
modifier = Modifier
|
||||
.padding(horizontal = padding)
|
||||
.fillMaxWidth()
|
||||
) {
|
||||
CardButton(
|
||||
onClick = {
|
||||
onImportTle()
|
||||
onDismiss()
|
||||
},
|
||||
text = "TLE",
|
||||
modifier = Modifier.weight(0.7f)
|
||||
)
|
||||
CardButton(
|
||||
onClick = {
|
||||
onImportTransceivers()
|
||||
onDismiss()
|
||||
},
|
||||
text = "Transceivers",
|
||||
modifier = Modifier.weight(1.3f)
|
||||
)
|
||||
}
|
||||
OutlinedTextField(
|
||||
value = locator.value,
|
||||
onValueChange = { locator.value = it },
|
||||
label = { Text(text = stringResource(id = R.string.prefs_locator_text)) }
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -140,7 +103,9 @@ private fun TransceiversDialogPreview() {
|
||||
useCustomTransceivers = true,
|
||||
tleUrl = "https://example.com/tle.txt",
|
||||
transceiversUrl = "https://example.com/tx.json",
|
||||
dismiss = {},
|
||||
onImportTle = {},
|
||||
onImportTransceivers = {},
|
||||
onDismiss = {},
|
||||
onSave = { _, _, _, _ -> }
|
||||
)
|
||||
}
|
||||
@@ -152,7 +117,9 @@ fun DataSourcesDialog(
|
||||
useCustomTransceivers: Boolean,
|
||||
tleUrl: String,
|
||||
transceiversUrl: String,
|
||||
dismiss: () -> Unit,
|
||||
onImportTle: () -> Unit,
|
||||
onImportTransceivers: () -> Unit,
|
||||
onDismiss: () -> Unit,
|
||||
onSave: (Boolean, Boolean, String, String) -> Unit
|
||||
) {
|
||||
val padding = LocalSpacing.current.large
|
||||
@@ -162,15 +129,34 @@ fun DataSourcesDialog(
|
||||
val urlTransceivers = rememberSaveable { mutableStateOf(transceiversUrl) }
|
||||
val onAccept = {
|
||||
onSave(isEnabledCustomTle.value, isEnabledCustomTransceivers.value, urlTle.value, urlTransceivers.value)
|
||||
dismiss()
|
||||
onDismiss()
|
||||
}
|
||||
val onCancel = { dismiss() }
|
||||
val onCancel = { onDismiss() }
|
||||
SharedDialog(
|
||||
title = stringResource(id = R.string.prefs_data_sources_title),
|
||||
onCancel = onCancel,
|
||||
onAccept = onAccept,
|
||||
) {
|
||||
Column(modifier = Modifier.padding(horizontal = padding)) {
|
||||
Row(horizontalArrangement = Arrangement.spacedBy(6.dp)) {
|
||||
CardButton(
|
||||
onClick = {
|
||||
onImportTle()
|
||||
onDismiss()
|
||||
},
|
||||
text = "TLE (3LE)\nR4UAB (.txt)",
|
||||
modifier = Modifier.weight(1f)
|
||||
)
|
||||
CardButton(
|
||||
onClick = {
|
||||
onImportTransceivers()
|
||||
onDismiss()
|
||||
},
|
||||
text = "Transceivers\nSatNOGS (.json)",
|
||||
modifier = Modifier.weight(1f)
|
||||
)
|
||||
}
|
||||
Spacer(modifier = Modifier.height(6.dp))
|
||||
Row(
|
||||
horizontalArrangement = Arrangement.SpaceBetween,
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
@@ -190,6 +176,7 @@ fun DataSourcesDialog(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
enabled = isEnabledCustomTle.value,
|
||||
)
|
||||
Spacer(modifier = Modifier.height(6.dp))
|
||||
Row(
|
||||
horizontalArrangement = Arrangement.SpaceBetween,
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
|
||||
@@ -150,7 +150,9 @@ private fun SettingsScreen(uiState: SettingsState) {
|
||||
useCustomTransceivers = uiState.dataSourcesSettings.useCustomTransceivers,
|
||||
tleUrl = uiState.dataSourcesSettings.tleUrl,
|
||||
transceiversUrl = uiState.dataSourcesSettings.transceiversUrl,
|
||||
dismiss = dismissDataSourcesDialog,
|
||||
onImportTle = { contentRequestForTle.launch("*/*") },
|
||||
onImportTransceivers = { contentRequestForTransceivers.launch("*/*") },
|
||||
onDismiss = dismissDataSourcesDialog,
|
||||
onSave = {
|
||||
useCustomTle, useCustomTransceivers, tleUrl, transceiversUrl ->
|
||||
if (!useCustomTle || tleUrl.isNotBlank()) {
|
||||
@@ -165,18 +167,6 @@ private fun SettingsScreen(uiState: SettingsState) {
|
||||
)
|
||||
}
|
||||
|
||||
// Import dialog
|
||||
val importDialogState = rememberSaveable { mutableStateOf(false) }
|
||||
val showImportDialog = { importDialogState.value = true }
|
||||
val dismissImportDialog = { importDialogState.value = false }
|
||||
if (importDialogState.value) {
|
||||
ImportDialog(
|
||||
onImportTle = { contentRequestForTle.launch("*/*") },
|
||||
onImportTransceivers = { contentRequestForTransceivers.launch("*/*") },
|
||||
onDismiss = dismissImportDialog
|
||||
)
|
||||
}
|
||||
|
||||
// Data settings
|
||||
val dataSettings = uiState.dataSettings
|
||||
val updateFromWeb: () -> Unit = { uiState.sendAction(SettingsAction.UpdateFromWeb) }
|
||||
@@ -248,7 +238,7 @@ private fun SettingsScreen(uiState: SettingsState) {
|
||||
item {
|
||||
LocationCard(posSettings, setGpsPos, showPosDialog, showLocDialog, dismissPos, uiState.sendSystemAction)
|
||||
}
|
||||
item { DataCard(dataSettings, updateFromWeb, clearAllData, showImportDialog, showDataSourcesDialog) }
|
||||
item { DataCard(dataSettings, updateFromWeb, clearAllData, showDataSourcesDialog) }
|
||||
item { NetworkOutputCard(rcSettings, setRotatorState, setRotatorAddress, setRotatorPort) }
|
||||
item { BluetoothOutputCard(rcSettings, setBluetoothState, setBluetoothAddress, setBluetoothFormat) }
|
||||
item { OtherCard(otherSettings, toggleUtc, toggleUpdate, toggleSweep, toggleSensor) }
|
||||
@@ -329,7 +319,7 @@ private fun LocationCard(
|
||||
@Composable
|
||||
private fun DataCardPreview() = MainTheme {
|
||||
val settings = DataSettings(true, 5000, 2500, 0L)
|
||||
DataCard(settings = settings, {}, {},{}) {}
|
||||
DataCard(settings = settings, {}, {}, {})
|
||||
}
|
||||
|
||||
@Composable
|
||||
@@ -337,7 +327,6 @@ private fun DataCard(
|
||||
settings: DataSettings,
|
||||
updateFromWeb: () -> Unit,
|
||||
clearAllData: () -> Unit,
|
||||
showImportDialog: () -> Unit,
|
||||
showDataSourcesDialog: () -> Unit
|
||||
) {
|
||||
ElevatedCard(modifier = Modifier.fillMaxWidth()) {
|
||||
@@ -360,17 +349,14 @@ private fun DataCard(
|
||||
Text(text = stringResource(R.string.prefs_data_radios, settings.radiosTotal))
|
||||
}
|
||||
Spacer(modifier = Modifier.height(1.dp))
|
||||
Row(
|
||||
horizontalArrangement = Arrangement.spacedBy(6.dp),
|
||||
modifier = Modifier.fillMaxWidth()
|
||||
) {
|
||||
Row(horizontalArrangement = Arrangement.spacedBy(6.dp)) {
|
||||
CardButton(
|
||||
onClick = updateFromWeb,
|
||||
text = stringResource(id = R.string.prefs_data_update),
|
||||
modifier = Modifier.weight(1f)
|
||||
)
|
||||
CardButton(
|
||||
onClick = showImportDialog,
|
||||
onClick = showDataSourcesDialog,
|
||||
text = stringResource(id = R.string.prefs_data_import),
|
||||
modifier = Modifier.weight(1f)
|
||||
)
|
||||
@@ -380,17 +366,6 @@ private fun DataCard(
|
||||
modifier = Modifier.weight(1f)
|
||||
)
|
||||
}
|
||||
Spacer(modifier = Modifier.height(6.dp))
|
||||
Row(
|
||||
horizontalArrangement = Arrangement.spacedBy(6.dp),
|
||||
modifier = Modifier.fillMaxWidth()
|
||||
) {
|
||||
CardButton(
|
||||
onClick = showDataSourcesDialog,
|
||||
text = stringResource(id = R.string.prefs_data_sources),
|
||||
modifier = Modifier.weight(1f)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -685,4 +660,3 @@ private fun BotCard(onClick: () -> Unit, resId: Int, text: String, modifier: Mod
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,7 +52,12 @@ class SettingsViewModel(
|
||||
|
||||
private val defaultPosSettings = PositionSettings(false, settingsRepo.stationPosition.value, 0)
|
||||
private val defaultDataSettings = DataSettings(false, 0, 0, 0L)
|
||||
private val defaultDataSourcesSettings = DataSourcesSettings(false, false, settingsRepo.dataSourcesSettings.value.tleUrl, settingsRepo.dataSourcesSettings.value.transceiversUrl)
|
||||
private val defaultDataSourcesSettings = DataSourcesSettings(
|
||||
useCustomTLE = false,
|
||||
useCustomTransceivers = false,
|
||||
tleUrl = settingsRepo.dataSourcesSettings.value.tleUrl,
|
||||
transceiversUrl = settingsRepo.dataSourcesSettings.value.transceiversUrl
|
||||
)
|
||||
private val _uiState = MutableStateFlow(
|
||||
SettingsState(
|
||||
nextTime = "00:00:00",
|
||||
|
||||
Reference in new issue
Block a user