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
a0e2f5dc
Commit
a0e2f5dc
authored
Apr 20, 2016
by
Daniel Dahan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed issue-316, where placeholder update was resolving to incorrect value
parent
af936563
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
64 additions
and
41 deletions
+64
-41
Examples/Programmatic/App/App/AppNavigationController.swift
+1
-0
Examples/Programmatic/TextField/TextField/ViewController.swift
+14
-11
Material.xcodeproj/project.pbxproj
+1
-1
README.md
+1
-0
Sources/Info.plist
+1
-1
Sources/iOS/MaterialButton.swift
+1
-1
Sources/iOS/MaterialCollectionViewCell.swift
+5
-1
Sources/iOS/MaterialPulseView.swift
+5
-1
Sources/iOS/MaterialTableViewCell.swift
+5
-1
Sources/iOS/TextField.swift
+30
-24
No files found.
Examples/Programmatic/App/App/AppNavigationController.swift
View file @
a0e2f5dc
...
...
@@ -61,6 +61,7 @@ class AppNavigationController: NavigationController {
/// Prepares the navigationBar
private
func
prepareNavigationBar
()
{
navigationBar
.
tintColor
=
MaterialColor
.
white
navigationBar
.
backgroundColor
=
MaterialColor
.
blue
.
base
}
}
Examples/Programmatic/TextField/TextField/ViewController.swift
View file @
a0e2f5dc
...
...
@@ -39,6 +39,9 @@ import UIKit
import
Material
class
ViewController
:
UIViewController
,
TextFieldDelegate
{
private
var
nameField
:
TextField
!
private
var
emailField
:
TextField
!
override
func
viewDidLoad
()
{
super
.
viewDidLoad
()
prepareView
()
...
...
@@ -55,30 +58,30 @@ class ViewController: UIViewController, TextFieldDelegate {
private
func
prepareNameField
()
{
let
w
:
CGFloat
=
300
let
x
:
CGFloat
=
(
MaterialDevice
.
width
-
w
)
/
2
let
textField
:
Text
Field
=
TextField
(
frame
:
CGRectMake
(
x
,
100
,
w
,
24
))
textField
.
placeholder
=
"First
Name"
view
.
addSubview
(
text
Field
)
name
Field
=
TextField
(
frame
:
CGRectMake
(
x
,
100
,
w
,
24
))
nameField
.
placeholder
=
"
Name"
view
.
addSubview
(
name
Field
)
}
/// Prepares the email TextField.
private
func
prepareEmailField
()
{
let
w
:
CGFloat
=
300
let
x
:
CGFloat
=
(
MaterialDevice
.
width
-
w
)
/
2
let
textField
:
Text
Field
=
TextField
(
frame
:
CGRectMake
(
x
,
200
,
w
,
24
))
text
Field
.
placeholder
=
"Email"
text
Field
.
delegate
=
self
email
Field
=
TextField
(
frame
:
CGRectMake
(
x
,
200
,
w
,
24
))
email
Field
.
placeholder
=
"Email"
email
Field
.
delegate
=
self
/*
Used to display the error message, which is displayed when
the user presses the 'return' key.
*/
text
Field
.
detailLabel
=
UILabel
()
text
Field
.
detailLabel
!.
text
=
"Email is incorrect."
text
Field
.
detailLabel
!.
font
=
RobotoFont
.
regularWithSize
(
12
)
text
Field
.
detailLabelActiveColor
=
MaterialColor
.
red
.
accent3
email
Field
.
detailLabel
=
UILabel
()
email
Field
.
detailLabel
!.
text
=
"Email is incorrect."
email
Field
.
detailLabel
!.
font
=
RobotoFont
.
regularWithSize
(
12
)
email
Field
.
detailLabelActiveColor
=
MaterialColor
.
red
.
accent3
// textField.detailLabelAutoHideEnabled = false // Uncomment this line to have manual hiding.
view
.
addSubview
(
text
Field
)
view
.
addSubview
(
email
Field
)
}
/// Executed when the 'return' key is pressed when using the emailField.
...
...
Material.xcodeproj/project.pbxproj
View file @
a0e2f5dc
...
...
@@ -452,9 +452,9 @@
96BCB8031CB40F4B00C806FE
/* Button */
=
{
isa
=
PBXGroup
;
children
=
(
96BCB7701CB40DC500C806FE
/* MaterialButton.swift */
,
96BCB75F1CB40DC500C806FE
/* FabButton.swift */
,
96BCB7601CB40DC500C806FE
/* FlatButton.swift */
,
96BCB7701CB40DC500C806FE
/* MaterialButton.swift */
,
96BCB7931CB40DC500C806FE
/* RaisedButton.swift */
,
);
name
=
Button
;
...
...
README.md
View file @
a0e2f5dc
...
...
@@ -396,6 +396,7 @@ Add a new dimension of interactivity with CaptureView. CaptureView is a fully fu
*
Bottom Sheets
*
Dialogs
*
Collapsing Toolbar
*
Pull to Refresh
*
RTL Support
*
Advanced Camera / Audio Toolset & Views
*
More Examples
...
...
Sources/Info.plist
View file @
a0e2f5dc
...
...
@@ -15,7 +15,7 @@
<
k
e
y
>
CFBundlePackageType
<
/k
e
y
>
<
string
>
FMWK
<
/string
>
<
k
e
y
>
CFBundleShortVersionString
<
/k
e
y
>
<
string
>
1.
40.0
<
/string
>
<
string
>
1.
39.14
<
/string
>
<
k
e
y
>
CFBundleSignature
<
/k
e
y
>
<
string
>
????
<
/string
>
<
k
e
y
>
CFBundleVersion
<
/k
e
y
>
...
...
Sources/iOS/MaterialButton.swift
View file @
a0e2f5dc
...
...
@@ -439,13 +439,13 @@ public class MaterialButton : UIButton {
public
override
func
touchesBegan
(
touches
:
Set
<
UITouch
>
,
withEvent
event
:
UIEvent
?)
{
super
.
touchesBegan
(
touches
,
withEvent
:
event
)
let
duration
:
NSTimeInterval
=
MaterialAnimation
.
pulseDuration
(
width
)
let
point
:
CGPoint
=
pulseCenter
?
CGPointMake
(
CGFloat
(
width
/
2
),
CGFloat
(
height
/
2
))
:
layer
.
convertPoint
(
touches
.
first
!.
locationInView
(
self
),
fromLayer
:
layer
)
if
pulseFocus
{
pulseLayer
=
CAShapeLayer
()
}
if
let
v
:
UIColor
=
pulseColor
{
let
point
:
CGPoint
=
pulseCenter
?
CGPointMake
(
CGFloat
(
width
/
2
),
CGFloat
(
height
/
2
))
:
layer
.
convertPoint
(
touches
.
first
!.
locationInView
(
self
),
fromLayer
:
layer
)
MaterialAnimation
.
pulseAnimation
(
layer
,
visualLayer
:
visualLayer
,
color
:
v
.
colorWithAlphaComponent
(
pulseOpacity
),
point
:
point
,
width
:
width
,
height
:
height
,
duration
:
duration
,
pulseLayer
:
pulseLayer
)
}
...
...
Sources/iOS/MaterialCollectionViewCell.swift
View file @
a0e2f5dc
...
...
@@ -61,6 +61,9 @@ public class MaterialCollectionViewCell : UICollectionViewCell {
/// The color of the pulse effect.
@IBInspectable
public
var
pulseColor
:
UIColor
?
/// Sets a pulse animation to always radiate from the center
@IBInspectable
public
var
pulseCenter
:
Bool
=
false
/**
A property that manages an image for the visualLayer's contents
property. Images should not be set to the backing layer's contents
...
...
@@ -547,7 +550,8 @@ public class MaterialCollectionViewCell : UICollectionViewCell {
}
if
let
v
:
UIColor
=
pulseColor
{
MaterialAnimation
.
pulseAnimation
(
layer
,
visualLayer
:
visualLayer
,
color
:
v
.
colorWithAlphaComponent
(
pulseOpacity
),
point
:
layer
.
convertPoint
(
touches
.
first
!.
locationInView
(
self
),
fromLayer
:
layer
),
width
:
width
,
height
:
height
,
duration
:
duration
,
pulseLayer
:
pulseLayer
)
let
point
:
CGPoint
=
pulseCenter
?
CGPointMake
(
CGFloat
(
width
/
2
),
CGFloat
(
height
/
2
))
:
layer
.
convertPoint
(
touches
.
first
!.
locationInView
(
self
),
fromLayer
:
layer
)
MaterialAnimation
.
pulseAnimation
(
layer
,
visualLayer
:
visualLayer
,
color
:
v
.
colorWithAlphaComponent
(
pulseOpacity
),
point
:
point
,
width
:
width
,
height
:
height
,
duration
:
duration
,
pulseLayer
:
pulseLayer
)
}
if
pulseScale
{
...
...
Sources/iOS/MaterialPulseView.swift
View file @
a0e2f5dc
...
...
@@ -46,6 +46,9 @@ public class MaterialPulseView : MaterialView {
/// The color of the pulse effect.
@IBInspectable
public
var
pulseColor
:
UIColor
?
/// Sets a pulse animation to always radiate from the center
@IBInspectable
public
var
pulseCenter
:
Bool
=
false
/**
Triggers the pulse animation.
- Parameter point: A Optional point to pulse from, otherwise pulses
...
...
@@ -86,7 +89,8 @@ public class MaterialPulseView : MaterialView {
}
if
let
v
:
UIColor
=
pulseColor
{
MaterialAnimation
.
pulseAnimation
(
layer
,
visualLayer
:
visualLayer
,
color
:
v
.
colorWithAlphaComponent
(
pulseOpacity
),
point
:
layer
.
convertPoint
(
touches
.
first
!.
locationInView
(
self
),
fromLayer
:
layer
),
width
:
width
,
height
:
height
,
duration
:
duration
,
pulseLayer
:
pulseLayer
)
let
point
:
CGPoint
=
pulseCenter
?
CGPointMake
(
CGFloat
(
width
/
2
),
CGFloat
(
height
/
2
))
:
layer
.
convertPoint
(
touches
.
first
!.
locationInView
(
self
),
fromLayer
:
layer
)
MaterialAnimation
.
pulseAnimation
(
layer
,
visualLayer
:
visualLayer
,
color
:
v
.
colorWithAlphaComponent
(
pulseOpacity
),
point
:
point
,
width
:
width
,
height
:
height
,
duration
:
duration
,
pulseLayer
:
pulseLayer
)
}
if
pulseScale
{
...
...
Sources/iOS/MaterialTableViewCell.swift
View file @
a0e2f5dc
...
...
@@ -60,6 +60,9 @@ public class MaterialTableViewCell : UITableViewCell {
/// The color of the pulse effect.
@IBInspectable
public
var
pulseColor
:
UIColor
?
/// Sets a pulse animation to always radiate from the center
@IBInspectable
public
var
pulseCenter
:
Bool
=
false
/**
This property is the same as clipsToBounds. It crops any of the view's
contents from bleeding past the view's frame. If an image is set using
...
...
@@ -397,7 +400,8 @@ public class MaterialTableViewCell : UITableViewCell {
}
if
let
v
:
UIColor
=
pulseColor
{
MaterialAnimation
.
pulseAnimation
(
layer
,
visualLayer
:
visualLayer
,
color
:
v
.
colorWithAlphaComponent
(
pulseOpacity
),
point
:
layer
.
convertPoint
(
touches
.
first
!.
locationInView
(
self
),
fromLayer
:
layer
),
width
:
width
,
height
:
height
,
duration
:
duration
,
pulseLayer
:
pulseLayer
)
let
point
:
CGPoint
=
pulseCenter
?
CGPointMake
(
CGFloat
(
width
/
2
),
CGFloat
(
height
/
2
))
:
layer
.
convertPoint
(
touches
.
first
!.
locationInView
(
self
),
fromLayer
:
layer
)
MaterialAnimation
.
pulseAnimation
(
layer
,
visualLayer
:
visualLayer
,
color
:
v
.
colorWithAlphaComponent
(
pulseOpacity
),
point
:
point
,
width
:
width
,
height
:
height
,
duration
:
duration
,
pulseLayer
:
pulseLayer
)
}
if
pulseScale
{
...
...
Sources/iOS/TextField.swift
View file @
a0e2f5dc
...
...
@@ -314,13 +314,6 @@ public class TextField : UITextField {
*/
@IBInspectable
public
var
titleLabelAnimationDistance
:
CGFloat
=
4
/// An override to the text property.
@IBInspectable
public
override
var
text
:
String
?
{
didSet
{
textFieldDidChange
()
}
}
/**
The detail UILabel that is displayed when the detailLabelHidden property
is set to false.
...
...
@@ -373,13 +366,31 @@ public class TextField : UITextField {
}
}
/// An override to the text property.
@IBInspectable
public
override
var
text
:
String
?
{
didSet
{
textFieldDidChange
()
}
}
/// Sets the placeholder value.
@IBInspectable
public
override
var
placeholder
:
String
?
{
didSet
{
if
let
v
:
String
=
placeholder
{
get
{
return
editing
?
nil
:
placeholderText
}
set
(
value
)
{
if
let
v
:
String
=
value
{
placeholderText
=
v
attributedPlaceholder
=
NSAttributedString
(
string
:
v
,
attributes
:
[
NSForegroundColorAttributeName
:
placeholderTextColor
])
}
else
{
super
.
placeholder
=
nil
if
!
editing
{
placeholderText
=
nil
}
}
if
0
<
text
?
.
utf16
.
count
{
titleLabel
.
text
=
placeholderText
}
placeholderText
=
placeholder
}
}
...
...
@@ -505,6 +516,11 @@ public class TextField : UITextField {
addTarget
(
self
,
action
:
#selector(
textFieldValueChanged
)
,
forControlEvents
:
.
ValueChanged
)
}
/// Handler for text changed.
internal
func
textFieldDidChange
()
{
sendActionsForControlEvents
(
.
ValueChanged
)
}
/// Clears the textField text.
internal
func
handleClearButton
()
{
if
false
==
delegate
?
.
textFieldShouldClear
?(
self
)
{
...
...
@@ -524,21 +540,15 @@ public class TextField : UITextField {
/// Handler for text editing began.
internal
func
textFieldDidBegin
()
{
showTitleLabel
()
placeholder
=
nil
titleLabel
.
textColor
=
titleLabelActiveColor
lineLayer
.
frame
.
size
.
height
=
lineLayerActiveThickness
lineLayer
.
backgroundColor
=
(
detailLabelHidden
?
nil
==
lineLayerActiveColor
?
titleLabelActiveColor
:
lineLayerActiveColor
:
nil
==
lineLayerDetailActiveColor
?
detailLabelActiveColor
:
lineLayerDetailActiveColor
)?
.
CGColor
}
/// Handler for text changed.
internal
func
textFieldDidChange
()
{
sendActionsForControlEvents
(
.
ValueChanged
)
}
/// Handler for text editing ended.
internal
func
textFieldDidEnd
()
{
if
0
<
text
?
.
utf16
.
count
{
showTitleLabel
()
}
else
if
0
==
text
?
.
utf16
.
count
{
if
0
==
text
?
.
utf16
.
count
{
hideTitleLabel
()
}
titleLabel
.
textColor
=
titleLabelColor
...
...
@@ -628,14 +638,10 @@ public class TextField : UITextField {
/// Shows and animates the titleLabel property.
private
func
showTitleLabel
()
{
if
titleLabel
.
hidden
{
if
let
v
:
String
=
placeholder
{
titleLabel
.
text
=
v
placeholderText
=
v
placeholder
=
nil
}
let
h
:
CGFloat
=
ceil
(
titleLabel
.
font
.
lineHeight
)
titleLabel
.
frame
=
bounds
titleLabel
.
font
=
font
titleLabel
.
text
=
placeholderText
titleLabel
.
hidden
=
false
UIView
.
animateWithDuration
(
0.15
,
animations
:
{
[
weak
self
]
in
if
let
v
:
TextField
=
self
{
...
...
@@ -656,8 +662,8 @@ public class TextField : UITextField {
}
})
{
[
weak
self
]
_
in
if
let
v
:
TextField
=
self
{
v
.
placeholder
=
v
.
placeholderText
v
.
titleLabel
.
hidden
=
true
v
.
placeholder
=
v
.
placeholderText
}
}
}
...
...
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