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
a6308b53
Commit
a6308b53
authored
Aug 18, 2016
by
Daniel Dahan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
development: updated NavigationItem internals
parent
33b548eb
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
49 additions
and
72 deletions
+49
-72
Sources/iOS/ControlView.swift
+1
-1
Sources/iOS/Grid.swift
+1
-0
Sources/iOS/Material+CALayer.swift
+11
-11
Sources/iOS/Material+UIView.swift
+2
-24
Sources/iOS/NavigationBar.swift
+7
-9
Sources/iOS/NavigationItem.swift
+26
-26
Sources/iOS/RootController.swift
+1
-1
No files found.
Sources/iOS/ControlView.swift
View file @
a6308b53
...
...
@@ -167,7 +167,7 @@ open class ControlView: View {
let
g
=
Int
(
width
/
gridFactor
)
let
columns
=
g
+
1
grid
.
views
=
[]
grid
.
views
.
removeAll
()
grid
.
axis
.
columns
=
columns
contentView
.
grid
.
columns
=
columns
...
...
Sources/iOS/Grid.swift
View file @
a6308b53
...
...
@@ -200,6 +200,7 @@ public class Grid {
var
n
:
Int
=
0
for
i
in
0
..<
views
.
count
{
print
(
i
,
views
.
count
,
views
)
let
child
=
views
[
i
]
if
let
parent
=
context
{
...
...
Sources/iOS/Material+CALayer.swift
View file @
a6308b53
...
...
@@ -105,7 +105,7 @@ private var MaterialLayerKey: UInt8 = 0
/// Grid extension for UIView.
extension
CALayer
{
/// MaterialLayer Reference.
internal
var
material
:
MaterialLayer
{
internal
var
material
Layer
:
MaterialLayer
{
get
{
return
AssociatedObject
(
base
:
self
,
key
:
&
MaterialLayerKey
)
{
return
MaterialLayer
(
layer
:
self
)
...
...
@@ -185,10 +185,10 @@ extension CALayer {
*/
open
var
shapePreset
:
ShapePreset
{
get
{
return
material
.
shapePreset
return
material
Layer
.
shapePreset
}
set
(
value
)
{
material
.
shapePreset
=
value
material
Layer
.
shapePreset
=
value
}
}
...
...
@@ -205,10 +205,10 @@ extension CALayer {
/// Grid reference.
open
var
depth
:
Depth
{
get
{
return
material
.
depth
return
material
Layer
.
depth
}
set
(
value
)
{
material
.
depth
=
value
material
Layer
.
depth
=
value
}
}
...
...
@@ -216,30 +216,30 @@ extension CALayer {
@IBInspectable
open
var
isShadowPathAutoSizing
:
Bool
{
get
{
return
material
.
isShadowPathAutoSizing
return
material
Layer
.
isShadowPathAutoSizing
}
set
(
value
)
{
material
.
isShadowPathAutoSizing
=
value
material
Layer
.
isShadowPathAutoSizing
=
value
}
}
/// A property that sets the cornerRadius of the backing layer.
open
var
cornerRadiusPreset
:
CornerRadiusPreset
{
get
{
return
material
.
cornerRadiusPreset
return
material
Layer
.
cornerRadiusPreset
}
set
(
value
)
{
material
.
cornerRadiusPreset
=
value
material
Layer
.
cornerRadiusPreset
=
value
}
}
/// A preset property to set the borderWidth.
open
var
borderWidthPreset
:
BorderWidthPreset
{
get
{
return
material
.
borderWidthPreset
return
material
Layer
.
borderWidthPreset
}
set
(
value
)
{
material
.
borderWidthPreset
=
value
material
Layer
.
borderWidthPreset
=
value
}
}
...
...
Sources/iOS/Material+UIView.swift
View file @
a6308b53
...
...
@@ -264,16 +264,7 @@ extension UIView {
- Parameter animation: A CAAnimation instance.
*/
open
func
animate
(
animation
:
CAAnimation
)
{
if
let
a
=
animation
as?
CABasicAnimation
{
a
.
fromValue
=
(
nil
==
layer
.
presentation
()
?
layer
:
layer
.
presentation
()
!
)
.
value
(
forKeyPath
:
a
.
keyPath
!
)
}
if
let
a
=
animation
as?
CAPropertyAnimation
{
layer
.
add
(
a
,
forKey
:
a
.
keyPath
!
)
}
else
if
let
a
=
animation
as?
CAAnimationGroup
{
layer
.
add
(
a
,
forKey
:
nil
)
}
else
if
let
a
=
animation
as?
CATransition
{
layer
.
add
(
a
,
forKey
:
kCATransition
)
}
layer
.
animate
(
animation
:
animation
)
}
/**
...
...
@@ -285,20 +276,7 @@ extension UIView {
if interrupted.
*/
open
func
animationDidStop
(
_
animation
:
CAAnimation
,
finished
flag
:
Bool
)
{
if
let
a
=
animation
as?
CAPropertyAnimation
{
if
let
b
=
a
as?
CABasicAnimation
{
if
let
v
=
b
.
toValue
{
if
let
k
=
b
.
keyPath
{
layer
.
setValue
(
v
,
forKeyPath
:
k
)
layer
.
removeAnimation
(
forKey
:
k
)
}
}
}
}
else
if
let
a
=
animation
as?
CAAnimationGroup
{
for
x
in
a
.
animations
!
{
animationDidStop
(
x
,
finished
:
true
)
}
}
layer
.
animationDidStop
(
animation
,
finished
:
flag
)
}
/// Manages the layout for the shape of the view instance.
...
...
Sources/iOS/NavigationBar.swift
View file @
a6308b53
...
...
@@ -207,14 +207,13 @@ public class NavigationBar: UINavigationBar {
contentView
.
grid
.
columns
=
columns
// leftControls
if
let
v
:
Array
<
UIControl
>
=
item
.
leftControls
{
if
let
v
=
item
.
leftControls
{
for
c
in
v
{
let
w
:
CGFloat
=
c
.
intrinsicContentSize
.
width
let
w
=
c
.
intrinsicContentSize
.
width
(
c
as?
UIButton
)?
.
contentEdgeInsets
=
UIEdgeInsets
.
zero
c
.
frame
.
size
.
height
=
titleView
.
frame
.
size
.
height
-
contentInset
.
top
-
contentInset
.
bottom
let
q
:
Int
=
Int
(
w
/
gridFactor
)
c
.
grid
.
columns
=
q
+
1
c
.
grid
.
columns
=
Int
(
w
/
gridFactor
)
+
1
contentView
.
grid
.
columns
-=
c
.
grid
.
columns
...
...
@@ -227,14 +226,13 @@ public class NavigationBar: UINavigationBar {
titleView
.
grid
.
views
.
append
(
contentView
)
// rightControls
if
let
v
:
Array
<
UIControl
>
=
item
.
rightControls
{
if
let
v
=
item
.
rightControls
{
for
c
in
v
{
let
w
:
CGFloat
=
c
.
intrinsicContentSize
.
width
let
w
=
c
.
intrinsicContentSize
.
width
(
c
as?
UIButton
)?
.
contentEdgeInsets
=
UIEdgeInsets
.
zero
c
.
frame
.
size
.
height
=
titleView
.
frame
.
size
.
height
-
contentInset
.
top
-
contentInset
.
bottom
let
q
:
Int
=
Int
(
w
/
gridFactor
)
c
.
grid
.
columns
=
q
+
1
c
.
grid
.
columns
=
Int
(
w
/
gridFactor
)
+
1
contentView
.
grid
.
columns
-=
c
.
grid
.
columns
...
...
@@ -268,7 +266,7 @@ public class NavigationBar: UINavigationBar {
item
.
titleLabel
.
sizeToFit
()
item
.
detailLabel
.
sizeToFit
()
let
diff
:
CGFloat
=
(
contentView
.
frame
.
height
-
item
.
titleLabel
.
frame
.
height
-
item
.
detailLabel
.
frame
.
height
)
/
2
let
diff
=
(
contentView
.
frame
.
height
-
item
.
titleLabel
.
frame
.
height
-
item
.
detailLabel
.
frame
.
height
)
/
2
item
.
titleLabel
.
frame
.
size
.
height
+=
diff
item
.
titleLabel
.
frame
.
size
.
width
=
contentView
.
frame
.
width
...
...
Sources/iOS/NavigationItem.swift
View file @
a6308b53
...
...
@@ -31,14 +31,14 @@
import
UIKit
/// A memory reference to the NavigationItem instance.
private
var
MaterialAssociatedObject
NavigationItemKey
:
UInt8
=
0
private
var
NavigationItemKey
:
UInt8
=
0
public
class
MaterialAssociatedObject
NavigationItem
{
public
class
NavigationItem
{
/**
A boolean indicating whether keys are being observed
on the UINavigationItem.
*/
internal
var
observed
:
Bool
=
false
internal
var
observed
=
false
/// Back Button.
public
var
backButton
:
IconButton
?
...
...
@@ -53,10 +53,10 @@ public class MaterialAssociatedObjectNavigationItem {
public
private(set)
var
detailLabel
:
UILabel
!
/// Left controls.
public
var
leftControls
:
Array
<
UIControl
>
?
public
var
leftControls
:
[
UIView
]
?
/// Right controls.
public
var
rightControls
:
Array
<
UIControl
>
?
public
var
rightControls
:
[
UIView
]
?
/// Initializer.
public
init
()
{
...
...
@@ -65,7 +65,7 @@ public class MaterialAssociatedObjectNavigationItem {
}
/// Reloads the subviews for the NavigationBar.
internal
func
reload
NavigationBar
()
{
internal
func
reload
()
{
guard
let
navigationBar
=
contentView
?
.
superview
?
.
superview
as?
NavigationBar
else
{
return
}
...
...
@@ -89,34 +89,34 @@ public class MaterialAssociatedObjectNavigationItem {
extension
UINavigationItem
{
/// NavigationItem reference.
public
internal(set)
var
item
:
MaterialAssociatedObject
NavigationItem
{
public
internal(set)
var
navigationItem
:
NavigationItem
{
get
{
return
AssociatedObject
(
base
:
self
,
key
:
&
MaterialAssociatedObject
NavigationItemKey
)
{
return
MaterialAssociatedObject
NavigationItem
()
return
AssociatedObject
(
base
:
self
,
key
:
&
NavigationItemKey
)
{
return
NavigationItem
()
}
}
set
(
value
)
{
AssociateObject
(
base
:
self
,
key
:
&
MaterialAssociatedObject
NavigationItemKey
,
value
:
value
)
AssociateObject
(
base
:
self
,
key
:
&
NavigationItemKey
,
value
:
value
)
}
}
/// Back Button.
public
internal(set)
var
backButton
:
IconButton
?
{
get
{
return
i
tem
.
backButton
return
navigationI
tem
.
backButton
}
set
(
value
)
{
i
tem
.
backButton
=
value
navigationI
tem
.
backButton
=
value
}
}
/// Content View.
public
internal(set)
var
contentView
:
UIView
?
{
get
{
return
i
tem
.
contentView
return
navigationI
tem
.
contentView
}
set
(
value
)
{
i
tem
.
contentView
=
value
navigationI
tem
.
contentView
=
value
}
}
...
...
@@ -127,13 +127,13 @@ extension UINavigationItem {
}
set
(
value
)
{
titleLabel
.
text
=
value
item
.
reloadNavigationBar
()
navigationItem
.
reload
()
}
}
/// Title Label.
public
var
titleLabel
:
UILabel
{
return
i
tem
.
titleLabel
return
navigationI
tem
.
titleLabel
}
/// Detail text.
...
...
@@ -143,32 +143,32 @@ extension UINavigationItem {
}
set
(
value
)
{
detailLabel
.
text
=
value
item
.
reloadNavigationBar
()
navigationItem
.
reload
()
}
}
/// Detail Label.
public
var
detailLabel
:
UILabel
{
return
i
tem
.
detailLabel
return
navigationI
tem
.
detailLabel
}
/// Left side UI
Control
s.
public
var
leftControls
:
Array
<
UIControl
>
?
{
/// Left side UI
View
s.
public
var
leftControls
:
[
UIView
]
?
{
get
{
return
i
tem
.
leftControls
return
navigationI
tem
.
leftControls
}
set
(
value
)
{
i
tem
.
leftControls
=
value
navigationI
tem
.
leftControls
=
value
}
}
/// Right side UI
Control
s.
public
var
rightControls
:
Array
<
UIControl
>
?
{
/// Right side UI
View
s.
public
var
rightControls
:
[
UIView
]
?
{
get
{
return
i
tem
.
rightControls
return
navigationI
tem
.
rightControls
}
set
(
value
)
{
i
tem
.
rightControls
=
value
navigationI
tem
.
rightControls
=
value
}
}
}
Sources/iOS/RootController.swift
View file @
a6308b53
...
...
@@ -62,7 +62,7 @@ open class RootController: UIViewController {
is recommended to use the transitionFromRootViewController
helper method.
*/
public
internal(set)
var
rootViewController
:
UIViewController
!
open
internal(set)
var
rootViewController
:
UIViewController
!
/**
An initializer that initializes the object with a NSCoder object.
...
...
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