94 lines
3.4 KiB
Markdown
94 lines
3.4 KiB
Markdown
# Feature 4: Status Screen
|
|
|
|
## Context
|
|
The status screen is the default view when the user clicks the tray icon. It gives a quick overview of backup health and provides shortcuts to key actions.
|
|
|
|
## Dependencies
|
|
- **Depends on**: Feature 0 (config), Feature 1 (screen routing), Feature 3 (SchedulerState, BackupHistory)
|
|
- **Depended on by**: Feature 5 (Restore — navigated to from status screen)
|
|
|
|
## Implementation Steps
|
|
|
|
### Step 1: Create the StatusViewModel
|
|
**Files to create:**
|
|
- `composeApp/src/jvmMain/kotlin/com/rukira/wowbackup/ui/status/StatusViewModel.kt`
|
|
|
|
Collects state from:
|
|
- `BackupScheduler.state` (StateFlow) — last backup, next backup, running status, progress, WoW status
|
|
- `ConfigManager.config` (StateFlow) — to check if configured
|
|
- `BackupHistory.listBackups()` — for backup count summary
|
|
|
|
Exposes a single `StatusUiState`:
|
|
```kotlin
|
|
data class StatusUiState(
|
|
val isConfigured: Boolean,
|
|
val lastBackupTime: String?, // human-readable relative time ("2 hours ago")
|
|
val lastBackupStatus: String?, // "Success" or "Failed: <reason>"
|
|
val nextBackupTime: String?, // "Today at 03:00" or "Tomorrow at 03:00"
|
|
val isWoWRunning: Boolean,
|
|
val forceBackupEnabled: Boolean,
|
|
val isBackupRunning: Boolean,
|
|
val backupProgress: BackupProgress?,
|
|
val totalBackups: Int,
|
|
)
|
|
```
|
|
|
|
### Step 2: Build the StatusScreen composable
|
|
**Files to create:**
|
|
- `composeApp/src/jvmMain/kotlin/com/rukira/wowbackup/ui/status/StatusScreen.kt`
|
|
|
|
Layout (Material3 Card-based):
|
|
|
|
#### Missing Config Warning (if !isConfigured)
|
|
- Warning banner: "Configuration incomplete. Set up WoW Backup to get started."
|
|
- "Open Settings" button
|
|
|
|
#### Last Backup Card
|
|
- Icon + "Last backup: 2 hours ago" (or "Never" if no backups)
|
|
- Status badge: green "Success" / red "Failed: reason"
|
|
|
|
#### Next Backup Card
|
|
- "Next backup: Today at 03:00"
|
|
- If WoW is running: yellow indicator "WoW is running" + note about force backup status
|
|
|
|
#### Backup Progress (if running)
|
|
- `LinearProgressIndicator` with file count ("142 / 350 files")
|
|
- Current file name (truncated)
|
|
|
|
#### Action Buttons Row
|
|
- **Backup Now** — triggers immediate backup (disabled if already running)
|
|
- **Open Backup Folder** — opens backup directory in OS file manager
|
|
- **Settings** — navigates to config screen
|
|
- **Restore** — navigates to restore screen
|
|
|
|
### Step 3: "Open folder" utility
|
|
**Files to create:**
|
|
- `composeApp/src/jvmMain/kotlin/com/rukira/wowbackup/platform/DesktopActions.kt`
|
|
|
|
```kotlin
|
|
object DesktopActions {
|
|
fun openFolder(path: File) {
|
|
Desktop.getDesktop().open(path)
|
|
}
|
|
}
|
|
```
|
|
|
|
Uses `java.awt.Desktop.open()` — works cross-platform.
|
|
|
|
### Step 4: Wire into App.kt routing
|
|
**Files to modify:**
|
|
- `composeApp/src/jvmMain/kotlin/com/rukira/wowbackup/App.kt`
|
|
|
|
Replace status placeholder with `StatusScreen(viewModel, onNavigateToConfig, onNavigateToRestore)`.
|
|
|
|
## Verification
|
|
1. Status screen shows "Never backed up" on first run
|
|
2. After a successful backup, shows correct time and "Success" status
|
|
3. After a failed backup, shows failure reason in red
|
|
4. While backup is running, progress bar and file count update live
|
|
5. "Backup Now" triggers immediate backup
|
|
6. "Open Backup Folder" opens the correct directory in Finder/Explorer
|
|
7. "Settings" navigates to config screen
|
|
8. "Restore" navigates to restore screen
|
|
9. Missing config warning shows when config is incomplete
|
|
10. WoW running indicator updates in real-time
|