Skip to content

Commit 26b4736

Browse files
committed
[FEAT] #7 프로필 구현완료
1 parent a8b409d commit 26b4736

File tree

3 files changed

+30
-18
lines changed

3 files changed

+30
-18
lines changed

Pinit/Pinit/Models/ProducerEntity.swift

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,59 +8,60 @@ import UIKit
88

99
struct ProducerEntity {
1010
//이름, 위,경도(지역), 생일, 각자사진, 소개, 문구, 기분(날씨)
11-
let name: String
11+
let title: String
1212
let latitude: Double
1313
let longitude: Double
1414
let date: Date
15-
let mediaPath: String
15+
let mediaPath: UIImage
1616
let description: String?
1717
let weather: String
1818

19+
1920
static let sampleData: [ProducerEntity] = [
2021
//데이터 부분들
2122

2223
ProducerEntity(
23-
name: "JustHm",
24+
title: "JustHm",
2425
latitude: 37.401848,
2526
longitude: 126.922736, //본인 지역의 의,경도
2627
date: Date(), //생년월일
27-
mediaPath: "JustHmImg",
28+
mediaPath: UIImage(named: "JustHMImg")!,
2829
description: "나는 누구 입니다1",
2930
weather: "구름"),
3031

3132
ProducerEntity(
32-
name: "Ikhwan0204",
33+
title: "Ikhwan0204",
3334
latitude: 37.502058,
3435
longitude: 126.672010, //본인 지역의 의,경도
3536
date: Date(), //생년월일
36-
mediaPath: "Ikhwan0204Img",
37+
mediaPath: UIImage(named: "Ikhwan0204Img")!,
3738
description: "나는 누구 입니다2",
3839
weather: "흐림"),
3940

4041
ProducerEntity(
41-
name: "IntakHan304",
42+
title: "IntakHan304",
4243
latitude: 37.557385,
4344
longitude: 126.956276, //본인 지역의 의,경도
4445
date: Date(), //생년월일
45-
mediaPath: "IntakHan304Img",
46+
mediaPath: UIImage(named: "IntakHan304Img")!,
4647
description: "나는 누구 입니다3",
4748
weather: ""),
4849

4950
ProducerEntity(
50-
name: "HISEHOONAN",
51+
title: "HISEHOONAN",
5152
latitude: 38.078549,
5253
longitude: 128.616008, //본인 지역의 의,경도
5354
date: Date(), //생년월일
54-
mediaPath: "HISEHOONANImg" ,
55+
mediaPath: UIImage(named: "HISEHOONImg")! ,
5556
description: "나는 누구 입니다4",
5657
weather: ""),
5758

5859
ProducerEntity(
59-
name: "kut7728",
60+
title: "kut7728",
6061
latitude: 37.484679,
6162
longitude: 126.897968, //본인 지역의 의,경도
6263
date: Date(), //생년월일
63-
mediaPath: "kut7728Img" ,
64+
mediaPath: UIImage(named: "kut7728Img")! ,
6465
description: "나는 누구 입니다5",
6566
weather: "맑음")
6667
]

Pinit/Pinit/Views/Setting/ProducerCollectionViewCell.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class ProducerCollectionViewCell : UICollectionViewCell {
2020

2121
public lazy var thumbnailImageView: UIImageView = {
2222
let imageView = UIImageView()
23-
imageView.contentMode = .scaleAspectFit
23+
imageView.contentMode = .scaleAspectFill
2424
imageView.backgroundColor = .lightGray
2525
return imageView
2626
}()
@@ -42,11 +42,11 @@ class ProducerCollectionViewCell : UICollectionViewCell {
4242
}()
4343

4444
func configure(model: ProducerEntity) {
45-
dateLabel.text = model.date.formatted()
46-
titleLabel.text = model.name
45+
dateLabel.text = model.date.snakeCaseDateString()
46+
titleLabel.text = model.title
4747
//thumbnailImageView.image = UIImage(systemName: "house")
4848
//프로필에 지정한 이미지가 없다면 기본이미지로 집모양으로 들어간다
49-
thumbnailImageView.image = UIImage(named: model.mediaPath)
49+
thumbnailImageView.image = model.mediaPath
5050
//model.mediaPath ?? UIImage(systemName: "house")
5151
cellSetting()
5252
} //모델(SettingView의 data)에서 데이터 가져오는 부분

Pinit/Pinit/Views/Setting/SettingViewController.swift

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,16 @@ final class SettingViewController: UIViewController {
1414

1515
private let resetButton = UIButton()
1616
private var produceCollectionView : UICollectionView = {
17+
1718
var layout = UICollectionViewFlowLayout()
18-
layout.minimumLineSpacing = 0
1919
layout.scrollDirection = .vertical
2020
layout.sectionInset = .zero
21+
let spacing = 5.0
22+
var width: CGFloat = UIScreen.main.bounds.width
23+
width = (width / 2) - (spacing * 1.5)
24+
layout.itemSize = .init(width: width, height: width * 1.23)
25+
layout.minimumInteritemSpacing = spacing
26+
layout.sectionInset = .init(top: 0, left: spacing, bottom: spacing, right: spacing)
2127

2228
let cv = UICollectionView(frame: .zero, collectionViewLayout: layout)
2329
return cv
@@ -63,6 +69,11 @@ final class SettingViewController: UIViewController {
6369

6470
extension SettingViewController : UICollectionViewDelegate, UICollectionViewDelegateFlowLayout, UICollectionViewDataSource {
6571

72+
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
73+
let detailVC = PinDetailViewController()
74+
present(detailVC, animated: true ,completion: nil )
75+
}
76+
6677
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { //컬랙션 뷰의 셀 갯수
6778
return data.count
6879
}
@@ -73,7 +84,7 @@ extension SettingViewController : UICollectionViewDelegate, UICollectionViewDele
7384
return UICollectionViewCell()
7485
}
7586
cell.configure(model: data[indexPath.row])
76-
cell.backgroundColor = .none
87+
7788

7889
return cell
7990
}

0 commit comments

Comments
 (0)