diff options
Diffstat (limited to 'android/lib')
3 files changed, 26 insertions, 80 deletions
diff --git a/android/lib/ui/component/src/main/kotlin/net/mullvad/mullvadvpn/lib/ui/component/relaylist/CheckableRelayListItem.kt b/android/lib/ui/component/src/main/kotlin/net/mullvad/mullvadvpn/lib/ui/component/relaylist/CheckableRelayListItem.kt index d92e978d5c..1f25432cf4 100644 --- a/android/lib/ui/component/src/main/kotlin/net/mullvad/mullvadvpn/lib/ui/component/relaylist/CheckableRelayListItem.kt +++ b/android/lib/ui/component/src/main/kotlin/net/mullvad/mullvadvpn/lib/ui/component/relaylist/CheckableRelayListItem.kt @@ -59,17 +59,28 @@ fun CheckableRelayLocationCell( selected = false, content = { Row( - modifier = - Modifier.padding(start = item.depth * Dimens.mediumPadding) - .padding(Dimens.mediumPadding), + modifier = Modifier.padding(start = item.depth * Dimens.mediumPadding), verticalAlignment = Alignment.CenterVertically, ) { - Name(name = item.item.name, state = null, active = true) + Checkbox( + modifier = Modifier.padding(Dimens.smallPadding), + checked = item.checked, + onCheckedChange = onRelayCheckedChange, + ) + + Name( + modifier = + Modifier.padding( + top = Dimens.mediumPadding, + bottom = Dimens.mediumPadding, + end = Dimens.mediumPadding, + ), + name = item.item.name, + state = null, + active = true, + ) } }, - leadingContent = { - Checkbox(checked = item.checked, onCheckedChange = onRelayCheckedChange) - }, onClick = { onRelayCheckedChange(!item.checked) }, onLongClick = null, trailingContent = { diff --git a/android/lib/ui/component/src/main/kotlin/net/mullvad/mullvadvpn/lib/ui/component/relaylist/SelectableRelayListItem.kt b/android/lib/ui/component/src/main/kotlin/net/mullvad/mullvadvpn/lib/ui/component/relaylist/SelectableRelayListItem.kt index e66bfbd359..ca70bf8a90 100644 --- a/android/lib/ui/component/src/main/kotlin/net/mullvad/mullvadvpn/lib/ui/component/relaylist/SelectableRelayListItem.kt +++ b/android/lib/ui/component/src/main/kotlin/net/mullvad/mullvadvpn/lib/ui/component/relaylist/SelectableRelayListItem.kt @@ -154,10 +154,12 @@ internal fun Name( @Composable internal fun Int.toBackgroundColor(): Color = when (this) { - 0 -> MaterialTheme.colorScheme.surfaceContainerHighest - 1 -> MaterialTheme.colorScheme.surfaceContainerHigh - 2 -> MaterialTheme.colorScheme.surfaceContainerLow - else -> MaterialTheme.colorScheme.surfaceContainerLowest + // Using primary is a workaround to ensure enough contrast between lowest depth (3) and the + // background. + 0 -> MaterialTheme.colorScheme.primary + 1 -> MaterialTheme.colorScheme.surfaceContainerHighest + 2 -> MaterialTheme.colorScheme.surfaceContainerHigh + else -> MaterialTheme.colorScheme.surfaceContainerLow } @Composable diff --git a/android/lib/ui/designsystem/src/main/kotlin/net/mullvad/mullvadvpn/lib/ui/designsystem/RelayListItem.kt b/android/lib/ui/designsystem/src/main/kotlin/net/mullvad/mullvadvpn/lib/ui/designsystem/RelayListItem.kt index c2e9664a18..b410c8b267 100644 --- a/android/lib/ui/designsystem/src/main/kotlin/net/mullvad/mullvadvpn/lib/ui/designsystem/RelayListItem.kt +++ b/android/lib/ui/designsystem/src/main/kotlin/net/mullvad/mullvadvpn/lib/ui/designsystem/RelayListItem.kt @@ -50,7 +50,6 @@ fun RelayListItem( enabled: Boolean = true, onClick: (() -> Unit) = {}, onLongClick: (() -> Unit)? = {}, - leadingContent: @Composable (() -> Unit)? = null, content: @Composable () -> Unit, trailingContent: @Composable (() -> Unit)? = null, colors: RelayListItemColors = RelayListItemDefaults.colors(), @@ -67,22 +66,6 @@ fun RelayListItem( horizontalArrangement = Arrangement.spacedBy(RelayListTokens.listItemSpacer), verticalAlignment = Alignment.CenterVertically, ) { - if (leadingContent != null) { - Box( - Modifier.background(colors.containerColor) - .width(RelayListTokens.listItemButtonWidth) - .fillMaxHeight(), - contentAlignment = Alignment.Center, - ) { - ProvideContentColorTextStyle( - colors.leadingIconColor, - MaterialTheme.typography.titleMedium, - ) { - leadingContent() - } - } - } - Row( Modifier.weight(1f, fill = true) .background(colors.containerColor) @@ -125,7 +108,6 @@ fun RelayListItem( class RelayListItemColors( val containerColor: Color, val headlineColor: Color, - val leadingIconColor: Color, val trailingIconColor: Color, val selectedHeadlineColor: Color, val disabledHeadlineColor: Color, @@ -160,7 +142,6 @@ object RelayListItemDefaults { fun colors( containerColor: Color = MaterialTheme.colorScheme.surface, headlineColor: Color = MaterialTheme.colorScheme.onSurface, - leadingIconColor: Color = MaterialTheme.colorScheme.onSurface, trailingIconColor: Color = MaterialTheme.colorScheme.onSurface, selectedHeadlineColor: Color = MaterialTheme.colorScheme.tertiary, disabledHeadlineColor: Color = @@ -169,7 +150,6 @@ object RelayListItemDefaults { RelayListItemColors( containerColor = containerColor, headlineColor = headlineColor, - leadingIconColor = leadingIconColor, trailingIconColor = trailingIconColor, selectedHeadlineColor = selectedHeadlineColor, disabledHeadlineColor = disabledHeadlineColor, @@ -215,7 +195,7 @@ private fun PreviewLeadingRelayListItem() { overflow = TextOverflow.Ellipsis, ) }, - leadingContent = { + trailingContent = { Box( modifier = Modifier.fillMaxSize().clickable(onClick = { /* Handle click */ }), contentAlignment = Alignment.Center, @@ -246,54 +226,7 @@ private fun PreviewTrailingRelayListItem() { ) { Icon(imageVector = Icons.Default.Check, contentDescription = null) Spacer(Modifier.width(8.dp)) - Text( - "Hello world fsadhkuhfiuskahf iuhsadhuf sa", - maxLines = 1, - overflow = TextOverflow.Ellipsis, - ) - } - }, - trailingContent = { - Box( - modifier = Modifier.fillMaxSize().clickable(onClick = {}), - contentAlignment = Alignment.Center, - ) { - Icon( - modifier = Modifier.padding(16.dp), - imageVector = Icons.Default.Add, - contentDescription = null, - ) - } - }, - ) - } -} - -@Preview -@PreviewFontScale -@Composable -private fun PreviewLeadingAndTrailingRelayListItem() { - AppTheme { - RelayListItem( - modifier = Modifier.fillMaxWidth(), - content = { - Text( - "Hello world iuhsadhuf sa", - modifier = Modifier.clickable {}.padding(16.dp).fillMaxSize(), - maxLines = 1, - overflow = TextOverflow.Ellipsis, - ) - }, - leadingContent = { - Box( - modifier = Modifier.fillMaxSize().clickable(onClick = {}), - contentAlignment = Alignment.Center, - ) { - Icon( - modifier = Modifier.padding(16.dp), - imageVector = Icons.Default.KeyboardArrowDown, - contentDescription = null, - ) + Text("Sample Relay Item", maxLines = 1, overflow = TextOverflow.Ellipsis) } }, trailingContent = { |
