Commit 4656d2b3 by Dmitriy Stepanets

Merge branch 'iOS-83-UI-fixes' into develop

# Conflicts:
#	1Weather.xcworkspace/xcuserdata/dstepanets.xcuserdatad/xcschemes/xcschememanagement.plist
parents 74580a8d 4a44766c
......@@ -12,7 +12,7 @@
<key>OneWeatherNotificationServiceExtension.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>55</integer>
<integer>49</integer>
</dict>
<key>PG (Playground) 1.xcscheme</key>
<dict>
......
......@@ -4,6 +4,27 @@
<dict>
<key>SchemeUserState</key>
<dict>
<key>OneWeatherCorePlayground (Playground) 1.xcscheme</key>
<dict>
<key>isShown</key>
<false/>
<key>orderHint</key>
<integer>58</integer>
</dict>
<key>OneWeatherCorePlayground (Playground) 2.xcscheme</key>
<dict>
<key>isShown</key>
<false/>
<key>orderHint</key>
<integer>59</integer>
</dict>
<key>OneWeatherCorePlayground (Playground).xcscheme</key>
<dict>
<key>isShown</key>
<false/>
<key>orderHint</key>
<integer>57</integer>
</dict>
<key>PG (Playground) 1.xcscheme</key>
<dict>
<key>isShown</key>
......@@ -51,7 +72,7 @@
<key>isShown</key>
<false/>
<key>orderHint</key>
<integer>54</integer>
<integer>56</integer>
</dict>
</dict>
</dict>
......
......@@ -28,6 +28,10 @@ class SettingsDetailsCoordinator:Coordinator {
}
}
func back() {
self.navigationController.popViewController(animated: true)
}
func viewControllerDidEnd(controller: UIViewController) {
parentCoordinator?.childDidFinish(child: self)
}
......
......@@ -52,6 +52,7 @@
"forecast.clearNight" = "Clear";
"forecast.partlyCloudyNight" = "Partly Cloudy";
"forecast.thunderstorm" = "Thunderstorm";
"forecast.thunderstorm.newLineIndex" = "7";
"forecast.heavySnow" = "Heavy Snow";
"forecast.lightSnow" = "Light Snow";
"forecast.freezingRain" = "Freezing Rain";
......
......@@ -110,7 +110,7 @@ class ForecastDetailPeriodButton: UIControl, PeriodButtonProtocol {
}
weatherImageView.image = dailyWeather.type.image(isDay: true)
weatherTypeLabel.text = dailyWeather.type.localized(isDay: true)
weatherTypeLabel.text = dailyWeather.type.localizedWithNewLine(isDay: true)
maxTempLabel.text = dailyWeather.maxTemp?.settingsConverted.shortString
minTempLabel.text = dailyWeather.minTemp?.settingsConverted.shortString
......
......@@ -32,7 +32,7 @@ class ForecastTimePeriodView: UIView {
//Private
private let scrollView = UIScrollView()
private let stackView = UIStackView()
private let graphView = GraphView()
private let graphView = GraphView(graphInsets: .init(top: 0, left: 8, bottom: 0, right: 8))
private var graphRect:CGRect = .zero
private var currentForecastType = ForecastType.daily
private var dailyGraphPoints = DailyGraphPoints(maxTempPoints: [CGPoint](), minTempPoints: [CGPoint]())
......
......@@ -56,8 +56,9 @@ struct GraphLine {
private mutating func linePath(from points:[CGPoint]) -> UIBezierPath {
let path = UIBezierPath()
let startPoint = CGPoint(x: 0, y: points.first?.y ?? 0)
let endPoint = CGPoint(x: self.onGetGraphRect().width, y: points.last?.y ?? 0)
let graphRect = self.onGetGraphRect()
let startPoint = CGPoint(x: graphRect.origin.x, y: points.first?.y ?? 0)
let endPoint = CGPoint(x: graphRect.width, y: points.last?.y ?? 0)
var pointsToAdd = [CGPoint]()
pointsToAdd.append(startPoint)
......
......@@ -10,6 +10,7 @@ import BezierKit
class GraphView: UIView {
//Private
private let graphInsets:UIEdgeInsets
private let mainLineSettings = GraphLineSettings(lineWidth: 3,
dotRadius: 2.5,
dotLineWidth: 2,
......@@ -31,28 +32,41 @@ class GraphView: UIView {
private lazy var mainLine:GraphLine = {
let line = GraphLine(settings: mainLineSettings, onGetGraphRect: {
return self.frame
let graphFrame = CGRect(x: self.frame.origin.x + self.graphInsets.left,
y: self.frame.origin.y + self.graphInsets.top,
width: self.frame.width - self.graphInsets.right,
height: self.frame.height - self.graphInsets.bottom)
return graphFrame
})
return line
}()
private lazy var additionalLine:GraphLine = {
let line = GraphLine(settings: additionalLineSettings, onGetGraphRect: {
return self.frame
let graphFrame = CGRect(x: self.frame.origin.x + self.graphInsets.left,
y: self.frame.origin.y + self.graphInsets.top,
width: self.frame.width - self.graphInsets.right,
height: self.frame.height - self.graphInsets.bottom)
return graphFrame
})
return line
}()
private lazy var windLine:GraphLine = {
let line = GraphLine(settings: windLineSettings, onGetGraphRect: {
return self.frame
let graphFrame = CGRect(x: self.frame.origin.x + self.graphInsets.left,
y: self.frame.origin.y + self.graphInsets.top,
width: self.frame.width - self.graphInsets.right,
height: self.frame.height - self.graphInsets.bottom)
return graphFrame
})
return line
}()
//MARK:- View life cycle
init() {
init(graphInsets:UIEdgeInsets = .zero) {
self.graphInsets = graphInsets
super.init(frame: .zero)
self.isUserInteractionEnabled = false
......
......@@ -202,7 +202,7 @@ extension ForecastViewController: UITableViewDelegate {
timePeriodCellFrame = tableView.cellForRow(at: [0,0])?.frame ?? .zero
}
let startPointY = timePeriodCellFrame.origin.y + timePeriodCellFrame.height - self.daysControlView.frame.height
let startPointY:CGFloat = 100 //timePeriodCellFrame.origin.y + timePeriodCellFrame.height - self.daysControlView.frame.height
let animationDuration = TimeInterval(UINavigationController.hideShowBarDuration)
if scrollView.contentOffset.y >= startPointY {
......@@ -225,7 +225,7 @@ extension ForecastViewController: UITableViewDelegate {
self.navigationBarStateBeingChanged = false
}
navVC.setNavigationBarHidden(false, animated: true)
UIView.animate(withDuration: 0.35) {
UIView.animate(withDuration: animationDuration) {
self.daysControlView.alpha = 0
}
}
......
......@@ -83,6 +83,7 @@ extension SettingsDetailsViewController: UITableViewDataSource {
extension SettingsDetailsViewController: UITableViewDelegate {
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
viewModel.selectUnitAtIndex(index: indexPath.row)
coordinator.back()
}
}
......
......@@ -17,6 +17,7 @@ private struct AirQualityDataType: CirqueDataType {
class TodayAirQualityCell: UITableViewCell {
//Private
private let headingLabel = UILabel()
private let container = UIView()
private let cirqueView = CirqueView()
private let valueCircle = CAShapeLayer()
private let airQualityValueLabel = UILabel()
......@@ -29,6 +30,7 @@ class TodayAirQualityCell: UITableViewCell {
prepareCell()
prepareHeading()
prepareContainer()
prepareAirLabels()
prepareValueProgress()
prepareStackView()
......@@ -111,17 +113,29 @@ private extension TodayAirQualityCell {
}
}
func prepareContainer() {
container.backgroundColor = ThemeManager.currentTheme.containerBackgroundColor
container.layer.cornerRadius = 12
contentView.addSubview(container)
container.snp.makeConstraints { make in
make.left.right.equalToSuperview().inset(18)
make.top.equalTo(headingLabel.snp.bottom).offset(20)
make.bottom.equalToSuperview().inset(15)
}
}
func prepareAirLabels() {
airQualityLabel.lineBreakMode = .byWordWrapping
airQualityLabel.numberOfLines = 0
airQualityValueLabel.font = AppFont.SFPro.bold(size: 18)
airQualityValueLabel.textColor = ThemeManager.currentTheme.secondaryTextColor
contentView.addSubview(airQualityValueLabel)
container.addSubview(airQualityValueLabel)
airQualityLabel.numberOfLines = 0
airQualityLabel.lineBreakMode = .byWordWrapping
airQualityLabel.textAlignment = .left
contentView.addSubview(airQualityLabel)
container.addSubview(airQualityLabel)
airDescLabel.textAlignment = .left
airDescLabel.numberOfLines = 0
......@@ -129,23 +143,23 @@ private extension TodayAirQualityCell {
airDescLabel.font = AppFont.SFPro.regular(size: 16)
airDescLabel.textColor = ThemeManager.currentTheme.secondaryTextColor
airDescLabel.text = ""
contentView.addSubview(airDescLabel)
container.addSubview(airDescLabel)
//Constraints
airQualityValueLabel.snp.makeConstraints { (make) in
make.left.equalToSuperview().inset(72)
make.top.equalTo(headingLabel.snp.bottom).offset(72).priority(999)
make.left.equalToSuperview().inset(54)
make.top.equalToSuperview().inset(52).priority(999)
}
airQualityLabel.snp.makeConstraints { (make) in
make.left.equalTo(airQualityValueLabel.snp.right).offset(54)
make.top.equalTo(headingLabel.snp.bottom).offset(48)
make.top.equalToSuperview().inset(28)
// make.centerY.equalTo(airQualityValueLabel)
make.right.equalToSuperview().inset(48)
}
airDescLabel.snp.makeConstraints { (make) in
make.left.right.equalToSuperview().inset(50)
make.left.right.equalToSuperview().inset(32)
make.top.greaterThanOrEqualTo(airQualityLabel.snp.bottom).offset(8)
// also see prepareValueProgress
}
......@@ -155,13 +169,13 @@ private extension TodayAirQualityCell {
valueCircle.strokeColor = UIColor(hex: 0xe9ebfc).cgColor
valueCircle.fillColor = UIColor.clear.cgColor
valueCircle.lineWidth = 2
contentView.layer.addSublayer(valueCircle)
container.layer.addSublayer(valueCircle)
cirqueView.lineWidth = 6
cirqueView.stepSize = 0.01
cirqueView.roundLineCorners = true
cirqueView.backgroundColor = .clear
contentView.addSubview(cirqueView)
container.addSubview(cirqueView)
cirqueView.snp.makeConstraints { (make) in
make.width.height.equalTo(77)
......@@ -177,10 +191,10 @@ private extension TodayAirQualityCell {
stackView.axis = .vertical
stackView.distribution = .fillProportionally
stackView.clipsToBounds = false
contentView.addSubview(stackView)
container.addSubview(stackView)
stackView.snp.makeConstraints { (make) in
make.left.right.equalToSuperview().inset(50)
make.left.right.equalToSuperview().inset(27)
make.top.equalTo(airDescLabel.snp.bottom).offset(15)
make.bottom.equalToSuperview().inset(15)
}
......
......@@ -56,6 +56,7 @@
CD615FC72655295C00B717DB /* UITabBarController+Hide.swift in Sources */ = {isa = PBXBuildFile; fileRef = CD615FB42655293100B717DB /* UITabBarController+Hide.swift */; };
CD615FC82655295C00B717DB /* CACornerMask+All.swift in Sources */ = {isa = PBXBuildFile; fileRef = CD615FB52655293100B717DB /* CACornerMask+All.swift */; };
CD615FC92655295C00B717DB /* UIDevice+Convenience.swift in Sources */ = {isa = PBXBuildFile; fileRef = CD615FB62655293100B717DB /* UIDevice+Convenience.swift */; };
CD71B9C6265E629D00803DBB /* String+NewLine.swift in Sources */ = {isa = PBXBuildFile; fileRef = CD71B9C5265E629D00803DBB /* String+NewLine.swift */; };
CD91685726552FAE00EC04EF /* MulticastDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = CD91685626552FAE00EC04EF /* MulticastDelegate.swift */; };
CD91685826552FD000EC04EF /* DefaultSettingsFactory.swift in Sources */ = {isa = PBXBuildFile; fileRef = CD615FCE265529DE00B717DB /* DefaultSettingsFactory.swift */; };
CD91685926552FD000EC04EF /* DefaultSettings.swift in Sources */ = {isa = PBXBuildFile; fileRef = CD615FCF265529DE00B717DB /* DefaultSettings.swift */; };
......@@ -139,6 +140,8 @@
CD615FCF265529DE00B717DB /* DefaultSettings.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DefaultSettings.swift; sourceTree = "<group>"; };
CD615FD0265529DE00B717DB /* DefaultSettingsImperial.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DefaultSettingsImperial.swift; sourceTree = "<group>"; };
CD615FD1265529DE00B717DB /* DefaultSettingsMetric.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DefaultSettingsMetric.swift; sourceTree = "<group>"; };
CD71B9C4265E5F7300803DBB /* OneWeatherCorePlayground.playground */ = {isa = PBXFileReference; lastKnownFileType = file.playground; name = OneWeatherCorePlayground.playground; path = ../OneWeatherCorePlayground.playground; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.swift; };
CD71B9C5265E629D00803DBB /* String+NewLine.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "String+NewLine.swift"; sourceTree = "<group>"; };
CD91685626552FAE00EC04EF /* MulticastDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MulticastDelegate.swift; sourceTree = "<group>"; };
CD91685C26552FEB00EC04EF /* Logger.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Logger.swift; sourceTree = "<group>"; };
CD91685D26552FEC00EC04EF /* Global.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Global.swift; sourceTree = "<group>"; };
......@@ -210,6 +213,7 @@
CD615F59265523A400B717DB = {
isa = PBXGroup;
children = (
CD71B9C4265E5F7300803DBB /* OneWeatherCorePlayground.playground */,
CD615F65265523A400B717DB /* OneWeatherCore */,
CD615F70265523A400B717DB /* OneWeatherCoreTests */,
CD615F64265523A400B717DB /* Products */,
......@@ -332,6 +336,7 @@
CD615FB42655293100B717DB /* UITabBarController+Hide.swift */,
CD615FB52655293100B717DB /* CACornerMask+All.swift */,
CD615FB62655293100B717DB /* UIDevice+Convenience.swift */,
CD71B9C5265E629D00803DBB /* String+NewLine.swift */,
);
path = Extensions;
sourceTree = "<group>";
......@@ -551,6 +556,7 @@
CD615FBB2655295C00B717DB /* UITabBarController+Append.swift in Sources */,
CD615FBD2655295C00B717DB /* Measurement+String.swift in Sources */,
CD615FBE2655295C00B717DB /* Calendar+TimeZone.swift in Sources */,
CD71B9C6265E629D00803DBB /* String+NewLine.swift in Sources */,
CD91685F26552FEC00EC04EF /* Global.swift in Sources */,
CD615FBF2655295C00B717DB /* UIStackView+RemoveAll.swift in Sources */,
CD615FC02655295C00B717DB /* UITableView+HeaderSize.swift in Sources */,
......
//
// String+NewLine.swift
// OneWeatherCore
//
// Created by Dmitry Stepanets on 26.05.2021.
//
import Foundation
extension String {
func addNewLineCharacter(at index:Int) -> String {
var originalString = self
originalString.insert("\n", at: originalString.index(originalString.startIndex, offsetBy: index))
return originalString
}
}
......@@ -31,6 +31,19 @@ public enum WeatherType: String, CaseIterable {
public func localized(isDay: Bool) -> String {
return "forecast.\(self.stringId(isDay: isDay))".localized()
}
public func localizedWithNewLine(isDay: Bool) -> String {
let localizeId = "forecast.\(self.stringId(isDay: isDay))"
let newLineIndexString = "\(localizeId).newLineIndex".localized()
if let newLineIndex = Int(newLineIndexString) {
let localizedString = localizeId.localized()
return localizedString.addNewLineCharacter(at: newLineIndex)
}
else {
return localizeId.localized()
}
}
public func image(isDay: Bool) -> UIImage {
guard let result = UIImage(named: self.stringId(isDay: isDay)) else {
......
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<playground version='5.0' target-platform='ios' buildActiveScheme='true' importAppTypes='true'>
<timeline fileName='timeline.xctimeline'/>
</playground>
\ No newline at end of file
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