Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix list animations for split tunneling #5145

Merged
merged 2 commits into from
Sep 12, 2023
Merged
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
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 @@ -18,9 +18,11 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.ImageBitmap
import androidx.compose.ui.graphics.asImageBitmap
import androidx.compose.ui.graphics.compositeOver
import androidx.compose.ui.graphics.painter.BitmapPainter
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import net.mullvad.mullvadvpn.R
Expand All @@ -33,7 +35,10 @@ import org.koin.androidx.compose.get
@Composable
private fun PreviewTunnelingCell() {
AppTheme {
Column(modifier = Modifier.background(color = MaterialTheme.colorScheme.background)) {
Column(
modifier =
Modifier.background(color = MaterialTheme.colorScheme.background).padding(20.dp)
) {
SplitTunnelingCell(title = "Mullvad VPN", packageName = "", isSelected = false)
SplitTunnelingCell(title = "Mullvad VPN", packageName = "", isSelected = true)
}
Expand Down Expand Up @@ -63,7 +68,11 @@ fun SplitTunnelingCell(
.defaultMinSize(minHeight = Dimens.listItemHeightExtra)
.fillMaxWidth()
.padding(vertical = Dimens.listItemDivider)
.background(MaterialTheme.colorScheme.primaryContainer)
.background(
MaterialTheme.colorScheme.primaryContainer.compositeOver(
MaterialTheme.colorScheme.background
)
)
.clickable(onClick = onCellClicked)
) {
Image(
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
Loading