Commit 98174d0b by Dmitry Stepanets

Changed logic of unique temps column rendering

parent 6644c623
......@@ -103,36 +103,24 @@ class MinutelyForecastView: UIView {
var uniqTemps = forecast.compactMap{$0.temp}.unique().sorted{$0.value > $1.value}
if uniqTemps.count > 4 {
var originalTimes = [Float]()
var originalValues = [Float]()
let uniqMax = uniqTemps.removeFirst()
let uniqMin = uniqTemps.removeLast()
let midPoint = (uniqTemps.count / 2)
for time in 0..<uniqTemps.count {
originalTimes.append(Float(time))
originalValues.append(Float(uniqTemps[time].value))
}
var newValues = [Float](repeating: 0, count: 4)
let stride = vDSP_Stride(1)
vDSP_vlint(originalValues,
originalTimes, stride,
&newValues, stride,
4,
vDSP_Length(originalValues.count))
// vDSP_vgenpD(originalValues, stride,
// originalTimes, stride,
// &newValues, stride,
// vDSP_Length(newValues.count),
// vDSP_Length(originalValues.count))
let firstHalf = uniqTemps[..<midPoint]
let firstHalfTemp = firstHalf[firstHalf.startIndex + firstHalf.count % 2]
let result = newValues.enumerated().map{ return $0 }
print("Break")
let seconHalf = uniqTemps[midPoint...]
let secondHalfTemp = seconHalf[seconHalf.startIndex + seconHalf.count % 2]
uniqTemps = [uniqMax, firstHalfTemp, secondHalfTemp, uniqMin]
}
for temp in uniqTemps {
let label = UILabel()
label.text = temp.settingsConverted.shortString
label.font = AppFont.SFPro.regular(size: 10)
label.setContentHuggingPriority(.fittingSizeLevel, for: .vertical)
label.sizeToFit()
verticalStackView.addArrangedSubview(label)
}
......@@ -183,14 +171,14 @@ private extension MinutelyForecastView {
func prepareVerticalStackView() {
verticalStackView.axis = .vertical
verticalStackView.distribution = .fillProportionally
verticalStackView.alignment = .fill
verticalStackView.distribution = .fillEqually
verticalStackView.alignment = .top
addSubview(verticalStackView)
verticalStackView.snp.makeConstraints { make in
make.height.equalTo(levelsStackView)
make.right.equalTo(scrollView.snp.left).offset(-6)
make.top.equalTo(scrollView).inset(4)
make.top.equalTo(scrollView)
}
}
......
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