ui: add "clear results" action to Benchmark screen
This commit is contained in:
parent
49df3aea9a
commit
bbf0420bac
|
|
@ -271,6 +271,11 @@ fun AppContent(
|
|||
),
|
||||
bottomBarConfig = BottomBarConfig.Benchmark(
|
||||
engineIdle = !engineState.isUninterruptible,
|
||||
onShare = {
|
||||
benchmarkResults.lastOrNull()?.let {
|
||||
handleScaffoldEvent(ScaffoldEvent.ShareText(it.text))
|
||||
}
|
||||
},
|
||||
onRerun = {
|
||||
if (engineState.isUninterruptible) {
|
||||
handleScaffoldEvent(ScaffoldEvent.ShowSnackbar(
|
||||
|
|
@ -281,11 +286,7 @@ fun AppContent(
|
|||
benchmarkViewModel.runBenchmark()
|
||||
}
|
||||
},
|
||||
onShare = {
|
||||
benchmarkResults.lastOrNull()?.let {
|
||||
handleScaffoldEvent(ScaffoldEvent.ShareText(it.text))
|
||||
}
|
||||
},
|
||||
onClear = benchmarkViewModel::clearResults,
|
||||
showModelCard = showModelCard,
|
||||
onToggleModelCard = benchmarkViewModel::toggleModelCard,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -105,8 +105,9 @@ fun AppScaffold(
|
|||
is BottomBarConfig.Benchmark -> {
|
||||
BenchmarkBottomBar(
|
||||
engineIdle = config.engineIdle,
|
||||
onRerun = config.onRerun,
|
||||
onShare = config.onShare,
|
||||
onRerun = config.onRerun,
|
||||
onClear = config.onClear,
|
||||
showModelCard = config.showModelCard,
|
||||
onToggleModelCard = config.onToggleModelCard,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import androidx.compose.animation.scaleIn
|
|||
import androidx.compose.animation.scaleOut
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.filled.Badge
|
||||
import androidx.compose.material.icons.filled.ClearAll
|
||||
import androidx.compose.material.icons.filled.Replay
|
||||
import androidx.compose.material.icons.filled.Share
|
||||
import androidx.compose.material.icons.outlined.Badge
|
||||
|
|
@ -20,8 +21,9 @@ import androidx.compose.runtime.Composable
|
|||
@Composable
|
||||
fun BenchmarkBottomBar(
|
||||
engineIdle: Boolean,
|
||||
onRerun: () -> Unit,
|
||||
onShare: () -> Unit,
|
||||
onRerun: () -> Unit,
|
||||
onClear: () -> Unit,
|
||||
showModelCard: Boolean,
|
||||
onToggleModelCard: (Boolean) -> Unit,
|
||||
) {
|
||||
|
|
@ -37,6 +39,13 @@ fun BenchmarkBottomBar(
|
|||
)
|
||||
}
|
||||
|
||||
IconButton(onClick = onClear) {
|
||||
Icon(
|
||||
imageVector = Icons.Default.ClearAll,
|
||||
contentDescription = "Clear benchmark results"
|
||||
)
|
||||
}
|
||||
|
||||
IconButton(onClick = { onToggleModelCard(!showModelCard) } ) {
|
||||
Icon(
|
||||
imageVector = if (showModelCard) Icons.Default.Badge else Icons.Outlined.Badge,
|
||||
|
|
|
|||
|
|
@ -87,8 +87,9 @@ sealed class BottomBarConfig {
|
|||
|
||||
data class Benchmark(
|
||||
val engineIdle: Boolean,
|
||||
val onRerun: () -> Unit,
|
||||
val onShare: () -> Unit,
|
||||
val onRerun: () -> Unit,
|
||||
val onClear: () -> Unit,
|
||||
val showModelCard: Boolean,
|
||||
val onToggleModelCard: (Boolean) -> Unit,
|
||||
) : BottomBarConfig()
|
||||
|
|
|
|||
|
|
@ -67,6 +67,12 @@ class BenchmarkViewModel @Inject constructor(
|
|||
}
|
||||
return true
|
||||
}
|
||||
|
||||
override suspend fun performCleanup() = clearResults()
|
||||
|
||||
fun clearResults() {
|
||||
_benchmarkResults.value = emptyList()
|
||||
}
|
||||
}
|
||||
|
||||
data class BenchmarkResult(
|
||||
|
|
|
|||
Loading…
Reference in New Issue