mirror of
https://github.com/atsunatsu/Look4Sat.git
synced 2026-10-02 03:15:37 +00:00
feat(settings): LoTW dialog — hint rewritten without Wavelog, confirm button is now Sync, remove separate sync button
This commit is contained in:
1 parent
2eb6d6cd5b
commit
de6ade025c
4 files changed
+41
-26
No files matched your search
+31
-5
@@ -210,12 +210,20 @@ fun RowScope.NextPassRow(pass: OrbitalPass, modifier: Modifier = Modifier, isUtc
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun CardButton(onClick: () -> Unit, text: String, modifier: Modifier = Modifier) {
|
fun CardButton(
|
||||||
|
onClick: () -> Unit,
|
||||||
|
text: String,
|
||||||
|
modifier: Modifier = Modifier,
|
||||||
|
isEnabled: Boolean = true
|
||||||
|
) {
|
||||||
ElevatedButton(
|
ElevatedButton(
|
||||||
onClick = onClick,
|
onClick = onClick,
|
||||||
|
enabled = isEnabled,
|
||||||
colors = ButtonDefaults.buttonColors(
|
colors = ButtonDefaults.buttonColors(
|
||||||
containerColor = MaterialTheme.colorScheme.surfaceVariant,
|
containerColor = MaterialTheme.colorScheme.surfaceVariant,
|
||||||
contentColor = MaterialTheme.colorScheme.onSurfaceVariant
|
contentColor = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||||
|
disabledContainerColor = MaterialTheme.colorScheme.surfaceVariant,
|
||||||
|
disabledContentColor = MaterialTheme.colorScheme.onSurfaceVariant.copy(alpha = 0.4f)
|
||||||
),
|
),
|
||||||
shape = MaterialTheme.shapes.small,
|
shape = MaterialTheme.shapes.small,
|
||||||
modifier = modifier,
|
modifier = modifier,
|
||||||
@@ -316,9 +324,21 @@ fun InfoDialog(
|
|||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun SharedDialog(
|
fun SharedDialog(
|
||||||
title: String, onCancel: () -> Unit, onAccept: () -> Unit, content: @Composable () -> Unit
|
title: String,
|
||||||
|
onCancel: () -> Unit,
|
||||||
|
onAccept: () -> Unit,
|
||||||
|
acceptText: String? = null,
|
||||||
|
acceptEnabled: Boolean = true,
|
||||||
|
content: @Composable () -> Unit
|
||||||
) {
|
) {
|
||||||
SharedDialog(title = title, onDismissRequest = onCancel, onCancel = onCancel, onAccept = onAccept) { _ ->
|
SharedDialog(
|
||||||
|
title = title,
|
||||||
|
onDismissRequest = onCancel,
|
||||||
|
onCancel = onCancel,
|
||||||
|
onAccept = onAccept,
|
||||||
|
acceptText = acceptText,
|
||||||
|
acceptEnabled = acceptEnabled
|
||||||
|
) { _ ->
|
||||||
content()
|
content()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -329,6 +349,8 @@ fun SharedDialog(
|
|||||||
onDismissRequest: () -> Unit,
|
onDismissRequest: () -> Unit,
|
||||||
onCancel: (() -> Unit)? = null,
|
onCancel: (() -> Unit)? = null,
|
||||||
onAccept: (() -> Unit)? = null,
|
onAccept: (() -> Unit)? = null,
|
||||||
|
acceptText: String? = null,
|
||||||
|
acceptEnabled: Boolean = true,
|
||||||
titleFontSize: Int = 16,
|
titleFontSize: Int = 16,
|
||||||
titleTextAlign: TextAlign = if (onCancel != null && onAccept != null) TextAlign.Center else TextAlign.Start,
|
titleTextAlign: TextAlign = if (onCancel != null && onAccept != null) TextAlign.Center else TextAlign.Start,
|
||||||
content: @Composable (padding: Dp) -> Unit
|
content: @Composable (padding: Dp) -> Unit
|
||||||
@@ -356,7 +378,11 @@ fun SharedDialog(
|
|||||||
.padding(horizontal = if (onCancel != null && onAccept != null) padding else 0.dp)
|
.padding(horizontal = if (onCancel != null && onAccept != null) padding else 0.dp)
|
||||||
)
|
)
|
||||||
if (onAccept != null) {
|
if (onAccept != null) {
|
||||||
CardButton(onClick = onAccept, text = stringResource(R.string.btn_accept))
|
CardButton(
|
||||||
|
onClick = onAccept,
|
||||||
|
text = acceptText ?: stringResource(R.string.btn_accept),
|
||||||
|
isEnabled = acceptEnabled
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
content(padding)
|
content(padding)
|
||||||
|
|||||||
@@ -151,8 +151,8 @@
|
|||||||
<string name="prefs_lotw_title">LoTW 已确认网格</string>
|
<string name="prefs_lotw_title">LoTW 已确认网格</string>
|
||||||
<string name="prefs_lotw_callsign">LoTW 呼号</string>
|
<string name="prefs_lotw_callsign">LoTW 呼号</string>
|
||||||
<string name="prefs_lotw_password">LoTW 密码</string>
|
<string name="prefs_lotw_password">LoTW 密码</string>
|
||||||
<string name="prefs_lotw_hint">直接从 ARRL LoTW 拉取已确认 QSO 的网格并与 Wavelog 网格合并(当前 %1$d 个)。密码仅保存在手机本地。填好直接点同步,会自动保存并拉取。</string>
|
<string name="prefs_lotw_hint">直接从 ARRL LoTW 拉取该呼号已确认 QSO 的网格并覆盖本地已存集合(当前 %1$d 个)。密码仅保存在手机本地。点"同步"会自动保存凭据并拉取。</string>
|
||||||
<string name="prefs_lotw_sync">立即同步</string>
|
<string name="prefs_lotw_sync">同步</string>
|
||||||
<string name="prefs_lotw_syncing">同步中…</string>
|
<string name="prefs_lotw_syncing">同步中…</string>
|
||||||
<string name="prefs_lotw_configured">已从 LoTW 同步 — 共 %1$d 个网格</string>
|
<string name="prefs_lotw_configured">已从 LoTW 同步 — 共 %1$d 个网格</string>
|
||||||
<string name="prefs_lotw_not_configured">未配置 — 直接登录 ARRL LoTW 拉取已确认 QSO 的网格,无需自建服务器</string>
|
<string name="prefs_lotw_not_configured">未配置 — 直接登录 ARRL LoTW 拉取已确认 QSO 的网格,无需自建服务器</string>
|
||||||
|
|||||||
@@ -186,8 +186,8 @@
|
|||||||
<string name="prefs_lotw_title">LoTW confirmed grids</string>
|
<string name="prefs_lotw_title">LoTW confirmed grids</string>
|
||||||
<string name="prefs_lotw_callsign">LoTW callsign</string>
|
<string name="prefs_lotw_callsign">LoTW callsign</string>
|
||||||
<string name="prefs_lotw_password">LoTW password</string>
|
<string name="prefs_lotw_password">LoTW password</string>
|
||||||
<string name="prefs_lotw_hint">Fetch confirmed-QSO grids directly from ARRL LoTW and merge them with Wavelog grids (currently %1$d). The password is stored on this device only. Just tap Sync — credentials are saved automatically.</string>
|
<string name="prefs_lotw_hint">Fetch confirmed-QSO grids directly from ARRL LoTW for this callsign and replace the stored set (currently %1$d). The password is stored on this device only. Tapping Sync saves the credentials and fetches in one step.</string>
|
||||||
<string name="prefs_lotw_sync">Sync now</string>
|
<string name="prefs_lotw_sync">Sync</string>
|
||||||
<string name="prefs_lotw_syncing">Syncing…</string>
|
<string name="prefs_lotw_syncing">Syncing…</string>
|
||||||
<string name="prefs_lotw_configured">Synced from LoTW — %1$d grids total</string>
|
<string name="prefs_lotw_configured">Synced from LoTW — %1$d grids total</string>
|
||||||
<string name="prefs_lotw_not_configured">Not configured — pull confirmed grids directly from ARRL LoTW, no self-hosted server needed</string>
|
<string name="prefs_lotw_not_configured">Not configured — pull confirmed grids directly from ARRL LoTW, no self-hosted server needed</string>
|
||||||
|
|||||||
+6
-17
@@ -238,10 +238,13 @@ fun LoTWDialog(
|
|||||||
SharedDialog(
|
SharedDialog(
|
||||||
title = stringResource(R.string.prefs_lotw_title),
|
title = stringResource(R.string.prefs_lotw_title),
|
||||||
onCancel = dismiss,
|
onCancel = dismiss,
|
||||||
|
// The confirm button IS the sync action: saving credentials and
|
||||||
|
// fetching confirmed grids happen in one step.
|
||||||
onAccept = {
|
onAccept = {
|
||||||
onSave(com.rtbishop.look4sat.core.domain.model.LoTWSettings(call.value, pass.value))
|
onSync(com.rtbishop.look4sat.core.domain.model.LoTWSettings(call.value, pass.value))
|
||||||
dismiss()
|
},
|
||||||
}
|
acceptText = stringResource(if (isSyncing) R.string.prefs_lotw_syncing else R.string.prefs_lotw_sync),
|
||||||
|
acceptEnabled = !isSyncing
|
||||||
) {
|
) {
|
||||||
OutlinedTextField(
|
OutlinedTextField(
|
||||||
value = call.value,
|
value = call.value,
|
||||||
@@ -273,20 +276,6 @@ fun LoTWDialog(
|
|||||||
modifier = Modifier.padding(horizontal = LocalSpacing.current.large)
|
modifier = Modifier.padding(horizontal = LocalSpacing.current.large)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
// Sync uses the values typed in the fields directly — saving and syncing
|
|
||||||
// happen in one step, no need to close and reopen the dialog.
|
|
||||||
Row(
|
|
||||||
horizontalArrangement = Arrangement.End,
|
|
||||||
modifier = Modifier.fillMaxWidth().padding(horizontal = LocalSpacing.current.large)
|
|
||||||
) {
|
|
||||||
TextButton(
|
|
||||||
onClick = { onSync(com.rtbishop.look4sat.core.domain.model.LoTWSettings(call.value, pass.value)) },
|
|
||||||
enabled = !isSyncing
|
|
||||||
) {
|
|
||||||
Text(text = if (isSyncing) stringResource(R.string.prefs_lotw_syncing)
|
|
||||||
else stringResource(R.string.prefs_lotw_sync))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Spacer(modifier = Modifier.height(0.dp))
|
Spacer(modifier = Modifier.height(0.dp))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user