Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
2C63B9CD2B067B4C009C6824 /* WeatherService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2C63B9CC2B067B4C009C6824 /* WeatherService.swift */; };
2C63B9D12B067FE0009C6824 /* WeatherBody.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2C63B9D02B067FE0009C6824 /* WeatherBody.swift */; };
2C9D36622AE8E3870033C284 /* DetailBottomBar.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2C9D36612AE8E3870033C284 /* DetailBottomBar.swift */; };
2C9F912B2B24B8C00028121F /* DetailTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2C9F912A2B24B8C00028121F /* DetailTableViewCell.swift */; };
2C9F912D2B24C1A60028121F /* CityData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2C9F912C2B24C1A60028121F /* CityData.swift */; };
2CC2ABB22AF6956E00418A7C /* ListHeaderView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2CC2ABB12AF6956E00418A7C /* ListHeaderView.swift */; };
2CC2ABB42AF6966000418A7C /* ListTableView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2CC2ABB32AF6966000418A7C /* ListTableView.swift */; };
2CC2ABB62AF697B300418A7C /* ListTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2CC2ABB52AF697B300418A7C /* ListTableViewCell.swift */; };
Expand All @@ -42,7 +44,6 @@
2CEAFFE82AE0268200BB21C0 /* DetailEnum.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2CEAFFE72AE0268200BB21C0 /* DetailEnum.swift */; };
2CEAFFEA2AE0281A00BB21C0 /* DetailData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2CEAFFE92AE0281A00BB21C0 /* DetailData.swift */; };
2CF5DB152AFB8A1400137423 /* DetailCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2CF5DB142AFB8A1400137423 /* DetailCollectionViewCell.swift */; };
2CF5DB172AFB8C6C00137423 /* DetailTableView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2CF5DB162AFB8C6C00137423 /* DetailTableView.swift */; };
2CF5DB192AFB98C000137423 /* DetailLiveCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2CF5DB182AFB98C000137423 /* DetailLiveCollectionViewCell.swift */; };
2CF5DB1B2AFCB6FE00137423 /* DetailHeaderView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2CF5DB1A2AFCB6FE00137423 /* DetailHeaderView.swift */; };
2CF5DB1D2AFCC72A00137423 /* DetailWeekView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2CF5DB1C2AFCC72A00137423 /* DetailWeekView.swift */; };
Expand Down Expand Up @@ -75,6 +76,8 @@
2C63B9CC2B067B4C009C6824 /* WeatherService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WeatherService.swift; sourceTree = "<group>"; };
2C63B9D02B067FE0009C6824 /* WeatherBody.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WeatherBody.swift; sourceTree = "<group>"; };
2C9D36612AE8E3870033C284 /* DetailBottomBar.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DetailBottomBar.swift; sourceTree = "<group>"; };
2C9F912A2B24B8C00028121F /* DetailTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DetailTableViewCell.swift; sourceTree = "<group>"; };
2C9F912C2B24C1A60028121F /* CityData.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CityData.swift; sourceTree = "<group>"; };
2CC2ABB12AF6956E00418A7C /* ListHeaderView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListHeaderView.swift; sourceTree = "<group>"; };
2CC2ABB32AF6966000418A7C /* ListTableView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListTableView.swift; sourceTree = "<group>"; };
2CC2ABB52AF697B300418A7C /* ListTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListTableViewCell.swift; sourceTree = "<group>"; };
Expand All @@ -86,7 +89,6 @@
2CEAFFE72AE0268200BB21C0 /* DetailEnum.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DetailEnum.swift; sourceTree = "<group>"; };
2CEAFFE92AE0281A00BB21C0 /* DetailData.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DetailData.swift; sourceTree = "<group>"; };
2CF5DB142AFB8A1400137423 /* DetailCollectionViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DetailCollectionViewCell.swift; sourceTree = "<group>"; };
2CF5DB162AFB8C6C00137423 /* DetailTableView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DetailTableView.swift; sourceTree = "<group>"; };
2CF5DB182AFB98C000137423 /* DetailLiveCollectionViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DetailLiveCollectionViewCell.swift; sourceTree = "<group>"; };
2CF5DB1A2AFCB6FE00137423 /* DetailHeaderView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DetailHeaderView.swift; sourceTree = "<group>"; };
2CF5DB1C2AFCC72A00137423 /* DetailWeekView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DetailWeekView.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -198,6 +200,7 @@
children = (
2C63B9CC2B067B4C009C6824 /* WeatherService.swift */,
2C63B9D02B067FE0009C6824 /* WeatherBody.swift */,
2C9F912C2B24C1A60028121F /* CityData.swift */,
);
path = Network;
sourceTree = "<group>";
Expand All @@ -218,7 +221,7 @@
2C9D36612AE8E3870033C284 /* DetailBottomBar.swift */,
2CEAFFDF2ADFC6BD00BB21C0 /* DetailView.swift */,
2CF5DB142AFB8A1400137423 /* DetailCollectionViewCell.swift */,
2CF5DB162AFB8C6C00137423 /* DetailTableView.swift */,
2C9F912A2B24B8C00028121F /* DetailTableViewCell.swift */,
2CF5DB1A2AFCB6FE00137423 /* DetailHeaderView.swift */,
2CEAFFE52ADFD34B00BB21C0 /* DetailLiveView.swift */,
2CF5DB182AFB98C000137423 /* DetailLiveCollectionViewCell.swift */,
Expand Down Expand Up @@ -370,7 +373,6 @@
2CEAFFE22ADFC6CF00BB21C0 /* DetailViewController.swift in Sources */,
2CF5DB152AFB8A1400137423 /* DetailCollectionViewCell.swift in Sources */,
2CEAFFE02ADFC6BD00BB21C0 /* DetailView.swift in Sources */,
2CF5DB172AFB8C6C00137423 /* DetailTableView.swift in Sources */,
2C2EFE322ADD5E7E00B2A2EC /* ListViewController.swift in Sources */,
2CF5DB1D2AFCC72A00137423 /* DetailWeekView.swift in Sources */,
2CF5DB1B2AFCB6FE00137423 /* DetailHeaderView.swift in Sources */,
Expand All @@ -385,8 +387,10 @@
2CEAFFEA2AE0281A00BB21C0 /* DetailData.swift in Sources */,
2C63B9CD2B067B4C009C6824 /* WeatherService.swift in Sources */,
2CEAFFE82AE0268200BB21C0 /* DetailEnum.swift in Sources */,
2C9F912B2B24B8C00028121F /* DetailTableViewCell.swift in Sources */,
2C528C252ADD96DE00383C90 /* UIFont+.swift in Sources */,
2C0069D52ADD6B6D00B933A2 /* UICollectionViewCell+.swift in Sources */,
2C9F912D2B24C1A60028121F /* CityData.swift in Sources */,
2C0069CF2ADD6AF300B933A2 /* String+.swift in Sources */,
2C528C1F2ADD940100383C90 /* ListView.swift in Sources */,
2CF5DB1F2AFCC8E800137423 /* DetailEnum2.swift in Sources */,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,4 @@ public enum Image {
//MARK: - WeatherImage
static let weatherLarge = UIImage(named: "weatherLarge")!
static let weatherSmall = UIImage(named: "weatherSmall")!

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
//
// CityData.swift
// Jiwon's Weather Forecast
//
// Created by 신지원 on 12/10/23.
//

import Foundation

let Cities = ["gongju", "gwangju", "gumi", "gunsan", "daegu", "daejeon", "mokpo", "busan", "seosan", "seoul", "sokcho", "suwon", "suncheon", "ulsan", "iksan", "jeonju", "jeju", "cheonan", "cheongju", "chuncheon"]
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ class WeatherService {

do {
let decodedData = try JSONDecoder().decode(Weathers.self, from: data)
// print(decodedData)
completion(decodedData, nil)
} catch {
completion(nil, error)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,19 @@ import Then
class DetailCollectionViewCell: UICollectionViewCell {

// MARK: - Properties
public var weatherDummy: [Weathers] = []

// MARK: - UI Components
let detailBackImageView = UIImageView()
let detailTableView = DetailTableView()
let detailTableView = UITableView()

// MARK: - Life Cycle
override init(frame: CGRect) {
super.init(frame: frame)

register()
delegate()

cellStyle()
hierarchy()
layout()
Expand All @@ -31,10 +35,14 @@ class DetailCollectionViewCell: UICollectionViewCell {
fatalError("init(coder:) has not been implemented")
}

// private func delegate() {
// detailTableView.delegate = self
// detailTableView.dataSource = self
// }
private func register() {
detailTableView.register(DetailTableViewCell.self, forCellReuseIdentifier: DetailTableViewCell.cellIdentifier)
}

private func delegate() {
detailTableView.delegate = self
detailTableView.dataSource = self
}

private func cellStyle() {
self.backgroundColor = UIColor(hex: 0x2A3040)
Expand All @@ -61,29 +69,21 @@ class DetailCollectionViewCell: UICollectionViewCell {
$0.edges.equalToSuperview()
}
}
}

extension DetailCollectionViewCell: UITableViewDelegate {}
extension DetailCollectionViewCell: UITableViewDataSource {
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 1
}

func dataBind(tag : Int){
detailTableView.detailHeaderView.detailPlaceLabel.text = listData[tag].place
detailTableView.detailHeaderView.detailWeatherLabel.text = listData[tag].weather
detailTableView.detailHeaderView.detailCurrentTemLabel.text = listData[tag].currentTem + "°"
detailTableView.detailHeaderView.detailHighTemLabel.text = "최고:" + listData[tag].highTem + "°"
detailTableView.detailHeaderView.detailLowTemLabel.text = "최저:" + listData[tag].lowTem + "°"
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
guard let cell = tableView.dequeueReusableCell(withIdentifier: DetailTableViewCell.identifier, for: indexPath) as? DetailTableViewCell else { return DetailTableViewCell() }
cell.dataBind()
return cell
}

func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return 1300.0
}
}
//
//extension DetailCollectionViewCell : UITableViewDelegate {}
//extension DetailCollectionViewCell : UITableViewDataSource {
// func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
// return 1
// }
//
// func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
// guard let cell = UITableViewCell()
// return cell
// }
//
// func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
// <#code#>
// }
//
//}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ import UIKit

class DetailLiveCollectionViewCell: UICollectionViewCell {

// MARK: - Properties
static let identifier: String = "DetailLiveCollectionViewCell"

// MARK: - UI Components
var detailTime = UILabel()
var detailIcon = UIImageView()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class DetailLiveView: UIView {
}

private func register() {
detailLiveCollectionView.register(DetailLiveCollectionViewCell.self, forCellWithReuseIdentifier: DetailLiveCollectionViewCell.cellIdentifier)
detailLiveCollectionView.register(DetailLiveCollectionViewCell.self, forCellWithReuseIdentifier: DetailLiveCollectionViewCell.identifier)
}

private func style() {
Expand All @@ -54,7 +54,7 @@ class DetailLiveView: UIView {
}

detailLiveLabel.do {
$0.text = "08:00~09:00에 강우 상태가, 18:00에 한때 흐린 상태가 예상됩니다."
$0.text = "From 08:00 to 09:00 Rainy conditions are expected"
$0.font = .SFPro(.regular, size: 18)
$0.textColor = .white
$0.numberOfLines = 0
Expand Down Expand Up @@ -112,14 +112,13 @@ extension DetailLiveView : UICollectionViewDelegateFlowLayout {
}
}
extension DetailLiveView : UICollectionViewDelegate {}

extension DetailLiveView : UICollectionViewDataSource {
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return detailLiveData.count
}

func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
guard let cell = collectionView.dequeueReusableCell(withReuseIdentifier: DetailLiveCollectionViewCell.cellIdentifier, for: indexPath) as? DetailLiveCollectionViewCell else { return UICollectionViewCell() }
guard let cell = collectionView.dequeueReusableCell(withReuseIdentifier: DetailLiveCollectionViewCell.identifier, for: indexPath) as? DetailLiveCollectionViewCell else { return UICollectionViewCell() }
cell.dataBind(tag: indexPath.row)
return cell
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,33 +1,45 @@
//
// DetailTableView.swift
// DetailTableViewCell.swift
// Jiwon's Weather Forecast
//
// Created by 신지원 on 11/8/23.
// Created by 신지원 on 12/10/23.
//

import UIKit

class DetailTableView: UITableView {
import SnapKit
import Then

// MARK: - Properties
var num = 0
class DetailTableViewCell: UITableViewCell {

// MARK: - Properties
public var weatherDummy: [Weathers] = []

// MARK: - UI Components
let detailHeaderView = DetailHeaderView()
let detailLiveView = DetailLiveView()
let detailWeekView = DetailWeekView()

// MARK: - Life Cycle
override init(frame: CGRect, style: UITableView.Style) {
super.init(frame: frame, style: style)

override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)

setStyle()
hierarchy()
layout()
}

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

private func setStyle() {
self.do {
$0.backgroundColor = .clear
$0.contentView.isHidden = true
$0.selectedBackgroundView?.isHidden = true
}
}

private func hierarchy() {
self.addSubviews(detailHeaderView, detailLiveView, detailWeekView)
}
Expand All @@ -50,7 +62,15 @@ class DetailTableView: UITableView {
$0.top.equalTo(detailLiveView.snp.bottom).offset(10)
$0.centerX.equalToSuperview()
$0.leading.equalTo(20)
// $0.height.equalTo(678)
$0.height.equalTo(600)
}
}

func dataBind(){
// detailHeaderView.detailPlaceLabel.text = weatherdummy[0].name
// detailHeaderView.detailWeatherLabel.text = weatherdummy[0].weather.first?.description
// detailHeaderView.detailCurrentTemLabel.text = String(weatherdummy[0].main.temp) + "°"
// detailHeaderView.detailHighTemLabel.text = "최고:" + String(weatherdummy[0].main.temp_max) + "°"
// detailHeaderView.detailLowTemLabel.text = "최저:" + String(weatherdummy[0].main.temp_min) + "°"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ import UIKit

class DetailWeekCollectionViewCell: UICollectionViewCell {

// MARK: - Properties
static let identifier: String = "DetailWeekCollectionViewCell"

// MARK: - UI Components
var detailDay = UILabel()
var detailIcon = UIImageView()
Expand Down Expand Up @@ -114,8 +117,7 @@ class DetailWeekCollectionViewCell: UICollectionViewCell {

var min = (Double)(detailWeekData[tag].lowTem - detailWeekDataMin) / (Double)(detailWeekDataMax - detailWeekDataMin) * 100
var max = (Double)(detailWeekDataMax - detailWeekData[tag].highTem) / (Double)(detailWeekDataMax - detailWeekDataMin) * 100
print(min)
print(max)

empty1.snp.makeConstraints() {
$0.top.equalTo(detailGradientTemp.snp.top)
$0.leading.equalTo(detailGradientTemp.snp.leading)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class DetailWeekView: UIView {
}

private func register() {
detailWeekCollectionView.register(DetailWeekCollectionViewCell.self, forCellWithReuseIdentifier: DetailWeekCollectionViewCell.cellIdentifier)
detailWeekCollectionView.register(DetailWeekCollectionViewCell.self, forCellWithReuseIdentifier: DetailWeekCollectionViewCell.identifier)
}

private func style() {
Expand All @@ -55,7 +55,7 @@ class DetailWeekView: UIView {
}

detailWeekLabel.do {
$0.text = "10일간의 일기예보"
$0.text = "10-DAY FORECAST"
$0.font = .SFPro(.thin, size: 15)
$0.textColor = UIColor(white: 1.0, alpha: 0.5)
$0.numberOfLines = 0
Expand Down Expand Up @@ -107,7 +107,7 @@ extension DetailWeekView : UICollectionViewDataSource {
}

func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
guard let cell = collectionView.dequeueReusableCell(withReuseIdentifier: DetailWeekCollectionViewCell.cellIdentifier, for: indexPath) as? DetailWeekCollectionViewCell else { return UICollectionViewCell() }
guard let cell = collectionView.dequeueReusableCell(withReuseIdentifier: DetailWeekCollectionViewCell.identifier, for: indexPath) as? DetailWeekCollectionViewCell else { return UICollectionViewCell() }
cell.dataBind(tag: indexPath.row)
return cell
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,14 @@ 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
Expand All @@ -29,8 +32,6 @@ class DetailViewController: UIViewController {
gesture()
target()
delegate()

// responseData(forCity: "Seoul")
}

// MARK: - Custom Method
Expand Down Expand Up @@ -78,12 +79,12 @@ extension DetailViewController : UICollectionViewDelegate {

extension DetailViewController : UICollectionViewDataSource {
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return listData.count
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.dataBind(tag: indexPath.row)
cell.weatherDummy = self.weatherDummy
return cell
}
}
Loading