Skip to content
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

[Feat] 태그 관리 기능 구현 #482

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from

Conversation

mooninbeom
Copy link
Collaborator

close #481

변경 사항

  • 태그 관리 뷰 및 기능 구현
  • PaperInfo 셀에다 해당 기능 연결
  • 자잘한 기능 수정

스크린샷 or 영상 링크

  • 태그 관리 뷰
스크린샷 2025-03-08 오후 3 26 14
  • 태그 추가 기록
스크린샷 2025-03-08 오후 3 26 43
  • 새로운 태그
스크린샷 2025-03-08 오후 3 29 13
  • 태그 추가
스크린샷 2025-03-08 오후 3 27 45
  • 반영된 모습
스크린샷 2025-03-08 오후 3 28 04

팀원에게 전달할 사항(Optional)

  • 커스텀 Alert를 넣어야 하는데 쿠로가 하고있다고 저번에 들어서 합쳐지면 그걸 넣어서 같이 사용해볼 예정입니다.
  • 아직 새로 바뀐 PaperInfo 셀이 검색결과에만 적용이 되어 있어 홈 화면에는 연결을 하지 못했습니다. 추후 구현되면 연결하겠습니다.
  • 하나의 Paperinfo에 태그가 최대 7개 들어갈 수 있는데 해당 조건을 처리하는 곳을 어디에 두어야 할지 고민입니다. 일단은 기능 구현을 위해 뷰모델에 넣었는데 UseCase나 Repository에 넣는건 어떤지 다른 분들의 의견이 궁금합니다!
  • 전 개인적으로 뷰모델에서는 뷰와 관련된 액션만 진행이 되어야 한다 생각하여 이런 내부 로직은 UseCase 또는 직접 저장과 불러오기를 담당하는 Repository에서 처리를 하는게 어떤가 하는 생각입니다.

@mooninbeom mooninbeom added Feature 기능의 추가가 필요할 때 PR-NeedReview 작업이 완료되고 리뷰가 필요한 PR labels Mar 8, 2025
@mooninbeom mooninbeom self-assigned this Mar 8, 2025
@@ -209,7 +209,7 @@ final class PaperDataRepositoryImpl: PaperDataRepository {
}
}

func addTag(to id: UUID, with tag: String) -> Result<VoidResponse, any Error> {
func addTag(to id: UUID, with tag: String) -> Result<Tag, any Error> {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

UI반영을 위해(추가된 태그 표시) 추가된 태그를 반환하도록 변경했습니다!

@@ -29,7 +29,7 @@ protocol PaperDataRepository: Sendable {

// 문서에 태그를 추가합니다
@discardableResult
func addTag(to id: UUID, with tag: String) -> Result<VoidResponse, Error>
func addTag(to id: UUID, with tag: String) -> Result<Tag, Error>
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

이하 동일

@@ -103,7 +103,7 @@ extension DefaultHomeSearchUseCase {
private func fetchPapersByTagName(_ tagName: String) -> [PaperInfo] {
let response = tagDataRepository.fetchAllTags()
if case let .success(tags) = response {
let result = tags.filter { $0.name == tagName }
let result = tags.filter { $0.name.localizedCaseInsensitiveContains(tagName) }
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

이름이 정확해야지 검색이 되는 기존 로직에서 같은 스펠이 들어가 있으면 검색 결과에 포함이 되도록 수정했습니다!

Comment on lines +52 to +54
} setTagAction: {
setTagAction()
popover.toggle()
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

PaperInfo 셀의 ellipsis 액션에 태그 관리 액션을 추가했습니다

@@ -34,6 +34,7 @@ final class HomeSearchViewModel: ObservableObject, Sendable {
enum SearchViewStatus: Hashable {
case normal
case search(PaperInfo)
case setTag(PaperInfo)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

태그 관리 뷰의 트리거를 위해 케이스를 추가 했습니다(이름 수정 뷰의 트리거와 동일하게 돌아감)

Comment on lines +224 to +226
.onDisappear {
homeSearchViewModel.searchPapers()
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

수정 결과가 이전 뷰에 반영이 될 수 있게 해당 뷰를 나가면 데이터를 다시 fetch 하도록 바꾸었습니다!

Comment on lines +17 to +27
init(name: String) {
self.tag = nil
self.name = name
self.action = {}
}

init(tag: Tag, action: @escaping () -> Void) {
self.tag = tag
self.name = tag.name
self.action = action
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

버튼으로 사용하는 경우와 단순히 보여주기 위한 셀로 쓰이는 경우가 나뉘어져 있어

  • 뷰로 사용할 경우 name으로 초기화
  • 버튼으로 사용할 경우 tag, 클로저로 초기화
    이렇게 나누었습니다!

Copy link
Collaborator

Choose a reason for hiding this comment

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

초기화를 이런 식으로 사용할 수도 있군요,, 굳굳!!!

Comment on lines +136 to +139
.onSubmit {
if let tag = viewModel.onSubmit(paperInfo: paperInfo) {
self.paperInfo.tags.append(tag)
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

추가된 태그를 현재 뷰의 paperinfo에 반영합니다!

}
.frame(width: 400, height: 52)
.onReceive(viewModel.$searchText) { _ in
viewModel.searchTagButtonTapped()
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

TextField의 텍스트의 변화에 따라 검색이 실행됩니다(0.5초 간격)

Comment on lines +145 to +159
public var showingSearchPlaceholder: Bool {
!isLoading && searchedTags.isEmpty && searchText.isEmpty && recentAddedTags.isEmpty
}

public var showingRecentAddedTags: Bool {
!isLoading && searchedTags.isEmpty && searchText.isEmpty && !recentAddedTags.isEmpty
}

public var showingCreateNewTag: Bool {
!isLoading && searchedTags.isEmpty && !searchText.isEmpty
}

public var showingExistingTags: Bool {
!isLoading && !searchedTags.isEmpty
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

뷰의 분기설정을 위한 프로퍼티입니다!

Comment on lines +27 to +33
var lastSearchTags: [String: String] {
get {
UserDefaults.standard.dictionary(forKey: UserDefaultsKeys.lastSearchTags) as? [String: String] ?? [:]
}
set {
UserDefaults.standard.set(newValue, forKey: UserDefaultsKeys.lastSearchTags)
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

태그 관리 내에서 최근 추가된 태그 내역을 저장하는 UserDefaults 입니다

Copy link
Collaborator

@Dorii0513 Dorii0513 left a comment

Choose a reason for hiding this comment

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

고생하셨습니다 무니!!
저도 뷰모델에서는 보여지는 뷰와 관련된 부분만 들어가는게 좋아보입니다
개인적인 생각으로는 tag가 paperInfo에도 들어간 만큼 해당 뷰의 useCase보다 좀 더 포괄적인repository에서 관리하는게 좋지 않을까 싶습니다~

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature 기능의 추가가 필요할 때 PR-NeedReview 작업이 완료되고 리뷰가 필요한 PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feat] 태그 관리 기능 구현
2 participants