Skip to content

Commit c3253c9

Browse files
committed
[FEAT] #25 Rematching PinEditVC and Add ViewType on Variables
1 parent 986251e commit c3253c9

File tree

2 files changed

+145
-120
lines changed

2 files changed

+145
-120
lines changed

Pinit/Pinit/Views/PastPin/PastPinViewController.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ final class PastPinViewController: UIViewController {
1313

1414
//MARK: - 모든 PinEntity를 가져옵니다.
1515
let pinData = PinEntity.sampleData
16+
let pinEntity = PinEntity.self
17+
1618
private let usecase: UseCase
1719

1820
//MARK: - properties
@@ -137,7 +139,8 @@ extension PastPinViewController : FSCalendarDelegate, FSCalendarDataSource, FSCa
137139
extension PastPinViewController : PinCollectionViewAdapterDelegate {
138140

139141
func selectedItem(selected: PinEntity) { //화면 이동
140-
print("selectedItem")
142+
let vc = PinDetailViewController(selected)
143+
self.present(vc, animated: true)
141144
}
142145

143146
func deletedItem(deleted: PinEntity?) { //아이템 삭제 클릭시

Pinit/Pinit/Views/PinEdit/PinEditViewController.swift

Lines changed: 141 additions & 119 deletions
Original file line numberDiff line numberDiff line change
@@ -2,174 +2,191 @@
22
// PinEditViewController.swift
33
// Pinit
44
//
5-
// Created by 안정흠이형메롱메롱메롱메롱바보바보바바바바보바보바보 on 3/12/25.
6-
// 푸시할때 조심 씬델리게이트 바꿔라
5+
// Created by 안정흠 on 3/12/25.
6+
// Edited by 안세훈 on 3/21/25 lol
77

88
import UIKit
99
import MapKit
1010
import SnapKit
1111

1212
enum PinMode {
1313
case create(latitude: Double, longtitude: Double)
14-
case edit
14+
case edit(PinEntity : PinEntity)
1515
}
1616

1717
final class PinEditViewController: UIViewController, UITextViewDelegate {
1818

19-
private var mapView: MKMapView!
20-
private let pinmode: PinMode = .edit
19+
var pinmode: PinMode?
2120

22-
override func viewDidLoad() {
23-
super.viewDidLoad()
24-
25-
view.backgroundColor = .white
26-
27-
switch pinmode {
28-
case let .create(latitude, longtitude):
29-
print("\(latitude), \(longtitude)")
30-
case .edit:
31-
print("편집 모드입니다")
32-
}
33-
34-
//MARK: mapView 설정
35-
mapView = MKMapView(frame: self.view.bounds) //mkmapview 초기화 및 뷰 추가함
36-
mapView = MKMapView(frame: CGRect(x: 0, y: 60, width: self.view.bounds.width, height: self.view.bounds.height / 4)) //화면의 1/4만 나오게 함
37-
self.view.addSubview(mapView) //mapview 뷰에 보이게
38-
39-
setUpKeyboard()
40-
21+
private var mapView: MKMapView = {
22+
let view = MKMapView()
4123
let center = CLLocationCoordinate2D(latitude: 37.506446, longitude: 126.885397) //중심좌표
4224
let region = MKCoordinateRegion(center: center, span: MKCoordinateSpan(latitudeDelta: 0.05, longitudeDelta: 0.05))
43-
mapView.setRegion(region, animated: true)
44-
25+
view.setRegion(region, animated: true)
26+
return view
27+
}()
28+
29+
private let saveButton : UIButton = {
30+
let button = UIButton()
31+
button.backgroundColor = UIColor(red: 28/255, green: 70/255, blue: 245/255, alpha: 1) // #FF8C42 (딥 오렌지)
32+
button.setTitle("저장", for: .normal)
33+
button.layer.cornerRadius = 10
34+
return button
35+
}()
36+
37+
let contentTextView : UITextView = {
38+
let textview = UITextView()
39+
textview.backgroundColor = .white
40+
textview.layer.borderColor = UIColor(red: 169/255, green: 169/255, blue: 169/255, alpha: 1).cgColor // #A9A9A9 (다크 라이트 그레이)
41+
textview.layer.borderWidth = 2 // 테두리 두께 설정
42+
textview.layer.cornerRadius = 5
43+
textview.text = "남기고자 하는 메모가 있다면 작성해주세요."
44+
textview.textAlignment = .center
45+
textview.textColor = UIColor.black
46+
textview.font = UIFont.systemFont(ofSize: 16)
47+
return textview
48+
}()
49+
50+
private let titleTextField : UITextField = {
51+
let textfield = UITextField()
52+
textfield.layer.borderColor = UIColor(red: 169/255, green: 169/255, blue: 169/255, alpha: 1).cgColor
53+
textfield.layer.borderWidth = 2
54+
textfield.textColor = .black
55+
textfield.layer.cornerRadius = 5
56+
textfield.attributedPlaceholder = NSAttributedString(
57+
string: "제목 작성",
58+
attributes: [NSAttributedString.Key.foregroundColor: UIColor.black]
59+
)
60+
textfield.font = DesignSystemFont.Pretendard_Bold14
61+
.value
62+
textfield.leftView = UIView(frame: CGRect(x: 0, y: 0, width: 16, height: 0))
63+
textfield.leftViewMode = .always
64+
return textfield
65+
}()
66+
67+
private let cameraButton : UIButton = {
68+
let button = UIButton()
69+
//MARK: 아래 카메라 버튼
70+
button.backgroundColor = .white
71+
button.layer.cornerRadius = 75
72+
button.layer.shadowColor = UIColor.black.cgColor // 색깔
73+
button.layer.masksToBounds = false // 내부에 속한 요소들이 UIView 밖을 벗어날 때, 잘라낼 것인지. 그림자는 밖에 그려지는 것이므로 false 로 설정
74+
button.layer.shadowOffset = CGSize(width: 0, height: 4) // 위치조정
75+
button.layer.shadowRadius = 10 // 반경
76+
button.layer.shadowOpacity = 0.5
4577

78+
if let cameraImage = UIImage(systemName: "camera.on.rectangle"){
79+
let largeConfig = UIImage.SymbolConfiguration(pointSize: 60, weight: .regular, scale: .default)
80+
let largeImage = cameraImage.withConfiguration(largeConfig)
81+
button.setImage(largeImage, for: .normal)
82+
}
83+
button.tintColor = UIColor(red: 96/255, green: 99/255, blue: 104/255, alpha: 1)
84+
button.imageView?.contentMode = .scaleAspectFit
85+
button.addTarget(PinEditViewController.self, action: #selector(cameraButtonTapped), for: .touchUpInside)
86+
return button
87+
}()
88+
89+
private let weatherButton : UIButton = {
90+
let button = UIButton()
91+
button.layer.cornerRadius = 10
92+
button.setTitle("맑음", for: .normal)
93+
button.setTitleColor(UIColor.black, for: .normal) // 글자색을 검은색으로 변경
94+
return button
95+
}()
96+
97+
private let dateButton : UIButton = {
98+
let button = UIButton()
99+
button.backgroundColor = .clear
100+
button.layer.cornerRadius = 10
101+
button.setTitle("3월 17일", for: .normal)
102+
button.setTitleColor(UIColor.black, for: .normal)
103+
return button
104+
}()
105+
106+
private let closeButton : UIButton = {
107+
let button = UIButton()
46108
//MARK: 지도 오른쪽 위에 닫기 버튼 추가, xmark.circle.fill
47109
if let closeImage = UIImage(systemName: "xmark.circle.fill") {
48110
let largeConfig = UIImage.SymbolConfiguration(pointSize: 45, weight: .bold, scale: .default)
49111
let largeImage = closeImage.withConfiguration(largeConfig)
50-
closeButton.setImage(largeImage, for: .normal)
51-
}
52-
closeButton.tintColor = .black
53-
closeButton.alpha = 0.7 // 투명도 50% 설정
54-
closeButton.addTarget(self, action: #selector(dismissButtonTapped), for: .touchUpInside)
55-
56-
//MARK: 왼쪽 기록 날짜 버튼
57-
datebutton.backgroundColor = .clear
58-
datebutton.layer.cornerRadius = 10
59-
datebutton.setTitle("3월 17일", for: .normal) //for: .normal은 아무런 상호작용 없을때 상태
60-
datebutton.setTitleColor(UIColor.black, for: .normal) // 글자색을 검은색으로 변경
61-
62-
63-
//MARK: 오른쪽 날씨 버튼
64-
weatherbutton.layer.cornerRadius = 10
65-
weatherbutton.setTitle("맑음", for: .normal)
66-
weatherbutton.setTitleColor(UIColor.black, for: .normal) // 글자색을 검은색으로 변경
67-
68-
//MARK: 아래 카메라 버튼
69-
camerabutton.backgroundColor = .white
70-
camerabutton.layer.cornerRadius = 75
71-
camerabutton.layer.shadowColor = UIColor.black.cgColor // 색깔
72-
camerabutton.layer.masksToBounds = false // 내부에 속한 요소들이 UIView 밖을 벗어날 때, 잘라낼 것인지. 그림자는 밖에 그려지는 것이므로 false 로 설정
73-
camerabutton.layer.shadowOffset = CGSize(width: 0, height: 4) // 위치조정
74-
camerabutton.layer.shadowRadius = 10 // 반경
75-
camerabutton.layer.shadowOpacity = 0.5
76-
if let cameraImage = UIImage(systemName: "camera.on.rectangle"){
77-
let largeConfig = UIImage.SymbolConfiguration(pointSize: 60, weight: .regular, scale: .default)
78-
let largeImage = cameraImage.withConfiguration(largeConfig)
79-
camerabutton.setImage(largeImage, for: .normal)
112+
button.setImage(largeImage, for: .normal)
80113
}
81-
camerabutton.tintColor = UIColor(red: 96/255, green: 99/255, blue: 104/255, alpha: 1) // #606368 (다크 그레이)
82-
camerabutton.imageView?.contentMode = .scaleAspectFit
83-
84-
camerabutton.addTarget(self, action: #selector(cameraButtonTapped), for: .touchUpInside)
85-
86-
//MARK: 제목 작성 버튼
87-
titlefield.layer.borderColor = UIColor(red: 169/255, green: 169/255, blue: 169/255, alpha: 1).cgColor // #A9A9A9 (다크 라이트 그레이)
88-
titlefield.layer.borderWidth = 2 // 테두리 두께 설정
89-
titlefield.textColor = .black
90-
titlefield.layer.cornerRadius = 5
91-
titlefield.attributedPlaceholder = NSAttributedString(
92-
string: "제목 작성",
93-
attributes: [NSAttributedString.Key.foregroundColor: UIColor.black] //제목작성 글자 흰색으로
94-
)
95-
titlefield.font = DesignSystemFont.Pretendard_Bold14
96-
.value
97-
titlefield.leftView = UIView(frame: CGRect(x: 0, y: 0, width: 16, height: 0)) // 이거 개쩜 제목 작성 맨 앞에 여백을 주는거임
98-
titlefield.leftViewMode = .always //항상
99-
100-
//MARK: 추가메모 텍스트뷰 추가
101-
contentTextView.backgroundColor = .white
102-
contentTextView.layer.borderColor = UIColor(red: 169/255, green: 169/255, blue: 169/255, alpha: 1).cgColor // #A9A9A9 (다크 라이트 그레이)
103-
contentTextView.layer.borderWidth = 2 // 테두리 두께 설정
104-
contentTextView.layer.cornerRadius = 5
105-
contentTextView.text = "남기고자 하는 메모가 있다면 작성해주세요."
106-
contentTextView.textAlignment = .center
107-
contentTextView.textColor = UIColor.black
108-
contentTextView.font = UIFont.systemFont(ofSize: 16)
109-
110-
contentTextView.delegate = self
111-
112-
//MARK: 저장 버튼
113-
savebutton.backgroundColor = UIColor(red: 28/255, green: 70/255, blue: 245/255, alpha: 1) // #FF8C42 (딥 오렌지)
114-
savebutton.setTitle("저장", for: .normal)
115-
savebutton.layer.cornerRadius = 10
116-
setui()
117-
118-
119-
//MARK: 키보드 완료 버튼
120-
let keyboardToolbar = UIToolbar()
114+
button.tintColor = .black
115+
button.alpha = 0.7 // 투명도 50% 설정
116+
button.addTarget(PinEditViewController.self, action: #selector(dismissButtonTapped), for: .touchUpInside)
117+
return button
118+
}()
119+
120+
private let keyboardToolBar: UIToolbar = {
121+
let toolbar = UIToolbar()
121122
let flexBarButton = UIBarButtonItem(barButtonSystemItem: .flexibleSpace, target: nil, action: nil)
122-
let doneBarButton = UIBarButtonItem(title: "완료", style: .plain, target: self, action: #selector(doneBtnClicked))
123-
keyboardToolbar.items = [flexBarButton, doneBarButton]
124-
keyboardToolbar.sizeToFit()
125-
126-
titlefield.inputAccessoryView = keyboardToolbar
127-
contentTextView.inputAccessoryView = keyboardToolbar
128-
123+
let doneBarButton = UIBarButtonItem(title: "완료", style: .plain, target: PinEditViewController.self, action: #selector(doneBtnClicked))
124+
toolbar.items = [flexBarButton, doneBarButton]
125+
toolbar.sizeToFit()
126+
return toolbar
127+
}()
128+
129+
override func viewDidLoad() {
130+
super.viewDidLoad()
131+
view.backgroundColor = .white
132+
SetUI()
133+
SetMap()
134+
viewmode()
135+
setUpKeyboard()
129136
}
130137

131-
//MARK: 오토레이아웃 정리
132-
let savebutton = UIButton()
133-
let contentTextView = UITextView()
134-
let titlefield = UITextField()
135-
let camerabutton = UIButton()
136-
let weatherbutton = UIButton()
137-
private let datebutton = UIButton()
138-
let closeButton = UIButton(type: .system)
139-
func setui() {
140-
self.view.addSubviews(savebutton, contentTextView, titlefield, camerabutton, weatherbutton, datebutton, closeButton)
138+
139+
func viewmode(){
140+
switch pinmode {
141+
case let .create(latitude, longtitude):
142+
print("\(latitude), \(longtitude)")
143+
case let .edit(PinEntity):
144+
print(PinEntity)
145+
// titleTextField.text = PinEntity.description
146+
print("편집 모드입니다")
147+
case .none:
148+
print("?")
149+
}
150+
}
151+
152+
private func SetUI() {
153+
titleTextField.inputAccessoryView = keyboardToolBar
154+
contentTextView.inputAccessoryView = keyboardToolBar
155+
contentTextView.delegate = self
156+
157+
self.view.addSubviews(mapView, saveButton, contentTextView, titleTextField, cameraButton, weatherButton, dateButton, closeButton)
141158

142-
savebutton.snp.makeConstraints{
159+
saveButton.snp.makeConstraints{
143160
$0.leading.equalToSuperview().offset(130)
144161
$0.top.equalToSuperview().offset(760)
145162
$0.width.equalTo(150)
146163
$0.height.equalTo(55)
147164
}
148165
contentTextView.snp.makeConstraints {
149166
$0.leading.equalToSuperview().offset(20)
150-
$0.top.equalTo(titlefield.snp.bottom).offset(10)
167+
$0.top.equalTo(titleTextField.snp.bottom).offset(10)
151168
$0.width.equalTo(360)
152169
$0.height.equalTo(150)
153170
}
154-
titlefield.snp.makeConstraints{
171+
titleTextField.snp.makeConstraints{
155172
$0.leading.equalToSuperview().offset(20)
156173
$0.top.equalToSuperview().offset(540)
157174
$0.width.equalTo(360)
158175
$0.height.equalTo(40)
159176
}
160-
camerabutton.snp.makeConstraints{
177+
cameraButton.snp.makeConstraints{
161178
$0.centerX.equalToSuperview()
162179
$0.centerY.equalToSuperview()
163180
$0.width.equalTo(150)
164181
$0.height.equalTo(150)
165182
}
166-
weatherbutton.snp.makeConstraints{
183+
weatherButton.snp.makeConstraints{
167184
$0.leading.equalToSuperview().offset(210)
168185
$0.top.equalToSuperview().offset(300)
169186
$0.width.equalTo(180)
170187
$0.height.equalTo(30)
171188
}
172-
datebutton.snp.makeConstraints{
189+
dateButton.snp.makeConstraints{
173190
$0.leading.equalToSuperview().offset(10)
174191
$0.top.equalToSuperview().offset(300)
175192
$0.width.equalTo(180)
@@ -182,6 +199,11 @@ final class PinEditViewController: UIViewController, UITextViewDelegate {
182199
}
183200
}
184201

202+
private func SetMap(){
203+
mapView = MKMapView(frame: self.view.bounds)
204+
mapView = MKMapView(frame: CGRect(x: 0, y: 60, width: self.view.bounds.width, height: self.view.bounds.height / 4))
205+
}
206+
185207
//MARK: 키보드 닫기
186208
@objc func doneBtnClicked() {
187209
view.endEditing(true)

0 commit comments

Comments
 (0)