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
55625112
Unverified
Commit
55625112
authored
Oct 17, 2016
by
Daniel Dahan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
development: reworked TextField complete
parent
c06092a1
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
74 additions
and
34 deletions
+74
-34
Examples/Programmatic/TextField/TextField.xcodeproj/project.pbxproj
+3
-2
Examples/Programmatic/TextField/TextField/ViewController.swift
+4
-8
Sources/Assets.xcassets/ic_phone_white.imageset/Contents.json
+24
-0
Sources/Assets.xcassets/ic_phone_white.imageset/ic_phone_white.png
+0
-0
Sources/Assets.xcassets/ic_phone_white.imageset/ic_phone_white@2x.png
+0
-0
Sources/Assets.xcassets/ic_phone_white.imageset/ic_phone_white@3x.png
+0
-0
Sources/iOS/Bar.swift
+1
-1
Sources/iOS/Card.swift
+1
-1
Sources/iOS/Divider.swift
+5
-1
Sources/iOS/ErrorTextField.swift
+1
-0
Sources/iOS/Icon.swift
+1
-0
Sources/iOS/NavigationBar.swift
+1
-1
Sources/iOS/Switch.swift
+1
-1
Sources/iOS/TextField.swift
+32
-19
No files found.
Examples/Programmatic/TextField/TextField.xcodeproj/project.pbxproj
View file @
55625112
...
...
@@ -107,6 +107,7 @@
TargetAttributes
=
{
96090AE31D9CDD2E00709CA6
=
{
CreatedOnToolsVersion
=
8.0
;
DevelopmentTeam
=
9Z76XCNLGL
;
ProvisioningStyle
=
Automatic
;
};
};
...
...
@@ -262,7 +263,7 @@
isa
=
XCBuildConfiguration
;
buildSettings
=
{
ASSETCATALOG_COMPILER_APPICON_NAME
=
AppIcon
;
DEVELOPMENT_TEAM
=
""
;
DEVELOPMENT_TEAM
=
9Z76XCNLGL
;
INFOPLIST_FILE
=
TextField/Info.plist
;
LD_RUNPATH_SEARCH_PATHS
=
"$(inherited) @executable_path/Frameworks"
;
PRODUCT_BUNDLE_IDENTIFIER
=
io.cosmicmind.TextField
;
...
...
@@ -275,7 +276,7 @@
isa
=
XCBuildConfiguration
;
buildSettings
=
{
ASSETCATALOG_COMPILER_APPICON_NAME
=
AppIcon
;
DEVELOPMENT_TEAM
=
""
;
DEVELOPMENT_TEAM
=
9Z76XCNLGL
;
INFOPLIST_FILE
=
TextField/Info.plist
;
LD_RUNPATH_SEARCH_PATHS
=
"$(inherited) @executable_path/Frameworks"
;
PRODUCT_BUNDLE_IDENTIFIER
=
io.cosmicmind.TextField
;
...
...
Examples/Programmatic/TextField/TextField/ViewController.swift
View file @
55625112
...
...
@@ -45,7 +45,7 @@ class ViewController: UIViewController {
prepareNameField
()
prepareEmailField
()
preparePasswordField
()
//
preparePasswordField()
prepareResignResponderButton
()
}
...
...
@@ -72,14 +72,13 @@ class ViewController: UIViewController {
private
func
prepareNameField
()
{
nameField
=
TextField
()
nameField
.
text
=
"Daniel Dahan"
nameField
.
placeholder
=
"Name"
nameField
.
detail
=
"Your given name"
nameField
.
textAlignment
=
.
center
nameField
.
isClearIconButtonEnabled
=
true
nameField
.
clearButtonMode
=
.
whileEditing
let
leftView
=
UIImageView
()
leftView
.
image
=
Icon
.
email
?
.
tint
(
with
:
Color
.
cyan
.
base
)
leftView
.
image
=
Icon
.
phone
?
.
tint
(
with
:
Color
.
blue
.
base
)
nameField
.
leftView
=
leftView
nameField
.
leftViewMode
=
.
always
...
...
@@ -89,15 +88,13 @@ class ViewController: UIViewController {
private
func
prepareEmailField
()
{
emailField
=
ErrorTextField
(
frame
:
CGRect
(
x
:
constant
,
y
:
7
*
constant
,
width
:
view
.
width
-
(
2
*
constant
),
height
:
constant
))
emailField
.
text
=
"Daniel Dahan"
emailField
.
placeholder
=
"Email"
emailField
.
detail
=
"Error, incorrect email"
emailField
.
isClearIconButtonEnabled
=
true
emailField
.
textAlignment
=
.
right
emailField
.
delegate
=
self
let
leftView
=
UIImageView
()
leftView
.
image
=
Icon
.
email
?
.
tint
(
with
:
Color
.
cyan
.
base
)
leftView
.
image
=
Icon
.
email
?
.
tint
(
with
:
Color
.
blue
.
base
)
emailField
.
leftView
=
leftView
emailField
.
leftViewMode
=
.
always
...
...
@@ -112,7 +109,6 @@ class ViewController: UIViewController {
private
func
preparePasswordField
()
{
passwordField
=
TextField
()
passwordField
.
text
=
"Daniel Dahan"
passwordField
.
placeholder
=
"Password"
passwordField
.
detail
=
"At least 8 characters"
passwordField
.
clearButtonMode
=
.
whileEditing
...
...
Sources/Assets.xcassets/ic_phone_white.imageset/Contents.json
0 → 100644
View file @
55625112
{
"images"
:
[
{
"idiom"
:
"universal"
,
"filename"
:
"ic_phone_white.png"
,
"scale"
:
"1x"
},
{
"idiom"
:
"universal"
,
"filename"
:
"ic_phone_white@2x.png"
,
"scale"
:
"2x"
},
{
"idiom"
:
"universal"
,
"filename"
:
"ic_phone_white@3x.png"
,
"scale"
:
"3x"
}
],
"info"
:
{
"version"
:
1
,
"author"
:
"xcode"
}
}
\ No newline at end of file
Sources/Assets.xcassets/ic_phone_white.imageset/ic_phone_white.png
0 → 100644
View file @
55625112
246 Bytes
Sources/Assets.xcassets/ic_phone_white.imageset/ic_phone_white@2x.png
0 → 100644
View file @
55625112
420 Bytes
Sources/Assets.xcassets/ic_phone_white.imageset/ic_phone_white@3x.png
0 → 100644
View file @
55625112
597 Bytes
Sources/iOS/Bar.swift
View file @
55625112
...
...
@@ -37,7 +37,7 @@ public enum ContentViewAlignment: Int {
}
open
class
Bar
:
View
{
/// Will
render
the view.
/// Will
layout
the view.
open
var
willLayout
:
Bool
{
return
0
<
width
&&
0
<
height
&&
nil
!=
superview
}
...
...
Sources/iOS/Card.swift
View file @
55625112
...
...
@@ -31,7 +31,7 @@
import
UIKit
open
class
Card
:
PulseView
{
/// Will
render
the view.
/// Will
layout
the view.
open
var
willLayout
:
Bool
{
return
0
<
width
&&
nil
!=
superview
}
...
...
Sources/iOS/Divider.swift
View file @
55625112
...
...
@@ -46,7 +46,11 @@ open class Divider {
internal
var
line
:
UIView
?
/// A reference to the height.
open
var
thickness
:
CGFloat
open
var
thickness
:
CGFloat
{
didSet
{
reload
()
}
}
/// A preset wrapper around contentEdgeInsets.
open
var
contentEdgeInsetsPreset
=
EdgeInsetsPreset
.
none
{
...
...
Sources/iOS/ErrorTextField.swift
View file @
55625112
...
...
@@ -35,6 +35,7 @@ open class ErrorTextField: TextField {
@IBInspectable
open
var
isErrorRevealed
=
false
{
didSet
{
layoutDetailLabel
()
detailLabel
.
isHidden
=
!
isErrorRevealed
}
}
...
...
Sources/iOS/Icon.swift
View file @
55625112
...
...
@@ -79,6 +79,7 @@ public struct Icon {
public
static
let
movie
=
Icon
.
icon
(
"ic_movie_white"
)
public
static
let
pen
=
Icon
.
icon
(
"ic_edit_white"
)
public
static
let
place
=
Icon
.
icon
(
"ic_place_white"
)
public
static
let
phone
=
Icon
.
icon
(
"ic_phone_white"
)
public
static
let
photoCamera
=
Icon
.
icon
(
"ic_photo_camera_white"
)
public
static
let
photoLibrary
=
Icon
.
icon
(
"ic_photo_library_white"
)
public
static
let
search
=
Icon
.
icon
(
"ic_search_white"
)
...
...
Sources/iOS/NavigationBar.swift
View file @
55625112
...
...
@@ -31,7 +31,7 @@
import
UIKit
open
class
NavigationBar
:
UINavigationBar
{
/// Will
render
the view.
/// Will
layout
the view.
open
var
willLayout
:
Bool
{
return
0
<
width
&&
0
<
height
&&
nil
!=
superview
}
...
...
Sources/iOS/Switch.swift
View file @
55625112
...
...
@@ -61,7 +61,7 @@ public protocol SwitchDelegate {
@objc(Switch)
open
class
Switch
:
UIControl
{
/// Will
render
the view.
/// Will
layout
the view.
open
var
willLayout
:
Bool
{
return
0
<
width
&&
0
<
height
&&
nil
!=
superview
}
...
...
Sources/iOS/TextField.swift
View file @
55625112
...
...
@@ -60,6 +60,11 @@ public protocol TextFieldDelegate: UITextFieldDelegate {
}
open
class
TextField
:
UITextField
{
/// Will layout the view.
open
var
willLayout
:
Bool
{
return
0
<
width
&&
0
<
height
&&
nil
!=
superview
}
/// Default size when using AutoLayout.
open
override
var
intrinsicContentSize
:
CGSize
{
return
CGSize
(
width
:
width
,
height
:
32
)
...
...
@@ -79,6 +84,11 @@ open class TextField: UITextField {
}
}
/// A boolean indicating whether the text is empty.
open
var
isEmpty
:
Bool
{
return
true
==
text
?
.
isEmpty
}
/// The leftView width value.
open
var
leftViewWidth
:
CGFloat
{
guard
nil
!=
leftView
else
{
...
...
@@ -136,7 +146,7 @@ open class TextField: UITextField {
@IBInspectable
open
override
var
text
:
String
?
{
didSet
{
guard
true
==
text
?
.
isEmpty
else
{
guard
isEmpty
else
{
return
}
...
...
@@ -227,6 +237,9 @@ open class TextField: UITextField {
}
}
/// A reference to the clearIconButton.
open
private(set)
var
clearIconButton
:
IconButton
?
/// Enables the clearIconButton.
@IBInspectable
open
var
isClearIconButtonEnabled
:
Bool
{
...
...
@@ -252,7 +265,7 @@ open class TextField: UITextField {
rightView
=
clearIconButton
isClearIconButtonAutoHandled
=
isClearIconButtonAutoHandled
?
true
:
false
layout
Button
(
button
:
clearIconButton
)
layout
Subviews
(
)
}
}
...
...
@@ -269,6 +282,9 @@ open class TextField: UITextField {
clearIconButton
?
.
addTarget
(
self
,
action
:
#selector(
handleClearIconButton
)
,
for
:
.
touchUpInside
)
}
}
/// A reference to the visibilityIconButton.
open
private(set)
var
visibilityIconButton
:
IconButton
?
/// Enables the visibilityIconButton.
@IBInspectable
...
...
@@ -296,7 +312,7 @@ open class TextField: UITextField {
rightView
=
visibilityIconButton
isVisibilityIconButtonAutoHandled
=
isVisibilityIconButtonAutoHandled
?
true
:
false
layout
Button
(
button
:
visibilityIconButton
)
layout
Subviews
(
)
}
}
...
...
@@ -314,12 +330,6 @@ open class TextField: UITextField {
}
}
/// A reference to the clearIconButton.
open
private(set)
var
clearIconButton
:
IconButton
?
/// A reference to the visibilityIconButton.
open
private(set)
var
visibilityIconButton
:
IconButton
?
open
override
func
observeValue
(
forKeyPath
keyPath
:
String
?,
of
object
:
Any
?,
change
:
[
NSKeyValueChangeKey
:
Any
]?,
context
:
UnsafeMutableRawPointer
?)
{
guard
"placeholderLabel.text"
!=
keyPath
else
{
updatePlaceholderLabelColor
()
...
...
@@ -381,8 +391,9 @@ open class TextField: UITextField {
/// Handles the text editing did begin state.
@objc
open
func
handleEditingDidBegin
()
{
placeholderEditingDidBeginAnimation
()
dividerEditingDidBeginAnimation
()
placeholderEditingDidBeginAnimation
()
}
// Live updates the textField text.
...
...
@@ -394,8 +405,8 @@ open class TextField: UITextField {
/// Handles the text editing did end state.
@objc
open
func
handleEditingDidEnd
()
{
divi
derEditingDidEndAnimation
()
placehol
derEditingDidEndAnimation
()
placehol
derEditingDidEndAnimation
()
divi
derEditingDidEndAnimation
()
}
/// Handles the clearIconButton TouchUpInside event.
...
...
@@ -448,6 +459,10 @@ open class TextField: UITextField {
/// Ensures that the components are sized correctly.
open
func
reload
()
{
guard
willLayout
else
{
return
}
guard
!
isAnimating
else
{
return
}
...
...
@@ -465,7 +480,7 @@ open class TextField: UITextField {
let
w
=
leftViewWidth
let
h
=
0
==
height
?
intrinsicContentSize
.
height
:
height
guard
isEditing
||
false
==
text
?
.
isEmpty
||
!
isPlaceholderAnimated
else
{
guard
isEditing
||
!
isEmpty
||
!
isPlaceholderAnimated
else
{
placeholderLabel
.
frame
=
CGRect
(
x
:
w
,
y
:
0
,
width
:
width
-
w
,
height
:
h
)
return
}
...
...
@@ -523,7 +538,7 @@ open class TextField: UITextField {
open
func
dividerEditingDidBeginAnimation
()
{
dividerThickness
=
dividerActiveHeight
dividerColor
=
dividerActiveColor
}
}
/// The animation for the divider when editing ends.
open
func
dividerEditingDidEndAnimation
()
{
...
...
@@ -537,8 +552,7 @@ open class TextField: UITextField {
return
}
guard
placeholderLabel
.
transform
.
isIdentity
else
{
updatePlaceholderLabelColor
()
guard
isEmpty
&&
!
isAnimating
else
{
return
}
...
...
@@ -570,8 +584,7 @@ open class TextField: UITextField {
return
}
guard
!
placeholderLabel
.
transform
.
isIdentity
&&
true
==
text
?
.
isEmpty
else
{
updatePlaceholderLabelColor
()
guard
isEmpty
&&
!
isAnimating
else
{
return
}
...
...
@@ -614,7 +627,7 @@ open class TextField: UITextField {
/// Prepares the leftView.
private
func
prepareLeftView
()
{
leftView
?
.
contentMode
=
.
center
leftView
?
.
contentMode
=
.
left
}
/// Prepares the target handlers.
...
...
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