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
d71867cc
Commit
d71867cc
authored
May 12, 2021
by
Demid Merzlyakov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Forecast: fix (hopefully) infinite recursion in `scrollViewDidScroll`.
parent
30bfb68a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
1 deletions
+13
-1
1Weather/UI/View controllers/Forecast/ForecastViewController.swift
+13
-1
No files found.
1Weather/UI/View controllers/Forecast/ForecastViewController.swift
View file @
d71867cc
...
...
@@ -23,6 +23,8 @@ class ForecastViewController: UIViewController {
return
TimePeriod
(
rawValue
:
timePeriodControl
.
selectedSegmentIndex
)
??
.
daily
}
private
var
navigationBarStateBeingChanged
=
false
init
(
viewModel
:
ForecastViewModel
,
coordinator
:
ForecastCoordinator
)
{
self
.
viewModel
=
viewModel
self
.
coordinator
=
coordinator
...
...
@@ -188,6 +190,7 @@ private extension ForecastViewController {
extension
ForecastViewController
:
UITableViewDelegate
{
func
scrollViewDidScroll
(
_
scrollView
:
UIScrollView
)
{
guard
!
navigationBarStateBeingChanged
,
let
navVC
=
self
.
navigationController
,
viewModel
.
location
?
.
daily
.
isEmpty
==
false
,
self
.
timePeriod
==
.
daily
...
...
@@ -200,18 +203,27 @@ extension ForecastViewController: UITableViewDelegate {
}
let
startPointY
=
timePeriodCellFrame
.
origin
.
y
+
timePeriodCellFrame
.
height
-
self
.
daysControlView
.
frame
.
height
let
animationDuration
=
TimeInterval
(
UINavigationController
.
hideShowBarDuration
)
if
scrollView
.
contentOffset
.
y
>=
startPointY
{
if
!
navVC
.
isNavigationBarHidden
{
self
.
navigationBarStateBeingChanged
=
true
DispatchQueue
.
main
.
asyncAfter
(
deadline
:
.
now
()
+
animationDuration
)
{
self
.
navigationBarStateBeingChanged
=
false
}
navVC
.
setNavigationBarHidden
(
true
,
animated
:
true
)
self
.
daysControlView
.
update
(
offset
:
self
.
viewModel
.
offsetHolder
.
currentOffset
)
UIView
.
animate
(
withDuration
:
0.35
)
{
UIView
.
animate
(
withDuration
:
animationDuration
)
{
self
.
daysControlView
.
alpha
=
1
}
}
}
else
{
if
navVC
.
isNavigationBarHidden
{
self
.
navigationBarStateBeingChanged
=
true
DispatchQueue
.
main
.
asyncAfter
(
deadline
:
.
now
()
+
animationDuration
)
{
self
.
navigationBarStateBeingChanged
=
false
}
navVC
.
setNavigationBarHidden
(
false
,
animated
:
true
)
UIView
.
animate
(
withDuration
:
0.35
)
{
self
.
daysControlView
.
alpha
=
0
...
...
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