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
1eafbc83
Commit
1eafbc83
authored
Jun 28, 2018
by
Orkhan Alikhanov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added ability to change password visibility icons
parent
b862f893
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
3 deletions
+24
-3
Sources/iOS/TextField.swift
+24
-3
No files found.
Sources/iOS/TextField.swift
View file @
1eafbc83
...
@@ -333,6 +333,20 @@ open class TextField: UITextField {
...
@@ -333,6 +333,20 @@ open class TextField: UITextField {
/// A reference to the visibilityIconButton.
/// A reference to the visibilityIconButton.
open
fileprivate
(
set
)
var
visibilityIconButton
:
IconButton
?
open
fileprivate
(
set
)
var
visibilityIconButton
:
IconButton
?
/// Icon for visibilityIconButton when in the on state.
open
var
visibilityIconOn
=
Icon
.
visibility
{
didSet
{
visibilityIconButton
?
.
image
=
visibilityIcon
}
}
/// Icon for visibilityIconButton when in the off state.
open
var
visibilityIconOff
=
Icon
.
visibilityOff
{
didSet
{
visibilityIconButton
?
.
image
=
visibilityIcon
}
}
/// Enables the visibilityIconButton.
/// Enables the visibilityIconButton.
@IBInspectable
@IBInspectable
open
var
isVisibilityIconButtonEnabled
:
Bool
{
open
var
isVisibilityIconButtonEnabled
:
Bool
{
...
@@ -350,10 +364,10 @@ open class TextField: UITextField {
...
@@ -350,10 +364,10 @@ open class TextField: UITextField {
return
return
}
}
visibilityIconButton
=
IconButton
(
image
:
isSecureTextEntry
?
Icon
.
visibility
:
Icon
.
visibilityOff
,
tintColor
:
placeholderNormalColor
.
withAlphaComponent
(
0.54
))
isSecureTextEntry
=
true
visibilityIconButton
=
IconButton
(
image
:
visibilityIcon
,
tintColor
:
placeholderNormalColor
.
withAlphaComponent
(
0.54
))
visibilityIconButton
!.
contentEdgeInsetsPreset
=
.
none
visibilityIconButton
!.
contentEdgeInsetsPreset
=
.
none
visibilityIconButton
!.
pulseAnimation
=
.
centerRadialBeyondBounds
visibilityIconButton
!.
pulseAnimation
=
.
centerRadialBeyondBounds
isSecureTextEntry
=
true
clearButtonMode
=
.
never
clearButtonMode
=
.
never
rightViewMode
=
.
whileEditing
rightViewMode
=
.
whileEditing
rightView
=
visibilityIconButton
rightView
=
visibilityIconButton
...
@@ -661,7 +675,7 @@ fileprivate extension TextField {
...
@@ -661,7 +675,7 @@ fileprivate extension TextField {
return
return
}
}
v
.
image
=
self
.
isSecureTextEntry
?
Icon
.
visibilityOff
?
.
tint
(
with
:
v
.
tintColor
.
withAlphaComponent
(
0.54
))
:
Icon
.
visibility
?
.
tint
(
with
:
v
.
tintColor
.
withAlphaComponent
(
0.54
))
v
.
image
=
self
.
visibilityIcon
})
})
}
}
}
}
...
@@ -758,3 +772,10 @@ extension TextField {
...
@@ -758,3 +772,10 @@ extension TextField {
})
})
}
}
}
}
private
extension
TextField
{
/// Visibility icon based on isSecureTextEntry value.
var
visibilityIcon
:
UIImage
?
{
return
isSecureTextEntry
?
visibilityIconOff
:
visibilityIconOn
}
}
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