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
6 changes: 6 additions & 0 deletions EATSSU/App/Resources/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -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점"
Expand Down Expand Up @@ -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: - Notification Inbox (알림함)

/// "알림"
Expand Down
6 changes: 6 additions & 0 deletions EATSSU/App/Resources/ja.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,8 @@
"review.reviewCount" = "レビュー %d件";
/// ReviewRateViewCell - "오늘의 메뉴"
"review.todayMenu" = "今日のメニュー";
/// "오늘의 메뉴를 찜해보세요!"
"review.todayMenuFavoritePrompt" = "今日のメニューをお気に入りに追加!";
/// ReviewRateViewCell - "5점"
"review.fiveStars" = "5点";
/// ReviewRateViewCell - "4점"
Expand Down Expand Up @@ -481,6 +483,10 @@
"notification.settingsTitle" = "通知がオフになっています";
/// "메뉴 찜 기능을 이용하려면 기기 설정에서 잇슈 알림을 허용해주세요."
"notification.settingsMessage" = "お気に入り機能を使うには、端末の設定でEAT-SSUの通知を許可してください。";
/// "메뉴 찜 알림을 허용해주세요"
"notification.favoriteRequestTitle" = "お気に入り通知を許可してください";
/// "찜한 메뉴가 학식에 나오면 가장 먼저 알려드릴게요."
"notification.favoriteRequestMessage" = "お気に入りメニューが出たら最初にお知らせします。";
// MARK: - Notification Inbox (알림함)

/// "알림"
Expand Down
6 changes: 6 additions & 0 deletions EATSSU/App/Resources/ko.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,8 @@
"review.reviewCount" = "리뷰 %d";
/// ReviewRateViewCell - "오늘의 메뉴"
"review.todayMenu" = "오늘의 메뉴";
/// "오늘의 메뉴를 찜해보세요!"
"review.todayMenuFavoritePrompt" = "오늘의 메뉴를 찜해보세요!";
/// ReviewRateViewCell - "5점"
"review.fiveStars" = "5점";
/// ReviewRateViewCell - "4점"
Expand Down Expand Up @@ -481,6 +483,10 @@
"notification.settingsTitle" = "알림 권한이 꺼져 있어요";
/// "메뉴 찜 기능을 이용하려면 기기 설정에서 잇슈 알림을 허용해주세요."
"notification.settingsMessage" = "메뉴 찜 기능을 이용하려면 기기 설정에서 잇슈 알림을 허용해주세요.";
/// "메뉴 찜 알림을 허용해주세요"
"notification.favoriteRequestTitle" = "메뉴 찜 알림을 허용해주세요";
/// "찜한 메뉴가 학식에 나오면 가장 먼저 알려드릴게요."
"notification.favoriteRequestMessage" = "찜한 메뉴가 학식에 나오면 가장 먼저 알려드릴게요.";
// MARK: - Notification Inbox (알림함)

/// "알림"
Expand Down
6 changes: 6 additions & 0 deletions EATSSU/App/Resources/vi.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -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점"
Expand Down Expand Up @@ -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: - Notification Inbox (알림함)

/// "알림"
Expand Down
33 changes: 33 additions & 0 deletions EATSSU/App/Sources/Notification/NotificationPermissionPrompt.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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?
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ final class HomeRestaurantViewController: BaseViewController {
// 리뷰 작성 뷰로 데이터 전달할 델리게이트
var delegate: ReviewMenuTypeInfoDelegate?

/// 마지막으로 조회한 식단의 날짜·시간대. 리뷰 화면이 "오늘 식단인지" 판단하는 데 넘긴다
private var displayedDate: Date?
private var displayedTimePart: String?

// 고정 메뉴 더미 데이터 (주말/방학 대비용)
private let fixedDummy = FixedMenuInfoData.Dummy()

Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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],
Expand Down
13 changes: 13 additions & 0 deletions EATSSU/App/Sources/Presentation/Like/Model/TodayMenuSlot.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

/// 별점 섹션 컨테이너
Expand Down Expand Up @@ -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

/// 별점 레이블 생성 헬퍼
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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)
}
Expand Down
Loading
Loading