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
bdca0e18
Commit
bdca0e18
authored
Apr 27, 2021
by
Demid Merzlyakov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
AppCoordinator can open screens now.
parent
1460b447
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
47 additions
and
10 deletions
+47
-10
1Weather/Coordinators/AppCoordinator.swift
+24
-0
1Weather/Coordinators/ForecastCoordinator.swift
+6
-0
1Weather/UI/View controllers/AppTabBarController.swift
+8
-7
1Weather/UI/View controllers/Forecast/ForecastViewController.swift
+9
-3
No files found.
1Weather/Coordinators/AppCoordinator.swift
View file @
bdca0e18
...
...
@@ -40,6 +40,30 @@ class AppCoordinator: Coordinator {
tabBarController
.
setupTabBar
()
}
public
func
openToday
()
{
tabBarController
.
selectedIndex
=
AppTabBarController
.
AppTab
.
today
.
rawValue
}
public
func
openForecast
(
timePeriod
:
TimePeriod
?)
{
let
forecastIndex
=
AppTabBarController
.
AppTab
.
forecast
.
rawValue
tabBarController
.
selectedIndex
=
forecastIndex
if
let
timePeriod
=
timePeriod
{
if
let
forecastCoordinator
=
childCoordinators
[
forecastIndex
]
as?
ForecastCoordinator
{
forecastCoordinator
.
open
(
timePeriod
:
timePeriod
)
}
}
}
public
func
openRadar
()
{
tabBarController
.
selectedIndex
=
AppTabBarController
.
AppTab
.
radar
.
rawValue
}
public
func
openNotifications
()
{
let
notificationsCoordinator
=
NotificationsCoordinator
(
parentViewController
:
tabBarController
)
notificationsCoordinator
.
parentCoordinator
=
self
notificationsCoordinator
.
start
()
}
func
viewControllerDidEnd
(
controller
:
UIViewController
)
{
//
}
...
...
1Weather/Coordinators/ForecastCoordinator.swift
View file @
bdca0e18
...
...
@@ -12,6 +12,7 @@ class ForecastCoordinator: Coordinator {
private
let
forecastViewModel
=
ForecastViewModel
(
locationManager
:
LocationManager
.
shared
)
private
let
navigationController
=
UINavigationController
(
nibName
:
nil
,
bundle
:
nil
)
private
var
tabBarController
:
UITabBarController
?
private
var
forecastViewController
:
ForecastViewController
?
//Public
var
childCoordinators
=
[
Coordinator
]()
...
...
@@ -25,6 +26,11 @@ class ForecastCoordinator: Coordinator {
let
forecastViewController
=
ForecastViewController
(
viewModel
:
forecastViewModel
)
navigationController
.
viewControllers
=
[
forecastViewController
]
tabBarController
?
.
add
(
viewController
:
navigationController
)
self
.
forecastViewController
=
forecastViewController
}
public
func
open
(
timePeriod
:
TimePeriod
)
{
self
.
forecastViewController
?
.
switchTo
(
timePeriod
:
timePeriod
)
}
func
viewControllerDidEnd
(
controller
:
UIViewController
)
{
...
...
1Weather/UI/View controllers/AppTabBarController.swift
View file @
bdca0e18
...
...
@@ -7,16 +7,17 @@
import
UIKit
private
enum
AppTab
:
Int
,
CaseIterable
{
case
today
=
0
case
forecast
=
1
case
radar
=
2
case
menu
=
3
}
class
AppTabBarController
:
UITabBarController
{
override
func
viewDidLoad
()
{
super
.
viewDidLoad
()
}
public
enum
AppTab
:
Int
,
CaseIterable
{
case
today
=
0
case
forecast
=
1
case
radar
=
2
case
menu
=
3
}
public
func
setupTabBar
()
{
...
...
1Weather/UI/View controllers/Forecast/ForecastViewController.swift
View file @
bdca0e18
...
...
@@ -67,13 +67,19 @@ class ForecastViewController: UIViewController {
}
}
public
func
switchTo
(
timePeriod
:
TimePeriod
)
{
if
self
.
timePeriodControl
.
selectedSegmentIndex
!=
timePeriod
.
rawValue
{
self
.
timePeriodControl
.
selectedSegmentIndex
=
timePeriod
.
rawValue
}
forecastCellFactory
.
setTimePeriod
(
timePeriod
:
timePeriod
)
self
.
tableView
.
reloadData
()
}
@objc
private
func
handleSegmentDidChange
()
{
guard
let
timePeriod
=
TimePeriod
(
rawValue
:
self
.
timePeriodControl
.
selectedSegmentIndex
)
else
{
return
}
forecastCellFactory
.
setTimePeriod
(
timePeriod
:
timePeriod
)
self
.
tableView
.
reloadData
()
self
.
switchTo
(
timePeriod
:
timePeriod
)
}
@objc
private
func
handleCityButton
()
{
...
...
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