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
12 changes: 8 additions & 4 deletions src/Projects/BKData/Sources/Constant/APIConfig.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,21 @@ private final class BKDataBundleToken {}
enum APIConfig {
private static let bundle = Bundle(for: BKDataBundleToken.self)

/// V1 API Base URL (auth, books, users, home)
static let baseURL: String = {
/// API Base URL (xcconfig에서 /api까지만 포함)
private static let baseURL: String = {
guard let value = bundle.object(forInfoDictionaryKey: "BASE_API_URL") as? String else {
fatalError("Can't load environment: BKData.BASE_API_URL")
}
return value
}()

/// V1 API Base URL (auth, books, users, home)
static let baseURLv1: String = {
return baseURL + "/v1"
}()

/// V2 API Base URL (emotions, reading-records)
static let baseURLv2: String = {
// V1 URL에서 v2로 변경
return baseURL.replacingOccurrences(of: "/api/v1", with: "/api/v2")
return baseURL + "/v2"
}()
}
Copy link
Member

Choose a reason for hiding this comment

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

DetailRecordV2ResponseDTO 따로 안없애고 그냥 두 개로 두는 걸까요?

Copy link
Member Author

Choose a reason for hiding this comment

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

각자 쓰이는 곳이 있어서 이후에 리팩토링하면서 정리할게요

Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ extension DetailRecordResponseDTO {
}
}

// api-v2
public struct DetailRecordV2ResponseDTO: Decodable {
public let id: String
public let userBookId: String
Expand Down
4 changes: 4 additions & 0 deletions src/Projects/BKData/Sources/DataAssembly.swift
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,10 @@ public struct DataAssembly: Assembly {
)
}

container.register(type: ExternalLinkRepository.self) { _ in
return DefaultExternalLinkRepository()
}

container.register(
type: EmotionRepository.self,
scope: .singleton
Expand Down
48 changes: 0 additions & 48 deletions src/Projects/BKDomain/Sources/Entity/Emotion.swift
Copy link
Member

Choose a reason for hiding this comment

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

subemotion을 서버에서 내려주는 이유가 app 단에서 데이터 안갖고 받은 데이터 그대로 뿌릴려고 그랬던 거 같은데, << 이게 맞다면 SubEmotion이 어떤 String으로 구성되면 안될 것 같습니다. 정책을 명확하게 기억하는 상태가 아니라 이거 AOS쪽에 물어보고 후속 작업하시는 거 어떠실까요?

Copy link
Member Author

Choose a reason for hiding this comment

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

SubEmotion이 이것저것 하다 남은 레거시 코드네요. 실제로는 사용중이지 않아서 삭제하겠습니다

Original file line number Diff line number Diff line change
Expand Up @@ -7,51 +7,3 @@ public enum Emotion: String, CaseIterable, Decodable {
case insight = "깨달음"
case other = "기타"
}

public enum SubEmotion: String, CaseIterable {
// 따뜻함
case comforted = "위로받은"
case cozy = "포근한"
case tender = "다정한"
case grateful = "고마운"
case relieved = "마음이 놓이는"
case peaceful = "편안한"

// 즐거움
case excited = "설레는"
case satisfied = "뿌듯한"
case cheerful = "유쾌한"
case joyful = "기쁜"
case thrilling = "흥미진진한"

// 슬픔
case hollow = "허무한"
case lonely = "외로운"
case regretful = "아쉬운"
case stunned = "먹먹한"
case bittersweet = "애틋한"
case pitiful = "안타까운"
case nostalgic = "그리운"

// 깨달음
case amazed = "감탄한"
case insightful = "통찰력을 얻은"
case inspired = "영감을 받은"
case deepened = "생각이 깊어진"
case understood = "새롭게 이해한"

public static func subEmotions(for emotion: Emotion) -> [SubEmotion] {
switch emotion {
case .warmth:
return [.comforted, .cozy, .tender, .grateful, .relieved, .peaceful]
case .joy:
return [.excited, .satisfied, .cheerful, .joyful, .thrilling]
case .sad:
return [.hollow, .lonely, .regretful, .stunned, .bittersweet, .pitiful, .nostalgic]
case .insight:
return [.amazed, .insightful, .inspired, .deepened, .understood]
case .other:
return []
}
}
}
22 changes: 0 additions & 22 deletions src/Projects/BKDomain/Sources/Entity/PrimaryEmotion.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,26 +31,4 @@ public enum PrimaryEmotion: String, CaseIterable, Codable {
case .other: return "네 가지 감정으로 표현하기 어려울 때"
}
}

/// Emotion으로 변환
public func toEmotion() -> Emotion {
switch self {
case .warmth: return .warmth
case .joy: return .joy
case .sadness: return .sad
case .insight: return .insight
case .other: return .other
}
}

/// Emotion에서 변환
public static func from(emotion: Emotion) -> PrimaryEmotion {
switch emotion {
case .warmth: return .warmth
case .joy: return .joy
case .sad: return .sadness
case .insight: return .insight
case .other: return .other
}
}
}
5 changes: 0 additions & 5 deletions src/Projects/BKDomain/Sources/Entity/RecordInfo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,4 @@ public struct RecordInfo: Decodable, Equatable {
self.bookCoverImageUrl = bookCoverImageUrl
self.author = author
}

/// 이전 API와의 호환성을 위한 computed property
public var emotionTags: [Emotion] {
[primaryEmotion.toEmotion()]
}
}
14 changes: 0 additions & 14 deletions src/Projects/BKDomain/Sources/VO/RecordDetails/RecordVO.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,4 @@ public struct RecordVO {
self.primaryEmotion = primaryEmotion
self.detailEmotionIds = detailEmotionIds
}

/// 이전 API와의 호환성을 위한 생성자
public init(
pageNumber: Int?,
quote: String,
review: String?,
emotionTags: [String]
) {
self.pageNumber = pageNumber
self.quote = quote
self.memo = review
self.primaryEmotion = .other
self.detailEmotionIds = emotionTags
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,7 @@ final class BookDetailViewCell: UICollectionViewCell {
noteLabel.setText(text: displayedNote)
emotionTagLabel.setText(text: "#\(emotion.displayName)")
creationLabel.setText(text: item.createdAt.toKoreanDotDateString())
if let page = item.page {
pageLabel.setText(text: "\(page)p")
} else {
pageLabel.setText(text: "-p")
}
pageLabel.setText(text: item.page.toPageString)
}

func applyMoreButtonGesture(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,6 @@ final class EmotionRegistrationView: BaseView {
rowView.addGestureRecognizer(tapGesture)
rowView.tag = emotion.hashValue

// Set up chip removal callback
rowView.onDetailEmotionRemoved = { [weak self] detailEmotion in
self?.removeDetailEmotion(detailEmotion)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,34 +8,6 @@ struct NoteForm: Equatable {
let memo: String?
let primaryEmotion: PrimaryEmotion
let detailEmotions: [DetailEmotion]

/// 이전 API 호환성 생성자
init(
page: Int?,
sentence: String,
emotion: Emotion,
appreciation: String?
) {
self.page = page
self.sentence = sentence
self.memo = appreciation
self.primaryEmotion = PrimaryEmotion.from(emotion: emotion)
self.detailEmotions = []
}

init(
page: Int?,
sentence: String,
memo: String?,
primaryEmotion: PrimaryEmotion,
detailEmotions: [DetailEmotion]
) {
self.page = page
self.sentence = sentence
self.memo = memo
self.primaryEmotion = primaryEmotion
self.detailEmotions = detailEmotions
}
}

extension NoteForm {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,7 @@ final class CollectedSentenceView: BaseView {
) {
let displayedText = "\"\(sentence)\""
collectedSentenceLabel.setText(text: displayedText)
if let page {
pageLabel.setText(text: "\(page)p")
} else {
pageLabel.setText(text: "-p")
}
pageLabel.setText(text: page.toPageString)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,14 @@ extension NoteEditCoordinator: AuthenticationRequiredNotifying, ErrorHandleable
}

extension NoteEditCoordinator {
func didTapEmotionEdit(currentEmotion: Emotion?, completion: @escaping (Emotion) -> Void) {
func didTapEmotionEdit(
currentEmotion: PrimaryEmotion?,
currentDetailEmotions: [DetailEmotion],
completion: @escaping (PrimaryEmotion, [DetailEmotion]) -> Void
) {
let emotionEditViewController = EmotionEditViewController(
currentEmotion: currentEmotion,
currentDetailEmotions: currentDetailEmotions,
completion: completion
)
emotionEditViewController.coordinator = self
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ import SnapKit

enum EmotionEditViewEvent {
case editButtonTapped
case emotionDidChange(Emotion?)
case emotionDidChange(PrimaryEmotion?)
case emotionSelected(PrimaryEmotion) // 감정 탭 시 (바텀시트 표시용)
}

final class EmotionEditView: BaseView {
Expand All @@ -20,10 +21,10 @@ final class EmotionEditView: BaseView {
let eventPublisher = PassthroughSubject<EmotionEditViewEvent, Never>()
private var cancellables = Set<AnyCancellable>()

private var currentSelectedEmotion: Emotion? {
private var currentSelectedPrimaryEmotion: PrimaryEmotion? {
guard let form = emotionRegistrationView.registrationForm(),
case .emotion(let emotionForm) = form else { return nil }
return emotionForm.emotion
return emotionForm.primaryEmotion
}

override func setupView() {
Expand All @@ -35,12 +36,17 @@ final class EmotionEditView: BaseView {
override func configure() {
editButton.title = "수정하기"
editButton.addTarget(self, action: #selector(editButtonTapped), for: .touchUpInside)


// 감정 탭 이벤트 전달 (바텀시트 표시용)
emotionRegistrationView.onEmotionSelected = { [weak self] emotion in
self?.eventPublisher.send(.emotionSelected(emotion))
}

emotionRegistrationView.inputChangedPublisher
.sink { [weak self] _ in
guard let self = self else { return }
let newEmotion = self.currentSelectedEmotion

let newEmotion = self.currentSelectedPrimaryEmotion
self.eventPublisher.send(.emotionDidChange(newEmotion))
}
.store(in: &cancellables)
Expand Down Expand Up @@ -72,17 +78,31 @@ final class EmotionEditView: BaseView {
}
}

func setSelectedEmotion(_ emotion: Emotion) {
emotionRegistrationView.setSelectedEmotion(emotion)
func setSelectedPrimaryEmotion(_ emotion: PrimaryEmotion) {
emotionRegistrationView.setSelectedPrimaryEmotion(emotion)
}

@objc private func editButtonTapped() {
eventPublisher.send(.editButtonTapped)
}

func setEditButtonEnabled(_ isEnabled: Bool) {
editButton.isDisabled = !isEnabled
}

// MARK: - Detail Emotions

func setDetailEmotions(_ detailEmotions: [DetailEmotion]) {
emotionRegistrationView.setDetailEmotions(detailEmotions)
}

func getSelectedDetailEmotions() -> [DetailEmotion] {
return emotionRegistrationView.getSelectedDetailEmotions()
}

func setLoadingEmotions(_ isLoading: Bool) {
emotionRegistrationView.setLoadingEmotions(isLoading)
}
}

private extension EmotionEditView {
Expand Down
Loading