Skip to content

Commit

Permalink
[feat/#83] 선택된 이미지 스크린타입 UI 분기
Browse files Browse the repository at this point in the history
  • Loading branch information
SsongSik committed Aug 25, 2024
1 parent 7f2aea6 commit 7e3ffdb
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 15 deletions.
25 changes: 25 additions & 0 deletions core/designsystem/src/main/res/drawable/ic_image_selected.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:aapt="http://schemas.android.com/aapt"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:pathData="M12,0C5.373,0 0,5.373 0,12C0,18.627 5.373,24 12,24C18.627,24 24,18.627 24,12C24,5.373 18.627,0 12,0ZM18.297,9.039C18.612,8.611 18.571,8.005 18.178,7.624L18.066,7.529C17.638,7.214 17.031,7.255 16.651,7.648L10.445,14.046L7.202,10.702L7.093,10.604C6.674,10.275 6.067,10.298 5.674,10.679C5.246,11.094 5.236,11.778 5.651,12.206L9.67,16.351L9.782,16.452C10.209,16.786 10.832,16.753 11.221,16.351L18.202,9.151L18.297,9.039Z"
android:fillType="evenOdd">
<aapt:attr name="android:fillColor">
<gradient
android:startX="3.333"
android:startY="1.989"
android:endX="10.354"
android:endY="29.192"
android:type="linear">
<item android:offset="0" android:color="#FF2CD7A6"/>
<item android:offset="0.77" android:color="#FF5DD281"/>
</gradient>
</aapt:attr>
</path>
<path
android:pathData="M18.178,7.627C18.571,8.007 18.612,8.614 18.297,9.042L18.202,9.154L11.221,16.354C10.832,16.755 10.21,16.789 9.782,16.454L9.67,16.354L5.651,12.209C5.236,11.781 5.246,11.097 5.675,10.682C6.067,10.301 6.674,10.278 7.093,10.607L7.202,10.705L10.446,14.049L16.651,7.65C17.032,7.258 17.638,7.216 18.066,7.532L18.178,7.627Z"
android:fillColor="#ffffff"/>
</vector>
Original file line number Diff line number Diff line change
Expand Up @@ -247,14 +247,26 @@ fun CustomGallery(

items(galleryItems) { item ->
GalleryItemView(
screenType = screenType,
item = item,
isSelected = selectedItems.contains(item),
selectedIndex = selectedItems.indexOf(item) + 1,
onClick = {
if (selectedItems.contains(item)) {
selectedItems.remove(item)
} else if (selectedItems.size < 3) {
selectedItems.add(item)
if (screenType == ScreenType.REVIEW.name) {
if (selectedItems.contains(item)) {
selectedItems.remove(item)
} else if (selectedItems.size < 3) {
selectedItems.add(item)
}
} else {
if (selectedItems.contains(item)) {
selectedItems.remove(item)
} else if (selectedItems.size < 1) {
selectedItems.add(item)
} else {
selectedItems.remove(selectedItems[0])
selectedItems.add(item)
}
}
}
)
Expand Down Expand Up @@ -325,6 +337,7 @@ fun loadImages(context: Context, onComplete: (List<GalleryItem>) -> Unit) {

@Composable
fun GalleryItemView(
screenType: String,
item: GalleryItem,
isSelected: Boolean,
selectedIndex: Int,
Expand All @@ -343,17 +356,28 @@ fun GalleryItemView(
)

if (isSelected) {
Box(
modifier = Modifier
.padding(8.dp)
.size(24.dp)
.align(Alignment.TopEnd)
.background(SpotTheme.colors.strokePositivePrimary, shape = CircleShape)
) {
Text(
text = selectedIndex.toString(),
color = Color.White,
modifier = Modifier.align(Alignment.Center)
if (screenType == ScreenType.REVIEW.name) {
Box(
modifier = Modifier
.padding(8.dp)
.size(24.dp)
.align(Alignment.TopEnd)
.background(SpotTheme.colors.strokePositivePrimary, shape = CircleShape)
) {
Text(
text = selectedIndex.toString(),
color = Color.White,
modifier = Modifier.align(Alignment.Center)
)
}
} else {
Image(
imageVector = ImageVector.vectorResource(id = com.depromeet.designsystem.R.drawable.ic_image_selected),
contentDescription = "selected",
modifier = Modifier
.padding(8.dp)
.size(24.dp)
.align(Alignment.TopEnd)
)
}
} else {
Expand Down

0 comments on commit 7e3ffdb

Please sign in to comment.