diff --git a/FiveGuyes/FiveGuyes.xcodeproj/project.pbxproj b/FiveGuyes/FiveGuyes.xcodeproj/project.pbxproj index 22abab4..c417572 100644 --- a/FiveGuyes/FiveGuyes.xcodeproj/project.pbxproj +++ b/FiveGuyes/FiveGuyes.xcodeproj/project.pbxproj @@ -794,7 +794,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.3.0; + MARKETING_VERSION = 1.3.1; OTHER_LDFLAGS = "-ObjC"; PRODUCT_BUNDLE_IDENTIFIER = com.FiveNorms.FiveNorms; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -834,7 +834,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.3.0; + MARKETING_VERSION = 1.3.1; OTHER_LDFLAGS = "-ObjC"; PRODUCT_BUNDLE_IDENTIFIER = com.FiveNorms.FiveNorms; PRODUCT_NAME = "$(TARGET_NAME)"; diff --git a/FiveGuyes/FiveGuyes/Resources/Assets.xcassets/AppIcon.appiconset/1024.png b/FiveGuyes/FiveGuyes/Resources/Assets.xcassets/AppIcon.appiconset/1024.png index 27405c7..75c427e 100644 Binary files a/FiveGuyes/FiveGuyes/Resources/Assets.xcassets/AppIcon.appiconset/1024.png and b/FiveGuyes/FiveGuyes/Resources/Assets.xcassets/AppIcon.appiconset/1024.png differ diff --git a/FiveGuyes/FiveGuyes/Resources/Assets.xcassets/AppIcon.appiconset/114.png b/FiveGuyes/FiveGuyes/Resources/Assets.xcassets/AppIcon.appiconset/114.png index 5f0654a..c73a547 100644 Binary files a/FiveGuyes/FiveGuyes/Resources/Assets.xcassets/AppIcon.appiconset/114.png and b/FiveGuyes/FiveGuyes/Resources/Assets.xcassets/AppIcon.appiconset/114.png differ diff --git a/FiveGuyes/FiveGuyes/Resources/Assets.xcassets/AppIcon.appiconset/120.png b/FiveGuyes/FiveGuyes/Resources/Assets.xcassets/AppIcon.appiconset/120.png index c4ec1ba..c33341b 100644 Binary files a/FiveGuyes/FiveGuyes/Resources/Assets.xcassets/AppIcon.appiconset/120.png and b/FiveGuyes/FiveGuyes/Resources/Assets.xcassets/AppIcon.appiconset/120.png differ diff --git a/FiveGuyes/FiveGuyes/Resources/Assets.xcassets/AppIcon.appiconset/180.png b/FiveGuyes/FiveGuyes/Resources/Assets.xcassets/AppIcon.appiconset/180.png index 497ceb5..bcc08c6 100644 Binary files a/FiveGuyes/FiveGuyes/Resources/Assets.xcassets/AppIcon.appiconset/180.png and b/FiveGuyes/FiveGuyes/Resources/Assets.xcassets/AppIcon.appiconset/180.png differ diff --git a/FiveGuyes/FiveGuyes/Resources/Assets.xcassets/AppIcon.appiconset/29.png b/FiveGuyes/FiveGuyes/Resources/Assets.xcassets/AppIcon.appiconset/29.png index 2fab318..3b479f6 100644 Binary files a/FiveGuyes/FiveGuyes/Resources/Assets.xcassets/AppIcon.appiconset/29.png and b/FiveGuyes/FiveGuyes/Resources/Assets.xcassets/AppIcon.appiconset/29.png differ diff --git a/FiveGuyes/FiveGuyes/Resources/Assets.xcassets/AppIcon.appiconset/40.png b/FiveGuyes/FiveGuyes/Resources/Assets.xcassets/AppIcon.appiconset/40.png index 1a38aae..614a3ee 100644 Binary files a/FiveGuyes/FiveGuyes/Resources/Assets.xcassets/AppIcon.appiconset/40.png and b/FiveGuyes/FiveGuyes/Resources/Assets.xcassets/AppIcon.appiconset/40.png differ diff --git a/FiveGuyes/FiveGuyes/Resources/Assets.xcassets/AppIcon.appiconset/57.png b/FiveGuyes/FiveGuyes/Resources/Assets.xcassets/AppIcon.appiconset/57.png index 4126ddf..a5f41a9 100644 Binary files a/FiveGuyes/FiveGuyes/Resources/Assets.xcassets/AppIcon.appiconset/57.png and b/FiveGuyes/FiveGuyes/Resources/Assets.xcassets/AppIcon.appiconset/57.png differ diff --git a/FiveGuyes/FiveGuyes/Resources/Assets.xcassets/AppIcon.appiconset/58.png b/FiveGuyes/FiveGuyes/Resources/Assets.xcassets/AppIcon.appiconset/58.png index 1ed6763..d24bd4f 100644 Binary files a/FiveGuyes/FiveGuyes/Resources/Assets.xcassets/AppIcon.appiconset/58.png and b/FiveGuyes/FiveGuyes/Resources/Assets.xcassets/AppIcon.appiconset/58.png differ diff --git a/FiveGuyes/FiveGuyes/Resources/Assets.xcassets/AppIcon.appiconset/60.png b/FiveGuyes/FiveGuyes/Resources/Assets.xcassets/AppIcon.appiconset/60.png index 85c6d2b..63dbb31 100644 Binary files a/FiveGuyes/FiveGuyes/Resources/Assets.xcassets/AppIcon.appiconset/60.png and b/FiveGuyes/FiveGuyes/Resources/Assets.xcassets/AppIcon.appiconset/60.png differ diff --git a/FiveGuyes/FiveGuyes/Resources/Assets.xcassets/AppIcon.appiconset/80.png b/FiveGuyes/FiveGuyes/Resources/Assets.xcassets/AppIcon.appiconset/80.png index d79baf2..8da1f18 100644 Binary files a/FiveGuyes/FiveGuyes/Resources/Assets.xcassets/AppIcon.appiconset/80.png and b/FiveGuyes/FiveGuyes/Resources/Assets.xcassets/AppIcon.appiconset/80.png differ diff --git a/FiveGuyes/FiveGuyes/Resources/Assets.xcassets/AppIcon.appiconset/87.png b/FiveGuyes/FiveGuyes/Resources/Assets.xcassets/AppIcon.appiconset/87.png index eddc34b..0fa6856 100644 Binary files a/FiveGuyes/FiveGuyes/Resources/Assets.xcassets/AppIcon.appiconset/87.png and b/FiveGuyes/FiveGuyes/Resources/Assets.xcassets/AppIcon.appiconset/87.png differ diff --git a/FiveGuyes/FiveGuyes/Resources/Assets.xcassets/AppIcon.appiconset/Contents.json b/FiveGuyes/FiveGuyes/Resources/Assets.xcassets/AppIcon.appiconset/Contents.json index 73d3b7f..af727e0 100644 --- a/FiveGuyes/FiveGuyes/Resources/Assets.xcassets/AppIcon.appiconset/Contents.json +++ b/FiveGuyes/FiveGuyes/Resources/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -1 +1,80 @@ -{"images":[{"size":"60x60","expected-size":"180","filename":"180.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"iphone","scale":"3x"},{"size":"40x40","expected-size":"80","filename":"80.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"iphone","scale":"2x"},{"size":"40x40","expected-size":"120","filename":"120.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"iphone","scale":"3x"},{"size":"60x60","expected-size":"120","filename":"120.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"iphone","scale":"2x"},{"size":"57x57","expected-size":"57","filename":"57.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"iphone","scale":"1x"},{"size":"29x29","expected-size":"58","filename":"58.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"iphone","scale":"2x"},{"size":"29x29","expected-size":"29","filename":"29.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"iphone","scale":"1x"},{"size":"29x29","expected-size":"87","filename":"87.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"iphone","scale":"3x"},{"size":"57x57","expected-size":"114","filename":"114.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"iphone","scale":"2x"},{"size":"20x20","expected-size":"40","filename":"40.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"iphone","scale":"2x"},{"size":"20x20","expected-size":"60","filename":"60.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"iphone","scale":"3x"},{"size":"1024x1024","filename":"1024.png","expected-size":"1024","idiom":"ios-marketing","folder":"Assets.xcassets/AppIcon.appiconset/","scale":"1x"}]} \ No newline at end of file +{ + "images" : [ + { + "filename" : "40.png", + "idiom" : "iphone", + "scale" : "2x", + "size" : "20x20" + }, + { + "filename" : "60.png", + "idiom" : "iphone", + "scale" : "3x", + "size" : "20x20" + }, + { + "filename" : "29.png", + "idiom" : "iphone", + "scale" : "1x", + "size" : "29x29" + }, + { + "filename" : "58.png", + "idiom" : "iphone", + "scale" : "2x", + "size" : "29x29" + }, + { + "filename" : "87.png", + "idiom" : "iphone", + "scale" : "3x", + "size" : "29x29" + }, + { + "filename" : "80.png", + "idiom" : "iphone", + "scale" : "2x", + "size" : "40x40" + }, + { + "filename" : "120.png", + "idiom" : "iphone", + "scale" : "3x", + "size" : "40x40" + }, + { + "filename" : "57.png", + "idiom" : "iphone", + "scale" : "1x", + "size" : "57x57" + }, + { + "filename" : "114.png", + "idiom" : "iphone", + "scale" : "2x", + "size" : "57x57" + }, + { + "filename" : "120.png", + "idiom" : "iphone", + "scale" : "2x", + "size" : "60x60" + }, + { + "filename" : "180.png", + "idiom" : "iphone", + "scale" : "3x", + "size" : "60x60" + }, + { + "filename" : "1024.png", + "idiom" : "ios-marketing", + "scale" : "1x", + "size" : "1024x1024" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/FiveGuyes/FiveGuyes/Sources/Models/ReadingScheduleCalculator.swift b/FiveGuyes/FiveGuyes/Sources/Models/ReadingScheduleCalculator.swift index 2123d8a..21d48c0 100644 --- a/FiveGuyes/FiveGuyes/Sources/Models/ReadingScheduleCalculator.swift +++ b/FiveGuyes/FiveGuyes/Sources/Models/ReadingScheduleCalculator.swift @@ -271,3 +271,19 @@ struct ReadingScheduleCalculator { return (pagesPerDay, remainder) } } + +extension ReadingScheduleCalculator { + /// 기록된 날짜의 수를 계산하는 메서드 + func calculateRecordedDays( + progress: Progress + ) -> Int { + return progress.readingRecords.values.filter { $0.pagesRead > 0 }.count + } + + func calculateTotalReadingPages( + setttings: Settings + ) -> Int { + return setttings.targetEndPage - setttings.startPage + } + +} diff --git a/FiveGuyes/FiveGuyes/Sources/Stores/NavigationCoordinator.swift b/FiveGuyes/FiveGuyes/Sources/Stores/NavigationCoordinator.swift index 468b436..fc22cb9 100644 --- a/FiveGuyes/FiveGuyes/Sources/Stores/NavigationCoordinator.swift +++ b/FiveGuyes/FiveGuyes/Sources/Stores/NavigationCoordinator.swift @@ -9,6 +9,7 @@ import SwiftUI // TODO: 추가되는 뷰 추가하기 enum Screens: Hashable { + typealias UserBook = UserBookSchemaV2.UserBookV2 case empty case mainHome case notiSetting @@ -17,6 +18,7 @@ enum Screens: Hashable { case dailyProgress case completionCelebration case completionReview + case completionReviewUpdate(book: UserBook) } @Observable @@ -42,6 +44,8 @@ final class NavigationCoordinator { CompletionCelebrationView() case .completionReview: CompletionReviewView() + case .completionReviewUpdate(book: let book): + CompletionReviewView(isUpdateMode: true, externalBook: book) } } diff --git a/FiveGuyes/FiveGuyes/Sources/Views/Components/CompletionListView.swift b/FiveGuyes/FiveGuyes/Sources/Views/Components/CompletionListView.swift index e44f716..7dc6aed 100644 --- a/FiveGuyes/FiveGuyes/Sources/Views/Components/CompletionListView.swift +++ b/FiveGuyes/FiveGuyes/Sources/Views/Components/CompletionListView.swift @@ -11,22 +11,24 @@ import SwiftUI struct CompletionListView: View { typealias UserBook = UserBookSchemaV2.UserBookV2 + @Environment(NavigationCoordinator.self) var navigationCoordinator: NavigationCoordinator @Environment(\.modelContext) private var modelContext @State private var selectedBookIndex: Int = 0 @State var showCompletionAlert: Bool = false // 완독한 책을 가져오는 쿼리 - // TODO: 책 역순으로 받아오기 🐯🐯🐯🐯🐯 @Query( filter: #Predicate { $0.completionStatus.isCompleted == true } ) - private var completedBooks: [UserBook] + private var fetchCompletedBooks: [UserBook] let completionAlertMessage = "정말로 내용을 삭제할까요?" let completionAlertText = "삭제 후에는 복원할 수 없어요" var body: some View { + var completedBooks = Array(fetchCompletedBooks.reversed()) + VStack(alignment: .leading, spacing: 16) { HStack { Text("완독 리스트") @@ -92,22 +94,34 @@ struct CompletionListView: View { .fontStyle(.body) .foregroundStyle(Color.Labels.primaryBlack1) .padding(.bottom, 10) - // TODO: 수정 버튼 추가하기 + HStack { Text("\(selectedBook.userSettings.targetEndDate.toKoreanDateStringWithoutYear()) 완독완료") Spacer() - // TODO: ❗️❗️❗️ 수정하기 기능 추가 - // 데이터를 지우니까 튕김 -// Button { -// showCompletionAlert = true -// } label: { -// Image(systemName: "ellipsis") -// .resizable() -// .scaledToFit() -// .frame(width: 20, height: 22) -// .tint(Color.Labels.secondaryBlack2) // 디자인 시스템으로 수정 -// .padding(.trailing, 3) -// } + + Menu { + Button { + navigationCoordinator.push(.completionReviewUpdate(book: completedBooks[selectedBookIndex])) + } label: { + Label("내용 수정하기", systemImage: "pencil") + } + + Divider() + + Button(role: .destructive) { + showCompletionAlert = true + } label: { + Label("삭제", systemImage: "trash") + } + } label: { + Image(systemName: "ellipsis") + .resizable() + .scaledToFit() + .frame(width: 20, height: 22) + .tint(Color.Labels.secondaryBlack2) + .padding(.trailing, 3) + + } } .fontStyle(.caption2) .foregroundStyle(Color.Labels.secondaryBlack2) @@ -117,8 +131,7 @@ struct CompletionListView: View { RoundedRectangle(cornerRadius: 16) .foregroundStyle(Color.Fills.lightGreen) } - .padding(.horizontal, 20) - + .padding(.horizontal, 20) } } else { @@ -128,21 +141,29 @@ struct CompletionListView: View { .padding(.horizontal, 20) } } - // TODO: ❗️❗️❗️ 수정하기 기능 추가 - // 데이터를 지우니까 튕김 - // FontStyle 적용해놓음 -// .alert(isPresented: $showCompletionAlert) { -// Alert( -// title: Text(completionAlertText) -// .alertFontStyle(.title3, weight: .semibold), -// message: Text(completionAlertMessage) -// .alertFontStyle(.caption1), -// primaryButton: .cancel(Text("취소하기")), -// secondaryButton: .destructive(Text("삭제")) { -// let book = completedBooks[selectedBookIndex] -// modelContext.delete(book) -// } -// ) -// } + .alert(isPresented: $showCompletionAlert) { + Alert( + title: Text(completionAlertText) + .alertFontStyle(.title3, weight: .semibold), + message: Text(completionAlertMessage) + .alertFontStyle(.caption1), + primaryButton: .cancel(Text("취소하기")), + secondaryButton: .destructive(Text("삭제")) { + let book = completedBooks[selectedBookIndex] + + modelContext.delete(book) + + // 처음 셀로 선택하기 + selectedBookIndex = 0 + + // 데이저 저장이 느려서 직접 저장해주기 + do { + try modelContext.save() + } catch { + print(error.localizedDescription) + } + } + ) + } } } diff --git a/FiveGuyes/FiveGuyes/Sources/Views/Screen/BookCompletion/CompletionCelebrationView.swift b/FiveGuyes/FiveGuyes/Sources/Views/Screen/BookCompletion/CompletionCelebrationView.swift index 09db5c0..07f5793 100644 --- a/FiveGuyes/FiveGuyes/Sources/Views/Screen/BookCompletion/CompletionCelebrationView.swift +++ b/FiveGuyes/FiveGuyes/Sources/Views/Screen/BookCompletion/CompletionCelebrationView.swift @@ -28,28 +28,28 @@ struct CompletionCelebrationView: View { let userSettings: UserSettingsProtocol = userBook.userSettings let readingProgress: any ReadingProgressProtocol = userBook.readingProgress - ZStack { - Image("completionBackground").ignoresSafeArea() + VStack(spacing: 0) { + Spacer() + celebrationTitle + .padding(.bottom, 14) - VStack(spacing: 0) { - Spacer() - celebrationTitle - .padding(.bottom, 14) - - celebrationMessage - .padding(.bottom, 80) - - celebrationBookImage(bookMetadata) - .padding(.bottom, 28) - - readingSummary(userSettings: userSettings, readingProgress: readingProgress) - - Spacer() - - reflectionButton - .padding(.bottom, 42) - } - .padding(.horizontal, 16) + celebrationMessage + .padding(.bottom, 80) + + celebrationBookImage(bookMetadata) + .padding(.bottom, 28) + + readingSummary(userSettings: userSettings, readingProgress: readingProgress) + + Spacer() + + reflectionButton + .padding(.bottom, 21) + } + .padding(.horizontal, 16) + .background { + Image("completionBackground") + .ignoresSafeArea() } .customNavigationBackButton() } @@ -102,16 +102,15 @@ struct CompletionCelebrationView: View { private func readingSummary(userSettings: UserSettingsProtocol, readingProgress: any ReadingProgressProtocol) -> some View { let readingScheduleCalculator = ReadingScheduleCalculator() - + // TODO: 완독을 수정할 수도 있기 때문에 완독 날짜가 바뀔 수 있음, 그래서 완독 날짜는 최종에서 업데이트하고 여기서는 오늘 날짜로 보여주기 -> 초기 설정 날보다 빠를 수도 있음 🐯 let endDateText = Date().toKoreanDateString() var startDateText = userSettings.startDate.toKoreanDateString() if startDateText > endDateText { startDateText = endDateText } // TODO: 위에 이유로 날짜가 바껴서 보이면 아래 로직에 파라미터 값도 바껴야 한다. 🐯 - let pagesPerDay = readingScheduleCalculator.firstCalculatePagesPerDay(settings: userSettings, progress: readingProgress).pagesPerDay - - let totalReadingDays = readingScheduleCalculator.firstCalculateTotalReadingDays(settings: userSettings, progress: readingProgress) + let totalReadingDays = readingScheduleCalculator.calculateRecordedDays(progress: readingProgress) + let pagesPerDay = readingScheduleCalculator.calculateTotalReadingPages(setttings: userSettings) / totalReadingDays return Text("\(startDateText)부터 \(endDateText)까지\n꾸준히 \(pagesPerDay)쪽씩 \(totalReadingDays)일동안 읽었어요 🎉") .fontStyle(.caption1) diff --git a/FiveGuyes/FiveGuyes/Sources/Views/Screen/BookCompletion/CompletionReviewView.swift b/FiveGuyes/FiveGuyes/Sources/Views/Screen/BookCompletion/CompletionReviewView.swift index c882d0e..514c208 100644 --- a/FiveGuyes/FiveGuyes/Sources/Views/Screen/BookCompletion/CompletionReviewView.swift +++ b/FiveGuyes/FiveGuyes/Sources/Views/Screen/BookCompletion/CompletionReviewView.swift @@ -22,11 +22,17 @@ struct CompletionReviewView: View { @Query(filter: #Predicate { $0.completionStatus.isCompleted == false }) private var currentlyReadingBooks: [UserBook] // 현재 읽고 있는 책을 가져오는 쿼리 + // 업데이트 상황을 나타내는 불 변수 + var isUpdateMode: Bool = false + + // 외부에서 주입받을 수 있는 책 변수 + var externalBook: UserBook? + var body: some View { - let userBook = currentlyReadingBooks.first ?? UserBook.dummyUserBookV2 + let userBook = isUpdateMode ? (externalBook ?? UserBook.dummyUserBookV2) : (currentlyReadingBooks.first ?? UserBook.dummyUserBookV2) let bookMetadata: BookMetaDataProtocol = userBook.bookMetaData - let completionStatus: CompletionStatusProtocol = userBook.completionStatus + var completionStatus: CompletionStatusProtocol = userBook.completionStatus let userSettings = userBook.userSettings let title = bookMetadata.title @@ -58,12 +64,18 @@ struct CompletionReviewView: View { if reflectionText.isEmpty { showAlert = true } else { - completionStatus.markAsCompleted(review: reflectionText) - // TODO: 해당 로직 모델로 옮기기 🐯 - userSettings.targetEndDate = Date() - if userSettings.startDate > userSettings.targetEndDate { - userSettings.startDate = userSettings.targetEndDate + if !isUpdateMode { + completionStatus.markAsCompleted(review: reflectionText) + + // TODO: 해당 로직 모델로 옮기기 🐯 + userSettings.targetEndDate = Date() + if userSettings.startDate > userSettings.targetEndDate { + userSettings.startDate = userSettings.targetEndDate + } + } else { + // 업데이트 모드인 경우 + completionStatus.completionReview = reflectionText } navigationCoordinator.popToRoot() @@ -86,6 +98,7 @@ struct CompletionReviewView: View { } .customNavigationBackButton() .onAppear { + reflectionText = completionStatus.completionReview isFocusedTextEditor = true } } diff --git a/FiveGuyes/FiveGuyes/Sources/Views/Screen/BookSetting/BookSettingsManagerView.swift b/FiveGuyes/FiveGuyes/Sources/Views/Screen/BookSetting/BookSettingsManagerView.swift index 55b897d..d28909b 100644 --- a/FiveGuyes/FiveGuyes/Sources/Views/Screen/BookSetting/BookSettingsManagerView.swift +++ b/FiveGuyes/FiveGuyes/Sources/Views/Screen/BookSetting/BookSettingsManagerView.swift @@ -26,6 +26,7 @@ struct BookSettingsManagerView: View { // TODO: 캘린더 뷰로 넘어갈 때 새롭게 그려지면서 어색한 동작 수정하기 if bookSettingInputModel.currentPage != 4 { ProgressBar(currentPage: bookSettingInputModel.currentPage) + .padding(.top, 5) } } .background(Color.Fills.white) diff --git a/FiveGuyes/FiveGuyes/Sources/Views/Screen/BookSetting/CompletionCalendarView.swift b/FiveGuyes/FiveGuyes/Sources/Views/Screen/BookSetting/CompletionCalendarView.swift index cc2c47c..c28e920 100644 --- a/FiveGuyes/FiveGuyes/Sources/Views/Screen/BookSetting/CompletionCalendarView.swift +++ b/FiveGuyes/FiveGuyes/Sources/Views/Screen/BookSetting/CompletionCalendarView.swift @@ -39,38 +39,14 @@ struct CompletionCalendarView: View { } var body: some View { - let bookTitle = bookSettingInputModel.selectedBook?.title ?? "" - VStack(spacing: 0) { - VStack(alignment: .leading, spacing: 0) { if isFirstClick { - Text("<\(bookTitle)>\(bookTitle.subjectParticle())") - .lineLimit(1) // 제목이 길어지면 줄바꿈 허용 - - HStack(spacing: 8) { - Text("총") - - Text("\(totalPages)") - .fontStyle(.title2, weight: .semibold) - .foregroundStyle(Color.Colors.green2) - .padding(.horizontal, 8) // 텍스트 필드와 이미지 주변 패딩 - .padding(.vertical, 4) - .background { - RoundedRectangle(cornerRadius: 8) - .foregroundStyle(Color.Fills.lightGreen) - } - - Text("쪽이에요") - - Spacer() - } Text("목표기간을 선택해주세요") HStack(spacing: 8) { Text("매일") - // TODO: 페이지 할당량 계산 Text("\(pagesPerDay)") .fontStyle(.title2, weight: .semibold) .foregroundStyle(Color.Colors.green2) @@ -250,15 +226,11 @@ struct CompletionCalendarView: View { private func dateText(for date: Date, isSelectedDay: Bool, textColor: Color) -> some View { Text("\(Calendar.current.component(.day, from: date))") .frame(width: 44, height: 44) -// .background( -// isSelectedDay ? Color.green : Color.clear -// ) .foregroundStyle(isSelectedDay ? .white : textColor) // 선택된 경우 화이트, 그렇지 않으면 전달된 색상 사용 .fontStyle( isSelectedDay ? .title2 : .body, weight: isSelectedDay ? .semibold : .regular ) -// .cornerRadius(26) } // 선택된 날짜 범위에 색칠 처리 diff --git a/FiveGuyes/FiveGuyes/Sources/Views/Screen/Main/MainHomeView.swift b/FiveGuyes/FiveGuyes/Sources/Views/Screen/Main/MainHomeView.swift index ed7d94f..1c9218b 100644 --- a/FiveGuyes/FiveGuyes/Sources/Views/Screen/Main/MainHomeView.swift +++ b/FiveGuyes/FiveGuyes/Sources/Views/Screen/Main/MainHomeView.swift @@ -26,6 +26,7 @@ struct MainHomeView: View { var body: some View { + var currentlyReadingBook = currentlyReadingBooks.first let title = currentlyReadingBooks.first?.bookMetaData.title ?? "" let mainAlertText = "현재 읽고 있는 <\(title)>\(title.postPositionParticle()) 책장에서 삭제할까요?" @@ -45,9 +46,13 @@ struct MainHomeView: View { .padding(.bottom, 40) Spacer() - if !currentlyReadingBooks.isEmpty { - Button { - showReadingBookAlert = true + if let currentReadingBook = currentlyReadingBooks.first { + Menu { + Button(role: .destructive) { + showReadingBookAlert = true + } label: { + Label("삭제", systemImage: "trash") + } } label: { Image(systemName: "ellipsis") .resizable() @@ -55,6 +60,7 @@ struct MainHomeView: View { .frame(width: 20, height: 22) .tint(Color.Labels.primaryBlack1) } + .fontStyle(.body) .alert(isPresented: $showReadingBookAlert) { Alert( title: Text(mainAlertText) @@ -66,6 +72,13 @@ struct MainHomeView: View { if let currentReadingBook = currentlyReadingBooks.first { // SwiftData 컨텍스트에서 삭제 필요 modelContext.delete(currentReadingBook) + + // 데이저 저장이 느려서 직접 저장해주기 + do { + try modelContext.save() + } catch { + print(error.localizedDescription) + } } } ) diff --git a/FiveGuyes/FiveGuyes/Sources/Views/Shared/CustomBackButton.swift b/FiveGuyes/FiveGuyes/Sources/Views/Shared/CustomBackButton.swift index 608b7cd..297dc49 100644 --- a/FiveGuyes/FiveGuyes/Sources/Views/Shared/CustomBackButton.swift +++ b/FiveGuyes/FiveGuyes/Sources/Views/Shared/CustomBackButton.swift @@ -24,7 +24,7 @@ struct CustomBackButton: View { } Spacer() } - .background(Color.Fills.white) + .background(Color.clear) } }