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
5f7e1893
Commit
5f7e1893
authored
Mar 15, 2021
by
Dmitriy Stepanets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added custom navigation bar
parent
89598404
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
96 additions
and
24 deletions
+96
-24
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
+24
-18
1Weather/UI/Helpers/DayControlsNavigatoinController.swift
+56
-0
1Weather/UI/View controllers/Today/TodayViewController.swift
+7
-1
Pods/Pods.xcodeproj/xcuserdata/dstepanets.xcuserdatad/xcschemes/xcschememanagement.plist
+3
-3
No files found.
1Weather.xcodeproj/project.pbxproj
View file @
5f7e1893
...
...
@@ -68,6 +68,7 @@
CDE18DCD25D1666700C80ED9
/* ForecastCoordinator.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
CDE18DCC25D1666700C80ED9
/* ForecastCoordinator.swift */
;
};
CDE18DD125D166F900C80ED9
/* ForecastViewController.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
CDE18DD025D166F900C80ED9
/* ForecastViewController.swift */
;
};
CDE18DD825D16CB200C80ED9
/* NavigationCityButton.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
CDE18DD725D16CB200C80ED9
/* NavigationCityButton.swift */
;
};
CDEABC5925FEA13E00B0F6C1
/* DayControlsNavigatoinController.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
CDEABC5825FEA13E00B0F6C1
/* DayControlsNavigatoinController.swift */
;
};
CDEE8AD725DA882200C289DE
/* ForecastPeriodButton.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
CDEE8AD625DA882200C289DE
/* ForecastPeriodButton.swift */
;
};
CE578FD325F7E89400E8B85D
/* DayTimeWeather.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
CE578FD225F7E89400E8B85D
/* DayTimeWeather.swift */
;
};
CE9D181625ECB8370028D9D7
/* MulticastDelegate.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
CE9D181525ECB8370028D9D7
/* MulticastDelegate.swift */
;
};
...
...
@@ -160,6 +161,7 @@
CDE18DCC25D1666700C80ED9
/* ForecastCoordinator.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
ForecastCoordinator.swift
;
sourceTree
=
"<group>"
;
};
CDE18DD025D166F900C80ED9
/* ForecastViewController.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
ForecastViewController.swift
;
sourceTree
=
"<group>"
;
};
CDE18DD725D16CB200C80ED9
/* NavigationCityButton.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
NavigationCityButton.swift
;
sourceTree
=
"<group>"
;
};
CDEABC5825FEA13E00B0F6C1
/* DayControlsNavigatoinController.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
DayControlsNavigatoinController.swift
;
sourceTree
=
"<group>"
;
};
CDEE8AD625DA882200C289DE
/* ForecastPeriodButton.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
ForecastPeriodButton.swift
;
sourceTree
=
"<group>"
;
};
CE578FD225F7E89400E8B85D
/* DayTimeWeather.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
DayTimeWeather.swift
;
sourceTree
=
"<group>"
;
};
CE9D181525ECB8370028D9D7
/* MulticastDelegate.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
MulticastDelegate.swift
;
sourceTree
=
"<group>"
;
};
...
...
@@ -461,6 +463,7 @@
CD9B6B1025DBC723001D9B80
/* CubicCurveAlgorithm.swift */
,
CD86246B25E6826A0097F3FB
/* InnerShadowLayer.swift */
,
CD8343B825FBEFF60003101F
/* DayControlsNavigationBar.swift */
,
CDEABC5825FEA13E00B0F6C1
/* DayControlsNavigatoinController.swift */
,
);
path
=
Helpers
;
sourceTree
=
"<group>"
;
...
...
@@ -698,6 +701,7 @@
CD9B6B1425DBCDE2001D9B80
/* GraphView.swift in Sources */
,
CD39F2EE25DE858D009FE398
/* NotificationName+Localization.swift in Sources */
,
CEAFF08F25DFC6ED00DF4EBF
/* HourlyWeather.swift in Sources */
,
CDEABC5925FEA13E00B0F6C1
/* DayControlsNavigatoinController.swift in Sources */
,
CD71709025FA317700A63C27
/* ForecastTimePeriodView.swift in Sources */
,
CDE18DD825D16CB200C80ED9
/* NavigationCityButton.swift in Sources */
,
CD17C60225D15C8500EE884E
/* CoordinatorProtocol.swift in Sources */
,
...
...
1Weather.xcodeproj/xcuserdata/dstepanets.xcuserdatad/xcschemes/xcschememanagement.plist
View file @
5f7e1893
...
...
@@ -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
>
3
<
/int
e
g
e
r
>
<
int
e
g
e
r
>
6
<
/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 @
5f7e1893
No preview for this file type
1Weather/Coordinators/TodayCoordinator.swift
View file @
5f7e1893
...
...
@@ -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
(
navigationBarClass
:
DayControlsNavigationBar
.
self
,
toolbarClass
:
nil
)
private
let
navigationController
=
DayControlsNavigatoinController
(
)
private
var
tabBarController
:
UITabBarController
?
//Public
...
...
1Weather/UI/Helpers/DayControlsNavigationBar.swift
View file @
5f7e1893
...
...
@@ -10,6 +10,8 @@ import UIKit
class
DayControlsNavigationBar
:
UINavigationBar
{
private
let
customView
=
UIView
()
private
var
contentView
:
UIView
?
private
var
currentProgress
:
CGFloat
=
0
private
var
savedProgress
:
CGFloat
=
0
var
controlsHeight
:
CGFloat
=
0
override
init
(
frame
:
CGRect
)
{
...
...
@@ -21,30 +23,31 @@ class DayControlsNavigationBar: UINavigationBar {
override
func
layoutSubviews
()
{
super
.
layoutSubviews
()
if
contentView
==
nil
{
guard
let
contentView
=
self
.
contentView
else
{
self
.
findAndSetupContentView
()
return
}
// guard let contentView = self.contentView else {
// self.findAndSetupContentView()
// return
// }
print
(
"Layout subviews"
)
let
targetHeight
=
contentView
.
frame
.
height
*
2
self
.
contentView
?
.
frame
.
size
.
height
=
targetHeight
// 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)
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
)
{
fatalError
(
"init(coder:) has not been implemented"
)
}
//Public
//Public
public
func
showControls
(
progressValue
:
CGFloat
)
{
var
progress
=
max
(
progressValue
,
0
)
progress
=
min
(
progress
,
1
)
self
.
currentProgress
=
progress
self
.
contentView
?
.
frame
.
origin
.
y
=
-
controlsHeight
*
progress
self
.
contentView
?
.
subviews
.
forEach
{
...
...
@@ -53,10 +56,19 @@ class DayControlsNavigationBar: UINavigationBar {
}
}
self
.
customView
.
frame
.
origin
.
y
=
contentView
!.
frame
.
origin
.
y
+
self
.
customView
.
frame
.
height
+
controlsHeight
*
progress
self
.
customView
.
alpha
=
progress
}
public
func
saveProgress
()
{
savedProgress
=
currentProgress
}
public
func
restoreProgress
()
{
currentProgress
=
savedProgress
showControls
(
progressValue
:
currentProgress
)
savedProgress
=
0
}
//Private
private
func
findAndSetupContentView
()
{
subviews
.
forEach
{
...
...
@@ -66,12 +78,6 @@ class DayControlsNavigationBar: UINavigationBar {
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/DayControlsNavigatoinController.swift
0 → 100644
View file @
5f7e1893
//
// DayControlsNavigatoinController.swift
// 1Weather
//
// Created by Dmitry Stepanets on 15.03.2021.
//
import
UIKit
class
DayControlsNavigatoinController
:
UINavigationController
{
private
var
dayControllsNavBar
:
DayControlsNavigationBar
?
{
return
self
.
navigationBar
as?
DayControlsNavigationBar
}
init
()
{
super
.
init
(
navigationBarClass
:
DayControlsNavigationBar
.
self
,
toolbarClass
:
nil
)
delegate
=
self
}
required
init
?(
coder
aDecoder
:
NSCoder
)
{
fatalError
(
"init(coder:) has not been implemented"
)
}
override
func
viewDidLoad
()
{
super
.
viewDidLoad
()
}
override
func
popViewController
(
animated
:
Bool
)
->
UIViewController
?
{
let
popViewController
=
super
.
popViewController
(
animated
:
animated
)
dayControllsNavBar
?
.
restoreProgress
()
// transitionCoordinator?.animate(alongsideTransition: nil, completion: {[weak self] _ in
// self?.dayControllsNavBar?.restoreProgress()
// })
return
popViewController
}
}
extension
DayControlsNavigatoinController
:
UINavigationControllerDelegate
{
func
navigationController
(
_
navigationController
:
UINavigationController
,
didShow
viewController
:
UIViewController
,
animated
:
Bool
)
{
// if viewController === viewControllers.first {
// self.dayControllsNavBar?.restoreProgress()
// }
}
func
navigationController
(
_
navigationController
:
UINavigationController
,
willShow
viewController
:
UIViewController
,
animated
:
Bool
)
{
if
viewController
!=
self
.
viewControllers
.
first
{
self
.
dayControllsNavBar
?
.
saveProgress
()
self
.
dayControllsNavBar
?
.
showControls
(
progressValue
:
0
)
}
}
}
1Weather/UI/View controllers/Today/TodayViewController.swift
View file @
5f7e1893
...
...
@@ -41,7 +41,7 @@ class TodayViewController: UIViewController {
viewModel
.
delegate
=
self
viewModel
.
updateWeather
()
}
override
func
viewWillTransition
(
to
size
:
CGSize
,
with
coordinator
:
UIViewControllerTransitionCoordinator
)
{
super
.
viewWillTransition
(
to
:
size
,
with
:
coordinator
)
...
...
@@ -123,6 +123,12 @@ extension TodayViewController: UITableViewDataSource {
//MARK:- UITableView Delegate
extension
TodayViewController
:
UITableViewDelegate
{
func
tableView
(
_
tableView
:
UITableView
,
didSelectRowAt
indexPath
:
IndexPath
)
{
let
vc
=
UIViewController
()
vc
.
view
.
backgroundColor
=
.
red
navigationController
?
.
pushViewController
(
vc
,
animated
:
true
)
}
func
scrollViewDidScroll
(
_
scrollView
:
UIScrollView
)
{
let
cellFrame
=
viewModel
.
todayCellFactory
.
forecastPeriodCellFrame
guard
cellFrame
.
origin
.
y
>
0
else
{
return
}
...
...
Pods/Pods.xcodeproj/xcuserdata/dstepanets.xcuserdatad/xcschemes/xcschememanagement.plist
View file @
5f7e1893
...
...
@@ -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
>
4
<
/int
e
g
e
r
>
<
int
e
g
e
r
>
5
<
/int
e
g
e
r
>
<
/
d
i
c
t
>
<
k
e
y
>
Localize-Swift.xcscheme
<
/k
e
y
>
<
d
i
c
t
>
...
...
@@ -33,7 +33,7 @@
<
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
>
6
<
/int
e
g
e
r
>
<
int
e
g
e
r
>
4
<
/int
e
g
e
r
>
<
/
d
i
c
t
>
<
k
e
y
>
Pods-1Weather.xcscheme
<
/k
e
y
>
<
d
i
c
t
>
...
...
@@ -52,7 +52,7 @@
<
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
>
5
<
/int
e
g
e
r
>
<
int
e
g
e
r
>
3
<
/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