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
5c350d9a
Unverified
Commit
5c350d9a
authored
Sep 29, 2016
by
Daniel Dahan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
additional cleanup to TextField before animation updates
parent
acb0d897
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
28 deletions
+34
-28
Sources/iOS/TextField.swift
+34
-28
No files found.
Sources/iOS/TextField.swift
View file @
5c350d9a
...
@@ -373,9 +373,10 @@ open class TextField: UITextField {
...
@@ -373,9 +373,10 @@ open class TextField: UITextField {
/// Handles the clearIconButton TouchUpInside event.
/// Handles the clearIconButton TouchUpInside event.
@objc
@objc
open
func
handleClearIconButton
()
{
open
func
handleClearIconButton
()
{
if
false
==
delegate
?
.
textFieldShouldClear
?(
self
)
{
guard
true
==
delegate
?
.
textFieldShouldClear
?(
self
)
else
{
return
return
}
}
text
=
nil
text
=
nil
}
}
...
@@ -383,10 +384,12 @@ open class TextField: UITextField {
...
@@ -383,10 +384,12 @@ open class TextField: UITextField {
@objc
@objc
open
func
handleVisibilityIconButton
()
{
open
func
handleVisibilityIconButton
()
{
isSecureTextEntry
=
!
isSecureTextEntry
isSecureTextEntry
=
!
isSecureTextEntry
if
!
isSecureTextEntry
{
if
!
isSecureTextEntry
{
super
.
font
=
nil
super
.
font
=
nil
font
=
placeholderLabel
.
font
font
=
placeholderLabel
.
font
}
}
visibilityIconButton
?
.
tintColor
=
visibilityIconButton
?
.
tintColor
.
withAlphaComponent
(
isSecureTextEntry
?
0.38
:
0.54
)
visibilityIconButton
?
.
tintColor
=
visibilityIconButton
?
.
tintColor
.
withAlphaComponent
(
isSecureTextEntry
?
0.38
:
0.54
)
}
}
...
@@ -412,12 +415,14 @@ open class TextField: UITextField {
...
@@ -412,12 +415,14 @@ open class TextField: UITextField {
/// Ensures that the components are sized correctly.
/// Ensures that the components are sized correctly.
open
func
layoutToSize
()
{
open
func
layoutToSize
()
{
if
!
isAnimating
{
guard
!
isAnimating
else
{
return
}
layoutPlaceholderLabel
()
layoutPlaceholderLabel
()
layoutDetailLabel
()
layoutDetailLabel
()
layoutClearIconButton
()
layoutButton
(
button
:
clearIconButton
)
layoutVisibilityIconButton
()
layoutButton
(
button
:
visibilityIconButton
)
}
}
}
/// Layout the divider.
/// Layout the divider.
...
@@ -460,26 +465,18 @@ open class TextField: UITextField {
...
@@ -460,26 +465,18 @@ open class TextField: UITextField {
guard
let
v
=
divider
.
line
else
{
guard
let
v
=
divider
.
line
else
{
return
return
}
}
let
h
:
CGFloat
=
nil
==
detail
?
12
:
detailLabel
.
font
.
stringSize
(
string
:
detail
!
,
constrainedToWidth
:
Double
(
width
))
.
height
let
h
:
CGFloat
=
nil
==
detail
?
12
:
detailLabel
.
font
.
stringSize
(
string
:
detail
!
,
constrainedToWidth
:
Double
(
width
))
.
height
detailLabel
.
frame
=
CGRect
(
x
:
0
,
y
:
v
.
y
+
detailVerticalOffset
,
width
:
width
,
height
:
h
)
detailLabel
.
frame
=
CGRect
(
x
:
0
,
y
:
v
.
y
+
detailVerticalOffset
,
width
:
width
,
height
:
h
)
}
}
/// Layout the clearIconButton.
/// Layout the a button.
open
func
layoutClearIconButton
()
{
open
func
layoutButton
(
button
:
UIButton
?)
{
if
let
v
=
clearIconButton
{
guard
0
<
width
&&
0
<
height
else
{
if
0
<
width
&&
0
<
height
{
return
v
.
frame
=
CGRect
(
x
:
width
-
height
,
y
:
0
,
width
:
height
,
height
:
height
)
}
}
}
}
/// Layout the visibilityIconButton.
button
?
.
frame
=
CGRect
(
x
:
width
-
height
,
y
:
0
,
width
:
height
,
height
:
height
)
open
func
layoutVisibilityIconButton
()
{
if
let
v
=
visibilityIconButton
{
if
0
<
width
&&
0
<
height
{
v
.
frame
=
CGRect
(
x
:
width
-
height
,
y
:
0
,
width
:
height
,
height
:
height
)
}
}
}
}
/// The animation for the divider when editing begins.
/// The animation for the divider when editing begins.
...
@@ -496,11 +493,21 @@ open class TextField: UITextField {
...
@@ -496,11 +493,21 @@ open class TextField: UITextField {
/// The animation for the placeholder when editing begins.
/// The animation for the placeholder when editing begins.
open
func
placeholderEditingDidBeginAnimation
()
{
open
func
placeholderEditingDidBeginAnimation
()
{
if
placeholderLabel
.
transform
.
isIdentity
{
guard
placeholderLabel
.
transform
.
isIdentity
else
{
if
isEditing
{
placeholderLabel
.
textColor
=
placeholderActiveColor
}
return
}
isAnimating
=
true
isAnimating
=
true
UIView
.
animate
(
withDuration
:
0.15
,
animations
:
{
[
weak
self
]
in
UIView
.
animate
(
withDuration
:
0.15
,
animations
:
{
[
weak
self
]
in
if
let
s
=
self
{
guard
let
s
=
self
else
{
return
}
s
.
placeholderLabel
.
transform
=
CGAffineTransform
(
scaleX
:
0.75
,
y
:
0.75
)
s
.
placeholderLabel
.
transform
=
CGAffineTransform
(
scaleX
:
0.75
,
y
:
0.75
)
switch
s
.
textAlignment
{
switch
s
.
textAlignment
{
case
.
left
,
.
natural
:
case
.
left
,
.
natural
:
s
.
placeholderLabel
.
x
=
0
s
.
placeholderLabel
.
x
=
0
...
@@ -508,15 +515,12 @@ open class TextField: UITextField {
...
@@ -508,15 +515,12 @@ open class TextField: UITextField {
s
.
placeholderLabel
.
x
=
s
.
width
-
s
.
placeholderLabel
.
width
s
.
placeholderLabel
.
x
=
s
.
width
-
s
.
placeholderLabel
.
width
default
:
break
default
:
break
}
}
s
.
placeholderLabel
.
y
=
-
s
.
placeholderLabel
.
height
+
s
.
placeholderVerticalOffset
s
.
placeholderLabel
.
y
=
-
s
.
placeholderLabel
.
height
+
s
.
placeholderVerticalOffset
s
.
placeholderLabel
.
textColor
=
s
.
placeholderActiveColor
s
.
placeholderLabel
.
textColor
=
s
.
placeholderActiveColor
}
})
{
[
weak
self
]
_
in
})
{
[
weak
self
]
_
in
self
?
.
isAnimating
=
false
self
?
.
isAnimating
=
false
}
}
}
else
if
isEditing
{
placeholderLabel
.
textColor
=
placeholderActiveColor
}
}
}
/// The animation for the placeholder when editing ends.
/// The animation for the placeholder when editing ends.
...
@@ -524,12 +528,14 @@ open class TextField: UITextField {
...
@@ -524,12 +528,14 @@ open class TextField: UITextField {
if
!
placeholderLabel
.
transform
.
isIdentity
&&
true
==
text
?
.
isEmpty
{
if
!
placeholderLabel
.
transform
.
isIdentity
&&
true
==
text
?
.
isEmpty
{
isAnimating
=
true
isAnimating
=
true
UIView
.
animate
(
withDuration
:
0.15
,
animations
:
{
[
weak
self
]
in
UIView
.
animate
(
withDuration
:
0.15
,
animations
:
{
[
weak
self
]
in
if
let
s
=
self
{
guard
let
s
=
self
else
{
return
}
s
.
placeholderLabel
.
transform
=
CGAffineTransform
.
identity
s
.
placeholderLabel
.
transform
=
CGAffineTransform
.
identity
s
.
placeholderLabel
.
x
=
0
s
.
placeholderLabel
.
x
=
0
s
.
placeholderLabel
.
y
=
0
s
.
placeholderLabel
.
y
=
0
s
.
placeholderLabel
.
textColor
=
s
.
placeholderNormalColor
s
.
placeholderLabel
.
textColor
=
s
.
placeholderNormalColor
}
})
{
[
weak
self
]
_
in
})
{
[
weak
self
]
_
in
self
?
.
isAnimating
=
false
self
?
.
isAnimating
=
false
}
}
...
@@ -540,7 +546,7 @@ open class TextField: UITextField {
...
@@ -540,7 +546,7 @@ open class TextField: UITextField {
/// Prepares the divider.
/// Prepares the divider.
private
func
prepareDivider
()
{
private
func
prepareDivider
()
{
dividerColor
=
Color
.
darkText
.
dividers
dividerColor
=
dividerNormalColor
}
}
/// Prepares the placeholderLabel.
/// Prepares the 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