Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
Material
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
Material
Commits
e69083a5
Commit
e69083a5
authored
Oct 26, 2017
by
Daniel Dahan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updated transition logic for motionTransitionType when using Tabs and base TransitionController.
parent
5e8497db
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
83 additions
and
55 deletions
+83
-55
Material.xcodeproj/project.pbxproj
+1
-1
Sources/Frameworks/Motion
+1
-1
Sources/iOS/Material+CALayer.swift
+1
-1
Sources/iOS/NavigationBar.swift
+21
-3
Sources/iOS/NavigationController.swift
+2
-0
Sources/iOS/TabsController.swift
+47
-49
Sources/iOS/TransitionController.swift
+10
-0
No files found.
Material.xcodeproj/project.pbxproj
View file @
e69083a5
...
@@ -712,8 +712,8 @@
...
@@ -712,8 +712,8 @@
96D88BFD1C1328D800B91418
/* LICENSE */
,
96D88BFD1C1328D800B91418
/* LICENSE */
,
96D88BFC1C1328D800B91418
/* Info.plist */
,
96D88BFC1C1328D800B91418
/* Info.plist */
,
96D88C091C1328D800B91418
/* Material.h */
,
96D88C091C1328D800B91418
/* Material.h */
,
9630ACB71F29A26B00B4217D
/* Frameworks */
,
96334EF51C8B84660083986B
/* Assets.xcassets */
,
96334EF51C8B84660083986B
/* Assets.xcassets */
,
9630ACB71F29A26B00B4217D
/* Frameworks */
,
96BCB7EC1CB40DE900C806FE
/* Font */
,
96BCB7EC1CB40DE900C806FE
/* Font */
,
96BCB7571CB40DC500C806FE
/* iOS */
,
96BCB7571CB40DC500C806FE
/* iOS */
,
);
);
...
...
Motion
@
83ab6b00
Subproject commit
b9a2576453296a86582ed43aad357456e76a7924
Subproject commit
83ab6b006233162b0fc49602e2e2754a3949ebac
Sources/iOS/Material+CALayer.swift
View file @
e69083a5
...
@@ -272,7 +272,7 @@ extension CALayer {
...
@@ -272,7 +272,7 @@ extension CALayer {
return
return
}
}
cornerRadius
=
bounds
.
size
.
width
/
2
cornerRadius
=
frame
.
size
.
width
/
2
}
}
/// Sets the shadow path.
/// Sets the shadow path.
...
...
Sources/iOS/NavigationBar.swift
View file @
e69083a5
...
@@ -176,16 +176,34 @@ internal extension NavigationBar {
...
@@ -176,16 +176,34 @@ internal extension NavigationBar {
}
}
item
.
toolbar
.
backgroundColor
=
.
clear
item
.
toolbar
.
backgroundColor
=
.
clear
item
.
titleView
=
item
.
toolbar
item
.
titleView
=
item
.
toolbar
guard
let
v
=
item
.
titleView
as?
Toolbar
else
{
guard
let
v
=
item
.
titleView
as?
Toolbar
else
{
return
return
}
}
removeConstraints
(
constraints
)
if
#available(iOS 11.0, *)
{
let
h
=
CGFloat
(
heightPreset
.
rawValue
)
frame
=
CGRect
(
x
:
frame
.
origin
.
x
,
y
:
20
,
width
:
frame
.
size
.
width
,
height
:
h
)
for
subview
in
subviews
{
var
stringFromClass
=
NSStringFromClass
(
subview
.
classForCoder
)
if
stringFromClass
.
contains
(
"BarBackground"
)
{
subview
.
frame
=
CGRect
(
x
:
0
,
y
:
0
,
width
:
frame
.
width
,
height
:
h
)
}
stringFromClass
=
NSStringFromClass
(
subview
.
classForCoder
)
if
stringFromClass
.
contains
(
"BarContent"
)
{
subview
.
frame
=
CGRect
(
x
:
subview
.
frame
.
origin
.
x
,
y
:
0
,
width
:
subview
.
frame
.
width
,
height
:
h
)
}
}
v
.
frame
=
frame
}
else
{
v
.
frame
=
bounds
}
v
.
contentEdgeInsets
=
contentEdgeInsets
v
.
contentEdgeInsets
=
contentEdgeInsets
v
.
interimSpace
=
interimSpace
v
.
interimSpace
=
interimSpace
v
.
frame
=
bounds
}
}
}
}
Sources/iOS/NavigationController.swift
View file @
e69083a5
...
@@ -120,6 +120,7 @@ open class NavigationController: UINavigationController {
...
@@ -120,6 +120,7 @@ open class NavigationController: UINavigationController {
*/
*/
open
func
prepare
()
{
open
func
prepare
()
{
isMotionEnabled
=
true
isMotionEnabled
=
true
navigationBar
.
frame
.
size
.
width
=
view
.
bounds
.
width
navigationBar
.
heightPreset
=
.
normal
navigationBar
.
heightPreset
=
.
normal
view
.
clipsToBounds
=
true
view
.
clipsToBounds
=
true
...
@@ -135,6 +136,7 @@ open class NavigationController: UINavigationController {
...
@@ -135,6 +136,7 @@ open class NavigationController: UINavigationController {
/// Calls the layout functions for the view heirarchy.
/// Calls the layout functions for the view heirarchy.
open
func
layoutSubviews
()
{
open
func
layoutSubviews
()
{
navigationBar
.
setNeedsUpdateConstraints
()
navigationBar
.
updateConstraints
()
navigationBar
.
updateConstraints
()
navigationBar
.
setNeedsLayout
()
navigationBar
.
setNeedsLayout
()
navigationBar
.
layoutIfNeeded
()
navigationBar
.
layoutIfNeeded
()
...
...
Sources/iOS/TabsController.swift
View file @
e69083a5
...
@@ -75,7 +75,7 @@ public protocol TabsControllerDelegate {
...
@@ -75,7 +75,7 @@ public protocol TabsControllerDelegate {
*/
*/
@objc
@objc
optional
func
tabsController
(
tabsController
:
TabsController
,
shouldSelect
viewController
:
UIViewController
)
->
Bool
optional
func
tabsController
(
tabsController
:
TabsController
,
shouldSelect
viewController
:
UIViewController
)
->
Bool
/**
/**
A delegation method that is executed when the view controller will transitioned to.
A delegation method that is executed when the view controller will transitioned to.
- Parameter tabsController: A TabsController.
- Parameter tabsController: A TabsController.
...
@@ -83,7 +83,7 @@ public protocol TabsControllerDelegate {
...
@@ -83,7 +83,7 @@ public protocol TabsControllerDelegate {
*/
*/
@objc
@objc
optional
func
tabsController
(
tabsController
:
TabsController
,
willSelect
viewController
:
UIViewController
)
optional
func
tabsController
(
tabsController
:
TabsController
,
willSelect
viewController
:
UIViewController
)
/**
/**
A delegation method that is executed when the view controller has been transitioned to.
A delegation method that is executed when the view controller has been transitioned to.
- Parameter tabsController: A TabsController.
- Parameter tabsController: A TabsController.
...
@@ -104,36 +104,36 @@ open class TabsController: TransitionController {
...
@@ -104,36 +104,36 @@ open class TabsController: TransitionController {
layoutSubviews
()
layoutSubviews
()
}
}
}
}
/// The TabBar used to switch between view controllers.
/// The TabBar used to switch between view controllers.
@IBInspectable
@IBInspectable
open
let
tabBar
=
TabBar
()
open
let
tabBar
=
TabBar
()
/// A delegation reference.
/// A delegation reference.
open
weak
var
delegate
:
TabsControllerDelegate
?
open
weak
var
delegate
:
TabsControllerDelegate
?
/// An Array of UIViewControllers.
/// An Array of UIViewControllers.
open
var
viewControllers
:
[
UIViewController
]
{
open
var
viewControllers
:
[
UIViewController
]
{
didSet
{
didSet
{
selectedIndex
=
0
selectedIndex
=
0
prepareSelectedIndexViewController
()
prepareSelectedIndexViewController
()
prepareTabBar
()
prepareTabBar
()
layoutSubviews
()
layoutSubviews
()
}
}
}
}
/// A reference to the currently selected view controller index value.
/// A reference to the currently selected view controller index value.
@IBInspectable
@IBInspectable
open
fileprivate
(
set
)
var
selectedIndex
=
0
open
fileprivate
(
set
)
var
selectedIndex
=
0
/// The tabBar alignment.
/// The tabBar alignment.
open
var
tabBarAlignment
=
TabBarAlignment
.
bottom
{
open
var
tabBarAlignment
=
TabBarAlignment
.
bottom
{
didSet
{
didSet
{
layoutSubviews
()
layoutSubviews
()
}
}
}
}
/**
/**
An initializer that initializes the object with a NSCoder object.
An initializer that initializes the object with a NSCoder object.
- Parameter aDecoder: A NSCoder instance.
- Parameter aDecoder: A NSCoder instance.
...
@@ -142,7 +142,7 @@ open class TabsController: TransitionController {
...
@@ -142,7 +142,7 @@ open class TabsController: TransitionController {
viewControllers
=
[]
viewControllers
=
[]
super
.
init
(
coder
:
aDecoder
)
super
.
init
(
coder
:
aDecoder
)
}
}
/**
/**
An initializer that accepts an Array of UIViewControllers.
An initializer that accepts an Array of UIViewControllers.
- Parameter viewControllers: An Array of UIViewControllers.
- Parameter viewControllers: An Array of UIViewControllers.
...
@@ -152,34 +152,34 @@ open class TabsController: TransitionController {
...
@@ -152,34 +152,34 @@ open class TabsController: TransitionController {
self
.
selectedIndex
=
selectedIndex
self
.
selectedIndex
=
selectedIndex
super
.
init
(
nibName
:
nil
,
bundle
:
nil
)
super
.
init
(
nibName
:
nil
,
bundle
:
nil
)
}
}
fileprivate
override
init
(
rootViewController
:
UIViewController
)
{
fileprivate
override
init
(
rootViewController
:
UIViewController
)
{
self
.
viewControllers
=
[]
self
.
viewControllers
=
[]
super
.
init
(
rootViewController
:
rootViewController
)
super
.
init
(
rootViewController
:
rootViewController
)
}
}
open
override
func
viewWillLayoutSubviews
()
{
open
override
func
viewWillLayoutSubviews
()
{
super
.
viewWillLayoutSubviews
()
super
.
viewWillLayoutSubviews
()
layoutSubviews
()
layoutSubviews
()
}
}
open
override
func
layoutSubviews
()
{
open
override
func
layoutSubviews
()
{
super
.
layoutSubviews
()
super
.
layoutSubviews
()
layoutTabBar
()
layoutTabBar
()
layoutContainer
()
layoutContainer
()
layoutRootViewController
()
layoutRootViewController
()
}
}
open
override
func
prepare
()
{
open
override
func
prepare
()
{
super
.
prepare
()
super
.
prepare
()
view
.
backgroundColor
=
.
white
view
.
backgroundColor
=
.
white
view
.
contentScaleFactor
=
Screen
.
scale
view
.
contentScaleFactor
=
Screen
.
scale
prepareTabBar
()
prepareTabBar
()
prepareTabItems
()
prepareTabItems
()
prepareSelectedIndexViewController
()
prepareSelectedIndexViewController
()
}
}
open
override
func
transition
(
to
viewController
:
UIViewController
,
completion
:
((
Bool
)
->
Void
)?)
{
open
override
func
transition
(
to
viewController
:
UIViewController
,
completion
:
((
Bool
)
->
Void
)?)
{
transition
(
to
:
viewController
,
isTriggeredByUserInteraction
:
false
,
completion
:
completion
)
transition
(
to
:
viewController
,
isTriggeredByUserInteraction
:
false
,
completion
:
completion
)
}
}
...
@@ -196,33 +196,30 @@ fileprivate extension TabsController {
...
@@ -196,33 +196,30 @@ fileprivate extension TabsController {
guard
let
fvcIndex
=
viewControllers
.
index
(
of
:
rootViewController
)
else
{
guard
let
fvcIndex
=
viewControllers
.
index
(
of
:
rootViewController
)
else
{
return
return
}
}
guard
let
tvcIndex
=
viewControllers
.
index
(
of
:
viewController
)
else
{
guard
let
tvcIndex
=
viewControllers
.
index
(
of
:
viewController
)
else
{
return
return
}
}
var
isAuto
=
false
switch
motionTransitionType
{
switch
viewController
.
motionModalTransitionType
{
case
.
auto
:
case
.
auto
:
isAuto
=
true
switch
viewController
.
motionTransitionType
{
viewController
.
motionModalTransitionType
=
fvcIndex
<
tvcIndex
?
.
slide
(
direction
:
.
left
)
:
.
slide
(
direction
:
.
right
)
case
.
auto
:
Motion
.
shared
.
setAnimationForNextTransition
(
fvcIndex
<
tvcIndex
?
.
slide
(
direction
:
.
left
)
:
.
slide
(
direction
:
.
right
))
default
:
break
}
default
:
break
default
:
break
}
}
if
isTriggeredByUserInteraction
{
if
isTriggeredByUserInteraction
{
delegate
?
.
tabsController
?(
tabsController
:
self
,
willSelect
:
viewController
)
delegate
?
.
tabsController
?(
tabsController
:
self
,
willSelect
:
viewController
)
}
}
super
.
transition
(
to
:
viewController
)
{
[
weak
self
,
isAuto
=
isAuto
,
viewController
=
viewController
,
completion
=
completion
]
(
isFinished
)
in
super
.
transition
(
to
:
viewController
)
{
[
weak
self
,
viewController
=
viewController
,
completion
=
completion
]
(
isFinished
)
in
guard
let
s
=
self
else
{
guard
let
s
=
self
else
{
return
return
}
}
if
isAuto
{
viewController
.
motionModalTransitionType
=
.
auto
}
completion
?(
isFinished
)
completion
?(
isFinished
)
if
isTriggeredByUserInteraction
{
if
isTriggeredByUserInteraction
{
...
@@ -237,7 +234,7 @@ fileprivate extension TabsController {
...
@@ -237,7 +234,7 @@ fileprivate extension TabsController {
func
prepareSelectedIndexViewController
()
{
func
prepareSelectedIndexViewController
()
{
rootViewController
=
viewControllers
[
selectedIndex
]
rootViewController
=
viewControllers
[
selectedIndex
]
}
}
/// Prepares the TabBar.
/// Prepares the TabBar.
func
prepareTabBar
()
{
func
prepareTabBar
()
{
tabBar
.
lineAlignment
=
.
bottom
==
tabBarAlignment
?
.
top
:
.
bottom
tabBar
.
lineAlignment
=
.
bottom
==
tabBarAlignment
?
.
top
:
.
bottom
...
@@ -245,11 +242,11 @@ fileprivate extension TabsController {
...
@@ -245,11 +242,11 @@ fileprivate extension TabsController {
tabBar
.
delegate
=
self
tabBar
.
delegate
=
self
view
.
addSubview
(
tabBar
)
view
.
addSubview
(
tabBar
)
}
}
/// Prepares the `tabBar.tabItems`.
/// Prepares the `tabBar.tabItems`.
func
prepareTabItems
()
{
func
prepareTabItems
()
{
var
tabItems
=
[
TabItem
]()
var
tabItems
=
[
TabItem
]()
for
v
in
viewControllers
{
for
v
in
viewControllers
{
// Expectation that viewDidLoad() triggers update of tab item title:
// Expectation that viewDidLoad() triggers update of tab item title:
if
#available(iOS 9.0, *)
{
if
#available(iOS 9.0, *)
{
...
@@ -259,7 +256,7 @@ fileprivate extension TabsController {
...
@@ -259,7 +256,7 @@ fileprivate extension TabsController {
}
}
tabItems
.
append
(
v
.
tabItem
)
tabItems
.
append
(
v
.
tabItem
)
}
}
tabBar
.
tabItems
=
tabItems
tabBar
.
tabItems
=
tabItems
tabBar
.
selectedTabItem
=
tabItems
[
selectedIndex
]
tabBar
.
selectedTabItem
=
tabItems
[
selectedIndex
]
}
}
...
@@ -272,30 +269,31 @@ fileprivate extension TabsController {
...
@@ -272,30 +269,31 @@ fileprivate extension TabsController {
case
.
partial
:
case
.
partial
:
let
p
=
tabBar
.
bounds
.
height
let
p
=
tabBar
.
bounds
.
height
let
y
=
view
.
bounds
.
height
-
p
let
y
=
view
.
bounds
.
height
-
p
switch
tabBarAlignment
{
switch
tabBarAlignment
{
case
.
top
:
case
.
top
:
container
.
frame
.
origin
.
y
=
p
container
.
frame
.
origin
.
y
=
p
container
.
frame
.
size
.
height
=
y
container
.
frame
.
size
.
height
=
y
case
.
bottom
:
case
.
bottom
:
container
.
frame
.
origin
.
y
=
0
container
.
frame
.
origin
.
y
=
0
container
.
frame
.
size
.
height
=
y
container
.
frame
.
size
.
height
=
y
}
}
container
.
frame
.
size
.
width
=
view
.
bounds
.
width
container
.
frame
.
size
.
width
=
view
.
bounds
.
width
case
.
full
:
case
.
full
:
container
.
frame
=
view
.
bounds
container
.
frame
=
view
.
bounds
}
}
}
}
/// Layout the tabBar.
/// Layout the tabBar.
func
layoutTabBar
()
{
func
layoutTabBar
()
{
tabBar
.
frame
.
origin
.
x
=
0
tabBar
.
frame
.
origin
.
x
=
0
tabBar
.
frame
.
origin
.
y
=
.
top
==
tabBarAlignment
?
0
:
view
.
bounds
.
height
-
tabBar
.
bounds
.
height
tabBar
.
frame
.
origin
.
y
=
.
top
==
tabBarAlignment
?
0
:
view
.
bounds
.
height
-
tabBar
.
bounds
.
height
tabBar
.
frame
.
size
.
width
=
view
.
bounds
.
width
tabBar
.
frame
.
size
.
width
=
view
.
bounds
.
width
}
}
/// Layout the rootViewController.
/// Layout the rootViewController.
func
layoutRootViewController
()
{
func
layoutRootViewController
()
{
rootViewController
.
view
.
frame
=
container
.
bounds
rootViewController
.
view
.
frame
=
container
.
bounds
...
@@ -311,19 +309,19 @@ extension TabsController {
...
@@ -311,19 +309,19 @@ extension TabsController {
guard
index
!=
selectedIndex
else
{
guard
index
!=
selectedIndex
else
{
return
return
}
}
Motion
.
async
{
[
weak
self
]
in
Motion
.
async
{
[
weak
self
]
in
guard
let
s
=
self
else
{
guard
let
s
=
self
else
{
return
return
}
}
s
.
tabBar
.
select
(
at
:
index
)
s
.
tabBar
.
select
(
at
:
index
)
s
.
transition
(
to
:
s
.
viewControllers
[
index
],
isTriggeredByUserInteraction
:
false
)
{
[
weak
self
]
(
isFinished
)
in
s
.
transition
(
to
:
s
.
viewControllers
[
index
],
isTriggeredByUserInteraction
:
false
)
{
[
weak
self
]
(
isFinished
)
in
guard
isFinished
else
{
guard
isFinished
else
{
return
return
}
}
self
?
.
selectedIndex
=
index
self
?
.
selectedIndex
=
index
}
}
}
}
...
@@ -336,24 +334,24 @@ extension TabsController: _TabBarDelegate {
...
@@ -336,24 +334,24 @@ extension TabsController: _TabBarDelegate {
guard
!
(
false
==
tabBar
.
delegate
?
.
tabBar
?(
tabBar
:
tabBar
,
shouldSelect
:
tabItem
))
else
{
guard
!
(
false
==
tabBar
.
delegate
?
.
tabBar
?(
tabBar
:
tabBar
,
shouldSelect
:
tabItem
))
else
{
return
return
}
}
guard
let
i
=
tabBar
.
tabItems
.
index
(
of
:
tabItem
)
else
{
guard
let
i
=
tabBar
.
tabItems
.
index
(
of
:
tabItem
)
else
{
return
return
}
}
guard
i
!=
selectedIndex
else
{
guard
i
!=
selectedIndex
else
{
return
return
}
}
guard
!
(
false
==
delegate
?
.
tabsController
?(
tabsController
:
self
,
shouldSelect
:
viewControllers
[
i
]))
else
{
guard
!
(
false
==
delegate
?
.
tabsController
?(
tabsController
:
self
,
shouldSelect
:
viewControllers
[
i
]))
else
{
return
return
}
}
transition
(
to
:
viewControllers
[
i
],
isTriggeredByUserInteraction
:
true
)
{
[
weak
self
]
(
isFinished
)
in
transition
(
to
:
viewControllers
[
i
],
isTriggeredByUserInteraction
:
true
)
{
[
weak
self
]
(
isFinished
)
in
guard
isFinished
else
{
guard
isFinished
else
{
return
return
}
}
self
?
.
selectedIndex
=
i
self
?
.
selectedIndex
=
i
}
}
}
}
...
...
Sources/iOS/TransitionController.swift
View file @
e69083a5
...
@@ -148,6 +148,16 @@ open class TransitionController: UIViewController {
...
@@ -148,6 +148,16 @@ open class TransitionController: UIViewController {
open
func
transition
(
to
viewController
:
UIViewController
,
completion
:
((
Bool
)
->
Void
)?
=
nil
)
{
open
func
transition
(
to
viewController
:
UIViewController
,
completion
:
((
Bool
)
->
Void
)?
=
nil
)
{
prepare
(
viewController
:
viewController
,
in
:
container
)
prepare
(
viewController
:
viewController
,
in
:
container
)
switch
motionTransitionType
{
case
.
auto
:
break
default
:
switch
viewController
.
motionTransitionType
{
case
.
auto
:
viewController
.
motionTransitionType
=
motionTransitionType
default
:
break
}
}
view
.
isUserInteractionEnabled
=
false
view
.
isUserInteractionEnabled
=
false
Motion
.
shared
.
transition
(
from
:
rootViewController
,
to
:
viewController
,
in
:
container
)
{
[
weak
self
,
viewController
=
viewController
,
completion
=
completion
]
(
isFinished
)
in
Motion
.
shared
.
transition
(
from
:
rootViewController
,
to
:
viewController
,
in
:
container
)
{
[
weak
self
,
viewController
=
viewController
,
completion
=
completion
]
(
isFinished
)
in
guard
let
s
=
self
else
{
guard
let
s
=
self
else
{
...
...
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