Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
1
1weather
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Dmitriy Stepanets
1weather
Commits
98174d0b
Commit
98174d0b
authored
Aug 27, 2021
by
Dmitry Stepanets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Changed logic of unique temps column rendering
parent
6644c623
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
25 deletions
+13
-25
1Weather/UI/SharedViews/MinutelyForecastView.swift
+13
-25
No files found.
1Weather/UI/SharedViews/MinutelyForecastView.swift
View file @
98174d0b
...
...
@@ -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
=
.
fill
Proportion
ally
verticalStackView
.
alignment
=
.
fill
verticalStackView
.
distribution
=
.
fill
Equ
ally
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
)
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment