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
7718da56
Commit
7718da56
authored
Apr 27, 2021
by
Dmitriy Stepanets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added logic to reduce timeline items count
parent
7ca65c2c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
14 deletions
+27
-14
1Weather/UI/View controllers/Radar/MapTimeControl/MapTimeControlView.swift
+14
-14
PG.playground/Contents.swift
+13
-0
No files found.
1Weather/UI/View controllers/Radar/MapTimeControl/MapTimeControlView.swift
View file @
7718da56
...
...
@@ -80,25 +80,25 @@ class MapTimeControlView: UIView {
}
public
func
configure
(
items
:[
MapTimeControlItem
],
timeZone
:
TimeZone
)
{
//Reduce count if needed
if
items
.
count
>
5
{
var
modifiedItems
=
items
while
modifiedItems
.
count
>
5
{
let
centerIndex
=
modifiedItems
.
count
/
2
modifiedItems
.
remove
(
at
:
centerIndex
)
self
.
currentItems
=
items
stackView
.
removeAll
()
//Reduce count if needed for displaying
let
maxValues
=
5
if
items
.
count
>
maxValues
{
let
steps
=
(
items
.
count
-
1
)
/
(
maxValues
-
1
)
for
index
in
0
..<
maxValues
{
let
view
=
MapTimeView
(
item
:
items
[
index
*
steps
])
stackView
.
addArrangedSubview
(
view
)
}
self
.
currentItems
=
modifiedItems
}
else
{
self
.
currentItems
=
items
items
.
forEach
{
let
view
=
MapTimeView
(
item
:
$0
)
stackView
.
addArrangedSubview
(
view
)
}
}
stackView
.
removeAll
()
self
.
currentItems
.
forEach
{
let
view
=
MapTimeView
(
item
:
$0
)
stackView
.
addArrangedSubview
(
view
)
}
stackView
.
layoutIfNeeded
()
}
...
...
PG.playground/Contents.swift
View file @
7718da56
import
Foundation
import
UIKit
var
arr
=
[
3
,
0
,
6
,
22
,
55
,
45
,
232
,
534
,
1
,
7
,
9
,
10
]
let
maxValues
=
6
let
steps
=
(
arr
.
count
-
1
)
/
(
maxValues
-
1
)
var
result
=
[
Int
]()
for
index
in
0
..<
maxValues
{
print
(
"Fraction:
\(
index
*
steps
)
"
)
result
.
append
(
arr
[
index
*
steps
])
}
print
(
"Orig:
\(
arr
)
"
)
print
(
"Result:
\(
result
)
"
)
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