Skip to content

Commit

Permalink
[FEAT] switch case for ImageView 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
kim-seonwoo committed Nov 9, 2023
1 parent 1f66930 commit edc5ec9
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 48 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import Then

class BottomAppBar: UIView {

// weak var delegate: BottomAppBarDelegate?
// weak var delegate: BottomAppBarDelegate?

private let lineView = UIView()
private let mapButton = UIButton()
Expand Down Expand Up @@ -78,7 +78,7 @@ class BottomAppBar: UIView {
}

}

}

extension WeatherDetailViewController {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,24 +65,41 @@ class TenDaysTableViewCell: UITableViewCell {
$0.centerY.equalToSuperview()
$0.top.equalToSuperview().inset(14)
$0.leading.equalTo(weatherImage.snp.trailing).offset(15)
}
}
degreeBarImage.snp.makeConstraints {
$0.centerY.equalToSuperview()
$0.leading.equalTo(minTempLabel.snp.trailing).offset(6)
$0.width.equalTo(108)
}
maxTempLabel.snp.makeConstraints {
$0.centerY.equalToSuperview()
$0.top.equalToSuperview().inset(14)
$0.leading.equalTo(degreeBarImage.snp.trailing).offset(6)
}
$0.centerY.equalToSuperview()
$0.leading.equalTo(minTempLabel.snp.trailing).offset(6)
$0.width.equalTo(108)
}
maxTempLabel.snp.makeConstraints {
$0.centerY.equalToSuperview()
$0.top.equalToSuperview().inset(14)
$0.leading.equalTo(degreeBarImage.snp.trailing).offset(6)
}
}

func bindData(data: TenDaysTableViewData) {
self.weatherImage.image = UIImage(named: data.weatherImage)
self.dateLabel.text = data.date
self.minTempLabel.text = data.minTemp
self.maxTempLabel.text = data.maxTemp
setWeatherImage(weather: data.weatherImage)
self.dateLabel.text = data.date
self.minTempLabel.text = data.minTemp
self.maxTempLabel.text = data.maxTemp
self.degreeBarImage.image = UIImage(named: data.degreeBar)
}

private func setWeatherImage(weather: String) {
switch weather {
case "cloudBolt":
weatherImage.image = UIImage(named: "cloudBolt")
case "cloudMoon":
weatherImage.image = UIImage(named: "cloudMoon")
case "softRain":
weatherImage.image = UIImage(named: "softRain")
case "heavyRain":
weatherImage.image = UIImage(named: "heavyRain")
case "rainWithSun":
weatherImage.image = UIImage(named: "rainWithSun")
default:
weatherImage.image = UIImage(named: "cloudMoon")
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,25 @@ class WeatherDetailCollectionViewCell: UICollectionViewCell {

func bindData(data: WeatherCollectionViewData) {
self.timeLabel.text = data.time
self.weatherImageView.image = UIImage(named: data.weather)
setWeatherImage(weather: data.weather)
self.temperatureLabel.text = data.temperature
}

private func setWeatherImage(weather: String) {
switch weather {
case "cloudBolt":
weatherImageView.image = UIImage(named: "cloudBolt")
case "cloudMoon":
weatherImageView.image = UIImage(named: "cloudMoon")
case "softRain":
weatherImageView.image = UIImage(named: "softRain")
case "heavyRain":
weatherImageView.image = UIImage(named: "heavyRain")
case "rainWithSun":
weatherImageView.image = UIImage(named: "rainWithSun")
default:
weatherImageView.image = UIImage(named: "cloudMoon")
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -50,45 +50,45 @@ class WetherListTableViewCell: UITableViewCell {
}

private func setLayout() {
self.backgroundColor = .black
self.backgroundColor = .black

self.isUserInteractionEnabled = true
self.contentView.addSubview(backgroundImageView)
backgroundImageView.snp.makeConstraints{
$0.top.equalToSuperview().offset(10)
$0.bottom.equalToSuperview().offset(-10)
$0.leading.trailing.equalToSuperview().inset(20)
}
[myLocationLabel, locationLabel, weatherLabel, temperatureLabel, maxtemperatureLabel, mintemperatureLabel].forEach {
self.backgroundImageView.addSubview($0)
}
myLocationLabel.snp.makeConstraints {
$0.top.equalToSuperview().inset(10)
$0.leading.equalToSuperview().inset(16)
}

self.contentView.addSubview(backgroundImageView)
backgroundImageView.snp.makeConstraints{
$0.top.equalToSuperview().offset(10)
$0.bottom.equalToSuperview().offset(-10)
$0.leading.trailing.equalToSuperview().inset(20)
}

[myLocationLabel, locationLabel, weatherLabel, temperatureLabel, maxtemperatureLabel, mintemperatureLabel].forEach {
self.backgroundImageView.addSubview($0)
}
myLocationLabel.snp.makeConstraints {
$0.top.equalToSuperview().inset(10)
$0.leading.equalToSuperview().inset(16)
}
locationLabel.snp.makeConstraints {
$0.top.equalToSuperview().inset(44)
$0.leading.equalToSuperview().inset(16)
}
$0.top.equalToSuperview().inset(44)
$0.leading.equalToSuperview().inset(16)
}
weatherLabel.snp.makeConstraints {
$0.bottom.equalToSuperview().inset(10)
$0.leading.equalToSuperview().inset(16)
}
$0.bottom.equalToSuperview().inset(10)
$0.leading.equalToSuperview().inset(16)
}
temperatureLabel.snp.makeConstraints {
$0.top.equalToSuperview().inset(4)
$0.leading.equalToSuperview().inset(249)
}
$0.top.equalToSuperview().inset(4)
$0.leading.equalToSuperview().inset(249)
}
maxtemperatureLabel.snp.makeConstraints {
$0.bottom.equalToSuperview().inset(10)
$0.leading.equalToSuperview().inset(196)
}
$0.bottom.equalToSuperview().inset(10)
$0.leading.equalToSuperview().inset(196)
}
mintemperatureLabel.snp.makeConstraints {
$0.bottom.equalToSuperview().inset(10)
$0.leading.equalToSuperview().inset(262)
}
$0.bottom.equalToSuperview().inset(10)
$0.leading.equalToSuperview().inset(262)
}
}

func bindData(data: WeatherListViewData) {
self.locationLabel.text = data.location
Expand Down

0 comments on commit edc5ec9

Please sign in to comment.