From b37fc22a14be736fc06684a9ed247d5b3d1d4571 Mon Sep 17 00:00:00 2001 From: Yoonseo Kim Date: Thu, 19 Aug 2021 16:33:16 +0900 Subject: [PATCH] =?UTF-8?q?[#21]=20=E1=84=85=E1=85=A9=E1=84=90=E1=85=B5=20?= =?UTF-8?q?loop=20=E1=84=89=E1=85=A5=E1=86=AF=E1=84=8C=E1=85=A5=E1=86=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Sources/Extensions/Date+Extension.swift | 6 +++--- .../MainPageViewController.swift | 10 ++++++++-- .../ViewControllers/MainViewController.swift | 17 ++++++++++++++--- 3 files changed, 25 insertions(+), 8 deletions(-) diff --git a/Apple-Weather/Apple-Weather/Sources/Extensions/Date+Extension.swift b/Apple-Weather/Apple-Weather/Sources/Extensions/Date+Extension.swift index 2796f2a..8e17329 100644 --- a/Apple-Weather/Apple-Weather/Sources/Extensions/Date+Extension.swift +++ b/Apple-Weather/Apple-Weather/Sources/Extensions/Date+Extension.swift @@ -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 diff --git a/Apple-Weather/Apple-Weather/Sources/ViewControllers/MainPageViewController.swift b/Apple-Weather/Apple-Weather/Sources/ViewControllers/MainPageViewController.swift index 63963e1..7609076 100644 --- a/Apple-Weather/Apple-Weather/Sources/ViewControllers/MainPageViewController.swift +++ b/Apple-Weather/Apple-Weather/Sources/ViewControllers/MainPageViewController.swift @@ -7,6 +7,7 @@ import UIKit +import Lottie import Moya import SnapKit import Then @@ -42,12 +43,11 @@ class MainPageViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() - requestGetWeather() setLayoutPageViewController() setPageControlBar() setTargets() registerNotification() - + requestGetWeather() } private func setLayoutPageViewController() { @@ -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 } diff --git a/Apple-Weather/Apple-Weather/Sources/ViewControllers/MainViewController.swift b/Apple-Weather/Apple-Weather/Sources/ViewControllers/MainViewController.swift index 5887619..3f7b98c 100644 --- a/Apple-Weather/Apple-Weather/Sources/ViewControllers/MainViewController.swift +++ b/Apple-Weather/Apple-Weather/Sources/ViewControllers/MainViewController.swift @@ -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) @@ -82,7 +85,6 @@ class MainViewController: UIViewController { super.viewDidLoad() initMainTableView() - setLottieView() setLayoutMainViewController() setTargets() setButton() @@ -91,6 +93,11 @@ class MainViewController: UIViewController { } + override func viewDidAppear(_ animated: Bool) { + super.viewDidAppear(animated) + + } + private func setButton() { addButton.isHidden = !isModal dismissButton.isHidden = !isModal @@ -108,7 +115,7 @@ class MainViewController: UIViewController { private func setLayoutMainViewController() { view.backgroundColor = .black - + view.addSubviews(lottieView, locationStackView, mainTableView, dismissButton, addButton) lottieView.snp.makeConstraints { @@ -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 + } }