Commit 4bad4c86 by Dmitriy Stepanets

Starting working on RadarController

parent 6957e2c8
No preview for this file type
......@@ -73,6 +73,8 @@
CD6B303E25726960004B34B3 /* ThemeProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = CD6B303D25726960004B34B3 /* ThemeProtocol.swift */; };
CD6B304325726AD1004B34B3 /* DefaultTheme.swift in Sources */ = {isa = PBXBuildFile; fileRef = CD6B304225726AD1004B34B3 /* DefaultTheme.swift */; };
CD71709025FA317700A63C27 /* ForecastTimePeriodView.swift in Sources */ = {isa = PBXBuildFile; fileRef = CD71708F25FA317700A63C27 /* ForecastTimePeriodView.swift */; };
CD7BF15526203E6900A30DF5 /* RadarViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = CD7BF15426203E6900A30DF5 /* RadarViewController.swift */; };
CD7BF1582620410800A30DF5 /* RadarCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = CD7BF1572620410800A30DF5 /* RadarCoordinator.swift */; };
CD80917B2578E4A8003541A4 /* UIViewController+Alert.swift in Sources */ = {isa = PBXBuildFile; fileRef = CD80917A2578E4A8003541A4 /* UIViewController+Alert.swift */; };
CD822FF525D6817000A05501 /* TodayForecastCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = CD822FF425D6817000A05501 /* TodayForecastCell.swift */; };
CD822FFA25D6890900A05501 /* OneWeatherColorsAsset.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = CD822FF925D6890900A05501 /* OneWeatherColorsAsset.xcassets */; };
......@@ -99,6 +101,8 @@
CDA5542825EF734200A2E08C /* TodayCellFactory.swift in Sources */ = {isa = PBXBuildFile; fileRef = CDA5542725EF734200A2E08C /* TodayCellFactory.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 */; };
CDAD97B1262042B2007FCFB1 /* MapButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = CDAD97B0262042B2007FCFB1 /* MapButton.swift */; };
CDAD97B426207D14007FCFB1 /* MapTimeControlView.swift in Sources */ = {isa = PBXBuildFile; fileRef = CDAD97B326207D14007FCFB1 /* MapTimeControlView.swift */; };
CDC6124F25E7964700188DA7 /* TodayDayTimesCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = CDC6124E25E7964700188DA7 /* TodayDayTimesCell.swift */; };
CDC6125325E79C8F00188DA7 /* DayTimeView.swift in Sources */ = {isa = PBXBuildFile; fileRef = CDC6125225E79C8F00188DA7 /* DayTimeView.swift */; };
CDC6125725E7AB1A00188DA7 /* TodayAirQualityCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = CDC6125625E7AB1A00188DA7 /* TodayAirQualityCell.swift */; };
......@@ -119,6 +123,8 @@
CDEE8AD725DA882200C289DE /* ForecastPeriodButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = CDEE8AD625DA882200C289DE /* ForecastPeriodButton.swift */; };
CDF4808F261727E00076E9F5 /* CLAuthorizationStatus+Localized.swift in Sources */ = {isa = PBXBuildFile; fileRef = CDF4808E261727E00076E9F5 /* CLAuthorizationStatus+Localized.swift */; };
CDF48092261729680076E9F5 /* UIApplication+Settings.swift in Sources */ = {isa = PBXBuildFile; fileRef = CDF48091261729680076E9F5 /* UIApplication+Settings.swift */; };
CDF8F12A262089A200DB384A /* MapTimeView.swift in Sources */ = {isa = PBXBuildFile; fileRef = CDF8F129262089A200DB384A /* MapTimeView.swift */; };
CDF8F12D26208E7B00DB384A /* CurrentTimeView.swift in Sources */ = {isa = PBXBuildFile; fileRef = CDF8F12C26208E7B00DB384A /* CurrentTimeView.swift */; };
CDF9BF8E26133D050037847D /* LocationSearchCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = CDF9BF8D26133D050037847D /* LocationSearchCoordinator.swift */; };
CE28474F26159857006C8DC5 /* HealthSource.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE28474E26159857006C8DC5 /* HealthSource.swift */; };
CE28475226159A32006C8DC5 /* BlendHealthModels.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE28475126159A32006C8DC5 /* BlendHealthModels.swift */; };
......@@ -257,6 +263,8 @@
CD6B303D25726960004B34B3 /* ThemeProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ThemeProtocol.swift; sourceTree = "<group>"; };
CD6B304225726AD1004B34B3 /* DefaultTheme.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DefaultTheme.swift; sourceTree = "<group>"; };
CD71708F25FA317700A63C27 /* ForecastTimePeriodView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ForecastTimePeriodView.swift; sourceTree = "<group>"; };
CD7BF15426203E6900A30DF5 /* RadarViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RadarViewController.swift; sourceTree = "<group>"; };
CD7BF1572620410800A30DF5 /* RadarCoordinator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RadarCoordinator.swift; sourceTree = "<group>"; };
CD80917A2578E4A8003541A4 /* UIViewController+Alert.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIViewController+Alert.swift"; sourceTree = "<group>"; };
CD822FF425D6817000A05501 /* TodayForecastCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TodayForecastCell.swift; sourceTree = "<group>"; };
CD822FF925D6890900A05501 /* OneWeatherColorsAsset.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = OneWeatherColorsAsset.xcassets; sourceTree = "<group>"; };
......@@ -283,6 +291,8 @@
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>"; };
CDA5542F25EFA13F00A2E08C /* Measurement+String.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Measurement+String.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>"; };
CDC6124E25E7964700188DA7 /* TodayDayTimesCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TodayDayTimesCell.swift; sourceTree = "<group>"; };
CDC6125225E79C8F00188DA7 /* DayTimeView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DayTimeView.swift; sourceTree = "<group>"; };
CDC6125625E7AB1A00188DA7 /* TodayAirQualityCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TodayAirQualityCell.swift; sourceTree = "<group>"; };
......@@ -303,6 +313,8 @@
CDEE8AD625DA882200C289DE /* ForecastPeriodButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ForecastPeriodButton.swift; sourceTree = "<group>"; };
CDF4808E261727E00076E9F5 /* CLAuthorizationStatus+Localized.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "CLAuthorizationStatus+Localized.swift"; sourceTree = "<group>"; };
CDF48091261729680076E9F5 /* UIApplication+Settings.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIApplication+Settings.swift"; sourceTree = "<group>"; };
CDF8F129262089A200DB384A /* MapTimeView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MapTimeView.swift; sourceTree = "<group>"; };
CDF8F12C26208E7B00DB384A /* CurrentTimeView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CurrentTimeView.swift; sourceTree = "<group>"; };
CDF9BF8D26133D050037847D /* LocationSearchCoordinator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LocationSearchCoordinator.swift; sourceTree = "<group>"; };
CE28474E26159857006C8DC5 /* HealthSource.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HealthSource.swift; sourceTree = "<group>"; };
CE28475126159A32006C8DC5 /* BlendHealthModels.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BlendHealthModels.swift; sourceTree = "<group>"; };
......@@ -517,6 +529,7 @@
CD37D3F2260DF4FB002669D6 /* SettingsCoordinator.swift */,
CD866A75260F77C500E96A5C /* SettingsDetailsCoordinator.swift */,
CDF9BF8D26133D050037847D /* LocationSearchCoordinator.swift */,
CD7BF1572620410800A30DF5 /* RadarCoordinator.swift */,
);
path = Coordinators;
sourceTree = "<group>";
......@@ -626,10 +639,11 @@
CD6B3038257267E2004B34B3 /* View controllers */ = {
isa = PBXGroup;
children = (
CE578FE025FB415E00E8B85D /* Locations */,
CD17C5F425D15B3400EE884E /* Today */,
CDE18DCF25D166DD00C80ED9 /* Forecast */,
CD7BF15026203E2300A30DF5 /* Radar */,
CD32CE02260C740600235081 /* Menu */,
CE578FE025FB415E00E8B85D /* Locations */,
CD37D3ED260DF4B8002669D6 /* Settings */,
CD82300925D6B2AF00A05501 /* AppTabBarController.swift */,
);
......@@ -655,6 +669,16 @@
path = Themes;
sourceTree = "<group>";
};
CD7BF15026203E2300A30DF5 /* Radar */ = {
isa = PBXGroup;
children = (
CDAD97B726207DFE007FCFB1 /* MapTimeControl */,
CDAD97AF26204285007FCFB1 /* Controls */,
CD7BF15426203E6900A30DF5 /* RadarViewController.swift */,
);
path = Radar;
sourceTree = "<group>";
};
CD822FF325D6814300A05501 /* Cells */ = {
isa = PBXGroup;
children = (
......@@ -713,6 +737,24 @@
path = Cells;
sourceTree = "<group>";
};
CDAD97AF26204285007FCFB1 /* Controls */ = {
isa = PBXGroup;
children = (
CDAD97B0262042B2007FCFB1 /* MapButton.swift */,
);
path = Controls;
sourceTree = "<group>";
};
CDAD97B726207DFE007FCFB1 /* MapTimeControl */ = {
isa = PBXGroup;
children = (
CDAD97B326207D14007FCFB1 /* MapTimeControlView.swift */,
CDF8F129262089A200DB384A /* MapTimeView.swift */,
CDF8F12C26208E7B00DB384A /* CurrentTimeView.swift */,
);
path = MapTimeControl;
sourceTree = "<group>";
};
CDC0C7AE261310DB0030607A /* SharedCells */ = {
isa = PBXGroup;
children = (
......@@ -1172,6 +1214,7 @@
CD35DFD0260344A500F2138F /* ForecastConditionView.swift in Sources */,
CD2ABF32261489F700C1A92E /* LocationCellFactory.swift in Sources */,
CE8962B126175DF500CA274A /* CoreHourlyWeather.swift in Sources */,
CD7BF15526203E6900A30DF5 /* RadarViewController.swift in Sources */,
CD82300325D69DE400A05501 /* TodayConditionsCell.swift in Sources */,
CEF959902600C5A800975FAA /* MoEngageAnalyticsService.swift in Sources */,
CEC526FD25E795F700DA58A5 /* WdtWeatherSource.swift in Sources */,
......@@ -1209,9 +1252,11 @@
CD593BC226088A5900C93428 /* TimePeriodOffsetHolder.swift in Sources */,
CE8962A226175DF500CA274A /* _CoreAirQuality.swift in Sources */,
CD17C5FB25D15B6B00EE884E /* AppCoordinator.swift in Sources */,
CDAD97B426207D14007FCFB1 /* MapTimeControlView.swift in Sources */,
CD32CE0E260C770E00235081 /* MenuHeaderView.swift in Sources */,
CD15DB3D25DA6C5100024727 /* ForecastTimePeriodControl.swift in Sources */,
CD1237F1255D83C500C98139 /* UIColor+Hex.swift in Sources */,
CD7BF1582620410800A30DF5 /* RadarCoordinator.swift in Sources */,
CDD0F1EE25725BCF00CF5017 /* ThemeManager.swift in Sources */,
CD1237F4255D889F00C98139 /* GradientView.swift in Sources */,
CD37D3EF260DF4E6002669D6 /* SettingsViewController.swift in Sources */,
......@@ -1231,6 +1276,7 @@
CD35DFD426034BCD00F2138F /* UIStackView+RemoveAll.swift in Sources */,
CD37D3E5260CB05C002669D6 /* MenuFooterView.swift in Sources */,
CDE18DD825D16CB200C80ED9 /* NavigationCityButton.swift in Sources */,
CDAD97B1262042B2007FCFB1 /* MapButton.swift in Sources */,
CD593BDC2608CDF100C93428 /* Date+Now.swift in Sources */,
CD17C60225D15C8500EE884E /* CoordinatorProtocol.swift in Sources */,
CDA5542825EF734200A2E08C /* TodayCellFactory.swift in Sources */,
......@@ -1301,6 +1347,7 @@
CD86246125E662BC0097F3FB /* SunUvLineView.swift in Sources */,
CD32CE0B260C744A00235081 /* MenuCoordinator.swift in Sources */,
CD55E0BB2615EE2400CC4DC7 /* PollutantView.swift in Sources */,
CDF8F12A262089A200DB384A /* MapTimeView.swift in Sources */,
CEC526FA25E7959A00DA58A5 /* WeatherSource.swift in Sources */,
CDF4808F261727E00076E9F5 /* CLAuthorizationStatus+Localized.swift in Sources */,
CD37D3DE260C9E37002669D6 /* MenuCell.swift in Sources */,
......@@ -1323,6 +1370,7 @@
CD37D3EB260DD30F002669D6 /* Settings.swift in Sources */,
CD17C5F625D15B4400EE884E /* TodayViewController.swift in Sources */,
CD86245E25E646350097F3FB /* SunUvView.swift in Sources */,
CDF8F12D26208E7B00DB384A /* CurrentTimeView.swift in Sources */,
CEAFF08325DFC67F00DF4EBF /* Location.swift in Sources */,
87C171EC25FF79CC00DA3464 /* EnvironmentManager.swift in Sources */,
CEFB857226174F7A00C5CDD2 /* Storage.swift in Sources */,
......
......@@ -29,7 +29,7 @@ class AppCoordinator: Coordinator {
forecastCoordinator.start()
childCoordinators.append(forecastCoordinator)
let radarCoordinator = ForecastCoordinator(tabBarController: tabBarController)
let radarCoordinator = RadarCoordinator(tabBarController: tabBarController)
radarCoordinator.start()
childCoordinators.append(radarCoordinator)
......
//
// RadarCoordinator.swift
// 1Weather
//
// Created by Dmitry Stepanets on 09.04.2021.
//
import UIKit
class RadarCoordinator: Coordinator {
//Private
private let navigationController = UINavigationController(nibName: nil, bundle: nil)
private var tabBarController:UITabBarController?
//Public
var childCoordinators = [Coordinator]()
var parentCoordinator: Coordinator?
init(tabBarController:UITabBarController) {
self.tabBarController = tabBarController
}
func start() {
let radarViewController = RadarViewController(coordinator: self)
navigationController.viewControllers = [radarViewController]
tabBarController?.add(viewController: navigationController)
}
func viewControllerDidEnd(controller: UIViewController) {
//
}
}
{
"images" : [
{
"filename" : "map_fullscreen.pdf",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
},
"properties" : {
"preserves-vector-representation" : true,
"template-rendering-intent" : "template"
}
}
{
"images" : [
{
"filename" : "map_layers.pdf",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
},
"properties" : {
"preserves-vector-representation" : true,
"template-rendering-intent" : "template"
}
}
{
"images" : [
{
"filename" : "map_precipitation.pdf",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
},
"properties" : {
"preserves-vector-representation" : true
}
}
{
"images" : [
{
"filename" : "map_radar.pdf",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
},
"properties" : {
"preserves-vector-representation" : true,
"template-rendering-intent" : "template"
}
}
{
"images" : [
{
"filename" : "map_time_bubble.pdf",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
},
"properties" : {
"preserves-vector-representation" : true,
"template-rendering-intent" : "template"
}
}
{
"images" : [
{
"filename" : "pause_icon.pdf",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
},
"properties" : {
"preserves-vector-representation" : true,
"template-rendering-intent" : "template"
}
}
{
"images" : [
{
"filename" : "play_icon.pdf",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
},
"properties" : {
"preserves-vector-representation" : true,
"template-rendering-intent" : "template"
}
}
{
"colors" : [
{
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "253",
"green" : "247",
"red" : "246"
}
},
"idiom" : "universal"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "dark"
}
],
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "26",
"green" : "23",
"red" : "23"
}
},
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
......@@ -110,4 +110,9 @@ struct DefaultTheme: ThemeProtocol {
var graphTintColor: UIColor {
return UIColor(named: "graph_tint_color") ?? .red
}
//Map
var mapControlsColor: UIColor {
return UIColor(named: "map_controls_color") ?? .red
}
}
......@@ -46,4 +46,7 @@ public protocol ThemeProtocol {
//Graph
var graphColor:UIColor { get }
var graphTintColor:UIColor { get }
//Map
var mapControlsColor:UIColor { get }
}
//
// MapButton.swift
// 1Weather
//
// Created by Dmitry Stepanets on 09.04.2021.
//
import UIKit
class MapButton: UIControl {
//Private
private let imageView = UIImageView()
private let gradient = CAGradientLayer()
init(image: UIImage?) {
super.init(frame: .zero)
self.imageView.image = image
prepareButton()
prepareGradient()
prepareImageView()
updateUI()
}
override func layoutSubviews() {
super.layoutSubviews()
self.layer.cornerRadius = (self.bounds.height / 2).rounded(.down)
self.gradient.frame = self.bounds
self.gradient.cornerRadius = (self.bounds.height / 2).rounded(.down)
self.layer.shadowPath = UIBezierPath(roundedRect: self.bounds, cornerRadius: self.layer.cornerRadius).cgPath
}
override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
super.traitCollectionDidChange(previousTraitCollection)
updateUI()
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
super.touchesBegan(touches, with: event)
UIView.performWithoutAnimation {
self.alpha = 0.7
}
}
override func touchesEnded(_ touches: Set<UITouch>, with event: UIEvent?) {
super.touchesBegan(touches, with: event)
UIView.performWithoutAnimation {
self.alpha = 1
}
}
//Private
private func updateUI() {
switch interfaceStyle {
case .light:
self.gradient.opacity = 0
self.backgroundColor = ThemeManager.currentTheme.mapControlsColor.withAlphaComponent(0.8)
self.imageView.tintColor = UIColor(hex: 0x3a4044)
case .dark:
self.gradient.opacity = 0.8
self.backgroundColor = .clear
self.imageView.tintColor = .white
}
}
}
//MARK:- Prepare
private extension MapButton {
func prepareButton() {
self.clipsToBounds = false
layer.shadowColor = UIColor.black.withAlphaComponent(0.3).cgColor
layer.shadowOffset = .init(width: 0, height: 3)
layer.shadowOpacity = 1
layer.shadowRadius = 5
}
func prepareGradient() {
gradient.startPoint = .init(x: 0.5, y: 0)
gradient.endPoint = .init(x: 0.5, y: 1)
gradient.colors = [UIColor(hex: 0x49494d).cgColor, UIColor(hex: 0x29292d).cgColor]
gradient.opacity = 0.8
layer.insertSublayer(gradient, at: 0)
}
func prepareImageView() {
imageView.isUserInteractionEnabled = false
imageView.contentMode = .center
imageView.clipsToBounds = true
addSubview(imageView)
imageView.snp.makeConstraints { (make) in
make.edges.equalToSuperview()
}
}
}
//
// CurrentTimeView.swift
// 1Weather
//
// Created by Dmitry Stepanets on 09.04.2021.
//
import UIKit
class CurrentTimeView: UIView {
private let imageView = UIImageView()
private let tempLabel = UILabel()
private let timeLabel = UILabel()
init() {
super.init(frame: .zero)
prepareView()
prepareImageView()
prepareLabels()
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}
//MARK:- Prepare
private extension CurrentTimeView {
func prepareView() {
self.backgroundColor = .clear
}
func prepareImageView() {
imageView.contentMode = .scaleAspectFit
imageView.image = UIImage(named: "map_time_bubble")
imageView.tintColor = ThemeManager.currentTheme.graphTintColor
addSubview(imageView)
imageView.snp.makeConstraints { (make) in
make.edges.equalToSuperview()
}
}
func prepareLabels() {
tempLabel.font = AppFont.SFPro.bold(size: 14)
tempLabel.textColor = .white
tempLabel.text = "49°"
tempLabel.setContentHuggingPriority(.fittingSizeLevel, for: .vertical)
addSubview(tempLabel)
timeLabel.font = AppFont.SFPro.bold(size: 10)
timeLabel.textColor = .white
timeLabel.text = "2:50 PM"
addSubview(timeLabel)
//Constraints
tempLabel.snp.makeConstraints { (make) in
make.top.equalToSuperview().inset(4)
make.centerX.equalToSuperview()
}
timeLabel.snp.makeConstraints { (make) in
make.top.equalTo(tempLabel.snp.bottom)
make.left.right.equalToSuperview().inset(4)
make.bottom.equalToSuperview().inset(9)
}
}
}
//
// MapTimeControlView.swift
// 1Weather
//
// Created by Dmitry Stepanets on 09.04.2021.
//
import UIKit
class MapTimeControlView: UIView {
//Private
private let container = UIView()
private let playButton = UIButton()
private let playButtonGradient = CAGradientLayer()
private let stackView = UIStackView()
private let currenTimeView = CurrentTimeView()
init() {
super.init(frame: .zero)
prepareView()
prepareContainer()
preparePlayButton()
prepareStackView()
prepareCurrentTimeView()
updateUI()
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
override func layoutSubviews() {
super.layoutSubviews()
container.layoutIfNeeded()
playButton.layoutIfNeeded()
playButton.layer.cornerRadius = (playButton.bounds.width / 2).rounded(.down)
playButtonGradient.frame = playButton.bounds
playButtonGradient.cornerRadius = playButton.layer.cornerRadius
container.layer.shadowPath = UIBezierPath(roundedRect: self.container.bounds,
cornerRadius: 14).cgPath
playButton.layer.shadowPath = UIBezierPath(roundedRect: self.playButton.bounds,
cornerRadius: self.playButton.layer.cornerRadius).cgPath
}
override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
super.traitCollectionDidChange(previousTraitCollection)
updateUI()
}
private func updateUI() {
container.backgroundColor = ThemeManager.currentTheme.mapControlsColor
switch interfaceStyle {
case .light:
playButtonGradient.colors = [UIColor(hex: 0xffffff).cgColor, UIColor(hex: 0xeceef6).cgColor]
case .dark:
playButtonGradient.colors = [UIColor(hex: 0x49494d).cgColor, UIColor(hex: 0x29292d).cgColor]
}
}
}
//MARK:- Prepare
private extension MapTimeControlView {
func prepareView() {
backgroundColor = .clear
}
func prepareContainer() {
container.layer.cornerRadius = 14
container.layer.shadowColor = UIColor(hex:0x0c192f).withAlphaComponent(0.06).cgColor
container.layer.shadowOffset = .init(width: 0, height: 5)
container.layer.shadowRadius = 20
container.layer.shadowOpacity = 1
addSubview(container)
container.snp.makeConstraints { (make) in
make.left.bottom.right.equalToSuperview()
make.height.equalTo(46)
}
}
func preparePlayButton() {
playButton.setImage(UIImage(named: "play_icon"), for: .normal)
playButton.tintColor = ThemeManager.currentTheme.graphTintColor
playButton.layer.shadowColor = UIColor.black.withAlphaComponent(0.12).cgColor
playButton.layer.shadowOffset = .init(width: 0, height: 3)
playButton.layer.shadowRadius = 8
playButton.layer.shadowOpacity = 1
playButtonGradient.startPoint = .init(x: 0.5, y: 0)
playButtonGradient.endPoint = .init(x: 0.5, y: 1)
playButton.layer.insertSublayer(playButtonGradient, below: playButton.imageView?.layer)
container.addSubview(playButton)
playButton.snp.makeConstraints { (make) in
make.width.height.equalTo(24)
make.centerY.equalToSuperview()
make.left.equalToSuperview().inset(12)
}
}
func prepareStackView() {
stackView.axis = .horizontal
stackView.distribution = .fillProportionally
stackView.clipsToBounds = false
container.addSubview(stackView)
stackView.snp.makeConstraints { (make) in
make.top.bottom.equalToSuperview()
make.left.equalTo(playButton.snp.right).offset(8)
make.right.equalToSuperview().inset(8)
}
for _ in 0..<5 {
let view = MapTimeView()
stackView.addArrangedSubview(view)
}
}
func prepareCurrentTimeView() {
addSubview(currenTimeView)
currenTimeView.snp.makeConstraints { (make) in
make.top.equalToSuperview()
make.bottom.equalTo(container.snp.top)
make.centerX.equalToSuperview()
}
}
}
//
// MapTimeView.swift
// 1Weather
//
// Created by Dmitry Stepanets on 09.04.2021.
//
import UIKit
class MapTimeView: UIView {
private let tempLabel = UILabel()
private let timeLabel = UILabel()
init() {
super.init(frame: .zero)
prepareLabels()
updateUI()
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
super.traitCollectionDidChange(previousTraitCollection)
updateUI()
}
private func updateUI() {
switch interfaceStyle {
case .light:
tempLabel.textColor = ThemeManager.currentTheme.secondaryTextColor
timeLabel.textColor = ThemeManager.currentTheme.secondaryTextColor
case .dark:
tempLabel.textColor = ThemeManager.currentTheme.primaryTextColor
timeLabel.textColor = ThemeManager.currentTheme.primaryTextColor
}
}
}
private extension MapTimeView {
func prepareLabels() {
tempLabel.text = "45°"
tempLabel.font = AppFont.SFPro.regular(size: 10)
addSubview(tempLabel)
timeLabel.text = "2:00"
timeLabel.textAlignment = .center
timeLabel.font = AppFont.SFPro.regular(size: 14)
timeLabel.setContentCompressionResistancePriority(.fittingSizeLevel, for: .vertical)
addSubview(timeLabel)
//Constraints
tempLabel.snp.makeConstraints { (make) in
make.top.equalToSuperview().inset(10)
make.centerX.equalToSuperview()
}
timeLabel.snp.makeConstraints { (make) in
make.bottom.equalToSuperview().inset(5)
make.top.equalTo(tempLabel.snp.bottom).offset(4)
make.left.right.equalToSuperview().inset(2)
}
}
}
//
// RadarViewController.swift
// 1Weather
//
// Created by Dmitry Stepanets on 09.04.2021.
//
import UIKit
import MapKit
class RadarViewController: UIViewController {
//Private
private let coordinator:RadarCoordinator
private let cityButton = NavigationCityButton()
private var localizationObserver:Any?
private let mapView = MKMapView()
//Buttons
private let fullScreenButton = MapButton(image: UIImage(named: "map_fullscreen"))
private let precipitationButton = MapButton(image: UIImage(named: "map_precipitation"))
private let layersButton = MapButton(image: UIImage(named: "map_layers"))
private let radarButton = MapButton(image: UIImage(named: "map_radar"))
private let mapTimeControlView = MapTimeControlView()
private let locationButton = UIButton()
init(coordinator:RadarCoordinator) {
self.coordinator = coordinator
super.init(nibName: nil, bundle: nil)
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
super.traitCollectionDidChange(previousTraitCollection)
updateUI()
}
override func viewDidLoad() {
super.viewDidLoad()
prepareNavigationBar()
prepareViewController()
// prepareMapView()
prepareLocationButton()
prepareMapButtons()
prepareMapTimeControl()
updateUI()
}
//Private
private func updateUI() {
view.backgroundColor = ThemeManager.currentTheme.baseBackgroundColor
locationButton.backgroundColor = ThemeManager.currentTheme.mapControlsColor
}
@objc private func handleCityButton() {
}
@objc private func handleNotificationButton() {
}
@objc private func handleFullScreenButton() {
}
@objc private func handlePrecipitationButton() {
}
@objc private func handleLayersButton() {
}
@objc private func handleRadarButton() {
}
@objc private func handleLocationButton() {
}
}
//MARK:- Prepare
private extension RadarViewController {
func prepareViewController() {
localizationObserver = NotificationCenter.default.addObserver(forName: .localizationChange, object: nil, queue: .main, using: { _ in
})
}
func prepareNavigationBar() {
//City button
cityButton.addTarget(self, action: #selector(handleCityButton), for: .touchUpInside)
let cityBarItem = UIBarButtonItem(customView: cityButton)
let barSpacer = UIBarButtonItem(barButtonSystemItem: .fixedSpace, target: nil, action: nil)
barSpacer.width = 18
//Notification button
let notificationButton = UIButton()
notificationButton.frame = .init(origin: .zero, size: .init(width: 40, height: 40))
notificationButton.setImage(UIImage(named: "bell"), for: .normal)
notificationButton.tintColor = ThemeManager.currentTheme.primaryTextColor
notificationButton.addTarget(self, action: #selector(handleNotificationButton), for: .touchUpInside)
let notificationBarButton = UIBarButtonItem(customView: notificationButton)
notificationButton.contentEdgeInsets = .init(top: 0, left: 16, bottom: 0, right: 0)
self.navigationItem.leftBarButtonItems = [barSpacer, cityBarItem]
self.navigationItem.rightBarButtonItem = notificationBarButton
}
func prepareMapView() {
mapView.showsCompass = false
view.addSubview(mapView)
mapView.snp.makeConstraints { (make) in
make.edges.equalToSuperview()
}
}
func prepareMapButtons() {
//Full screen
fullScreenButton.addTarget(self, action: #selector(handleFullScreenButton), for: .touchUpInside)
view.addSubview(fullScreenButton)
fullScreenButton.snp.makeConstraints { (make) in
make.width.height.equalTo(40)
make.top.equalToSuperview().inset(16)
make.right.equalToSuperview().inset(8)
}
//Precipitation
precipitationButton.addTarget(self, action: #selector(handlePrecipitationButton), for: .touchUpInside)
view.addSubview(precipitationButton)
precipitationButton.snp.makeConstraints { (make) in
make.width.height.equalTo(46)
make.right.equalToSuperview().inset(8)
make.bottom.equalTo(locationButton.snp.top).offset(-18)
}
//Layers
layersButton.addTarget(self, action: #selector(handleLayersButton), for: .touchUpInside)
view.addSubview(layersButton)
layersButton.snp.makeConstraints { (make) in
make.width.height.equalTo(46)
make.right.equalToSuperview().inset(8)
make.bottom.equalTo(precipitationButton.snp.top).offset(-18)
}
//Radar
radarButton.addTarget(self, action: #selector(handleRadarButton), for: .touchUpInside)
view.addSubview(radarButton)
radarButton.snp.makeConstraints { (make) in
make.width.height.equalTo(46)
make.right.equalToSuperview().inset(8)
make.bottom.equalTo(layersButton.snp.top).offset(-18)
}
}
func prepareLocationButton() {
locationButton.setImage(UIImage(named: "location_arrow"), for: .normal)
locationButton.layer.cornerRadius = 14
locationButton.addTarget(self, action: #selector(handleLocationButton), for: .touchUpInside)
locationButton.tintColor = ThemeManager.currentTheme.graphTintColor
view.addSubview(locationButton)
locationButton.snp.makeConstraints { (make) in
make.width.height.equalTo(46)
make.right.equalToSuperview().inset(8)
make.bottom.equalToSuperview().inset(4)
}
}
func prepareMapTimeControl() {
view.addSubview(mapTimeControlView)
mapTimeControlView.snp.makeConstraints { (make) in
make.left.bottom.equalToSuperview().inset(4)
make.right.equalTo(locationButton.snp.left).offset(-4)
}
}
}
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