fix(firmware): auto-connect 시 Scan UI 조건부 숨김 (cloud-mvp d0e5ca7 이식)

target 설정된 상태 (auto-connect 성공) 에서는 Scan 버튼 · Devices 리스트 숨김.
target 없거나 IDLE/SCANNING phase 에서만 노출.

Fallback: 연결 없이 진입하거나 auto-connect 실패 시 기존 스캔 UI 유지.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
2026-08-03 15:44:13 +09:00
parent 33c4e94d07
commit 638b8e454c
@@ -233,16 +233,19 @@ fun DfuScreen(manager: DfuManager, modifier: Modifier = Modifier) {
} }
// ── Actions ─────────────────────────────────────────────────────────────────────── // ── Actions ───────────────────────────────────────────────────────────────────────
// 2026-08-03: auto-connect 로 대부분 target 즉시 설정됨.
// target 없는 경우 (fresh install · 새 기기) 에만 수동 Scan/Stop 노출.
val hasTarget = target != null
Row(horizontalArrangement = Arrangement.spacedBy(8.dp)) { Row(horizontalArrangement = Arrangement.spacedBy(8.dp)) {
// Keyed off the phase, not the scanner: the DFU re-scan also runs the scanner, and if (!hasTarget || phase == DfuPhase.IDLE || phase == DfuPhase.SCANNING) {
// stopping that one from here would abort the update. if (phase == DfuPhase.SCANNING) {
if (phase == DfuPhase.SCANNING) { OutlinedButton(onClick = { manager.stopScan() }) { Text("Stop") }
OutlinedButton(onClick = { manager.stopScan() }) { Text("Stop") } } else {
} else { OutlinedButton(
OutlinedButton( onClick = { manager.startScan() },
onClick = { manager.startScan() }, enabled = !manager.isBusy,
enabled = !manager.isBusy, ) { Text("Scan") }
) { Text("Scan") } }
} }
Button( Button(
@@ -261,31 +264,32 @@ fun DfuScreen(manager: DfuManager, modifier: Modifier = Modifier) {
} }
} }
// ── Discovered devices ──────────────────────────────────────────────────────────── // ── Discovered devices — target 없을 때만 (auto-connect 실패 · 첫 사용) ────────
Text( if (!hasTarget) {
"Devices (${manager.devices.size})", Text(
style = MaterialTheme.typography.labelLarge, "Devices (${manager.devices.size})",
) style = MaterialTheme.typography.labelLarge,
Card(modifier = Modifier.fillMaxWidth().heightIn(min = 80.dp, max = 220.dp)) { )
if (manager.devices.isEmpty()) { Card(modifier = Modifier.fillMaxWidth().heightIn(min = 80.dp, max = 220.dp)) {
Text( if (manager.devices.isEmpty()) {
when (phase) { Text(
DfuPhase.CONNECTED -> "Connected — disconnect to scan again." when (phase) {
DfuPhase.SCANNING -> "Scanning…" DfuPhase.SCANNING -> "Scanning…"
else -> "No devices yet — tap Scan." else -> "No devices yet — tap Scan."
}, },
modifier = Modifier.padding(12.dp), modifier = Modifier.padding(12.dp),
style = MaterialTheme.typography.bodySmall, style = MaterialTheme.typography.bodySmall,
) )
} else { } else {
LazyColumn { LazyColumn {
items(manager.devices, key = { it.address }) { device -> items(manager.devices, key = { it.address }) { device ->
DeviceRow( DeviceRow(
device = device, device = device,
enabled = !manager.isBusy, enabled = !manager.isBusy,
onClick = { manager.connect(device) }, onClick = { manager.connect(device) },
) )
HorizontalDivider() HorizontalDivider()
}
} }
} }
} }