Commit f14dbb96 by Dmitriy Stepanets

Working on time zones

parent 2128cb7f
...@@ -115,6 +115,7 @@ ...@@ -115,6 +115,7 @@
CDA5542825EF734200A2E08C /* TodayCellFactory.swift in Sources */ = {isa = PBXBuildFile; fileRef = CDA5542725EF734200A2E08C /* TodayCellFactory.swift */; }; CDA5542825EF734200A2E08C /* TodayCellFactory.swift in Sources */ = {isa = PBXBuildFile; fileRef = CDA5542725EF734200A2E08C /* TodayCellFactory.swift */; };
CDA5542D25EF7C9700A2E08C /* ReusableCellProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = CDA5542C25EF7C9700A2E08C /* ReusableCellProtocol.swift */; }; CDA5542D25EF7C9700A2E08C /* ReusableCellProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = CDA5542C25EF7C9700A2E08C /* ReusableCellProtocol.swift */; };
CDA5543025EFA13F00A2E08C /* Measurement+String.swift in Sources */ = {isa = PBXBuildFile; fileRef = CDA5542F25EFA13F00A2E08C /* Measurement+String.swift */; }; CDA5543025EFA13F00A2E08C /* Measurement+String.swift in Sources */ = {isa = PBXBuildFile; fileRef = CDA5542F25EFA13F00A2E08C /* Measurement+String.swift */; };
CDAC9B8526319B0500AC1BF4 /* MapTimeControlItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = CDAC9B8426319B0500AC1BF4 /* MapTimeControlItem.swift */; };
CDAD97B1262042B2007FCFB1 /* MapButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = CDAD97B0262042B2007FCFB1 /* MapButton.swift */; }; CDAD97B1262042B2007FCFB1 /* MapButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = CDAD97B0262042B2007FCFB1 /* MapButton.swift */; };
CDAD97B426207D14007FCFB1 /* MapTimeControlView.swift in Sources */ = {isa = PBXBuildFile; fileRef = CDAD97B326207D14007FCFB1 /* MapTimeControlView.swift */; }; CDAD97B426207D14007FCFB1 /* MapTimeControlView.swift in Sources */ = {isa = PBXBuildFile; fileRef = CDAD97B326207D14007FCFB1 /* MapTimeControlView.swift */; };
CDC6124F25E7964700188DA7 /* TodayDayTimesCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = CDC6124E25E7964700188DA7 /* TodayDayTimesCell.swift */; }; CDC6124F25E7964700188DA7 /* TodayDayTimesCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = CDC6124E25E7964700188DA7 /* TodayDayTimesCell.swift */; };
...@@ -127,6 +128,7 @@ ...@@ -127,6 +128,7 @@
CDD0F1E52572425200CF5017 /* SF-Pro.ttf in Resources */ = {isa = PBXBuildFile; fileRef = CDD0F1E42572425200CF5017 /* SF-Pro.ttf */; }; CDD0F1E52572425200CF5017 /* SF-Pro.ttf in Resources */ = {isa = PBXBuildFile; fileRef = CDD0F1E42572425200CF5017 /* SF-Pro.ttf */; };
CDD0F1E82572429E00CF5017 /* AppFont.swift in Sources */ = {isa = PBXBuildFile; fileRef = CDD0F1E72572429E00CF5017 /* AppFont.swift */; }; CDD0F1E82572429E00CF5017 /* AppFont.swift in Sources */ = {isa = PBXBuildFile; fileRef = CDD0F1E72572429E00CF5017 /* AppFont.swift */; };
CDD0F1EE25725BCF00CF5017 /* ThemeManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = CDD0F1ED25725BCF00CF5017 /* ThemeManager.swift */; }; CDD0F1EE25725BCF00CF5017 /* ThemeManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = CDD0F1ED25725BCF00CF5017 /* ThemeManager.swift */; };
CDD17E2E263300CF00E92B6A /* Date+TimeZoneConvert.swift in Sources */ = {isa = PBXBuildFile; fileRef = CDD17E2D263300CF00E92B6A /* Date+TimeZoneConvert.swift */; };
CDD75F0D25DE68B10099ACDB /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = CDD75F0F25DE68B10099ACDB /* Localizable.strings */; }; CDD75F0D25DE68B10099ACDB /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = CDD75F0F25DE68B10099ACDB /* Localizable.strings */; };
CDDE8D7C262EED3C00267931 /* MapLegendSevereView.swift in Sources */ = {isa = PBXBuildFile; fileRef = CDDE8D7B262EED3C00267931 /* MapLegendSevereView.swift */; }; CDDE8D7C262EED3C00267931 /* MapLegendSevereView.swift in Sources */ = {isa = PBXBuildFile; fileRef = CDDE8D7B262EED3C00267931 /* MapLegendSevereView.swift */; };
CDDE8D7F262EED4D00267931 /* MapLegendWeatherView.swift in Sources */ = {isa = PBXBuildFile; fileRef = CDDE8D7E262EED4D00267931 /* MapLegendWeatherView.swift */; }; CDDE8D7F262EED4D00267931 /* MapLegendWeatherView.swift in Sources */ = {isa = PBXBuildFile; fileRef = CDDE8D7E262EED4D00267931 /* MapLegendWeatherView.swift */; };
...@@ -322,6 +324,7 @@ ...@@ -322,6 +324,7 @@
CDA5542725EF734200A2E08C /* TodayCellFactory.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TodayCellFactory.swift; sourceTree = "<group>"; }; CDA5542725EF734200A2E08C /* TodayCellFactory.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TodayCellFactory.swift; sourceTree = "<group>"; };
CDA5542C25EF7C9700A2E08C /* ReusableCellProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReusableCellProtocol.swift; sourceTree = "<group>"; }; CDA5542C25EF7C9700A2E08C /* ReusableCellProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReusableCellProtocol.swift; sourceTree = "<group>"; };
CDA5542F25EFA13F00A2E08C /* Measurement+String.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Measurement+String.swift"; sourceTree = "<group>"; }; CDA5542F25EFA13F00A2E08C /* Measurement+String.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Measurement+String.swift"; sourceTree = "<group>"; };
CDAC9B8426319B0500AC1BF4 /* MapTimeControlItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MapTimeControlItem.swift; sourceTree = "<group>"; };
CDAD97B0262042B2007FCFB1 /* MapButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MapButton.swift; sourceTree = "<group>"; }; CDAD97B0262042B2007FCFB1 /* MapButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MapButton.swift; sourceTree = "<group>"; };
CDAD97B326207D14007FCFB1 /* MapTimeControlView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MapTimeControlView.swift; sourceTree = "<group>"; }; CDAD97B326207D14007FCFB1 /* MapTimeControlView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MapTimeControlView.swift; sourceTree = "<group>"; };
CDC6124E25E7964700188DA7 /* TodayDayTimesCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TodayDayTimesCell.swift; sourceTree = "<group>"; }; CDC6124E25E7964700188DA7 /* TodayDayTimesCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TodayDayTimesCell.swift; sourceTree = "<group>"; };
...@@ -334,6 +337,7 @@ ...@@ -334,6 +337,7 @@
CDD0F1E42572425200CF5017 /* SF-Pro.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "SF-Pro.ttf"; sourceTree = "<group>"; }; CDD0F1E42572425200CF5017 /* SF-Pro.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "SF-Pro.ttf"; sourceTree = "<group>"; };
CDD0F1E72572429E00CF5017 /* AppFont.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppFont.swift; sourceTree = "<group>"; }; CDD0F1E72572429E00CF5017 /* AppFont.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppFont.swift; sourceTree = "<group>"; };
CDD0F1ED25725BCF00CF5017 /* ThemeManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ThemeManager.swift; sourceTree = "<group>"; }; CDD0F1ED25725BCF00CF5017 /* ThemeManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ThemeManager.swift; sourceTree = "<group>"; };
CDD17E2D263300CF00E92B6A /* Date+TimeZoneConvert.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Date+TimeZoneConvert.swift"; sourceTree = "<group>"; };
CDD75F0E25DE68B10099ACDB /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/Localizable.strings; sourceTree = "<group>"; }; CDD75F0E25DE68B10099ACDB /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/Localizable.strings; sourceTree = "<group>"; };
CDDE8D7B262EED3C00267931 /* MapLegendSevereView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MapLegendSevereView.swift; sourceTree = "<group>"; }; CDDE8D7B262EED3C00267931 /* MapLegendSevereView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MapLegendSevereView.swift; sourceTree = "<group>"; };
CDDE8D7E262EED4D00267931 /* MapLegendWeatherView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MapLegendWeatherView.swift; sourceTree = "<group>"; }; CDDE8D7E262EED4D00267931 /* MapLegendWeatherView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MapLegendWeatherView.swift; sourceTree = "<group>"; };
...@@ -532,6 +536,7 @@ ...@@ -532,6 +536,7 @@
CDF4808E261727E00076E9F5 /* CLAuthorizationStatus+Localized.swift */, CDF4808E261727E00076E9F5 /* CLAuthorizationStatus+Localized.swift */,
CDF48091261729680076E9F5 /* UIApplication+Settings.swift */, CDF48091261729680076E9F5 /* UIApplication+Settings.swift */,
CD67616C262587D30079D273 /* UITabBarController+Hide.swift */, CD67616C262587D30079D273 /* UITabBarController+Hide.swift */,
CDD17E2D263300CF00E92B6A /* Date+TimeZoneConvert.swift */,
); );
path = Extensions; path = Extensions;
sourceTree = "<group>"; sourceTree = "<group>";
...@@ -810,6 +815,7 @@ ...@@ -810,6 +815,7 @@
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
CDAD97B326207D14007FCFB1 /* MapTimeControlView.swift */, CDAD97B326207D14007FCFB1 /* MapTimeControlView.swift */,
CDAC9B8426319B0500AC1BF4 /* MapTimeControlItem.swift */,
CDF8F129262089A200DB384A /* MapTimeView.swift */, CDF8F129262089A200DB384A /* MapTimeView.swift */,
CDF8F12C26208E7B00DB384A /* MapCurrentTimeView.swift */, CDF8F12C26208E7B00DB384A /* MapCurrentTimeView.swift */,
CD7F3ABC262443260041C478 /* MapPinnedLayersView.swift */, CD7F3ABC262443260041C478 /* MapPinnedLayersView.swift */,
...@@ -1418,6 +1424,7 @@ ...@@ -1418,6 +1424,7 @@
CD866A65260F642600E96A5C /* SettingsDetailsViewController.swift in Sources */, CD866A65260F642600E96A5C /* SettingsDetailsViewController.swift in Sources */,
CD647D0225ED07D60034578B /* TodayViewModel.swift in Sources */, CD647D0225ED07D60034578B /* TodayViewModel.swift in Sources */,
CD593BD32608BC3F00C93428 /* ForecastDayCell.swift in Sources */, CD593BD32608BC3F00C93428 /* ForecastDayCell.swift in Sources */,
CDAC9B8526319B0500AC1BF4 /* MapTimeControlItem.swift in Sources */,
CD4742D0261200500061AC95 /* TodayAlertCell.swift in Sources */, CD4742D0261200500061AC95 /* TodayAlertCell.swift in Sources */,
CD15DB4225DA806C00024727 /* TodayForecastTimePeriodCell.swift in Sources */, CD15DB4225DA806C00024727 /* TodayForecastTimePeriodCell.swift in Sources */,
CD7F3ABD262443260041C478 /* MapPinnedLayersView.swift in Sources */, CD7F3ABD262443260041C478 /* MapPinnedLayersView.swift in Sources */,
...@@ -1436,6 +1443,7 @@ ...@@ -1436,6 +1443,7 @@
CD55E0BB2615EE2400CC4DC7 /* PollutantView.swift in Sources */, CD55E0BB2615EE2400CC4DC7 /* PollutantView.swift in Sources */,
CDDE8D7C262EED3C00267931 /* MapLegendSevereView.swift in Sources */, CDDE8D7C262EED3C00267931 /* MapLegendSevereView.swift in Sources */,
CD6761882625C3360079D273 /* RadarViewModel.swift in Sources */, CD6761882625C3360079D273 /* RadarViewModel.swift in Sources */,
CDD17E2E263300CF00E92B6A /* Date+TimeZoneConvert.swift in Sources */,
CDF8F12A262089A200DB384A /* MapTimeView.swift in Sources */, CDF8F12A262089A200DB384A /* MapTimeView.swift in Sources */,
CEC526FA25E7959A00DA58A5 /* WeatherSource.swift in Sources */, CEC526FA25E7959A00DA58A5 /* WeatherSource.swift in Sources */,
CDF4808F261727E00076E9F5 /* CLAuthorizationStatus+Localized.swift in Sources */, CDF4808F261727E00076E9F5 /* CLAuthorizationStatus+Localized.swift in Sources */,
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
<key>1Weather.xcscheme_^#shared#^_</key> <key>1Weather.xcscheme_^#shared#^_</key>
<dict> <dict>
<key>orderHint</key> <key>orderHint</key>
<integer>26</integer> <integer>25</integer>
</dict> </dict>
<key>PG (Playground) 1.xcscheme</key> <key>PG (Playground) 1.xcscheme</key>
<dict> <dict>
......
...@@ -7,64 +7,16 @@ ...@@ -7,64 +7,16 @@
<BreakpointProxy <BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint"> BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent <BreakpointContent
uuid = "89C8A0DD-3D0D-4C33-BA19-94E6A7991DA2" uuid = "03921A78-9DF4-4BDE-88B6-E44035BF9063"
shouldBeEnabled = "Yes" shouldBeEnabled = "Yes"
ignoreCount = "0" ignoreCount = "0"
continueAfterRunningActions = "No" continueAfterRunningActions = "No"
filePath = "1Weather/UI/Helpers/DayControlsNavigationBar.swift" filePath = "1Weather/Extensions/Calendar+TimeZone.swift"
startingColumnNumber = "9223372036854775807" startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807"
startingLineNumber = "50" startingLineNumber = "21"
endingLineNumber = "50" endingLineNumber = "21"
landmarkName = "restoreProgress()" landmarkName = "isNow(fromDate:timeZone:)"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "14AFAEC9-A39D-4B7B-9B2D-C2DA2519300A"
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "1Weather/UI/Helpers/DayControlsNavigationBar.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "35"
endingLineNumber = "35"
landmarkName = "showControls(progressValue:)"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "D794B66E-D7A6-4A78-A1CE-C34AC9DC948E"
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "1Weather/UI/Helpers/DayControlsNavigationBar.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "51"
endingLineNumber = "51"
landmarkName = "restoreProgress()"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "2AD266BE-E133-463F-BF26-2797D4C1A0EF"
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "1Weather/UI/Helpers/DayControlsNavigationBar.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "40"
endingLineNumber = "40"
landmarkName = "showControls(progressValue:)"
landmarkType = "7"> landmarkType = "7">
</BreakpointContent> </BreakpointContent>
</BreakpointProxy> </BreakpointProxy>
......
//
// Date+TimeZoneConvert.swift
// 1Weather
//
// Created by Dmitry Stepanets on 23.04.2021.
//
import Foundation
extension Date {
func convert(from initTimeZone: TimeZone, to targetTimeZone: TimeZone) -> Date {
let delta = TimeInterval(targetTimeZone.secondsFromGMT(for: self) - initTimeZone.secondsFromGMT(for: self))
return addingTimeInterval(delta)
}
}
//
// MapTimeControlItem.swift
// 1Weather
//
// Created by Dmitry Stepanets on 22.04.2021.
//
import Foundation
struct MapTimeControlItem {
let value:String
let date:Date
}
...@@ -64,6 +64,16 @@ class MapTimeControlView: UIView { ...@@ -64,6 +64,16 @@ class MapTimeControlView: UIView {
updateUI() updateUI()
} }
public func configure(items:[MapTimeControlItem], timeZone:TimeZone) {
stackView.removeAll()
items.forEach {
let view = MapTimeView(item: $0)
stackView.addArrangedSubview(view)
}
stackView.layoutIfNeeded()
}
private func updateUI() { private func updateUI() {
container.backgroundColor = ThemeManager.currentTheme.mapControlsColor container.backgroundColor = ThemeManager.currentTheme.mapControlsColor
...@@ -132,11 +142,6 @@ private extension MapTimeControlView { ...@@ -132,11 +142,6 @@ private extension MapTimeControlView {
make.left.equalTo(playButton.snp.right).offset(8) make.left.equalTo(playButton.snp.right).offset(8)
make.right.equalToSuperview().inset(8) make.right.equalToSuperview().inset(8)
} }
for _ in 0..<5 {
let view = MapTimeView()
stackView.addArrangedSubview(view)
}
} }
func prepareCurrentTimeView() { func prepareCurrentTimeView() {
......
...@@ -8,14 +8,22 @@ ...@@ -8,14 +8,22 @@
import UIKit import UIKit
class MapTimeView: UIView { class MapTimeView: UIView {
private let tempLabel = UILabel() private let valueLabel = UILabel()
private let timeLabel = UILabel() private let timeLabel = UILabel()
private static let timeFormatter:DateFormatter = {
let fmt = DateFormatter()
fmt.dateFormat = "h:mm"
return fmt
}()
init() { init(item:MapTimeControlItem) {
super.init(frame: .zero) super.init(frame: .zero)
prepareLabels() prepareLabels()
updateUI() updateUI()
valueLabel.text = item.value
timeLabel.text = MapTimeView.timeFormatter.string(from: item.date)
} }
required init?(coder: NSCoder) { required init?(coder: NSCoder) {
...@@ -30,20 +38,21 @@ class MapTimeView: UIView { ...@@ -30,20 +38,21 @@ class MapTimeView: UIView {
private func updateUI() { private func updateUI() {
switch interfaceStyle { switch interfaceStyle {
case .light: case .light:
tempLabel.textColor = ThemeManager.currentTheme.secondaryTextColor valueLabel.textColor = ThemeManager.currentTheme.secondaryTextColor
timeLabel.textColor = ThemeManager.currentTheme.secondaryTextColor timeLabel.textColor = ThemeManager.currentTheme.secondaryTextColor
case .dark: case .dark:
tempLabel.textColor = ThemeManager.currentTheme.primaryTextColor valueLabel.textColor = ThemeManager.currentTheme.primaryTextColor
timeLabel.textColor = ThemeManager.currentTheme.primaryTextColor timeLabel.textColor = ThemeManager.currentTheme.primaryTextColor
} }
} }
} }
//MARK:- Prepare
private extension MapTimeView { private extension MapTimeView {
func prepareLabels() { func prepareLabels() {
tempLabel.text = "45°" valueLabel.text = "45°"
tempLabel.font = AppFont.SFPro.regular(size: 10) valueLabel.font = AppFont.SFPro.regular(size: 10)
addSubview(tempLabel) addSubview(valueLabel)
timeLabel.text = "2:00" timeLabel.text = "2:00"
timeLabel.textAlignment = .center timeLabel.textAlignment = .center
...@@ -52,14 +61,14 @@ private extension MapTimeView { ...@@ -52,14 +61,14 @@ private extension MapTimeView {
addSubview(timeLabel) addSubview(timeLabel)
//Constraints //Constraints
tempLabel.snp.makeConstraints { (make) in valueLabel.snp.makeConstraints { (make) in
make.top.equalToSuperview().inset(10) make.top.equalToSuperview().inset(10)
make.centerX.equalToSuperview() make.centerX.equalToSuperview()
} }
timeLabel.snp.makeConstraints { (make) in timeLabel.snp.makeConstraints { (make) in
make.bottom.equalToSuperview().inset(5) make.bottom.equalToSuperview().inset(5)
make.top.equalTo(tempLabel.snp.bottom).offset(4) make.top.equalTo(valueLabel.snp.bottom).offset(4)
make.left.right.equalToSuperview().inset(2) make.left.right.equalToSuperview().inset(2)
} }
} }
......
...@@ -32,7 +32,7 @@ class RadarViewController: UIViewController { ...@@ -32,7 +32,7 @@ class RadarViewController: UIViewController {
if let overlay = swarmOverlay { if let overlay = swarmOverlay {
overlay.startUpdating(block: { [weak self] (dataAvailable, updateError) in overlay.startUpdating(block: { [weak self] (dataAvailable, updateError) in
self?.swarmRenderer?.setNeedsDisplay() self?.swarmRenderer?.setNeedsDisplay()
//print("Updating: \(String(describing: self?.updateDateLabel()))") // print("[SWARM] Updating: \(String(describing: self?.updateDateLabel()))")
}) })
mapView.addOverlay(overlay, level: .aboveRoads) mapView.addOverlay(overlay, level: .aboveRoads)
swarmRenderer?.setNeedsDisplay() // forces overlay to update to latest radar view swarmRenderer?.setNeedsDisplay() // forces overlay to update to latest radar view
...@@ -80,7 +80,6 @@ class RadarViewController: UIViewController { ...@@ -80,7 +80,6 @@ class RadarViewController: UIViewController {
prepareMapTimeControl() prepareMapTimeControl()
updateUI() updateUI()
initialConfigure() initialConfigure()
setOverlay()
} }
//Private //Private
...@@ -97,6 +96,7 @@ class RadarViewController: UIViewController { ...@@ -97,6 +96,7 @@ class RadarViewController: UIViewController {
let span = MKCoordinateSpan(latitudeDelta: 3.0, longitudeDelta: 3.0) let span = MKCoordinateSpan(latitudeDelta: 3.0, longitudeDelta: 3.0)
let coordinateRegion = MKCoordinateRegion.init(center: coordinates, span: span) let coordinateRegion = MKCoordinateRegion.init(center: coordinates, span: span)
mapView.setRegion(coordinateRegion, animated: true) mapView.setRegion(coordinateRegion, animated: true)
setOverlay()
} }
private func initialConfigure() { private func initialConfigure() {
...@@ -128,8 +128,21 @@ class RadarViewController: UIViewController { ...@@ -128,8 +128,21 @@ class RadarViewController: UIViewController {
overlay.alpha = 0.85 overlay.alpha = 0.85
// overlay.debug = true // overlay.debug = true
overlay.queryTimes { (_, error) in overlay.queryTimes {[weak self] (_, error) in
guard let self = self else { return }
self.swarmOverlay = overlay self.swarmOverlay = overlay
//Update timeline
if let validTimes = overlay.validTimes as? [String:AnyObject] {
let dates = validTimes.map{$0.value}.first as? [String]
if let stringArray = dates {
let items = self.radarViewModel.buildTimelineValuesFor(validTimes: stringArray)
if let timeZone = self.radarViewModel.location?.timeZone {
self.mapTimeControlView.configure(items: items, timeZone: timeZone)
}
}
}
// _ = self.updateDateLabel() // _ = self.updateDateLabel()
} }
} }
...@@ -151,9 +164,9 @@ class RadarViewController: UIViewController { ...@@ -151,9 +164,9 @@ class RadarViewController: UIViewController {
DispatchQueue.global(qos: .userInitiated).async { DispatchQueue.global(qos: .userInitiated).async {
/*self.progress*/ _ = overlay.fetchTilesForAnimation(self.mapView.visibleMapRect, readyBlock: { [weak self] in /*self.progress*/ _ = overlay.fetchTilesForAnimation(self.mapView.visibleMapRect, readyBlock: { [weak self] in
guard let strongSelf = self else { return } guard let strongSelf = self else { return }
strongSelf.swarmOverlay?.startAnimating({ [weak self] (_) in strongSelf.swarmOverlay?.startAnimating({(_) in
// let _ = self?.updateDateLabel() ?? "" // let _ = self?.updateDateLabel() ?? ""
//print("Animation: \(time)") // print("Animation: \(time)")
self?.swarmRenderer?.setNeedsDisplay()//setNeedsDisplayInMapRect((self?.mapView.visibleMapRect)!) self?.swarmRenderer?.setNeedsDisplay()//setNeedsDisplayInMapRect((self?.mapView.visibleMapRect)!)
}) })
}) })
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
// //
import UIKit import UIKit
import Swarm
protocol RadarViewModelDelegate: ViewModelDelegate { protocol RadarViewModelDelegate: ViewModelDelegate {
func viewModel(model:RadarViewModel, didSelectLayer layer:RadarLayer) func viewModel(model:RadarViewModel, didSelectLayer layer:RadarLayer)
...@@ -35,6 +36,14 @@ class RadarViewModel: ViewModelProtocol { ...@@ -35,6 +36,14 @@ class RadarViewModel: ViewModelProtocol {
} }
//Private //Private
private var swarmDateFormatter:DateFormatter = {
let fmt = DateFormatter()
fmt.timeZone = TimeZone(secondsFromGMT: 0)
fmt.locale = Locale(identifier: "en_US_POSIX")
fmt.dateFormat = "yyyy-MM-dd'T'HH:mm:ss"
return fmt
}()
private let locationManager = LocationManager.shared private let locationManager = LocationManager.shared
var location:Location? { var location:Location? {
return locationManager.selectedLocation return locationManager.selectedLocation
...@@ -81,6 +90,36 @@ class RadarViewModel: ViewModelProtocol { ...@@ -81,6 +90,36 @@ class RadarViewModel: ViewModelProtocol {
delegate?.viewModel(model: self, didSelectLayer: selectedLayer) delegate?.viewModel(model: self, didSelectLayer: selectedLayer)
} }
public func buildTimelineValuesFor(validTimes:[String]) -> [MapTimeControlItem] {
#warning("Comparing hourly & valid date disabled")
// guard let hourly = self.location?.hourly else {
// return []
// }
guard let locationTimeZone = location?.timeZone else {
return []
}
var items = [MapTimeControlItem]()
for validTime in validTimes {
guard let validDate = swarmDateFormatter.date(from: validTime) else {
continue
}
let timeZoneDate = validDate.convert(from: locationTimeZone, to: TimeZone(secondsFromGMT: 0)!)
items.append(.init(value: "", date: timeZoneDate))
// for hourlyWeather in hourly {
// if validDate == hourlyWeather.date {
// items.append(.init(value: hourlyWeather.temp?.shortString ?? "",
// date: validDate))
// }
// }
}
return items
}
//Private //Private
private func rebuildLayers() { private func rebuildLayers() {
let pinnedLayerIds = Settings.shared.pinnedLayerIds let pinnedLayerIds = Settings.shared.pinnedLayerIds
......
...@@ -9,175 +9,175 @@ ...@@ -9,175 +9,175 @@
<key>isShown</key> <key>isShown</key>
<false/> <false/>
<key>orderHint</key> <key>orderHint</key>
<integer>1</integer> <integer>0</integer>
</dict> </dict>
<key>BezierKit.xcscheme</key> <key>BezierKit.xcscheme</key>
<dict> <dict>
<key>isShown</key> <key>isShown</key>
<false/> <false/>
<key>orderHint</key> <key>orderHint</key>
<integer>2</integer> <integer>1</integer>
</dict> </dict>
<key>Cirque.xcscheme</key> <key>Cirque.xcscheme</key>
<dict> <dict>
<key>isShown</key> <key>isShown</key>
<false/> <false/>
<key>orderHint</key> <key>orderHint</key>
<integer>3</integer> <integer>2</integer>
</dict> </dict>
<key>Firebase.xcscheme</key> <key>Firebase.xcscheme</key>
<dict> <dict>
<key>isShown</key> <key>isShown</key>
<false/> <false/>
<key>orderHint</key> <key>orderHint</key>
<integer>4</integer> <integer>3</integer>
</dict> </dict>
<key>FirebaseABTesting.xcscheme</key> <key>FirebaseABTesting.xcscheme</key>
<dict> <dict>
<key>isShown</key> <key>isShown</key>
<false/> <false/>
<key>orderHint</key> <key>orderHint</key>
<integer>5</integer> <integer>4</integer>
</dict> </dict>
<key>FirebaseAnalytics.xcscheme</key> <key>FirebaseAnalytics.xcscheme</key>
<dict> <dict>
<key>isShown</key> <key>isShown</key>
<false/> <false/>
<key>orderHint</key> <key>orderHint</key>
<integer>6</integer> <integer>5</integer>
</dict> </dict>
<key>FirebaseCore.xcscheme</key> <key>FirebaseCore.xcscheme</key>
<dict> <dict>
<key>isShown</key> <key>isShown</key>
<false/> <false/>
<key>orderHint</key> <key>orderHint</key>
<integer>7</integer> <integer>6</integer>
</dict> </dict>
<key>FirebaseCoreDiagnostics.xcscheme</key> <key>FirebaseCoreDiagnostics.xcscheme</key>
<dict> <dict>
<key>isShown</key> <key>isShown</key>
<false/> <false/>
<key>orderHint</key> <key>orderHint</key>
<integer>8</integer> <integer>7</integer>
</dict> </dict>
<key>FirebaseCrashlytics.xcscheme</key> <key>FirebaseCrashlytics.xcscheme</key>
<dict> <dict>
<key>isShown</key> <key>isShown</key>
<false/> <false/>
<key>orderHint</key> <key>orderHint</key>
<integer>9</integer> <integer>8</integer>
</dict> </dict>
<key>FirebaseInstallations.xcscheme</key> <key>FirebaseInstallations.xcscheme</key>
<dict> <dict>
<key>isShown</key> <key>isShown</key>
<false/> <false/>
<key>orderHint</key> <key>orderHint</key>
<integer>10</integer> <integer>9</integer>
</dict> </dict>
<key>FirebaseRemoteConfig.xcscheme</key> <key>FirebaseRemoteConfig.xcscheme</key>
<dict> <dict>
<key>isShown</key> <key>isShown</key>
<false/> <false/>
<key>orderHint</key> <key>orderHint</key>
<integer>11</integer> <integer>10</integer>
</dict> </dict>
<key>Flurry-iOS-SDK.xcscheme</key> <key>Flurry-iOS-SDK.xcscheme</key>
<dict> <dict>
<key>isShown</key> <key>isShown</key>
<false/> <false/>
<key>orderHint</key> <key>orderHint</key>
<integer>12</integer> <integer>11</integer>
</dict> </dict>
<key>GoogleAppMeasurement.xcscheme</key> <key>GoogleAppMeasurement.xcscheme</key>
<dict> <dict>
<key>isShown</key> <key>isShown</key>
<false/> <false/>
<key>orderHint</key> <key>orderHint</key>
<integer>13</integer> <integer>12</integer>
</dict> </dict>
<key>GoogleDataTransport.xcscheme</key> <key>GoogleDataTransport.xcscheme</key>
<dict> <dict>
<key>isShown</key> <key>isShown</key>
<false/> <false/>
<key>orderHint</key> <key>orderHint</key>
<integer>14</integer> <integer>13</integer>
</dict> </dict>
<key>GoogleUtilities.xcscheme</key> <key>GoogleUtilities.xcscheme</key>
<dict> <dict>
<key>isShown</key> <key>isShown</key>
<false/> <false/>
<key>orderHint</key> <key>orderHint</key>
<integer>15</integer> <integer>14</integer>
</dict> </dict>
<key>Localize-Swift.xcscheme</key> <key>Localize-Swift.xcscheme</key>
<dict> <dict>
<key>isShown</key> <key>isShown</key>
<false/> <false/>
<key>orderHint</key> <key>orderHint</key>
<integer>16</integer> <integer>15</integer>
</dict> </dict>
<key>Logging.xcscheme</key> <key>Logging.xcscheme</key>
<dict> <dict>
<key>isShown</key> <key>isShown</key>
<false/> <false/>
<key>orderHint</key> <key>orderHint</key>
<integer>17</integer> <integer>16</integer>
</dict> </dict>
<key>MORichNotification.xcscheme</key> <key>MORichNotification.xcscheme</key>
<dict> <dict>
<key>isShown</key> <key>isShown</key>
<false/> <false/>
<key>orderHint</key> <key>orderHint</key>
<integer>19</integer> <integer>18</integer>
</dict> </dict>
<key>MoEngage-iOS-SDK.xcscheme</key> <key>MoEngage-iOS-SDK.xcscheme</key>
<dict> <dict>
<key>isShown</key> <key>isShown</key>
<false/> <false/>
<key>orderHint</key> <key>orderHint</key>
<integer>18</integer> <integer>17</integer>
</dict> </dict>
<key>Pods-1Weather.xcscheme</key> <key>Pods-1Weather.xcscheme</key>
<dict> <dict>
<key>isShown</key> <key>isShown</key>
<false/> <false/>
<key>orderHint</key> <key>orderHint</key>
<integer>21</integer> <integer>20</integer>
</dict> </dict>
<key>PromisesObjC.xcscheme</key> <key>PromisesObjC.xcscheme</key>
<dict> <dict>
<key>isShown</key> <key>isShown</key>
<false/> <false/>
<key>orderHint</key> <key>orderHint</key>
<integer>22</integer> <integer>21</integer>
</dict> </dict>
<key>SnapKit.xcscheme</key> <key>SnapKit.xcscheme</key>
<dict> <dict>
<key>isShown</key> <key>isShown</key>
<false/> <false/>
<key>orderHint</key> <key>orderHint</key>
<integer>23</integer> <integer>22</integer>
</dict> </dict>
<key>Swarm.xcscheme</key> <key>Swarm.xcscheme</key>
<dict> <dict>
<key>isShown</key> <key>isShown</key>
<false/> <false/>
<key>orderHint</key> <key>orderHint</key>
<integer>24</integer> <integer>23</integer>
</dict> </dict>
<key>XMLCoder.xcscheme</key> <key>XMLCoder.xcscheme</key>
<dict> <dict>
<key>isShown</key> <key>isShown</key>
<false/> <false/>
<key>orderHint</key> <key>orderHint</key>
<integer>25</integer> <integer>24</integer>
</dict> </dict>
<key>nanopb.xcscheme</key> <key>nanopb.xcscheme</key>
<dict> <dict>
<key>isShown</key> <key>isShown</key>
<false/> <false/>
<key>orderHint</key> <key>orderHint</key>
<integer>20</integer> <integer>19</integer>
</dict> </dict>
</dict> </dict>
<key>SuppressBuildableAutocreation</key> <key>SuppressBuildableAutocreation</key>
......
...@@ -39,7 +39,9 @@ import MapKit ...@@ -39,7 +39,9 @@ import MapKit
open var loopZoomOffset = 0 { didSet { if loopZoomOffset < 0 { loopZoomOffset = 0 } } } open var loopZoomOffset = 0 { didSet { if loopZoomOffset < 0 { loopZoomOffset = 0 } } }
internal var currentFrameTimestamp: String { return (index >= 0 && index < loopTimes.count) ? loopTimes[index] : "" } internal var currentFrameTimestamp: String {
return (index >= 0 && index < loopTimes.count) ? loopTimes[index] : ""
}
fileprivate var timestamp: String? = nil fileprivate var timestamp: String? = nil
...@@ -67,7 +69,7 @@ import MapKit ...@@ -67,7 +69,7 @@ import MapKit
fileprivate let renderedImageCache = NSCache<AnyObject, AnyObject>() fileprivate let renderedImageCache = NSCache<AnyObject, AnyObject>()
fileprivate var validTimes: AnyObject? = nil public private(set) var validTimes: AnyObject? = nil
fileprivate var loopTimes: [String] = [] { didSet { index = loopTimes.count - 1 } } fileprivate var loopTimes: [String] = [] { didSet { index = loopTimes.count - 1 } }
internal(set) var zoomScale: MKZoomScale = 0.0 internal(set) var zoomScale: MKZoomScale = 0.0
......
...@@ -35,6 +35,8 @@ open class SwarmTileOverlayRenderer: MKTileOverlayRenderer { ...@@ -35,6 +35,8 @@ open class SwarmTileOverlayRenderer: MKTileOverlayRenderer {
return true return true
} }
print("[SWARM] TimeStamp: \(timeStamp)")
swarmOverlay.downloadTileAtURL(url) { [weak self] error in swarmOverlay.downloadTileAtURL(url) { [weak self] error in
guard error == nil else { return } guard error == nil else { return }
self?.setNeedsDisplay(mapRect, zoomScale: zoomScale) self?.setNeedsDisplay(mapRect, zoomScale: zoomScale)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment