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
1460b447
Commit
1460b447
authored
Apr 27, 2021
by
Demid Merzlyakov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Radar: handle bell icon, arrow icon, click on city.
parent
a554db24
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
2 deletions
+31
-2
1Weather/Coordinators/RadarCoordinator.swift
+6
-0
1Weather/UI/View controllers/Radar/RadarViewController.swift
+6
-2
1Weather/ViewModels/RadarViewModel.swift
+19
-0
No files found.
1Weather/Coordinators/RadarCoordinator.swift
View file @
1460b447
...
...
@@ -32,6 +32,12 @@ class RadarCoordinator: Coordinator {
notificationsCoordinator
.
start
()
}
public
func
openLocationsSearch
()
{
let
searchCoordinator
=
LocationSearchCoordinator
(
parentViewController
:
navigationController
)
searchCoordinator
.
parentCoordinator
=
self
searchCoordinator
.
start
()
}
func
viewControllerDidEnd
(
controller
:
UIViewController
)
{
//
}
...
...
1Weather/UI/View controllers/Radar/RadarViewController.swift
View file @
1460b447
...
...
@@ -186,7 +186,7 @@ class RadarViewController: UIViewController {
//MARK: Handlers
@objc
private
func
handleCityButton
()
{
coordinator
.
openLocationsSearch
()
}
@objc
private
func
handleNotificationButton
()
{
...
...
@@ -230,7 +230,7 @@ class RadarViewController: UIViewController {
}
@objc
private
func
handleLocationButton
()
{
radarViewModel
.
useCurrentLocationTapped
(
in
:
self
)
}
}
...
...
@@ -365,6 +365,10 @@ extension RadarViewController: RadarViewModelDelegate {
pinnedLayersView
.
selectLayer
(
radarLayer
:
selectedLayer
)
}
}
func
viewModel
(
model
:
RadarViewModel
,
tellsToNavigateTo
coordinates
:
CLLocationCoordinate2D
)
{
mapView
.
setCenter
(
coordinates
,
animated
:
true
)
}
}
//MARK:- MapView delegate
...
...
1Weather/ViewModels/RadarViewModel.swift
View file @
1460b447
...
...
@@ -7,10 +7,12 @@
import
UIKit
import
Swarm
import
CoreLocation
protocol
RadarViewModelDelegate
:
ViewModelDelegate
{
func
viewModel
(
model
:
RadarViewModel
,
didSelectLayer
layer
:
RadarLayer
)
func
viewModelPinnedLayersDidChange
(
model
:
RadarViewModel
)
func
viewModel
(
model
:
RadarViewModel
,
tellsToNavigateTo
coordinates
:
CLLocationCoordinate2D
)
}
class
RadarViewModel
:
ViewModelProtocol
{
...
...
@@ -119,6 +121,19 @@ class RadarViewModel: ViewModelProtocol {
return
items
}
public
func
useCurrentLocationTapped
(
in
vc
:
UIViewController
)
{
locationManager
.
useCurrentLocation
(
presentDialogsIn
:
vc
)
{
(
result
)
in
switch
result
{
case
.
success
:
break
case
.
denied
:
break
case
.
useSearch
:
break
}
}
}
//Private
private
func
rebuildLayers
()
{
let
pinnedLayerIds
=
Settings
.
shared
.
pinnedLayerIds
...
...
@@ -143,6 +158,10 @@ extension RadarViewModel: LocationManagerDelegate {
func
locationManager
(
_
locationManager
:
LocationManager
,
changedSelectedLocation
newLocation
:
Location
?)
{
self
.
rebuildLayers
()
if
let
coordinates
=
newLocation
?
.
coordinates
{
self
.
delegate
?
.
viewModel
(
model
:
self
,
tellsToNavigateTo
:
coordinates
)
}
DispatchQueue
.
main
.
async
{
self
.
delegate
?
.
viewModelDidChange
(
model
:
self
)
}
...
...
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