Commit cbdfe4ca by Dmitriy Stepanets

Started implementing dark mode

parent bb0e57d7
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
CD1DDD332602305200AC62B2 /* ForecastInfoCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = CD1DDD322602305200AC62B2 /* ForecastInfoCell.swift */; }; CD1DDD332602305200AC62B2 /* ForecastInfoCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = CD1DDD322602305200AC62B2 /* ForecastInfoCell.swift */; };
CD251ED82603633800ED7A65 /* ForecastPrecipitationCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = CD251ED72603633800ED7A65 /* ForecastPrecipitationCell.swift */; }; CD251ED82603633800ED7A65 /* ForecastPrecipitationCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = CD251ED72603633800ED7A65 /* ForecastPrecipitationCell.swift */; };
CD251EDC26036E5400ED7A65 /* DayTimePrecipitationView.swift in Sources */ = {isa = PBXBuildFile; fileRef = CD251EDB26036E5400ED7A65 /* DayTimePrecipitationView.swift */; }; CD251EDC26036E5400ED7A65 /* DayTimePrecipitationView.swift in Sources */ = {isa = PBXBuildFile; fileRef = CD251EDB26036E5400ED7A65 /* DayTimePrecipitationView.swift */; };
CD2B2140260A366B00AB918A /* UIView+InterfaceStyle.swift in Sources */ = {isa = PBXBuildFile; fileRef = CD2B213F260A366B00AB918A /* UIView+InterfaceStyle.swift */; };
CD35DFCC260341B000F2138F /* Calendar+TimeZone.swift in Sources */ = {isa = PBXBuildFile; fileRef = CD35DFCB260341B000F2138F /* Calendar+TimeZone.swift */; }; CD35DFCC260341B000F2138F /* Calendar+TimeZone.swift in Sources */ = {isa = PBXBuildFile; fileRef = CD35DFCB260341B000F2138F /* Calendar+TimeZone.swift */; };
CD35DFD0260344A500F2138F /* ForecastConditionView.swift in Sources */ = {isa = PBXBuildFile; fileRef = CD35DFCF260344A500F2138F /* ForecastConditionView.swift */; }; CD35DFD0260344A500F2138F /* ForecastConditionView.swift in Sources */ = {isa = PBXBuildFile; fileRef = CD35DFCF260344A500F2138F /* ForecastConditionView.swift */; };
CD35DFD426034BCD00F2138F /* UIStackView+RemoveAll.swift in Sources */ = {isa = PBXBuildFile; fileRef = CD35DFD326034BCD00F2138F /* UIStackView+RemoveAll.swift */; }; CD35DFD426034BCD00F2138F /* UIStackView+RemoveAll.swift in Sources */ = {isa = PBXBuildFile; fileRef = CD35DFD326034BCD00F2138F /* UIStackView+RemoveAll.swift */; };
...@@ -125,6 +126,7 @@ ...@@ -125,6 +126,7 @@
CD1DDD322602305200AC62B2 /* ForecastInfoCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ForecastInfoCell.swift; sourceTree = "<group>"; }; CD1DDD322602305200AC62B2 /* ForecastInfoCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ForecastInfoCell.swift; sourceTree = "<group>"; };
CD251ED72603633800ED7A65 /* ForecastPrecipitationCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ForecastPrecipitationCell.swift; sourceTree = "<group>"; }; CD251ED72603633800ED7A65 /* ForecastPrecipitationCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ForecastPrecipitationCell.swift; sourceTree = "<group>"; };
CD251EDB26036E5400ED7A65 /* DayTimePrecipitationView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DayTimePrecipitationView.swift; sourceTree = "<group>"; }; CD251EDB26036E5400ED7A65 /* DayTimePrecipitationView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DayTimePrecipitationView.swift; sourceTree = "<group>"; };
CD2B213F260A366B00AB918A /* UIView+InterfaceStyle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIView+InterfaceStyle.swift"; sourceTree = "<group>"; };
CD35DFCB260341B000F2138F /* Calendar+TimeZone.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Calendar+TimeZone.swift"; sourceTree = "<group>"; }; CD35DFCB260341B000F2138F /* Calendar+TimeZone.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Calendar+TimeZone.swift"; sourceTree = "<group>"; };
CD35DFCF260344A500F2138F /* ForecastConditionView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ForecastConditionView.swift; sourceTree = "<group>"; }; CD35DFCF260344A500F2138F /* ForecastConditionView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ForecastConditionView.swift; sourceTree = "<group>"; };
CD35DFD326034BCD00F2138F /* UIStackView+RemoveAll.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIStackView+RemoveAll.swift"; sourceTree = "<group>"; }; CD35DFD326034BCD00F2138F /* UIStackView+RemoveAll.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIStackView+RemoveAll.swift"; sourceTree = "<group>"; };
...@@ -296,6 +298,7 @@ ...@@ -296,6 +298,7 @@
CD35DFD326034BCD00F2138F /* UIStackView+RemoveAll.swift */, CD35DFD326034BCD00F2138F /* UIStackView+RemoveAll.swift */,
CD593BC826089FC100C93428 /* UITableView+HeaderSize.swift */, CD593BC826089FC100C93428 /* UITableView+HeaderSize.swift */,
CD593BDB2608CDF100C93428 /* Date+Now.swift */, CD593BDB2608CDF100C93428 /* Date+Now.swift */,
CD2B213F260A366B00AB918A /* UIView+InterfaceStyle.swift */,
); );
path = Extensions; path = Extensions;
sourceTree = "<group>"; sourceTree = "<group>";
...@@ -760,6 +763,7 @@ ...@@ -760,6 +763,7 @@
CD86C22225F0DCCB00F38A16 /* PrecipitationView.swift in Sources */, CD86C22225F0DCCB00F38A16 /* PrecipitationView.swift in Sources */,
CD17C5FF25D15B7C00EE884E /* TodayCoordinator.swift in Sources */, CD17C5FF25D15B7C00EE884E /* TodayCoordinator.swift in Sources */,
CD822FF525D6817000A05501 /* CityForecastCell.swift in Sources */, CD822FF525D6817000A05501 /* CityForecastCell.swift in Sources */,
CD2B2140260A366B00AB918A /* UIView+InterfaceStyle.swift in Sources */,
CEDE4E8525EEFD56007457E9 /* WdtHourlySummariesArray.swift in Sources */, CEDE4E8525EEFD56007457E9 /* WdtHourlySummariesArray.swift in Sources */,
CDC6125725E7AB1A00188DA7 /* CityAirQualityCell.swift in Sources */, CDC6125725E7AB1A00188DA7 /* CityAirQualityCell.swift in Sources */,
CD593BCF2608A50900C93428 /* ForecastHourlyCell.swift in Sources */, CD593BCF2608A50900C93428 /* ForecastHourlyCell.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>5</integer> <integer>6</integer>
</dict> </dict>
<key>PG (Playground) 1.xcscheme</key> <key>PG (Playground) 1.xcscheme</key>
<dict> <dict>
......
//
// UIView+Mode.swift
// 1Weather
//
// Created by Dmitry Stepanets on 23.03.2021.
//
import UIKit
public enum AppInterfaceStyle {
case light
case dark
}
extension UIView {
var interfaceStyle:AppInterfaceStyle {
if #available(iOS 12.0, *) {
return traitCollection.userInterfaceStyle == .light ? .light : .dark
}
else {
return .light
}
}
}
...@@ -23,9 +23,9 @@ ...@@ -23,9 +23,9 @@
"color-space" : "srgb", "color-space" : "srgb",
"components" : { "components" : {
"alpha" : "1.000", "alpha" : "1.000",
"blue" : "0x13", "blue" : "0x1A",
"green" : "0x13", "green" : "0x17",
"red" : "0x13" "red" : "0x17"
} }
}, },
"idiom" : "universal" "idiom" : "universal"
......
{
"colors" : [
{
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "1.000",
"green" : "1.000",
"red" : "1.000"
}
},
"idiom" : "universal"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "dark"
}
],
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0x2B",
"green" : "0x26",
"red" : "0x26"
}
},
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
...@@ -23,9 +23,9 @@ ...@@ -23,9 +23,9 @@
"color-space" : "srgb", "color-space" : "srgb",
"components" : { "components" : {
"alpha" : "1.000", "alpha" : "1.000",
"blue" : "105", "blue" : "0xEC",
"green" : "79", "green" : "0xE0",
"red" : "70" "red" : "0xCA"
} }
}, },
"idiom" : "universal" "idiom" : "universal"
......
...@@ -17,6 +17,10 @@ struct DefaultTheme: ThemeProtocol { ...@@ -17,6 +17,10 @@ struct DefaultTheme: ThemeProtocol {
return UIColor(named: "background_color") ?? .red return UIColor(named: "background_color") ?? .red
} }
var containerBackgroundColor: UIColor {
return UIColor(named: "container_background_color") ?? .red
}
//Navigation bar //Navigation bar
var navigationBarBackgroundColor: UIColor { var navigationBarBackgroundColor: UIColor {
return baseBackgroundColor return baseBackgroundColor
......
...@@ -11,6 +11,7 @@ protocol ThemeProtocol { ...@@ -11,6 +11,7 @@ protocol ThemeProtocol {
//Base //Base
var name:String { get } var name:String { get }
var baseBackgroundColor:UIColor { get } var baseBackgroundColor:UIColor { get }
var containerBackgroundColor:UIColor { get }
//Navigation bar //Navigation bar
var navigationBarBackgroundColor:UIColor { get } var navigationBarBackgroundColor:UIColor { get }
......
...@@ -20,7 +20,7 @@ class CityForecastCell: UITableViewCell { ...@@ -20,7 +20,7 @@ class CityForecastCell: UITableViewCell {
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier) super.init(style: style, reuseIdentifier: reuseIdentifier)
prepareCellStyle() prepareCell()
prepareContainer() prepareContainer()
prepareCityImage() prepareCityImage()
prepareTemperatureLabel() prepareTemperatureLabel()
...@@ -47,18 +47,29 @@ class CityForecastCell: UITableViewCell { ...@@ -47,18 +47,29 @@ class CityForecastCell: UITableViewCell {
//MARK:- Prepare //MARK:- Prepare
private extension CityForecastCell { private extension CityForecastCell {
func prepareCellStyle() { func prepareCell() {
selectionStyle = .none selectionStyle = .none
contentView.backgroundColor = ThemeManager.currentTheme.baseBackgroundColor contentView.backgroundColor = ThemeManager.currentTheme.baseBackgroundColor
} }
func prepareContainer() { func prepareContainer() {
container.backgroundColor = .white container.clipsToBounds = false
container.layer.cornerRadius = 12 container.backgroundColor = ThemeManager.currentTheme.containerBackgroundColor
if self.interfaceStyle == .light {
container.layer.shadowColor = UIColor(hex: 0x020116).cgColor container.layer.shadowColor = UIColor(hex: 0x020116).cgColor
container.layer.shadowOffset = .init(width: 0, height: 10) container.layer.shadowOffset = .init(width: 0, height: 10)
container.layer.shadowRadius = 20 container.layer.shadowRadius = 20
container.layer.shadowOpacity = 0.12 container.layer.shadowOpacity = 0.12
}
else {
container.layer.shadowColor = UIColor.black.cgColor
container.layer.shadowOffset = .init(width: 8, height: 8)
container.layer.shadowRadius = 8
container.layer.shadowOpacity = 1.0
}
container.layer.cornerRadius = 12
contentView.addSubview(container) contentView.addSubview(container)
container.snp.makeConstraints { (make) in container.snp.makeConstraints { (make) in
......
...@@ -20,8 +20,11 @@ class TodayAdCell: UITableViewCell { ...@@ -20,8 +20,11 @@ class TodayAdCell: UITableViewCell {
prepareCellStyle() prepareCellStyle()
prepareContainer() prepareContainer()
prepareAd() prepareAd()
if self.interfaceStyle == .light {
prepareGradient() prepareGradient()
} }
}
required init?(coder: NSCoder) { required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented") fatalError("init(coder:) has not been implemented")
...@@ -36,10 +39,14 @@ private extension TodayAdCell { ...@@ -36,10 +39,14 @@ private extension TodayAdCell {
} }
func prepareContainer() { func prepareContainer() {
container.backgroundColor = .white container.backgroundColor = ThemeManager.currentTheme.containerBackgroundColor
container.layer.cornerRadius = 6 container.layer.cornerRadius = 6
if self.interfaceStyle == .light {
container.layer.borderWidth = 1 / UIScreen.main.scale container.layer.borderWidth = 1 / UIScreen.main.scale
container.layer.borderColor = UIColor(hex: 0xc7c7c7).cgColor container.layer.borderColor = UIColor(hex: 0xc7c7c7).cgColor
}
contentView.addSubview(container) contentView.addSubview(container)
container.snp.makeConstraints { (make) in container.snp.makeConstraints { (make) in
......
...@@ -52,7 +52,7 @@ ...@@ -52,7 +52,7 @@
<key>XMLCoder.xcscheme_^#shared#^_</key> <key>XMLCoder.xcscheme_^#shared#^_</key>
<dict> <dict>
<key>orderHint</key> <key>orderHint</key>
<integer>6</integer> <integer>5</integer>
</dict> </dict>
</dict> </dict>
<key>SuppressBuildableAutocreation</key> <key>SuppressBuildableAutocreation</key>
......
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