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
12ff1437
Commit
12ff1437
authored
Oct 06, 2021
by
Demid Merzlyakov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
IOS-183: minutely general smart text support.
parent
27623f2a
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
113 additions
and
1 deletions
+113
-1
1Weather/Resources/Assets.xcassets/minutely_smart_text_precipitation.imageset/Contents.json
+23
-0
1Weather/Resources/Assets.xcassets/minutely_smart_text_precipitation.imageset/bitmapCopy.png
+0
-0
1Weather/Resources/Assets.xcassets/minutely_smart_text_precipitation.imageset/bitmapCopy@2x.png
+0
-0
1Weather/Resources/Assets.xcassets/minutely_smart_text_precipitation.imageset/bitmapCopy@3x.png
+0
-0
1Weather/Resources/Assets.xcassets/minutely_smart_text_temperature.imageset/Contents.json
+23
-0
1Weather/Resources/Assets.xcassets/minutely_smart_text_temperature.imageset/bitmapCopy20.png
+0
-0
1Weather/Resources/Assets.xcassets/minutely_smart_text_temperature.imageset/bitmapCopy20@2x.png
+0
-0
1Weather/Resources/Assets.xcassets/minutely_smart_text_temperature.imageset/bitmapCopy20@3x.png
+0
-0
1Weather/UI/SharedViews/MinutelyForecastView/MinutelyForecastView.swift
+67
-1
No files found.
1Weather/Resources/Assets.xcassets/minutely_smart_text_precipitation.imageset/Contents.json
0 → 100644
View file @
12ff1437
{
"images"
:
[
{
"filename"
:
"bitmapCopy.png"
,
"idiom"
:
"universal"
,
"scale"
:
"1x"
},
{
"filename"
:
"bitmapCopy@2x.png"
,
"idiom"
:
"universal"
,
"scale"
:
"2x"
},
{
"filename"
:
"bitmapCopy@3x.png"
,
"idiom"
:
"universal"
,
"scale"
:
"3x"
}
],
"info"
:
{
"author"
:
"xcode"
,
"version"
:
1
}
}
1Weather/Resources/Assets.xcassets/minutely_smart_text_precipitation.imageset/bitmapCopy.png
0 → 100644
View file @
12ff1437
290 Bytes
1Weather/Resources/Assets.xcassets/minutely_smart_text_precipitation.imageset/bitmapCopy@2x.png
0 → 100644
View file @
12ff1437
386 Bytes
1Weather/Resources/Assets.xcassets/minutely_smart_text_precipitation.imageset/bitmapCopy@3x.png
0 → 100644
View file @
12ff1437
572 Bytes
1Weather/Resources/Assets.xcassets/minutely_smart_text_temperature.imageset/Contents.json
0 → 100644
View file @
12ff1437
{
"images"
:
[
{
"filename"
:
"bitmapCopy20.png"
,
"idiom"
:
"universal"
,
"scale"
:
"1x"
},
{
"filename"
:
"bitmapCopy20@2x.png"
,
"idiom"
:
"universal"
,
"scale"
:
"2x"
},
{
"filename"
:
"bitmapCopy20@3x.png"
,
"idiom"
:
"universal"
,
"scale"
:
"3x"
}
],
"info"
:
{
"author"
:
"xcode"
,
"version"
:
1
}
}
1Weather/Resources/Assets.xcassets/minutely_smart_text_temperature.imageset/bitmapCopy20.png
0 → 100644
View file @
12ff1437
291 Bytes
1Weather/Resources/Assets.xcassets/minutely_smart_text_temperature.imageset/bitmapCopy20@2x.png
0 → 100644
View file @
12ff1437
422 Bytes
1Weather/Resources/Assets.xcassets/minutely_smart_text_temperature.imageset/bitmapCopy20@3x.png
0 → 100644
View file @
12ff1437
476 Bytes
1Weather/UI/SharedViews/MinutelyForecastView/MinutelyForecastView.swift
View file @
12ff1437
...
...
@@ -8,6 +8,7 @@
import
UIKit
import
OneWeatherCore
import
Accelerate
import
SnapKit
enum
MinutelyForecastType
{
case
temperature
...
...
@@ -16,6 +17,9 @@ enum MinutelyForecastType {
private
let
kTemperatureColors
=
[
UIColor
(
hex
:
0xff934f
),
UIColor
(
hex
:
0xff414a
)]
private
let
kPrecipitationColors
=
[
UIColor
(
hex
:
0x2d99ff
),
UIColor
(
hex
:
0x8fc6fb
)]
private
let
kSmartTextBackgroundColorTemperature
=
UIColor
(
hex
:
0xfaedda80
)
private
let
kSmartTextBackgroundColorPrecipitation
=
UIColor
(
hex
:
0xd9ebfe
)
private
let
kSmartTextAreaHeight
=
CGFloat
(
40
)
private
class
MinutelyLevelView
:
UIView
{
private
let
gradient
=
CAGradientLayer
()
...
...
@@ -67,6 +71,10 @@ class MinutelyForecastView: UIView {
private
let
levelsStackView
=
UIStackView
()
private
let
verticalStackView
=
UIStackView
()
private
let
scrollView
=
UIScrollView
()
private
let
smartTextBackgroundView
=
UIView
()
private
var
smartTextBackgroundViewHeightContraint
:
Constraint
?
private
let
smartTextLabel
=
UILabel
()
private
let
smartTextIcon
=
UIImageView
()
private
let
centerDashline
=
CAShapeLayer
()
private
var
levelsDashline
=
[
CAShapeLayer
]()
private
let
feedbackGenerator
=
UISelectionFeedbackGenerator
()
...
...
@@ -75,6 +83,8 @@ class MinutelyForecastView: UIView {
private
var
lastSelectedLevelIndex
=
0
private
var
minutelyForecast
=
[
MinutelyItem
]()
private
var
forecastType
=
MinutelyForecastType
.
temperature
private
var
smartTextProvider
:
SmartTextProvider
=
SmartTextProvider
(
prioritizedSmartTexts
:
[])
private
lazy
var
dateFormatter
:
DateFormatter
=
{
let
formatter
=
DateFormatter
()
formatter
.
dateFormat
=
"h:mm a"
...
...
@@ -88,6 +98,7 @@ class MinutelyForecastView: UIView {
prepareDetailView
()
prepareCenterDashLine
()
prepareScrollView
()
prepareSmartTextView
()
prepareVerticalStackView
()
}
...
...
@@ -128,6 +139,7 @@ class MinutelyForecastView: UIView {
centerDashline
.
strokeColor
=
forecastType
==
.
temperature
?
kTemperatureColors
.
last
?
.
cgColor
:
kPrecipitationColors
.
last
?
.
cgColor
updateSmartText
()
prepareMinutelyItems
()
if
let
firstMinutelyItem
=
minutelyForecast
.
first
{
...
...
@@ -136,6 +148,29 @@ class MinutelyForecastView: UIView {
updateChart
()
}
private
func
updateSmartText
()
{
smartTextBackgroundView
.
backgroundColor
=
self
.
forecastType
==
.
temperature
?
kSmartTextBackgroundColorTemperature
:
kSmartTextBackgroundColorPrecipitation
smartTextIcon
.
image
=
UIImage
(
named
:
forecastType
==
.
temperature
?
"minutely_smart_text_temperature"
:
"minutely_smart_text_precipitation"
)
var
smartText
=
""
if
let
location
=
self
.
location
{
smartText
=
smartTextProvider
.
smartText
(
for
:
location
)
}
smartTextLabel
.
text
=
smartText
let
newHeight
:
CGFloat
if
smartText
.
isEmpty
{
newHeight
=
0
smartTextBackgroundView
.
isHidden
=
true
}
else
{
newHeight
=
kSmartTextAreaHeight
smartTextBackgroundView
.
isHidden
=
false
}
smartTextBackgroundViewHeightContraint
?
.
deactivate
()
smartTextBackgroundView
.
snp
.
makeConstraints
{
make
in
smartTextBackgroundViewHeightContraint
=
make
.
height
.
equalTo
(
newHeight
)
.
constraint
}
}
private
func
updateDetailsView
(
minutelyItem
:
MinutelyItem
)
{
switch
forecastType
{
case
.
temperature
:
...
...
@@ -382,10 +417,41 @@ private extension MinutelyForecastView {
make
.
left
.
equalToSuperview
()
.
inset
(
42
)
make
.
top
.
equalTo
(
detailsInfoView
.
snp
.
bottom
)
.
offset
(
8
)
make
.
right
.
equalToSuperview
()
.
inset
(
20
)
make
.
bottom
.
equalToSuperview
()
.
inset
(
40
)
}
}
func
prepareSmartTextView
()
{
smartTextBackgroundView
.
translatesAutoresizingMaskIntoConstraints
=
false
smartTextBackgroundView
.
layer
.
cornerRadius
=
12
smartTextBackgroundView
.
clipsToBounds
=
true
addSubview
(
smartTextBackgroundView
)
smartTextBackgroundView
.
snp
.
makeConstraints
{
make
in
make
.
top
.
equalTo
(
scrollView
.
snp
.
bottom
)
.
offset
(
18
)
make
.
left
.
right
.
equalToSuperview
()
.
inset
(
20
)
make
.
bottom
.
equalToSuperview
()
}
smartTextLabel
.
font
=
AppFont
.
SFPro
.
regular
(
size
:
13
)
smartTextLabel
.
numberOfLines
=
0
smartTextBackgroundView
.
addSubview
(
smartTextIcon
)
smartTextBackgroundView
.
addSubview
(
smartTextLabel
)
smartTextIcon
.
snp
.
makeConstraints
{
make
in
make
.
leading
.
equalToSuperview
()
.
inset
(
18
)
make
.
width
.
height
.
equalTo
(
12
)
make
.
centerY
.
equalToSuperview
()
}
smartTextLabel
.
snp
.
makeConstraints
{
make
in
make
.
leading
.
equalTo
(
smartTextIcon
.
snp
.
trailing
)
.
offset
(
7
)
make
.
centerY
.
equalToSuperview
()
make
.
trailing
.
lessThanOrEqualToSuperview
()
.
inset
(
18
)
}
updateSmartText
()
}
func
prepareCenterDashLine
()
{
centerDashline
.
lineWidth
=
1
centerDashline
.
lineDashPattern
=
[
4
,
2
]
...
...
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