Skip to content

Commit cd2816f

Browse files
committed
Update TableScreen.kt to wrap the MeasurementTypeFilterRow in an AnimatedVisibility block, controlled by the showTypeFilterRow setting.
1 parent b64610a commit cd2816f

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

  • android_app/app/src/main/java/com/health/openscale/ui/screen/table

android_app/app/src/main/java/com/health/openscale/ui/screen/table/TableScreen.kt

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import android.net.Uri
2121
import androidx.activity.compose.BackHandler
2222
import androidx.activity.compose.rememberLauncherForActivityResult
2323
import androidx.activity.result.contract.ActivityResultContracts
24+
import androidx.compose.animation.AnimatedVisibility
2425
import androidx.compose.foundation.background
2526
import androidx.compose.foundation.clickable
2627
import androidx.compose.foundation.horizontalScroll
@@ -104,6 +105,7 @@ import com.health.openscale.ui.screen.settings.BluetoothViewModel
104105
import com.health.openscale.ui.shared.SharedViewModel
105106
import com.health.openscale.ui.shared.TopBarAction
106107
import com.health.openscale.core.utils.LocaleUtils
108+
import com.health.openscale.ui.screen.components.SHOW_TYPE_FILTER_ROW_SUFFIX
107109
import kotlinx.coroutines.async
108110
import kotlinx.coroutines.awaitAll
109111
import kotlinx.coroutines.flow.filter
@@ -203,6 +205,9 @@ fun TableScreen(
203205
// ── Selection ─────────────────────────────────────────────────────────────
204206
var isInSelectionMode by rememberSaveable { mutableStateOf(false) }
205207
var selectedKeys by remember { mutableStateOf<Set<String>>(emptySet()) }
208+
val showTypeFilterRow by sharedViewModel
209+
.observeSetting("${SettingsPreferenceKeys.TABLE_SCREEN_CONTEXT}${SHOW_TYPE_FILTER_ROW_SUFFIX}", true)
210+
.collectAsState(initial = true)
206211

207212
fun toggleKey(key: String) {
208213
selectedKeys = if (key in selectedKeys) selectedKeys - key else selectedKeys + key
@@ -618,7 +623,6 @@ fun TableScreen(
618623

619624
val addMeasurementAction = rememberAddMeasurementActionButton(sharedViewModel, navController)
620625
val bluetoothAction = rememberBluetoothActionButton(bluetoothViewModel, sharedViewModel, navController)
621-
// FIX: also provide filter action in drill-down (was null before)
622626
val filterAction = if (!isDrillDown) provideFilterTopBarAction(
623627
sharedViewModel = sharedViewModel,
624628
screenContextName = SettingsPreferenceKeys.TABLE_SCREEN_CONTEXT,
@@ -665,7 +669,6 @@ fun TableScreen(
665669
actions.add(bluetoothAction)
666670
actions.add(addMeasurementAction)
667671
}
668-
// FIX: show selection mode button also in drill-down if there are items
669672
if (aggregatedItems.isNotEmpty()) {
670673
actions.add(TopBarAction(
671674
icon = Icons.Outlined.CheckBox,
@@ -678,7 +681,6 @@ fun TableScreen(
678681
}
679682
}
680683

681-
// FIX: BackHandler also active in drill-down when in selection mode
682684
if (isInSelectionMode) {
683685
BackHandler(enabled = true) {
684686
isInSelectionMode = false
@@ -700,7 +702,7 @@ fun TableScreen(
700702
val dateColumnHeader = stringResource(R.string.table_header_date)
701703

702704
Column(modifier = Modifier.fillMaxSize()) {
703-
if (!isDrillDown) {
705+
AnimatedVisibility(visible = !isDrillDown && showTypeFilterRow) {
704706
MeasurementTypeFilterRow(
705707
allMeasurementTypesProvider = { allAvailableTypesFromVM },
706708
selectedTypeIdsFlowProvider = { sharedViewModel.selectedTableTypeIds },
@@ -737,7 +739,6 @@ fun TableScreen(
737739
)
738740
HorizontalDivider()
739741
}
740-
741742
when {
742743
tableUiState is SharedViewModel.UiState.Loading -> {
743744
Box(Modifier.fillMaxSize(), contentAlignment = Alignment.Center) {

0 commit comments

Comments
 (0)