-
Notifications
You must be signed in to change notification settings - Fork 0
[Feat] 저장작품 리스트 화면 #204
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
The head ref may contain hidden characters: "FLT-13-\uC800\uC7A5\uC791\uD488-\uB9AC\uC2A4\uD2B8-\uD654\uBA74"
Merged
[Feat] 저장작품 리스트 화면 #204
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
342 changes: 342 additions & 0 deletions
342
app/src/main/java/com/flint/presentation/profile/SavedContentScreen.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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, | ||
| ) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| 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 = {}, | ||
| ) | ||
| } | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Repository: imflint/Flint-Android
Length of output: 841
🏁 Script executed:
Repository: imflint/Flint-Android
Length of output: 11924
🏁 Script executed:
Repository: imflint/Flint-Android
Length of output: 1058
하드코딩된 값으로 인한 부정확한 정보 표시
bookmarkCount = 123과director = "감독이름"이 하드코딩되어 있습니다.BookmarkedContentItemModel에 이 필드들이 없어서, 모든 북마크가 동일한 값으로 표시됩니다. 실제 데이터를 사용하도록 수정하거나, 이 파라미터들이 필요 없다면 제거해야 합니다.🤖 Prompt for AI Agents
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
북마크 api연결하면서 BookmarkedContentItemModel 추가할 예정