Skip to content

Commit ea27eaf

Browse files
committed
add select finger animation and rounded corners to preview
1 parent cb3c624 commit ea27eaf

File tree

4 files changed

+61
-8
lines changed

4 files changed

+61
-8
lines changed

app/src/main/java/com/uravgcode/chooser/tutorial/presentation/page/ModePage.kt

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,20 @@ import androidx.compose.animation.graphics.ExperimentalAnimationGraphicsApi
55
import androidx.compose.animation.graphics.res.animatedVectorResource
66
import androidx.compose.animation.graphics.res.rememberAnimatedVectorPainter
77
import androidx.compose.animation.graphics.vector.AnimatedImageVector
8+
import androidx.compose.foundation.BorderStroke
89
import androidx.compose.foundation.Image
10+
import androidx.compose.foundation.background
911
import androidx.compose.foundation.layout.Arrangement
1012
import androidx.compose.foundation.layout.Column
1113
import androidx.compose.foundation.layout.Row
1214
import androidx.compose.foundation.layout.aspectRatio
1315
import androidx.compose.foundation.layout.fillMaxWidth
1416
import androidx.compose.foundation.layout.padding
1517
import androidx.compose.foundation.layout.size
18+
import androidx.compose.foundation.shape.RoundedCornerShape
19+
import androidx.compose.material3.Card
20+
import androidx.compose.material3.CardColors
21+
import androidx.compose.material3.CardDefaults
1622
import androidx.compose.material3.Icon
1723
import androidx.compose.material3.MaterialTheme
1824
import androidx.compose.material3.Text
@@ -24,6 +30,7 @@ import androidx.compose.runtime.remember
2430
import androidx.compose.runtime.setValue
2531
import androidx.compose.ui.Alignment
2632
import androidx.compose.ui.Modifier
33+
import androidx.compose.ui.graphics.Color
2734
import androidx.compose.ui.layout.ContentScale
2835
import androidx.compose.ui.res.painterResource
2936
import androidx.compose.ui.text.font.FontWeight
@@ -77,14 +84,29 @@ fun ModePage(
7784
textAlign = TextAlign.Center
7885
)
7986

80-
Image(
81-
painter = rememberAnimatedVectorPainter(image, atEnd),
82-
contentDescription = null,
83-
modifier = Modifier
84-
.fillMaxWidth(0.8f)
85-
.aspectRatio(1f),
86-
contentScale = ContentScale.Crop
87-
)
87+
Card(
88+
modifier = Modifier.padding(8.dp),
89+
shape = RoundedCornerShape(24.dp),
90+
colors = CardColors(
91+
containerColor = Color.Black,
92+
contentColor = Color.White,
93+
disabledContainerColor = Color.Black,
94+
disabledContentColor = Color.White
95+
),
96+
border = BorderStroke(
97+
width = 2.dp,
98+
color = MaterialTheme.colorScheme.outlineVariant
99+
)
100+
) {
101+
Image(
102+
painter = rememberAnimatedVectorPainter(image, atEnd),
103+
contentDescription = null,
104+
modifier = Modifier
105+
.fillMaxWidth()
106+
.aspectRatio(1f),
107+
contentScale = ContentScale.Crop
108+
)
109+
}
88110

89111
Text(
90112
text = previewDescription,
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<set xmlns:android="http://schemas.android.com/apk/res/android">
3+
<objectAnimator
4+
android:duration="250"
5+
android:interpolator="@android:interpolator/accelerate_quad"
6+
android:propertyName="scaleX"
7+
android:valueFrom="4.1875"
8+
android:valueTo="1.0"
9+
android:valueType="floatType" />
10+
<objectAnimator
11+
android:duration="250"
12+
android:interpolator="@android:interpolator/accelerate_quad"
13+
android:propertyName="scaleY"
14+
android:valueFrom="4.1875"
15+
android:valueTo="1.0"
16+
android:valueType="floatType" />
17+
</set>

app/src/main/res/drawable/single_preview.xml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,17 @@
33
android:height="108dp"
44
android:viewportWidth="108"
55
android:viewportHeight="108">
6+
<path
7+
android:fillColor="#2988cc"
8+
android:pathData="M-0,0h108v108h-108z" />
9+
<group
10+
android:name="black_radius"
11+
android:pivotX="75"
12+
android:pivotY="41">
13+
<path
14+
android:fillColor="#000"
15+
android:pathData="M75,41m-24,0a24,24 0,1 1,48 0a24,24 0,1 1,-48 0" />
16+
</group>
617
<group
718
android:name="disappearing_circle"
819
android:pivotX="75"

app/src/main/res/drawable/single_preview_animated.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,7 @@
33
<target
44
android:name="disappearing_circle"
55
android:animation="@animator/fade_out_shrinking" />
6+
<target
7+
android:name="black_radius"
8+
android:animation="@animator/fade_in_shrinking" />
69
</animated-vector>

0 commit comments

Comments
 (0)