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
ea8ee682
Commit
ea8ee682
authored
Aug 10, 2021
by
Dmitriy Stepanets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Working on optimization
parent
0d839b0e
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
27 additions
and
50 deletions
+27
-50
1Weather.xcworkspace/xcuserdata/dstepanets.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist
+4
-36
OneWeatherUI/OneWeatherUI/Extensions/OneWeatherUI+Global.swift
+3
-3
OneWeatherWidget/Data/WeatherProvider.swift
+6
-7
OneWeatherWidget/UI/SnapshotLoader.swift
+12
-3
Pods/Swarm/Swarm/SwarmTileOverlayRenderer.swift
+2
-1
No files found.
1Weather.xcworkspace/xcuserdata/dstepanets.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist
View file @
ea8ee682
...
@@ -7,48 +7,16 @@
...
@@ -7,48 +7,16 @@
<BreakpointProxy
<BreakpointProxy
BreakpointExtensionID =
"Xcode.Breakpoint.FileBreakpoint"
>
BreakpointExtensionID =
"Xcode.Breakpoint.FileBreakpoint"
>
<BreakpointContent
<BreakpointContent
uuid =
"A7148659-DCDF-4EB8-92F7-0A571A0AF0A4"
uuid =
"A9B8B751-5C25-4473-82EC-7DA4EEF9BFB2"
shouldBeEnabled =
"Yes"
ignoreCount =
"0"
continueAfterRunningActions =
"No"
filePath =
"OneWeatherWidget/UI/SnapshotLoader.swift"
startingColumnNumber =
"9223372036854775807"
endingColumnNumber =
"9223372036854775807"
startingLineNumber =
"36"
endingLineNumber =
"36"
landmarkName =
"load(at:size:completion:)"
landmarkType =
"7"
>
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID =
"Xcode.Breakpoint.FileBreakpoint"
>
<BreakpointContent
uuid =
"5B96F754-0820-40B1-949A-F9E6198E88F7"
shouldBeEnabled =
"Yes"
ignoreCount =
"0"
continueAfterRunningActions =
"No"
filePath =
"OneWeatherWidget/UI/SnapshotLoader.swift"
startingColumnNumber =
"9223372036854775807"
endingColumnNumber =
"9223372036854775807"
startingLineNumber =
"59"
endingLineNumber =
"59"
landmarkName =
"addTile(to:region:scale:completion:)"
landmarkType =
"7"
>
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID =
"Xcode.Breakpoint.FileBreakpoint"
>
<BreakpointContent
uuid =
"095DF7BE-D4B0-44F2-8BAD-AE8C0E952B56"
shouldBeEnabled =
"Yes"
shouldBeEnabled =
"Yes"
ignoreCount =
"0"
ignoreCount =
"0"
continueAfterRunningActions =
"No"
continueAfterRunningActions =
"No"
filePath =
"Pods/Swarm/Swarm/SwarmTileOverlayRenderer.swift"
filePath =
"Pods/Swarm/Swarm/SwarmTileOverlayRenderer.swift"
startingColumnNumber =
"9223372036854775807"
startingColumnNumber =
"9223372036854775807"
endingColumnNumber =
"9223372036854775807"
endingColumnNumber =
"9223372036854775807"
startingLineNumber =
"
88
"
startingLineNumber =
"
107
"
endingLineNumber =
"
88
"
endingLineNumber =
"
107
"
landmarkName =
"getTilesImage(_:zoomLevel:completion:)"
landmarkName =
"getTilesImage(_:zoomLevel:
scale:
completion:)"
landmarkType =
"7"
>
landmarkType =
"7"
>
</BreakpointContent>
</BreakpointContent>
</BreakpointProxy>
</BreakpointProxy>
...
...
OneWeatherUI/OneWeatherUI/Extensions/OneWeatherUI+Global.swift
View file @
ea8ee682
...
@@ -13,10 +13,10 @@ extension OneWeatherUI {
...
@@ -13,10 +13,10 @@ extension OneWeatherUI {
static
let
frameworkBundle
=
Bundle
(
for
:
OneWeatherUIClass
.
self
)
static
let
frameworkBundle
=
Bundle
(
for
:
OneWeatherUIClass
.
self
)
static
let
loadFonts
:
()
=
{
static
let
loadFonts
:
()
=
{
loadFontWith
(
name
:
"SF-Pro-Display-Regular"
,
fileExtension
:
"otf"
)
//
loadFontWith(name: "SF-Pro-Display-Regular", fileExtension: "otf")
loadFontWith
(
name
:
"SF-Pro-Display-Light"
,
fileExtension
:
"otf"
)
//
loadFontWith(name: "SF-Pro-Display-Light", fileExtension: "otf")
loadFontWith
(
name
:
"SF-Pro-Display-Bold"
,
fileExtension
:
"otf"
)
loadFontWith
(
name
:
"SF-Pro-Display-Bold"
,
fileExtension
:
"otf"
)
loadFontWith
(
name
:
"SF-Pro-Display-Thin"
,
fileExtension
:
"otf"
)
//
loadFontWith(name: "SF-Pro-Display-Thin", fileExtension: "otf")
}()
}()
internal
static
func
loadFontWith
(
name
:
String
,
fileExtension
:
String
)
{
internal
static
func
loadFontWith
(
name
:
String
,
fileExtension
:
String
)
{
...
...
OneWeatherWidget/Data/WeatherProvider.swift
View file @
ea8ee682
...
@@ -64,12 +64,11 @@ class WeatherProvider: TimelineProvider {
...
@@ -64,12 +64,11 @@ class WeatherProvider: TimelineProvider {
}
}
func
getTimeline
(
in
context
:
Context
,
completion
:
@escaping
(
Timeline
<
WeatherEntry
>
)
->
Void
)
{
func
getTimeline
(
in
context
:
Context
,
completion
:
@escaping
(
Timeline
<
WeatherEntry
>
)
->
Void
)
{
getUpToDateLocation
{
location
in
getUpToDateLocation
{
location
in
guard
let
fetchedLocation
=
location
else
{
if
return
let
fetchedLocation
=
location
,
}
let
coordinates
=
fetchedLocation
.
coordinates
{
if
let
coordinates
=
fetchedLocation
.
coordinates
{
SnapshotLoader
.
load
(
at
:
coordinates
,
SnapshotLoader
.
load
(
at
:
coordinates
,
size
:
.
init
(
width
:
340
,
height
:
280
)
size
:
.
init
(
width
:
340
,
height
:
280
)
)
{
mapImage
in
)
{
mapImage
in
...
@@ -82,7 +81,7 @@ class WeatherProvider: TimelineProvider {
...
@@ -82,7 +81,7 @@ class WeatherProvider: TimelineProvider {
}
}
else
{
else
{
let
nextRefresh
=
Calendar
.
current
.
date
(
byAdding
:
.
minute
,
value
:
30
,
to
:
Date
())
!
let
nextRefresh
=
Calendar
.
current
.
date
(
byAdding
:
.
minute
,
value
:
30
,
to
:
Date
())
!
let
entry
=
WeatherEntry
(
location
:
fetchedL
ocation
,
date
:
nextRefresh
)
let
entry
=
WeatherEntry
(
location
:
l
ocation
,
date
:
nextRefresh
)
let
timeline
=
Timeline
(
entries
:
[
entry
],
policy
:
.
atEnd
)
let
timeline
=
Timeline
(
entries
:
[
entry
],
policy
:
.
atEnd
)
WidgetManager
.
shared
.
logUpdate
()
WidgetManager
.
shared
.
logUpdate
()
completion
(
timeline
)
completion
(
timeline
)
...
...
OneWeatherWidget/UI/SnapshotLoader.swift
View file @
ea8ee682
...
@@ -49,12 +49,21 @@ class SnapshotLoader: ObservableObject {
...
@@ -49,12 +49,21 @@ class SnapshotLoader: ObservableObject {
completion
:
@escaping
(
_
finalImage
:
UIImage
?)
->
Void
completion
:
@escaping
(
_
finalImage
:
UIImage
?)
->
Void
)
{
)
{
DispatchQueue
.
main
.
async
{
DispatchQueue
.
main
.
async
{
let
mapView
=
MKMapView
(
frame
:
.
init
(
origin
:
.
zero
,
size
:
.
init
(
width
:
340
,
height
:
280
)))
// let mapView = MKMapView(frame: .init(origin: .zero, size: .init(width: 340, height: 280)))
mapView
.
setRegion
(
region
,
animated
:
false
)
// mapView.setRegion(region, animated: false)
let
topLeft
=
CLLocationCoordinate2D
(
latitude
:
region
.
center
.
latitude
+
(
region
.
span
.
latitudeDelta
/
2
),
longitude
:
region
.
center
.
longitude
-
(
region
.
span
.
longitudeDelta
/
2
))
let
bottomRight
=
CLLocationCoordinate2D
(
latitude
:
region
.
center
.
latitude
-
(
region
.
span
.
latitudeDelta
/
2
),
longitude
:
region
.
center
.
longitude
+
(
region
.
span
.
longitudeDelta
/
2
))
let
a
=
MKMapPoint
(
topLeft
)
let
b
=
MKMapPoint
(
bottomRight
)
let
rect
=
MKMapRect
(
origin
:
MKMapPoint
(
x
:
min
(
a
.
x
,
b
.
x
),
y
:
min
(
a
.
y
,
b
.
y
)),
size
:
MKMapSize
(
width
:
abs
(
a
.
x
-
b
.
x
),
height
:
abs
(
a
.
y
-
b
.
y
)))
let
renderer
=
SwarmTileOverlayRenderer
(
overlay
:
SnapshotLoader
.
swarmOverlay
)
let
renderer
=
SwarmTileOverlayRenderer
(
overlay
:
SnapshotLoader
.
swarmOverlay
)
let
zoomLevel
=
Int
(
SnapshotLoader
.
zoomLevel
(
for
:
region
)
.
rounded
(
.
up
))
let
zoomLevel
=
Int
(
SnapshotLoader
.
zoomLevel
(
for
:
region
)
.
rounded
(
.
up
))
renderer
.
getTilesImage
(
mapView
.
visibleMapRect
,
zoomLevel
:
zoomLevel
)
{
image
in
renderer
.
getTilesImage
(
rect
,
zoomLevel
:
zoomLevel
,
scale
:
scale
)
{
image
in
guard
let
tilesImage
=
image
else
{
guard
let
tilesImage
=
image
else
{
completion
(
nil
)
completion
(
nil
)
return
return
...
...
Pods/Swarm/Swarm/SwarmTileOverlayRenderer.swift
View file @
ea8ee682
...
@@ -78,6 +78,7 @@ open class SwarmTileOverlayRenderer: MKTileOverlayRenderer {
...
@@ -78,6 +78,7 @@ open class SwarmTileOverlayRenderer: MKTileOverlayRenderer {
public
func
getTilesImage
(
_
forRect
:
MKMapRect
,
public
func
getTilesImage
(
_
forRect
:
MKMapRect
,
zoomLevel
:
Int
,
zoomLevel
:
Int
,
scale
:
CGFloat
,
completion
:
@escaping
(
_
tilesImage
:
UIImage
?)
->
Void
completion
:
@escaping
(
_
tilesImage
:
UIImage
?)
->
Void
)
{
)
{
let
downloadGroup
=
DispatchGroup
()
let
downloadGroup
=
DispatchGroup
()
...
@@ -89,7 +90,7 @@ open class SwarmTileOverlayRenderer: MKTileOverlayRenderer {
...
@@ -89,7 +90,7 @@ open class SwarmTileOverlayRenderer: MKTileOverlayRenderer {
return
return
}
}
let
tilePaths
=
forRect
.
tilePaths
(
zoomLevel
,
tileSize
:
256
,
contentScale
:
2
)
let
tilePaths
=
forRect
.
tilePaths
(
zoomLevel
,
tileSize
:
256
,
contentScale
:
scale
)
for
path
in
tilePaths
{
for
path
in
tilePaths
{
let
url
=
swarm
.
urlForTile
(
path
,
timestamp
:
timeStamp
)
let
url
=
swarm
.
urlForTile
(
path
,
timestamp
:
timeStamp
)
downloadGroup
.
enter
()
downloadGroup
.
enter
()
...
...
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