-
Notifications
You must be signed in to change notification settings - Fork 0
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
base: develop
Are you sure you want to change the base?
[Feat] 태그 관리 기능 구현 #482
Conversation
@@ -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> { |
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.
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> |
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.
이하 동일
@@ -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) } |
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.
이름이 정확해야지 검색이 되는 기존 로직에서 같은 스펠이 들어가 있으면 검색 결과에 포함이 되도록 수정했습니다!
} setTagAction: { | ||
setTagAction() | ||
popover.toggle() |
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.
PaperInfo 셀의 ellipsis 액션에 태그 관리 액션을 추가했습니다
@@ -34,6 +34,7 @@ final class HomeSearchViewModel: ObservableObject, Sendable { | |||
enum SearchViewStatus: Hashable { | |||
case normal | |||
case search(PaperInfo) | |||
case setTag(PaperInfo) |
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.
태그 관리 뷰의 트리거를 위해 케이스를 추가 했습니다(이름 수정 뷰의 트리거와 동일하게 돌아감)
.onDisappear { | ||
homeSearchViewModel.searchPapers() | ||
} |
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.
수정 결과가 이전 뷰에 반영이 될 수 있게 해당 뷰를 나가면 데이터를 다시 fetch 하도록 바꾸었습니다!
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 | ||
} |
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.
버튼으로 사용하는 경우와 단순히 보여주기 위한 셀로 쓰이는 경우가 나뉘어져 있어
- 뷰로 사용할 경우 name으로 초기화
- 버튼으로 사용할 경우 tag, 클로저로 초기화
이렇게 나누었습니다!
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.
초기화를 이런 식으로 사용할 수도 있군요,, 굳굳!!!
.onSubmit { | ||
if let tag = viewModel.onSubmit(paperInfo: paperInfo) { | ||
self.paperInfo.tags.append(tag) | ||
} |
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.
추가된 태그를 현재 뷰의 paperinfo에 반영합니다!
} | ||
.frame(width: 400, height: 52) | ||
.onReceive(viewModel.$searchText) { _ in | ||
viewModel.searchTagButtonTapped() |
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.
TextField의 텍스트의 변화에 따라 검색이 실행됩니다(0.5초 간격)
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 | ||
} |
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.
뷰의 분기설정을 위한 프로퍼티입니다!
var lastSearchTags: [String: String] { | ||
get { | ||
UserDefaults.standard.dictionary(forKey: UserDefaultsKeys.lastSearchTags) as? [String: String] ?? [:] | ||
} | ||
set { | ||
UserDefaults.standard.set(newValue, forKey: UserDefaultsKeys.lastSearchTags) | ||
} |
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.
태그 관리 내에서 최근 추가된 태그 내역을 저장하는 UserDefaults 입니다
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.
고생하셨습니다 무니!!
저도 뷰모델에서는 보여지는 뷰와 관련된 부분만 들어가는게 좋아보입니다
개인적인 생각으로는 tag가 paperInfo에도 들어간 만큼 해당 뷰의 useCase보다 좀 더 포괄적인repository에서 관리하는게 좋지 않을까 싶습니다~
close #481
변경 사항
스크린샷 or 영상 링크
팀원에게 전달할 사항(Optional)