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
35008f53
Commit
35008f53
authored
Apr 21, 2021
by
Dmitriy Stepanets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Finished legend layout
parent
d35e906a
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
53 additions
and
26 deletions
+53
-26
1Weather/UI/View controllers/Radar/Controls/MapLegendSevereView.swift
+3
-3
1Weather/UI/View controllers/Radar/Controls/MapLegendView.swift
+45
-19
1Weather/UI/View controllers/Radar/Controls/MapLegendWeatherView.swift
+4
-4
1Weather/UI/View controllers/Radar/RadarViewController.swift
+1
-0
No files found.
1Weather/UI/View controllers/Radar/Controls/MapLegendSevereView.swift
View file @
35008f53
...
...
@@ -31,7 +31,7 @@ class MapLegendSevereView: UIView {
private
func
prepare
()
{
stackView
.
axis
=
.
horizontal
stackView
.
spacing
=
4
stackView
.
spacing
=
8
stackView
.
distribution
=
.
equalSpacing
addSubview
(
stackView
)
...
...
@@ -66,7 +66,7 @@ private class SevereLegendElement:UIView {
private
func
prepare
()
{
self
.
snp
.
makeConstraints
{
(
make
)
in
make
.
width
.
equalTo
(
50
)
make
.
width
.
equalTo
(
50
)
.
priority
(
999
)
}
imageView
.
clipsToBounds
=
true
...
...
@@ -75,7 +75,7 @@ private class SevereLegendElement:UIView {
addSubview
(
imageView
)
imageView
.
snp
.
makeConstraints
{
(
make
)
in
make
.
top
.
equalToSuperview
()
.
inset
(
3
)
make
.
top
.
equalToSuperview
()
.
inset
(
3
)
.
priority
(
999
)
make
.
width
.
equalTo
(
30
)
make
.
height
.
equalTo
(
10
)
make
.
centerX
.
equalToSuperview
()
...
...
1Weather/UI/View controllers/Radar/Controls/MapLegendView.swift
View file @
35008f53
...
...
@@ -15,7 +15,6 @@ private enum LegendType {
class
MapLegendView
:
UIView
{
//Private
private
let
kOpenWidth
:
CGFloat
=
180
private
let
kCloseWidth
:
CGFloat
=
40
private
let
containerView
=
UIView
()
private
let
button
=
UIButton
()
...
...
@@ -34,8 +33,12 @@ class MapLegendView: UIView {
prepareView
()
prepareViewGradient
()
prepareButton
()
prepareContainer
()
prepareLegend
()
updateUI
()
containerView
.
setNeedsLayout
()
containerView
.
layoutIfNeeded
()
}
required
init
?(
coder
:
NSCoder
)
{
...
...
@@ -59,6 +62,8 @@ class MapLegendView: UIView {
public
func
configure
(
radarLayer
:
RadarLayer
)
{
legendSevereView
.
alpha
=
0
legendWeatherView
.
alpha
=
0
legendSevereView
.
snp
.
removeConstraints
()
legendWeatherView
.
snp
.
removeConstraints
()
if
let
weatherLayer
=
radarLayer
.
layer
as?
WeatherLayerType
{
self
.
configure
(
weatherLayer
:
weatherLayer
)
...
...
@@ -75,6 +80,7 @@ class MapLegendView: UIView {
legendWeatherView
.
alpha
=
isOpened
?
1
:
0
buttonGradient
.
colors
=
weatherLayer
.
colors
legendWeatherView
.
configure
(
weatherLayer
:
weatherLayer
)
rebuildWeatherConstraints
()
}
private
func
configure
(
severeLayer
:
SevereLayerType
)
{
...
...
@@ -82,6 +88,7 @@ class MapLegendView: UIView {
legendSevereView
.
alpha
=
isOpened
?
1
:
0
buttonGradient
.
colors
=
severeLayer
.
colors
legendSevereView
.
configure
(
severeLayer
:
severeLayer
)
rebuildSevereConstraints
()
}
private
func
updateUI
()
{
...
...
@@ -95,11 +102,28 @@ class MapLegendView: UIView {
}
}
private
func
rebuildSevereConstraints
()
{
legendSevereView
.
snp
.
makeConstraints
{
(
make
)
in
make
.
left
.
top
.
bottom
.
equalToSuperview
()
make
.
right
.
equalToSuperview
()
.
priority
(
.
medium
)
}
}
private
func
rebuildWeatherConstraints
()
{
legendWeatherView
.
snp
.
makeConstraints
{
(
make
)
in
make
.
left
.
equalToSuperview
()
make
.
right
.
equalToSuperview
()
.
priority
(
.
medium
)
make
.
top
.
equalToSuperview
()
.
inset
(
13
)
make
.
bottom
.
equalToSuperview
()
.
inset
(
6
)
}
}
@objc
private
func
handleButton
()
{
if
self
.
isOpened
{
self
.
isOpened
=
false
self
.
widthConstraint
?
.
isActive
=
true
self
.
heightConstraint
?
.
isActive
=
true
}
else
{
self
.
isOpened
=
true
...
...
@@ -107,10 +131,12 @@ class MapLegendView: UIView {
self
.
heightConstraint
?
.
isActive
=
false
}
self
.
containerView
.
setNeedsLayout
()
self
.
setNeedsLayout
()
self
.
button
.
setImage
(
isOpened
?
UIImage
(
named
:
"map_legend_close"
)
:
nil
,
for
:
.
normal
)
UIView
.
animate
(
withDuration
:
0.3
)
{
self
.
superview
?
.
layoutIfNeeded
()
self
.
layoutIfNeeded
()
switch
self
.
legendType
{
case
.
weather
:
self
.
legendWeatherView
.
alpha
=
self
.
isOpened
?
1
:
0
...
...
@@ -132,10 +158,9 @@ private extension MapLegendView {
layer
.
shadowOpacity
=
1
layer
.
shadowRadius
=
5
addSubview
(
containerView
)
containerView
.
snp
.
makeConstraints
{
(
make
)
in
make
.
left
.
top
.
bottom
.
equalToSuperview
()
self
.
widthConstraint
=
make
.
width
.
equalTo
(
kCloseWidth
)
.
priority
(
1000
)
.
constraint
self
.
snp
.
makeConstraints
{
(
make
)
in
self
.
widthConstraint
=
make
.
width
.
equalTo
(
kCloseWidth
)
.
constraint
self
.
heightConstraint
=
make
.
height
.
equalTo
(
kCloseWidth
)
.
constraint
}
}
...
...
@@ -154,7 +179,7 @@ private extension MapLegendView {
button
.
layer
.
cornerRadius
=
14
button
.
addTarget
(
self
,
action
:
#selector(
handleButton
)
,
for
:
.
touchUpInside
)
button
.
layer
.
insertSublayer
(
buttonGradient
,
below
:
button
.
imageView
?
.
layer
)
containerView
.
addSubview
(
button
)
addSubview
(
button
)
button
.
snp
.
makeConstraints
{
(
make
)
in
make
.
width
.
height
.
equalTo
(
28
)
...
...
@@ -163,24 +188,25 @@ private extension MapLegendView {
}
}
func
prepareLegend
()
{
legendWeatherView
.
alpha
=
0
containerView
.
addSubview
(
legendWeatherView
)
func
prepareContainer
()
{
containerView
.
backgroundColor
=
.
clear
containerView
.
clipsToBounds
=
true
addSubview
(
containerView
)
legendWeath
erView
.
snp
.
makeConstraints
{
(
make
)
in
contain
erView
.
snp
.
makeConstraints
{
(
make
)
in
make
.
left
.
equalTo
(
button
.
snp
.
right
)
.
offset
(
6
)
.
priority
(
999
)
make
.
right
.
equalToSuperview
()
.
inset
(
17
)
make
.
top
.
equalToSuperview
()
.
inset
(
13
)
make
.
bottom
.
equalToSuperview
()
.
inset
(
6
)
make
.
right
.
equalToSuperview
()
.
inset
(
16
)
make
.
top
.
bottom
.
equalToSuperview
()
}
}
func
prepareLegend
()
{
legendWeatherView
.
alpha
=
0
legendWeatherView
.
translatesAutoresizingMaskIntoConstraints
=
false
containerView
.
addSubview
(
legendWeatherView
)
legendSevereView
.
alpha
=
0
legendSevereView
.
translatesAutoresizingMaskIntoConstraints
=
false
containerView
.
addSubview
(
legendSevereView
)
legendSevereView
.
snp
.
makeConstraints
{
(
make
)
in
make
.
left
.
equalTo
(
button
.
snp
.
right
)
.
offset
(
6
)
.
priority
(
999
)
make
.
right
.
equalToSuperview
()
.
inset
(
17
)
make
.
top
.
bottom
.
equalToSuperview
()
}
}
}
1Weather/UI/View controllers/Radar/Controls/MapLegendWeatherView.swift
View file @
35008f53
...
...
@@ -64,19 +64,19 @@ private extension MapLegendWeatherView {
legendGradient
.
snp
.
makeConstraints
{
(
make
)
in
make
.
left
.
right
.
top
.
equalToSuperview
()
make
.
height
.
equalTo
(
4
)
make
.
height
.
equalTo
(
4
)
.
priority
(
999
)
}
}
func
prepareStackView
()
{
legendLabelsStackView
.
axis
=
.
horizontal
legendLabelsStackView
.
spacing
=
4
legendLabelsStackView
.
distribution
=
.
equalSpacing
legendLabelsStackView
.
spacing
=
8
legendLabelsStackView
.
distribution
=
.
fill
addSubview
(
legendLabelsStackView
)
legendLabelsStackView
.
snp
.
makeConstraints
{
(
make
)
in
make
.
left
.
right
.
equalToSuperview
()
make
.
top
.
equalTo
(
legendGradient
.
snp
.
bottom
)
.
offset
(
6
)
make
.
top
.
equalTo
(
legendGradient
.
snp
.
bottom
)
.
offset
(
6
)
.
priority
(
999
)
make
.
bottom
.
equalToSuperview
()
.
inset
(
4
)
}
}
...
...
1Weather/UI/View controllers/Radar/RadarViewController.swift
View file @
35008f53
...
...
@@ -194,6 +194,7 @@ private extension RadarViewController {
//Legend
view
.
addSubview
(
legendView
)
legendView
.
snp
.
makeConstraints
{
(
make
)
in
make
.
width
.
lessThanOrEqualToSuperview
()
make
.
right
.
equalToSuperview
()
.
inset
(
8
)
make
.
bottom
.
equalTo
(
locationButton
.
snp
.
top
)
.
offset
(
-
18
)
}
...
...
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