Skip to content

Commit

Permalink
[#21] 로티 loop 설정
Browse files Browse the repository at this point in the history
  • Loading branch information
ezidayzi committed Aug 19, 2021
1 parent 28e943a commit b37fc22
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ extension Date {
let date = DateFormatter()
date.locale = Locale(identifier: "ko_kr")
date.timeZone = TimeZone(secondsFromGMT: timezone)

let hour = Calendar.current.component(.hour, from: date.date(from: date.string(from: self)) ?? Date())

date.dateFormat = "HH"
let hour = Int(date.string(from: self))!
switch hour {
case 6..<17 :
return false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import UIKit

import Lottie
import Moya
import SnapKit
import Then
Expand Down Expand Up @@ -42,12 +43,11 @@ class MainPageViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()

requestGetWeather()
setLayoutPageViewController()
setPageControlBar()
setTargets()
registerNotification()

requestGetWeather()
}

private func setLayoutPageViewController() {
Expand Down Expand Up @@ -133,6 +133,12 @@ class MainPageViewController: UIViewController {
let vc = MainViewController()
vc.view.tag = index + 1
vc.setData(weather: weathers[index])
//
// if Date().isNight(weathers[index].timezonwOffset ) {
// vc.view.backgroundColor = .black
// } else {
// vc.view.backgroundColor = .blue
// }
return vc
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,10 @@ class MainViewController: UIViewController {
$0.spacing = 10
}

private var lottieView = AnimationView(name: "4796-weather-cloudynight")
public var lottieView = AnimationView().then {
$0.play()
$0.loopMode = .loop
}

private let dismissButton = UIButton().then {
$0.setTitle("취소", for: .normal)
Expand All @@ -82,7 +85,6 @@ class MainViewController: UIViewController {
super.viewDidLoad()
initMainTableView()

setLottieView()
setLayoutMainViewController()
setTargets()
setButton()
Expand All @@ -91,6 +93,11 @@ class MainViewController: UIViewController {

}

override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)

}

private func setButton() {
addButton.isHidden = !isModal
dismissButton.isHidden = !isModal
Expand All @@ -108,7 +115,7 @@ class MainViewController: UIViewController {
private func setLayoutMainViewController() {

view.backgroundColor = .black

view.addSubviews(lottieView, locationStackView, mainTableView, dismissButton, addButton)

lottieView.snp.makeConstraints {
Expand Down Expand Up @@ -160,6 +167,10 @@ class MainViewController: UIViewController {
lowTemperatureLabel.text = "최저:\(weather.lowTemperatuer.isFahrenheit().addTemperatureSymbol())"
highTemperatureLabel.text = "최고:\(weather.highTemperature.isFahrenheit().addTemperatureSymbol())"
weatherLabel.text = weather.weather
lottieView = AnimationView(name: self.setLottieImage(weather.timezonwOffset))
lottieView.play()
lottieView.loopMode = .loop

}
}

Expand Down

0 comments on commit b37fc22

Please sign in to comment.