Skip to content

Commit 7a01f6c

Browse files
committed
[NDGL-69] refactor: image의 height이 0일때 aspectRatio 에러 방지
1 parent 897b006 commit 7a01f6c

2 files changed

Lines changed: 34 additions & 8 deletions

File tree

feature/travel/src/main/java/com/yapp/ndgl/feature/travel/followtravel/placedetail/component/FollowPlacePhotoTab.kt

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ import androidx.compose.foundation.layout.Column
66
import androidx.compose.foundation.layout.Row
77
import androidx.compose.foundation.layout.aspectRatio
88
import androidx.compose.foundation.layout.fillMaxWidth
9+
import androidx.compose.foundation.layout.height
910
import androidx.compose.foundation.layout.padding
11+
import androidx.compose.foundation.layout.size
1012
import androidx.compose.foundation.shape.RoundedCornerShape
1113
import androidx.compose.runtime.Composable
1214
import androidx.compose.ui.Modifier
@@ -35,7 +37,14 @@ internal fun FollowPlacePhotoTab(leftPhotos: List<PlacePhoto>, rightPhotos: List
3537
contentDescription = null,
3638
modifier = Modifier
3739
.fillMaxWidth()
38-
.aspectRatio(photo.aspectRatio)
40+
.then(
41+
if (photo.height == 0) {
42+
Modifier.height(44.dp)
43+
} else {
44+
Modifier
45+
.aspectRatio(photo.aspectRatio)
46+
},
47+
)
3948
.clip(RoundedCornerShape(8.dp))
4049
.background(Color.LightGray),
4150
contentScale = ContentScale.Crop,
@@ -50,9 +59,13 @@ internal fun FollowPlacePhotoTab(leftPhotos: List<PlacePhoto>, rightPhotos: List
5059
AsyncImage(
5160
model = photo.url,
5261
contentDescription = null,
53-
modifier = Modifier
54-
.fillMaxWidth()
55-
.aspectRatio(photo.aspectRatio)
62+
modifier = if (photo.height == 0) {
63+
Modifier.size(44.dp)
64+
} else {
65+
Modifier
66+
.fillMaxWidth()
67+
.aspectRatio(photo.aspectRatio)
68+
}
5669
.clip(RoundedCornerShape(8.dp))
5770
.background(Color.LightGray),
5871
contentScale = ContentScale.Crop,

feature/travel/src/main/java/com/yapp/ndgl/feature/travel/placedetail/component/PlacePhotoTab.kt

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ import androidx.compose.foundation.layout.Column
66
import androidx.compose.foundation.layout.Row
77
import androidx.compose.foundation.layout.aspectRatio
88
import androidx.compose.foundation.layout.fillMaxWidth
9+
import androidx.compose.foundation.layout.height
910
import androidx.compose.foundation.layout.padding
11+
import androidx.compose.foundation.layout.size
1012
import androidx.compose.foundation.shape.RoundedCornerShape
1113
import androidx.compose.runtime.Composable
1214
import androidx.compose.ui.Modifier
@@ -37,7 +39,14 @@ internal fun PlacePhotoTab(leftPhotos: List<PlacePhoto>, rightPhotos: List<Place
3739
contentDescription = null,
3840
modifier = Modifier
3941
.fillMaxWidth()
40-
.aspectRatio(photo.aspectRatio)
42+
.then(
43+
if (photo.height == 0) {
44+
Modifier.height(44.dp)
45+
} else {
46+
Modifier
47+
.aspectRatio(photo.aspectRatio)
48+
},
49+
)
4150
.clip(RoundedCornerShape(8.dp))
4251
.background(Color.LightGray),
4352
contentScale = ContentScale.Crop,
@@ -52,9 +61,13 @@ internal fun PlacePhotoTab(leftPhotos: List<PlacePhoto>, rightPhotos: List<Place
5261
AsyncImage(
5362
model = photo.url,
5463
contentDescription = null,
55-
modifier = Modifier
56-
.fillMaxWidth()
57-
.aspectRatio(photo.aspectRatio)
64+
modifier = if (photo.height == 0) {
65+
Modifier.size(44.dp)
66+
} else {
67+
Modifier
68+
.fillMaxWidth()
69+
.aspectRatio(photo.aspectRatio)
70+
}
5871
.clip(RoundedCornerShape(8.dp))
5972
.background(Color.LightGray),
6073
contentScale = ContentScale.Crop,

0 commit comments

Comments
 (0)