Skip to content

Commit

Permalink
Merge branch 'fix-list-animation-for-split-tunneling-droid-321'
Browse files Browse the repository at this point in the history
  • Loading branch information
Pururun committed Sep 12, 2023
2 parents af5a3b7 + 1f68473 commit fa73320
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 15 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 @@ -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

0 comments on commit fa73320

Please sign in to comment.