summaryrefslogtreecommitdiffhomepage
path: root/android/app/src
diff options
context:
space:
mode:
authorJonatan Rhodin <jonatan.rhodin@mullvad.net>2023-10-30 14:58:48 +0100
committerJonatan Rhodin <jonatan.rhodin@mullvad.net>2023-10-30 14:58:48 +0100
commit4b4166cc232910fea18b9fb35aca88b2d3dcfc43 (patch)
treed1660f7cdca3e42280771b9086cbfa64c0bdea7a /android/app/src
parent4f40522551c003c07204e1142ffdc33398abb711 (diff)
parentd074de3d211c11b3929cacec4a6078a5e321249c (diff)
downloadmullvadvpn-4b4166cc232910fea18b9fb35aca88b2d3dcfc43.tar.xz
mullvadvpn-4b4166cc232910fea18b9fb35aca88b2d3dcfc43.zip
Merge branch 'select-location-ui-fixes-droid-454'
Diffstat (limited to 'android/app/src')
-rw-r--r--android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/cell/RelayLocationCell.kt7
-rw-r--r--android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/component/Chevron.kt31
-rw-r--r--android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/component/LocationInfo.kt15
-rw-r--r--android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/component/VerticalDivider.kt28
4 files changed, 56 insertions, 25 deletions
diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/cell/RelayLocationCell.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/cell/RelayLocationCell.kt
index 75888a8579..b9390cd4ef 100644
--- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/cell/RelayLocationCell.kt
+++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/cell/RelayLocationCell.kt
@@ -29,6 +29,7 @@ import androidx.compose.ui.res.painterResource
import androidx.compose.ui.tooling.preview.Preview
import net.mullvad.mullvadvpn.R
import net.mullvad.mullvadvpn.compose.component.ChevronView
+import net.mullvad.mullvadvpn.compose.component.VerticalDivider
import net.mullvad.mullvadvpn.lib.theme.AppTheme
import net.mullvad.mullvadvpn.lib.theme.Dimens
import net.mullvad.mullvadvpn.lib.theme.color.Alpha40
@@ -255,12 +256,16 @@ fun RelayLocationCell(
)
}
if (relay.hasChildren) {
+ VerticalDivider(
+ color = MaterialTheme.colorScheme.background,
+ modifier = Modifier.padding(vertical = Dimens.verticalDividerPadding)
+ )
ChevronView(
isExpanded = expanded.value,
modifier =
Modifier.fillMaxHeight()
.clickable { expanded.value = !expanded.value }
- .padding(horizontal = Dimens.mediumPadding)
+ .padding(horizontal = Dimens.largePadding)
.align(Alignment.CenterVertically)
)
}
diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/component/Chevron.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/component/Chevron.kt
index c1c01dc6c1..cd41c3e2a0 100644
--- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/component/Chevron.kt
+++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/component/Chevron.kt
@@ -1,38 +1,39 @@
package net.mullvad.mullvadvpn.compose.component
-import androidx.compose.animation.core.Animatable
import androidx.compose.animation.core.LinearEasing
-import androidx.compose.animation.core.tween
-import androidx.compose.foundation.Image
+import androidx.compose.animation.core.TweenSpec
+import androidx.compose.animation.core.animateFloatAsState
+import androidx.compose.material3.Icon
+import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.Composable
-import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.rotate
-import androidx.compose.ui.graphics.ColorFilter
+import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.painterResource
import net.mullvad.mullvadvpn.R
+import net.mullvad.mullvadvpn.lib.theme.color.AlphaChevron
@Composable
fun ChevronView(
modifier: Modifier = Modifier,
- colorFilter: ColorFilter? = null,
+ color: Color = MaterialTheme.colorScheme.onBackground.copy(alpha = AlphaChevron),
isExpanded: Boolean
) {
val resourceId = R.drawable.icon_chevron
- val rotation = remember { Animatable(90f + if (isExpanded) 180f else 0f) }
- LaunchedEffect(isExpanded) {
- rotation.animateTo(
- targetValue = 90f + if (isExpanded) 180f else 0f,
- animationSpec = tween(100, easing = LinearEasing)
+ val degree = remember(isExpanded) { if (isExpanded) 270f else 90f }
+ val animatedRotation =
+ animateFloatAsState(
+ targetValue = degree,
+ label = "",
+ animationSpec = TweenSpec(100, easing = LinearEasing)
)
- }
- Image(
+ Icon(
painterResource(id = resourceId),
contentDescription = null,
- colorFilter = colorFilter,
- modifier = modifier.rotate(rotation.value),
+ tint = color,
+ modifier = modifier.rotate(animatedRotation.value),
)
}
diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/component/LocationInfo.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/component/LocationInfo.kt
index b8f48c4e1a..cd96bae05d 100644
--- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/component/LocationInfo.kt
+++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/component/LocationInfo.kt
@@ -10,7 +10,6 @@ import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.alpha
import androidx.compose.ui.graphics.Color
-import androidx.compose.ui.graphics.ColorFilter
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.tooling.preview.Preview
@@ -72,14 +71,12 @@ fun LocationInfo(
)
ChevronView(
isExpanded = isExpanded,
- colorFilter =
- ColorFilter.tint(
- if (isExpanded) {
- colorExpanded
- } else {
- colorCollapsed
- }
- ),
+ color =
+ if (isExpanded) {
+ colorExpanded
+ } else {
+ colorCollapsed
+ },
modifier = Modifier.padding(horizontal = Dimens.chevronMargin)
)
}
diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/component/VerticalDivider.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/component/VerticalDivider.kt
new file mode 100644
index 0000000000..d7e4709b5d
--- /dev/null
+++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/component/VerticalDivider.kt
@@ -0,0 +1,28 @@
+package net.mullvad.mullvadvpn.compose.component
+
+import androidx.compose.foundation.background
+import androidx.compose.foundation.layout.Box
+import androidx.compose.foundation.layout.fillMaxHeight
+import androidx.compose.foundation.layout.width
+import androidx.compose.material3.DividerDefaults
+import androidx.compose.runtime.Composable
+import androidx.compose.ui.Modifier
+import androidx.compose.ui.graphics.Color
+import androidx.compose.ui.platform.LocalDensity
+import androidx.compose.ui.unit.Dp
+import androidx.compose.ui.unit.dp
+
+@Composable
+fun VerticalDivider(
+ modifier: Modifier = Modifier,
+ thickness: Dp = DividerDefaults.Thickness,
+ color: Color = DividerDefaults.color,
+) {
+ val targetThickness =
+ if (thickness == Dp.Hairline) {
+ (1f / LocalDensity.current.density).dp
+ } else {
+ thickness
+ }
+ Box(modifier.fillMaxHeight().width(targetThickness).background(color = color))
+}