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
76 changes: 0 additions & 76 deletions Pinit/Pinit/Views/PinDetail/EmptyGuideView.swift

This file was deleted.

4 changes: 1 addition & 3 deletions Pinit/Pinit/Views/PinDetail/PinDetailHeader.swift
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ class PinDetailHeader: UIView {
public lazy var pinImageView: UIImageView = {
let imageView = UIImageView()
imageView.image = UIImage(named: "sampleImg.jpg")
imageView.contentMode = .scaleAspectFit
return imageView
}()

Expand Down Expand Up @@ -150,6 +151,3 @@ class PinDetailHeader: UIView {
PinDetailHeader()
}

#Preview {
PinDetailViewController()
}
2 changes: 1 addition & 1 deletion Pinit/Pinit/Views/PinDetail/PinDetailView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -107,5 +107,5 @@ class PinDetailView: UIView {


#Preview {
PinDetailViewController()
PinDetailViewController(PinEntity.sampleData[0])
}
91 changes: 61 additions & 30 deletions Pinit/Pinit/Views/PinDetail/PinDetailViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,31 @@ import UIKit
import SnapKit
import MapKit

// MARK: - Pin Detail Main View Controller

// MARK: - Pin Detail Main ViewController
final class PinDetailViewController: UIViewController {

private var pinTableView = UITableView(frame: .zero, style: .grouped)
private var pinEntity: PinEntity

init(_ entity: PinEntity) {
self.pinEntity = entity

super.init(nibName: nil, bundle: nil)
}

required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}


// 더미 리뷰 데이터
private lazy var datasource: [ReviewEntity] = [
ReviewEntity(id: UUID(), pinID: UUID(), date: Date(), description: "리뷰1"),
ReviewEntity(id: UUID(), pinID: UUID(), date: Date(), description: "리뷰2"),
ReviewEntity(id: UUID(), pinID: UUID(), date: Date(), description: "리뷰3")
]

public var pinTableView: UITableView!

// MARK: - VIewDidLoad
override func viewDidLoad() {
Expand All @@ -37,17 +51,19 @@ final class PinDetailViewController: UIViewController {
// 지도 뷰
public lazy var mapView: MKMapView = {
let map = MKMapView()
let lat = pinEntity.latitude
let long = pinEntity.longitude

let center = CLLocationCoordinate2D(latitude: 37.7749, longitude: -122.4194) // San Francisco, CA
let center = CLLocationCoordinate2D(latitude: lat, longitude: long) // San Francisco, CA
let region = MKCoordinateRegion(center: center, span: MKCoordinateSpan(latitudeDelta: 0.05, longitudeDelta: 0.05))

map.setRegion(region, animated: true)
map.showsUserLocation = true

let annotation = MKPointAnnotation()
annotation.coordinate = CLLocationCoordinate2D(latitude: 37.7749, longitude: -122.4194) // San Francisco, CA
annotation.title = "San Francisco"
annotation.subtitle = "CA"
annotation.coordinate = CLLocationCoordinate2D(latitude: lat, longitude: long) // San Francisco, CA
annotation.title = pinEntity.title
annotation.subtitle = pinEntity.weather
map.addAnnotation(annotation)

return map
Expand All @@ -66,13 +82,9 @@ final class PinDetailViewController: UIViewController {
return button
}()

@objc func dismissButtonTapped() {
self.dismiss(animated: true, completion: nil)
}

// 리뷰 테이블뷰 설정
private func setupReviewTable() {
pinTableView = UITableView(frame: .zero, style: .grouped)
// pinTableView = UITableView(frame: .zero, style: .grouped)
pinTableView.estimatedRowHeight = UITableView.automaticDimension
pinTableView.dataSource = self
pinTableView.delegate = self
Expand Down Expand Up @@ -122,12 +134,43 @@ final class PinDetailViewController: UIViewController {
$0.top.equalTo(mapView.snp.bottom)
$0.bottom.equalTo(reviewPanelContainer.snp.top)
}
}
}



// MARK: - objc function
extension PinDetailViewController {

@objc func dismissButtonTapped() {
self.dismiss(animated: true, completion: nil)
}

@objc func pinMenuButtonTapped() {
let actionSheet = UIAlertController(title: nil, message: nil, preferredStyle: .actionSheet)

let editAction = UIAlertAction(title: "수정", style: .default) { _ in
print("수정")
let vc = PinEditViewController()
vc.modalPresentationStyle = .fullScreen
self.present(vc, animated: true, completion: nil)
}
let deleteAction = UIAlertAction(title: "삭제", style: .destructive) { _ in
print("삭제")
}
let cancelAction = UIAlertAction(title: "취소", style: .cancel, handler: nil)

actionSheet.addAction(editAction)
actionSheet.addAction(deleteAction)
actionSheet.addAction(cancelAction)

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

}



// MARK: - Delegate
extension PinDetailViewController: UITableViewDataSource, UITableViewDelegate {

Expand Down Expand Up @@ -170,28 +213,16 @@ extension PinDetailViewController: UITableViewDataSource, UITableViewDelegate {
// viewForHeaderInSection
func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
let header = PinDetailHeader()
header.pinDate.text = pinEntity.date.koreanDateString()
header.pinTitle.text = pinEntity.title
header.pinImageView.image = pinEntity.mediaPath
header.pinWeather.text = pinEntity.weather
header.pinDescription.text = pinEntity.description
header.pinMenuButton.addTarget(self, action: #selector(pinMenuButtonTapped), for: .touchUpInside)
return header
}

@objc func pinMenuButtonTapped() {
let actionSheet = UIAlertController(title: nil, message: nil, preferredStyle: .actionSheet)

let editAction = UIAlertAction(title: "수정", style: .default) { _ in
print("수정")
self.present(PinEditViewController(), animated: true, completion: nil)
}
let deleteAction = UIAlertAction(title: "삭제", style: .destructive) { _ in
print("삭제")
}
let cancelAction = UIAlertAction(title: "취소", style: .cancel, handler: nil)

actionSheet.addAction(editAction)
actionSheet.addAction(deleteAction)
actionSheet.addAction(cancelAction)

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


// estimatedHeightForHeaderInSection
func tableView(_ tableView: UITableView, estimatedHeightForHeaderInSection section: Int) -> CGFloat {
Expand All @@ -211,5 +242,5 @@ extension PinDetailViewController: UITableViewDataSource, UITableViewDelegate {


#Preview {
PinDetailViewController()
PinDetailViewController(PinEntity.sampleData[0])
}
130 changes: 0 additions & 130 deletions Pinit/Pinit/Views/PinDetail/PinReviewTableViewController.swift

This file was deleted.

3 changes: 0 additions & 3 deletions Pinit/Pinit/Views/PinDetail/ReviewCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,3 @@ class ReviewCell: UITableViewCell {
ReviewCell()
}

#Preview {
PinDetailViewController()
}
Loading