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
b1ac229d
Commit
b1ac229d
authored
Oct 20, 2015
by
Daniel Dahan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
updates to internal layout for MaterialTextView
parent
e10b5f39
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
37 additions
and
78 deletions
+37
-78
Source/BasicCardView.swift
+2
-2
Source/ImageCardView.swift
+2
-2
Source/MaterialLayout.swift
+6
-29
Source/MaterialPulseCollectionViewCell.swift
+1
-1
Source/MaterialTextView.swift
+6
-28
Source/NavigationBarView.swift
+2
-2
Source/SearchBarView.swift
+1
-1
Source/SideNavigationViewController.swift
+17
-13
No files found.
Source/BasicCardView.swift
View file @
b1ac229d
...
...
@@ -300,7 +300,7 @@ public class BasicCardView : MaterialPulseView {
verticalFormat
+=
"-[titleLabel]"
views
[
"titleLabel"
]
=
v
MaterialLayout
.
alignToParentHorizontally
WithInsets
(
self
,
child
:
v
,
left
:
contentInsetsRef
.
left
+
titleLabelInsetsRef
.
left
,
right
:
contentInsetsRef
.
right
+
titleLabelInsetsRef
.
right
)
MaterialLayout
.
alignToParentHorizontally
(
self
,
child
:
v
,
left
:
contentInsetsRef
.
left
+
titleLabelInsetsRef
.
left
,
right
:
contentInsetsRef
.
right
+
titleLabelInsetsRef
.
right
)
}
// detail
...
...
@@ -317,7 +317,7 @@ public class BasicCardView : MaterialPulseView {
verticalFormat
+=
"-[detailLabel]"
views
[
"detailLabel"
]
=
v
MaterialLayout
.
alignToParentHorizontally
WithInsets
(
self
,
child
:
v
,
left
:
contentInsetsRef
.
left
+
detailLabelInsetsRef
.
left
,
right
:
contentInsetsRef
.
right
+
detailLabelInsetsRef
.
right
)
MaterialLayout
.
alignToParentHorizontally
(
self
,
child
:
v
,
left
:
contentInsetsRef
.
left
+
detailLabelInsetsRef
.
left
,
right
:
contentInsetsRef
.
right
+
detailLabelInsetsRef
.
right
)
}
// leftButtons
...
...
Source/ImageCardView.swift
View file @
b1ac229d
...
...
@@ -400,7 +400,7 @@ public class ImageCardView : MaterialPulseView {
}
else
{
MaterialLayout
.
alignFromTop
(
self
,
child
:
v
,
top
:
contentInsetsRef
.
top
+
titleLabelInsetsRef
.
top
)
}
MaterialLayout
.
alignToParentHorizontally
WithInsets
(
self
,
child
:
v
,
left
:
contentInsetsRef
.
left
+
titleLabelInsetsRef
.
left
,
right
:
contentInsetsRef
.
right
+
titleLabelInsetsRef
.
right
)
MaterialLayout
.
alignToParentHorizontally
(
self
,
child
:
v
,
left
:
contentInsetsRef
.
left
+
titleLabelInsetsRef
.
left
,
right
:
contentInsetsRef
.
right
+
titleLabelInsetsRef
.
right
)
}
// detail
...
...
@@ -417,7 +417,7 @@ public class ImageCardView : MaterialPulseView {
verticalFormat
+=
"-[detailLabel]"
views
[
"detailLabel"
]
=
v
MaterialLayout
.
alignToParentHorizontally
WithInsets
(
self
,
child
:
v
,
left
:
contentInsetsRef
.
left
+
detailLabelInsetsRef
.
left
,
right
:
contentInsetsRef
.
right
+
detailLabelInsetsRef
.
right
)
MaterialLayout
.
alignToParentHorizontally
(
self
,
child
:
v
,
left
:
contentInsetsRef
.
left
+
detailLabelInsetsRef
.
left
,
right
:
contentInsetsRef
.
right
+
detailLabelInsetsRef
.
right
)
}
// leftButtons
...
...
Source/MaterialLayout.swift
View file @
b1ac229d
...
...
@@ -46,48 +46,25 @@ public struct MaterialLayout {
}
/**
:name: alignToParent
*/
public
static
func
alignToParent
(
parent
:
UIView
,
child
:
UIView
)
{
let
views
:
Dictionary
<
String
,
AnyObject
>
=
[
"child"
:
child
]
parent
.
addConstraints
(
constraint
(
"H:|[child]|"
,
options
:
[],
metrics
:
nil
,
views
:
views
))
parent
.
addConstraints
(
constraint
(
"V:|[child]|"
,
options
:
[],
metrics
:
nil
,
views
:
views
))
}
/**
:name: alignToParentHorizontally
*/
public
static
func
alignToParentHorizontally
(
parent
:
UIView
,
child
:
UIView
)
{
alignToParentHorizontallyWithInsets
(
parent
,
child
:
child
,
left
:
0
,
right
:
0
)
}
/**
:name: alignToParentHorizontallyWithInsets
*/
public
static
func
alignToParentHorizontally
WithInsets
(
parent
:
UIView
,
child
:
UIView
,
left
:
CGFloat
=
0
,
right
:
CGFloat
=
0
)
{
public
static
func
alignToParentHorizontally
(
parent
:
UIView
,
child
:
UIView
,
left
:
CGFloat
=
0
,
right
:
CGFloat
=
0
)
{
parent
.
addConstraints
(
constraint
(
"H:|-(left)-[child]-(right)-|"
,
options
:
[],
metrics
:
[
"left"
:
left
,
"right"
:
right
],
views
:
[
"child"
:
child
]))
}
/**
:name: alignToParentVertically
*/
public
static
func
alignToParentVertically
(
parent
:
UIView
,
child
:
UIView
)
{
alignToParentVerticallyWithInsets
(
parent
,
child
:
child
,
top
:
0
,
bottom
:
0
)
}
/**
:name: alignToParentVerticallyWithInsets
*/
public
static
func
alignToParentVerticallyWithInsets
(
parent
:
UIView
,
child
:
UIView
,
top
:
CGFloat
=
0
,
bottom
:
CGFloat
=
0
)
{
public
static
func
alignToParentVertically
(
parent
:
UIView
,
child
:
UIView
,
top
:
CGFloat
=
0
,
bottom
:
CGFloat
=
0
)
{
parent
.
addConstraints
(
constraint
(
"V:|-(top)-[child]-(bottom)-|"
,
options
:
[],
metrics
:
[
"bottom"
:
bottom
,
"top"
:
top
],
views
:
[
"child"
:
child
]))
}
/**
:name: alignToParent
WithInsets
:name: alignToParent
*/
public
static
func
alignToParent
WithInsets
(
parent
:
UIView
,
child
:
UIView
,
top
:
CGFloat
=
0
,
left
:
CGFloat
=
0
,
bottom
:
CGFloat
=
0
,
right
:
CGFloat
=
0
)
{
alignToParentHorizontally
WithInsets
(
parent
,
child
:
child
,
left
:
left
,
right
:
right
)
alignToParentVertically
WithInsets
(
parent
,
child
:
child
,
top
:
top
,
bottom
:
bottom
)
public
static
func
alignToParent
(
parent
:
UIView
,
child
:
UIView
,
top
:
CGFloat
=
0
,
left
:
CGFloat
=
0
,
bottom
:
CGFloat
=
0
,
right
:
CGFloat
=
0
)
{
alignToParentHorizontally
(
parent
,
child
:
child
,
left
:
left
,
right
:
right
)
alignToParentVertically
(
parent
,
child
:
child
,
top
:
top
,
bottom
:
bottom
)
}
/**
...
...
Source/MaterialPulseCollectionViewCell.swift
View file @
b1ac229d
...
...
@@ -469,7 +469,7 @@ public class MaterialPulseCollectionViewCell : UICollectionViewCell {
// :name: layoutVisualLayer
//
internal
func
layoutVisualLayer
()
{
visualLayer
.
frame
=
bounds
visualLayer
.
bounds
=
bounds
visualLayer
.
position
=
CGPointMake
(
width
/
2
,
height
/
2
)
visualLayer
.
cornerRadius
=
layer
.
cornerRadius
}
...
...
Source/MaterialTextView.swift
View file @
b1ac229d
...
...
@@ -21,11 +21,6 @@ import UIKit
public
protocol
MaterialTextViewDelegate
:
UITextViewDelegate
{}
public
class
MaterialTextView
:
UITextView
{
//
// :name: layoutConstraints
//
internal
lazy
var
layoutConstraints
:
Array
<
NSLayoutConstraint
>
=
Array
<
NSLayoutConstraint
>
()
/**
:name: init
*/
...
...
@@ -105,26 +100,9 @@ public class MaterialTextView: UITextView {
*/
internal
func
updateLabelConstraints
()
{
if
let
p
=
placeholderLabel
{
NSLayoutConstraint
.
deactivateConstraints
(
layoutConstraints
)
layoutConstraints
=
NSLayoutConstraint
.
constraintsWithVisualFormat
(
"H:|-(left)-[placeholderLabel]-(right)-|"
,
options
:
[],
metrics
:
[
"left"
:
textContainerInset
.
left
+
textContainer
.
lineFragmentPadding
,
"right"
:
textContainerInset
.
right
+
textContainer
.
lineFragmentPadding
],
views
:
[
"placeholderLabel"
:
p
])
layoutConstraints
+=
NSLayoutConstraint
.
constraintsWithVisualFormat
(
"V:|-(top)-[placeholderLabel]-(>=bottom)-|"
,
options
:
[],
metrics
:
[
"top"
:
textContainerInset
.
top
,
"bottom"
:
textContainerInset
.
bottom
],
views
:
[
"placeholderLabel"
:
p
])
NSLayoutConstraint
.
activateConstraints
(
layoutConstraints
)
removeConstraints
(
constraints
)
MaterialLayout
.
alignToParentHorizontally
(
self
,
child
:
p
,
left
:
textContainerInset
.
left
+
textContainer
.
lineFragmentPadding
,
right
:
textContainerInset
.
right
+
textContainer
.
lineFragmentPadding
)
MaterialLayout
.
alignToParentVertically
(
self
,
child
:
p
,
top
:
textContainerInset
.
top
,
bottom
:
textContainerInset
.
bottom
)
}
}
...
...
@@ -141,10 +119,10 @@ public class MaterialTextView: UITextView {
// :name: prepareView
//
private
func
prepareView
()
{
// label needs to be added to the view
// hierarchy before setting insets
textContainerInset
=
UIEdgeInsetsMake
(
16
,
16
,
16
,
16
)
backgroundColor
=
.
clearColor
()
backgroundColor
=
MaterialColor
.
clear
NSNotificationCenter
.
defaultCenter
()
.
removeObserver
(
self
)
NSNotificationCenter
.
defaultCenter
()
.
removeObserver
(
self
,
name
:
UITextViewTextDidChangeNotification
,
object
:
nil
)
NSNotificationCenter
.
defaultCenter
()
.
addObserver
(
self
,
selector
:
"textViewTextDidChange"
,
name
:
UITextViewTextDidChangeNotification
,
object
:
nil
)
updateLabelConstraints
()
}
...
...
Source/NavigationBarView.swift
View file @
b1ac229d
...
...
@@ -242,7 +242,7 @@ public class NavigationBarView : MaterialView {
views
[
"titleLabel"
]
=
v
addSubview
(
v
)
MaterialLayout
.
alignToParentHorizontally
WithInsets
(
self
,
child
:
v
,
left
:
contentInsetsRef
.
left
+
titleLabelInsetsRef
.
left
,
right
:
contentInsetsRef
.
right
+
titleLabelInsetsRef
.
right
)
MaterialLayout
.
alignToParentHorizontally
(
self
,
child
:
v
,
left
:
contentInsetsRef
.
left
+
titleLabelInsetsRef
.
left
,
right
:
contentInsetsRef
.
right
+
titleLabelInsetsRef
.
right
)
}
// detail
...
...
@@ -256,7 +256,7 @@ public class NavigationBarView : MaterialView {
views
[
"detailLabel"
]
=
v
addSubview
(
v
)
MaterialLayout
.
alignToParentHorizontally
WithInsets
(
self
,
child
:
v
,
left
:
contentInsetsRef
.
left
+
detailLabelInsetsRef
.
left
,
right
:
contentInsetsRef
.
right
+
detailLabelInsetsRef
.
right
)
MaterialLayout
.
alignToParentHorizontally
(
self
,
child
:
v
,
left
:
contentInsetsRef
.
left
+
detailLabelInsetsRef
.
left
,
right
:
contentInsetsRef
.
right
+
detailLabelInsetsRef
.
right
)
}
// leftButtons
...
...
Source/SearchBarView.swift
View file @
b1ac229d
...
...
@@ -224,7 +224,7 @@ public class SearchBarView : MaterialView, UITextFieldDelegate {
addSubview
(
textField
)
MaterialLayout
.
alignToParentHorizontally
WithInsets
(
self
,
child
:
textField
,
left
:
contentInsetsRef
.
left
+
textFieldInsetsRef
.
left
,
right
:
contentInsetsRef
.
right
+
textFieldInsetsRef
.
right
)
MaterialLayout
.
alignToParentHorizontally
(
self
,
child
:
textField
,
left
:
contentInsetsRef
.
left
+
textFieldInsetsRef
.
left
,
right
:
contentInsetsRef
.
right
+
textFieldInsetsRef
.
right
)
// leftButtons
if
let
v
=
leftButtons
{
...
...
Source/SideNavigationViewController.swift
View file @
b1ac229d
...
...
@@ -192,8 +192,12 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer
let
w
:
CGFloat
=
(
hidden
?
-
width
:
width
)
/
2
if
animated
{
self
.
leftView
!.
width
=
width
self
.
leftView
!.
position
.
x
=
w
MaterialAnimation
.
animationWithDuration
(
0.25
,
animations
:
{
self
.
leftView
!.
width
=
width
self
.
leftView
!.
position
.
x
=
w
})
{
self
.
userInteractionEnabled
=
false
}
}
else
{
MaterialAnimation
.
animationDisabled
({
self
.
leftView
!.
width
=
width
...
...
@@ -213,14 +217,14 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer
:name: openLeftViewContainer
*/
public
func
openLeftViewContainer
(
velocity
:
CGFloat
=
0
)
{
if
let
v
c
=
leftView
{
let
w
:
CGFloat
=
v
c
.
width
let
h
:
CGFloat
=
v
c
.
height
let
d
:
Double
=
Double
(
0
==
velocity
?
animationDuration
:
fmax
(
0.1
,
fmin
(
1
,
Double
(
v
c
.
x
/
velocity
))))
if
let
v
=
leftView
{
let
w
:
CGFloat
=
v
.
width
let
h
:
CGFloat
=
v
.
height
let
d
:
Double
=
Double
(
0
==
velocity
?
animationDuration
:
fmax
(
0.1
,
fmin
(
1
,
Double
(
v
.
x
/
velocity
))))
toggleStatusBar
(
true
)
MaterialAnimation
.
animationWithDuration
(
d
,
animations
:
{
v
c
.
position
=
CGPointMake
(
w
/
2
,
h
/
2
)
v
.
position
=
CGPointMake
(
w
/
2
,
h
/
2
)
self
.
backdropLayer
.
hidden
=
false
})
{
self
.
userInteractionEnabled
=
false
...
...
@@ -232,14 +236,14 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer
:name: closeLeftViewContainer
*/
public
func
closeLeftViewContainer
(
velocity
:
CGFloat
=
0
)
{
if
let
v
c
=
leftView
{
let
w
:
CGFloat
=
v
c
.
width
let
h
:
CGFloat
=
v
c
.
height
let
d
:
Double
=
Double
(
0
==
velocity
?
animationDuration
:
fmax
(
0.1
,
fmin
(
1
,
Double
(
v
c
.
x
/
velocity
))))
if
let
v
=
leftView
{
let
w
:
CGFloat
=
v
.
width
let
h
:
CGFloat
=
v
.
height
let
d
:
Double
=
Double
(
0
==
velocity
?
animationDuration
:
fmax
(
0.1
,
fmin
(
1
,
Double
(
v
.
x
/
velocity
))))
toggleStatusBar
(
false
)
MaterialAnimation
.
animationWithDuration
(
d
,
animations
:
{
v
c
.
position
=
CGPointMake
(
-
w
/
2
,
h
/
2
)
v
.
position
=
CGPointMake
(
-
w
/
2
,
h
/
2
)
self
.
backdropLayer
.
hidden
=
true
})
{
self
.
userInteractionEnabled
=
true
...
...
@@ -435,7 +439,7 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer
// :name: prepareViewControllerWithinContainer
//
private
func
prepareViewControllerWithinContainer
(
controller
:
UIViewController
,
container
:
UIView
)
{
controller
.
view
.
autoresizingMask
=
[
.
FlexibleWidth
,
.
FlexibleHeight
]
controller
.
view
.
clipsToBounds
=
true
addChildViewController
(
controller
)
container
.
addSubview
(
controller
.
view
)
controller
.
didMoveToParentViewController
(
self
)
...
...
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