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
89598404
Commit
89598404
authored
Mar 13, 2021
by
Dmitriy Stepanets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added controls to navigation bar
parent
9254d554
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
160 additions
and
7 deletions
+160
-7
1Weather.xcodeproj/project.pbxproj
+4
-0
1Weather.xcodeproj/xcuserdata/dstepanets.xcuserdatad/xcschemes/xcschememanagement.plist
+1
-1
1Weather.xcworkspace/xcuserdata/dstepanets.xcuserdatad/UserInterfaceState.xcuserstate
+0
-0
1Weather/Coordinators/TodayCoordinator.swift
+1
-1
1Weather/UI/Helpers/DayControlsNavigationBar.swift
+78
-0
1Weather/UI/Helpers/DayControlsNavigatoinBar.swift
+48
-0
1Weather/UI/View controllers/Today/Cells/TodayCellFactory.swift
+2
-0
1Weather/UI/View controllers/Today/TodayViewController.swift
+21
-0
Pods/Pods.xcodeproj/xcuserdata/dstepanets.xcuserdatad/xcschemes/xcschememanagement.plist
+5
-5
No files found.
1Weather.xcodeproj/project.pbxproj
View file @
89598404
...
...
@@ -38,6 +38,7 @@
CD82300325D69DE400A05501
/* CityConditionsCell.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
CD82300225D69DE400A05501
/* CityConditionsCell.swift */
;
};
CD82300725D6A73F00A05501
/* CityConditionButton.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
CD82300625D6A73E00A05501
/* CityConditionButton.swift */
;
};
CD82300A25D6B2AF00A05501
/* AppTabBarController.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
CD82300925D6B2AF00A05501
/* AppTabBarController.swift */
;
};
CD8343B925FBEFF60003101F
/* DayControlsNavigationBar.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
CD8343B825FBEFF60003101F
/* DayControlsNavigationBar.swift */
;
};
CD86245E25E646350097F3FB
/* SunUvView.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
CD86245D25E646350097F3FB
/* SunUvView.swift */
;
};
CD86246125E662BC0097F3FB
/* SunUvLineView.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
CD86246025E662BC0097F3FB
/* SunUvLineView.swift */
;
};
CD86246525E66E8A0097F3FB
/* CityPrecipCell.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
CD86246425E66E8A0097F3FB
/* CityPrecipCell.swift */
;
};
...
...
@@ -129,6 +130,7 @@
CD82300225D69DE400A05501
/* CityConditionsCell.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
CityConditionsCell.swift
;
sourceTree
=
"<group>"
;
};
CD82300625D6A73E00A05501
/* CityConditionButton.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
CityConditionButton.swift
;
sourceTree
=
"<group>"
;
};
CD82300925D6B2AF00A05501
/* AppTabBarController.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
AppTabBarController.swift
;
sourceTree
=
"<group>"
;
};
CD8343B825FBEFF60003101F
/* DayControlsNavigationBar.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
DayControlsNavigationBar.swift
;
sourceTree
=
"<group>"
;
};
CD86245D25E646350097F3FB
/* SunUvView.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
SunUvView.swift
;
sourceTree
=
"<group>"
;
};
CD86246025E662BC0097F3FB
/* SunUvLineView.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
SunUvLineView.swift
;
sourceTree
=
"<group>"
;
};
CD86246425E66E8A0097F3FB
/* CityPrecipCell.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
CityPrecipCell.swift
;
sourceTree
=
"<group>"
;
};
...
...
@@ -458,6 +460,7 @@
CDD0F1ED25725BCF00CF5017
/* ThemeManager.swift */
,
CD9B6B1025DBC723001D9B80
/* CubicCurveAlgorithm.swift */
,
CD86246B25E6826A0097F3FB
/* InnerShadowLayer.swift */
,
CD8343B825FBEFF60003101F
/* DayControlsNavigationBar.swift */
,
);
path
=
Helpers
;
sourceTree
=
"<group>"
;
...
...
@@ -735,6 +738,7 @@
CDC6126625E9085600188DA7
/* GraphLine.swift in Sources */
,
CD86246525E66E8A0097F3FB
/* CityPrecipCell.swift in Sources */
,
CD80917B2578E4A8003541A4
/* UIViewController+Alert.swift in Sources */
,
CD8343B925FBEFF60003101F
/* DayControlsNavigationBar.swift in Sources */
,
CEDE4F0F25EFA3B4007457E9
/* UpdatableModelObjectInTime.swift in Sources */
,
CD3F6E6925FA59D4002DB99B
/* ForecastDetailPeriodButton.swift in Sources */
,
CD17C5F625D15B4400EE884E
/* TodayViewController.swift in Sources */
,
...
...
1Weather.xcodeproj/xcuserdata/dstepanets.xcuserdatad/xcschemes/xcschememanagement.plist
View file @
89598404
...
...
@@ -7,7 +7,7 @@
<
k
e
y
>
1Weather.xcscheme_
^#
shared
#^
_
<
/k
e
y
>
<
d
i
c
t
>
<
k
e
y
>
orderHint
<
/k
e
y
>
<
int
e
g
e
r
>
5
<
/int
e
g
e
r
>
<
int
e
g
e
r
>
3
<
/int
e
g
e
r
>
<
/
d
i
c
t
>
<
k
e
y
>
PG
(
Playground
)
1.xcscheme
<
/k
e
y
>
<
d
i
c
t
>
...
...
1Weather.xcworkspace/xcuserdata/dstepanets.xcuserdatad/UserInterfaceState.xcuserstate
View file @
89598404
No preview for this file type
1Weather/Coordinators/TodayCoordinator.swift
View file @
89598404
...
...
@@ -10,7 +10,7 @@ import UIKit
class
TodayCoordinator
:
Coordinator
{
//Private
private
let
todayViewModel
=
TodayViewModel
(
locationManager
:
LocationManager
.
shared
)
// TODO: get rid of singleton maybe?
private
let
navigationController
=
UINavigationController
(
n
ibName
:
nil
,
bundle
:
nil
)
private
let
navigationController
=
UINavigationController
(
n
avigationBarClass
:
DayControlsNavigationBar
.
self
,
toolbarClass
:
nil
)
private
var
tabBarController
:
UITabBarController
?
//Public
...
...
1Weather/UI/Helpers/DayControlsNavigationBar.swift
0 → 100644
View file @
89598404
//
// DayControlsNavigatoinBar.swift
// 1Weather
//
// Created by Dmitry Stepanets on 12.03.2021.
//
import
UIKit
class
DayControlsNavigationBar
:
UINavigationBar
{
private
let
customView
=
UIView
()
private
var
contentView
:
UIView
?
var
controlsHeight
:
CGFloat
=
0
override
init
(
frame
:
CGRect
)
{
super
.
init
(
frame
:
frame
)
customView
.
backgroundColor
=
.
lightGray
}
override
func
layoutSubviews
()
{
super
.
layoutSubviews
()
if
contentView
==
nil
{
self
.
findAndSetupContentView
()
}
// guard let contentView = self.contentView else {
// self.findAndSetupContentView()
// return
// }
// contentView.frame.origin.y = -30
// customView.frame = .init(x: contentView.frame.origin.x,
// y: contentView.bounds.height,
// width: contentView.bounds.width,
// height: contentView.bounds.height)
}
required
init
?(
coder
:
NSCoder
)
{
fatalError
(
"init(coder:) has not been implemented"
)
}
//Public
public
func
showControls
(
progressValue
:
CGFloat
)
{
var
progress
=
max
(
progressValue
,
0
)
progress
=
min
(
progress
,
1
)
self
.
contentView
?
.
frame
.
origin
.
y
=
-
controlsHeight
*
progress
self
.
contentView
?
.
subviews
.
forEach
{
if
$0
!=
customView
{
$0
.
alpha
=
1
-
progress
}
}
self
.
customView
.
frame
.
origin
.
y
=
contentView
!.
frame
.
origin
.
y
+
self
.
customView
.
frame
.
height
+
controlsHeight
*
progress
self
.
customView
.
alpha
=
progress
}
//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
self
.
customView
.
frame
=
.
init
(
x
:
contentView
!.
frame
.
origin
.
x
,
y
:
contentView
!.
frame
.
height
,
width
:
contentView
!.
frame
.
width
,
height
:
contentView
!.
frame
.
height
)
self
.
controlsHeight
=
self
.
customView
.
frame
.
height
}
}
}
}
1Weather/UI/Helpers/DayControlsNavigatoinBar.swift
0 → 100644
View file @
89598404
//
// DayControlsNavigatoinBar.swift
// 1Weather
//
// Created by Dmitry Stepanets on 12.03.2021.
//
import
UIKit
class
DayControlsNavigationBar
:
UINavigationBar
{
private
let
customView
=
UIView
()
private
var
contentView
:
UIView
?
override
init
(
frame
:
CGRect
)
{
super
.
init
(
frame
:
frame
)
customView
.
backgroundColor
=
.
red
}
override
func
layoutSubviews
()
{
super
.
layoutSubviews
()
guard
let
contentView
=
self
.
contentView
else
{
self
.
findAndSetupContentView
()
return
}
contentView
.
frame
.
origin
.
y
=
-
30
customView
.
frame
=
.
init
(
x
:
contentView
.
frame
.
origin
.
x
,
y
:
contentView
.
bounds
.
height
,
width
:
contentView
.
bounds
.
width
,
height
:
contentView
.
bounds
.
height
)
}
required
init
?(
coder
:
NSCoder
)
{
fatalError
(
"init(coder:) has not been implemented"
)
}
private
func
findAndSetupContentView
()
{
subviews
.
forEach
{
if
String
(
cString
:
class_getName
(
$0
.
classForCoder
))
==
"_UINavigationBarContentView"
{
self
.
contentView
=
$0
self
.
contentView
?
.
clipsToBounds
=
true
self
.
contentView
?
.
addSubview
(
customView
)
}
}
}
}
1Weather/UI/View controllers/Today/Cells/TodayCellFactory.swift
View file @
89598404
...
...
@@ -20,6 +20,7 @@ private enum TodayCellType:Int, CaseIterable {
class
TodayCellFactory
{
public
var
onGetLocation
:(()
->
Location
?)?
public
var
forecastPeriodCellFrame
:
CGRect
=
.
zero
public
var
numberOfRows
:
Int
{
return
TodayCellType
.
allCases
.
count
}
...
...
@@ -59,6 +60,7 @@ class TodayCellFactory {
return
cell
case
.
forecastPeriod
:
let
cell
=
dequeueReusableCell
(
type
:
CityForecastTimePeriodCell
.
self
,
tableView
:
tableView
,
indexPath
:
indexPath
)
forecastPeriodCellFrame
=
cell
.
frame
cell
.
configure
(
with
:
loc
)
return
cell
case
.
precipitation
:
...
...
1Weather/UI/View controllers/Today/TodayViewController.swift
View file @
89598404
...
...
@@ -13,6 +13,7 @@ class TodayViewController: UIViewController {
private
let
cityButton
=
NavigationCityButton
()
private
let
viewModel
:
TodayViewModel
private
let
tableView
=
UITableView
()
private
var
dayControlsNavigationBar
:
DayControlsNavigationBar
?
private
var
localizationObserver
:
Any
?
deinit
{
...
...
@@ -68,6 +69,8 @@ private extension TodayViewController {
}
func
prepareNavigationBar
()
{
self
.
dayControlsNavigationBar
=
self
.
navigationController
?
.
navigationBar
as?
DayControlsNavigationBar
//City button
cityButton
.
isHidden
=
true
cityButton
.
addTarget
(
self
,
action
:
#selector(
handleCityButton
)
,
for
:
.
touchUpInside
)
...
...
@@ -120,6 +123,24 @@ extension TodayViewController: UITableViewDataSource {
//MARK:- UITableView Delegate
extension
TodayViewController
:
UITableViewDelegate
{
func
scrollViewDidScroll
(
_
scrollView
:
UIScrollView
)
{
let
cellFrame
=
viewModel
.
todayCellFactory
.
forecastPeriodCellFrame
guard
cellFrame
.
origin
.
y
>
0
else
{
return
}
let
controlsHeight
=
dayControlsNavigationBar
?
.
controlsHeight
??
0
let
startPointY
=
cellFrame
.
origin
.
y
+
cellFrame
.
height
-
controlsHeight
if
scrollView
.
contentOffset
.
y
>=
startPointY
{
let
cellOffset
=
scrollView
.
contentOffset
.
y
-
startPointY
let
progress
=
cellOffset
/
controlsHeight
dayControlsNavigationBar
?
.
showControls
(
progressValue
:
progress
)
print
(
"progress:
\(
progress
)
"
)
}
else
{
dayControlsNavigationBar
?
.
showControls
(
progressValue
:
0
)
}
}
func
tableView
(
_
tableView
:
UITableView
,
willDisplay
cell
:
UITableViewCell
,
forRowAt
indexPath
:
IndexPath
)
{
viewModel
.
todayCellFactory
.
willDisplay
(
cell
:
cell
)
}
...
...
Pods/Pods.xcodeproj/xcuserdata/dstepanets.xcuserdatad/xcschemes/xcschememanagement.plist
View file @
89598404
...
...
@@ -21,7 +21,7 @@
<
k
e
y
>
Cirque.xcscheme_
^#
shared
#^
_
<
/k
e
y
>
<
d
i
c
t
>
<
k
e
y
>
orderHint
<
/k
e
y
>
<
int
e
g
e
r
>
6
<
/int
e
g
e
r
>
<
int
e
g
e
r
>
4
<
/int
e
g
e
r
>
<
/
d
i
c
t
>
<
k
e
y
>
Localize-Swift.xcscheme
<
/k
e
y
>
<
d
i
c
t
>
...
...
@@ -33,26 +33,26 @@
<
k
e
y
>
Localize-Swift.xcscheme_
^#
shared
#^
_
<
/k
e
y
>
<
d
i
c
t
>
<
k
e
y
>
orderHint
<
/k
e
y
>
<
int
e
g
e
r
>
3
<
/int
e
g
e
r
>
<
int
e
g
e
r
>
6
<
/int
e
g
e
r
>
<
/
d
i
c
t
>
<
k
e
y
>
Pods-1Weather.xcscheme
<
/k
e
y
>
<
d
i
c
t
>
<
k
e
y
>
isShown
<
/k
e
y
>
<
fa
ls
e
/
>
<
k
e
y
>
orderHint
<
/k
e
y
>
<
int
e
g
e
r
>
2
<
/int
e
g
e
r
>
<
int
e
g
e
r
>
1
<
/int
e
g
e
r
>
<
/
d
i
c
t
>
<
k
e
y
>
SnapKit.xcscheme
<
/k
e
y
>
<
d
i
c
t
>
<
k
e
y
>
isShown
<
/k
e
y
>
<
fa
ls
e
/
>
<
k
e
y
>
orderHint
<
/k
e
y
>
<
int
e
g
e
r
>
3
<
/int
e
g
e
r
>
<
int
e
g
e
r
>
2
<
/int
e
g
e
r
>
<
/
d
i
c
t
>
<
k
e
y
>
XMLCoder.xcscheme_
^#
shared
#^
_
<
/k
e
y
>
<
d
i
c
t
>
<
k
e
y
>
orderHint
<
/k
e
y
>
<
int
e
g
e
r
>
6
<
/int
e
g
e
r
>
<
int
e
g
e
r
>
5
<
/int
e
g
e
r
>
<
/
d
i
c
t
>
<
/
d
i
c
t
>
<
k
e
y
>
SuppressBuildableAutocreation
<
/k
e
y
>
...
...
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