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
caac91a4
Commit
caac91a4
authored
Sep 29, 2021
by
Dmitry Stepanets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[IOS-172]: Working on weather type cache
parent
cfb301df
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
55 additions
and
5 deletions
+55
-5
1Weather.xcworkspace/xcuserdata/dstepanets.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist
+18
-0
1Weather/UI/SharedViews/MinutelyForecastView/MinutelyForecastView.swift
+32
-5
OneWeatherCore/OneWeatherCore/ModelObjects/Minutely/MinutelyItem.swift
+5
-0
No files found.
1Weather.xcworkspace/xcuserdata/dstepanets.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist
View file @
caac91a4
...
@@ -3,4 +3,22 @@
...
@@ -3,4 +3,22 @@
uuid =
"55281C35-FE9F-4CED-865E-FBED0E7393F6"
uuid =
"55281C35-FE9F-4CED-865E-FBED0E7393F6"
type =
"0"
type =
"0"
version =
"2.0"
>
version =
"2.0"
>
<Breakpoints>
<BreakpointProxy
BreakpointExtensionID =
"Xcode.Breakpoint.FileBreakpoint"
>
<BreakpointContent
uuid =
"75F9A873-CE27-44A5-80C1-ACB69F8CF7B8"
shouldBeEnabled =
"Yes"
ignoreCount =
"0"
continueAfterRunningActions =
"No"
filePath =
"1Weather/UI/SharedViews/MinutelyForecastView/MinutelyForecastView.swift"
startingColumnNumber =
"9223372036854775807"
endingColumnNumber =
"9223372036854775807"
startingLineNumber =
"283"
endingLineNumber =
"283"
landmarkName =
"scrollViewDidScroll(_:)"
landmarkType =
"7"
>
</BreakpointContent>
</BreakpointProxy>
</Breakpoints>
</Bucket>
</Bucket>
1Weather/UI/SharedViews/MinutelyForecastView/MinutelyForecastView.swift
View file @
caac91a4
...
@@ -57,6 +57,7 @@ class MinutelyForecastView: UIView {
...
@@ -57,6 +57,7 @@ class MinutelyForecastView: UIView {
private
let
scrollView
=
UIScrollView
()
private
let
scrollView
=
UIScrollView
()
private
let
centerDashline
=
CAShapeLayer
()
private
let
centerDashline
=
CAShapeLayer
()
private
var
levelsPositionXCache
=
[
Int
:
CGFloat
]()
private
var
levelsPositionXCache
=
[
Int
:
CGFloat
]()
private
var
weatherTypeCache
=
[
Int
:
WeatherType
]()
private
lazy
var
dateFormatter
:
DateFormatter
=
{
private
lazy
var
dateFormatter
:
DateFormatter
=
{
let
formatter
=
DateFormatter
()
let
formatter
=
DateFormatter
()
formatter
.
dateFormat
=
"h:mm a"
formatter
.
dateFormat
=
"h:mm a"
...
@@ -100,9 +101,35 @@ class MinutelyForecastView: UIView {
...
@@ -100,9 +101,35 @@ class MinutelyForecastView: UIView {
colors
:
kTemperatureColors
)
colors
:
kTemperatureColors
)
}
}
updateWeatherTypeCahce
()
updateChart
()
updateChart
()
}
}
private
func
updateWeatherTypeCahce
()
{
weatherTypeCache
.
removeAll
()
guard
let
currentLocation
=
self
.
location
,
let
minutelyForecast
=
currentLocation
.
minutely
else
{
return
}
let
allHours
=
minutelyForecast
.
forecast
.
compactMap
{
$0
.
hourComponent
}
let
maxHour
=
allHours
.
max
{
$0
>
$1
}
??
0
for
hourlyWeather
in
currentLocation
.
hourly
{
guard
let
hourComponent
=
Calendar
.
current
.
dateComponents
([
.
hour
],
from
:
hourlyWeather
.
date
)
.
hour
else
{
continue
}
if
hourComponent
>
maxHour
{
return
}
weatherTypeCache
[
hourComponent
]
=
hourlyWeather
.
type
}
}
private
func
updateChart
()
{
private
func
updateChart
()
{
verticalStackView
.
removeAll
()
verticalStackView
.
removeAll
()
levelsStackView
.
removeAll
()
levelsStackView
.
removeAll
()
...
@@ -173,7 +200,7 @@ class MinutelyForecastView: UIView {
...
@@ -173,7 +200,7 @@ class MinutelyForecastView: UIView {
levelsPositionXCache
[
index
]
=
view
.
frame
.
origin
.
x
levelsPositionXCache
[
index
]
=
view
.
frame
.
origin
.
x
}
}
}
}
required
init
?(
coder
:
NSCoder
)
{
required
init
?(
coder
:
NSCoder
)
{
fatalError
(
"init(coder:) has not been implemented"
)
fatalError
(
"init(coder:) has not been implemented"
)
}
}
...
@@ -249,10 +276,10 @@ extension MinutelyForecastView: UIScrollViewDelegate {
...
@@ -249,10 +276,10 @@ extension MinutelyForecastView: UIScrollViewDelegate {
return
return
}
}
let
forecast
=
location
?
.
minutely
?
.
forecast
[
cachedValue
.
key
]
let
forecast
=
location
?
.
minutely
?
.
forecast
[
cachedValue
.
key
]
detailsInfoView
.
configure
(
valueStirng
:
forecast
?
.
temp
.
shortString
??
"--"
,
detailsInfoView
.
configure
(
valueStirng
:
forecast
?
.
temp
.
shortString
??
"--"
,
date
:
forecast
?
.
time
,
date
:
forecast
?
.
time
,
colors
:
kTemperatureColors
)
colors
:
kTemperatureColors
)
print
(
"[min] Target current index
\(
cachedValue
.
key
)
"
)
print
(
"[min] Target current index
\(
cachedValue
.
key
)
"
)
}
}
}
}
OneWeatherCore/OneWeatherCore/ModelObjects/Minutely/MinutelyItem.swift
View file @
caac91a4
...
@@ -13,6 +13,7 @@ public struct MinutelyItem {
...
@@ -13,6 +13,7 @@ public struct MinutelyItem {
public
let
precipitation
:
Double
public
let
precipitation
:
Double
public
let
windSpeed
:
WindSpeed
public
let
windSpeed
:
WindSpeed
public
let
pressure
:
Pressure
public
let
pressure
:
Pressure
public
let
hourComponent
:
Int
?
public
init
(
time
:
Date
,
temp
:
Temperature
,
precipitation
:
Double
,
windSpeed
:
WindSpeed
,
pressure
:
Pressure
)
{
public
init
(
time
:
Date
,
temp
:
Temperature
,
precipitation
:
Double
,
windSpeed
:
WindSpeed
,
pressure
:
Pressure
)
{
self
.
time
=
time
self
.
time
=
time
...
@@ -20,5 +21,9 @@ public struct MinutelyItem {
...
@@ -20,5 +21,9 @@ public struct MinutelyItem {
self
.
precipitation
=
precipitation
self
.
precipitation
=
precipitation
self
.
windSpeed
=
windSpeed
self
.
windSpeed
=
windSpeed
self
.
pressure
=
pressure
self
.
pressure
=
pressure
let
calendar
=
Calendar
.
current
let
components
=
calendar
.
dateComponents
([
.
hour
],
from
:
time
)
self
.
hourComponent
=
components
.
hour
}
}
}
}
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