From bb307b8e619981fe0bea26a3a550dc0bfe06d404 Mon Sep 17 00:00:00 2001 From: Hwang Sang Hwan <137605270+Hrepay@users.noreply.github.com> Date: Sun, 8 Nov 2026 16:47:14 +0900 Subject: [PATCH] =?UTF-8?q?[#483]=20=EC=98=A4=EB=8A=98=20=EC=8B=9D?= =?UTF-8?q?=EB=8B=A8=EC=9D=98=20=EB=A6=AC=EB=B7=B0=20=ED=99=94=EB=A9=B4?= =?UTF-8?q?=EC=97=90=20=EB=A9=94=EB=89=B4=20=EC=B0=9C=ED=95=98=EA=B8=B0=20?= =?UTF-8?q?=EB=B2=84=ED=8A=BC=EC=9D=84=20=EC=B6=94=EA=B0=80=ED=95=98?= =?UTF-8?q?=EA=B3=A0,=20=EC=95=8C=EB=A6=BC=EC=9D=B4=20=ED=97=88=EC=9A=A9?= =?UTF-8?q?=EB=8F=BC=20=EC=9E=88=EC=9C=BC=EB=A9=B4=20=EC=B0=9C=20=ED=83=AD?= =?UTF-8?q?=EC=9D=98=20=ED=95=B4=EB=8B=B9=20=EC=8B=9D=EB=8B=B9=C2=B7?= =?UTF-8?q?=EC=8B=9C=EA=B0=84=EB=8C=80=20=EC=B9=B4=EB=93=9C=EB=A1=9C=20?= =?UTF-8?q?=EC=9D=B4=EB=8F=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Resources/en.lproj/Localizable.strings | 6 ++ .../Resources/ja.lproj/Localizable.strings | 6 ++ .../Resources/ko.lproj/Localizable.strings | 6 ++ .../Resources/vi.lproj/Localizable.strings | 6 ++ .../NotificationPermissionPrompt.swift | 33 +++++++ .../Home/Model/ReviewMenuTypeInfo.swift | 4 + .../HomeRestaurantViewController.swift | 9 ++ .../Like/Model/TodayMenuSlot.swift | 13 +++ .../ViewController/LikeViewController.swift | 6 ++ .../MenuLikeViewController.swift | 15 ++- .../View/SeeReview/ReviewRateViewCell.swift | 96 ++++++++++++++++++- .../ViewController/ReviewViewController.swift | 30 +++++- .../CustomTabBarContainerController.swift | 8 ++ .../Sources/Utility/Literal/TextLiteral.swift | 15 +++ .../Tests/UnitTests/TodayMenuSlotTests.swift | 13 +++ 15 files changed, 262 insertions(+), 4 deletions(-) diff --git a/EATSSU/App/Resources/en.lproj/Localizable.strings b/EATSSU/App/Resources/en.lproj/Localizable.strings index 20d87315..1665b1db 100644 --- a/EATSSU/App/Resources/en.lproj/Localizable.strings +++ b/EATSSU/App/Resources/en.lproj/Localizable.strings @@ -410,6 +410,8 @@ "review.reviewCount" = "%d Reviews"; /// ReviewRateViewCell - "오늘의 메뉴" "review.todayMenu" = "Today's Menu"; +/// "오늘의 메뉴를 찜해보세요!" +"review.todayMenuFavoritePrompt" = "Save today's menu to favorites!"; /// ReviewRateViewCell - "5점" "review.fiveStars" = "5 Stars"; /// ReviewRateViewCell - "4점" @@ -480,6 +482,10 @@ "notification.settingsTitle" = "Notifications are off"; /// "메뉴 찜 기능을 이용하려면 기기 설정에서 잇슈 알림을 허용해주세요." "notification.settingsMessage" = "To use menu favorites, allow EAT-SSU notifications in Settings."; +/// "메뉴 찜 알림을 허용해주세요" +"notification.favoriteRequestTitle" = "Allow menu favorite alerts"; +/// "찜한 메뉴가 학식에 나오면 가장 먼저 알려드릴게요." +"notification.favoriteRequestMessage" = "We'll let you know first when a saved menu is served."; // MARK: - Restaurant diff --git a/EATSSU/App/Resources/ja.lproj/Localizable.strings b/EATSSU/App/Resources/ja.lproj/Localizable.strings index 5f54ffee..e7fd343b 100644 --- a/EATSSU/App/Resources/ja.lproj/Localizable.strings +++ b/EATSSU/App/Resources/ja.lproj/Localizable.strings @@ -411,6 +411,8 @@ "review.reviewCount" = "レビュー %d件"; /// ReviewRateViewCell - "오늘의 메뉴" "review.todayMenu" = "今日のメニュー"; +/// "오늘의 메뉴를 찜해보세요!" +"review.todayMenuFavoritePrompt" = "今日のメニューをお気に入りに追加!"; /// ReviewRateViewCell - "5점" "review.fiveStars" = "5点"; /// ReviewRateViewCell - "4점" @@ -481,6 +483,10 @@ "notification.settingsTitle" = "通知がオフになっています"; /// "메뉴 찜 기능을 이용하려면 기기 설정에서 잇슈 알림을 허용해주세요." "notification.settingsMessage" = "お気に入り機能を使うには、端末の設定でEAT-SSUの通知を許可してください。"; +/// "메뉴 찜 알림을 허용해주세요" +"notification.favoriteRequestTitle" = "お気に入り通知を許可してください"; +/// "찜한 메뉴가 학식에 나오면 가장 먼저 알려드릴게요." +"notification.favoriteRequestMessage" = "お気に入りメニューが出たら最初にお知らせします。"; // MARK: - Restaurant diff --git a/EATSSU/App/Resources/ko.lproj/Localizable.strings b/EATSSU/App/Resources/ko.lproj/Localizable.strings index 3e2809fb..a9b32fd7 100644 --- a/EATSSU/App/Resources/ko.lproj/Localizable.strings +++ b/EATSSU/App/Resources/ko.lproj/Localizable.strings @@ -411,6 +411,8 @@ "review.reviewCount" = "리뷰 %d"; /// ReviewRateViewCell - "오늘의 메뉴" "review.todayMenu" = "오늘의 메뉴"; +/// "오늘의 메뉴를 찜해보세요!" +"review.todayMenuFavoritePrompt" = "오늘의 메뉴를 찜해보세요!"; /// ReviewRateViewCell - "5점" "review.fiveStars" = "5점"; /// ReviewRateViewCell - "4점" @@ -481,6 +483,10 @@ "notification.settingsTitle" = "알림 권한이 꺼져 있어요"; /// "메뉴 찜 기능을 이용하려면 기기 설정에서 잇슈 알림을 허용해주세요." "notification.settingsMessage" = "메뉴 찜 기능을 이용하려면 기기 설정에서 잇슈 알림을 허용해주세요."; +/// "메뉴 찜 알림을 허용해주세요" +"notification.favoriteRequestTitle" = "메뉴 찜 알림을 허용해주세요"; +/// "찜한 메뉴가 학식에 나오면 가장 먼저 알려드릴게요." +"notification.favoriteRequestMessage" = "찜한 메뉴가 학식에 나오면 가장 먼저 알려드릴게요."; // MARK: - Restaurant diff --git a/EATSSU/App/Resources/vi.lproj/Localizable.strings b/EATSSU/App/Resources/vi.lproj/Localizable.strings index 8c7cb4ce..5f277f93 100644 --- a/EATSSU/App/Resources/vi.lproj/Localizable.strings +++ b/EATSSU/App/Resources/vi.lproj/Localizable.strings @@ -411,6 +411,8 @@ "review.reviewCount" = "%d đánh giá"; /// ReviewRateViewCell - "오늘의 메뉴" "review.todayMenu" = "Thực đơn hôm nay"; +/// "오늘의 메뉴를 찜해보세요!" +"review.todayMenuFavoritePrompt" = "Lưu thực đơn hôm nay vào yêu thích!"; /// ReviewRateViewCell - "5점" "review.fiveStars" = "5 điểm"; /// ReviewRateViewCell - "4점" @@ -481,6 +483,10 @@ "notification.settingsTitle" = "Thông báo đang tắt"; /// "메뉴 찜 기능을 이용하려면 기기 설정에서 잇슈 알림을 허용해주세요." "notification.settingsMessage" = "Để dùng tính năng lưu món, hãy bật thông báo EAT-SSU trong Cài đặt."; +/// "메뉴 찜 알림을 허용해주세요" +"notification.favoriteRequestTitle" = "Cho phép thông báo món đã lưu"; +/// "찜한 메뉴가 학식에 나오면 가장 먼저 알려드릴게요." +"notification.favoriteRequestMessage" = "Chúng tôi sẽ báo đầu tiên khi món đã lưu được phục vụ."; // MARK: - Restaurant diff --git a/EATSSU/App/Sources/Notification/NotificationPermissionPrompt.swift b/EATSSU/App/Sources/Notification/NotificationPermissionPrompt.swift index c0f9c81b..a22372d7 100644 --- a/EATSSU/App/Sources/Notification/NotificationPermissionPrompt.swift +++ b/EATSSU/App/Sources/Notification/NotificationPermissionPrompt.swift @@ -57,6 +57,39 @@ enum NotificationPermissionPrompt { } } + /// 찜 기능을 쓰려는데 알림이 꺼져 있을 때(마이페이지 토글 OFF 또는 권한 미결정): 허용 요청 + static func presentFavoriteRequest(on tabBar: CustomTabBarContainerController) { + tabBar.showDialog( + title: TextLiteral.Notification.favoriteRequestTitle, + message: TextLiteral.Notification.favoriteRequestMessage, + cancelButtonTitle: TextLiteral.Common.cancel, + confirmButtonTitle: TextLiteral.Notification.allow, + cancelAction: nil, + confirmAction: { requestPermission(on: tabBar) } + ) + } + + /// 메뉴 찜 알림을 받을 수 있는 상태인지에 따라 안내 다이얼로그를 띄우거나 `allowed`를 실행한다 + /// - 기기 권한 거부 → 설정 이동 안내 / 토글 OFF 또는 권한 미결정 → 허용 요청 / 그 외 → allowed + static func ensureFavoriteNotificationAllowed(on tabBar: CustomTabBarContainerController, allowed: @escaping () -> Void) { + Task { @MainActor in + let settings = await NotificationManager.shared.checkNotificationSetting() + let isToggleOn = UserDefaults.standard.bool(forKey: TextLiteral.MyPage.pushNotificationUserSettingKey) + switch settings.authorizationStatus { + case .denied: + presentSettingsDialog(on: tabBar) + case .notDetermined: + presentFavoriteRequest(on: tabBar) + default: + if isToggleOn { + allowed() + } else { + presentFavoriteRequest(on: tabBar) + } + } + } + } + /// 기기 알림 권한이 꺼져 있을 때: 설정 앱으로 안내 static func presentSettingsDialog(on tabBar: CustomTabBarContainerController) { tabBar.showDialog( diff --git a/EATSSU/App/Sources/Presentation/Home/Model/ReviewMenuTypeInfo.swift b/EATSSU/App/Sources/Presentation/Home/Model/ReviewMenuTypeInfo.swift index e594977a..012391c4 100644 --- a/EATSSU/App/Sources/Presentation/Home/Model/ReviewMenuTypeInfo.swift +++ b/EATSSU/App/Sources/Presentation/Home/Model/ReviewMenuTypeInfo.swift @@ -12,4 +12,8 @@ struct ReviewMenuTypeInfo { var menuID: Int var changeMenuIDList: [Int]? var restaurantName: String? + /// 리뷰 화면의 "오늘의 메뉴를 찜해보세요!" 판단용: 보고 있던 식단의 날짜·식당 코드(`HAKSIK` 등)·시간대(`LUNCH` 등) + var date: Date? + var restaurantCode: String? + var timePart: String? } diff --git a/EATSSU/App/Sources/Presentation/Home/ViewController/HomeRestaurantViewController.swift b/EATSSU/App/Sources/Presentation/Home/ViewController/HomeRestaurantViewController.swift index 57d632f8..f9e71c5a 100644 --- a/EATSSU/App/Sources/Presentation/Home/ViewController/HomeRestaurantViewController.swift +++ b/EATSSU/App/Sources/Presentation/Home/ViewController/HomeRestaurantViewController.swift @@ -55,6 +55,10 @@ final class HomeRestaurantViewController: BaseViewController { // 리뷰 작성 뷰로 데이터 전달할 델리게이트 var delegate: ReviewMenuTypeInfoDelegate? + /// 마지막으로 조회한 식단의 날짜·시간대. 리뷰 화면이 "오늘 식단인지" 판단하는 데 넘긴다 + private var displayedDate: Date? + private var displayedTimePart: String? + // 고정 메뉴 더미 데이터 (주말/방학 대비용) private let fixedDummy = FixedMenuInfoData.Dummy() @@ -159,6 +163,8 @@ final class HomeRestaurantViewController: BaseViewController { // 날짜와 시간에 따라 메뉴 데이터 fetch func fetchData(date: Date, time: String) { + displayedDate = date + displayedTimePart = time // 새로운 데이터 요청 전, 이전 요청들을 모두 취소 cancellables.forEach { $0.cancel() } cancellables.removeAll() @@ -294,6 +300,9 @@ extension HomeRestaurantViewController: UITableViewDataSource { if section < sectionHeaderRestaurant.count { reviewMenuTypeInfo.restaurantName = sectionHeaderRestaurant[section] } + reviewMenuTypeInfo.date = displayedDate + reviewMenuTypeInfo.restaurantCode = restaurant + reviewMenuTypeInfo.timePart = displayedTimePart if !isSnackCorner { guard let menus = changeMenuTableViewData[restaurant], diff --git a/EATSSU/App/Sources/Presentation/Like/Model/TodayMenuSlot.swift b/EATSSU/App/Sources/Presentation/Like/Model/TodayMenuSlot.swift index 916db821..cb258b71 100644 --- a/EATSSU/App/Sources/Presentation/Like/Model/TodayMenuSlot.swift +++ b/EATSSU/App/Sources/Presentation/Like/Model/TodayMenuSlot.swift @@ -34,6 +34,19 @@ struct TodayMenuSlot: Equatable { Self.isAvailable(restaurant: restaurant, mealTime: mealTime) } + /// 리뷰 화면 "오늘의 메뉴를 찜해보세요!"에 연결할 식당·시간대 + /// + /// 변동 식단(`VARIABLE`)이고, 식단 날짜가 오늘이며, 찜 대상 식당(스낵코너 제외)일 때만 값이 있다. + /// 어제·내일 식단에서는 버튼을 보여주지 않는다 (기능 명세) + static func forReview(menuType: String, restaurantCode: String?, timePart: String?, date: Date?, now: Date = Date()) -> TodayMenuSlot? { + guard menuType == "VARIABLE", + let date, Calendar.current.isDate(date, inSameDayAs: now), + let restaurant = Restaurant.allCases.first(where: { $0.identifier == restaurantCode }), + selectableRestaurants.contains(restaurant), + let mealTime = timePart.flatMap(MealTimePart.init(rawValue:)) else { return nil } + return TodayMenuSlot(restaurant: restaurant, mealTime: mealTime) + } + /// "학생 식당 · 점심" var title: String { "\(restaurant.shortTitle) · \(mealTime.title)" diff --git a/EATSSU/App/Sources/Presentation/Like/ViewController/LikeViewController.swift b/EATSSU/App/Sources/Presentation/Like/ViewController/LikeViewController.swift index a5468a6d..580835ef 100644 --- a/EATSSU/App/Sources/Presentation/Like/ViewController/LikeViewController.swift +++ b/EATSSU/App/Sources/Presentation/Like/ViewController/LikeViewController.swift @@ -101,6 +101,12 @@ final class LikeViewController: BaseViewController { } } + /// 리뷰 화면 → 메뉴 찜 탭. "오늘 식단에서 찜하기" 카드를 해당 식당·시간대로 펼친다 + func showTodayMenu(slot: TodayMenuSlot) { + prepare(tab: .menu, showsBackToMap: false) + menuViewController.showTodayMenu(slot: slot) + } + /// 탭바에서 찜 탭을 다시 눌렀을 때 현재 페이지 갱신 func reloadContent() { switch currentTab { diff --git a/EATSSU/App/Sources/Presentation/Like/ViewController/MenuLikeViewController.swift b/EATSSU/App/Sources/Presentation/Like/ViewController/MenuLikeViewController.swift index 5deb2f8f..aff618fa 100644 --- a/EATSSU/App/Sources/Presentation/Like/ViewController/MenuLikeViewController.swift +++ b/EATSSU/App/Sources/Presentation/Like/ViewController/MenuLikeViewController.swift @@ -190,6 +190,19 @@ final class MenuLikeViewController: BaseViewController { } } + /// 리뷰 화면의 "오늘의 메뉴를 찜해보세요!"로 들어온 경우: 해당 식당·시간대로 카드를 펼친 상태로 보여준다 + func showTodayMenu(slot: TodayMenuSlot) { + if searchBar.textField.isFirstResponder || currentKeyword.isEmpty == false { + finishSearch() + searchBar.textField.resignFirstResponder() + } + todaySlot = slot + todayMenus = [] + hasLoadedTodayMenus = false + todayMenuCard.clearSelection() + setTodayMenuExpanded(true) + } + // MARK: - Search @objc private func textDidChange() { @@ -310,7 +323,7 @@ final class MenuLikeViewController: BaseViewController { $0.height.equalTo(1) $0.bottom.equalToSuperview().inset(Layout.favoritesRowsBelowTitle - Layout.favoritesSeparatorBelowTitle - 1) } - todayMenuCard.setExpanded(false) + // 카드의 접힘/펼침 상태는 여기서 건드리지 않는다. 리뷰 화면에서 펼친 채로 들어오면 헤더가 나중에 만들어지기 때문 return header } diff --git a/EATSSU/App/Sources/Presentation/Review/View/SeeReview/ReviewRateViewCell.swift b/EATSSU/App/Sources/Presentation/Review/View/SeeReview/ReviewRateViewCell.swift index 365c219e..42be8422 100644 --- a/EATSSU/App/Sources/Presentation/Review/View/SeeReview/ReviewRateViewCell.swift +++ b/EATSSU/App/Sources/Presentation/Review/View/SeeReview/ReviewRateViewCell.swift @@ -18,6 +18,14 @@ final class ReviewRateViewCell: UITableViewCell { /// 리뷰 작성 버튼 탭 핸들러 var handler: (() -> Void)? + + /// "오늘의 메뉴를 찜해보세요!" 탭 핸들러 + var onTapTodayMenuFavorite: (() -> Void)? + + /// 찜 버튼이 보일 때 셀에 더해지는 높이 (버튼 위 12.5 + 버튼 41). 디자인 기준 + static let todayMenuFavoriteExtraHeight: CGFloat = 53.5 + + private var rateSectionTopConstraint: Constraint? /// 전체 평균 별점 var totalRate: Double = 0 @@ -69,6 +77,47 @@ final class ReviewRateViewCell: UITableViewCell { return stack }() + // MARK: - UI Components - Today Menu Favorite + + /// 오늘 식단일 때만 보이는 찜 탭 이동 버튼. 디자인: 높이 41, 모서리 8, gray300 테두리, 하트(좌 11) · Medium 12 · 화살표(우 14) + private let todayMenuFavoriteButton: UIControl = { + let control = UIControl() + control.backgroundColor = .white + control.layer.cornerRadius = 8 + control.layer.borderWidth = 1 + control.layer.borderColor = UIColor.gray300.cgColor + control.isHidden = true + // 하위 라벨 대신 버튼 하나로 읽히게 한다 (VoiceOver · UI 테스트) + control.isAccessibilityElement = true + control.accessibilityTraits = .button + control.accessibilityLabel = TextLiteral.Review.todayMenuFavoritePrompt + control.accessibilityIdentifier = "review.todayMenuFavoriteButton" + return control + }() + + private let favoriteHeartImageView: UIImageView = { + let imageView = UIImageView(image: EATSSUDesignAsset.Images.icLikeLine.image) + imageView.tintColor = .gray400 + imageView.contentMode = .scaleAspectFit + return imageView + }() + + private let favoriteTitleLabel: UILabel = { + let label = UILabel() + label.text = TextLiteral.Review.todayMenuFavoritePrompt + label.font = .caption2 + label.textColor = .gray700 + return label + }() + + private let favoriteChevronImageView: UIImageView = { + let config = UIImage.SymbolConfiguration(pointSize: 12, weight: .medium) + let imageView = UIImageView(image: UIImage(systemName: "chevron.right", withConfiguration: config)) + imageView.tintColor = .gray400 + imageView.contentMode = .center + return imageView + }() + // MARK: - UI Components - Rating Section /// 별점 섹션 컨테이너 @@ -156,6 +205,25 @@ final class ReviewRateViewCell: UITableViewCell { fatalError("init(coder:) has not been implemented") } + // MARK: - Today Menu Favorite + + /// 오늘 식단의 리뷰 화면에서만 찜 탭 이동 버튼을 보여준다 + func setTodayMenuFavoriteButtonVisible(_ visible: Bool) { + todayMenuFavoriteButton.isHidden = !visible + rateSectionTopConstraint?.deactivate() + rateSectionContainer.snp.makeConstraints { make in + if visible { + rateSectionTopConstraint = make.top.equalTo(todayMenuFavoriteButton.snp.bottom).offset(24).constraint + } else { + rateSectionTopConstraint = make.top.equalTo(menuContainer.snp.bottom).offset(24).constraint + } + } + } + + @objc private func didTapTodayMenuFavorite() { + onTapTodayMenuFavorite?() + } + // MARK: - Helper Methods /// 별점 레이블 생성 헬퍼 @@ -217,8 +285,10 @@ final class ReviewRateViewCell: UITableViewCell { fiveChartBar = fiveBar.container fiveForeground = fiveBar.foreground - contentView.addSubviews(menuContainer, rateSectionContainer) + contentView.addSubviews(menuContainer, todayMenuFavoriteButton, rateSectionContainer) menuContainer.addSubviews(menuTitleStackView, menuLabel) + todayMenuFavoriteButton.addSubviews(favoriteHeartImageView, favoriteTitleLabel, favoriteChevronImageView) + todayMenuFavoriteButton.addTarget(self, action: #selector(didTapTodayMenuFavorite), for: .touchUpInside) rateSectionContainer.addSubviews( totalRateStackView, yAxisStackView, @@ -253,8 +323,30 @@ final class ReviewRateViewCell: UITableViewCell { make.bottom.equalToSuperview().inset(16) } + todayMenuFavoriteButton.snp.makeConstraints { make in + make.top.equalTo(menuContainer.snp.bottom).offset(12.5) + make.leading.trailing.equalTo(menuContainer) + make.height.equalTo(41) + } + favoriteHeartImageView.snp.makeConstraints { make in + make.leading.equalToSuperview().inset(11) + make.centerY.equalToSuperview() + make.size.equalTo(16) + } + favoriteTitleLabel.snp.makeConstraints { make in + make.leading.equalToSuperview().inset(33) + make.centerY.equalToSuperview() + make.trailing.lessThanOrEqualTo(favoriteChevronImageView.snp.leading).offset(-8) + } + favoriteChevronImageView.snp.makeConstraints { make in + make.trailing.equalToSuperview().inset(14) + make.centerY.equalToSuperview() + make.size.equalTo(16) + } + rateSectionContainer.snp.makeConstraints { make in - make.top.equalTo(menuLabel.snp.bottom).offset(40) + // 메뉴 박스 아래 24 (찜 버튼이 보이면 버튼 아래 24) + rateSectionTopConstraint = make.top.equalTo(menuContainer.snp.bottom).offset(24).constraint make.centerX.equalToSuperview().offset(16) make.width.equalToSuperview().inset(16) } diff --git a/EATSSU/App/Sources/Presentation/Review/ViewController/ReviewViewController.swift b/EATSSU/App/Sources/Presentation/Review/ViewController/ReviewViewController.swift index 6e10d131..d3669a1c 100644 --- a/EATSSU/App/Sources/Presentation/Review/ViewController/ReviewViewController.swift +++ b/EATSSU/App/Sources/Presentation/Review/ViewController/ReviewViewController.swift @@ -34,6 +34,9 @@ final class ReviewViewController: BaseViewController { /// 리뷰 작성 대상 메뉴가 속한 식당 이름 (예: "학생 식당") private var restaurantName: String? + + /// "오늘의 메뉴를 찜해보세요!"로 열 찜 탭 식당·시간대. 오늘 식단의 변동 메뉴일 때만 있다 + private var todayMenuSlot: TodayMenuSlot? /// 메뉴 이름 리스트 private var menuNameList: [String] = [] @@ -430,7 +433,8 @@ extension ReviewViewController: UITableViewDelegate { func tableView(_: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { switch indexPath.section { case 0: - return 251.adjusted + let extra: CGFloat = todayMenuSlot == nil ? 0 : ReviewRateViewCell.todayMenuFavoriteExtraHeight + return (251 + extra).adjusted case 1: return UITableView.automaticDimension case 2: @@ -516,6 +520,10 @@ extension ReviewViewController: UITableViewDataSource { guard let self else { return } self.userTapReviewButton() } + cell.setTodayMenuFavoriteButtonVisible(todayMenuSlot != nil) + cell.onTapTodayMenuFavorite = { [weak self] in + self?.openTodayMenuFavorite() + } cell.reloadInputViews() return cell @@ -890,5 +898,25 @@ extension ReviewViewController: ReviewMenuTypeInfoDelegate { menuID = menuTypeData.menuID menuIDList = menuTypeData.changeMenuIDList restaurantName = menuTypeData.restaurantName + todayMenuSlot = TodayMenuSlot.forReview( + menuType: menuTypeData.menuType, + restaurantCode: menuTypeData.restaurantCode, + timePart: menuTypeData.timePart, + date: menuTypeData.date + ) + } +} + +// MARK: - Today Menu Favorite + +extension ReviewViewController { + + /// "오늘의 메뉴를 찜해보세요!": 알림을 받을 수 있는 상태면 찜 탭의 해당 식당·시간대 카드로 이동하고, + /// 아니면 그 자리에서 알림 허용 안내를 띄운다 (기능 명세) + private func openTodayMenuFavorite() { + guard let slot = todayMenuSlot, let tabBar = tabBarContainer else { return } + NotificationPermissionPrompt.ensureFavoriteNotificationAllowed(on: tabBar) { + tabBar.showTodayMenuFavorite(slot: slot) + } } } diff --git a/EATSSU/App/Sources/Presentation/TabBar/CustomTabBarContainerController.swift b/EATSSU/App/Sources/Presentation/TabBar/CustomTabBarContainerController.swift index f7cc2343..567d294b 100644 --- a/EATSSU/App/Sources/Presentation/TabBar/CustomTabBarContainerController.swift +++ b/EATSSU/App/Sources/Presentation/TabBar/CustomTabBarContainerController.swift @@ -134,6 +134,14 @@ final class CustomTabBarContainerController: UITabBarController { setTab(index: Tab.like.rawValue) } + /// 리뷰 화면 "오늘의 메뉴를 찜해보세요!" → 찜 탭(메뉴 찜)으로 전환해 해당 식당·시간대 카드를 펼친다 + public func showTodayMenuFavorite(slot: TodayMenuSlot) { + guard let likeVC = getNavController(at: Tab.like.rawValue)?.viewControllers.first as? LikeViewController else { return } + getNavController(at: Tab.like.rawValue)?.popToRootViewController(animated: false) + likeVC.showTodayMenu(slot: slot) + setTab(index: Tab.like.rawValue) + } + /// 찜 탭의 뒤로가기 → 지도 탭 복귀 public func returnToMapTab() { setTab(index: Tab.map.rawValue) diff --git a/EATSSU/App/Sources/Utility/Literal/TextLiteral.swift b/EATSSU/App/Sources/Utility/Literal/TextLiteral.swift index dfc83d11..21a3a5a0 100644 --- a/EATSSU/App/Sources/Utility/Literal/TextLiteral.swift +++ b/EATSSU/App/Sources/Utility/Literal/TextLiteral.swift @@ -1099,6 +1099,11 @@ enum TextLiteral { Localization.localized("review.todayMenu", fallback: "오늘의 메뉴") } + /// "오늘의 메뉴를 찜해보세요!" (오늘 식단일 때만 보이는 찜 탭 이동 버튼) + static var todayMenuFavoritePrompt: String { + Localization.localized("review.todayMenuFavoritePrompt", fallback: "오늘의 메뉴를 찜해보세요!") + } + /// ReviewRateViewCell - "5점" static var fiveStars: String { Localization.localized("review.fiveStars", fallback: "5점") @@ -1265,6 +1270,16 @@ enum TextLiteral { static var settingsMessage: String { Localization.localized("notification.settingsMessage", fallback: "메뉴 찜 기능을 이용하려면 기기 설정에서 잇슈 알림을 허용해주세요.") } + + /// "메뉴 찜 알림을 허용해주세요" + static var favoriteRequestTitle: String { + Localization.localized("notification.favoriteRequestTitle", fallback: "메뉴 찜 알림을 허용해주세요") + } + + /// "찜한 메뉴가 학식에 나오면 가장 먼저 알려드릴게요." + static var favoriteRequestMessage: String { + Localization.localized("notification.favoriteRequestMessage", fallback: "찜한 메뉴가 학식에 나오면 가장 먼저 알려드릴게요.") + } } // MARK: - Restaurant diff --git a/EATSSU/Tests/UnitTests/TodayMenuSlotTests.swift b/EATSSU/Tests/UnitTests/TodayMenuSlotTests.swift index 7f4fc21a..4b21e282 100644 --- a/EATSSU/Tests/UnitTests/TodayMenuSlotTests.swift +++ b/EATSSU/Tests/UnitTests/TodayMenuSlotTests.swift @@ -32,6 +32,19 @@ final class TodayMenuSlotTests: XCTestCase { XCTAssertTrue(TodayMenuSlot.isAvailable(restaurant: .facultyRestaurant, mealTime: .lunch)) } + func test_리뷰_화면_버튼은_오늘_변동식단_찜_대상_식당일_때만() { + let now = Date() + let yesterday = Calendar.current.date(byAdding: .day, value: -1, to: now)! + XCTAssertEqual( + TodayMenuSlot.forReview(menuType: "VARIABLE", restaurantCode: "DODAM", timePart: "DINNER", date: now, now: now), + TodayMenuSlot(restaurant: .dodamRestaurant, mealTime: .dinner) + ) + XCTAssertNil(TodayMenuSlot.forReview(menuType: "VARIABLE", restaurantCode: "DODAM", timePart: "DINNER", date: yesterday, now: now), "어제 식단") + XCTAssertNil(TodayMenuSlot.forReview(menuType: "FIXED", restaurantCode: "SNACK_CORNER", timePart: "LUNCH", date: now, now: now), "스낵코너") + XCTAssertNil(TodayMenuSlot.forReview(menuType: "VARIABLE", restaurantCode: "HAKSIK", timePart: nil, date: now, now: now), "시간대 없음") + XCTAssertNil(TodayMenuSlot.forReview(menuType: "VARIABLE", restaurantCode: "FOOD_COURT", timePart: "LUNCH", date: now, now: now), "앱에 없는 식당") + } + func test_시간대_탭_인덱스와_서버_값() { XCTAssertEqual(MealTimePart(rawValue: "LUNCH")?.tabIndex, 1) XCTAssertEqual(MealTimePart.allCases.map(\.tabIndex), [0, 1, 2])