Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,342 @@
package com.flint.presentation.profile

import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
import androidx.compose.foundation.text.KeyboardActions
import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalSoftwareKeyboardController
import androidx.compose.ui.text.input.ImeAction
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.hilt.navigation.compose.hiltViewModel
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import com.flint.R
import com.flint.core.common.util.UiState
import com.flint.core.designsystem.component.indicator.FlintLoadingIndicator
import com.flint.core.designsystem.component.modal.OneButtonModal
import com.flint.core.designsystem.component.textfield.FlintSearchTextField
import com.flint.core.designsystem.component.topappbar.FlintBackTopAppbar
import com.flint.core.designsystem.component.view.FlintSearchEmptyView
import com.flint.core.designsystem.theme.FlintTheme
import com.flint.domain.model.content.BookmarkedContentItemModel
import com.flint.domain.model.content.BookmarkedContentListModel
import com.flint.domain.type.OttType
import com.flint.presentation.profile.component.CollectionCreateContentBookmark
import com.flint.presentation.profile.uistate.SavedContentUiState
import kotlinx.collections.immutable.ImmutableList
import kotlinx.collections.immutable.persistentListOf

@Composable
fun SavedContentRoute(
paddingValues: PaddingValues,
navigateUp: () -> Unit,
viewModel: SavedContentViewModel = hiltViewModel(),
) {
val uiState by viewModel.uiState.collectAsStateWithLifecycle()

SavedContentScreen(
uiState = uiState,
navigateUp = navigateUp,
onSearchKeywordChanged = viewModel::updateSearchKeyword,
onClearSearch = viewModel::clearSearchKeyword,
onBookmarkClick = viewModel::toggleBookmark,
onDismissRestrictionModal = viewModel::dismissBookmarkRestrictionModal,
modifier = Modifier.padding(paddingValues),
)
}

@Composable
fun SavedContentScreen(
uiState: SavedContentUiState,
navigateUp: () -> Unit,
onSearchKeywordChanged: (String) -> Unit,
onClearSearch: () -> Unit,
onBookmarkClick: (contentId: String) -> Unit,
onDismissRestrictionModal: () -> Unit,
modifier: Modifier = Modifier,
) {
val keyboardController = LocalSoftwareKeyboardController.current

Column(
modifier = modifier
.fillMaxSize()
.background(color = FlintTheme.colors.background),
) {
FlintBackTopAppbar(
onClick = navigateUp,
title = "저장 작품",
)

Spacer(modifier = Modifier.height(12.dp))

FlintSearchTextField(
value = uiState.searchKeyword,
onValueChanged = onSearchKeywordChanged,
placeholder = "작품을 검색해보세요",
modifier = Modifier.padding(horizontal = 16.dp),
keyboardOptions = KeyboardOptions(imeAction = ImeAction.Search),
keyboardActions = KeyboardActions(
onSearch = {
keyboardController?.hide()
},
),
onClearAction = onClearSearch,
)

// "총 n개"는 실제 데이터가 있는 Success 상태에서만 노출
if (uiState.contents is UiState.Success) {
Spacer(modifier = Modifier.height(16.dp))

Text(
text = "총 ${uiState.totalCount}개",
modifier = Modifier.padding(horizontal = 16.dp),
color = FlintTheme.colors.gray100,
style = FlintTheme.typography.body2R14,
)

Spacer(modifier = Modifier.height(10.dp))
}

when (uiState.contents) {
is UiState.Loading -> {
Box(
modifier = Modifier.fillMaxSize(),
contentAlignment = Alignment.Center,
) {
FlintLoadingIndicator()
}
}
is UiState.Success -> {
if (uiState.filteredContents.isEmpty()) {
// 검색 결과가 없을 때
Box(
modifier = Modifier.fillMaxSize(),
contentAlignment = Alignment.Center,
) {
FlintSearchEmptyView(
title = "작품을 찾을 수 없어요",
)
}
} else {
SavedContentList(
contents = uiState.filteredContents,
onBookmarkClick = onBookmarkClick,
)
}
}
is UiState.Empty,
is UiState.Failure -> {
Box(
modifier = Modifier.fillMaxSize(),
contentAlignment = Alignment.Center,
) {
FlintSearchEmptyView(
title = "작품을 찾을 수 없어요",
)
}
}
}
}

// 저장 취소 제한 안내 모달 (저장 작품이 5개일 때 북마크 토글 시 노출)
if (uiState.showBookmarkRestrictionModal) {
OneButtonModal(
title = "작품 저장을 취소할 수 없어요",
message = "취향 키워드 분석을 위해\n최소 ${SavedContentUiState.MIN_REQUIRED_COUNT}개의 작품을 저장해주세요",
buttonText = "확인",
onConfirm = onDismissRestrictionModal,
onDismiss = onDismissRestrictionModal,
icon = R.drawable.ic_gradient_bookmark,
)
}
}

@Composable
private fun SavedContentList(
contents: ImmutableList<BookmarkedContentItemModel>,
onBookmarkClick: (contentId: String) -> Unit,
modifier: Modifier = Modifier,
) {
if (contents.isEmpty()) {
Box(
modifier = modifier.fillMaxSize(),
contentAlignment = Alignment.Center,
) {
FlintSearchEmptyView(
title = "작품을 찾을 수 없어요",
)
}
return
}

LazyColumn(
modifier = modifier.fillMaxSize(),
) {
items(
items = contents,
key = { it.id },
) { content ->
CollectionCreateContentBookmark(
onBookmarkClick = { onBookmarkClick(content.id) },
onMoreClick = {},
isBookmarked = true,
bookmarkCount = 123,
imageUrl = content.imageUrl,
title = content.title,
director = "감독이름",
createdYear = content.year,
ottList = content.getOttSimpleList,
)
Comment on lines +192 to +202
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot May 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# BookmarkedContentItemModel의 실제 필드 확인
ast-grep --pattern $'data class BookmarkedContentItemModel(
  $$$
)'

# CollectionCreateContentBookmark 컴포넌트 시그니처 확인
ast-grep --pattern $'fun CollectionCreateContentBookmark(
  $$$
)'

Repository: imflint/Flint-Android

Length of output: 841


🏁 Script executed:

# Search for CollectionCreateContentBookmark function definition
rg "fun CollectionCreateContentBookmark" -A 15

Repository: imflint/Flint-Android

Length of output: 11924


🏁 Script executed:

# Also check the actual file at the specified lines
cat -n app/src/main/java/com/flint/presentation/profile/SavedContentScreen.kt | sed -n '185,210p'

Repository: imflint/Flint-Android

Length of output: 1058


하드코딩된 값으로 인한 부정확한 정보 표시

bookmarkCount = 123director = "감독이름"이 하드코딩되어 있습니다. BookmarkedContentItemModel에 이 필드들이 없어서, 모든 북마크가 동일한 값으로 표시됩니다. 실제 데이터를 사용하도록 수정하거나, 이 파라미터들이 필요 없다면 제거해야 합니다.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@app/src/main/java/com/flint/presentation/profile/SavedContentScreen.kt`
around lines 192 - 202, The CollectionCreateContentBookmark invocation uses
hardcoded bookmarkCount=123 and director="감독이름", causing incorrect display;
update the call to pass real values from the BookmarkedContentItemModel (e.g.,
use content.bookmarkCount and content.director if those properties exist) or, if
the model truly lacks those fields, remove the bookmarkCount and director params
from the CollectionCreateContentBookmark call and from the component signature
(update the CollectionCreateContentBookmark composable to no longer require
those params). Locate the call at CollectionCreateContentBookmark and the
model/class BookmarkedContentItemModel and either map the actual fields or
remove the unused props consistently.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

북마크 api연결하면서 BookmarkedContentItemModel 추가할 예정

}
}
}

private object SavedContentPreviewData {
val FakeList: ImmutableList<BookmarkedContentItemModel> = persistentListOf(
BookmarkedContentItemModel(
id = "0",
title = "은하수를 여행하는 히치하이커를 위한 안내서",
year = 2005,
imageUrl = "",
getOttSimpleList = listOf(
OttType.Netflix,
OttType.Disney,
OttType.Tving,
),
),
BookmarkedContentItemModel(
id = "1",
title = "해리포터와 불의잔",
year = 2005,
imageUrl = "",
getOttSimpleList = listOf(
OttType.Netflix,
OttType.CoupangPlay
),
),
BookmarkedContentItemModel(
id = "2",
title = "해리포터와 불의잔",
year = 2005,
imageUrl = "",
getOttSimpleList = listOf(OttType.Netflix),
),
BookmarkedContentItemModel(
id = "3",
title = "해리포터와 불의잔",
year = 2005,
imageUrl = "",
getOttSimpleList = listOf(OttType.Netflix),
),
BookmarkedContentItemModel(
id = "4",
title = "해리포터와 불의잔",
year = 2005,
imageUrl = "",
getOttSimpleList = listOf(OttType.Netflix),
),
BookmarkedContentItemModel(
id = "5",
title = "해리포터와 불의잔",
year = 2005,
imageUrl = "",
getOttSimpleList = listOf(OttType.Netflix),
),
BookmarkedContentItemModel(
id = "6",
title = "해리포터와 불의잔",
year = 2005,
imageUrl = "",
getOttSimpleList = listOf(OttType.Netflix),
),
BookmarkedContentItemModel(
id = "7",
title = "해리포터와 불의잔",
year = 2005,
imageUrl = "",
getOttSimpleList = listOf(OttType.Netflix),
),
)
}

@Preview(showBackground = true)
@Composable
private fun SavedContentScreenPreview() {
FlintTheme {
SavedContentScreen(
uiState = SavedContentUiState(
contents = UiState.Success(
BookmarkedContentListModel(contents = SavedContentPreviewData.FakeList),
),
),
navigateUp = {},
onSearchKeywordChanged = {},
onClearSearch = {},
onBookmarkClick = {},
onDismissRestrictionModal = {},
)
}
}

@Preview(showBackground = true, name = "Empty")
@Composable
private fun SavedContentScreenEmptyPreview() {
FlintTheme {
SavedContentScreen(
uiState = SavedContentUiState(contents = UiState.Empty),
navigateUp = {},
onSearchKeywordChanged = {},
onClearSearch = {},
onBookmarkClick = {},
onDismissRestrictionModal = {},
)
}
}

@Preview(showBackground = true, name = "Loading")
@Composable
private fun SavedContentScreenLoadingPreview() {
FlintTheme {
SavedContentScreen(
uiState = SavedContentUiState(contents = UiState.Loading),
navigateUp = {},
onSearchKeywordChanged = {},
onClearSearch = {},
onBookmarkClick = {},
onDismissRestrictionModal = {},
)
}
}

@Preview(showBackground = true, name = "Restriction Modal")
@Composable
private fun SavedContentScreenRestrictionModalPreview() {
FlintTheme {
SavedContentScreen(
uiState = SavedContentUiState(
contents = UiState.Success(
BookmarkedContentListModel(contents = SavedContentPreviewData.FakeList),
),
showBookmarkRestrictionModal = true,
),
navigateUp = {},
onSearchKeywordChanged = {},
onClearSearch = {},
onBookmarkClick = {},
onDismissRestrictionModal = {},
)
}
}
Loading
Loading