Skip to content

Commit 8749a54

Browse files
Merge pull request #13 from hyunjung-choi/feature/latest-images-card
Feature/latest images card
2 parents 51f12e0 + fff5926 commit 8749a54

File tree

5 files changed

+81
-29
lines changed

5 files changed

+81
-29
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
## 📸 ScreenShots
1616

1717
<p>
18-
<img src="https://github.com/user-attachments/assets/565fe6dc-0cd1-4c8a-ab1e-817fadd7985d", width="300" />
18+
<img src="https://github.com/user-attachments/assets/7709b133-f468-459a-947a-39ddcdddf047", width="300" />
1919
<img src="https://github.com/user-attachments/assets/f8ede8da-ee70-431f-9f80-a31bf58421f6", width="300" />
2020
</p>
2121

Lines changed: 70 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,97 @@
11
package com.prography.android.test.hyunjung.ui.component
22

3+
import androidx.compose.foundation.background
34
import androidx.compose.foundation.clickable
4-
import androidx.compose.foundation.layout.Column
5+
import androidx.compose.foundation.layout.Box
56
import androidx.compose.foundation.layout.fillMaxWidth
67
import androidx.compose.foundation.layout.height
78
import androidx.compose.foundation.layout.padding
89
import androidx.compose.foundation.shape.RoundedCornerShape
910
import androidx.compose.material3.Card
11+
import androidx.compose.material3.Text
1012
import androidx.compose.runtime.Composable
13+
import androidx.compose.ui.Alignment
1114
import androidx.compose.ui.Modifier
1215
import androidx.compose.ui.draw.clip
16+
import androidx.compose.ui.geometry.Offset
17+
import androidx.compose.ui.graphics.Brush
18+
import androidx.compose.ui.graphics.Color.Companion.Transparent
19+
import androidx.compose.ui.graphics.Shadow
1320
import androidx.compose.ui.layout.ContentScale
14-
import androidx.compose.ui.tooling.preview.Preview
21+
import androidx.compose.ui.text.font.FontWeight
22+
import androidx.compose.ui.text.style.TextOverflow
1523
import androidx.compose.ui.unit.dp
24+
import androidx.compose.ui.unit.sp
1625
import coil3.compose.AsyncImage
1726
import com.prography.android.test.hyunjung.data.model.Photo
27+
import com.prography.android.test.hyunjung.ui.theme.Black
28+
import com.prography.android.test.hyunjung.ui.theme.Typography
29+
import com.prography.android.test.hyunjung.ui.theme.White
1830

1931
@Composable
20-
fun ImageItem(photo: Photo, onClick: () -> Unit) {
32+
fun ImageItem(
33+
photo: Photo,
34+
onClick: () -> Unit,
35+
showOverlay: Boolean = false
36+
) {
2137
Card(
2238
modifier = Modifier
2339
.padding(5.dp)
2440
.fillMaxWidth()
2541
.clickable { onClick() },
2642
shape = RoundedCornerShape(10.dp),
2743
) {
28-
Column {
29-
AsyncImage(
30-
model = photo.urls.regular,
31-
contentDescription = null,
32-
modifier = Modifier
33-
.height(150.dp)
34-
.fillMaxWidth()
35-
.clip(RoundedCornerShape(10.dp)),
36-
contentScale = ContentScale.Crop
37-
)
44+
Box {
45+
if (showOverlay) {
46+
AsyncImage(
47+
model = photo.urls.regular,
48+
contentDescription = null,
49+
modifier = Modifier
50+
.clip(RoundedCornerShape(10.dp)),
51+
contentScale = ContentScale.Crop
52+
)
53+
54+
Box(
55+
modifier = Modifier
56+
.fillMaxWidth()
57+
.align(Alignment.BottomStart)
58+
.background(
59+
Brush.verticalGradient(
60+
colors = listOf(Transparent, Black.copy(alpha = 0.3f)),
61+
startY = 100f
62+
)
63+
)
64+
) {
65+
Text(
66+
text = "titletitletitle\n" +
67+
"타이틀은최대2줄까지",
68+
modifier = Modifier
69+
.align(Alignment.BottomStart)
70+
.padding(top = 12.dp, bottom = 8.dp, start = 8.dp, end = 8.dp),
71+
style = Typography.labelSmall.copy(
72+
shadow = Shadow(
73+
color = Black.copy(alpha = 0.25f),
74+
offset = Offset(0f, 2f),
75+
blurRadius = 4f
76+
)
77+
),
78+
maxLines = 2,
79+
color = White,
80+
fontSize = 13.sp,
81+
fontWeight = FontWeight.Bold,
82+
overflow = TextOverflow.Ellipsis
83+
)
84+
}
85+
} else {
86+
AsyncImage(
87+
model = photo.urls.regular,
88+
contentDescription = null,
89+
modifier = Modifier
90+
.height(128.dp)
91+
.clip(RoundedCornerShape(10.dp)),
92+
contentScale = ContentScale.Crop
93+
)
94+
}
3895
}
3996
}
40-
}
41-
42-
@Preview
43-
@Composable
44-
private fun ImageItemPreview() {
4597
}

app/src/main/java/com/prography/android/test/hyunjung/ui/home/HomeScreen.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ fun HomeScreen(viewModel: HomeViewModel = hiltViewModel()) {
100100
items(
101101
photos.distinctBy { it.id },
102102
key = { photo -> photo.id }) { photo ->
103-
ImageItem(photo, onClick = { viewModel.toggleBookmark(photo) })
103+
ImageItem(photo, onClick = { viewModel.toggleBookmark(photo) }, showOverlay = true)
104104
}
105105

106106
item {

app/src/main/java/com/prography/android/test/hyunjung/ui/theme/Theme.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package com.prography.android.test.hyunjung.ui.theme
22

3-
import android.app.Activity
43
import android.os.Build
54
import androidx.compose.foundation.isSystemInDarkTheme
65
import androidx.compose.material3.MaterialTheme
Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.prography.android.test.hyunjung.ui.theme
22

33
import androidx.compose.material3.Typography
4+
import androidx.compose.ui.graphics.Color
45
import androidx.compose.ui.text.TextStyle
56
import androidx.compose.ui.text.font.FontFamily
67
import androidx.compose.ui.text.font.FontWeight
@@ -14,21 +15,21 @@ val Typography = Typography(
1415
fontSize = 16.sp,
1516
lineHeight = 24.sp,
1617
letterSpacing = 0.5.sp
17-
)
18-
/* Other default text styles to override
18+
),
19+
1920
titleLarge = TextStyle(
2021
fontFamily = FontFamily.Default,
21-
fontWeight = FontWeight.Normal,
22-
fontSize = 22.sp,
22+
fontWeight = FontWeight.Bold,
23+
fontSize = 20.sp,
2324
lineHeight = 28.sp,
24-
letterSpacing = 0.sp
25+
letterSpacing = (-0.3).sp
2526
),
27+
2628
labelSmall = TextStyle(
2729
fontFamily = FontFamily.Default,
2830
fontWeight = FontWeight.Medium,
29-
fontSize = 11.sp,
31+
fontSize = 13.sp,
3032
lineHeight = 16.sp,
31-
letterSpacing = 0.5.sp
33+
letterSpacing = (-0.3).sp
3234
)
33-
*/
3435
)

0 commit comments

Comments
 (0)