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