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