Commit cbdfe4ca by Dmitriy Stepanets

Started implementing dark mode

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