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
110 changes: 65 additions & 45 deletions Pinit/Pinit/Models/ProducerEntity.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,63 +6,83 @@
//
import UIKit

struct ProducerEntity {
//이름, 위,경도(지역), 생일, 각자사진, 소개, 문구, 기분(날씨)
let title: String
let latitude: Double
let longitude: Double
let date: Date
let mediaPath: UIImage
let description: String?
let weather: String
extension PinEntity {

private static func toDate(_ dateString: String)-> Date {
let dateFormatter = DateFormatter()
dateFormatter.dateFormat = "yyyy-MM-dd"
dateFormatter.timeZone = TimeZone.current // 현재 시간대 사용
dateFormatter.locale = Locale(identifier: "ko_KR") // 한국 로캘 설정 (선택사항)

if let date = dateFormatter.date(from: dateString) {
return date
}else{
return Date()
}
}


static let sampleData: [ProducerEntity] = [
static let producerData: [PinEntity] = [
//데이터 부분들

ProducerEntity(
PinEntity(
pin_id: UUID(),
title: "JustHm",
latitude: 37.401848,
longitude: 126.922736, //본인 지역의 의,경도
date: Date(), //생년월일
mediaPath: UIImage(named: "JustHMImg")!,
description: "나는 누구 입니다1",
weather: "구름"),
latitude: 37.9244577,
longitude: 128.800009,//본인 지역의 의,경도
address: "",
date: toDate("1998-05-01"), //생년월일
weather: "istj",
description: "안녕하세요 ! 감자 개발자 안정흠입니다!",
mediaPath: UIImage(named: "JustHMImg")!
),

ProducerEntity(
PinEntity(
pin_id: UUID(),
title: "Ikhwan0204",
latitude: 37.502058,
longitude: 126.672010, //본인 지역의 의,경도
date: Date(), //생년월일
mediaPath: UIImage(named: "Ikhwan0204Img")!,
description: "나는 누구 입니다2",
weather: "흐림"),
latitude: 37.506610,
longitude: 126.885332,
address: "",
date: toDate("2002-04-12"),
weather: "enfj",
description: "개발개바발 개발자 이규현입니다.ㅎㅎㅎ",
mediaPath: UIImage(named: "Ikhwan0204Img")!
),

ProducerEntity(
PinEntity(
pin_id: UUID(),
title: "IntakHan304",
latitude: 37.557385,
longitude: 126.956276, //본인 지역의 의,경도
date: Date(), //생년월일
mediaPath: UIImage(named: "IntakHan304Img")!,
description: "나는 누구 입니다3",
weather: "비"),
latitude: 37.434981,
longitude: 126.902328,
address: "",
date: toDate("1991-03-04"),
weather: "infj" ,
description: "처음 시작하는 개발자 한인탁 입니다.",
mediaPath: UIImage(named: "IntakHan304Img")!
),

ProducerEntity(
PinEntity(
pin_id: UUID(),
title: "HISEHOONAN",
latitude: 38.078549,
longitude: 128.616008, //본인 지역의 의,경도
date: Date(), //생년월일
mediaPath: UIImage(named: "HISEHOONImg")! ,
description: "나는 누구 입니다4",
weather: "눈"),
latitude: 37.508645,
longitude: 126.703513,
address: "",
date: toDate("1999.06.17"),
weather: "infp",
description: "안녕하세요 ! 개발새발 개발자 안세훈입니다 ! ",
mediaPath: UIImage(named: "HISEHOONImg")!
),

ProducerEntity(
PinEntity(
pin_id: UUID(),
title: "kut7728",
latitude: 37.484679,
longitude: 126.897968, //본인 지역의 의,경도
date: Date(), //생년월일
mediaPath: UIImage(named: "kut7728Img")! ,
description: "나는 누구 입니다5",
weather: "맑음")
latitude: 37.554267,
longitude: 126.953922, //본인 지역의 의,경도
address: "",
date: toDate("1998.03.02"), //생년월일
weather: "intj",
description: "네이티브 앱, 애플, 테크기기에 관심이 많은 앱 개발자(지망)입니다.", //
mediaPath: UIImage(named: "kut7728Img")!
)
]
}
8 changes: 3 additions & 5 deletions Pinit/Pinit/Views/Setting/ProducerCollectionViewCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,12 @@ class ProducerCollectionViewCell : UICollectionViewCell {
return label
}()

func configure(model: ProducerEntity) {
func configure(model: PinEntity) {

dateLabel.text = model.date.snakeCaseDateString()
titleLabel.text = model.title
//thumbnailImageView.image = UIImage(systemName: "house")
//프로필에 지정한 이미지가 없다면 기본이미지로 집모양으로 들어간다
thumbnailImageView.image = model.mediaPath
//model.mediaPath ?? UIImage(systemName: "house")

cellSetting()
} //모델(SettingView의 data)에서 데이터 가져오는 부분

Expand All @@ -74,7 +73,6 @@ class ProducerCollectionViewCell : UICollectionViewCell {

contentView.addSubviews(thumbnailImageView, titleLabel, dateLabel)

//img.contentMode = .scaleToFill
thumbnailImageView.snp.remakeConstraints {
$0.top.leading.trailing.equalToSuperview().inset(8)
$0.height.equalTo(contentView.frame.width * 0.76)
Expand Down
38 changes: 20 additions & 18 deletions Pinit/Pinit/Views/Setting/SettingViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@
// Created by 안정흠 on 3/12/25.
//


import UIKit

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

private let resetButton = UIButton()
Expand Down Expand Up @@ -41,8 +40,17 @@ final class SettingViewController: UIViewController {

//버튼 레이아웃 설정
resetButton.setTitle("전체 기록 삭제", for: .normal)
resetButton.titleLabel?.font = DesignSystemFont.Pretendard_Medium18.value
resetButton.addTarget(self, action: #selector(resetAlert), for: .touchUpInside)
resetButton.backgroundColor = .lightGray

resetButton.setTitleColor(.white, for: .normal)

resetButton.backgroundColor = .red
resetButton.layer.cornerRadius = 10

resetButton.layer.masksToBounds = false
//resetButton.layer.shadowOpacity = 0.5
//resetButton.layer.shadowOffset = CGSize(width: 0, height: 4)

autoLayout()
produceCollectionView.register(ProducerCollectionViewCell.self, forCellWithReuseIdentifier: "cell")
Expand Down Expand Up @@ -70,7 +78,8 @@ final class SettingViewController: UIViewController {
extension SettingViewController : UICollectionViewDelegate, UICollectionViewDelegateFlowLayout, UICollectionViewDataSource {

func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
let detailVC = PinDetailViewController()
let detailVC = PinDetailViewController() //프로필 누르면 상세 화면으로

present(detailVC, animated: true ,completion: nil )
}

Expand All @@ -89,29 +98,22 @@ extension SettingViewController : UICollectionViewDelegate, UICollectionViewDele
return cell
}

func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
//컬렉션 뷰의 셀의 크기
let itemSpacing : CGFloat = 10

let myWidth : CGFloat = (collectionView.bounds.width - itemSpacing * 2) / 2

return CGSize(width: myWidth, height: myWidth * 1.2)
}
}

//오토레이아웃 제약 설정(snapkit) 부분
extension SettingViewController {
private func autoLayout() {
resetButton.snp.makeConstraints {
$0.centerX.equalToSuperview()
$0.bottom.equalToSuperview().offset(-90)
$0.height.equalTo(50)
$0.leading.equalTo(10)
$0.bottom.equalTo(view.safeAreaLayoutGuide)
$0.height.equalTo(70)
$0.leading.equalToSuperview().inset(10)
$0.trailing.equalToSuperview().offset(-10)
}
//컬렉션 뷰 제약 설정 부분 예정
produceCollectionView.snp.makeConstraints {
$0.edges.equalTo(view.safeAreaLayoutGuide)
$0.bottom.equalTo(resetButton.snp.top).offset(-30)
$0.top.equalTo(view.safeAreaLayoutGuide).inset(10)
$0.width.equalToSuperview()
$0.bottom.equalTo(resetButton.snp.top)
}
}
}
Expand Down