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
d35e906a
Commit
d35e906a
authored
Apr 20, 2021
by
Dmitriy Stepanets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Working on legend view animation/layout
parent
38c8f007
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
327 additions
and
53 deletions
+327
-53
1Weather-Icons.sketch
+0
-0
1Weather.xcodeproj/project.pbxproj
+8
-0
1Weather.xcodeproj/xcuserdata/dstepanets.xcuserdatad/xcschemes/xcschememanagement.plist
+1
-1
1Weather/Model/RadarLayers/SevereLayerType.swift
+67
-10
1Weather/UI/View controllers/Radar/Controls/MapLegendSevereView.swift
+105
-0
1Weather/UI/View controllers/Radar/Controls/MapLegendView.swift
+59
-38
1Weather/UI/View controllers/Radar/Controls/MapLegendWeatherView.swift
+83
-0
Pods/Pods.xcodeproj/xcuserdata/dstepanets.xcuserdatad/xcschemes/xcschememanagement.plist
+4
-4
No files found.
1Weather-Icons.sketch
View file @
d35e906a
No preview for this file type
1Weather.xcodeproj/project.pbxproj
View file @
d35e906a
...
...
@@ -128,6 +128,8 @@
CDD0F1E82572429E00CF5017
/* AppFont.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
CDD0F1E72572429E00CF5017
/* AppFont.swift */
;
};
CDD0F1EE25725BCF00CF5017
/* ThemeManager.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
CDD0F1ED25725BCF00CF5017
/* ThemeManager.swift */
;
};
CDD75F0D25DE68B10099ACDB
/* Localizable.strings in Resources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
CDD75F0F25DE68B10099ACDB
/* Localizable.strings */
;
};
CDDE8D7C262EED3C00267931
/* MapLegendSevereView.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
CDDE8D7B262EED3C00267931
/* MapLegendSevereView.swift */
;
};
CDDE8D7F262EED4D00267931
/* MapLegendWeatherView.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
CDDE8D7E262EED4D00267931
/* MapLegendWeatherView.swift */
;
};
CDE18DCA25D165F100C80ED9
/* UITabBarController+Append.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
CDE18DC925D165F100C80ED9
/* UITabBarController+Append.swift */
;
};
CDE18DCD25D1666700C80ED9
/* ForecastCoordinator.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
CDE18DCC25D1666700C80ED9
/* ForecastCoordinator.swift */
;
};
CDE18DD125D166F900C80ED9
/* ForecastViewController.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
CDE18DD025D166F900C80ED9
/* ForecastViewController.swift */
;
};
...
...
@@ -333,6 +335,8 @@
CDD0F1E72572429E00CF5017
/* AppFont.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
AppFont.swift
;
sourceTree
=
"<group>"
;
};
CDD0F1ED25725BCF00CF5017
/* ThemeManager.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
ThemeManager.swift
;
sourceTree
=
"<group>"
;
};
CDD75F0E25DE68B10099ACDB
/* en */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
text.plist.strings
;
name
=
en
;
path
=
en.lproj/Localizable.strings
;
sourceTree
=
"<group>"
;
};
CDDE8D7B262EED3C00267931
/* MapLegendSevereView.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
MapLegendSevereView.swift
;
sourceTree
=
"<group>"
;
};
CDDE8D7E262EED4D00267931
/* MapLegendWeatherView.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
MapLegendWeatherView.swift
;
sourceTree
=
"<group>"
;
};
CDE18DC925D165F100C80ED9
/* UITabBarController+Append.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
"UITabBarController+Append.swift"
;
sourceTree
=
"<group>"
;
};
CDE18DCC25D1666700C80ED9
/* ForecastCoordinator.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
ForecastCoordinator.swift
;
sourceTree
=
"<group>"
;
};
CDE18DD025D166F900C80ED9
/* ForecastViewController.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
ForecastViewController.swift
;
sourceTree
=
"<group>"
;
};
...
...
@@ -796,6 +800,8 @@
CDAD97B0262042B2007FCFB1
/* MapButton.swift */
,
CD18728A2624763000AFEDAA
/* MapLegendView.swift */
,
CD676169262575CD0079D273
/* MapLegendGradientView.swift */
,
CDDE8D7B262EED3C00267931
/* MapLegendSevereView.swift */
,
CDDE8D7E262EED4D00267931
/* MapLegendWeatherView.swift */
,
);
path
=
Controls
;
sourceTree
=
"<group>"
;
...
...
@@ -1293,6 +1299,7 @@
CD866A62260F596B00E96A5C
/* Dimension+Name.swift in Sources */
,
CDE2BF222609D4250085C930
/* ForecastWindSpeedCell.swift in Sources */
,
CD866A6C260F676400E96A5C
/* SettingsDetailsCellFactory.swift in Sources */
,
CDDE8D7F262EED4D00267931
/* MapLegendWeatherView.swift in Sources */
,
CDA5543025EFA13F00A2E08C
/* Measurement+String.swift in Sources */
,
CEF9596C2600C32E00975FAA
/* AnalyticsEvent.swift in Sources */
,
CEF959982600C88100975FAA
/* AnalyticsParameter.swift in Sources */
,
...
...
@@ -1427,6 +1434,7 @@
CD86246125E662BC0097F3FB
/* SunUvLineView.swift in Sources */
,
CD32CE0B260C744A00235081
/* MenuCoordinator.swift in Sources */
,
CD55E0BB2615EE2400CC4DC7
/* PollutantView.swift in Sources */
,
CDDE8D7C262EED3C00267931
/* MapLegendSevereView.swift in Sources */
,
CD6761882625C3360079D273
/* RadarViewModel.swift in Sources */
,
CDF8F12A262089A200DB384A
/* MapTimeView.swift in Sources */
,
CEC526FA25E7959A00DA58A5
/* WeatherSource.swift in Sources */
,
...
...
1Weather.xcodeproj/xcuserdata/dstepanets.xcuserdatad/xcschemes/xcschememanagement.plist
View file @
d35e906a
...
...
@@ -7,7 +7,7 @@
<
k
e
y
>
1Weather.xcscheme_
^#
shared
#^
_
<
/k
e
y
>
<
d
i
c
t
>
<
k
e
y
>
orderHint
<
/k
e
y
>
<
int
e
g
e
r
>
11
<
/int
e
g
e
r
>
<
int
e
g
e
r
>
24
<
/int
e
g
e
r
>
<
/
d
i
c
t
>
<
k
e
y
>
PG
(
Playground
)
1.xcscheme
<
/k
e
y
>
<
d
i
c
t
>
...
...
1Weather/Model/RadarLayers/SevereLayerType.swift
View file @
d35e906a
...
...
@@ -33,29 +33,86 @@ public enum SevereLayerType:String, CaseIterable, RadarLayerType {
case
.
fire
:
return
[
"Watch"
,
"Warning"
]
case
.
floods
:
return
[
"Flash warn
."
,
"Flash watch"
,
"Flood warn.
"
]
return
[
"Flash warn
ing"
,
"Flash watch"
,
"Flood warning
"
]
case
.
fog
:
return
[
"Freezing adv
."
,
"Dense adv.
"
]
return
[
"Freezing adv
isory"
,
"Dense advisory
"
]
case
.
freezing
:
return
[
"Freezing warn
."
,
"Frost adv."
,
"Frost warn.
"
]
return
[
"Freezing warn
ing"
,
"Frost advisory"
,
"Frost warning
"
]
case
.
hurricaneTropical
:
return
[
"Warning"
,
"Watch"
,
"Tropical warn
.
"
,
"Tropical watch"
]
return
[
"Warning"
,
"Watch"
,
"Tropical warn
ing
"
,
"Tropical watch"
]
case
.
hurricaneTropicalTracks
:
return
[
"Forecast track"
,
"Past track"
,
"Forecast cone"
,
"Hurricane"
,
"Tropical storm"
,
"Low"
,
"Invest area"
]
case
.
ice
:
return
[
"Strom warn
."
,
"Storm watch"
,
"Sleet warn."
,
"Sleet adv."
,
"Freezing rain adv
."
]
return
[
"Strom warn
ing"
,
"Storm watch"
,
"Sleet warning"
,
"Sleet advisory"
,
"Freezing rain adisory
."
]
case
.
snow
:
return
[
"Heavy snow warn
."
,
"Snow adv."
,
"Blowing snow warn."
,
"Blowing snow adv.
"
]
return
[
"Heavy snow warn
ing"
,
"Snow advisory"
,
"Blowing snow warning"
,
"Blowing snow advisory
"
]
case
.
stormTornados
:
return
[
"Tornado warn
."
,
"Tornado watch"
,
"Severe T-Storm warn.
"
,
"Severe T-storm watch"
]
return
[
"Tornado warn
ing"
,
"Tornado watch"
,
"Severe T-Storm warning
"
,
"Severe T-storm watch"
]
case
.
wind
:
return
[
"High wind warn
."
,
"High wind adv."
,
"High wind watch"
,
"Wind adv."
,
"Dust strom warn."
,
"Blowing dust adv.
"
]
return
[
"High wind warn
ing"
,
"High wind advisory"
,
"High wind watch"
,
"Wind advisory"
,
"Dust strom warning"
,
"Blowing dust advisory
"
]
case
.
winter
:
return
[
"Blizzard warn
."
,
"Blizzard watch"
,
"Winter strom warn."
,
"Winter storm watch"
,
"Winter weather adv.
"
]
return
[
"Blizzard warn
ing"
,
"Blizzard watch"
,
"Winter strom warning"
,
"Winter storm watch"
,
"Winter weather advisory
"
]
}
}
var
colors
:[
CGColor
]
{
return
[
UIColor
.
blue
,
UIColor
.
yellow
]
.
map
{
$0
.
cgColor
}
switch
self
{
case
.
fire
:
return
[
UIColor
(
hex
:
0xFFDDAD
),
UIColor
(
hex
:
0xFF1494
)]
.
map
{
$0
.
cgColor
}
case
.
floods
:
return
[
UIColor
(
hex
:
0x8C0001
),
UIColor
(
hex
:
0x32CD33
),
UIColor
(
hex
:
0x00FF01
)]
.
map
{
$0
.
cgColor
}
case
.
fog
:
return
[
UIColor
(
hex
:
0x008081
),
UIColor
(
hex
:
0x708090
)]
.
map
{
$0
.
cgColor
}
case
.
freezing
:
return
[
UIColor
(
hex
:
0x00FFFF
),
UIColor
(
hex
:
0x6395EC
),
UIColor
(
hex
:
0x2B32B4
)]
.
map
{
$0
.
cgColor
}
case
.
hurricaneTropical
:
return
[
UIColor
(
hex
:
0xFE1745
),
UIColor
(
hex
:
0xFF00FE
),
UIColor
(
hex
:
0x7F1819
),
UIColor
(
hex
:
0xF0807F
)]
.
map
{
$0
.
cgColor
}
case
.
hurricaneTropicalTracks
:
return
[
UIColor
.
black
,
UIColor
.
black
,
UIColor
.
black
,
UIColor
.
black
,
UIColor
.
black
,
UIColor
.
black
,
UIColor
.
black
]
.
map
{
$0
.
cgColor
}
case
.
ice
:
return
[
UIColor
(
hex
:
0x8A008B
),
UIColor
(
hex
:
0x8A008B
),
UIColor
(
hex
:
0x87CEEA
),
UIColor
(
hex
:
0x7C68EE
),
UIColor
(
hex
:
0xDA70D5
)]
.
map
{
$0
.
cgColor
}
case
.
snow
:
return
[
UIColor
(
hex
:
0x8A2BE1
),
UIColor
(
hex
:
0x669ACC
),
UIColor
(
hex
:
0xB0DFE5
),
UIColor
(
hex
:
0x81A1AC
)]
.
map
{
$0
.
cgColor
}
case
.
stormTornados
:
return
[
UIColor
(
hex
:
0xFE0000
),
UIColor
(
hex
:
0xFFFF01
),
UIColor
(
hex
:
0xFEA500
),
UIColor
(
hex
:
0xDC7092
)]
.
map
{
$0
.
cgColor
}
case
.
wind
:
return
[
UIColor
(
hex
:
0xDAA521
),
UIColor
(
hex
:
0xA78432
),
UIColor
(
hex
:
0xC48B00
),
UIColor
(
hex
:
0x9C8768
),
UIColor
(
hex
:
0xFEE4C3
),
UIColor
(
hex
:
0xAFAB64
)]
.
map
{
$0
.
cgColor
}
case
.
winter
:
return
[
UIColor
(
hex
:
0xFE4600
),
UIColor
(
hex
:
0xCFFF86
),
UIColor
(
hex
:
0xFF69B3
),
UIColor
(
hex
:
0x4682B4
),
UIColor
(
hex
:
0x7C68EE
)]
.
map
{
$0
.
cgColor
}
}
}
}
1Weather/UI/View controllers/Radar/Controls/MapLegendSevereView.swift
0 → 100644
View file @
d35e906a
//
// MapLegendSevereView.swift
// 1Weather
//
// Created by Dmitry Stepanets on 20.04.2021.
//
import
UIKit
class
MapLegendSevereView
:
UIView
{
//Private
private
let
stackView
=
UIStackView
()
init
()
{
super
.
init
(
frame
:
.
zero
)
prepare
()
}
public
func
configure
(
severeLayer
:
SevereLayerType
)
{
stackView
.
removeAll
()
severeLayer
.
values
.
enumerated
()
.
forEach
{
let
element
=
SevereLegendElement
(
color
:
UIColor
(
cgColor
:
severeLayer
.
colors
[
$0
]),
value
:
$1
)
stackView
.
addArrangedSubview
(
element
)
}
stackView
.
layoutIfNeeded
()
}
required
init
?(
coder
:
NSCoder
)
{
fatalError
(
"init(coder:) has not been implemented"
)
}
private
func
prepare
()
{
stackView
.
axis
=
.
horizontal
stackView
.
spacing
=
4
stackView
.
distribution
=
.
equalSpacing
addSubview
(
stackView
)
stackView
.
snp
.
makeConstraints
{
(
make
)
in
make
.
edges
.
equalToSuperview
()
}
}
}
//MARK:- Severe Legend Element
private
class
SevereLegendElement
:
UIView
{
private
let
imageView
=
UIImageView
()
private
let
textLabel
=
UILabel
()
init
(
color
:
UIColor
,
value
:
String
)
{
super
.
init
(
frame
:
.
zero
)
prepare
()
updateUI
()
imageView
.
backgroundColor
=
color
textLabel
.
text
=
value
}
required
init
?(
coder
:
NSCoder
)
{
fatalError
(
"init(coder:) has not been implemented"
)
}
override
func
traitCollectionDidChange
(
_
previousTraitCollection
:
UITraitCollection
?)
{
super
.
traitCollectionDidChange
(
previousTraitCollection
)
updateUI
()
}
private
func
prepare
()
{
self
.
snp
.
makeConstraints
{
(
make
)
in
make
.
width
.
equalTo
(
50
)
}
imageView
.
clipsToBounds
=
true
imageView
.
layer
.
cornerRadius
=
5
imageView
.
contentMode
=
.
scaleAspectFit
addSubview
(
imageView
)
imageView
.
snp
.
makeConstraints
{
(
make
)
in
make
.
top
.
equalToSuperview
()
.
inset
(
3
)
make
.
width
.
equalTo
(
30
)
make
.
height
.
equalTo
(
10
)
make
.
centerX
.
equalToSuperview
()
}
textLabel
.
font
=
AppFont
.
SFPro
.
medium
(
size
:
10
)
textLabel
.
numberOfLines
=
0
textLabel
.
textAlignment
=
.
center
textLabel
.
lineBreakMode
=
.
byWordWrapping
addSubview
(
textLabel
)
textLabel
.
snp
.
makeConstraints
{
(
make
)
in
make
.
left
.
right
.
equalToSuperview
()
make
.
top
.
equalTo
(
imageView
.
snp
.
bottom
)
.
offset
(
2
)
make
.
bottom
.
equalToSuperview
()
.
inset
(
2
)
}
}
private
func
updateUI
()
{
switch
interfaceStyle
{
case
.
light
:
textLabel
.
textColor
=
ThemeManager
.
currentTheme
.
secondaryTextColor
case
.
dark
:
textLabel
.
textColor
=
ThemeManager
.
currentTheme
.
primaryTextColor
}
}
}
1Weather/UI/View controllers/Radar/Controls/MapLegendView.swift
View file @
d35e906a
...
...
@@ -8,16 +8,24 @@
import
UIKit
import
SnapKit
private
enum
LegendType
{
case
weather
case
severe
}
class
MapLegendView
:
UIView
{
//Private
private
let
kOpenWidth
:
CGFloat
=
180
private
let
kCloseWidth
:
CGFloat
=
40
private
let
containerView
=
UIView
()
private
let
button
=
UIButton
()
private
let
viewGradient
=
CAGradientLayer
()
private
let
buttonGradient
=
CAGradientLayer
()
private
let
legendGradient
=
MapLegendGradientView
()
private
let
legendLabelsStackView
=
UIStackView
()
private
var
legendLabels
=
[
UILabel
]()
private
let
legendWeatherView
=
MapLegendWeatherView
()
private
let
legendSevereView
=
MapLegendSevereView
()
private
var
legendType
=
LegendType
.
weather
private
var
widthConstraint
:
Constraint
?
private
var
heightConstraint
:
Constraint
?
private
var
isOpened
=
false
init
()
{
...
...
@@ -49,21 +57,33 @@ class MapLegendView: UIView {
//Public
public
func
configure
(
radarLayer
:
RadarLayer
)
{
legendGradient
.
set
(
colors
:
radarLayer
.
layer
.
colors
)
buttonGradient
.
colors
=
radarLayer
.
layer
.
colors
legendSevereView
.
alpha
=
0
legendWeatherView
.
alpha
=
0
if
let
weatherLayer
=
radarLayer
.
layer
as?
WeatherLayerType
{
self
.
configure
(
weatherLayer
:
weatherLayer
)
}
legendLabelsStackView
.
removeAll
()
radarLayer
.
layer
.
values
.
enumerated
()
.
forEach
{
let
label
=
UILabel
()
label
.
font
=
AppFont
.
SFPro
.
regular
(
size
:
10
)
label
.
text
=
$1
self
.
legendLabels
.
append
(
label
)
legendLabelsStackView
.
addArrangedSubview
(
label
)
if
let
severeLayer
=
radarLayer
.
layer
as?
SevereLayerType
{
self
.
configure
(
severeLayer
:
severeLayer
)
}
legendLabelsStackView
.
layoutIfNeeded
()
}
//Private
private
func
configure
(
weatherLayer
:
WeatherLayerType
)
{
legendType
=
.
weather
legendWeatherView
.
alpha
=
isOpened
?
1
:
0
buttonGradient
.
colors
=
weatherLayer
.
colors
legendWeatherView
.
configure
(
weatherLayer
:
weatherLayer
)
}
private
func
configure
(
severeLayer
:
SevereLayerType
)
{
legendType
=
.
severe
legendSevereView
.
alpha
=
isOpened
?
1
:
0
buttonGradient
.
colors
=
severeLayer
.
colors
legendSevereView
.
configure
(
severeLayer
:
severeLayer
)
}
private
func
updateUI
()
{
switch
interfaceStyle
{
case
.
light
:
...
...
@@ -78,23 +98,25 @@ class MapLegendView: UIView {
@objc
private
func
handleButton
()
{
if
self
.
isOpened
{
self
.
isOpened
=
false
self
.
snp
.
updateConstraints
{
(
update
)
in
update
.
width
.
equalTo
(
self
.
kCloseWidth
)
}
self
.
widthConstraint
?
.
isActive
=
true
self
.
heightConstraint
?
.
isActive
=
true
}
else
{
self
.
isOpened
=
true
self
.
snp
.
updateConstraints
{
(
update
)
in
update
.
width
.
equalTo
(
self
.
kOpenWidth
)
}
self
.
widthConstraint
?
.
isActive
=
false
self
.
heightConstraint
?
.
isActive
=
false
}
self
.
setNeedsLayout
()
self
.
button
.
setImage
(
isOpened
?
UIImage
(
named
:
"map_legend_close"
)
:
nil
,
for
:
.
normal
)
UIView
.
animate
(
withDuration
:
0.3
)
{
self
.
superview
?
.
layoutIfNeeded
()
self
.
legendGradient
.
alpha
=
self
.
isOpened
?
1
:
0
self
.
legendLabelsStackView
.
alpha
=
self
.
isOpened
?
1
:
0
switch
self
.
legendType
{
case
.
weather
:
self
.
legendWeatherView
.
alpha
=
self
.
isOpened
?
1
:
0
case
.
severe
:
self
.
legendSevereView
.
alpha
=
self
.
isOpened
?
1
:
0
}
self
.
layer
.
borderWidth
=
self
.
isOpened
?
0.5
:
0
}
}
...
...
@@ -110,8 +132,10 @@ private extension MapLegendView {
layer
.
shadowOpacity
=
1
layer
.
shadowRadius
=
5
self
.
snp
.
makeConstraints
{
(
make
)
in
make
.
width
.
height
.
equalTo
(
40
)
.
priority
(
1000
)
addSubview
(
containerView
)
containerView
.
snp
.
makeConstraints
{
(
make
)
in
make
.
left
.
top
.
bottom
.
equalToSuperview
()
self
.
widthConstraint
=
make
.
width
.
equalTo
(
kCloseWidth
)
.
priority
(
1000
)
.
constraint
}
}
...
...
@@ -130,7 +154,7 @@ private extension MapLegendView {
button
.
layer
.
cornerRadius
=
14
button
.
addTarget
(
self
,
action
:
#selector(
handleButton
)
,
for
:
.
touchUpInside
)
button
.
layer
.
insertSublayer
(
buttonGradient
,
below
:
button
.
imageView
?
.
layer
)
addSubview
(
button
)
containerView
.
addSubview
(
button
)
button
.
snp
.
makeConstraints
{
(
make
)
in
make
.
width
.
height
.
equalTo
(
28
)
...
...
@@ -140,26 +164,23 @@ private extension MapLegendView {
}
func
prepareLegend
()
{
legendGradient
.
alpha
=
0
legendGradient
.
layer
.
cornerRadius
=
2
addSubview
(
legendGradient
)
legendWeatherView
.
alpha
=
0
containerView
.
addSubview
(
legendWeatherView
)
legend
Gradient
.
snp
.
makeConstraints
{
(
make
)
in
legend
WeatherView
.
snp
.
makeConstraints
{
(
make
)
in
make
.
left
.
equalTo
(
button
.
snp
.
right
)
.
offset
(
6
)
.
priority
(
999
)
make
.
top
.
equalToSuperview
()
.
inset
(
13
)
make
.
height
.
equalTo
(
4
)
make
.
right
.
equalToSuperview
()
.
inset
(
17
)
make
.
top
.
equalToSuperview
()
.
inset
(
13
)
make
.
bottom
.
equalToSuperview
()
.
inset
(
6
)
}
//Labels
legendLabelsStackView
.
alpha
=
0
legendLabelsStackView
.
axis
=
.
horizontal
legendLabelsStackView
.
distribution
=
.
equalCentering
addSubview
(
legendLabelsStackView
)
legendSevereView
.
alpha
=
0
containerView
.
addSubview
(
legendSevereView
)
legendLabelsStackView
.
snp
.
makeConstraints
{
(
make
)
in
make
.
left
.
right
.
equalTo
(
legendGradient
)
make
.
top
.
equalTo
(
legendGradient
.
snp
.
bottom
)
.
offset
(
6
)
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
0 → 100644
View file @
d35e906a
//
// MapLegendWeatherView.swift
// 1Weather
//
// Created by Dmitry Stepanets on 20.04.2021.
//
import
UIKit
class
MapLegendWeatherView
:
UIView
{
//Private
private
let
legendGradient
=
MapLegendGradientView
()
private
let
legendLabelsStackView
=
UIStackView
()
private
var
legendLabels
=
[
UILabel
]()
override
init
(
frame
:
CGRect
)
{
super
.
init
(
frame
:
frame
)
prepareLegend
()
prepareStackView
()
updateUI
()
}
required
init
?(
coder
:
NSCoder
)
{
fatalError
(
"init(coder:) has not been implemented"
)
}
override
func
traitCollectionDidChange
(
_
previousTraitCollection
:
UITraitCollection
?)
{
super
.
traitCollectionDidChange
(
previousTraitCollection
)
updateUI
()
}
public
func
configure
(
weatherLayer
:
WeatherLayerType
)
{
legendGradient
.
set
(
colors
:
weatherLayer
.
colors
)
legendLabelsStackView
.
removeAll
()
weatherLayer
.
values
.
enumerated
()
.
forEach
{
let
label
=
UILabel
()
label
.
font
=
AppFont
.
SFPro
.
regular
(
size
:
10
)
label
.
text
=
$1
self
.
legendLabels
.
append
(
label
)
legendLabelsStackView
.
addArrangedSubview
(
label
)
}
legendLabelsStackView
.
layoutIfNeeded
()
}
//Private
private
func
updateUI
()
{
self
.
legendLabels
.
forEach
{
switch
interfaceStyle
{
case
.
light
:
$0
.
textColor
=
ThemeManager
.
currentTheme
.
secondaryTextColor
case
.
dark
:
$0
.
textColor
=
ThemeManager
.
currentTheme
.
primaryTextColor
}
}
}
}
private
extension
MapLegendWeatherView
{
func
prepareLegend
()
{
legendGradient
.
layer
.
cornerRadius
=
2
addSubview
(
legendGradient
)
legendGradient
.
snp
.
makeConstraints
{
(
make
)
in
make
.
left
.
right
.
top
.
equalToSuperview
()
make
.
height
.
equalTo
(
4
)
}
}
func
prepareStackView
()
{
legendLabelsStackView
.
axis
=
.
horizontal
legendLabelsStackView
.
spacing
=
4
legendLabelsStackView
.
distribution
=
.
equalSpacing
addSubview
(
legendLabelsStackView
)
legendLabelsStackView
.
snp
.
makeConstraints
{
(
make
)
in
make
.
left
.
right
.
equalToSuperview
()
make
.
top
.
equalTo
(
legendGradient
.
snp
.
bottom
)
.
offset
(
6
)
make
.
bottom
.
equalToSuperview
()
.
inset
(
4
)
}
}
}
Pods/Pods.xcodeproj/xcuserdata/dstepanets.xcuserdatad/xcschemes/xcschememanagement.plist
View file @
d35e906a
...
...
@@ -21,14 +21,14 @@
<
k
e
y
>
isShown
<
/k
e
y
>
<
fa
ls
e
/
>
<
k
e
y
>
orderHint
<
/k
e
y
>
<
int
e
g
e
r
>
0
<
/int
e
g
e
r
>
<
int
e
g
e
r
>
1
<
/int
e
g
e
r
>
<
/
d
i
c
t
>
<
k
e
y
>
Cirque.xcscheme
<
/k
e
y
>
<
d
i
c
t
>
<
k
e
y
>
isShown
<
/k
e
y
>
<
fa
ls
e
/
>
<
k
e
y
>
orderHint
<
/k
e
y
>
<
int
e
g
e
r
>
3
<
/int
e
g
e
r
>
<
int
e
g
e
r
>
4
<
/int
e
g
e
r
>
<
/
d
i
c
t
>
<
k
e
y
>
Cirque.xcscheme_
^#
shared
#^
_
<
/k
e
y
>
<
d
i
c
t
>
...
...
@@ -232,7 +232,7 @@
<
k
e
y
>
isShown
<
/k
e
y
>
<
fa
ls
e
/
>
<
k
e
y
>
orderHint
<
/k
e
y
>
<
int
e
g
e
r
>
1
<
/int
e
g
e
r
>
<
int
e
g
e
r
>
2
<
/int
e
g
e
r
>
<
/
d
i
c
t
>
<
k
e
y
>
PromisesObjC.xcscheme
<
/k
e
y
>
<
d
i
c
t
>
...
...
@@ -251,7 +251,7 @@
<
k
e
y
>
isShown
<
/k
e
y
>
<
fa
ls
e
/
>
<
k
e
y
>
orderHint
<
/k
e
y
>
<
int
e
g
e
r
>
2
<
/int
e
g
e
r
>
<
int
e
g
e
r
>
3
<
/int
e
g
e
r
>
<
/
d
i
c
t
>
<
k
e
y
>
XMLCoder.xcscheme
<
/k
e
y
>
<
d
i
c
t
>
...
...
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