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
94c6f356
Commit
94c6f356
authored
Mar 17, 2021
by
Dmitriy Stepanets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Experiments
parent
21eee6bc
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
119 additions
and
48 deletions
+119
-48
1Weather.xcworkspace/xcuserdata/dstepanets.xcuserdatad/UserInterfaceState.xcuserstate
+0
-0
1Weather.xcworkspace/xcuserdata/dstepanets.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist
+66
-0
1Weather/UI/Helpers/DayControlsNavigationBar.swift
+15
-40
1Weather/UI/Helpers/DayControlsNavigatoinController.swift
+0
-4
1Weather/UI/View controllers/Forecast/ForecastViewController.swift
+15
-1
1Weather/UI/View controllers/Today/TodayViewController.swift
+23
-3
No files found.
1Weather.xcworkspace/xcuserdata/dstepanets.xcuserdatad/UserInterfaceState.xcuserstate
View file @
94c6f356
No preview for this file type
1Weather.xcworkspace/xcuserdata/dstepanets.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist
View file @
94c6f356
...
@@ -3,4 +3,70 @@
...
@@ -3,4 +3,70 @@
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 =
"89C8A0DD-3D0D-4C33-BA19-94E6A7991DA2"
shouldBeEnabled =
"Yes"
ignoreCount =
"0"
continueAfterRunningActions =
"No"
filePath =
"1Weather/UI/Helpers/DayControlsNavigationBar.swift"
startingColumnNumber =
"9223372036854775807"
endingColumnNumber =
"9223372036854775807"
startingLineNumber =
"50"
endingLineNumber =
"50"
landmarkName =
"restoreProgress()"
landmarkType =
"7"
>
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID =
"Xcode.Breakpoint.FileBreakpoint"
>
<BreakpointContent
uuid =
"14AFAEC9-A39D-4B7B-9B2D-C2DA2519300A"
shouldBeEnabled =
"Yes"
ignoreCount =
"0"
continueAfterRunningActions =
"No"
filePath =
"1Weather/UI/Helpers/DayControlsNavigationBar.swift"
startingColumnNumber =
"9223372036854775807"
endingColumnNumber =
"9223372036854775807"
startingLineNumber =
"35"
endingLineNumber =
"35"
landmarkName =
"showControls(progressValue:)"
landmarkType =
"7"
>
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID =
"Xcode.Breakpoint.FileBreakpoint"
>
<BreakpointContent
uuid =
"D794B66E-D7A6-4A78-A1CE-C34AC9DC948E"
shouldBeEnabled =
"Yes"
ignoreCount =
"0"
continueAfterRunningActions =
"No"
filePath =
"1Weather/UI/Helpers/DayControlsNavigationBar.swift"
startingColumnNumber =
"9223372036854775807"
endingColumnNumber =
"9223372036854775807"
startingLineNumber =
"51"
endingLineNumber =
"51"
landmarkName =
"restoreProgress()"
landmarkType =
"7"
>
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID =
"Xcode.Breakpoint.FileBreakpoint"
>
<BreakpointContent
uuid =
"2AD266BE-E133-463F-BF26-2797D4C1A0EF"
shouldBeEnabled =
"Yes"
ignoreCount =
"0"
continueAfterRunningActions =
"No"
filePath =
"1Weather/UI/Helpers/DayControlsNavigationBar.swift"
startingColumnNumber =
"9223372036854775807"
endingColumnNumber =
"9223372036854775807"
startingLineNumber =
"40"
endingLineNumber =
"40"
landmarkName =
"showControls(progressValue:)"
landmarkType =
"7"
>
</BreakpointContent>
</BreakpointProxy>
</Breakpoints>
</Bucket>
</Bucket>
1Weather/UI/Helpers/DayControlsNavigationBar.swift
View file @
94c6f356
...
@@ -8,35 +8,22 @@
...
@@ -8,35 +8,22 @@
import
UIKit
import
UIKit
class
DayControlsNavigationBar
:
UINavigationBar
{
class
DayControlsNavigationBar
:
UINavigationBar
{
private
let
customView
=
UIView
()
private
var
contentView
:
UIView
?
private
var
currentProgress
:
CGFloat
=
0
private
var
currentProgress
:
CGFloat
=
0
private
var
savedProgress
:
CGFloat
=
0
private
var
savedProgress
:
CGFloat
=
0
var
controlsHeigh
t
:
CGFloat
=
0
private
var
defaultYOffse
t
:
CGFloat
=
0
override
init
(
frame
:
CGRect
)
{
override
init
(
frame
:
CGRect
)
{
super
.
init
(
frame
:
frame
)
super
.
init
(
frame
:
frame
)
customView
.
backgroundColor
=
.
lightGray
isTranslucent
=
true
}
}
override
func
layoutSubviews
()
{
override
func
layoutSubviews
()
{
super
.
layoutSubviews
()
super
.
layoutSubviews
()
guard
let
contentView
=
self
.
contentView
else
{
if
frame
.
origin
.
y
!=
0
&&
defaultYOffset
==
0
{
self
.
findAndSetupContentView
()
self
.
defaultYOffset
=
frame
.
origin
.
y
return
}
}
print
(
"Layout subviews"
)
let
targetHeight
=
contentView
.
frame
.
height
*
2
self
.
contentView
?
.
frame
.
size
.
height
=
targetHeight
self
.
customView
.
frame
=
.
init
(
x
:
contentView
.
frame
.
origin
.
x
,
y
:
targetHeight
/
2
,
width
:
contentView
.
frame
.
width
,
height
:
targetHeight
/
2
)
self
.
controlsHeight
=
targetHeight
/
2
}
}
required
init
?(
coder
:
NSCoder
)
{
required
init
?(
coder
:
NSCoder
)
{
...
@@ -49,14 +36,8 @@ class DayControlsNavigationBar: UINavigationBar {
...
@@ -49,14 +36,8 @@ class DayControlsNavigationBar: UINavigationBar {
progress
=
min
(
progress
,
1
)
progress
=
min
(
progress
,
1
)
self
.
currentProgress
=
progress
self
.
currentProgress
=
progress
self
.
contentView
?
.
frame
.
origin
.
y
=
-
controlsHeight
*
progress
self
.
frame
.
origin
.
y
=
defaultYOffset
-
self
.
frame
.
height
*
progressValue
self
.
contentView
?
.
subviews
.
forEach
{
self
.
alpha
=
1
-
progressValue
if
$0
!=
customView
{
$0
.
alpha
=
1
-
progress
}
}
self
.
customView
.
alpha
=
progress
}
}
public
func
saveProgress
()
{
public
func
saveProgress
()
{
...
@@ -64,21 +45,15 @@ class DayControlsNavigationBar: UINavigationBar {
...
@@ -64,21 +45,15 @@ class DayControlsNavigationBar: UINavigationBar {
}
}
public
func
restoreProgress
()
{
public
func
restoreProgress
()
{
currentProgress
=
savedProgress
let
diff
=
(
savedProgress
-
currentProgress
)
*
100
showControls
(
progressValue
:
currentProgress
)
let
numerOfSteps
=
Int
((
diff
/
60
*
0.35
*
100
)
.
rounded
(
.
up
))
savedProgress
=
0
for
step
in
0
..<
numerOfSteps
{
}
showControls
(
progressValue
:
CGFloat
(
step
)
/
CGFloat
(
numerOfSteps
))
//Private
private
func
findAndSetupContentView
()
{
subviews
.
forEach
{
if
String
(
cString
:
class_getName
(
$0
.
classForCoder
))
==
"_UINavigationBarContentView"
{
self
.
contentView
=
$0
self
.
contentView
?
.
clipsToBounds
=
false
self
.
contentView
?
.
addSubview
(
customView
)
self
.
customView
.
alpha
=
0
}
}
}
// currentProgress = savedProgress
// showControls(progressValue: currentProgress)
// savedProgress = 0
}
}
}
}
1Weather/UI/Helpers/DayControlsNavigatoinController.swift
View file @
94c6f356
...
@@ -29,10 +29,6 @@ class DayControlsNavigatoinController: UINavigationController {
...
@@ -29,10 +29,6 @@ class DayControlsNavigatoinController: UINavigationController {
let
popViewController
=
super
.
popViewController
(
animated
:
animated
)
let
popViewController
=
super
.
popViewController
(
animated
:
animated
)
dayControllsNavBar
?
.
restoreProgress
()
dayControllsNavBar
?
.
restoreProgress
()
// transitionCoordinator?.animate(alongsideTransition: nil, completion: {[weak self] _ in
// self?.dayControllsNavBar?.restoreProgress()
// })
return
popViewController
return
popViewController
}
}
}
}
...
...
1Weather/UI/View controllers/Forecast/ForecastViewController.swift
View file @
94c6f356
...
@@ -10,6 +10,7 @@ import UIKit
...
@@ -10,6 +10,7 @@ import UIKit
class
ForecastViewController
:
UIViewController
{
class
ForecastViewController
:
UIViewController
{
//Private
//Private
private
let
cityButton
=
NavigationCityButton
()
private
let
cityButton
=
NavigationCityButton
()
private
let
daysStackView
=
UIStackView
()
private
let
tableView
=
UITableView
()
private
let
tableView
=
UITableView
()
private
let
viewModel
:
ForecastViewModel
private
let
viewModel
:
ForecastViewModel
private
var
localizationObserver
:
Any
?
private
var
localizationObserver
:
Any
?
...
@@ -31,6 +32,7 @@ class ForecastViewController: UIViewController {
...
@@ -31,6 +32,7 @@ class ForecastViewController: UIViewController {
prepareViewController
()
prepareViewController
()
prepareNavigationBar
()
prepareNavigationBar
()
prepareTableView
()
prepareTableView
()
prepareDaysStackView
()
refreshCityButton
()
refreshCityButton
()
}
}
...
@@ -48,7 +50,7 @@ class ForecastViewController: UIViewController {
...
@@ -48,7 +50,7 @@ class ForecastViewController: UIViewController {
}
}
}
}
//MAR
k
:- Prepare
//MAR
K
:- Prepare
private
extension
ForecastViewController
{
private
extension
ForecastViewController
{
func
prepareViewController
()
{
func
prepareViewController
()
{
view
.
backgroundColor
=
ThemeManager
.
currentTheme
.
baseBackgroundColor
view
.
backgroundColor
=
ThemeManager
.
currentTheme
.
baseBackgroundColor
...
@@ -80,6 +82,18 @@ private extension ForecastViewController {
...
@@ -80,6 +82,18 @@ private extension ForecastViewController {
self
.
navigationItem
.
rightBarButtonItem
=
notificationBarButton
self
.
navigationItem
.
rightBarButtonItem
=
notificationBarButton
}
}
func
prepareDaysStackView
()
{
let
dView
=
UIView
()
dView
.
backgroundColor
=
.
red
view
.
addSubview
(
dView
)
dView
.
snp
.
makeConstraints
{
(
make
)
in
make
.
left
.
right
.
equalToSuperview
()
make
.
height
.
equalTo
(
50
)
make
.
top
.
equalTo
(
self
.
view
.
safeAreaLayoutGuide
.
snp
.
top
)
}
}
func
prepareTableView
()
{
func
prepareTableView
()
{
viewModel
.
forecastCellFactory
.
registerCells
(
on
:
tableView
)
viewModel
.
forecastCellFactory
.
registerCells
(
on
:
tableView
)
tableView
.
contentInset
=
.
init
(
top
:
0
,
left
:
0
,
bottom
:
15
,
right
:
0
)
tableView
.
contentInset
=
.
init
(
top
:
0
,
left
:
0
,
bottom
:
15
,
right
:
0
)
...
...
1Weather/UI/View controllers/Today/TodayViewController.swift
View file @
94c6f356
...
@@ -15,6 +15,16 @@ class TodayViewController: UIViewController {
...
@@ -15,6 +15,16 @@ class TodayViewController: UIViewController {
private
let
tableView
=
UITableView
()
private
let
tableView
=
UITableView
()
private
var
dayControlsNavigationBar
:
DayControlsNavigationBar
?
private
var
dayControlsNavigationBar
:
DayControlsNavigationBar
?
private
var
localizationObserver
:
Any
?
private
var
localizationObserver
:
Any
?
private
func
getStatusBarHeight
()
->
CGFloat
{
var
statusBarHeight
:
CGFloat
=
0
if
#available(iOS 13.0, *)
{
let
window
=
UIApplication
.
shared
.
windows
.
filter
{
$0
.
isKeyWindow
}
.
first
statusBarHeight
=
window
?
.
windowScene
?
.
statusBarManager
?
.
statusBarFrame
.
height
??
0
}
else
{
statusBarHeight
=
UIApplication
.
shared
.
statusBarFrame
.
height
}
return
statusBarHeight
}
deinit
{
deinit
{
if
let
observer
=
localizationObserver
{
if
let
observer
=
localizationObserver
{
...
@@ -38,6 +48,16 @@ class TodayViewController: UIViewController {
...
@@ -38,6 +48,16 @@ class TodayViewController: UIViewController {
prepareNavigationBar
()
prepareNavigationBar
()
prepareTableView
()
prepareTableView
()
let
dView
=
UIView
()
dView
.
backgroundColor
=
.
red
view
.
addSubview
(
dView
)
dView
.
snp
.
makeConstraints
{
(
make
)
in
make
.
left
.
right
.
equalToSuperview
()
make
.
height
.
equalTo
(
50
)
make
.
top
.
equalToSuperview
()
.
inset
(
self
.
getStatusBarHeight
())
}
viewModel
.
delegate
=
self
viewModel
.
delegate
=
self
viewModel
.
updateWeather
()
viewModel
.
updateWeather
()
}
}
...
@@ -132,10 +152,10 @@ extension TodayViewController: UITableViewDelegate {
...
@@ -132,10 +152,10 @@ extension TodayViewController: UITableViewDelegate {
func
scrollViewDidScroll
(
_
scrollView
:
UIScrollView
)
{
func
scrollViewDidScroll
(
_
scrollView
:
UIScrollView
)
{
let
cellFrame
=
viewModel
.
todayCellFactory
.
forecastPeriodCellFrame
let
cellFrame
=
viewModel
.
todayCellFactory
.
forecastPeriodCellFrame
guard
cellFrame
.
origin
.
y
>
0
else
{
return
}
guard
cellFrame
.
origin
.
y
>
0
else
{
return
}
let
controlsHeight
=
dayControlsNavigationBar
?
.
controlsHeight
??
0
let
controlsHeight
:
CGFloat
=
5
0
let
startPointY
=
cellFrame
.
origin
.
y
+
cellFrame
.
height
-
controlsHeight
let
startPointY
=
cellFrame
.
origin
.
y
+
cellFrame
.
height
-
controlsHeight
if
scrollView
.
contentOffset
.
y
>=
startPointY
{
if
scrollView
.
contentOffset
.
y
>=
startPointY
{
let
cellOffset
=
scrollView
.
contentOffset
.
y
-
startPointY
let
cellOffset
=
scrollView
.
contentOffset
.
y
-
startPointY
let
progress
=
cellOffset
/
controlsHeight
let
progress
=
cellOffset
/
controlsHeight
...
...
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