Skip to content

Commit ee651e9

Browse files
committed
[CHORE] #20 버튼 및 Entity 수정
1 parent 00c8ef8 commit ee651e9

3 files changed

Lines changed: 74 additions & 57 deletions

File tree

Pinit/Pinit/Models/ProducerEntity.swift

Lines changed: 59 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -6,63 +6,83 @@
66
//
77
import UIKit
88

9-
struct ProducerEntity {
10-
//이름, 위,경도(지역), 생일, 각자사진, 소개, 문구, 기분(날씨)
11-
let title: String
12-
let latitude: Double
13-
let longitude: Double
14-
let date: String
15-
let mediaPath: UIImage
16-
let description: String?
17-
let weather: String
9+
extension PinEntity {
10+
11+
private static func toDate(_ dateString: String)-> Date {
12+
let dateFormatter = DateFormatter()
13+
dateFormatter.dateFormat = "yyyy-MM-dd"
14+
dateFormatter.timeZone = TimeZone.current // 현재 시간대 사용
15+
dateFormatter.locale = Locale(identifier: "ko_KR") // 한국 로캘 설정 (선택사항)
16+
17+
if let date = dateFormatter.date(from: dateString) {
18+
return date
19+
}else{
20+
return Date()
21+
}
22+
}
1823

1924

20-
static let sampleData: [ProducerEntity] = [
25+
static let producerData: [PinEntity] = [
2126
//데이터 부분들
2227

23-
ProducerEntity(
28+
PinEntity(
29+
pin_id: UUID(),
2430
title: "JustHm",
2531
latitude: 37.9244577,
26-
longitude: 128.800009, //본인 지역의 의,경도
27-
date: "1998-05-01", //생년월일
28-
mediaPath: UIImage(named: "JustHMImg")!,
29-
description: "안녕하세요 ! 감자 개발자 안정흠입니다!",//istj
30-
weather: "구름"),
32+
longitude: 128.800009,//본인 지역의 의,경도
33+
address: "",
34+
date: toDate("1998-05-01"), //생년월일
35+
weather: "istj",
36+
description: "안녕하세요 ! 감자 개발자 안정흠입니다!",
37+
mediaPath: UIImage(named: "JustHMImg")!
38+
),
3139

32-
ProducerEntity(
40+
PinEntity(
41+
pin_id: UUID(),
3342
title: "Ikhwan0204",
3443
latitude: 37.506610,
35-
longitude: 126.885332, //본인 지역의 의,경도
36-
date: "2002-04-12", //생년월일
37-
mediaPath: UIImage(named: "Ikhwan0204Img")!,
38-
description: "개발개바발 개발자 이규현입니다.ㅎㅎㅎ", //enfj
39-
weather: "흐림"),
44+
longitude: 126.885332,
45+
address: "",
46+
date: toDate("2002-04-12"),
47+
weather: "enfj",
48+
description: "개발개바발 개발자 이규현입니다.ㅎㅎㅎ",
49+
mediaPath: UIImage(named: "Ikhwan0204Img")!
50+
),
4051

41-
ProducerEntity(
52+
PinEntity(
53+
pin_id: UUID(),
4254
title: "IntakHan304",
4355
latitude: 37.434981,
44-
longitude: 126.902328, //본인 지역의 의,경도
45-
date: "1991-03-04", //생년월일
46-
mediaPath: UIImage(named: "IntakHan304Img")!,
47-
description: "나는 누구 입니다3",
48-
weather: ""),
56+
longitude: 126.902328,
57+
address: "",
58+
date: toDate("1991-03-04"),
59+
weather: "infj" ,
60+
description: "처음 시작하는 개발자 한인탁 입니다.",
61+
mediaPath: UIImage(named: "IntakHan304Img")!
62+
),
4963

50-
ProducerEntity(
64+
PinEntity(
65+
pin_id: UUID(),
5166
title: "HISEHOONAN",
5267
latitude: 37.508645,
53-
longitude: 126.703513, //본인 지역의 의,경도
54-
date: "1998.06.17", //생년월일
55-
mediaPath: UIImage(named: "HISEHOONImg")! ,
56-
description: "안녕하세요 ! 개발새발 개발자 안세훈입니다 !",//infp
57-
weather: ""),
68+
longitude: 126.703513,
69+
address: "",
70+
date: toDate("1999.06.17"),
71+
weather: "infp",
72+
description: "안녕하세요 ! 개발새발 개발자 안세훈입니다 ! ",
73+
mediaPath: UIImage(named: "HISEHOONImg")!
74+
),
5875

59-
ProducerEntity(
76+
PinEntity(
77+
pin_id: UUID(),
6078
title: "kut7728",
6179
latitude: 37.554267,
6280
longitude: 126.953922, //본인 지역의 의,경도
63-
date: "1998.03.02", //생년월일
64-
mediaPath: UIImage(named: "kut7728Img")! ,
65-
description: "네이티브 앱, 애플, 테크기기에 관심이 많은 앱 개발자(지망)입니다.", //infj
66-
weather: "맑음")
81+
address: "",
82+
date: toDate("1998.03.02"), //생년월일
83+
weather: "intj",
84+
description: "네이티브 앱, 애플, 테크기기에 관심이 많은 앱 개발자(지망)입니다.", //
85+
mediaPath: UIImage(named: "kut7728Img")!
86+
)
6787
]
6888
}

Pinit/Pinit/Views/Setting/ProducerCollectionViewCell.swift

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,9 @@ class ProducerCollectionViewCell : UICollectionViewCell {
4141
return label
4242
}()
4343

44-
func configure(model: ProducerEntity) {
45-
let myFormatter = DateFormatter()
46-
myFormatter.dateFormat = "yyyy-MM-dd" // String의 문자열 형식과 동일 해야함
47-
48-
let birDate = myFormatter.date(from: model.date)! //생일 데이터를 불러온다
49-
50-
dateLabel.text = birDate.snakeCaseDateString()
44+
func configure(model: PinEntity) {
45+
46+
dateLabel.text = model.date.snakeCaseDateString()
5147
titleLabel.text = model.title
5248
thumbnailImageView.image = model.mediaPath
5349

Pinit/Pinit/Views/Setting/SettingViewController.swift

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import UIKit
99

1010
final class SettingViewController: UIViewController {
11-
var data: [ProducerEntity] = ProducerEntity.sampleData
11+
var data: [PinEntity] = PinEntity.producerData
1212
//모델에서 데이터를 가져옴
1313

1414
private let resetButton = UIButton()
@@ -43,14 +43,14 @@ final class SettingViewController: UIViewController {
4343
resetButton.titleLabel?.font = DesignSystemFont.Pretendard_Medium18.value
4444
resetButton.addTarget(self, action: #selector(resetAlert), for: .touchUpInside)
4545

46-
resetButton.setTitleColor(.red, for: .normal)
46+
resetButton.setTitleColor(.white, for: .normal)
4747

48-
resetButton.backgroundColor = .white
48+
resetButton.backgroundColor = .red
4949
resetButton.layer.cornerRadius = 10
5050

5151
resetButton.layer.masksToBounds = false
52-
resetButton.layer.shadowOpacity = 0.5
53-
resetButton.layer.shadowOffset = CGSize(width: 0, height: 4)
52+
//resetButton.layer.shadowOpacity = 0.5
53+
//resetButton.layer.shadowOffset = CGSize(width: 0, height: 4)
5454

5555
autoLayout()
5656
produceCollectionView.register(ProducerCollectionViewCell.self, forCellWithReuseIdentifier: "cell")
@@ -104,15 +104,16 @@ extension SettingViewController : UICollectionViewDelegate, UICollectionViewDele
104104
extension SettingViewController {
105105
private func autoLayout() {
106106
resetButton.snp.makeConstraints {
107-
$0.centerX.equalToSuperview()
108-
$0.bottom.equalToSuperview().offset(-90)
109-
$0.height.equalTo(50)
110-
$0.leading.equalTo(10)
107+
$0.bottom.equalTo(view.safeAreaLayoutGuide)
108+
$0.height.equalTo(70)
109+
$0.leading.equalToSuperview().inset(10)
110+
$0.trailing.equalToSuperview().offset(-10)
111111
}
112112
//컬렉션 뷰 제약 설정 부분 예정
113113
produceCollectionView.snp.makeConstraints {
114-
$0.edges.equalTo(view.safeAreaLayoutGuide)
115-
$0.bottom.equalTo(resetButton.snp.top).offset(-30)
114+
$0.top.equalTo(view.safeAreaLayoutGuide).inset(10)
115+
$0.width.equalToSuperview()
116+
$0.bottom.equalTo(resetButton.snp.top)
116117
}
117118
}
118119
}

0 commit comments

Comments
 (0)