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
b591c92d
Unverified
Commit
b591c92d
authored
Oct 02, 2016
by
Daniel Dahan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added feature where TextField placeholder does not animate issue-534
parent
7b0a4f16
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
35 additions
and
9 deletions
+35
-9
Material.xcodeproj/project.pbxproj
+9
-1
Sources/iOS/ErrorTextField.swift
+1
-0
Sources/iOS/Grid.swift
+10
-5
Sources/iOS/TextField.swift
+15
-3
No files found.
Material.xcodeproj/project.pbxproj
View file @
b591c92d
...
...
@@ -339,6 +339,14 @@
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
9602F00C1DA1163000F3FB79
/* Grid */
=
{
isa
=
PBXGroup
;
children
=
(
96BCB7611CB40DC500C806FE
/* Grid.swift */
,
);
name
=
Grid
;
sourceTree
=
"<group>"
;
};
96090B031D9D709E00709CA6
/* TextField */
=
{
isa
=
PBXGroup
;
children
=
(
...
...
@@ -520,6 +528,7 @@
96230AB61D6A51FD00AF47DC
/* Divider */
,
96BCB80A1CB410A100C806FE
/* Extension */
,
96BCB8071CB4101C00C806FE
/* Font */
,
9602F00C1DA1163000F3FB79
/* Grid */
,
96BCB8081CB4105E00C806FE
/* Icon */
,
96BCB80D1CB410FD00C806FE
/* Layer */
,
96BCB8041CB40F6C00C806FE
/* Layout */
,
...
...
@@ -619,7 +628,6 @@
isa
=
PBXGroup
;
children
=
(
96BCB7811CB40DC500C806FE
/* Layout.swift */
,
96BCB7611CB40DC500C806FE
/* Grid.swift */
,
);
name
=
Layout
;
sourceTree
=
"<group>"
;
...
...
Sources/iOS/ErrorTextField.swift
View file @
b591c92d
...
...
@@ -48,6 +48,7 @@ open class ErrorTextField: TextField {
*/
open
override
func
prepare
()
{
super
.
prepare
()
isErrorRevealed
=
false
detailColor
=
Color
.
red
.
base
}
}
Sources/iOS/Grid.swift
View file @
b591c92d
...
...
@@ -214,9 +214,14 @@ public class Grid {
return
}
let
count
=
views
.
count
guard
0
<
count
else
{
return
}
var
n
:
Int
=
0
var
i
:
Int
=
0
var
count
=
views
.
count
for
child
in
views
{
guard
let
canvas
=
context
else
{
...
...
@@ -230,7 +235,7 @@ public class Grid {
switch
axis
.
direction
{
case
.
horizontal
:
let
c
=
0
==
child
.
grid
.
columns
?
axis
.
columns
/
views
.
count
:
child
.
grid
.
columns
let
c
=
0
==
child
.
grid
.
columns
?
axis
.
columns
/
count
:
child
.
grid
.
columns
let
co
=
child
.
grid
.
offset
.
columns
let
w
=
(
canvas
.
bounds
.
width
-
contentEdgeInsets
.
left
-
contentEdgeInsets
.
right
-
layoutEdgeInsets
.
left
-
layoutEdgeInsets
.
right
+
interimSpace
)
/
CGFloat
(
axis
.
columns
)
...
...
@@ -242,7 +247,7 @@ public class Grid {
n
+=
c
+
co
-
1
case
.
vertical
:
let
r
=
0
==
child
.
grid
.
rows
?
axis
.
rows
/
views
.
count
:
child
.
grid
.
rows
let
r
=
0
==
child
.
grid
.
rows
?
axis
.
rows
/
count
:
child
.
grid
.
rows
let
ro
=
child
.
grid
.
offset
.
rows
let
h
=
(
canvas
.
bounds
.
height
-
contentEdgeInsets
.
top
-
contentEdgeInsets
.
bottom
-
layoutEdgeInsets
.
top
-
layoutEdgeInsets
.
bottom
+
interimSpace
)
/
CGFloat
(
axis
.
rows
)
...
...
@@ -254,9 +259,9 @@ public class Grid {
n
+=
r
+
ro
-
1
case
.
any
:
let
r
=
0
==
child
.
grid
.
rows
?
axis
.
rows
/
views
.
count
:
child
.
grid
.
rows
let
r
=
0
==
child
.
grid
.
rows
?
axis
.
rows
/
count
:
child
.
grid
.
rows
let
ro
=
child
.
grid
.
offset
.
rows
let
c
=
0
==
child
.
grid
.
columns
?
axis
.
columns
/
views
.
count
:
child
.
grid
.
columns
let
c
=
0
==
child
.
grid
.
columns
?
axis
.
columns
/
count
:
child
.
grid
.
columns
let
co
=
child
.
grid
.
offset
.
columns
let
w
=
(
canvas
.
bounds
.
width
-
contentEdgeInsets
.
left
-
contentEdgeInsets
.
right
-
layoutEdgeInsets
.
left
-
layoutEdgeInsets
.
right
+
interimSpace
)
/
CGFloat
(
axis
.
columns
)
let
h
=
(
canvas
.
bounds
.
height
-
contentEdgeInsets
.
top
-
contentEdgeInsets
.
bottom
-
layoutEdgeInsets
.
top
-
layoutEdgeInsets
.
bottom
+
interimSpace
)
/
CGFloat
(
axis
.
rows
)
...
...
Sources/iOS/TextField.swift
View file @
b591c92d
...
...
@@ -40,6 +40,10 @@ open class TextField: UITextField {
return
CGSize
(
width
:
width
,
height
:
32
)
}
/// A Boolean that indicates if the placeholder label is animated.
@IBInspectable
open
var
isPlaceholderAnimated
=
true
/// A Boolean that indicates if the TextField is in an animating state.
open
internal(set)
var
isAnimating
=
false
...
...
@@ -161,7 +165,7 @@ open class TextField: UITextField {
/// The detailLabel UILabel that is displayed.
@IBInspectable
open
private(set)
lazy
var
detailLabel
=
UILabel
(
frame
:
.
zero
)
open
private(set)
lazy
var
detailLabel
=
UILabel
()
/// The detailLabel text value.
@IBInspectable
...
...
@@ -432,7 +436,7 @@ open class TextField: UITextField {
/// Layout the placeholderLabel.
open
func
layoutPlaceholderLabel
()
{
if
!
isEditing
&&
true
==
text
?
.
isEmpty
{
if
!
isEditing
&&
true
==
text
?
.
isEmpty
&&
isPlaceholderAnimated
{
placeholderLabel
.
frame
=
bounds
}
else
if
placeholderLabel
.
transform
.
isIdentity
{
placeholderLabel
.
frame
=
bounds
...
...
@@ -493,6 +497,10 @@ open class TextField: UITextField {
/// The animation for the placeholder when editing begins.
open
func
placeholderEditingDidBeginAnimation
()
{
guard
isPlaceholderAnimated
else
{
return
}
guard
placeholderLabel
.
transform
.
isIdentity
else
{
if
isEditing
{
placeholderLabel
.
textColor
=
placeholderActiveColor
...
...
@@ -525,6 +533,10 @@ open class TextField: UITextField {
/// The animation for the placeholder when editing ends.
open
func
placeholderEditingDidEndAnimation
()
{
guard
isPlaceholderAnimated
else
{
return
}
if
!
placeholderLabel
.
transform
.
isIdentity
&&
true
==
text
?
.
isEmpty
{
isAnimating
=
true
UIView
.
animate
(
withDuration
:
0.15
,
animations
:
{
[
weak
self
]
in
...
...
@@ -551,7 +563,7 @@ open class TextField: UITextField {
/// Prepares the placeholderLabel.
private
func
preparePlaceholderLabel
()
{
placeholderLabel
=
UILabel
(
frame
:
.
zero
)
placeholderLabel
=
UILabel
()
placeholderNormalColor
=
Color
.
darkText
.
others
font
=
RobotoFont
.
regular
(
with
:
16
)
addSubview
(
placeholderLabel
)
...
...
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