-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDetailViewController.swift
More file actions
90 lines (68 loc) · 2.71 KB
/
DetailViewController.swift
File metadata and controls
90 lines (68 loc) · 2.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
//
// WeatherDetailViewController.swift
// Jiwon's Weather Forecast
//
// Created by 신지원 on 10/18/23.
//
import UIKit
import SnapKit
import Then
class DetailViewController: UIViewController {
// MARK: - Properties
var index: Int = 0
public var weatherDummy : [Weathers] = []
public var detailTag = Int()
// MARK: - UI Components
let rootView = DetailView()
// MARK: - Life Cycle
override func loadView() {
self.view = rootView
}
override func viewDidLoad() {
super.viewDidLoad()
gesture()
target()
delegate()
}
// MARK: - Custom Method
private func gesture() {
rootView.detailBottomBar.detailListButton.addTarget(self, action: #selector(detailListBtnTap), for: .touchUpInside)
}
private func target() {
}
private func delegate() {
rootView.detailCollectionView.delegate = self
rootView.detailCollectionView.dataSource = self
}
//MARK: - Action Method
@objc
func detailListBtnTap() {
self.navigationController?.popViewController(animated: true)
}
}
extension DetailViewController : UICollectionViewDelegateFlowLayout {
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumLineSpacingForSectionAt section: Int) -> CGFloat {
return 0
}
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
return CGSize(width: UIScreen.main.bounds.width , height: UIScreen.main.bounds.height)
}
}
extension DetailViewController : UICollectionViewDelegate {
func scrollViewWillEndDragging(_ scrollView: UIScrollView, withVelocity velocity: CGPoint, targetContentOffset: UnsafeMutablePointer<CGPoint>) {
let page = Int(targetContentOffset.pointee.x / UIScreen.main.bounds.width)
if(page < listData.count ){
rootView.detailBottomBar.detailPageController.currentPage = page
}
}
}
extension DetailViewController : UICollectionViewDataSource {
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return weatherDummy.count
}
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
guard let cell = collectionView.dequeueReusableCell(withReuseIdentifier: DetailCollectionViewCell.cellIdentifier, for: indexPath) as? DetailCollectionViewCell else { return UICollectionViewCell() }
cell.weatherDummy = self.weatherDummy
return cell
}
}