Skip to content

Commit

Permalink
refactor: EditModeLeadingItem을 별도의 파일로 분리
Browse files Browse the repository at this point in the history
  • Loading branch information
tmdgh1592 committed Jun 5, 2024
1 parent d3969bc commit ae16637
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ import androidx.compose.animation.AnimatedVisibility
import androidx.compose.animation.fadeIn
import androidx.compose.animation.fadeOut
import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
Expand All @@ -18,7 +16,6 @@ import androidx.compose.foundation.layout.systemBarsPadding
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.LazyListScope
import androidx.compose.foundation.lazy.items
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.material3.CircularProgressIndicator
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
Expand All @@ -28,7 +25,6 @@ import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.res.vectorResource
Expand All @@ -37,13 +33,12 @@ import androidx.compose.ui.unit.dp
import androidx.hilt.navigation.compose.hiltViewModel
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import com.droidknights.app.core.designsystem.theme.KnightsTheme
import com.droidknights.app.core.designsystem.theme.Purple01
import com.droidknights.app.core.designsystem.theme.White
import com.droidknights.app.core.model.Session
import com.droidknights.app.feature.bookmark.component.BookmarkCard
import com.droidknights.app.feature.bookmark.component.BookmarkItem
import com.droidknights.app.feature.bookmark.component.BookmarkTimelineItem
import com.droidknights.app.feature.bookmark.component.BookmarkTopAppBar
import com.droidknights.app.feature.bookmark.component.EditModeLeadingItem
import com.droidknights.app.feature.bookmark.component.RemoveBookmarkSnackBar
import com.droidknights.app.feature.bookmark.model.BookmarkItemUiState
import com.droidknights.app.feature.bookmark.model.BookmarkUiState
Expand Down Expand Up @@ -254,39 +249,3 @@ private fun BookmarkEmptyScreen() {
)
}
}

@Composable
private fun EditModeLeadingItem(
itemState: BookmarkItemUiState,
selectedSessionIds: ImmutableSet<String>,
onSelectedItem: (Session) -> Unit,
) {
val isSelectedItem = selectedSessionIds.contains(itemState.session.id)
val baseModifier = Modifier
.padding(horizontal = 18.dp)
.size(24.dp)
.clip(CircleShape)
.clickable { onSelectedItem(itemState.session) }
if (isSelectedItem) {
Box(
modifier = baseModifier.background(Purple01),
contentAlignment = Alignment.Center
) {
Icon(
modifier = Modifier.size(16.dp),
imageVector = ImageVector.vectorResource(id = R.drawable.ic_check),
contentDescription = null,
tint = White
)
}
} else {
Box(
modifier = baseModifier
.border(
width = 1.dp,
color = MaterialTheme.colorScheme.surfaceContainerHigh,
shape = CircleShape
)
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
package com.droidknights.app.feature.bookmark.component

import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.res.vectorResource
import androidx.compose.ui.unit.dp
import com.droidknights.app.core.designsystem.theme.Purple01
import com.droidknights.app.core.designsystem.theme.White
import com.droidknights.app.core.model.Session
import com.droidknights.app.feature.bookmark.R
import com.droidknights.app.feature.bookmark.model.BookmarkItemUiState
import kotlinx.collections.immutable.ImmutableSet

@Composable
internal fun EditModeLeadingItem(
itemState: BookmarkItemUiState,
selectedSessionIds: ImmutableSet<String>,
onSelectedItem: (Session) -> Unit,
) {
val isSelectedItem = selectedSessionIds.contains(itemState.session.id)
val baseModifier = Modifier
.padding(horizontal = 18.dp)
.size(24.dp)
.clip(CircleShape)
.clickable { onSelectedItem(itemState.session) }
if (isSelectedItem) {
Box(
modifier = baseModifier.background(Purple01),
contentAlignment = Alignment.Center
) {
Icon(
modifier = Modifier.size(16.dp),
imageVector = ImageVector.vectorResource(id = R.drawable.ic_check),
contentDescription = null,
tint = White
)
}
} else {
Box(
modifier = baseModifier
.border(
width = 1.dp,
color = MaterialTheme.colorScheme.surfaceContainerHigh,
shape = CircleShape
)
)
}
}

0 comments on commit ae16637

Please sign in to comment.