-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathRestaurantInfoViewController.swift
More file actions
76 lines (61 loc) ยท 2.23 KB
/
Copy pathRestaurantInfoViewController.swift
File metadata and controls
76 lines (61 loc) ยท 2.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
//
// RestaurantInfoViewController.swift
// EatSSU-iOS
//
// Created by ์ต์ง์ฐ on 2023/08/29.
//
import UIKit
import SnapKit
import Moya
final class RestaurantInfoViewController: BaseViewController {
// MARK: - UI Components
private let restaurantInfoView = RestaurantInfoView()
// MARK: - Functions
override func configureUI() {
view.addSubview(restaurantInfoView)
}
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
logScreenView(screenID: FirebaseScreenID.Home.home2)
}
override func setLayout() {
restaurantInfoView.snp.makeConstraints {
$0.edges.equalToSuperview()
}
}
/// ์ปจํ
์ธ ์ ๋ง๋ ์ํธ ๋์ด (๋ง์ง๋ง ํ
์คํธ ์๋ ์ฌ๋ฐฑ 54, ์ธ์ดํ์๋ฆฌ์ด ํฌํจ)
func calculatePreferredHeight() -> CGFloat {
let targetSize = CGSize(width: view.bounds.width, height: UIView.layoutFittingCompressedSize.height)
return view.systemLayoutSizeFitting(
targetSize,
withHorizontalFittingPriority: .required,
verticalFittingPriority: .fittingSizeLevel
).height
}
}
// MARK: - RestaurantInfoDelegate
extension RestaurantInfoViewController: RestaurantInfoDelegate {
func didTappedRestaurantInfo(restaurantName: String) {
restaurantInfoView.restaurantNameLabel.text = restaurantName
let koreanName = koreanRestaurantName(from: restaurantName)
if let restaurantInfo = RestaurantInfoData.restaurantInfoData.first(where: { $0.name == koreanName }) {
restaurantInfoView.bind(data: restaurantInfo)
}
}
private func koreanRestaurantName(from name: String) -> String {
switch name {
case TextLiteral.Restaurant.dodamRestaurant:
return "๋๋ด ์๋น"
case TextLiteral.Restaurant.studentRestaurant:
return "ํ์ ์๋น"
case TextLiteral.Restaurant.snackCorner:
return "์ค๋ต ์ฝ๋"
case TextLiteral.Restaurant.dormitoryRestaurant:
return "๊ธฐ์์ฌ ์๋น"
case TextLiteral.Restaurant.facultyRestaurant:
return "FACULTY (๊ต์ง์ ์ ์ฉ)"
default:
return name
}
}
}