Skip to content

Commit

Permalink
Fix row animations
Browse files Browse the repository at this point in the history
  • Loading branch information
Rawa committed Sep 12, 2023
1 parent 70da6e8 commit 28c2cb7
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,17 +65,12 @@ internal fun BaseCell(
minHeight: Dp = Dimens.cellHeight,
testTag: String = ""
) {
val rowModifier =
Modifier.let {
if (isRowEnabled) {
it.clickable { onCellClicked() }
} else it
}
Row(
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.Start,
modifier =
rowModifier
modifier
.clickable(isRowEnabled, onClick = onCellClicked)
.wrapContentHeight()
.defaultMinSize(minHeight = minHeight)
.fillMaxWidth()
Expand All @@ -89,7 +84,7 @@ internal fun BaseCell(

Spacer(modifier = Modifier.weight(1.0f))

Column(modifier = modifier.wrapContentWidth().wrapContentHeight()) { bodyView() }
Column(modifier = Modifier.wrapContentWidth().wrapContentHeight()) { bodyView() }
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,12 @@ fun NormalSwitchComposeCell(
fun HeaderSwitchComposeCell(
title: String,
isToggled: Boolean,
modifier: Modifier = Modifier,
startPadding: Dp = Dimens.cellStartPadding,
isEnabled: Boolean = true,
background: Color = MaterialTheme.colorScheme.primary,
onCellClicked: (Boolean) -> Unit = {},
onInfoClicked: (() -> Unit)? = null
onInfoClicked: (() -> Unit)? = null,
) {
SwitchComposeCell(
titleView = { BaseCellTitle(title = title, style = MaterialTheme.typography.titleMedium) },
Expand All @@ -88,7 +89,8 @@ fun HeaderSwitchComposeCell(
isEnabled = isEnabled,
background = background,
onCellClicked = onCellClicked,
onInfoClicked = onInfoClicked
onInfoClicked = onInfoClicked,
modifier,
)
}

Expand All @@ -100,9 +102,11 @@ private fun SwitchComposeCell(
isEnabled: Boolean,
background: Color,
onCellClicked: (Boolean) -> Unit,
onInfoClicked: (() -> Unit)?
onInfoClicked: (() -> Unit)?,
modifier: Modifier = Modifier,
) {
BaseCell(
modifier = modifier,
title = titleView,
isRowEnabled = isEnabled,
bodyView = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,10 @@ fun SplitTunnelingScreen(
}
}
item(key = CommonContentKey.SPACER, contentType = ContentType.SPACER) {
Spacer(modifier = Modifier.height(Dimens.mediumPadding))
Spacer(
modifier =
Modifier.animateItemPlacement().height(Dimens.mediumPadding)
)
}
}

Expand All @@ -194,14 +197,16 @@ fun SplitTunnelingScreen(
HeaderSwitchComposeCell(
title = stringResource(id = R.string.show_system_apps),
isToggled = uiState.showSystemApps,
onCellClicked = { newValue -> onShowSystemAppsClick(newValue) }
onCellClicked = { newValue -> onShowSystemAppsClick(newValue) },
modifier = Modifier.animateItemPlacement()
)
}
itemWithDivider(
key = SplitTunnelingContentKey.INCLUDED_APPLICATIONS,
contentType = ContentType.HEADER
) {
BaseCell(
modifier = Modifier.animateItemPlacement(),
title = {
Text(
text = stringResource(id = R.string.all_applications),
Expand Down

0 comments on commit 28c2cb7

Please sign in to comment.