Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Changed
- **Live Charge Screen**: Screen now automatically closes and navigates back when charging stops, as the completed charge is immediately available in the charges list

## [1.1.0-beta3] - 2026-02-12

### Fixed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableLongStateOf
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import kotlinx.coroutines.delay
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
Expand Down Expand Up @@ -91,6 +93,27 @@ fun CurrentChargeScreen(
}
}

// Auto-close screen when charging stops
var previouslyCharging by remember { mutableStateOf<Boolean?>(null) }
LaunchedEffect(uiState.isNotCharging, uiState.isLoading) {
// Skip if still loading initial data
if (uiState.isLoading) return@LaunchedEffect

// Initialize previous state on first load
if (previouslyCharging == null) {
previouslyCharging = !uiState.isNotCharging
return@LaunchedEffect
}

// Detect transition: was charging → now not charging
if (previouslyCharging == true && uiState.isNotCharging) {
onNavigateBack()
}

// Update previous state for next check
previouslyCharging = !uiState.isNotCharging
}

Scaffold(
topBar = {
TopAppBar(
Expand Down
Loading