Skip to content
Merged
Show file tree
Hide file tree
Changes from 8 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
1 change: 1 addition & 0 deletions DevLog.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@
hasScannedForEncodings = 0;
knownRegions = (
ko,
en,
);
mainGroup = DFD48AF72DC4D6E2005905C5;
minimizedProjectReferenceProxies = 1;
Expand Down
2 changes: 1 addition & 1 deletion DevLog/App/RootView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ struct RootView: View {
get: { viewModel.state.showAlert },
set: { viewModel.send(.setAlert($0)) }
)) {
Button("확인", role: .cancel) { }
Button(String(localized: "common_close"), role: .cancel) { }
} message: {
Text(viewModel.state.alertMessage)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ enum ProfileActivityType: String, CaseIterable, Hashable {

var title: String {
switch self {
case .created: return "생성"
case .completed: return "완료"
case .created: return String(localized: "profile_activity_created")
case .completed: return String(localized: "profile_activity_completed")
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@ struct ProfileSelectedDayActivity: Identifiable, Hashable {

var activityLabel: String {
if showsCreated && showsCompleted {
return "생성/완료"
return String(localized: "profile_activity_created_completed")
}
return showsCreated ? "생성" : "완료"
return showsCreated
? String(localized: "profile_activity_created")
: String(localized: "profile_activity_completed")
}
}
2 changes: 1 addition & 1 deletion DevLog/Presentation/Structure/WebPageItem.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ struct WebPageItem: Identifiable, Hashable {
}

var id: URL { metadata.url }
var title: String { metadata.title ?? "웹페이지를 찾을 수 없습니다" }
var title: String { metadata.title ?? String(localized: "web_page_missing_title") }
var url: URL { metadata.url }
var displayURL: String { metadata.displayURL.absoluteString }
var imageURL: URL? { metadata.imageURL }
Expand Down
20 changes: 10 additions & 10 deletions DevLog/Presentation/ViewModel/AccountViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -160,17 +160,17 @@ private extension AccountViewModel {
func setAlert(_ state: inout State, isPresented: Bool, type: AlertType?) {
switch type {
case .linkEmailNotFound:
state.alertTitle = "이메일 확인 불가"
state.alertMessage = "선택한 계정의 이메일 정보를 확인할 수 없어 연결할 수 없어요. 계정 설정을 확인한 뒤 다시 시도해주세요."
state.alertTitle = String(localized: "account_alert_email_unavailable_title")
state.alertMessage = String(localized: "account_alert_email_unavailable_message")
case .linkEmailMismatch:
state.alertTitle = "연결할 수 없음"
state.alertMessage = "현재 로그인한 계정과 선택한 계정의 이메일이 달라 연결할 수 없어요. 같은 이메일의 계정으로 다시 시도해주세요."
state.alertTitle = String(localized: "account_alert_cannot_link_title")
state.alertMessage = String(localized: "account_alert_cannot_link_message")
case .linkCredentialAlreadyInUse:
state.alertTitle = "이미 연결된 계정"
state.alertMessage = "선택한 계정은 이미 다른 계정에 연결되어 있어요. 해당 계정으로 로그인한 뒤 이용해주세요."
state.alertTitle = String(localized: "account_alert_already_linked_title")
state.alertMessage = String(localized: "account_alert_already_linked_message")
case .error:
state.alertTitle = "오류"
state.alertMessage = "문제가 발생했습니다. 잠시 후 다시 시도해주세요."
state.alertTitle = String(localized: "common_error_title")
state.alertMessage = String(localized: "common_error_message")
case .none:
state.alertTitle = ""
state.alertMessage = ""
Expand All @@ -182,9 +182,9 @@ private extension AccountViewModel {
func setToast(_ state: inout State, isPresented: Bool, type: ToastType?) {
switch type {
case .linkSuccess:
state.toastMessage = "계정이 성공적으로 연결되었습니다."
state.toastMessage = String(localized: "account_toast_link_success")
case .unlinkSuccess:
state.toastMessage = "계정 연결이 성공적으로 해제되었습니다."
state.toastMessage = String(localized: "account_toast_unlink_success")
case .none:
state.toastMessage = ""
}
Expand Down
14 changes: 7 additions & 7 deletions DevLog/Presentation/ViewModel/HomeViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -390,15 +390,15 @@ private extension HomeViewModel {
) {
switch type {
case .webPageInput:
state.alertTitle = "URL 추가"
state.alertMessage = "웹페이지 URL을 입력해주세요."
state.alertTitle = String(localized: "home_webpage_input_title")
state.alertMessage = String(localized: "home_webpage_input_message")
state.webPageURLInput = "https://"
case .invalidURL:
state.alertTitle = "URL 확인"
state.alertMessage = "올바른 URL을 입력해주세요."
state.alertTitle = String(localized: "home_invalid_url_title")
state.alertMessage = String(localized: "home_invalid_url_message")
case .error:
state.alertTitle = "오류"
state.alertMessage = "문제가 발생했습니다. 잠시 후 다시 시도해주세요."
state.alertTitle = String(localized: "common_error_title")
state.alertMessage = String(localized: "common_error_message")
case .none:
state.alertTitle = ""
state.alertMessage = ""
Expand All @@ -414,7 +414,7 @@ private extension HomeViewModel {
) {
switch type {
case .deleteWebPage:
state.toastMessage = "실행 취소"
state.toastMessage = String(localized: "common_undo")
case .none:
state.toastMessage = ""
}
Expand Down
4 changes: 2 additions & 2 deletions DevLog/Presentation/ViewModel/LoginViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ private extension LoginViewModel {
_ state: inout State,
isPresented: Bool,
) {
state.alertTitle = "오류"
state.alertMessage = "문제가 발생했습니다. 잠시 후 다시 시도해주세요."
state.alertTitle = String(localized: "common_error_title")
state.alertMessage = String(localized: "common_error_message")
state.showAlert = isPresented
}
}
4 changes: 2 additions & 2 deletions DevLog/Presentation/ViewModel/MainViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ private extension MainViewModel {
_ state: inout State,
isPresented: Bool
) {
state.alertTitle = "오류"
state.alertMessage = "알림 배지를 불러오는 중 문제가 발생했습니다."
state.alertTitle = String(localized: "common_error_title")
state.alertMessage = String(localized: "main_alert_badge_error_message")
state.showAlert = isPresented
}

Expand Down
4 changes: 2 additions & 2 deletions DevLog/Presentation/ViewModel/ProfileViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -362,8 +362,8 @@ private extension ProfileViewModel {
_ state: inout State,
isPresented: Bool
) {
state.alertTitle = "오류"
state.alertMessage = "문제가 발생했습니다. 잠시 후 다시 시도해주세요."
state.alertTitle = String(localized: "common_error_title")
state.alertMessage = String(localized: "common_error_message")
state.showAlert = isPresented
}

Expand Down
22 changes: 14 additions & 8 deletions DevLog/Presentation/ViewModel/PushNotificationListViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -301,16 +301,16 @@ private extension PushNotificationListViewModel {
_ state: inout State,
isPresented: Bool
) {
state.alertTitle = "오류"
state.alertMessage = "문제가 발생했습니다. 잠시 후 다시 시도해주세요."
state.alertTitle = String(localized: "common_error_title")
state.alertMessage = String(localized: "common_error_message")
state.showAlert = isPresented
}

func setToast(
_ state: inout State,
isPresented: Bool
) {
state.toastMessage = "실행 취소"
state.toastMessage = String(localized: "common_undo")
state.showToast = isPresented
}

Expand Down Expand Up @@ -357,8 +357,8 @@ private extension PushNotificationListViewModel {
extension PushNotificationQuery.SortOrder {
var title: String {
switch self {
case .latest: return "최신순"
case .oldest: return "예전순"
case .latest: return String(localized: "push_sort_latest")
case .oldest: return String(localized: "push_sort_oldest")
}
}
}
Expand All @@ -375,11 +375,17 @@ extension PushNotificationQuery.TimeFilter {
var title: String {
switch self {
case .none:
return "전체"
return String(localized: "push_timefilter_all")
case .hours(let value):
return "최근 \(value)시간"
return String.localizedStringWithFormat(
String(localized: "push_timefilter_hours_format"),
Int64(value)
)
case .days(let value):
return "최근 \(value)일"
return String.localizedStringWithFormat(
String(localized: "push_timefilter_days_format"),
Int64(value)
)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,8 @@ extension PushNotificationSettingsViewModel {
_ state: inout State,
isPresented: Bool
) {
state.alertTitle = "오류"
state.alertMessage = "문제가 발생했습니다. 잠시 후 다시 시도해주세요."
state.alertTitle = String(localized: "common_error_title")
state.alertMessage = String(localized: "common_error_message")
state.showAlert = isPresented
}

Expand Down
4 changes: 2 additions & 2 deletions DevLog/Presentation/ViewModel/RootViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ private extension RootViewModel {
_ state: inout State,
isPresented: Bool
) {
state.alertTitle = "네트워크 연결 끊김"
state.alertMessage = "인터넷 연결을 확인해주세요."
state.alertTitle = String(localized: "root_network_disconnected_title")
state.alertMessage = String(localized: "root_network_disconnected_message")
state.showAlert = isPresented
}

Expand Down
4 changes: 2 additions & 2 deletions DevLog/Presentation/ViewModel/SearchViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,8 @@ private extension SearchViewModel {
_ state: inout State,
isPresented: Bool
) {
state.alertTitle = "오류"
state.alertMessage = "문제가 발생했습니다. 잠시 후 다시 시도해주세요."
state.alertTitle = String(localized: "common_error_title")
state.alertMessage = String(localized: "common_error_message")
state.showAlert = isPresented
}

Expand Down
16 changes: 8 additions & 8 deletions DevLog/Presentation/ViewModel/SettingViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -143,17 +143,17 @@ private extension SettingViewModel {
) {
switch type {
case .signOut:
state.alertTitle = "로그아웃"
state.alertMessage = "로그아웃 하시겠습니까?"
state.alertTitle = String(localized: "settings_alert_sign_out_title")
state.alertMessage = String(localized: "settings_alert_sign_out_message")
case .deleteAuth:
state.alertTitle = "정말 탈퇴하시겠습니까?"
state.alertMessage = "회원 탈퇴가 진행되면 모든 데이터가 지워지고 복구할 수 없습니다."
state.alertTitle = String(localized: "settings_alert_delete_account_title")
state.alertMessage = String(localized: "settings_alert_delete_account_message")
case .error:
state.alertTitle = "오류"
state.alertMessage = "문제가 발생했습니다. 잠시 후 다시 시도해주세요."
state.alertTitle = String(localized: "common_error_title")
state.alertMessage = String(localized: "common_error_message")
case .removeCache:
state.alertTitle = "임시 데이터 삭제"
state.alertMessage = "임시 데이터를 삭제하고 정리합니다.\n계속하시겠습니까?"
state.alertTitle = String(localized: "settings_alert_clear_temp_title")
state.alertMessage = String(localized: "settings_alert_clear_temp_message")
case .none:
state.alertTitle = ""
state.alertMessage = ""
Expand Down
31 changes: 21 additions & 10 deletions DevLog/Presentation/ViewModel/TodayViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -89,22 +89,33 @@ final class TodayViewModel: Store {
var sections: [SectionContent] {
let groupedItems = groupedSectionItems(from: displayedTodos)
let allSections: [SectionContent] = [
SectionContent(title: "집중할 일", items: groupedItems.focused),
SectionContent(title: "지난 마감", items: groupedItems.overdue),
SectionContent(title: "\(upcomingWindowDays)일 내 일정", items: groupedItems.dueSoon),
SectionContent(title: "나중 일정", items: groupedItems.later),
SectionContent(title: "일정 미정", items: groupedItems.unscheduled)
SectionContent(title: String(localized: "today_section_focused"), items: groupedItems.focused),
SectionContent(title: String(localized: "today_section_overdue"), items: groupedItems.overdue),
SectionContent(
title: String.localizedStringWithFormat(
String(localized: "today_section_due_soon_format"),
Int64(upcomingWindowDays)
),
items: groupedItems.dueSoon
),
SectionContent(title: String(localized: "today_section_later"), items: groupedItems.later),
SectionContent(title: String(localized: "today_section_unscheduled"), items: groupedItems.unscheduled)
]

switch state.selectedSummaryScope {
case .all:
return allSections.filter { !$0.items.isEmpty }
case .focused:
return allSections.filter { $0.title == "집중할 일" && !$0.items.isEmpty }
return allSections.filter { $0.title == String(localized: "today_section_focused") && !$0.items.isEmpty }
case .overdue:
return allSections.filter { $0.title == "지난 마감" && !$0.items.isEmpty }
return allSections.filter { $0.title == String(localized: "today_section_overdue") && !$0.items.isEmpty }
case .dueSoon:
return allSections.filter { $0.title == "\(upcomingWindowDays)일 내 일정" && !$0.items.isEmpty }
return allSections.filter {
$0.title == String.localizedStringWithFormat(
String(localized: "today_section_due_soon_format"),
Int64(upcomingWindowDays)
) && !$0.items.isEmpty
}
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

로컬라이즈된 문자열을 비교하여 섹션을 필터링하는 방식은 유지보수가 어렵고 비효율적입니다. SummaryScope 열거형을 활용하여 필요한 섹션만 직접 생성하여 반환하도록 개선할 수 있습니다.

        switch state.selectedSummaryScope {
        case .all:
            return [
                SectionContent(title: String(localized: "today_section_focused"), items: groupedItems.focused),
                SectionContent(title: String(localized: "today_section_overdue"), items: groupedItems.overdue),
                SectionContent(
                    title: String.localizedStringWithFormat(
                        String(localized: "today_section_due_soon_format"),
                        Int64(upcomingWindowDays)
                    ),
                    items: groupedItems.dueSoon
                ),
                SectionContent(title: String(localized: "today_section_later"), items: groupedItems.later),
                SectionContent(title: String(localized: "today_section_unscheduled"), items: groupedItems.unscheduled)
            ].filter { !$0.items.isEmpty }
        case .focused:
            let items = groupedItems.focused
            return items.isEmpty ? [] : [SectionContent(title: String(localized: "today_section_focused"), items: items)]
        case .overdue:
            let items = groupedItems.overdue
            return items.isEmpty ? [] : [SectionContent(title: String(localized: "today_section_overdue"), items: items)]
        case .dueSoon:
            let items = groupedItems.dueSoon
            let title = String.localizedStringWithFormat(String(localized: "today_section_due_soon_format"), Int64(upcomingWindowDays))
            return items.isEmpty ? [] : [SectionContent(title: title, items: items)]
        }

}

Expand Down Expand Up @@ -275,8 +286,8 @@ private extension TodayViewModel {
_ state: inout State,
isPresented: Bool
) {
state.alertTitle = "오류"
state.alertMessage = "문제가 발생했습니다. 잠시 후 다시 시도해주세요."
state.alertTitle = String(localized: "common_error_title")
state.alertMessage = String(localized: "common_error_message")
state.showAlert = isPresented
}

Expand Down
4 changes: 2 additions & 2 deletions DevLog/Presentation/ViewModel/TodoDetailViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,8 @@ private extension TodoDetailViewModel {
_ state: inout State,
isPresented: Bool
) {
state.alertTitle = "오류"
state.alertMessage = "문제가 발생했습니다. 잠시 후 다시 시도해주세요."
state.alertTitle = String(localized: "common_error_title")
state.alertMessage = String(localized: "common_error_message")
state.showAlert = isPresented
}

Expand Down
7 changes: 5 additions & 2 deletions DevLog/Presentation/ViewModel/TodoEditorViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,13 @@ final class TodoEditorViewModel: Store {

var navigationTitle: String {
if originalDraft == nil {
return "새 \(state.category.localizedName) 추가"
return String.localizedStringWithFormat(
String(localized: "todo_editor_new_format"),
state.category.localizedName
)
}

return "편집"
return String(localized: "todo_edit")
}

var hasChanges: Bool {
Expand Down
Loading