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