Commit 4a44766c by Dmitriy Stepanets

Finished all "Low" priority issues

parent 615d2924
......@@ -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()
}
}
......
......@@ -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